When reserving a preallocated register spill the aliases of this
authorAlkis Evlogimenos <alkis@evlogimenos.com>
Sat, 13 Dec 2003 11:58:10 +0000 (11:58 +0000)
committerAlkis Evlogimenos <alkis@evlogimenos.com>
Sat, 13 Dec 2003 11:58:10 +0000 (11:58 +0000)
register too.

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

lib/CodeGen/RegAllocLinearScan.cpp

index 8645a2b0448114a746480d31285610bfa3fe207f..dd94ad31c1f804abc7dd9bf6b8a083ce232ce427 100644 (file)
@@ -628,6 +628,22 @@ void RA::reservePhysReg(unsigned physReg)
         assignVirt2StackSlot(virtReg);
     }
     p2vMap_[physReg] = physReg; // this denotes a reserved physical register
+
+    // if it also aliases any other registers with values spill them too
+    for (const unsigned* as = mri_->getAliasSet(physReg); *as; ++as) {
+        unsigned virtReg = p2vMap_[*as];
+        if (virtReg != 0 && virtReg != *as) {
+            // remove interval from active
+            for (IntervalPtrs::iterator i = active_.begin(), e = active_.end();
+                 i != e; ++i) {
+                if ((*i)->reg == virtReg) {
+                    active_.erase(i);
+                    break;
+                }
+            }
+            assignVirt2StackSlot(virtReg);
+        }
+    }
 }
 
 void RA::clearReservedPhysReg(unsigned physReg)