]> granicus.if.org Git - llvm/commitdiff
Factor out a helper. NFC
authorSean Silva <chisophugis@gmail.com>
Sun, 12 Jun 2016 05:44:51 +0000 (05:44 +0000)
committerSean Silva <chisophugis@gmail.com>
Sun, 12 Jun 2016 05:44:51 +0000 (05:44 +0000)
Prep for porting to new PM.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272503 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/IPO/FunctionAttrs.cpp

index c757eb327d02fa3980f2fc4be590a638d641a2e6..7c14c20ba8929752204de145e0fa23ac5ecea5d0 100644 (file)
@@ -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<CallGraphWrapperPass>().getCallGraph();
   SmallVector<Function *, 16> Worklist;
   for (scc_iterator<CallGraph *> 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<CallGraphWrapperPass>().getCallGraph();
+
+  return deduceFunctionAttributeInRPO(M, CG);
+}