[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
This commit is contained in:
Chandler Carruth 2016-12-06 10:29:23 +00:00
parent 7582c669bd
commit 23a6c3f746
1 changed files with 12 additions and 4 deletions

View File

@ -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;
}