Skip to content

Commit 2be11a1

Browse files
authored
[DevMSAN] Skip device globals without users (#16760)
1 parent f791cd1 commit 2be11a1

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -775,6 +775,8 @@ Constant *getOrCreateGlobalString(Module &M, StringRef Name, StringRef Value,
775775
}
776776

777777
static bool isUnsupportedDeviceGlobal(const GlobalVariable *G) {
778+
if (G->user_empty())
779+
return true;
778780
// Skip instrumenting on "__MsanKernelMetadata" etc.
779781
if (G->getName().starts_with("__Msan"))
780782
return true;

llvm/test/Instrumentation/MemorySanitizer/SPIRV/instrument_device_global.ll

+8
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,15 @@ target triple = "spir64-unknown-unknown"
44

55
@.str = external addrspace(1) constant [59 x i8]
66
@__spirv_BuiltInGlobalInvocationId = external addrspace(1) constant <3 x i64>
7+
@dev_global_no_users = dso_local addrspace(1) global { [4 x i32] } zeroinitializer
8+
9+
define spir_func void @_ZZZ4mainENKUlRN4sycl3_V17handlerEE_clES2_ENKUlvE_clEv() {
10+
entry:
11+
%call = call spir_func ptr addrspace(4) null(ptr addrspace(4) addrspacecast (ptr addrspace(1) @.str to ptr addrspace(4)), i64 0)
12+
ret void
13+
}
714

815
; CHECK: @__MsanDeviceGlobalMetadata
916
; CHECK-NOT: @__spirv_BuiltInGlobalInvocationId
17+
; CHECK-NOT: @dev_global_no_users
1018
; CHECK-SAME: @.str

0 commit comments

Comments
 (0)