[PATCH] D57793: [NewPM][MSan] Add sanitizer at O0

Philip Pfaffe via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 5 15:18:58 PST 2019


philip.pfaffe created this revision.
philip.pfaffe added reviewers: chandlerc, leonardchan, fedor.sergeev.
Herald added a subscriber: bollu.
Herald added a project: LLVM.

New-PM's msan currently is not inserted at O0, unlike with the legacy PM.


Repository:
  rL LLVM

https://reviews.llvm.org/D57793

Files:
  clang/lib/CodeGen/BackendUtil.cpp


Index: clang/lib/CodeGen/BackendUtil.cpp
===================================================================
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -917,6 +917,14 @@
   }
 }
 
+FunctionPassManager addSanitizersAtO0() {
+  FunctionPassManager FPM;
+  if (LangOpts.Sanitize.has(SanitizerKind::Memory))
+    FPM.addPass(MemorySanitizerPass());
+
+  return FPM;
+}
+
 /// A clean version of `EmitAssembly` that uses the new pass manager.
 ///
 /// Not all features are currently supported in this system, but where
@@ -1036,7 +1044,7 @@
       if (LangOpts.Sanitize.has(SanitizerKind::Memory))
         PB.registerOptimizerLastEPCallback(
             [](FunctionPassManager &FPM, PassBuilder::OptimizationLevel Level) {
-              FPM.addPass(MemorySanitizerPass({}));
+              FPM.addPass(MemorySanitizerPass());
             });
       if (LangOpts.Sanitize.has(SanitizerKind::Thread))
         PB.registerOptimizerLastEPCallback(
@@ -1063,6 +1071,8 @@
                                                CodeGenOpts.DebugPassManager);
       }
     }
+    if (Level == PassBuilder::O0)
+      MPM.addPass(addSanitizersAtO0());
   }
 
   // FIXME: We still use the legacy pass manager to do code generation. We


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D57793.185423.patch
Type: text/x-patch
Size: 1256 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190205/80220ec9/attachment.bin>


More information about the llvm-commits mailing list