diff options
author | Chris Lattner <sabre@nondot.org> | 2004-11-02 19:29:59 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2004-11-02 19:29:59 +0000 |
commit | caa35bc0b6425bc019bb7e4ce08d20e8ba615139 (patch) | |
tree | a56dbf66e2e3b13aa4481682d5cf4bc73ecef6e9 /lib/Analysis/DataStructure/EquivClassGraphs.cpp | |
parent | 033a7d5389ee6827e33de3fa4602e10226e04170 (diff) |
Correctly handle new SCC's found as a result of merging EQ graphs do to
function pointer equivalences. This fixes many problems, including a testcase
reduced Prolangs-C++/objects.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17437 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/DataStructure/EquivClassGraphs.cpp')
-rw-r--r-- | lib/Analysis/DataStructure/EquivClassGraphs.cpp | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/lib/Analysis/DataStructure/EquivClassGraphs.cpp b/lib/Analysis/DataStructure/EquivClassGraphs.cpp index 43cd46198b..6a2c29836b 100644 --- a/lib/Analysis/DataStructure/EquivClassGraphs.cpp +++ b/lib/Analysis/DataStructure/EquivClassGraphs.cpp @@ -306,19 +306,32 @@ processSCC(DSGraph &FG, std::vector<DSGraph*> &Stack, unsigned &NextID, return Min; // This is part of a larger SCC! // If this is a new SCC, process it now. - bool IsMultiNodeSCC = false; + bool MergedGraphs = false; while (Stack.back() != &FG) { DSGraph *NG = Stack.back(); ValMap[NG] = ~0U; - // Since all SCCs must be the same as those found in CBU, we do not need to - // do any merging. Make sure all functions in the SCC share the same graph. - assert(NG == &FG && "ECG discovered different SCC's than the CBU pass?"); + // If the SCC found is not the same as those found in CBU, make sure to + // merge the graphs as appropriate. + DSGraph::NodeMapTy NodeMap; + FG.cloneInto(*NG, FG.getScalarMap(), FG.getReturnNodes(), NodeMap); + + // Update the DSInfo map and delete the old graph... + for (DSGraph::ReturnNodesTy::iterator I = NG->getReturnNodes().begin(); + I != NG->getReturnNodes().end(); ++I) + DSInfo[I->first] = &FG; + // Remove NG from the ValMap since the pointer may get recycled. + ValMap.erase(NG); + delete NG; + MergedGraphs = true; Stack.pop_back(); - IsMultiNodeSCC = true; } + // Clean up the graph before we start inlining a bunch again. + if (MergedGraphs) + FG.removeTriviallyDeadNodes(); + Stack.pop_back(); processGraph(FG); |