[LCG] Switch the parent SCC tracking from a SmallSetVector to
authorChandler Carruth <chandlerc@gmail.com>
Thu, 24 Apr 2014 09:22:31 +0000 (09:22 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Thu, 24 Apr 2014 09:22:31 +0000 (09:22 +0000)
a SmallPtrSet. Currently, there is no need for stable iteration in this
dimension, and I now thing there won't need to be going forward.

If this is ever re-introduced in any form, it needs to not be
a SetVector based solution because removal cannot be linear. There will
be many SCCs with large numbers of parents. When encountering these, the
incremental SCC update for intra-SCC edge removal was quadratic due to
linear removal (kind of).

I'm really hoping we can avoid having an ordering property here at all
though...

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

include/llvm/Analysis/LazyCallGraph.h
lib/Analysis/LazyCallGraph.cpp

index ea65cbac1d30705cf3f1c7b282a16edc26ed3ca9..b53e77b4f76ebf36e5a43d5e4a7447d9c6429d0b 100644 (file)
@@ -215,7 +215,7 @@ public:
     friend class LazyCallGraph;
     friend class LazyCallGraph::Node;
 
-    SmallSetVector<SCC *, 1> ParentSCCs;
+    SmallPtrSet<SCC *, 1> ParentSCCs;
     SmallVector<Node *, 1> Nodes;
 
     SCC() {}
@@ -228,7 +228,7 @@ public:
 
   public:
     typedef SmallVectorImpl<Node *>::const_iterator iterator;
-    typedef pointee_iterator<SmallSetVector<SCC *, 1>::const_iterator> parent_iterator;
+    typedef pointee_iterator<SmallPtrSet<SCC *, 1>::const_iterator> parent_iterator;
 
     iterator begin() const { return Nodes.begin(); }
     iterator end() const { return Nodes.end(); }
index 832d2b9e7e636d616d12644239562a3ac0b3526a..c4d597e2f4f3cfb489a58b9b5790cebd47fb109d 100644 (file)
@@ -157,7 +157,7 @@ void LazyCallGraph::SCC::removeEdge(LazyCallGraph &G, Function &Caller,
   // the caller no longer a parent of the callee. Walk the other call edges
   // in the caller to tell.
   if (!HasOtherCallToCalleeC) {
-    bool Removed = CalleeC.ParentSCCs.remove(this);
+    bool Removed = CalleeC.ParentSCCs.erase(this);
     (void)Removed;
     assert(Removed &&
            "Did not find the caller SCC in the callee SCC's parent list!");
@@ -239,7 +239,7 @@ LazyCallGraph::SCC::removeInternalEdge(LazyCallGraph &G, Node &Caller,
         // However, we do need to remove this SCC from its SCC's parent set.
         SCC &ChildSCC = *G.SCCMap.lookup(&ChildN);
         if (&ChildSCC != this) {
-          ChildSCC.ParentSCCs.remove(this);
+          ChildSCC.ParentSCCs.erase(this);
           continue;
         }