Clean up code that calculate MBB live-in's.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43061 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Evan Cheng 2007-10-17 02:12:22 +00:00
parent 4ca980e7f9
commit 3f4b80ec0c

View File

@ -288,23 +288,25 @@ void RALinScan::linearScan()
DOUT << "\tinterval " << *i->first << " expired\n"); DOUT << "\tinterval " << *i->first << " expired\n");
inactive_.clear(); inactive_.clear();
// A brute force way of adding live-ins to every BB. // Add live-ins to every BB except for entry.
MachineFunction::iterator MBB = mf_->begin(); MachineFunction::iterator EntryMBB = mf_->begin();
++MBB; // Skip entry MBB. for (LiveIntervals::iterator i = li_->begin(), e = li_->end(); i != e; ++i) {
for (MachineFunction::iterator E = mf_->end(); MBB != E; ++MBB) { const LiveInterval &cur = i->second;
unsigned StartIdx = li_->getMBBStartIdx(MBB->getNumber()); unsigned Reg = 0;
for (IntervalPtrs::iterator i = fixed_.begin(), e = fixed_.end(); if (MRegisterInfo::isPhysicalRegister(cur.reg))
i != e; ++i) Reg = i->second.reg;
if (i->first->liveAt(StartIdx)) else if (vrm_->isAssignedReg(cur.reg))
MBB->addLiveIn(i->first->reg); Reg = vrm_->getPhys(cur.reg);
if (!Reg)
for (unsigned i = 0, e = handled_.size(); i != e; ++i) { continue;
LiveInterval *HI = handled_[i]; for (LiveInterval::Ranges::const_iterator I = cur.begin(), E = cur.end();
unsigned Reg = HI->reg; I != E; ++I) {
if (vrm_->isAssignedReg(Reg) && HI->liveAt(StartIdx)) { const LiveRange &LR = *I;
assert(MRegisterInfo::isVirtualRegister(Reg)); SmallVector<MachineBasicBlock*, 4> LiveInMBBs;
Reg = vrm_->getPhys(Reg); if (li_->findLiveInMBBs(LR, LiveInMBBs)) {
MBB->addLiveIn(Reg); for (unsigned i = 0, e = LiveInMBBs.size(); i != e; ++i)
if (LiveInMBBs[i] != EntryMBB)
LiveInMBBs[i]->addLiveIn(Reg);
} }
} }
} }