[llvm-commits] [llvm] r132580 - /llvm/trunk/lib/CodeGen/RegisterClassInfo.cpp

Jakob Stoklund Olesen stoklund at 2pi.dk
Fri Jun 3 13:34:50 PDT 2011


Author: stoklund
Date: Fri Jun  3 15:34:50 2011
New Revision: 132580

URL: http://llvm.org/viewvc/llvm-project?rev=132580&view=rev
Log:
Preserve the original ordering when a CSR has multiple aliases.

Previously, these aliases would be ordered alphabetically. (BH, BL)

Print out the computed allocation orders.

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

Modified: llvm/trunk/lib/CodeGen/RegisterClassInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/RegisterClassInfo.cpp?rev=132580&r1=132579&r2=132580&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/RegisterClassInfo.cpp (original)
+++ llvm/trunk/lib/CodeGen/RegisterClassInfo.cpp Fri Jun  3 15:34:50 2011
@@ -14,10 +14,14 @@
 //
 //===----------------------------------------------------------------------===//
 
+#define DEBUG_TYPE "regalloc"
 #include "RegisterClassInfo.h"
 #include "llvm/CodeGen/MachineFunction.h"
 #include "llvm/Target/TargetMachine.h"
 
+#include "llvm/Support/Debug.h"
+#include "llvm/Support/raw_ostream.h"
+
 using namespace llvm;
 
 RegisterClassInfo::RegisterClassInfo() : Tag(0), MF(0), TRI(0), CalleeSaved(0)
@@ -86,8 +90,9 @@
     if (Reserved.test(PhysReg))
       continue;
     if (unsigned CSR = CSRNum[PhysReg])
-      // PhysReg aliases a CSR, save it for later.
-      CSRAlias.push_back(std::make_pair(CSR, PhysReg));
+      // PhysReg aliases a CSR, save it for later.  Provide a (CSR, N) sort key
+      // to preserve the original ordering of multiple aliases of the same CSR.
+      CSRAlias.push_back(std::make_pair((CSR << 16) + (I - AOB), PhysReg));
     else
       RCI.Order[N++] = PhysReg;
   }
@@ -101,6 +106,13 @@
   for (unsigned i = 0, e = CSRAlias.size(); i != e; ++i)
       RCI.Order[N++] = CSRAlias[i].second;
 
+  DEBUG({
+    dbgs() << "AllocationOrder(" << RC->getName() << ") = [";
+    for (unsigned I = 0; I != N; ++I)
+      dbgs() << ' ' << PrintReg(RCI.Order[I], TRI);
+    dbgs() << " ]\n";
+  });
+
   // RCI is now up-to-date.
   RCI.Tag = Tag;
 }





More information about the llvm-commits mailing list