Skip to content

Commit da9a703

Browse files
committed
[HIP] Fix -fno-gpu-sanitize
Fix a typo about -fno-gpu-sanitize handling and disable warnings when -fno-gpu-sanitize is specified. Reviewed by: Artem Belevich Differential Revision: https://reviews.llvm.org/D121302
1 parent 6730b44 commit da9a703

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

clang/lib/Driver/ToolChains/HIPAMD.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ static bool shouldSkipSanitizeOption(const ToolChain &TC,
4747
return false;
4848

4949
if (!DriverArgs.hasFlag(options::OPT_fgpu_sanitize,
50-
-options::OPT_fno_gpu_sanitize))
50+
options::OPT_fno_gpu_sanitize))
5151
return true;
5252

5353
auto &Diags = TC.getDriver().getDiags();
@@ -162,6 +162,8 @@ HIPAMDToolChain::HIPAMDToolChain(const Driver &D, const llvm::Triple &Triple,
162162
getProgramPaths().push_back(getDriver().Dir);
163163

164164
// Diagnose unsupported sanitizer options only once.
165+
if (!Args.hasFlag(options::OPT_fgpu_sanitize, options::OPT_fno_gpu_sanitize))
166+
return;
165167
for (auto A : Args.filtered(options::OPT_fsanitize_EQ)) {
166168
SanitizerMask K = parseSanitizerValue(A->getValue(), /*AllowGroups=*/false);
167169
if (K != SanitizerKind::Address)

clang/test/Driver/hip-sanitize-options.hip

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,20 @@
3535
// RUN: -fsanitize=leak -nogpuinc --rocm-path=%S/Inputs/rocm \
3636
// RUN: %s 2>&1 | FileCheck -check-prefixes=XNACKNEG %s
3737

38+
// Check -fno-gpu-sanitize with supported and unsupported GPU.
39+
// Sanitizer should be disabled for all GPU's and there should be no warnings about unsupported
40+
// GPU.
41+
42+
// RUN: %clang -### -target x86_64-unknown-linux-gnu --offload-arch=gfx900:xnack- \
43+
// RUN: --offload-arch=gfx900:xnack+ --offload-arch=gfx906 -fsanitize=address -fno-gpu-sanitize \
44+
// RUN: -fsanitize=leak -nogpuinc --rocm-path=%S/Inputs/rocm \
45+
// RUN: %s 2>&1 | FileCheck -check-prefixes=NOGPU %s
46+
47+
// RUN: %clang -### -target x86_64-unknown-linux-gnu --offload-arch=gfx900:xnack- \
48+
// RUN: --offload-arch=gfx900:xnack+ --offload-arch=gfx906 -fsanitize=address -fno-gpu-sanitize \
49+
// RUN: -fsanitize=leak -nogpuinc --rocm-path=%S/Inputs/rocm \
50+
// RUN: %s 2>&1 | FileCheck -check-prefixes=NOGPUNEG %s
51+
3852
// CHECK-NOT: {{"[^"]*clang[^"]*".* "-fcuda-is-device".* "-fsanitize=address"}}
3953
// CHECK-NOT: {{"[^"]*clang[^"]*".* "-fcuda-is-device".* "-mlink-bitcode-file" ".*asanrtl.bc"}}
4054
// CHECK-NOT: {{"[^"]*lld(\.exe){0,1}".* ".*hip.bc"}}
@@ -65,3 +79,22 @@
6579
// XNACKNEG-NOT: {{"[^"]*clang[^"]*".* "-mlink-bitcode-file" ".*asanrtl.bc".* "-target-cpu" "gfx900".* "-target-feature" "-xnack"}}
6680
// XNACKNEG-NOT: {{"[^"]*clang[^"]*".* "-mlink-bitcode-file" ".*asanrtl.bc".* "-target-cpu" "gfx906"}}
6781
// XNACKNEG-NOT: {{"[^"]*lld(\.exe){0,1}".* ".*hip.bc"}}
82+
83+
// NOGPU-DAG: {{"[^"]*clang[^"]*".* "-target-cpu" "gfx900".* "-target-feature" "\+xnack"}}
84+
// NOGPU-DAG: {{"[^"]*clang[^"]*".* "-target-cpu" "gfx900".* "-target-feature" "-xnack"}}
85+
// NOGPU-DAG: {{"[^"]*clang[^"]*".* "-target-cpu" "gfx906"}}
86+
// NOGPU-DAG: {{"[^"]*clang[^"]*".* "-triple" "x86_64-unknown-linux-gnu".* "-fsanitize=address,leak"}}
87+
// NOGPUNEG-NOT: warning: ignoring '-fsanitize=leak' option as it is not currently supported for target 'amdgcn-amd-amdhsa'
88+
// NOGPUNEG-NOT: warning: ignoring '-fsanitize=address' option as it is not currently supported for offload arch 'gfx900:xnack-'. Use it with an offload arch containing 'xnack+' instead
89+
// NOGPUNEG-NOT: warning: ignoring '-fsanitize=address' option as it is not currently supported for offload arch 'gfx906'. Use it with an offload arch containing 'xnack+' instead
90+
// NOGPUNEG-NOT: {{"[^"]*clang[^"]*".* "-mlink-bitcode-file" ".*asanrtl.bc".* "-target-cpu" "gfx900".* "-target-feature" "\+xnack".* "-fsanitize=address"}}
91+
// NOGPUNEG-NOT: {{"[^"]*clang[^"]*".* "-target-cpu" "gfx900".* "-target-feature" "\+xnack".* "-fsanitize=address,leak"}}
92+
// NOGPUNEG-NOT: {{"[^"]*clang[^"]*".* "-target-cpu" "gfx900".* "-target-feature" "-xnack".* "-fsanitize=address,leak"}}
93+
// NOGPUNEG-NOT: {{"[^"]*clang[^"]*".* "-target-cpu" "gfx906".* "-fsanitize=address,leak"}}
94+
// NOGPUNEG-NOT: {{"[^"]*clang[^"]*".* "-target-cpu" "gfx900".* "-target-feature" "\+xnack".* "-fsanitize=address"}}
95+
// NOGPUNEG-NOT: {{"[^"]*clang[^"]*".* "-target-cpu" "gfx900".* "-target-feature" "-xnack".* "-fsanitize=address"}}
96+
// NOGPUNEG-NOT: {{"[^"]*clang[^"]*".* "-target-cpu" "gfx906".* "-fsanitize=address"}}
97+
// NOGPUNEG-NOT: {{"[^"]*clang[^"]*".* "-mlink-bitcode-file" ".*asanrtl.bc".* "-target-cpu" "gfx900".* "-target-feature" "\+xnack"}}
98+
// NOGPUNEG-NOT: {{"[^"]*clang[^"]*".* "-mlink-bitcode-file" ".*asanrtl.bc".* "-target-cpu" "gfx900".* "-target-feature" "-xnack"}}
99+
// NOGPUNEG-NOT: {{"[^"]*clang[^"]*".* "-mlink-bitcode-file" ".*asanrtl.bc".* "-target-cpu" "gfx906"}}
100+
// NOGPUNEG-NOT: {{"[^"]*lld(\.exe){0,1}".* ".*hip.bc"}}

0 commit comments

Comments
 (0)