r354431 - [NewPM] Add other sanitizers at O0

Leonard Chan via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 19 19:50:11 PST 2019


Author: leonardchan
Date: Tue Feb 19 19:50:11 2019
New Revision: 354431

URL: http://llvm.org/viewvc/llvm-project?rev=354431&view=rev
Log:
[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

Modified:
    cfe/trunk/lib/CodeGen/BackendUtil.cpp
    cfe/trunk/test/Driver/msan.c
    cfe/trunk/test/Driver/tsan.c

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=354431&r1=354430&r2=354431&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Tue Feb 19 19:50:11 2019
@@ -932,6 +932,14 @@ void addSanitizersAtO0(ModulePassManager
         /*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.

Modified: cfe/trunk/test/Driver/msan.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/msan.c?rev=354431&r1=354430&r2=354431&view=diff
==============================================================================
--- cfe/trunk/test/Driver/msan.c (original)
+++ cfe/trunk/test/Driver/msan.c Tue Feb 19 19:50:11 2019
@@ -15,6 +15,18 @@
 
 // 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

Modified: cfe/trunk/test/Driver/tsan.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/tsan.c?rev=354431&r1=354430&r2=354431&view=diff
==============================================================================
--- cfe/trunk/test/Driver/tsan.c (original)
+++ cfe/trunk/test/Driver/tsan.c Tue Feb 19 19:50:11 2019
@@ -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




More information about the cfe-commits mailing list