Skip to content

Commit 1a240ed

Browse files
committedFeb 20, 2019
[NewPM] Add other sanitizers at O0
This allows for MSan and TSan to be used without optimizations required. Differential Revision: https://reviews.llvm.org/D58424 llvm-svn: 354431
1 parent 303217e commit 1a240ed

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed
 

‎clang/lib/CodeGen/BackendUtil.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -932,6 +932,14 @@ void addSanitizersAtO0(ModulePassManager &MPM, const Triple &TargetTriple,
932932
/*CompileKernel=*/false, Recover, ModuleUseAfterScope,
933933
CodeGenOpts.SanitizeAddressUseOdrIndicator));
934934
}
935+
936+
if (LangOpts.Sanitize.has(SanitizerKind::Memory)) {
937+
MPM.addPass(createModuleToFunctionPassAdaptor(MemorySanitizerPass({})));
938+
}
939+
940+
if (LangOpts.Sanitize.has(SanitizerKind::Thread)) {
941+
MPM.addPass(createModuleToFunctionPassAdaptor(ThreadSanitizerPass()));
942+
}
935943
}
936944

937945
/// A clean version of `EmitAssembly` that uses the new pass manager.

‎clang/test/Driver/msan.c

+12
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,18 @@
1515

1616
// Verify that -fsanitize=memory and -fsanitize=kernel-memory invoke MSan/KMSAN instrumentation.
1717

18+
// Also check that this works with the new pass manager with and without
19+
// optimization
20+
// RUN: %clang -target x86_64-unknown-linux -fexperimental-new-pass-manager -fsanitize=memory %s -S -emit-llvm -o - | FileCheck %s --check-prefix=CHECK-MSAN
21+
// RUN: %clang -O1 -target x86_64-unknown-linux -fexperimental-new-pass-manager -fsanitize=memory %s -S -emit-llvm -o - | FileCheck %s --check-prefix=CHECK-MSAN
22+
// RUN: %clang -O2 -target x86_64-unknown-linux -fexperimental-new-pass-manager -fsanitize=memory %s -S -emit-llvm -o - | FileCheck %s --check-prefix=CHECK-MSAN
23+
// RUN: %clang -O3 -target x86_64-unknown-linux -fexperimental-new-pass-manager -fsanitize=memory %s -S -emit-llvm -o - | FileCheck %s --check-prefix=CHECK-MSAN
24+
25+
// RUN: %clang -fexperimental-new-pass-manager -target mips64-linux-gnu -fsanitize=memory %s -S -emit-llvm -o - | FileCheck %s --check-prefix=CHECK-MSAN
26+
// RUN: %clang -fexperimental-new-pass-manager -target mips64el-unknown-linux-gnu -fsanitize=memory %s -S -emit-llvm -o - | FileCheck %s --check-prefix=CHECK-MSAN
27+
// RUN: %clang -fexperimental-new-pass-manager -target powerpc64-unknown-linux-gnu -fsanitize=memory %s -S -emit-llvm -o - | FileCheck %s --check-prefix=CHECK-MSAN
28+
// RUN: %clang -fexperimental-new-pass-manager -target powerpc64le-unknown-linux-gnu -fsanitize=memory %s -S -emit-llvm -o - | FileCheck %s --check-prefix=CHECK-MSAN
29+
1830
int foo(int *a) { return *a; }
1931
// CHECK-MSAN: __msan_init
2032
// CHECK-KMSAN: __msan_get_context_state

‎clang/test/Driver/tsan.c

+8
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,13 @@
55
// RUN: %clang -target x86_64-unknown-linux -fsanitize=thread %s -S -emit-llvm -o - | FileCheck %s
66
// Verify that -fsanitize=thread invokes tsan instrumentation.
77

8+
// Also check that this works with the new pass manager with and without
9+
// optimization
10+
// RUN: %clang -fexperimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=thread %s -S -emit-llvm -o - | FileCheck %s
11+
// RUN: %clang -O1 -fexperimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=thread %s -S -emit-llvm -o - | FileCheck %s
12+
// RUN: %clang -O2 -fexperimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=thread %s -S -emit-llvm -o - | FileCheck %s
13+
// RUN: %clang -O3 -fexperimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=thread %s -S -emit-llvm -o - | FileCheck %s
14+
// RUN: %clang -fexperimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=thread %s -S -emit-llvm -o - | FileCheck %s
15+
816
int foo(int *a) { return *a; }
917
// CHECK: __tsan_init

0 commit comments

Comments
 (0)
Please sign in to comment.