[PATCH] D29376: LTO: align the Monolithic LTO optimization pipeline on the ThinLTO and O2/O3 one

Mehdi AMINI via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 31 23:19:31 PST 2017

mehdi_amini created this revision.
Herald added a subscriber: Prazek.

18 months ago, we tried to do the same thing but the increased
link-time was not judged acceptable because the lack of scaling
for LTO. Now that ThinLTO is there for any project that cares
about scaling and build time performance in general, we can be
more aggressive with Monolithic LTO for projects that are either
small enough or are willing to pay the extra compile time.

Aligning the pipeline on https://reviews.llvm.org/owners/package/2//https://reviews.llvm.org/owners/package/3/ (and ThinLTO), makes the pipeline
maintenance easier: making the pipeline evolve for ThinLTO will
benefit Monolithic LTO and vice-versa. Also any misoptimization
for one use case is likely to affect the other and fixing it will
benefit all. Studying the difference in performance between LTO
and ThinLTO while doing this helped us last year to improve some
analyses that helped non-LTO builds.

Note: I haven't had time to benchmark this recently, so I put it up
for review so that everyone can run their own private benchmarks and
we can evaluate any identified defficiencies.



Index: llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
--- llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
+++ llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
@@ -504,11 +504,12 @@
   // If we are planning to perform ThinLTO later, let's not bloat the code with
   // unrolling/vectorization/... now. We'll first run the inliner + CGSCC passes
   // during ThinLTO and perform the rest of the optimizations afterward.
-  if (PrepareForThinLTO) {
+  if (PrepareForThinLTO || PrepareForLTO) {
     // Reduce the size of the IR as much as possible.
-    // Rename anon globals to be able to export them in the summary.
-    MPM.add(createNameAnonGlobalPass());
+    if (PrepareForThinLTO)
+      // Rename anon globals to be able to export them in the summary.
+      MPM.add(createNameAnonGlobalPass());
@@ -839,30 +840,8 @@
 void PassManagerBuilder::populateLTOPassManager(legacy::PassManagerBase &PM) {
-  PM.add(new TargetLibraryInfoWrapperPass());
-  if (VerifyInput)
-    PM.add(createVerifierPass());
-  if (OptLevel != 0)
-    addLTOOptimizationPasses(PM);
-  // Create a function that performs CFI checks for cross-DSO calls with targets
-  // in the current module.
-  PM.add(createCrossDSOCFIPass());
-  // Lower type metadata and the type.test intrinsic. This pass supports Clang's
-  // control flow integrity mechanisms (-fsanitize=cfi*) and needs to run at
-  // link time if CFI is enabled. The pass does nothing if CFI is disabled.
-  PM.add(createLowerTypeTestsPass(Summary ? LowerTypeTestsSummaryAction::Export
-                                          : LowerTypeTestsSummaryAction::None,
-                                  Summary));
-  if (OptLevel != 0)
-    addLateLTOOptimizationPasses(PM);
-  if (VerifyOutput)
-    PM.add(createVerifierPass());
+  // Just use the same pipeline as ThinLTO
+  populateThinLTOPassManager(PM);
 inline PassManagerBuilder *unwrap(LLVMPassManagerBuilderRef P) {

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D29376.86581.patch
Type: text/x-patch
Size: 2065 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170201/038e0bd3/attachment.bin>

More information about the llvm-commits mailing list