[llvm] 87dadf0 - [Pipeline] Move some GlobalOpt/GlobalDCE runs into simplification pipeline

Arthur Eubanks via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 14 09:01:27 PDT 2023


Author: Arthur Eubanks
Date: 2023-03-14T09:01:14-07:00
New Revision: 87dadf0f5b06f08baa480633aeef0bc47d3a59a0

URL: https://github.com/llvm/llvm-project/commit/87dadf0f5b06f08baa480633aeef0bc47d3a59a0
DIFF: https://github.com/llvm/llvm-project/commit/87dadf0f5b06f08baa480633aeef0bc47d3a59a0.diff

LOG: [Pipeline] Move some GlobalOpt/GlobalDCE runs into simplification pipeline

These are very clearly more simplification than optimization.

Mostly NFC, except for some ordering around passes that don't really matter.

Reviewed By: nikic

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

Added: 
    

Modified: 
    llvm/lib/Passes/PassBuilderPipelines.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Passes/PassBuilderPipelines.cpp b/llvm/lib/Passes/PassBuilderPipelines.cpp
index 9efc16186c8f..c3a8506d2500 100644
--- a/llvm/lib/Passes/PassBuilderPipelines.cpp
+++ b/llvm/lib/Passes/PassBuilderPipelines.cpp
@@ -1072,6 +1072,14 @@ PassBuilder::buildModuleSimplificationPipeline(OptimizationLevel Level,
 
   MPM.addPass(CoroCleanupPass());
 
+  // Optimize globals now that functions are fully simplified.
+  MPM.addPass(GlobalOptPass());
+
+  // Remove dead code, except in the ThinLTO pre-link pipeline where we may want
+  // to keep available_externally functions.
+  if (Phase != ThinOrFullLTOPhase::ThinLTOPreLink)
+    MPM.addPass(GlobalDCEPass());
+
   if (EnableMemProfiler && Phase != ThinOrFullLTOPhase::ThinLTOPreLink) {
     MPM.addPass(createModuleToFunctionPassAdaptor(MemProfilerPass()));
     MPM.addPass(ModuleMemProfilerPass());
@@ -1227,10 +1235,6 @@ PassBuilder::buildModuleOptimizationPipeline(OptimizationLevel Level,
                            LTOPhase == ThinOrFullLTOPhase::FullLTOPreLink);
   ModulePassManager MPM;
 
-  // Optimize globals now that the module is fully simplified.
-  MPM.addPass(GlobalOptPass());
-  MPM.addPass(GlobalDCEPass());
-
   // Run partial inlining pass to partially inline functions that have
   // large bodies.
   if (RunPartialInlining)
@@ -1475,9 +1479,6 @@ PassBuilder::buildThinLTOPreLinkDefaultPipeline(OptimizationLevel Level) {
   if (RunPartialInlining)
     MPM.addPass(PartialInlinerPass());
 
-  // Reduce the size of the IR as much as possible.
-  MPM.addPass(GlobalOptPass());
-
   if (PGOOpt && PGOOpt->PseudoProbeForProfiling &&
       PGOOpt->Action == PGOOptions::SampleUse)
     MPM.addPass(PseudoProbeUpdatePass());


        


More information about the llvm-commits mailing list