[llvm-commits] CVS: llvm/lib/CodeGen/RegAllocLocal.cpp

Chris Lattner lattner at cs.uiuc.edu
Sat Aug 23 18:50:02 PDT 2003


Changes in directory llvm/lib/CodeGen:

RegAllocLocal.cpp updated: 1.26 -> 1.27

---
Log message:

Fix bug: Jello/2003-08-23-RegisterAllocatePhysReg.ll


---
Diffs of the changes:

Index: llvm/lib/CodeGen/RegAllocLocal.cpp
diff -u llvm/lib/CodeGen/RegAllocLocal.cpp:1.26 llvm/lib/CodeGen/RegAllocLocal.cpp:1.27
--- llvm/lib/CodeGen/RegAllocLocal.cpp:1.26	Sun Aug 17 13:01:15 2003
+++ llvm/lib/CodeGen/RegAllocLocal.cpp	Sat Aug 23 18:49:42 2003
@@ -400,19 +400,27 @@
              "Couldn't find a register of the appropriate class!");
       
       unsigned R = PhysRegsUseOrder[i];
-      // If the current register is compatible, use it.
-      if (RegInfo->getRegClass(R) == RC) {
-	PhysReg = R;
-	break;
-      } else {
-	// If one of the registers aliased to the current register is
-	// compatible, use it.
-	if (const unsigned *AliasSet = RegInfo->getAliasSet(R))
-	  for (unsigned a = 0; AliasSet[a]; ++a)
-	    if (RegInfo->getRegClass(AliasSet[a]) == RC) {
-	      PhysReg = AliasSet[a];    // Take an aliased register
-	      break;
-	    }
+
+      // We can only use this register if it holds a virtual register (ie, it
+      // can be spilled).  Do not use it if it is an explicitly allocated
+      // physical register!
+      assert(PhysRegsUsed.count(R) &&
+             "PhysReg in PhysRegsUseOrder, but is not allocated?");
+      if (PhysRegsUsed[R]) {
+        // If the current register is compatible, use it.
+        if (RegInfo->getRegClass(R) == RC) {
+          PhysReg = R;
+          break;
+        } else {
+          // If one of the registers aliased to the current register is
+          // compatible, use it.
+          if (const unsigned *AliasSet = RegInfo->getAliasSet(R))
+            for (unsigned a = 0; AliasSet[a]; ++a)
+              if (RegInfo->getRegClass(AliasSet[a]) == RC) {
+                PhysReg = AliasSet[a];    // Take an aliased register
+                break;
+              }
+        }
       }
     }
 





More information about the llvm-commits mailing list