[llvm-branch-commits] [llvm-branch] r101698 - in /llvm/branches/Apple/Morbo: include/llvm/ADT/SCCIterator.h include/llvm/CallGraphSCCPass.h include/llvm/Transforms/IPO/InlinerPass.h lib/Analysis/IPA/CallGraphSCCPass.cpp lib/Transforms/IPO/ArgumentPromotion.cpp lib/Transforms/IPO/Inliner.cpp lib/Transforms/IPO/PruneEH.cpp lib/Transforms/IPO/StructRetPromotion.cpp tools/opt/opt.cpp unittests/VMCore/PassManagerTest.cpp

Dale Johannesen dalej at apple.com
Sat Apr 17 21:57:30 PDT 2010


Author: johannes
Date: Sat Apr 17 23:57:30 2010
New Revision: 101698

URL: http://llvm.org/viewvc/llvm-project?rev=101698&view=rev
Log:
Revert 101682.


Modified:
    llvm/branches/Apple/Morbo/include/llvm/ADT/SCCIterator.h
    llvm/branches/Apple/Morbo/include/llvm/CallGraphSCCPass.h
    llvm/branches/Apple/Morbo/include/llvm/Transforms/IPO/InlinerPass.h
    llvm/branches/Apple/Morbo/lib/Analysis/IPA/CallGraphSCCPass.cpp
    llvm/branches/Apple/Morbo/lib/Transforms/IPO/ArgumentPromotion.cpp
    llvm/branches/Apple/Morbo/lib/Transforms/IPO/Inliner.cpp
    llvm/branches/Apple/Morbo/lib/Transforms/IPO/PruneEH.cpp
    llvm/branches/Apple/Morbo/lib/Transforms/IPO/StructRetPromotion.cpp
    llvm/branches/Apple/Morbo/tools/opt/opt.cpp
    llvm/branches/Apple/Morbo/unittests/VMCore/PassManagerTest.cpp

Modified: llvm/branches/Apple/Morbo/include/llvm/ADT/SCCIterator.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Morbo/include/llvm/ADT/SCCIterator.h?rev=101698&r1=101697&r2=101698&view=diff
==============================================================================
--- llvm/branches/Apple/Morbo/include/llvm/ADT/SCCIterator.h (original)
+++ llvm/branches/Apple/Morbo/include/llvm/ADT/SCCIterator.h Sat Apr 17 23:57:30 2010
@@ -66,7 +66,7 @@
   std::vector<unsigned> MinVisitNumStack;
 
   // A single "visit" within the non-recursive DFS traversal.
