[llvm-commits] [llvm] r49167 - in /llvm/trunk: include/llvm/CodeGen/LiveInterval.h lib/CodeGen/RegAllocLinearScan.cpp
Evan Cheng
evan.cheng at apple.com
Thu Apr 3 09:40:27 PDT 2008
Author: evancheng
Date: Thu Apr 3 11:40:27 2008
New Revision: 49167
URL: http://llvm.org/viewvc/llvm-project?rev=49167&view=rev
Log:
Special handling of zero-sized live intervals.
Modified:
llvm/trunk/include/llvm/CodeGen/LiveInterval.h
llvm/trunk/lib/CodeGen/RegAllocLinearScan.cpp
Modified: llvm/trunk/include/llvm/CodeGen/LiveInterval.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/LiveInterval.h?rev=49167&r1=49166&r2=49167&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/LiveInterval.h (original)
+++ llvm/trunk/include/llvm/CodeGen/LiveInterval.h Thu Apr 3 11:40:27 2008
@@ -275,14 +275,16 @@
/// beginNumber - Return the lowest numbered slot covered by interval.
unsigned beginNumber() const {
- assert(!empty() && "empty interval for register");
+ if (empty())
+ return 0;
return ranges.front().start;
}
/// endNumber - return the maximum point of the interval of the whole,
/// exclusive.
unsigned endNumber() const {
- assert(!empty() && "empty interval for register");
+ if (empty())
+ return 0;
return ranges.back().end;
}
Modified: llvm/trunk/lib/CodeGen/RegAllocLinearScan.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/RegAllocLinearScan.cpp?rev=49167&r1=49166&r2=49167&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/RegAllocLinearScan.cpp (original)
+++ llvm/trunk/lib/CodeGen/RegAllocLinearScan.cpp Thu Apr 3 11:40:27 2008
@@ -322,11 +322,13 @@
++NumIters;
DOUT << "\n*** CURRENT ***: " << *cur << '\n';
- processActiveIntervals(cur->beginNumber());
- processInactiveIntervals(cur->beginNumber());
+ if (!cur->empty()) {
+ processActiveIntervals(cur->beginNumber());
+ processInactiveIntervals(cur->beginNumber());
- assert(TargetRegisterInfo::isVirtualRegister(cur->reg) &&
- "Can only allocate virtual registers!");
+ assert(TargetRegisterInfo::isVirtualRegister(cur->reg) &&
+ "Can only allocate virtual registers!");
+ }
// Allocating a virtual register. try to find a free
// physical register or spill an interval (possibly this one) in order to
@@ -508,11 +510,23 @@
{
DOUT << "\tallocating current interval: ";
+ // This is an implicitly defined live interval, just assign any register.
+ const TargetRegisterClass *RC = reginfo_->getRegClass(cur->reg);
+ if (cur->empty()) {
+ unsigned physReg = cur->preference;
+ if (!physReg)
+ physReg = *RC->allocation_order_begin(*mf_);
+ DOUT << tri_->getName(physReg) << '\n';
+ // Note the register is not really in use.
+ vrm_->assignVirt2Phys(cur->reg, physReg);
+ handled_.push_back(cur);
+ return;
+ }
+
PhysRegTracker backupPrt = *prt_;
std::vector<std::pair<unsigned, float> > SpillWeightsToAdd;
unsigned StartPosition = cur->beginNumber();
- const TargetRegisterClass *RC = reginfo_->getRegClass(cur->reg);
const TargetRegisterClass *RCLeader = RelatedRegClasses.getLeaderValue(RC);
// If this live interval is defined by a move instruction and its source is
More information about the llvm-commits
mailing list