[ThinLTO] Ensure sanitizer passes are run
authorTeresa Johnson <tejohnson@google.com>
Wed, 8 Nov 2017 19:45:52 +0000 (19:45 +0000)
committerTeresa Johnson <tejohnson@google.com>
Wed, 8 Nov 2017 19:45:52 +0000 (19:45 +0000)
Summary:
In ThinLTO compilation, we exit populateModulePassManager early and
were not adding PM extension passes meant to run at the end of the
pipeline. This includes sanitizer passes. Add these passes before
the early exit.

A test will be added to projects/compiler-rt.

Reviewers: pcc

Subscribers: mehdi_amini, inglorion, llvm-commits

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

llvm-svn: 317714

llvm/lib/Transforms/IPO/PassManagerBuilder.cpp

index b8ff614..5d37366 100644 (file)
@@ -548,6 +548,9 @@ void PassManagerBuilder::populateModulePassManager(
   // unrolling/vectorization/... now. We'll first run the inliner + CGSCC passes
   // during ThinLTO and perform the rest of the optimizations afterward.
   if (PrepareForThinLTO) {
+    // Ensure we perform any last passes, but do so before renaming anonymous
+    // globals in case the passes add any.
+    addExtensionsToPM(EP_OptimizerLast, MPM);
     // Rename anon globals to be able to export them in the summary.
     MPM.add(createNameAnonGlobalPass());
     return;