From 918df98aed2a4d22b1c8f8117fbe1ec24f14031b Mon Sep 17 00:00:00 2001 From: Sean Silva Date: Sun, 12 Jun 2016 05:44:51 +0000 Subject: [PATCH] Factor out a helper. NFC Prep for porting to new PM. llvm-svn: 272503 --- lib/Transforms/IPO/FunctionAttrs.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/Transforms/IPO/FunctionAttrs.cpp b/lib/Transforms/IPO/FunctionAttrs.cpp index c757eb327d0..7c14c20ba89 100644 --- a/lib/Transforms/IPO/FunctionAttrs.cpp +++ b/lib/Transforms/IPO/FunctionAttrs.cpp @@ -1203,10 +1203,7 @@ static bool addNoRecurseAttrsTopDown(Function &F) { return setDoesNotRecurse(F); } -bool ReversePostOrderFunctionAttrs::runOnModule(Module &M) { - if (skipModule(M)) - return false; - +static bool deduceFunctionAttributeInRPO(Module &M, CallGraph &CG) { // We only have a post-order SCC traversal (because SCCs are inherently // discovered in post-order), so we accumulate them in a vector and then walk // it in reverse. This is simpler than using the RPO iterator infrastructure @@ -1214,7 +1211,6 @@ bool ReversePostOrderFunctionAttrs::runOnModule(Module &M) { // graph. We can also cheat egregiously because we're primarily interested in // synthesizing norecurse and so we can only save the singular SCCs as SCCs // with multiple functions in them will clearly be recursive. - auto &CG = getAnalysis().getCallGraph(); SmallVector Worklist; for (scc_iterator I = scc_begin(&CG); !I.isAtEnd(); ++I) { if (I->size() != 1) @@ -1232,3 +1228,12 @@ bool ReversePostOrderFunctionAttrs::runOnModule(Module &M) { return Changed; } + +bool ReversePostOrderFunctionAttrs::runOnModule(Module &M) { + if (skipModule(M)) + return false; + + auto &CG = getAnalysis().getCallGraph(); + + return deduceFunctionAttributeInRPO(M, CG); +}