-  void DFSVisitOne(NodeType *N) {
+  void DFSVisitOne(NodeType* N) {
     ++visitNum;                         // Global counter for the visit order
     nodeVisitNumbers[N] = visitNum;
     SCCNodeStack.push_back(N);
@@ -83,7 +83,7 @@
       // TOS has at least one more child so continue DFS
       NodeType *childN = *VisitStack.back().second++;
       if (!nodeVisitNumbers.count(childN)) {
-        // this node has never been seen.
+        // this node has never been seen
         DFSVisitOne(childN);
       } else {
         unsigned childNum = nodeVisitNumbers[childN];
@@ -136,11 +136,11 @@
   typedef scc_iterator<GraphT, GT> _Self;
 
   // Provide static "constructors"...
-  static inline _Self begin(const GraphT &G){return _Self(GT::getEntryNode(G));}
-  static inline _Self end  (const GraphT &G) { return _Self(); }
+  static inline _Self begin(const GraphT& G) { return _Self(GT::getEntryNode(G)); }
+  static inline _Self end  (const GraphT& G) { return _Self(); }
 
-  // Direct loop termination test: I.isAtEnd() is more efficient than I == end()
-  inline bool isAtEnd() const {
+  // Direct loop termination test (I.fini() is more efficient than I == end())
+  inline bool fini() const {
     assert(!CurrentSCC.empty() || VisitStack.empty());
     return CurrentSCC.empty();
   }
@@ -181,14 +181,6 @@
         return true;
     return false;
   }
-                           
-  /// ReplaceNode - This informs the scc_iterator that the specified Old node
-  /// has been deleted, and New is to be used in its place.
-  void ReplaceNode(NodeType *Old, NodeType *New) {
-    assert(nodeVisitNumbers.count(Old) && "Old not in scc_iterator?");
-    nodeVisitNumbers[New] = nodeVisitNumbers[Old];
-    nodeVisitNumbers.erase(Old);
-  }
 };
 
 

Modified: llvm/branches/Apple/Morbo/include/llvm/CallGraphSCCPass.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Morbo/include/llvm/CallGraphSCCPass.h?rev=101698&r1=101697&r2=101698&view=diff
==============================================================================
--- llvm/branches/Apple/Morbo/include/llvm/CallGraphSCCPass.h (original)
+++ llvm/branches/Apple/Morbo/include/llvm/CallGraphSCCPass.h Sat Apr 17 23:57:30 2010
@@ -29,17 +29,12 @@
 class CallGraphNode;
 class CallGraph;
 class PMStack;
-class CallGraphSCC;
-  
-class CallGraphSCCPass : public Pass {
-public:
+
+struct CallGraphSCCPass : public Pass {
+
   explicit CallGraphSCCPass(intptr_t pid) : Pass(PT_CallGraphSCC, pid) {}
   explicit CallGraphSCCPass(void *pid) : Pass(PT_CallGraphSCC, pid) {}
 
-  /// createPrinterPass - Get a pass that prints the Module
-  /// corresponding to a CallGraph.
-  Pass *createPrinterPass(raw_ostream &O, const std::string &Banner) const;
-
   /// doInitialization - This method is called before the SCC's of the program
   /// has been processed, allowing the pass to do initialization as necessary.
   virtual bool doInitialization(CallGraph &CG) {
@@ -54,7 +49,7 @@
   /// SCC passes that add or delete functions to the SCC are required to update
   /// the SCC list, otherwise stale pointers may be dereferenced.
   ///
-  virtual bool runOnSCC(CallGraphSCC &SCC) = 0;
+  virtual bool runOnSCC(std::vector<CallGraphNode *> &SCC) = 0;
 
   /// doFinalization - This method is called after the SCC's of the program has
   /// been processed, allowing the pass to do final cleanup as necessary.
@@ -64,7 +59,7 @@
 
   /// Assign pass manager to manager this pass
   virtual void assignPassManager(PMStack &PMS,
-                                 PassManagerType PMT =PMT_CallGraphPassManager);
+                                 PassManagerType PMT = PMT_CallGraphPassManager);
 
   ///  Return what kind of Pass Manager can manage this pass.
   virtual PassManagerType getPotentialPassManagerType() const {
@@ -77,29 +72,6 @@
   virtual void getAnalysisUsage(AnalysisUsage &Info) const;
 };
 
-/// CallGraphSCC - This is a single SCC that a CallGraphSCCPass is run on. 
-class CallGraphSCC {
-  void *Context; // The CGPassManager object that is vending this.
-  std::vector<CallGraphNode*> Nodes;
-public:
-  CallGraphSCC(void *context) : Context(context) {}
-  
-  void initialize(CallGraphNode*const*I, CallGraphNode*const*E) {
-    Nodes.assign(I, E);
-  }
-  
-  bool isSingular() const { return Nodes.size() == 1; }
-  unsigned size() const { return Nodes.size(); }
-  
-  /// ReplaceNode - This informs the SCC and the pass manager that the specified
-  /// Old node has been deleted, and New is to be used in its place.
-  void ReplaceNode(CallGraphNode *Old, CallGraphNode *New);
-  
-  typedef std::vector<CallGraphNode*>::const_iterator iterator;
-  iterator begin() const { return Nodes.begin(); }
-  iterator end() const { return Nodes.end(); }
-};
-
 } // End llvm namespace
 
 #endif

Modified: llvm/branches/Apple/Morbo/include/llvm/Transforms/IPO/InlinerPass.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Morbo/include/llvm/Transforms/IPO/InlinerPass.h?rev=101698&r1=101697&r2=101698&view=diff
==============================================================================
--- llvm/branches/Apple/Morbo/include/llvm/Transforms/IPO/InlinerPass.h (original)
+++ llvm/branches/Apple/Morbo/include/llvm/Transforms/IPO/InlinerPass.h Sat Apr 17 23:57:30 2010
@@ -40,7 +40,7 @@
 
   // Main run interface method, this implements the interface required by the
   // Pass class.
-  virtual bool runOnSCC(CallGraphSCC &SCC);
+  virtual bool runOnSCC(std::vector<CallGraphNode *> &SCC);
 
   // doFinalization - Remove now-dead linkonce functions at the end of
   // processing to avoid breaking the SCC traversal.
@@ -77,7 +77,7 @@
 
   /// growCachedCostInfo - update the cached cost info for Caller after Callee
   /// has been inlined.
-  virtual void growCachedCostInfo(Function *Caller, Function *Callee) = 0;
+  virtual void growCachedCostInfo(Function* Caller, Function* Callee) = 0;
 
   /// removeDeadFunctions - Remove dead functions that are not included in
   /// DNR (Do Not Remove) list.

Modified: llvm/branches/Apple/Morbo/lib/Analysis/IPA/CallGraphSCCPass.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Morbo/lib/Analysis/IPA/CallGraphSCCPass.cpp?rev=101698&r1=101697&r2=101698&view=diff
==============================================================================
--- llvm/branches/Apple/Morbo/lib/Analysis/IPA/CallGraphSCCPass.cpp (original)
+++ llvm/branches/Apple/Morbo/lib/Analysis/IPA/CallGraphSCCPass.cpp Sat Apr 17 23:57:30 2010
@@ -80,9 +80,9 @@
   }
   
 private:
-  bool RunPassOnSCC(Pass *P, CallGraphSCC &CurSCC,
+  bool RunPassOnSCC(Pass *P, std::vector<CallGraphNode*> &CurSCC,
                     CallGraph &CG, bool &CallGraphUpToDate);
-  void RefreshCallGraph(CallGraphSCC &CurSCC, CallGraph &CG,
+  void RefreshCallGraph(std::vector<CallGraphNode*> &CurSCC, CallGraph &CG,
                         bool IsCheckingMode);
 };
 
@@ -90,7 +90,7 @@
 
 char CGPassManager::ID = 0;
 
-bool CGPassManager::RunPassOnSCC(Pass *P, CallGraphSCC &CurSCC,
+bool CGPassManager::RunPassOnSCC(Pass *P, std::vector<CallGraphNode*> &CurSCC,
                                  CallGraph &CG, bool &CallGraphUpToDate) {
   bool Changed = false;
   PMDataManager *PM = P->getAsPMDataManager();
@@ -122,9 +122,8 @@
   FPPassManager *FPP = (FPPassManager*)P;
   
   // Run pass P on all functions in the current SCC.
-  for (CallGraphSCC::iterator I = CurSCC.begin(), E = CurSCC.end();
-       I != E; ++I) {
-    if (Function *F = (*I)->getFunction()) {
+  for (unsigned i = 0, e = CurSCC.size(); i != e; ++i) {
+    if (Function *F = CurSCC[i]->getFunction()) {
       dumpPassInfo(P, EXECUTION_MSG, ON_FUNCTION_MSG, F->getName());
       Timer *T = StartPassTimer(FPP);
       Changed |= FPP->runOnFunction(*F);
@@ -148,24 +147,21 @@
 /// FunctionPasses have potentially munged the callgraph, and can be used after
 /// CallGraphSCC passes to verify that they correctly updated the callgraph.
 ///
-void CGPassManager::RefreshCallGraph(CallGraphSCC &CurSCC,
+void CGPassManager::RefreshCallGraph(std::vector<CallGraphNode*> &CurSCC,
                                      CallGraph &CG, bool CheckingMode) {
   DenseMap<Value*, CallGraphNode*> CallSites;
   
   DEBUG(dbgs() << "CGSCCPASSMGR: Refreshing SCC with " << CurSCC.size()
                << " nodes:\n";
-        for (CallGraphSCC::iterator I = CurSCC.begin(), E = CurSCC.end();
-             I != E; ++I)
-          (*I)->dump();
+        for (unsigned i = 0, e = CurSCC.size(); i != e; ++i)
+          CurSCC[i]->dump();
         );
 
   bool MadeChange = false;
   
   // Scan all functions in the SCC.
-  unsigned FunctionNo = 0;
-  for (CallGraphSCC::iterator SCCIdx = CurSCC.begin(), E = CurSCC.end();
-       SCCIdx != E; ++SCCIdx, ++FunctionNo) {
-    CallGraphNode *CGN = *SCCIdx;
+  for (unsigned sccidx = 0, e = CurSCC.size(); sccidx != e; ++sccidx) {
+    CallGraphNode *CGN = CurSCC[sccidx];
     Function *F = CGN->getFunction();
     if (F == 0 || F->isDeclaration()) continue;
     
@@ -284,15 +280,14 @@
     
     // Periodically do an explicit clear to remove tombstones when processing
     // large scc's.
-    if ((FunctionNo & 15) == 15)
+    if ((sccidx & 15) == 0)
       CallSites.clear();
   }
 
   DEBUG(if (MadeChange) {
           dbgs() << "CGSCCPASSMGR: Refreshed SCC is now:\n";
-          for (CallGraphSCC::iterator I = CurSCC.begin(), E = CurSCC.end();
-            I != E; ++I)
-              (*I)->dump();
+          for (unsigned i = 0, e = CurSCC.size(); i != e; ++i)
+            CurSCC[i]->dump();
          } else {
            dbgs() << "CGSCCPASSMGR: SCC Refresh didn't change call graph.\n";
          }
@@ -305,17 +300,17 @@
   CallGraph &CG = getAnalysis<CallGraph>();
   bool Changed = doInitialization(CG);
 
+  std::vector<CallGraphNode*> CurSCC;
+  
   // Walk the callgraph in bottom-up SCC order.
-  scc_iterator<CallGraph*> CGI = scc_begin(&CG);
-
-  CallGraphSCC CurSCC(&CGI);
-  while (!CGI.isAtEnd()) {
+  for (scc_iterator<CallGraph*> CGI = scc_begin(&CG), E = scc_end(&CG);
+       CGI != E;) {
     // Copy the current SCC and increment past it so that the pass can hack
     // on the SCC if it wants to without invalidating our iterator.
-    std::vector<CallGraphNode*> &NodeVec = *CGI;
-    CurSCC.initialize(&NodeVec[0], &NodeVec[0]+NodeVec.size());
+    CurSCC = *CGI;
     ++CGI;
     
+    
     // CallGraphUpToDate - Keep track of whether the callgraph is known to be
     // up-to-date or not.  The CGSSC pass manager runs two types of passes:
     // CallGraphSCC Passes and other random function passes.  Because other
@@ -336,10 +331,9 @@
         std::string Functions;
 #ifndef NDEBUG
         raw_string_ostream OS(Functions);
-        for (CallGraphSCC::iterator I = CurSCC.begin(), E = CurSCC.end();
-             I != E; ++I) {
-          if (I != CurSCC.begin()) OS << ", ";
-          (*I)->print(OS);
+        for (unsigned i = 0, e = CurSCC.size(); i != e; ++i) {
+          if (i) OS << ", ";
+          CurSCC[i]->print(OS);
         }
         OS.flush();
 #endif
@@ -401,32 +395,6 @@
   return Changed;
 }
 
-//===----------------------------------------------------------------------===//
-// CallGraphSCC Implementation
-//===----------------------------------------------------------------------===//
-
-/// ReplaceNode - This informs the SCC and the pass manager that the specified
-/// Old node has been deleted, and New is to be used in its place.
-void CallGraphSCC::ReplaceNode(CallGraphNode *Old, CallGraphNode *New) {
-  assert(Old != New && "Should not replace node with self");
-  for (unsigned i = 0; ; ++i) {
-    assert(i != Nodes.size() && "Node not in SCC");
-    if (Nodes[i] != Old) continue;
-    Nodes[i] = New;
-    break;
-  }
-  
-  // Update the active scc_iterator so that it doesn't contain dangling
-  // pointers to the old CallGraphNode.
-  scc_iterator<CallGraph*> *CGI = (scc_iterator<CallGraph*>*)Context;
-  CGI->ReplaceNode(Old, New);
-}
-
-
-//===----------------------------------------------------------------------===//
-// CallGraphSCCPass Implementation
-//===----------------------------------------------------------------------===//
-
 /// Assign pass manager to manage this pass.
 void CallGraphSCCPass::assignPassManager(PMStack &PMS,
                                          PassManagerType PreferredType) {
@@ -471,42 +439,3 @@
   AU.addRequired<CallGraph>();
   AU.addPreserved<CallGraph>();
 }
-
-//===----------------------------------------------------------------------===//
-// PrintCallGraphPass Implementation
-//===----------------------------------------------------------------------===//
-
-namespace {
-  /// PrintCallGraphPass - Print a Module corresponding to a call graph.
-  ///
-  class PrintCallGraphPass : public CallGraphSCCPass {
-    std::string Banner;
-    raw_ostream &Out;       // raw_ostream to print on.
-    
-  public:
-    static char ID;
-    PrintCallGraphPass() : CallGraphSCCPass(&ID), Out(dbgs()) {}
-    PrintCallGraphPass(const std::string &B, raw_ostream &o)
-      : CallGraphSCCPass(&ID), Banner(B), Out(o) {}
-    
-    virtual void getAnalysisUsage(AnalysisUsage &AU) const {
-      AU.setPreservesAll();
-    }
-    
-    bool runOnSCC(CallGraphSCC &SCC) {
-      Out << Banner;
-      for (CallGraphSCC::iterator I = SCC.begin(), E = SCC.end(); I != E; ++I)
-        (*I)->getFunction()->print(Out);
-      return false;
-    }
-  };
-  
-} // end anonymous namespace.
-
-char PrintCallGraphPass::ID = 0;
-
-Pass *CallGraphSCCPass::createPrinterPass(raw_ostream &O,
-                                          const std::string &Banner) const {
-  return new PrintCallGraphPass(Banner, O);
-}
-

Modified: llvm/branches/Apple/Morbo/lib/Transforms/IPO/ArgumentPromotion.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Morbo/lib/Transforms/IPO/ArgumentPromotion.cpp?rev=101698&r1=101697&r2=101698&view=diff
==============================================================================
--- llvm/branches/Apple/Morbo/lib/Transforms/IPO/ArgumentPromotion.cpp (original)
+++ llvm/branches/Apple/Morbo/lib/Transforms/IPO/ArgumentPromotion.cpp Sat Apr 17 23:57:30 2010
@@ -64,7 +64,7 @@
       CallGraphSCCPass::getAnalysisUsage(AU);
     }
 
-    virtual bool runOnSCC(CallGraphSCC &SCC);
+    virtual bool runOnSCC(std::vector<CallGraphNode *> &SCC);
     static char ID; // Pass identification, replacement for typeid
     explicit ArgPromotion(unsigned maxElements = 3)
       : CallGraphSCCPass(&ID), maxElements(maxElements) {}
@@ -91,18 +91,17 @@
   return new ArgPromotion(maxElements);
 }
 
-bool ArgPromotion::runOnSCC(CallGraphSCC &SCC) {
+bool ArgPromotion::runOnSCC(std::vector<CallGraphNode *> &SCC) {
   bool Changed = false, LocalChange;
 
   do {  // Iterate until we stop promoting from this SCC.
     LocalChange = false;
     // Attempt to promote arguments from all functions in this SCC.
-    for (CallGraphSCC::iterator I = SCC.begin(), E = SCC.end(); I != E; ++I) {
-      if (CallGraphNode *CGN = PromoteArguments(*I)) {
+    for (unsigned i = 0, e = SCC.size(); i != e; ++i)
+      if (CallGraphNode *CGN = PromoteArguments(SCC[i])) {
         LocalChange = true;
-        SCC.ReplaceNode(*I, CGN);
+        SCC[i] = CGN;
       }
-    }
     Changed |= LocalChange;               // Remember that we changed something.
   } while (LocalChange);
 

Modified: llvm/branches/Apple/Morbo/lib/Transforms/IPO/Inliner.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Morbo/lib/Transforms/IPO/Inliner.cpp?rev=101698&r1=101697&r2=101698&view=diff
==============================================================================
--- llvm/branches/Apple/Morbo/lib/Transforms/IPO/Inliner.cpp (original)
+++ llvm/branches/Apple/Morbo/lib/Transforms/IPO/Inliner.cpp Sat Apr 17 23:57:30 2010
@@ -292,14 +292,14 @@
   return true;
 }
 
-bool Inliner::runOnSCC(CallGraphSCC &SCC) {
+bool Inliner::runOnSCC(std::vector<CallGraphNode*> &SCC) {
   CallGraph &CG = getAnalysis<CallGraph>();
   const TargetData *TD = getAnalysisIfAvailable<TargetData>();
 
   SmallPtrSet<Function*, 8> SCCFunctions;
   DEBUG(dbgs() << "Inliner visiting SCC:");
-  for (CallGraphSCC::iterator I = SCC.begin(), E = SCC.end(); I != E; ++I) {
-    Function *F = (*I)->getFunction();
+  for (unsigned i = 0, e = SCC.size(); i != e; ++i) {
+    Function *F = SCC[i]->getFunction();
     if (F) SCCFunctions.insert(F);
     DEBUG(dbgs() << " " << (F ? F->getName() : "INDIRECTNODE"));
   }
@@ -309,8 +309,8 @@
   // from inlining other functions.
   SmallVector<CallSite, 16> CallSites;
 
-  for (CallGraphSCC::iterator I = SCC.begin(), E = SCC.end(); I != E; ++I) {
-    Function *F = (*I)->getFunction();
+  for (unsigned i = 0, e = SCC.size(); i != e; ++i) {
+    Function *F = SCC[i]->getFunction();
     if (!F) continue;
     
     for (Function::iterator BB = F->begin(), E = F->end(); BB != E; ++BB)
@@ -417,7 +417,7 @@
       // swap/pop_back for efficiency, but do not use it if doing so would
       // move a call site to a function in this SCC before the
       // 'FirstCallInSCC' barrier.
-      if (SCC.isSingular()) {
+      if (SCC.size() == 1) {
         std::swap(CallSites[CSi], CallSites.back());
         CallSites.pop_back();
       } else {

Modified: llvm/branches/Apple/Morbo/lib/Transforms/IPO/PruneEH.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Morbo/lib/Transforms/IPO/PruneEH.cpp?rev=101698&r1=101697&r2=101698&view=diff
==============================================================================
--- llvm/branches/Apple/Morbo/lib/Transforms/IPO/PruneEH.cpp (original)
+++ llvm/branches/Apple/Morbo/lib/Transforms/IPO/PruneEH.cpp Sat Apr 17 23:57:30 2010
@@ -40,7 +40,7 @@
     PruneEH() : CallGraphSCCPass(&ID) {}
 
     // runOnSCC - Analyze the SCC, performing the transformation if possible.
-    bool runOnSCC(CallGraphSCC &SCC);
+    bool runOnSCC(std::vector<CallGraphNode *> &SCC);
 
     bool SimplifyFunction(Function *F);
     void DeleteBasicBlock(BasicBlock *BB);
@@ -54,20 +54,20 @@
 Pass *llvm::createPruneEHPass() { return new PruneEH(); }
 
 
-bool PruneEH::runOnSCC(CallGraphSCC &SCC) {
+bool PruneEH::runOnSCC(std::vector<CallGraphNode *> &SCC) {
   SmallPtrSet<CallGraphNode *, 8> SCCNodes;
   CallGraph &CG = getAnalysis<CallGraph>();
   bool MadeChange = false;
 
   // Fill SCCNodes with the elements of the SCC.  Used for quickly
   // looking up whether a given CallGraphNode is in this SCC.
-  for (CallGraphSCC::iterator I = SCC.begin(), E = SCC.end(); I != E; ++I)
-    SCCNodes.insert(*I);
+  for (unsigned i = 0, e = SCC.size(); i != e; ++i)
+    SCCNodes.insert(SCC[i]);
 
   // First pass, scan all of the functions in the SCC, simplifying them
   // according to what we know.
-  for (CallGraphSCC::iterator I = SCC.begin(), E = SCC.end(); I != E; ++I)
-    if (Function *F = (*I)->getFunction())
+  for (unsigned i = 0, e = SCC.size(); i != e; ++i)
+    if (Function *F = SCC[i]->getFunction())
       MadeChange |= SimplifyFunction(F);
 
   // Next, check to see if any callees might throw or if there are any external
@@ -78,9 +78,9 @@
   // obviously the SCC might throw.
   //
   bool SCCMightUnwind = false, SCCMightReturn = false;
-  for (CallGraphSCC::iterator I = SCC.begin(), E = SCC.end(); 
-       (!SCCMightUnwind || !SCCMightReturn) && I != E; ++I) {
-    Function *F = (*I)->getFunction();
+  for (unsigned i = 0, e = SCC.size();
+       (!SCCMightUnwind || !SCCMightReturn) && i != e; ++i) {
+    Function *F = SCC[i]->getFunction();
     if (F == 0) {
       SCCMightUnwind = true;
       SCCMightReturn = true;
@@ -132,7 +132,7 @@
 
   // If the SCC doesn't unwind or doesn't throw, note this fact.
   if (!SCCMightUnwind || !SCCMightReturn)
-    for (CallGraphSCC::iterator I = SCC.begin(), E = SCC.end(); I != E; ++I) {
+    for (unsigned i = 0, e = SCC.size(); i != e; ++i) {
       Attributes NewAttributes = Attribute::None;
 
       if (!SCCMightUnwind)
@@ -140,20 +140,19 @@
       if (!SCCMightReturn)
         NewAttributes |= Attribute::NoReturn;
 
-      Function *F = (*I)->getFunction();
-      const AttrListPtr &PAL = F->getAttributes();
+      const AttrListPtr &PAL = SCC[i]->getFunction()->getAttributes();
       const AttrListPtr &NPAL = PAL.addAttr(~0, NewAttributes);
       if (PAL != NPAL) {
         MadeChange = true;
-        F->setAttributes(NPAL);
+        SCC[i]->getFunction()->setAttributes(NPAL);
       }
     }
 
-  for (CallGraphSCC::iterator I = SCC.begin(), E = SCC.end(); I != E; ++I) {
+  for (unsigned i = 0, e = SCC.size(); i != e; ++i) {
     // Convert any invoke instructions to non-throwing functions in this node
     // into call instructions with a branch.  This makes the exception blocks
     // dead.
-    if (Function *F = (*I)->getFunction())
+    if (Function *F = SCC[i]->getFunction())
       MadeChange |= SimplifyFunction(F);
   }
 

Modified: llvm/branches/Apple/Morbo/lib/Transforms/IPO/StructRetPromotion.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Morbo/lib/Transforms/IPO/StructRetPromotion.cpp?rev=101698&r1=101697&r2=101698&view=diff
==============================================================================
--- llvm/branches/Apple/Morbo/lib/Transforms/IPO/StructRetPromotion.cpp (original)
+++ llvm/branches/Apple/Morbo/lib/Transforms/IPO/StructRetPromotion.cpp Sat Apr 17 23:57:30 2010
@@ -48,7 +48,7 @@
       CallGraphSCCPass::getAnalysisUsage(AU);
     }
 
-    virtual bool runOnSCC(CallGraphSCC &SCC);
+    virtual bool runOnSCC(std::vector<CallGraphNode *> &SCC);
     static char ID; // Pass identification, replacement for typeid
     SRETPromotion() : CallGraphSCCPass(&ID) {}
 
@@ -69,12 +69,12 @@
   return new SRETPromotion();
 }
 
-bool SRETPromotion::runOnSCC(CallGraphSCC &SCC) {
+bool SRETPromotion::runOnSCC(std::vector<CallGraphNode *> &SCC) {
   bool Changed = false;
 
-  for (CallGraphSCC::iterator I = SCC.begin(), E = SCC.end(); I != E; ++I)
-    if (CallGraphNode *NewNode = PromoteReturn(*I)) {
-      SCC.ReplaceNode(*I, NewNode);
+  for (unsigned i = 0, e = SCC.size(); i != e; ++i)
+    if (CallGraphNode *NewNode = PromoteReturn(SCC[i])) {
+      SCC[i] = NewNode;
       Changed = true;
     }
 

Modified: llvm/branches/Apple/Morbo/tools/opt/opt.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Morbo/tools/opt/opt.cpp?rev=101698&r1=101697&r2=101698&view=diff
==============================================================================
--- llvm/branches/Apple/Morbo/tools/opt/opt.cpp (original)
+++ llvm/branches/Apple/Morbo/tools/opt/opt.cpp Sat Apr 17 23:57:30 2010
@@ -142,14 +142,15 @@
   CallGraphSCCPassPrinter(const PassInfo *PI) :
     CallGraphSCCPass(&ID), PassToPrint(PI) {}
 
-  virtual bool runOnSCC(CallGraphSCC &SCC) {
+  virtual bool runOnSCC(std::vector<CallGraphNode *>&SCC) {
     if (!Quiet) {
       outs() << "Printing analysis '" << PassToPrint->getPassName() << "':\n";
 
-      for (CallGraphSCC::iterator I = SCC.begin(), E = SCC.end(); I != E; ++I) {
-        Function *F = (*I)->getFunction();
-        if (F)
+      for (unsigned i = 0, e = SCC.size(); i != e; ++i) {
+        Function *F = SCC[i]->getFunction();
+        if (F) {
           getAnalysisID<Pass>(PassToPrint).print(outs(), F->getParent());
+        }
       }
     }
     // Get and print pass...

Modified: llvm/branches/Apple/Morbo/unittests/VMCore/PassManagerTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Morbo/unittests/VMCore/PassManagerTest.cpp?rev=101698&r1=101697&r2=101698&view=diff
==============================================================================
--- llvm/branches/Apple/Morbo/unittests/VMCore/PassManagerTest.cpp (original)
+++ llvm/branches/Apple/Morbo/unittests/VMCore/PassManagerTest.cpp Sat Apr 17 23:57:30 2010
@@ -154,7 +154,7 @@
 
     struct CGPass : public PassTest<CallGraph, CallGraphSCCPass> {
     public:
-      virtual bool runOnSCC(CallGraphSCC &SCMM) {
+      virtual bool runOnSCC(std::vector<CallGraphNode*> &SCMM) {
         EXPECT_TRUE(getAnalysisIfAvailable<TargetData>());
         run();
         return false;





More information about the llvm-branch-commits mailing list