]> granicus.if.org Git - clang/commitdiff
[NewPM] Add other sanitizers at O0
authorLeonard Chan <leonardchan@google.com>
Wed, 20 Feb 2019 03:50:11 +0000 (03:50 +0000)
committerLeonard Chan <leonardchan@google.com>
Wed, 20 Feb 2019 03:50:11 +0000 (03:50 +0000)
This allows for MSan and TSan to be used without optimizations required.

Differential Revision: https://reviews.llvm.org/D58424

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@354431 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/BackendUtil.cpp
test/Driver/msan.c
test/Driver/tsan.c

index d86e24ff2dd35918d40df10d766676856490e18e..8f9ea093c9624a33cece9bd8eadfb1ba2427d94d 100644 (file)
@@ -932,6 +932,14 @@ void addSanitizersAtO0(ModulePassManager &MPM, const Triple &TargetTriple,
         /*CompileKernel=*/false, Recover, ModuleUseAfterScope,
         CodeGenOpts.SanitizeAddressUseOdrIndicator));
   }
+
+  if (LangOpts.Sanitize.has(SanitizerKind::Memory)) {
+    MPM.addPass(createModuleToFunctionPassAdaptor(MemorySanitizerPass({})));
+  }
+
+  if (LangOpts.Sanitize.has(SanitizerKind::Thread)) {
+    MPM.addPass(createModuleToFunctionPassAdaptor(ThreadSanitizerPass()));
+  }
 }
 
 /// A clean version of `EmitAssembly` that uses the new pass manager.
index d810f4ca14d8a2d1abebe77c45b4190e050b8884..6e66a5396e09c6a1d0fb7680c16ccf6ff7c2481f 100644 (file)
 
 // Verify that -fsanitize=memory and -fsanitize=kernel-memory invoke MSan/KMSAN instrumentation.
 
+// Also check that this works with the new pass manager with and without
+// optimization
+// RUN: %clang     -target x86_64-unknown-linux -fexperimental-new-pass-manager -fsanitize=memory %s -S -emit-llvm -o - | FileCheck %s --check-prefix=CHECK-MSAN
+// 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
+// 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
+// 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
+
+// RUN: %clang -fexperimental-new-pass-manager -target mips64-linux-gnu -fsanitize=memory %s -S -emit-llvm -o - | FileCheck %s --check-prefix=CHECK-MSAN
+// RUN: %clang -fexperimental-new-pass-manager -target mips64el-unknown-linux-gnu -fsanitize=memory %s -S -emit-llvm -o - | FileCheck %s --check-prefix=CHECK-MSAN
+// RUN: %clang -fexperimental-new-pass-manager -target powerpc64-unknown-linux-gnu -fsanitize=memory %s -S -emit-llvm -o - | FileCheck %s --check-prefix=CHECK-MSAN
+// RUN: %clang -fexperimental-new-pass-manager -target powerpc64le-unknown-linux-gnu -fsanitize=memory %s -S -emit-llvm -o - | FileCheck %s --check-prefix=CHECK-MSAN
+
 int foo(int *a) { return *a; }
 // CHECK-MSAN: __msan_init
 // CHECK-KMSAN: __msan_get_context_state
index 82a0785c07ac366bf54bcf05682943563f5da72c..163375234820d83289ebc862bfc7eec56957688e 100644 (file)
@@ -5,5 +5,13 @@
 // RUN: %clang     -target x86_64-unknown-linux -fsanitize=thread  %s -S -emit-llvm -o - | FileCheck %s
 // Verify that -fsanitize=thread invokes tsan instrumentation.
 
+// Also check that this works with the new pass manager with and without
+// optimization
+// RUN: %clang     -fexperimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=thread %s -S -emit-llvm -o - | FileCheck %s
+// RUN: %clang -O1 -fexperimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=thread %s -S -emit-llvm -o - | FileCheck %s
+// RUN: %clang -O2 -fexperimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=thread %s -S -emit-llvm -o - | FileCheck %s
+// RUN: %clang -O3 -fexperimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=thread %s -S -emit-llvm -o - | FileCheck %s
+// RUN: %clang     -fexperimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=thread %s -S -emit-llvm -o - | FileCheck %s
+
 int foo(int *a) { return *a; }
 // CHECK: __tsan_init