[llvm-commits] [llvm] r121519 - /llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp

Jakob Stoklund Olesen stoklund at 2pi.dk
Fri Dec 10 12:45:04 PST 2010


Author: stoklund
Date: Fri Dec 10 14:45:04 2010
New Revision: 121519

URL: http://llvm.org/viewvc/llvm-project?rev=121519&view=rev
Log:
Fix miscompilation caused by trivial logic error in the reassignVReg()
interference check.

Modified:
    llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp

Modified: llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp?rev=121519&r1=121518&r2=121519&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp (original)
+++ llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp Fri Dec 10 14:45:04 2010
@@ -81,6 +81,7 @@
   static char ID;
 
 private:
+  bool checkUncachedInterference(LiveInterval &, unsigned);
   bool reassignVReg(LiveInterval &InterferingVReg, unsigned OldPhysReg);
   bool reassignInterferences(LiveInterval &VirtReg, unsigned PhysReg);
 };
@@ -146,6 +147,20 @@
   return Priority;
 }
 
+// Check interference without using the cache.
+bool RAGreedy::checkUncachedInterference(LiveInterval &VirtReg,
+                                         unsigned PhysReg) {
+  LiveIntervalUnion::Query subQ(&VirtReg, &PhysReg2LiveUnion[PhysReg]);
+  if (subQ.checkInterference())
+      return true;
+  for (const unsigned *AliasI = TRI->getAliasSet(PhysReg); *AliasI; ++AliasI) {
+    subQ.init(&VirtReg, &PhysReg2LiveUnion[*AliasI]);
+    if (subQ.checkInterference())
+      return true;
+  }
+  return false;
+}
+
 // Attempt to reassign this virtual register to a different physical register.
 //
 // FIXME: we are not yet caching these "second-level" interferences discovered
@@ -168,18 +183,9 @@
     if (PhysReg == OldPhysReg || ReservedRegs.test(PhysReg))
       continue;
 
-    // Instantiate a "subquery", not to be confused with the Queries array.
-    LiveIntervalUnion::Query subQ(&InterferingVReg,
-                                  &PhysReg2LiveUnion[PhysReg]);
-    if (subQ.checkInterference())
+    if (checkUncachedInterference(InterferingVReg, PhysReg))
       continue;
 
-    for (const unsigned *AliasI = TRI->getAliasSet(PhysReg);
-         *AliasI; ++AliasI) {
-      subQ.init(&InterferingVReg, &PhysReg2LiveUnion[*AliasI]);
-      if (subQ.checkInterference())
-        continue;
-    }
     DEBUG(dbgs() << "reassigning: " << InterferingVReg << " from " <<
           TRI->getName(OldPhysReg) << " to " << TRI->getName(PhysReg) << '\n');
 





More information about the llvm-commits mailing list