[llvm-commits] [llvm] r103975 - /llvm/trunk/lib/CodeGen/RegAllocFast.cpp

Jakob Stoklund Olesen stoklund at 2pi.dk
Mon May 17 14:02:08 PDT 2010


Author: stoklund
Date: Mon May 17 16:02:08 2010
New Revision: 103975

URL: http://llvm.org/viewvc/llvm-project?rev=103975&view=rev
Log:
Pull the UsedInInstr.test() calls into calcSpillCost() and remember aliases.
This fixes the miscompilations of MultiSource/Applications/JM/l{en,de}cod.
Clang now successfully self hosts in a debug build with the fast register allocator.

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

Modified: llvm/trunk/lib/CodeGen/RegAllocFast.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/RegAllocFast.cpp?rev=103975&r1=103974&r2=103975&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/RegAllocFast.cpp (original)
+++ llvm/trunk/lib/CodeGen/RegAllocFast.cpp Mon May 17 16:02:08 2010
@@ -381,6 +381,8 @@
 // can be allocated directly.
 // Returns spillImpossible when PhysReg or an alias can't be spilled.
 unsigned RAFast::calcSpillCost(unsigned PhysReg) const {
+  if (UsedInInstr.test(PhysReg))
+    return spillImpossible;
   switch (unsigned VirtReg = PhysRegState[PhysReg]) {
   case regDisabled:
     break;
@@ -396,6 +398,8 @@
   unsigned Cost = 0;
   for (const unsigned *AS = TRI->getAliasSet(PhysReg);
        unsigned Alias = *AS; ++AS) {
+    if (UsedInInstr.test(Alias))
+      return spillImpossible;
     switch (unsigned VirtReg = PhysRegState[Alias]) {
     case regDisabled:
       break;
@@ -436,14 +440,11 @@
 
   // Ignore invalid hints.
   if (Hint && (!TargetRegisterInfo::isPhysicalRegister(Hint) ||
-               !RC->contains(Hint) || UsedInInstr.test(Hint) ||
-               !Allocatable.test(Hint)))
+               !RC->contains(Hint) || !Allocatable.test(Hint)))
     Hint = 0;
 
   // Take hint when possible.
   if (Hint) {
-    assert(RC->contains(Hint) && !UsedInInstr.test(Hint) &&
-           Allocatable.test(Hint) && "Invalid hint should have been cleared");
     switch(calcSpillCost(Hint)) {
     default:
       definePhysReg(MI, Hint, regFree);
@@ -470,7 +471,6 @@
 
   unsigned BestReg = 0, BestCost = spillImpossible;
   for (TargetRegisterClass::iterator I = AOB; I != AOE; ++I) {
-    if (UsedInInstr.test(*I)) continue;
     unsigned Cost = calcSpillCost(*I);
     // Cost is 0 when all aliases are already disabled.
     if (Cost == 0)





More information about the llvm-commits mailing list