-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[Driver][ROCm][OpenMP] Fix default ockl linking for OpenMP. #126186
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@llvm/pr-subscribers-clang-driver @llvm/pr-subscribers-clang Author: Amit Kumar Pandey (ampandey-1995) ChangesASan gpu runtime (asanrtl.bc) linking is dependent on 'ockl.bc'. Link 'ockl.bc' only when ASan is enabled for openmp amdgpu offloading application. Full diff: https://github.com/llvm/llvm-project/pull/126186.diff 3 Files Affected:
diff --git a/clang/lib/Driver/ToolChains/AMDGPU.cpp b/clang/lib/Driver/ToolChains/AMDGPU.cpp
index e66e5a32e58acdc..62247842bcdfa5a 100644
--- a/clang/lib/Driver/ToolChains/AMDGPU.cpp
+++ b/clang/lib/Driver/ToolChains/AMDGPU.cpp
@@ -1014,7 +1014,12 @@ RocmInstallationDetector::getCommonBitcodeLibs(
bool isOpenMP = false) const {
llvm::SmallVector<ToolChain::BitCodeLibraryInfo, 12> BCLibs;
- auto GPUSanEnabled = [GPUSan]() { return std::get<bool>(GPUSan); };
+ // GPU Sanitizer currently only supports ASan and is enabled through host
+ // ASan.
+ auto GPUSanEnabled = [GPUSan]() {
+ return std::get<bool>(GPUSan) &&
+ std::get<const SanitizerArgs>(GPUSan).needsAsanRt();
+ };
auto AddBCLib = [&](ToolChain::BitCodeLibraryInfo BCLib,
bool Internalize = true) {
BCLib.ShouldInternalize = Internalize;
@@ -1066,7 +1071,7 @@ ROCMToolChain::getCommonDeviceLibNames(const llvm::opt::ArgList &DriverArgs,
// them all?
std::tuple<bool, const SanitizerArgs> GPUSan(
DriverArgs.hasFlag(options::OPT_fgpu_sanitize,
- options::OPT_fno_gpu_sanitize, false),
+ options::OPT_fno_gpu_sanitize, true),
getSanitizerArgs(DriverArgs));
bool DAZ = DriverArgs.hasFlag(options::OPT_fgpu_flush_denormals_to_zero,
options::OPT_fno_gpu_flush_denormals_to_zero,
@@ -1099,7 +1104,7 @@ bool AMDGPUToolChain::shouldSkipSanitizeOption(
return false;
if (!DriverArgs.hasFlag(options::OPT_fgpu_sanitize,
- options::OPT_fno_gpu_sanitize, false))
+ options::OPT_fno_gpu_sanitize, true))
return true;
auto &Diags = TC.getDriver().getDiags();
diff --git a/clang/test/Driver/amdgpu-openmp-sanitize-options.c b/clang/test/Driver/amdgpu-openmp-sanitize-options.c
index c28a758bfc0c5e8..50fae71f369bbf2 100644
--- a/clang/test/Driver/amdgpu-openmp-sanitize-options.c
+++ b/clang/test/Driver/amdgpu-openmp-sanitize-options.c
@@ -13,6 +13,11 @@
// RUN: | FileCheck --check-prefix=NOTSUPPORTED %s
// GPU ASan Enabled Test Cases
+
+// GPU ASan enabled through -fsanitize=address flag for amdgpu-arch [gfx908]
+// RUN: %clang -no-canonical-prefixes -### --target=x86_64-unknown-linux-gnu -fopenmp=libomp --offload-arch=gfx908 -fsanitize=address --rocm-path=%S/Inputs/rocm %s 2>&1 \
+// RUN: | FileCheck -check-prefixes=NOXNACK,GPUSAN %s
+
// ASan enabled for amdgpu-arch [gfx908]
// RUN: %clang -no-canonical-prefixes -### --target=x86_64-unknown-linux-gnu -fopenmp=libomp --offload-arch=gfx908 -fsanitize=address -fgpu-sanitize --rocm-path=%S/Inputs/rocm %s 2>&1 \
// RUN: | FileCheck -check-prefixes=NOXNACK,GPUSAN %s
diff --git a/clang/test/Driver/hip-sanitize-options.hip b/clang/test/Driver/hip-sanitize-options.hip
index 8a852867f5b3b34..8de0ee9e18426b6 100644
--- a/clang/test/Driver/hip-sanitize-options.hip
+++ b/clang/test/Driver/hip-sanitize-options.hip
@@ -1,5 +1,5 @@
// RUN: %clang -### --target=x86_64-unknown-linux-gnu --offload-arch=gfx900:xnack+ \
-// RUN: -fsanitize=address -fgpu-sanitize \
+// RUN: -fsanitize=address \
// RUN: -nogpuinc --rocm-path=%S/Inputs/rocm \
// RUN: %s 2>&1 | FileCheck -check-prefixes=NORDC %s
|
a1a255f
to
030e486
Compare
✅ With the latest revision this PR passed the C/C++ code formatter. |
030e486
to
43433af
Compare
ASan gpu runtime (asanrtl.bc) linking is dependent on 'ockl.bc'. Link 'ockl.bc' only when ASan is enabled for openmp amdgpu offloading application.
43433af
to
666f907
Compare
…126628) Reverts #126186 This broke the sanitizer buildbot: https://lab.llvm.org/buildbot/#/builders/55/builds/6846
…r OpenMP." (#126628) Reverts llvm/llvm-project#126186 This broke the sanitizer buildbot: https://lab.llvm.org/buildbot/#/builders/55/builds/6846
…lvm#126628) Reverts llvm#126186 This broke the sanitizer buildbot: https://lab.llvm.org/buildbot/#/builders/55/builds/6846
…lvm#126628) Reverts llvm#126186 This broke the sanitizer buildbot: https://lab.llvm.org/buildbot/#/builders/55/builds/6846
…lvm#126628) Reverts llvm#126186 This broke the sanitizer buildbot: https://lab.llvm.org/buildbot/#/builders/55/builds/6846
ASan gpu runtime (asanrtl.bc) linking is dependent on 'ockl.bc'. Link 'ockl.bc' only when ASan is enabled for openmp amdgpu offloading application.