summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/LiveIntervalAnalysis.cpp
diff options
context:
space:
mode:
authorEvan Cheng <evan.cheng@apple.com>2007-02-22 23:03:39 +0000
committerEvan Cheng <evan.cheng@apple.com>2007-02-22 23:03:39 +0000
commitcc607daac10984696aa6c4a1298e8335ef56bf9d (patch)
treed079f987c8b30ece64cb7e2df20c930bf6f08d16 /llvm/lib/CodeGen/LiveIntervalAnalysis.cpp
parent5cbb4262abff5a6ae9a8046971e2e04e723b9e44 (diff)
downloadbcm5719-llvm-cc607daac10984696aa6c4a1298e8335ef56bf9d.tar.gz
bcm5719-llvm-cc607daac10984696aa6c4a1298e8335ef56bf9d.zip
Remove unnecessary isKill properties if a live range has been lengthened due to coalescing.
llvm-svn: 34503
Diffstat (limited to 'llvm/lib/CodeGen/LiveIntervalAnalysis.cpp')
-rw-r--r--llvm/lib/CodeGen/LiveIntervalAnalysis.cpp25
1 files changed, 24 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/LiveIntervalAnalysis.cpp b/llvm/lib/CodeGen/LiveIntervalAnalysis.cpp
index 29c095a1aa4..f03830ab1d3 100644
--- a/llvm/lib/CodeGen/LiveIntervalAnalysis.cpp
+++ b/llvm/lib/CodeGen/LiveIntervalAnalysis.cpp
@@ -959,10 +959,22 @@ bool LiveIntervals::JoinCopy(MachineInstr *CopyMI,
DOUT << "\n\t\tJoined. Result = "; DestInt.print(DOUT, mri_);
DOUT << "\n";
-
+
// If the intervals were swapped by Join, swap them back so that the register
// mapping (in the r2i map) is correct.
if (Swapped) SrcInt.swap(DestInt);
+
+ // Live range has been lengthened due to colaescing, eliminate the
+ // unnecessary kills at the end of the source live ranges.
+ LiveVariables::VarInfo& vi = lv_->getVarInfo(repSrcReg);
+ for (unsigned i = 0, e = vi.Kills.size(); i != e; ++i) {
+ MachineInstr *Kill = vi.Kills[i];
+ if (Kill == CopyMI || isRemoved(Kill))
+ continue;
+ if (DestInt.liveAt(getInstructionIndex(Kill) + InstrSlots::NUM))
+ unsetRegisterKill(Kill, repSrcReg);
+ }
+
removeInterval(repSrcReg);
r2rMap_[repSrcReg] = repDstReg;
@@ -1471,6 +1483,17 @@ LiveIntervals::hasRegisterUse(unsigned Reg, unsigned Start, unsigned End) {
return false;
}
+/// unsetRegisterKill - Unset IsKill property of all uses of specific register
+/// of the specific instruction.
+void LiveIntervals::unsetRegisterKill(MachineInstr *MI, unsigned Reg) {
+ for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) {
+ MachineOperand &MO = MI->getOperand(i);
+ if (MO.isReg() && MO.isUse() && MO.isKill() && MO.getReg() &&
+ mri_->regsOverlap(rep(MO.getReg()), Reg))
+ MO.unsetIsKill();
+ }
+}
+
LiveInterval LiveIntervals::createInterval(unsigned reg) {
float Weight = MRegisterInfo::isPhysicalRegister(reg) ?
HUGE_VALF : 0.0F;
OpenPOWER on IntegriCloud