Handle the case where OldNodeMap == &ScalarMap correctly

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7000 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2003-06-30 05:09:29 +00:00
parent acbc8c6768
commit 2cb9acd785

View File

@ -784,18 +784,14 @@ void DSGraph::cloneInto(const DSGraph &G, ScalarMapTy &OldValMap,
// Copy the scalar map... merging all of the global nodes... // Copy the scalar map... merging all of the global nodes...
for (ScalarMapTy::const_iterator I = G.ScalarMap.begin(), for (ScalarMapTy::const_iterator I = G.ScalarMap.begin(),
E = G.ScalarMap.end(); I != E; ++I) { E = G.ScalarMap.end(); I != E; ++I) {
DSNodeHandle &H = OldValMap[I->first];
DSNodeHandle &MappedNode = OldNodeMap[I->second.getNode()]; DSNodeHandle &MappedNode = OldNodeMap[I->second.getNode()];
H.setOffset(I->second.getOffset()+MappedNode.getOffset()); DSNodeHandle &H = OldValMap[I->first];
H.setNode(MappedNode.getNode()); H.mergeWith(DSNodeHandle(MappedNode.getNode(),
I->second.getOffset()+MappedNode.getOffset()));
if (isa<GlobalValue>(I->first)) { // Is this a global? // If this is a global, add the global to this fn or merge if already exists
ScalarMapTy::iterator GVI = ScalarMap.find(I->first); if (isa<GlobalValue>(I->first) && &OldNodeMap != &ScalarMap)
if (GVI != ScalarMap.end()) // Is the global value in this fn already? ScalarMap[I->first].mergeWith(H);
GVI->second.mergeWith(H);
else
ScalarMap[I->first] = H; // Add global pointer to this graph
}
} }
if (!(CloneFlags & DontCloneCallNodes)) { if (!(CloneFlags & DontCloneCallNodes)) {
@ -832,8 +828,7 @@ void DSGraph::cloneInto(const DSGraph &G, ScalarMapTy &OldValMap,
/// ///
void DSGraph::mergeInGraph(DSCallSite &CS, Function &F, const DSGraph &Graph, void DSGraph::mergeInGraph(DSCallSite &CS, Function &F, const DSGraph &Graph,
unsigned CloneFlags) { unsigned CloneFlags) {
ScalarMapTy OldValMap; ScalarMapTy OldValMap, *ScalarMap;
ScalarMapTy *ScalarMap = &OldValMap;
DSNodeHandle RetVal; DSNodeHandle RetVal;
// If this is not a recursive call, clone the graph into this graph... // If this is not a recursive call, clone the graph into this graph...