[PATCH] D58424: [NewPM] Add other sanitizers at O0

2019-02-19 Thread Leonard Chan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL354431: [NewPM] Add other sanitizers at O0 (authored by 
leonardchan, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D58424?vs=187492&id=187506#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58424/new/

https://reviews.llvm.org/D58424

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


Index: cfe/trunk/lib/CodeGen/BackendUtil.cpp
===
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp
@@ -932,6 +932,14 @@
 /*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: cfe/trunk/test/Driver/tsan.c
===
--- cfe/trunk/test/Driver/tsan.c
+++ cfe/trunk/test/Driver/tsan.c
@@ -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
Index: cfe/trunk/test/Driver/msan.c
===
--- cfe/trunk/test/Driver/msan.c
+++ cfe/trunk/test/Driver/msan.c
@@ -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


Index: cfe/trunk/lib/CodeGen/BackendUtil.cpp
===
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp
@@ -932,6 +932,14 @@
 /*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: cfe/trunk/test/Driver/tsan.c
===

[PATCH] D58424: [NewPM] Add other sanitizers at O0

2019-02-19 Thread Chandler Carruth via Phabricator via cfe-commits
chandlerc accepted this revision.
chandlerc added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58424/new/

https://reviews.llvm.org/D58424



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D58424: [NewPM] Add other sanitizers at O0

2019-02-19 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan created this revision.
leonardchan added reviewers: chandlerc, philip.pfaffe, fedor.sergeev.
leonardchan added a project: clang.

This allows for MSan and TSan to be used without optimizations required.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D58424

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  clang/test/Driver/msan.c
  clang/test/Driver/tsan.c


Index: clang/test/Driver/tsan.c
===
--- clang/test/Driver/tsan.c
+++ clang/test/Driver/tsan.c
@@ -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
Index: clang/test/Driver/msan.c
===
--- clang/test/Driver/msan.c
+++ clang/test/Driver/msan.c
@@ -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
Index: clang/lib/CodeGen/BackendUtil.cpp
===
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -932,6 +932,14 @@
 /*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: clang/test/Driver/tsan.c
===
--- clang/test/Driver/tsan.c
+++ clang/test/Driver/tsan.c
@@ -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