Avoid referencing deleted DSgraphs when merging an SCC into a larger SCC. This
fixes the crash in 176.gcc. llvm-svn: 11033
This commit is contained in:
parent
50d97e33b7
commit
2f58ffc571
|
@ -152,7 +152,7 @@ unsigned BUDataStructures::calculateGraphs(Function *F,
|
||||||
} else {
|
} else {
|
||||||
// SCCFunctions - Keep track of the functions in the current SCC
|
// SCCFunctions - Keep track of the functions in the current SCC
|
||||||
//
|
//
|
||||||
hash_set<Function*> SCCFunctions;
|
hash_set<DSGraph*> SCCGraphs;
|
||||||
|
|
||||||
Function *NF;
|
Function *NF;
|
||||||
std::vector<Function*>::iterator FirstInSCC = Stack.end();
|
std::vector<Function*>::iterator FirstInSCC = Stack.end();
|
||||||
|
@ -160,36 +160,38 @@ unsigned BUDataStructures::calculateGraphs(Function *F,
|
||||||
do {
|
do {
|
||||||
NF = *--FirstInSCC;
|
NF = *--FirstInSCC;
|
||||||
ValMap[NF] = ~0U;
|
ValMap[NF] = ~0U;
|
||||||
SCCFunctions.insert(NF);
|
|
||||||
|
|
||||||
// Figure out which graph is the largest one, in order to speed things up
|
// Figure out which graph is the largest one, in order to speed things up
|
||||||
// a bit in situations where functions in the SCC have widely different
|
// a bit in situations where functions in the SCC have widely different
|
||||||
// graph sizes.
|
// graph sizes.
|
||||||
DSGraph &NFGraph = getDSGraph(*NF);
|
DSGraph &NFGraph = getDSGraph(*NF);
|
||||||
|
SCCGraphs.insert(&NFGraph);
|
||||||
if (!SCCGraph || SCCGraph->getGraphSize() < NFGraph.getGraphSize())
|
if (!SCCGraph || SCCGraph->getGraphSize() < NFGraph.getGraphSize())
|
||||||
SCCGraph = &NFGraph;
|
SCCGraph = &NFGraph;
|
||||||
} while (NF != F);
|
} while (NF != F);
|
||||||
|
|
||||||
std::cerr << "Calculating graph for SCC #: " << MyID << " of size: "
|
std::cerr << "Calculating graph for SCC #: " << MyID << " of size: "
|
||||||
<< SCCFunctions.size() << "\n";
|
<< SCCGraphs.size() << "\n";
|
||||||
|
|
||||||
// Compute the Max SCC Size...
|
// Compute the Max SCC Size...
|
||||||
if (MaxSCC < SCCFunctions.size())
|
if (MaxSCC < SCCGraphs.size())
|
||||||
MaxSCC = SCCFunctions.size();
|
MaxSCC = SCCGraphs.size();
|
||||||
|
|
||||||
// First thing first, collapse all of the DSGraphs into a single graph for
|
// First thing first, collapse all of the DSGraphs into a single graph for
|
||||||
// the entire SCC. We computed the largest graph, so clone all of the other
|
// the entire SCC. We computed the largest graph, so clone all of the other
|
||||||
// (smaller) graphs into it. Discard all of the old graphs.
|
// (smaller) graphs into it. Discard all of the old graphs.
|
||||||
//
|
//
|
||||||
for (hash_set<Function*>::iterator I = SCCFunctions.begin(),
|
for (hash_set<DSGraph*>::iterator I = SCCGraphs.begin(),
|
||||||
E = SCCFunctions.end(); I != E; ++I) {
|
E = SCCGraphs.end(); I != E; ++I) {
|
||||||
DSGraph &G = getDSGraph(**I);
|
DSGraph &G = **I;
|
||||||
if (&G != SCCGraph) {
|
if (&G != SCCGraph) {
|
||||||
DSGraph::NodeMapTy NodeMap;
|
DSGraph::NodeMapTy NodeMap;
|
||||||
SCCGraph->cloneInto(G, SCCGraph->getScalarMap(),
|
SCCGraph->cloneInto(G, SCCGraph->getScalarMap(),
|
||||||
SCCGraph->getReturnNodes(), NodeMap);
|
SCCGraph->getReturnNodes(), NodeMap);
|
||||||
// Update the DSInfo map and delete the old graph...
|
// Update the DSInfo map and delete the old graph...
|
||||||
DSInfo[*I] = SCCGraph;
|
for (DSGraph::ReturnNodesTy::iterator I = G.getReturnNodes().begin(),
|
||||||
|
E = G.getReturnNodes().end(); I != E; ++I)
|
||||||
|
DSInfo[I->first] = SCCGraph;
|
||||||
delete &G;
|
delete &G;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue