[clang] [OpenMP][ASan] Enable ASan Instrumentation for AMDGPUOpenMPToolChain. (PR #124754)
Amit Kumar Pandey via cfe-commits
cfe-commits at lists.llvm.org
Tue Jan 28 09:06:44 PST 2025
================
@@ -37,6 +37,16 @@ AMDGPUOpenMPToolChain::AMDGPUOpenMPToolChain(const Driver &D,
// Lookup binaries into the driver directory, this is used to
// discover the 'amdgpu-arch' executable.
getProgramPaths().push_back(getDriver().Dir);
+ // Diagnose unsupported sanitizer options only once.
+ if (!Args.hasFlag(options::OPT_fgpu_sanitize, options::OPT_fno_gpu_sanitize,
----------------
ampandey-1995 wrote:
Yes. We actually had a flag ```**-fgpu-sanitize**``` from the beginning of ASan project which actually used by every toolchain(hip,openmp,opencl) to enable device code instrumentation.
Using ```**-fsanitize=address**``` enables asan instrumentation for host code , now for device when ```**-fgpu-sanitize**[Default always on]``` can be used alongwith ```**-fsanitize=address**``` but since it value is by default on so using ```-fgpu-sanitize``` only(without -fsanitize=address) would be a no-op effect for both host and device code.
We only use the negative ```-fno-gpu-sanitize``` to disable device code asan instrumentation leaving only the host code asan instrumented.
BTW, other checks are also done in progression i.e in ```shouldSkipSanitizeFunction``` which checks for ```:xnack+``` feature also in ```--offload-arch=``` option.
In short asan instrumentation for both host and device is done using ```-fsanitize=address``` , there are inbuilt clang-driver checks for hip,openmp,opencl which if successful allows -fsanitize=address to pass forward to device toolchain cmd line job invocation otherwise it is skipped.
If any edge tests cases missing please let me know @b-sumner , @yxsamliu , @jhuber6 ?
https://github.com/llvm/llvm-project/pull/124754
More information about the cfe-commits
mailing list