summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/LazyCallGraph.cpp
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2017-08-05 03:37:37 +0000
committerChandler Carruth <chandlerc@gmail.com>2017-08-05 03:37:37 +0000
commit13ffd110ada372b07140a635b86a21e5a142c461 (patch)
tree79365ba7fc43a9acc652ccdbc869d59a8ecb39c7 /llvm/lib/Analysis/LazyCallGraph.cpp
parenta3c3d7b442181a37e8960fa939ce693ac56205a4 (diff)
downloadbcm5719-llvm-13ffd110ada372b07140a635b86a21e5a142c461.tar.gz
bcm5719-llvm-13ffd110ada372b07140a635b86a21e5a142c461.zip
[LCG] Remove the use of the parent sets to compute connectivity when
merging RefSCCs. The logic to directly use the reference edges is simpler and not substantially slower (despite the comments to the contrary) because this is not actually an especially hot part of LCG in practice. llvm-svn: 310161
Diffstat (limited to 'llvm/lib/Analysis/LazyCallGraph.cpp')
-rw-r--r--llvm/lib/Analysis/LazyCallGraph.cpp30
1 files changed, 14 insertions, 16 deletions
diff --git a/llvm/lib/Analysis/LazyCallGraph.cpp b/llvm/lib/Analysis/LazyCallGraph.cpp
index d287f81985f..fbf39a23779 100644
--- a/llvm/lib/Analysis/LazyCallGraph.cpp
+++ b/llvm/lib/Analysis/LazyCallGraph.cpp
@@ -957,22 +957,20 @@ LazyCallGraph::RefSCC::insertIncomingRefEdge(Node &SourceN, Node &TargetN) {
// RefSCCs (and their edges) are visited here.
auto ComputeSourceConnectedSet = [&](SmallPtrSetImpl<RefSCC *> &Set) {
Set.insert(&SourceC);
- SmallVector<RefSCC *, 4> Worklist;
- Worklist.push_back(&SourceC);
- do {
- RefSCC &RC = *Worklist.pop_back_val();
- for (RefSCC &ParentRC : RC.parents()) {
- // Skip any RefSCCs outside the range of source to target in the
- // postorder sequence.
- int ParentIdx = G->getRefSCCIndex(ParentRC);
- assert(ParentIdx > SourceIdx && "Parent cannot precede source in postorder!");
- if (ParentIdx > TargetIdx)
- continue;
- if (Set.insert(&ParentRC).second)
- // First edge connecting to this parent, add it to our worklist.
- Worklist.push_back(&ParentRC);
- }
- } while (!Worklist.empty());
+ auto IsConnected = [&](RefSCC &RC) {
+ for (SCC &C : RC)
+ for (Node &N : C)
+ for (Edge &E : *N)
+ if (Set.count(G->lookupRefSCC(E.getNode())))
+ return true;
+
+ return false;
+ };
+
+ for (RefSCC *C : make_range(G->PostOrderRefSCCs.begin() + SourceIdx + 1,
+ G->PostOrderRefSCCs.begin() + TargetIdx + 1))
+ if (IsConnected(*C))
+ Set.insert(C);
};
// Use a normal worklist to find which SCCs the target connects to. We still
OpenPOWER on IntegriCloud