Skip to content

Commit 38818a4

Browse files
authored
[sycl-rel] Cherry-pick sanitizer patches (#18885)
Cherry-pick commits that reached the internal branch between intel/llvm cutoff and release branch pulldown. Included patches: --- [DeviceSanitizer][Coverity] die when fail to create context (#17600) There is uncaught exception through logger creation in sanitizer layer `context_t` 's creation. We catch exceptions here and die if the creation of sanitizer layer context fails. Patch-by: Wu Yingcong <[email protected]> --- [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. Patch-by: Wu Yingcong <[email protected]>
1 parent 3ed6d31 commit 38818a4

File tree

4 files changed

+35
-2
lines changed

4 files changed

+35
-2
lines changed

clang/lib/Driver/OffloadBundler.cpp

Lines changed: 4 additions & 1 deletion
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.
Lines changed: 6 additions & 0 deletions
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;}
Lines changed: 18 additions & 0 deletions
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

unified-runtime/source/loader/layers/sanitizer/ur_sanitizer_layer.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,13 @@
1616
#include "msan/msan_ddi.hpp"
1717

1818
namespace ur_sanitizer_layer {
19-
context_t *getContext() { return context_t::get_direct(); }
19+
context_t *getContext() {
20+
try {
21+
return context_t::get_direct();
22+
} catch (...) {
23+
die("Failed to get sanitizer context.");
24+
}
25+
}
2026

2127
///////////////////////////////////////////////////////////////////////////////
2228
context_t::context_t()

0 commit comments

Comments
 (0)