[llvm-commits] CVS: llvm/lib/CodeGen/LiveIntervalAnalysis.cpp
Evan Cheng
evan.cheng at apple.com
Thu Feb 22 15:04:03 PST 2007
Changes in directory llvm/lib/CodeGen:
LiveIntervalAnalysis.cpp updated: 1.211 -> 1.212
---
Log message:
Remove unnecessary isKill properties if a live range has been lengthened due to coalescing.
---
Diffs of the changes: (+24 -1)
LiveIntervalAnalysis.cpp | 25 ++++++++++++++++++++++++-
1 files changed, 24 insertions(+), 1 deletion(-)
Index: llvm/lib/CodeGen/LiveIntervalAnalysis.cpp
diff -u llvm/lib/CodeGen/LiveIntervalAnalysis.cpp:1.211 llvm/lib/CodeGen/LiveIntervalAnalysis.cpp:1.212
--- llvm/lib/CodeGen/LiveIntervalAnalysis.cpp:1.211 Wed Feb 21 16:41:17 2007
+++ llvm/lib/CodeGen/LiveIntervalAnalysis.cpp Thu Feb 22 17:03:39 2007
@@ -959,10 +959,22 @@
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 @@
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;
More information about the llvm-commits
mailing list