MergeValueInto is too smart: it might choose to do the merge the opposite direction.

Live interval reconstruction needs to account for this, and scour its maps to
prevent dangling references.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@63558 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Owen Anderson
2009-02-02 22:42:01 +00:00
parent 8a782a2a8c
commit 5b93f6fa82
3 changed files with 22 additions and 4 deletions
+18 -2
View File
@@ -654,8 +654,24 @@ PreAllocSplitting::PerformPHIConstructionFallBack(MachineBasicBlock::iterator Us
}
if (MBB->pred_size() == 1 && !RetVNI->hasPHIKill) {
LI->MergeValueNumberInto(RetVNI, IncomingVNs.begin()->second);
Phis[MBB] = RetVNI = IncomingVNs.begin()->second;
VNInfo* OldVN = RetVNI;
VNInfo* NewVN = IncomingVNs.begin()->second;
VNInfo* MergedVN = LI->MergeValueNumberInto(OldVN, NewVN);
if (MergedVN == OldVN) std::swap(OldVN, NewVN);
for (DenseMap<MachineBasicBlock*, VNInfo*>::iterator LOI = LiveOut.begin(),
LOE = LiveOut.end(); LOI != LOE; ++LOI)
if (LOI->second == OldVN)
LOI->second = MergedVN;
for (DenseMap<MachineInstr*, VNInfo*>::iterator NVI = NewVNs.begin(),
NVE = NewVNs.end(); NVI != NVE; ++NVI)
if (NVI->second == OldVN)
NVI->second = MergedVN;
for (DenseMap<MachineBasicBlock*, VNInfo*>::iterator PI = Phis.begin(),
PE = Phis.end(); PI != PE; ++PI)
if (PI->second == OldVN)
PI->second = MergedVN;
RetVNI = MergedVN;
} else {
// Otherwise, merge the incoming VNInfos with a phi join. Create a new
// VNInfo to represent the joined value.