reenable r101565, removing a problematic assertion.
authorChris Lattner <sabre@nondot.org>
Sat, 17 Apr 2010 07:17:19 +0000 (07:17 +0000)
committerChris Lattner <sabre@nondot.org>
Sat, 17 Apr 2010 07:17:19 +0000 (07:17 +0000)
CGSCC can delete nodes in regions of the callgraph that
have already been visited.  If new CG nodes are allocated
to the same pointer, we shouldn't abort, just handle it
correctly by assigning a new number.  This should restore
stability by removing invalidated pointers that *will* be
reused from the densemap in the iterator.

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

include/llvm/ADT/SCCIterator.h
lib/Analysis/IPA/CallGraphSCCPass.cpp

index 80eb8c55b22f64fa26a4c5bdae07d13b4bdfe90f..c49d599cf38f1785eaa2980ffaf625ab5bb6f02f 100644 (file)
@@ -66,7 +66,7 @@ class scc_iterator
   std::vector<unsigned> MinVisitNumStack;
 
   // A single "visit" within the non-recursive DFS traversal.
-  void DFSVisitOne(NodeTypeN) {
+  void DFSVisitOne(NodeType *N) {
     ++visitNum;                         // Global counter for the visit order
     nodeVisitNumbers[N] = visitNum;
     SCCNodeStack.push_back(N);
@@ -83,7 +83,7 @@ class scc_iterator
       // 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);
         continue;
       }
@@ -187,7 +187,6 @@ public:
   /// 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(New) && "New already in scc_iterator?");
     assert(nodeVisitNumbers.count(Old) && "Old not in scc_iterator?");
     nodeVisitNumbers[New] = nodeVisitNumbers[Old];
     nodeVisitNumbers.erase(Old);
index cf4c0d2549c71cc04dd313d40c3375c1822a3d11..7b73c5dffce5590e3c8b52270d6e4e2c33041786 100644 (file)
@@ -420,10 +420,8 @@ void CallGraphSCC::ReplaceNode(CallGraphNode *Old, CallGraphNode *New) {
   
   // Update the active scc_iterator so that it doesn't contain dangling
   // pointers to the old CallGraphNode.
-#if 0
   scc_iterator<CallGraph*> *CGI = (scc_iterator<CallGraph*>*)Context;
   CGI->ReplaceNode(Old, New);
-#endif
 }