Fix an issue in PHI construction that was exposed by GCC 4.2 producing a different set iteration order for the reg_iterator.

llvm-svn: 63490
This commit is contained in:
Owen Anderson 2009-02-01 07:06:00 +00:00
parent 676130f2e1
commit 66838e9a27
1 changed files with 27 additions and 40 deletions

View File

@ -467,22 +467,6 @@ VNInfo* PreAllocSplitting::PerformPHIConstruction(
unsigned StartIndex = LIs->getMBBStartIdx(MBB); unsigned StartIndex = LIs->getMBBStartIdx(MBB);
if (MBB->pred_size() == 1) {
Phis[MBB] = ret = PerformPHIConstruction((*MBB->pred_begin())->end(),
*(MBB->pred_begin()), LI, Visited,
Defs, Uses, NewVNs, LiveOut, Phis,
false, false);
unsigned EndIndex = 0;
if (intrablock) {
EndIndex = LIs->getInstructionIndex(use);
EndIndex = LiveIntervals::getUseIndex(EndIndex);
} else
EndIndex = LIs->getMBBEndIdx(MBB);
LI->addRange(LiveRange(StartIndex, EndIndex+1, ret));
if (intrablock)
LI->addKill(ret, EndIndex);
} else {
Phis[MBB] = ret = LI->getNextValue(~0U, /*FIXME*/ 0, Phis[MBB] = ret = LI->getNextValue(~0U, /*FIXME*/ 0,
LIs->getVNInfoAllocator()); LIs->getVNInfoAllocator());
if (!intrablock) LiveOut[MBB] = ret; if (!intrablock) LiveOut[MBB] = ret;
@ -500,6 +484,9 @@ VNInfo* PreAllocSplitting::PerformPHIConstruction(
IncomingVNs[*PI] = Incoming; IncomingVNs[*PI] = Incoming;
} }
if (MBB->pred_size() == 1 && !ret->hasPHIKill) {
LI->MergeValueNumberInto(ret, IncomingVNs.begin()->second);
} else {
// Otherwise, merge the incoming VNInfos with a phi join. Create a new // Otherwise, merge the incoming VNInfos with a phi join. Create a new
// VNInfo to represent the joined value. // VNInfo to represent the joined value.
for (DenseMap<MachineBasicBlock*, VNInfo*>::iterator I = for (DenseMap<MachineBasicBlock*, VNInfo*>::iterator I =
@ -509,6 +496,7 @@ VNInfo* PreAllocSplitting::PerformPHIConstruction(
if (!LiveInterval::isKill(I->second, KillIndex)) if (!LiveInterval::isKill(I->second, KillIndex))
LI->addKill(I->second, KillIndex); LI->addKill(I->second, KillIndex);
} }
}
unsigned EndIndex = 0; unsigned EndIndex = 0;
if (intrablock) { if (intrablock) {
@ -519,7 +507,6 @@ VNInfo* PreAllocSplitting::PerformPHIConstruction(
LI->addRange(LiveRange(StartIndex, EndIndex+1, ret)); LI->addRange(LiveRange(StartIndex, EndIndex+1, ret));
if (intrablock) if (intrablock)
LI->addKill(ret, EndIndex); LI->addKill(ret, EndIndex);
}
} else if (ContainsDefs && !ContainsUses) { } else if (ContainsDefs && !ContainsUses) {
SmallPtrSet<MachineInstr*, 2>& BlockDefs = Defs[MBB]; SmallPtrSet<MachineInstr*, 2>& BlockDefs = Defs[MBB];