summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/StrongPHIElimination.cpp
diff options
context:
space:
mode:
authorOwen Anderson <resistor@mac.com>2008-07-25 23:38:08 +0000
committerOwen Anderson <resistor@mac.com>2008-07-25 23:38:08 +0000
commit54912b3e8dbf944d94fbfd54ab4914ecf39832a5 (patch)
tree4fc1b4b7c915eaac2de27b36cf691c53c494b9d6 /llvm/lib/CodeGen/StrongPHIElimination.cpp
parent0478105f7c618a939da185438cc299f304aeeb9a (diff)
downloadbcm5719-llvm-54912b3e8dbf944d94fbfd54ab4914ecf39832a5.tar.gz
bcm5719-llvm-54912b3e8dbf944d94fbfd54ab4914ecf39832a5.zip
Fix the issues originally addressed in r54070. After thinking about it some more, I realized that the right thing to do
is to have StrongPHIElimination use its knowledge of the PHIs before they're erased to update the intervals appropriate. This is both simpler and more accurate than the alternative, which was having LIA figure it out when it renumbered things, plus it's just the right thing to do! llvm-svn: 54077
Diffstat (limited to 'llvm/lib/CodeGen/StrongPHIElimination.cpp')
-rw-r--r--llvm/lib/CodeGen/StrongPHIElimination.cpp21
1 files changed, 19 insertions, 2 deletions
diff --git a/llvm/lib/CodeGen/StrongPHIElimination.cpp b/llvm/lib/CodeGen/StrongPHIElimination.cpp
index 7f98463e48c..399e6154184 100644
--- a/llvm/lib/CodeGen/StrongPHIElimination.cpp
+++ b/llvm/lib/CodeGen/StrongPHIElimination.cpp
@@ -741,7 +741,7 @@ void StrongPHIElimination::ScheduleCopies(MachineBasicBlock* MBB,
std::set<unsigned> RegHandled;
for (SmallVector<std::pair<unsigned, MachineInstr*>, 4>::iterator I =
InsertedPHIDests.begin(), E = InsertedPHIDests.end(); I != E; ++I)
- if (!RegHandled.insert(I->first).second)
+ if (RegHandled.insert(I->first).second)
LI.addLiveRangeToEndOfBlock(I->first, I->second);
}
@@ -846,6 +846,19 @@ bool StrongPHIElimination::runOnMachineFunction(MachineFunction &Fn) {
I != E; ) {
MachineInstr* PInstr = *(I++);
+ // Trim live intervals of input registers. They are no longer live into
+ // this block.
+ for (unsigned i = 1; i < PInstr->getNumOperands(); i += 2) {
+ unsigned reg = PInstr->getOperand(i).getReg();
+ MachineBasicBlock* MBB = PInstr->getOperand(i+1).getMBB();
+ LiveInterval& InputI = LI.getInterval(reg);
+ if (MBB != PInstr->getParent() &&
+ InputI.liveAt(LI.getMBBStartIdx(PInstr->getParent())))
+ InputI.removeRange(LI.getMBBStartIdx(PInstr->getParent()),
+ LI.getInstructionIndex(PInstr),
+ true);
+ }
+
// If this is a dead PHI node, then remove it from LiveIntervals.
unsigned DestReg = PInstr->getOperand(0).getReg();
LiveInterval& PI = LI.getInterval(DestReg);
@@ -860,7 +873,11 @@ bool StrongPHIElimination::runOnMachineFunction(MachineFunction &Fn) {
// If the PHI is not dead, then the valno defined by the PHI
// now has an unknown def.
unsigned idx = LI.getDefIndex(LI.getInstructionIndex(PInstr));
- PI.getLiveRangeContaining(idx)->valno->def = ~0U;
+ const LiveRange* PLR = PI.getLiveRangeContaining(idx);
+ PLR->valno->def = ~0U;
+ LiveRange R (LI.getMBBStartIdx(PInstr->getParent()),
+ PLR->start, PLR->valno);
+ PI.addRange(R);
}
LI.RemoveMachineInstrFromMaps(PInstr);
OpenPOWER on IntegriCloud