Skip to content

Commit

Permalink
Factor out a helper. NFC
Browse files Browse the repository at this point in the history
Prep for porting to new PM.

llvm-svn: 272503
  • Loading branch information
chisophugis committed Jun 12, 2016
1 parent 43de178 commit adc7939
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions llvm/lib/Transforms/IPO/FunctionAttrs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1203,18 +1203,14 @@ 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
// because we need to combine SCC detection and the PO walk of the call
// 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<CallGraphWrapperPass>().getCallGraph();
SmallVector<Function *, 16> Worklist;
for (scc_iterator<CallGraph *> I = scc_begin(&CG); !I.isAtEnd(); ++I) {
if (I->size() != 1)
Expand All @@ -1232,3 +1228,12 @@ bool ReversePostOrderFunctionAttrs::runOnModule(Module &M) {

return Changed;
}

bool ReversePostOrderFunctionAttrs::runOnModule(Module &M) {
if (skipModule(M))
return false;

auto &CG = getAnalysis<CallGraphWrapperPass>().getCallGraph();

return deduceFunctionAttributeInRPO(M, CG);
}

0 comments on commit adc7939

Please sign in to comment.