Skip to content

Commit 13a80f8

Browse files
authored
[DeviceSanitizer] Strip off pointer casts and inbounds GEPs (#13262)
Disable device sanitizer instrument following case: %0 = load i64, ptr addrspace(1) getelementptr inbounds (i8, ptr addrspace(1) @__spirv_BuiltInGlobalInvocationId, i64 8)
1 parent b963e89 commit 13a80f8

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1328,7 +1328,7 @@ static bool isUnsupportedSPIRAccess(Value *Addr, Function *Func) {
13281328
}
13291329

13301330
// All the rest address spaces: skip SPIR-V built-in varibles
1331-
auto *OrigValue = Addr->stripPointerCasts();
1331+
auto *OrigValue = Addr->stripInBoundsOffsets();
13321332
return OrigValue->getName().starts_with("__spirv_BuiltIn");
13331333
}
13341334

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
; RUN: opt < %s -passes=asan -asan-instrumentation-with-call-threshold=0 -asan-stack=0 -asan-globals=0 -S | FileCheck %s
2+
3+
target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-n8:16:32:64"
4+
target triple = "spir64-unknown-unknown"
5+
6+
@__spirv_BuiltInGlobalInvocationId = external addrspace(1) constant <3 x i64>
7+
8+
; Function Attrs: sanitize_address
9+
define spir_kernel void @_ZTSN4sycl3_V16detail19__pf_kernel_wrapperIZZ4mainENKUlRNS0_7handlerEE_clES4_E19bufferByRange2_initEE() #0 {
10+
entry:
11+
; CHECK-NOT: {{ __asan_load8.*__spirv_BuiltInGlobalInvocationId }}
12+
%0 = load i64, ptr addrspace(1) getelementptr inbounds (i8, ptr addrspace(1) @__spirv_BuiltInGlobalInvocationId, i64 8), align 8
13+
ret void
14+
}
15+
16+
attributes #0 = { sanitize_address }
17+

0 commit comments

Comments
 (0)