Skip to content

Commit 64b2b45

Browse files
committed
add comp flag asan-spir-shadow-bounds
1 parent 4f9c732 commit 64b2b45

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1742,19 +1742,21 @@ static bool isUnsupportedAMDGPUAddrspace(Value *Addr) {
17421742
}
17431743

17441744
static bool isUnsupportedDeviceGlobal(GlobalVariable *G) {
1745-
// Non image scope device globals are implemented by device USM, and the
1746-
// out-of-bounds check for them will be done by sanitizer USM part. So we
1747-
// exclude them here.
1748-
if (!G->hasAttribute("sycl-device-image-scope"))
1749-
return true;
1750-
17511745
// Skip instrumenting on "__AsanKernelMetadata" etc.
1752-
if (G->getName().starts_with("__Asan"))
1746+
if (G->getName().starts_with("__Asan") || G->getName().starts_with("__asan"))
17531747
return true;
17541748

17551749
if (G->getAddressSpace() == kSpirOffloadLocalAS)
17561750
return !ClSpirOffloadLocals;
17571751

1752+
// When shadow bounds check is disabled, we need to instrument all global
1753+
// variables that user code can access
1754+
if (ClSpirCheckShadowBounds)
1755+
return false;
1756+
1757+
// Non image scope device globals are implemented by device USM, and the
1758+
// out-of-bounds check for them will be done by sanitizer USM part. So we
1759+
// exclude them here.
17581760
Attribute Attr = G->getAttribute("sycl-device-image-scope");
17591761
return (!Attr.isStringAttribute() || Attr.getValueAsString() == "false");
17601762
}

sycl/test-e2e/AddressSanitizer/out-of-bounds/USM/arbitrary_access.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// REQUIRES: linux, gpu && level_zero
2-
// RUN: %{build} %device_asan_flags -O0 -g -o %t1.out
2+
// RUN: %{build} %device_asan_flags -Xarch_device -mllvm=-asan-spir-shadow-bounds=1 -O0 -g -o %t1.out
33
// RUN: %{run} not %t1.out 2>&1 | FileCheck %s
4-
// RUN: %{build} %device_asan_flags -O2 -g -o %t3.out
4+
// RUN: %{build} %device_asan_flags -Xarch_device -mllvm=-asan-spir-shadow-bounds=1 -O2 -g -o %t3.out
55
// RUN: %{run} not %t3.out 2>&1 | FileCheck %s
66

77
#include <sycl/detail/core.hpp>

0 commit comments

Comments
 (0)