Fix a couple of bugs where we considered physregs past their range as possibly
authorChris Lattner <sabre@nondot.org>
Thu, 18 Nov 2004 04:33:31 +0000 (04:33 +0000)
committerChris Lattner <sabre@nondot.org>
Thu, 18 Nov 2004 04:33:31 +0000 (04:33 +0000)
intersecting an interval.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17939 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/RegAllocLinearScan.cpp

index 0cb30430a37b92faa76bf22d71f354e2f846b15f..c63a0c18aec2be55e7e857d5ad44301010a37e63 100644 (file)
@@ -145,6 +145,7 @@ bool RA::runOnMachineFunction(MachineFunction &fn) {
   tm_ = &fn.getTarget();
   mri_ = tm_->getRegisterInfo();
   li_ = &getAnalysis<LiveIntervals>();
+
   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);
+      }
     }
   }