Skip to content

Commit 7a83f21

Browse files
authored
[DeviceSanitizer] Skip adding device sanitizers internal variable to bundler symbol table (#17399)
`__MsanDeviceGlobalMetadata` etc are sanitizer internal variables, and should not be bundled to the symbol table.
1 parent bf20e6e commit 7a83f21

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

clang/lib/Driver/OffloadBundler.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,10 @@ class ObjectFileHandler final : public FileHandler {
700700
if (SF->isIR() &&
701701
(Name == "llvm.used" || Name == "llvm.compiler.used" ||
702702
Name == "__AsanDeviceGlobalMetadata" ||
703-
Name == "__AsanKernelMetadata" || Name == "__MsanKernelMetadata"))
703+
Name == "__MsanDeviceGlobalMetadata" ||
704+
Name == "__TsanDeviceGlobalMetadata" ||
705+
Name == "__AsanKernelMetadata" || Name == "__MsanKernelMetadata" ||
706+
Name == "__TsanKernelMetadata"))
704707
continue;
705708

706709
// Add symbol name with the target prefix to the buffer.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// RUN: llvm-as %s.ll -o %t-in.bc
2+
// RUN: %clang -c -o %t-in.o %s
3+
// RUN: clang-offload-bundler -type=o -targets=openmp-spir64_gen,host-x86_64-unknown-linux-gnu -input=%t-in.bc -input=%t-in.o -output=%t-out.o
4+
// RUN: llvm-readobj --string-dump=.tgtsym %t-out.o | FileCheck %s.ll
5+
6+
int main() {return 0;}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
@__AsanKernelMetadata = global i64 0
2+
;CHECK-NOT: __AsanKernelMetadata
3+
@__MsanKernelMetadata = global i64 0
4+
;CHECK-NOT: __MsanKernelMetadata
5+
@__TsanKernelMetadata = global i64 0
6+
;CHECK-NOT: __TsanKernelMetadata
7+
@__AsanDeviceGlobalMetadata = global i64 0
8+
;CHECK-NOT: __AsanDeviceGlobalMetadata
9+
@__MsanDeviceGlobalMetadata = global i64 0
10+
;CHECK-NOT: __MsanDeviceGlobalMetadata
11+
@__TsanDeviceGlobalMetadata = global i64 0
12+
;CHECK-NOT: __TsanDeviceGlobalMetadata
13+
14+
@not_skipping = global i64 0
15+
;CHECK: not_skipping
16+
17+
@__another_global = global i64 0
18+
;CHECK: __another_global

0 commit comments

Comments
 (0)