diff --git a/projects/clr/rocclr/compiler/lib/utils/OPTIONS.def b/projects/clr/rocclr/compiler/lib/utils/OPTIONS.def index a8a906365c..85724813b6 100644 --- a/projects/clr/rocclr/compiler/lib/utils/OPTIONS.def +++ b/projects/clr/rocclr/compiler/lib/utils/OPTIONS.def @@ -1275,6 +1275,13 @@ OPTION(OT_UINT32, \ 5, 4, 5, NULL, \ "Specify code object ABI version. Allowed values are 4, and 5. Defaults to 5. (COMGR only)") +// -fsanitze=tool +NOPTION(OT_CSTRING, \ + OA_RUNTIME|OVA_REQUIRED|OA_SEPARATOR_EQUAL|OFA_PREFIX_F, \ + "sanitize", NULL, \ + FSanitize, \ + 0, 0, 0, "address", \ + "Enable sanitizer instrumentation") /* Do not remove the following line. Any option should be added above this line. diff --git a/projects/clr/rocclr/compiler/lib/utils/options.cpp b/projects/clr/rocclr/compiler/lib/utils/options.cpp index 50cdbd5a6c..f238d22480 100644 --- a/projects/clr/rocclr/compiler/lib/utils/options.cpp +++ b/projects/clr/rocclr/compiler/lib/utils/options.cpp @@ -1005,6 +1005,10 @@ processOption(int OptDescTableIx, Options& Opts, const std::string& Value, break; + case OID_FSanitize: + if (sval != NULL) + Opts.clangOptions.push_back("-fsanitize=" + std::string(sval)); + break; default: break; } diff --git a/projects/clr/rocclr/device/device.cpp b/projects/clr/rocclr/device/device.cpp index dfc7d09928..23d68e2e2c 100644 --- a/projects/clr/rocclr/device/device.cpp +++ b/projects/clr/rocclr/device/device.cpp @@ -576,6 +576,11 @@ bool Device::BlitProgram::create(amd::Device* device, const std::string& extraKe if (device->settings().kernel_arg_opt_) { opt += " -Wb,-amdgpu-kernarg-preload-count=8 "; } +#if defined(__clang__) +#if __has_feature(address_sanitizer) + opt += " -fsanitize=address "; +#endif +#endif if ((retval = program_->build(devices, opt.c_str(), nullptr, nullptr, GPU_DUMP_BLIT_KERNELS)) != CL_SUCCESS) { DevLogPrintfError("Build failed for Kernel: %s with error code %d\n",