aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/LiveIntervalAnalysis.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-07-25 05:45:18 +0000
committerChris Lattner <sabre@nondot.org>2004-07-25 05:45:18 +0000
commit62d4e16a059b5bbcd49b1bcab0d4854e784821f9 (patch)
tree2b88a8a8e0fcc72caabae4352ff84b1d76991e17 /lib/CodeGen/LiveIntervalAnalysis.cpp
parent6925a9f9cc0b9d34cfbc19d9208c416e293ca516 (diff)
Fix a bug where we incorrectly value numbered the first PHI definition the
same as the PHI use. This is not correct as the PHI use value is different depending on which branch is taken. This fixes espresso with aggressive coallescing, and perhaps others. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@15189 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/LiveIntervalAnalysis.cpp')
-rw-r--r--lib/CodeGen/LiveIntervalAnalysis.cpp29
1 files changed, 26 insertions, 3 deletions
diff --git a/lib/CodeGen/LiveIntervalAnalysis.cpp b/lib/CodeGen/LiveIntervalAnalysis.cpp
index d54eaefb66..361210e106 100644
--- a/lib/CodeGen/LiveIntervalAnalysis.cpp
+++ b/lib/CodeGen/LiveIntervalAnalysis.cpp
@@ -393,9 +393,32 @@ void LiveIntervals::handleVirtualRegisterDef(MachineBasicBlock* mbb,
DEBUG(std::cerr << "RESULT: " << interval);
} else {
- // Otherwise, this must be because of phi elimination. In this case,
- // the defined value will be live until the end of the basic block it
- // is defined in.
+ // Otherwise, this must be because of phi elimination. If this is the
+ // first redefinition of the vreg that we have seen, go back and change
+ // the live range in the PHI block to be a different value number.
+ if (interval.containsOneValue()) {
+ assert(vi.Kills.size() == 1 &&
+ "PHI elimination vreg should have one kill, the PHI itself!");
+
+ // Remove the old range that we now know has an incorrect number.
+ MachineInstr *Killer = vi.Kills[0];
+ unsigned Start = getInstructionIndex(Killer->getParent()->begin());
+ unsigned End = getUseIndex(getInstructionIndex(Killer))+1;
+ DEBUG(std::cerr << "Removing [" << Start << "," << End << "] from: "
+ << interval << "\n");
+ interval.removeRange(Start, End);
+ DEBUG(std::cerr << "RESULT: " << interval);
+
+ // Replace the interval with one of a NEW value number.
+ LiveRange LR(Start, End, interval.getNextValue());
+ DEBUG(std::cerr << " replace range with " << LR);
+ interval.addRange(LR);
+ DEBUG(std::cerr << "RESULT: " << interval);
+ }
+
+ // In the case of PHI elimination, each variable definition is only
+ // live until the end of the block. We've already taken care of the
+ // rest of the live range.
unsigned defIndex = getDefIndex(getInstructionIndex(mi));
LiveRange LR(defIndex,
getInstructionIndex(&mbb->back()) + InstrSlots::NUM,