summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/LazyCallGraph.cpp
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2016-12-06 10:29:23 +0000
committerChandler Carruth <chandlerc@gmail.com>2016-12-06 10:29:23 +0000
commit23a6c3f7462ad79be7b135e8adf246bbc756a1cb (patch)
treeb8eaa70296a95f19d9bb6acd09898a84d1eb6e17 /llvm/lib/Analysis/LazyCallGraph.cpp
parent7582c669bdc4aed10c18eb799313c2b6f7e71edb (diff)
downloadbcm5719-llvm-23a6c3f7462ad79be7b135e8adf246bbc756a1cb.tar.gz
bcm5719-llvm-23a6c3f7462ad79be7b135e8adf246bbc756a1cb.zip
[LCG] Add some much needed asserts and verify runs to uncover
a hilarious bug and fix it. We somehow were never verifying the RefSCCs newly formed when splitting an existing one apart, and when verifying them we weren't really checking the SCC indices mapping effectively. If we had been, it would have been blindingly obvious that right after putting something int `RC.SCCs` we should update `RC.SCCIndices` instead of `SCCIndices` which we were about to clear and rebuild anyways. =[ Anyways, this is thoroughly covered by existing tests now that we actually verify things properly. llvm-svn: 288795
Diffstat (limited to 'llvm/lib/Analysis/LazyCallGraph.cpp')
-rw-r--r--llvm/lib/Analysis/LazyCallGraph.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/llvm/lib/Analysis/LazyCallGraph.cpp b/llvm/lib/Analysis/LazyCallGraph.cpp
index fe635c4e366..d1689377ac6 100644
--- a/llvm/lib/Analysis/LazyCallGraph.cpp
+++ b/llvm/lib/Analysis/LazyCallGraph.cpp
@@ -258,6 +258,9 @@ void LazyCallGraph::RefSCC::verify() {
"SCC doesn't think it is inside this RefSCC!");
bool Inserted = SCCSet.insert(C).second;
assert(Inserted && "Found a duplicate SCC!");
+ auto IndexIt = SCCIndices.find(C);
+ assert(IndexIt != SCCIndices.end() &&
+ "Found an SCC that doesn't have an index!");
}
// Check that our indices map correctly.
@@ -1203,9 +1206,8 @@ LazyCallGraph::RefSCC::removeInternalRefEdge(Node &SourceN, Node &TargetN) {
}
// If this child isn't currently in this RefSCC, no need to process
- // it.
- // However, we do need to remove this RefSCC from its RefSCC's parent
- // set.
+ // it. However, we do need to remove this RefSCC from its RefSCC's
+ // parent set.
RefSCC &ChildRC = *G->lookupRefSCC(ChildN);
ChildRC.Parents.erase(this);
++I;
@@ -1305,7 +1307,7 @@ LazyCallGraph::RefSCC::removeInternalRefEdge(Node &SourceN, Node &TargetN) {
RefSCC &RC = *Result[SCCNumber - 1];
int SCCIndex = RC.SCCs.size();
RC.SCCs.push_back(C);
- SCCIndices[C] = SCCIndex;
+ RC.SCCIndices[C] = SCCIndex;
C->OuterRefSCC = &RC;
}
@@ -1376,6 +1378,12 @@ LazyCallGraph::RefSCC::removeInternalRefEdge(Node &SourceN, Node &TargetN) {
std::remove(G->LeafRefSCCs.begin(), G->LeafRefSCCs.end(), this),
G->LeafRefSCCs.end());
+#ifndef NDEBUG
+ // Verify all of the new RefSCCs.
+ for (RefSCC *RC : Result)
+ RC->verify();
+#endif
+
// Return the new list of SCCs.
return Result;
}
OpenPOWER on IntegriCloud