From: Chris Lattner Date: Thu, 18 Nov 2004 04:33:31 +0000 (+0000) Subject: Fix a couple of bugs where we considered physregs past their range as possibly X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=f348e3abfcca1b6366638ba8aa617118d090a305;p=oota-llvm.git Fix a couple of bugs where we considered physregs past their range as possibly intersecting an interval. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17939 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/RegAllocLinearScan.cpp b/lib/CodeGen/RegAllocLinearScan.cpp index 0cb30430a37..c63a0c18aec 100644 --- a/lib/CodeGen/RegAllocLinearScan.cpp +++ b/lib/CodeGen/RegAllocLinearScan.cpp @@ -145,6 +145,7 @@ bool RA::runOnMachineFunction(MachineFunction &fn) { tm_ = &fn.getTarget(); mri_ = tm_->getRegisterInfo(); li_ = &getAnalysis(); + if (!prt_.get()) prt_.reset(new PhysRegTracker(*mri_)); vrm_.reset(new VirtRegMap(*mf_)); if (!spiller_.get()) spiller_.reset(createSpiller()); @@ -393,12 +394,16 @@ void RA::assignRegOrStackSlotAtInterval(LiveInterval* cur) for (unsigned i = 0, e = fixed_.size(); i != e; ++i) { IntervalPtr &IP = fixed_[i]; LiveInterval *I = IP.first; - LiveInterval::iterator II = I->advanceTo(IP.second, StartPosition); - IP.second = II; - if (cur->overlapsFrom(*I, II)) { - unsigned reg = I->reg; - prt_->addRegUse(reg); - updateSpillWeights(reg, I->weight); + if (I->endNumber() > StartPosition) { + LiveInterval::iterator II = I->advanceTo(IP.second, StartPosition); + IP.second = II; + if (II != I->begin() && II->start > StartPosition) + --II; + if (cur->overlapsFrom(*I, II)) { + unsigned reg = I->reg; + prt_->addRegUse(reg); + updateSpillWeights(reg, I->weight); + } } }