Skip to content

Commit ec9a0e3

Browse files
[IPO] Remove addLTOOptimizationPasses and addLateLTOOptimizationPasses (NFC)
The last uses were removed on Apr 15, 2022 in commit 2e6ac54. Differential Revision: https://reviews.llvm.org/D129460
1 parent a45dd3d commit ec9a0e3

File tree

3 files changed

+1
-181
lines changed

3 files changed

+1
-181
lines changed

llvm/include/llvm/Transforms/IPO/PassManagerBuilder.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,6 @@ class PassManagerBuilder {
211211
void addExtensionsToPM(ExtensionPointTy ETy,
212212
legacy::PassManagerBase &PM) const;
213213
void addInitialAliasAnalysisPasses(legacy::PassManagerBase &PM) const;
214-
void addLTOOptimizationPasses(legacy::PassManagerBase &PM);
215-
void addLateLTOOptimizationPasses(legacy::PassManagerBase &PM);
216214
void addFunctionSimplificationPasses(legacy::PassManagerBase &MPM);
217215
void addVectorPasses(legacy::PassManagerBase &PM, bool IsFullLTO);
218216

llvm/lib/Passes/PassBuilderPipelines.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1728,8 +1728,7 @@ PassBuilder::buildLTODefaultPipeline(OptimizationLevel Level,
17281728
// in ICP (which is performed earlier than this in the regular LTO pipeline).
17291729
MPM.addPass(LowerTypeTestsPass(nullptr, nullptr, true));
17301730

1731-
// Enable splitting late in the FullLTO post-link pipeline. This is done in
1732-
// the same stage in the old pass manager (\ref addLateLTOOptimizationPasses).
1731+
// Enable splitting late in the FullLTO post-link pipeline.
17331732
if (EnableHotColdSplit)
17341733
MPM.addPass(HotColdSplittingPass());
17351734

llvm/lib/Transforms/IPO/PassManagerBuilder.cpp

Lines changed: 0 additions & 177 deletions
Original file line numberDiff line numberDiff line change
@@ -898,183 +898,6 @@ void PassManagerBuilder::populateModulePassManager(
898898
MPM.add(createAnnotationRemarksLegacyPass());
899899
}
900900

901-
void PassManagerBuilder::addLTOOptimizationPasses(legacy::PassManagerBase &PM) {
902-
// Load sample profile before running the LTO optimization pipeline.
903-
if (!PGOSampleUse.empty()) {
904-
PM.add(createPruneEHPass());
905-
PM.add(createSampleProfileLoaderPass(PGOSampleUse));
906-
}
907-
908-
// Remove unused virtual tables to improve the quality of code generated by
909-
// whole-program devirtualization and bitset lowering.
910-
PM.add(createGlobalDCEPass());
911-
912-
// Provide AliasAnalysis services for optimizations.
913-
addInitialAliasAnalysisPasses(PM);
914-
915-
// Allow forcing function attributes as a debugging and tuning aid.
916-
PM.add(createForceFunctionAttrsLegacyPass());
917-
918-
// Infer attributes about declarations if possible.
919-
PM.add(createInferFunctionAttrsLegacyPass());
920-
921-
if (OptLevel > 1) {
922-
// Split call-site with more constrained arguments.
923-
PM.add(createCallSiteSplittingPass());
924-
925-
// Propage constant function arguments by specializing the functions.
926-
if (EnableFunctionSpecialization && OptLevel > 2)
927-
PM.add(createFunctionSpecializationPass());
928-
929-
// Propagate constants at call sites into the functions they call. This
930-
// opens opportunities for globalopt (and inlining) by substituting function
931-
// pointers passed as arguments to direct uses of functions.
932-
PM.add(createIPSCCPPass());
933-
934-
// Attach metadata to indirect call sites indicating the set of functions
935-
// they may target at run-time. This should follow IPSCCP.
936-
PM.add(createCalledValuePropagationPass());
937-
938-
// Infer attributes on declarations, call sites, arguments, etc.
939-
if (AttributorRun & AttributorRunOption::MODULE)
940-
PM.add(createAttributorLegacyPass());
941-
}
942-
943-
// Infer attributes about definitions. The readnone attribute in particular is
944-
// required for virtual constant propagation.
945-
PM.add(createPostOrderFunctionAttrsLegacyPass());
946-
PM.add(createReversePostOrderFunctionAttrsPass());
947-
948-
// Split globals using inrange annotations on GEP indices. This can help
949-
// improve the quality of generated code when virtual constant propagation or
950-
// control flow integrity are enabled.
951-
PM.add(createGlobalSplitPass());
952-
953-
// Apply whole-program devirtualization and virtual constant propagation.
954-
PM.add(createWholeProgramDevirtPass(ExportSummary, nullptr));
955-
956-
// That's all we need at opt level 1.
957-
if (OptLevel == 1)
958-
return;
959-
960-
// Now that we internalized some globals, see if we can hack on them!
961-
PM.add(createGlobalOptimizerPass());
962-
// Promote any localized global vars.
963-
PM.add(createPromoteMemoryToRegisterPass());
964-
965-
// Linking modules together can lead to duplicated global constants, only
966-
// keep one copy of each constant.
967-
PM.add(createConstantMergePass());
968-
969-
// Remove unused arguments from functions.
970-
PM.add(createDeadArgEliminationPass());
971-
972-
// Reduce the code after globalopt and ipsccp. Both can open up significant
973-
// simplification opportunities, and both can propagate functions through
974-
// function pointers. When this happens, we often have to resolve varargs
975-
// calls, etc, so let instcombine do this.
976-
if (OptLevel > 2)
977-
PM.add(createAggressiveInstCombinerPass());
978-
PM.add(createInstructionCombiningPass());
979-
addExtensionsToPM(EP_Peephole, PM);
980-
981-
// Inline small functions
982-
bool RunInliner = Inliner;
983-
if (RunInliner) {
984-
PM.add(Inliner);
985-
Inliner = nullptr;
986-
}
987-
988-
PM.add(createPruneEHPass()); // Remove dead EH info.
989-
990-
// Infer attributes on declarations, call sites, arguments, etc. for an SCC.
991-
if (AttributorRun & AttributorRunOption::CGSCC)
992-
PM.add(createAttributorCGSCCLegacyPass());
993-
994-
// Try to perform OpenMP specific optimizations. This is a (quick!) no-op if
995-
// there are no OpenMP runtime calls present in the module.
996-
if (OptLevel > 1)
997-
PM.add(createOpenMPOptCGSCCLegacyPass());
998-
999-
// Optimize globals again if we ran the inliner.
1000-
if (RunInliner)
1001-
PM.add(createGlobalOptimizerPass());
1002-
PM.add(createGlobalDCEPass()); // Remove dead functions.
1003-
1004-
// The IPO passes may leave cruft around. Clean up after them.
1005-
PM.add(createInstructionCombiningPass());
1006-
addExtensionsToPM(EP_Peephole, PM);
1007-
PM.add(createJumpThreadingPass());
1008-
1009-
// Break up allocas
1010-
PM.add(createSROAPass());
1011-
1012-
// LTO provides additional opportunities for tailcall elimination due to
1013-
// link-time inlining, and visibility of nocapture attribute.
1014-
if (OptLevel > 1)
1015-
PM.add(createTailCallEliminationPass());
1016-
1017-
// Infer attributes on declarations, call sites, arguments, etc.
1018-
PM.add(createPostOrderFunctionAttrsLegacyPass()); // Add nocapture.
1019-
// Run a few AA driven optimizations here and now, to cleanup the code.
1020-
PM.add(createGlobalsAAWrapperPass()); // IP alias analysis.
1021-
1022-
PM.add(createLICMPass(LicmMssaOptCap, LicmMssaNoAccForPromotionCap,
1023-
/*AllowSpeculation=*/true));
1024-
PM.add(NewGVN ? createNewGVNPass()
1025-
: createGVNPass(DisableGVNLoadPRE)); // Remove redundancies.
1026-
PM.add(createMemCpyOptPass()); // Remove dead memcpys.
1027-
1028-
// Nuke dead stores.
1029-
PM.add(createDeadStoreEliminationPass());
1030-
PM.add(createMergedLoadStoreMotionPass()); // Merge ld/st in diamonds.
1031-
1032-
// More loops are countable; try to optimize them.
1033-
if (EnableLoopFlatten)
1034-
PM.add(createLoopFlattenPass());
1035-
PM.add(createIndVarSimplifyPass());
1036-
PM.add(createLoopDeletionPass());
1037-
if (EnableLoopInterchange)
1038-
PM.add(createLoopInterchangePass());
1039-
1040-
if (EnableConstraintElimination)
1041-
PM.add(createConstraintEliminationPass());
1042-
1043-
// Unroll small loops and perform peeling.
1044-
PM.add(createSimpleLoopUnrollPass(OptLevel, DisableUnrollLoops,
1045-
ForgetAllSCEVInLoopUnroll));
1046-
PM.add(createLoopDistributePass());
1047-
1048-
addVectorPasses(PM, /* IsFullLTO */ true);
1049-
1050-
addExtensionsToPM(EP_Peephole, PM);
1051-
1052-
PM.add(createJumpThreadingPass());
1053-
}
1054-
1055-
void PassManagerBuilder::addLateLTOOptimizationPasses(
1056-
legacy::PassManagerBase &PM) {
1057-
// See comment in the new PM for justification of scheduling splitting at
1058-
// this stage (\ref buildLTODefaultPipeline).
1059-
if (EnableHotColdSplit)
1060-
PM.add(createHotColdSplittingPass());
1061-
1062-
// Delete basic blocks, which optimization passes may have killed.
1063-
PM.add(
1064-
createCFGSimplificationPass(SimplifyCFGOptions().hoistCommonInsts(true)));
1065-
1066-
// Drop bodies of available externally objects to improve GlobalDCE.
1067-
PM.add(createEliminateAvailableExternallyPass());
1068-
1069-
// Now that we have optimized the program, discard unreachable functions.
1070-
PM.add(createGlobalDCEPass());
1071-
1072-
// FIXME: this is profitable (for compiler time) to do at -O0 too, but
1073-
// currently it damages debug info.
1074-
if (MergeFunctions)
1075-
PM.add(createMergeFunctionsPass());
1076-
}
1077-
1078901
LLVMPassManagerBuilderRef LLVMPassManagerBuilderCreate() {
1079902
PassManagerBuilder *PMB = new PassManagerBuilder();
1080903
return wrap(PMB);

0 commit comments

Comments
 (0)