diff --git a/include/llvm/Analysis/LazyCallGraph.h b/include/llvm/Analysis/LazyCallGraph.h index d4b2d354f18..07ba0004bd8 100644 --- a/include/llvm/Analysis/LazyCallGraph.h +++ b/include/llvm/Analysis/LazyCallGraph.h @@ -384,7 +384,7 @@ private: SmallVector, 4> DFSStack; /// \brief Set of entry nodes not-yet-processed into SCCs. - SmallSetVector SCCEntryNodes; + SmallVector SCCEntryNodes; /// \brief Stack of nodes the DFS has walked but not yet put into a SCC. SmallVector PendingSCCStack; diff --git a/lib/Analysis/LazyCallGraph.cpp b/lib/Analysis/LazyCallGraph.cpp index 50accb3a753..196003430a4 100644 --- a/lib/Analysis/LazyCallGraph.cpp +++ b/lib/Analysis/LazyCallGraph.cpp @@ -100,9 +100,9 @@ LazyCallGraph::LazyCallGraph(Module &M) : NextDFSNumber(0) { for (auto &Entry : EntryNodes) if (Function *F = Entry.dyn_cast()) - SCCEntryNodes.insert(F); + SCCEntryNodes.push_back(F); else - SCCEntryNodes.insert(&Entry.get()->getFunction()); + SCCEntryNodes.push_back(&Entry.get()->getFunction()); } LazyCallGraph::LazyCallGraph(LazyCallGraph &&G) @@ -437,10 +437,12 @@ LazyCallGraph::SCC *LazyCallGraph::getNextSCCInPostOrder() { DFSStack.pop_back(); } else { // If we've handled all candidate entry nodes to the SCC forest, we're done. - if (SCCEntryNodes.empty()) - return nullptr; + do { + if (SCCEntryNodes.empty()) + return nullptr; - N = &get(*SCCEntryNodes.pop_back_val()); + N = &get(*SCCEntryNodes.pop_back_val()); + } while (N->DFSNumber != 0); I = N->begin(); N->LowLink = N->DFSNumber = 1; NextDFSNumber = 2; @@ -463,7 +465,6 @@ LazyCallGraph::SCC *LazyCallGraph::getNextSCCInPostOrder() { assert(!SCCMap.count(&ChildN) && "Found a node with 0 DFS number but already in an SCC!"); ChildN.LowLink = ChildN.DFSNumber = NextDFSNumber++; - SCCEntryNodes.remove(&ChildN.getFunction()); N = &ChildN; I = ChildN.begin(); E = ChildN.end();