aboutsummaryrefslogtreecommitdiff
path: root/lib/Analysis/DataStructure/BottomUpClosure.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-01-31 21:02:18 +0000
committerChris Lattner <sabre@nondot.org>2004-01-31 21:02:18 +0000
commita67138ddff4920a80056f6aada1b010d3bf459ac (patch)
tree1972d405f9a359fa0cefddfa860c746662a3f50a /lib/Analysis/DataStructure/BottomUpClosure.cpp
parent08cec00588ec1a8fa85b208555f006d7396ae7a4 (diff)
Avoid referencing deleted DSgraphs when merging an SCC into a larger SCC. This
fixes the crash in 176.gcc. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11033 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/DataStructure/BottomUpClosure.cpp')
-rw-r--r--lib/Analysis/DataStructure/BottomUpClosure.cpp20
1 files changed, 11 insertions, 9 deletions
diff --git a/lib/Analysis/DataStructure/BottomUpClosure.cpp b/lib/Analysis/DataStructure/BottomUpClosure.cpp
index 1406da7738..3dd8f204f7 100644
--- a/lib/Analysis/DataStructure/BottomUpClosure.cpp
+++ b/lib/Analysis/DataStructure/BottomUpClosure.cpp
@@ -152,7 +152,7 @@ unsigned BUDataStructures::calculateGraphs(Function *F,
} else {
// SCCFunctions - Keep track of the functions in the current SCC
//
- hash_set<Function*> SCCFunctions;
+ hash_set<DSGraph*> SCCGraphs;
Function *NF;
std::vector<Function*>::iterator FirstInSCC = Stack.end();
@@ -160,36 +160,38 @@ unsigned BUDataStructures::calculateGraphs(Function *F,
do {
NF = *--FirstInSCC;
ValMap[NF] = ~0U;
- SCCFunctions.insert(NF);
// 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
// graph sizes.
DSGraph &NFGraph = getDSGraph(*NF);
+ SCCGraphs.insert(&NFGraph);
if (!SCCGraph || SCCGraph->getGraphSize() < NFGraph.getGraphSize())
SCCGraph = &NFGraph;
} while (NF != F);
std::cerr << "Calculating graph for SCC #: " << MyID << " of size: "
- << SCCFunctions.size() << "\n";
+ << SCCGraphs.size() << "\n";
// Compute the Max SCC Size...
- if (MaxSCC < SCCFunctions.size())
- MaxSCC = SCCFunctions.size();
+ if (MaxSCC < SCCGraphs.size())
+ MaxSCC = SCCGraphs.size();
// 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
// (smaller) graphs into it. Discard all of the old graphs.
//
- for (hash_set<Function*>::iterator I = SCCFunctions.begin(),
- E = SCCFunctions.end(); I != E; ++I) {
- DSGraph &G = getDSGraph(**I);
+ for (hash_set<DSGraph*>::iterator I = SCCGraphs.begin(),
+ E = SCCGraphs.end(); I != E; ++I) {
+ DSGraph &G = **I;
if (&G != SCCGraph) {
DSGraph::NodeMapTy NodeMap;
SCCGraph->cloneInto(G, SCCGraph->getScalarMap(),
SCCGraph->getReturnNodes(), NodeMap);
// 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;
}
}