mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-10-22 04:22:57 +02:00
Refactor the PassManagerBuilder: extract a "addFunctionSimplificationPasses()"
It is intended to contains the passes run over a function after the inliner is done with a function and before it moves to its callers. From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 260603
This commit is contained in:
parent
1f0b6a8459
commit
ce40bf909a
@ -160,7 +160,7 @@ private:
|
|||||||
void addEarlyLTOOptimizationPasses(legacy::PassManagerBase &PM);
|
void addEarlyLTOOptimizationPasses(legacy::PassManagerBase &PM);
|
||||||
void addLateLTOOptimizationPasses(legacy::PassManagerBase &PM);
|
void addLateLTOOptimizationPasses(legacy::PassManagerBase &PM);
|
||||||
void addPGOInstrPasses(legacy::PassManagerBase &MPM);
|
void addPGOInstrPasses(legacy::PassManagerBase &MPM);
|
||||||
|
void addFunctionSimplificationPasses(legacy::PassManagerBase &MPM);
|
||||||
public:
|
public:
|
||||||
/// populateFunctionPassManager - This fills in the function pass manager,
|
/// populateFunctionPassManager - This fills in the function pass manager,
|
||||||
/// which is expected to be run on each function immediately as it is
|
/// which is expected to be run on each function immediately as it is
|
||||||
|
@ -215,79 +215,8 @@ void PassManagerBuilder::addPGOInstrPasses(legacy::PassManagerBase &MPM) {
|
|||||||
if (!PGOInstrUse.empty())
|
if (!PGOInstrUse.empty())
|
||||||
MPM.add(createPGOInstrumentationUsePass(PGOInstrUse));
|
MPM.add(createPGOInstrumentationUsePass(PGOInstrUse));
|
||||||
}
|
}
|
||||||
|
void PassManagerBuilder::addFunctionSimplificationPasses(
|
||||||
void PassManagerBuilder::populateModulePassManager(
|
|
||||||
legacy::PassManagerBase &MPM) {
|
legacy::PassManagerBase &MPM) {
|
||||||
// Allow forcing function attributes as a debugging and tuning aid.
|
|
||||||
MPM.add(createForceFunctionAttrsLegacyPass());
|
|
||||||
|
|
||||||
// If all optimizations are disabled, just run the always-inline pass and,
|
|
||||||
// if enabled, the function merging pass.
|
|
||||||
if (OptLevel == 0) {
|
|
||||||
addPGOInstrPasses(MPM);
|
|
||||||
if (Inliner) {
|
|
||||||
MPM.add(Inliner);
|
|
||||||
Inliner = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
// FIXME: The BarrierNoopPass is a HACK! The inliner pass above implicitly
|
|
||||||
// creates a CGSCC pass manager, but we don't want to add extensions into
|
|
||||||
// that pass manager. To prevent this we insert a no-op module pass to reset
|
|
||||||
// the pass manager to get the same behavior as EP_OptimizerLast in non-O0
|
|
||||||
// builds. The function merging pass is
|
|
||||||
if (MergeFunctions)
|
|
||||||
MPM.add(createMergeFunctionsPass());
|
|
||||||
else if (!GlobalExtensions->empty() || !Extensions.empty())
|
|
||||||
MPM.add(createBarrierNoopPass());
|
|
||||||
|
|
||||||
addExtensionsToPM(EP_EnabledOnOptLevel0, MPM);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add LibraryInfo if we have some.
|
|
||||||
if (LibraryInfo)
|
|
||||||
MPM.add(new TargetLibraryInfoWrapperPass(*LibraryInfo));
|
|
||||||
|
|
||||||
addInitialAliasAnalysisPasses(MPM);
|
|
||||||
|
|
||||||
if (!DisableUnitAtATime) {
|
|
||||||
// Infer attributes about declarations if possible.
|
|
||||||
MPM.add(createInferFunctionAttrsLegacyPass());
|
|
||||||
|
|
||||||
addExtensionsToPM(EP_ModuleOptimizerEarly, MPM);
|
|
||||||
|
|
||||||
MPM.add(createIPSCCPPass()); // IP SCCP
|
|
||||||
MPM.add(createGlobalOptimizerPass()); // Optimize out global vars
|
|
||||||
// Promote any localized global vars
|
|
||||||
MPM.add(createPromoteMemoryToRegisterPass());
|
|
||||||
|
|
||||||
MPM.add(createDeadArgEliminationPass()); // Dead argument elimination
|
|
||||||
|
|
||||||
MPM.add(createInstructionCombiningPass());// Clean up after IPCP & DAE
|
|
||||||
addExtensionsToPM(EP_Peephole, MPM);
|
|
||||||
MPM.add(createCFGSimplificationPass()); // Clean up after IPCP & DAE
|
|
||||||
}
|
|
||||||
|
|
||||||
addPGOInstrPasses(MPM);
|
|
||||||
|
|
||||||
if (EnableNonLTOGlobalsModRef)
|
|
||||||
// We add a module alias analysis pass here. In part due to bugs in the
|
|
||||||
// analysis infrastructure this "works" in that the analysis stays alive
|
|
||||||
// for the entire SCC pass run below.
|
|
||||||
MPM.add(createGlobalsAAWrapperPass());
|
|
||||||
|
|
||||||
// Start of CallGraph SCC passes.
|
|
||||||
if (!DisableUnitAtATime)
|
|
||||||
MPM.add(createPruneEHPass()); // Remove dead EH info
|
|
||||||
if (Inliner) {
|
|
||||||
MPM.add(Inliner);
|
|
||||||
Inliner = nullptr;
|
|
||||||
}
|
|
||||||
if (!DisableUnitAtATime)
|
|
||||||
MPM.add(createPostOrderFunctionAttrsPass());
|
|
||||||
if (OptLevel > 2)
|
|
||||||
MPM.add(createArgumentPromotionPass()); // Scalarize uninlined fn args
|
|
||||||
|
|
||||||
// Start of function pass.
|
// Start of function pass.
|
||||||
// Break up aggregate allocas, using SSAUpdater.
|
// Break up aggregate allocas, using SSAUpdater.
|
||||||
if (UseNewSROA)
|
if (UseNewSROA)
|
||||||
@ -373,6 +302,81 @@ void PassManagerBuilder::populateModulePassManager(
|
|||||||
MPM.add(createCFGSimplificationPass()); // Merge & remove BBs
|
MPM.add(createCFGSimplificationPass()); // Merge & remove BBs
|
||||||
MPM.add(createInstructionCombiningPass()); // Clean up after everything.
|
MPM.add(createInstructionCombiningPass()); // Clean up after everything.
|
||||||
addExtensionsToPM(EP_Peephole, MPM);
|
addExtensionsToPM(EP_Peephole, MPM);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PassManagerBuilder::populateModulePassManager(
|
||||||
|
legacy::PassManagerBase &MPM) {
|
||||||
|
// Allow forcing function attributes as a debugging and tuning aid.
|
||||||
|
MPM.add(createForceFunctionAttrsLegacyPass());
|
||||||
|
|
||||||
|
// If all optimizations are disabled, just run the always-inline pass and,
|
||||||
|
// if enabled, the function merging pass.
|
||||||
|
if (OptLevel == 0) {
|
||||||
|
addPGOInstrPasses(MPM);
|
||||||
|
if (Inliner) {
|
||||||
|
MPM.add(Inliner);
|
||||||
|
Inliner = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
// FIXME: The BarrierNoopPass is a HACK! The inliner pass above implicitly
|
||||||
|
// creates a CGSCC pass manager, but we don't want to add extensions into
|
||||||
|
// that pass manager. To prevent this we insert a no-op module pass to reset
|
||||||
|
// the pass manager to get the same behavior as EP_OptimizerLast in non-O0
|
||||||
|
// builds. The function merging pass is
|
||||||
|
if (MergeFunctions)
|
||||||
|
MPM.add(createMergeFunctionsPass());
|
||||||
|
else if (!GlobalExtensions->empty() || !Extensions.empty())
|
||||||
|
MPM.add(createBarrierNoopPass());
|
||||||
|
|
||||||
|
addExtensionsToPM(EP_EnabledOnOptLevel0, MPM);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add LibraryInfo if we have some.
|
||||||
|
if (LibraryInfo)
|
||||||
|
MPM.add(new TargetLibraryInfoWrapperPass(*LibraryInfo));
|
||||||
|
|
||||||
|
addInitialAliasAnalysisPasses(MPM);
|
||||||
|
|
||||||
|
if (!DisableUnitAtATime) {
|
||||||
|
// Infer attributes about declarations if possible.
|
||||||
|
MPM.add(createInferFunctionAttrsLegacyPass());
|
||||||
|
|
||||||
|
addExtensionsToPM(EP_ModuleOptimizerEarly, MPM);
|
||||||
|
|
||||||
|
MPM.add(createIPSCCPPass()); // IP SCCP
|
||||||
|
MPM.add(createGlobalOptimizerPass()); // Optimize out global vars
|
||||||
|
// Promote any localized global vars
|
||||||
|
MPM.add(createPromoteMemoryToRegisterPass());
|
||||||
|
|
||||||
|
MPM.add(createDeadArgEliminationPass()); // Dead argument elimination
|
||||||
|
|
||||||
|
MPM.add(createInstructionCombiningPass());// Clean up after IPCP & DAE
|
||||||
|
addExtensionsToPM(EP_Peephole, MPM);
|
||||||
|
MPM.add(createCFGSimplificationPass()); // Clean up after IPCP & DAE
|
||||||
|
}
|
||||||
|
|
||||||
|
addPGOInstrPasses(MPM);
|
||||||
|
|
||||||
|
if (EnableNonLTOGlobalsModRef)
|
||||||
|
// We add a module alias analysis pass here. In part due to bugs in the
|
||||||
|
// analysis infrastructure this "works" in that the analysis stays alive
|
||||||
|
// for the entire SCC pass run below.
|
||||||
|
MPM.add(createGlobalsAAWrapperPass());
|
||||||
|
|
||||||
|
// Start of CallGraph SCC passes.
|
||||||
|
if (!DisableUnitAtATime)
|
||||||
|
MPM.add(createPruneEHPass()); // Remove dead EH info
|
||||||
|
if (Inliner) {
|
||||||
|
MPM.add(Inliner);
|
||||||
|
Inliner = nullptr;
|
||||||
|
}
|
||||||
|
if (!DisableUnitAtATime)
|
||||||
|
MPM.add(createPostOrderFunctionAttrsPass());
|
||||||
|
if (OptLevel > 2)
|
||||||
|
MPM.add(createArgumentPromotionPass()); // Scalarize uninlined fn args
|
||||||
|
|
||||||
|
addFunctionSimplificationPasses(MPM);
|
||||||
|
|
||||||
// FIXME: This is a HACK! The inliner pass above implicitly creates a CGSCC
|
// FIXME: This is a HACK! The inliner pass above implicitly creates a CGSCC
|
||||||
// pass manager that we are specifically trying to avoid. To prevent this
|
// pass manager that we are specifically trying to avoid. To prevent this
|
||||||
|
Loading…
Reference in New Issue
Block a user