diff options
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/LTO/LTOCodeGenerator.cpp | 2 | ||||
| -rw-r--r-- | llvm/lib/Passes/PassRegistry.def | 1 | ||||
| -rw-r--r-- | llvm/lib/Transforms/IPO/FunctionAttrs.cpp | 38 | ||||
| -rw-r--r-- | llvm/lib/Transforms/IPO/IPO.cpp | 2 |
4 files changed, 23 insertions, 20 deletions
diff --git a/llvm/lib/LTO/LTOCodeGenerator.cpp b/llvm/lib/LTO/LTOCodeGenerator.cpp index 52634652932..4f556f9da03 100644 --- a/llvm/lib/LTO/LTOCodeGenerator.cpp +++ b/llvm/lib/LTO/LTOCodeGenerator.cpp @@ -122,7 +122,7 @@ void LTOCodeGenerator::initializeLTOPasses() { initializeSROA_DTPass(R); initializeSROA_SSAUpPass(R); initializePostOrderFunctionAttrsLegacyPassPass(R); - initializeReversePostOrderFunctionAttrsPass(R); + initializeReversePostOrderFunctionAttrsLegacyPassPass(R); initializeGlobalsAAWrapperPassPass(R); initializeLICMPass(R); initializeMergedLoadStoreMotionPass(R); diff --git a/llvm/lib/Passes/PassRegistry.def b/llvm/lib/Passes/PassRegistry.def index b72fcad5c54..34d09a21082 100644 --- a/llvm/lib/Passes/PassRegistry.def +++ b/llvm/lib/Passes/PassRegistry.def @@ -56,6 +56,7 @@ MODULE_PASS("print-profile-summary", ProfileSummaryPrinterPass(dbgs())) MODULE_PASS("print-callgraph", CallGraphPrinterPass(dbgs())) MODULE_PASS("print", PrintModulePass(dbgs())) MODULE_PASS("print-lcg", LazyCallGraphPrinterPass(dbgs())) +MODULE_PASS("rpo-functionattrs", ReversePostOrderFunctionAttrsPass()) MODULE_PASS("sample-profile", SampleProfileLoaderPass()) MODULE_PASS("strip-dead-prototypes", StripDeadPrototypesPass()) MODULE_PASS("verify", VerifierPass()) diff --git a/llvm/lib/Transforms/IPO/FunctionAttrs.cpp b/llvm/lib/Transforms/IPO/FunctionAttrs.cpp index 7c14c20ba89..f437235a28d 100644 --- a/llvm/lib/Transforms/IPO/FunctionAttrs.cpp +++ b/llvm/lib/Transforms/IPO/FunctionAttrs.cpp @@ -1137,20 +1137,10 @@ bool PostOrderFunctionAttrsLegacyPass::runOnSCC(CallGraphSCC &SCC) { } namespace { -/// A pass to do RPO deduction and propagation of function attributes. -/// -/// This pass provides a general RPO or "top down" propagation of -/// function attributes. For a few (rare) cases, we can deduce significantly -/// more about function attributes by working in RPO, so this pass -/// provides the compliment to the post-order pass above where the majority of -/// deduction is performed. -// FIXME: Currently there is no RPO CGSCC pass structure to slide into and so -// this is a boring module pass, but eventually it should be an RPO CGSCC pass -// when such infrastructure is available. -struct ReversePostOrderFunctionAttrs : public ModulePass { +struct ReversePostOrderFunctionAttrsLegacyPass : public ModulePass { static char ID; // Pass identification, replacement for typeid - ReversePostOrderFunctionAttrs() : ModulePass(ID) { - initializeReversePostOrderFunctionAttrsPass(*PassRegistry::getPassRegistry()); + ReversePostOrderFunctionAttrsLegacyPass() : ModulePass(ID) { + initializeReversePostOrderFunctionAttrsLegacyPassPass(*PassRegistry::getPassRegistry()); } bool runOnModule(Module &M) override; @@ -1163,15 +1153,15 @@ struct ReversePostOrderFunctionAttrs : public ModulePass { }; } -char ReversePostOrderFunctionAttrs::ID = 0; -INITIALIZE_PASS_BEGIN(ReversePostOrderFunctionAttrs, "rpo-functionattrs", +char ReversePostOrderFunctionAttrsLegacyPass::ID = 0; +INITIALIZE_PASS_BEGIN(ReversePostOrderFunctionAttrsLegacyPass, "rpo-functionattrs", "Deduce function attributes in RPO", false, false) INITIALIZE_PASS_DEPENDENCY(CallGraphWrapperPass) -INITIALIZE_PASS_END(ReversePostOrderFunctionAttrs, "rpo-functionattrs", +INITIALIZE_PASS_END(ReversePostOrderFunctionAttrsLegacyPass, "rpo-functionattrs", "Deduce function attributes in RPO", false, false) Pass *llvm::createReversePostOrderFunctionAttrsPass() { - return new ReversePostOrderFunctionAttrs(); + return new ReversePostOrderFunctionAttrsLegacyPass(); } static bool addNoRecurseAttrsTopDown(Function &F) { @@ -1229,7 +1219,7 @@ static bool deduceFunctionAttributeInRPO(Module &M, CallGraph &CG) { return Changed; } -bool ReversePostOrderFunctionAttrs::runOnModule(Module &M) { +bool ReversePostOrderFunctionAttrsLegacyPass::runOnModule(Module &M) { if (skipModule(M)) return false; @@ -1237,3 +1227,15 @@ bool ReversePostOrderFunctionAttrs::runOnModule(Module &M) { return deduceFunctionAttributeInRPO(M, CG); } + +PreservedAnalyses +ReversePostOrderFunctionAttrsPass::run(Module &M, AnalysisManager<Module> &AM) { + auto &CG = AM.getResult<CallGraphAnalysis>(M); + + bool Changed = deduceFunctionAttributeInRPO(M, CG); + if (!Changed) + return PreservedAnalyses::all(); + PreservedAnalyses PA; + PA.preserve<CallGraphAnalysis>(); + return PA; +} diff --git a/llvm/lib/Transforms/IPO/IPO.cpp b/llvm/lib/Transforms/IPO/IPO.cpp index 157a24e7d29..c80f08787bf 100644 --- a/llvm/lib/Transforms/IPO/IPO.cpp +++ b/llvm/lib/Transforms/IPO/IPO.cpp @@ -43,7 +43,7 @@ void llvm::initializeIPO(PassRegistry &Registry) { initializeMergeFunctionsPass(Registry); initializePartialInlinerPass(Registry); initializePostOrderFunctionAttrsLegacyPassPass(Registry); - initializeReversePostOrderFunctionAttrsPass(Registry); + initializeReversePostOrderFunctionAttrsLegacyPassPass(Registry); initializePruneEHPass(Registry); initializeStripDeadPrototypesLegacyPassPass(Registry); initializeStripSymbolsPass(Registry); |

