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

Arthur Eubanks via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 13 10:52:04 PDT 2023


aeubanks created this revision.
Herald added a subscriber: hiraditya.
Herald added a project: All.
aeubanks requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

These are very clearly more simplification than optimization.

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D145967

Files:
  llvm/lib/Passes/PassBuilderPipelines.cpp


Index: llvm/lib/Passes/PassBuilderPipelines.cpp
===================================================================
--- llvm/lib/Passes/PassBuilderPipelines.cpp
+++ llvm/lib/Passes/PassBuilderPipelines.cpp
@@ -1072,6 +1072,14 @@
 
   MPM.addPass(CoroCleanupPass());
 
+  // Optimize globals now that the module is 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 @@
                            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 @@
   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());


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D145967.504752.patch
Type: text/x-patch
Size: 1475 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230313/8b83b054/attachment.bin>


More information about the llvm-commits mailing list