[llvm] r272503 - Factor out a helper. NFC

Sean Silva via llvm-commits llvm-commits at lists.llvm.org
Sat Jun 11 22:44:51 PDT 2016


Author: silvas
Date: Sun Jun 12 00:44:51 2016
New Revision: 272503

URL: http://llvm.org/viewvc/llvm-project?rev=272503&view=rev
Log:
Factor out a helper. NFC

Prep for porting to new PM.

Modified:
    llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp

Modified: llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp?rev=272503&r1=272502&r2=272503&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp Sun Jun 12 00:44:51 2016
@@ -1203,10 +1203,7 @@ static bool addNoRecurseAttrsTopDown(Fun
   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::runO
   // 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::runO
 
   return Changed;
 }
+
+bool ReversePostOrderFunctionAttrs::runOnModule(Module &M) {
+  if (skipModule(M))
+    return false;
+
+  auto &CG = getAnalysis<CallGraphWrapperPass>().getCallGraph();
+
+  return deduceFunctionAttributeInRPO(M, CG);
+}




More information about the llvm-commits mailing list