[llvm-commits] [llvm] r56384 - in /llvm/trunk/lib/CodeGen: RegAllocLinearScan.cpp SimpleRegisterCoalescing.cpp

Dale Johannesen dalej at apple.com
Fri Sep 19 19:03:04 PDT 2008


Author: johannes
Date: Fri Sep 19 21:03:04 2008
New Revision: 56384

URL: http://llvm.org/viewvc/llvm-project?rev=56384&view=rev
Log:
Teach coalescer about earlyclobber bits.
Check bits for preferred register.


Modified:
    llvm/trunk/lib/CodeGen/RegAllocLinearScan.cpp
    llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp

Modified: llvm/trunk/lib/CodeGen/RegAllocLinearScan.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/RegAllocLinearScan.cpp?rev=56384&r1=56383&r2=56384&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/RegAllocLinearScan.cpp (original)
+++ llvm/trunk/lib/CodeGen/RegAllocLinearScan.cpp Fri Sep 19 21:03:04 2008
@@ -1122,9 +1122,12 @@
   unsigned FreeRegInactiveCount = 0;
 
   // If copy coalescer has assigned a "preferred" register, check if it's
-  // available first.
+  // available first.  Coalescer can create new earlyclobber interferences,
+  // so we need to check that.
   if (cur->preference) {
-    if (prt_->isRegAvail(cur->preference) && RC->contains(cur->preference)) {
+    if (prt_->isRegAvail(cur->preference) && 
+        RC->contains(cur->preference) &&
+        noEarlyClobberConflict(cur, cur->preference)) {
       DOUT << "\t\tassigned the preferred register: "
            << tri_->getName(cur->preference) << "\n";
       return cur->preference;

Modified: llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp?rev=56384&r1=56383&r2=56384&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp (original)
+++ llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp Fri Sep 19 21:03:04 2008
@@ -1206,6 +1206,14 @@
   DOUT << " and "; DstInt.print(DOUT, tri_);
   DOUT << ": ";
 
+  // If one interval is earlyclobber and the other is overlaps-earlyclobber,
+  // we cannot coalesce them.
+  if ((SrcInt.isEarlyClobber && DstInt.overlapsEarlyClobber) ||
+      (DstInt.isEarlyClobber && SrcInt.overlapsEarlyClobber)) {
+    DOUT << "\t\tCannot join due to earlyclobber.";
+    return false;
+  }
+
   // Check if it is necessary to propagate "isDead" property.
   if (!isExtSubReg && !isInsSubReg) {
     MachineOperand *mopd = CopyMI->findRegisterDefOperand(DstReg, false);
@@ -1366,6 +1374,10 @@
   if (TargetRegisterInfo::isVirtualRegister(DstReg))
     RemoveUnnecessaryKills(DstReg, *ResDstInt);
 
+  // Merge the earlyclobber bits.
+  ResDstInt->isEarlyClobber |= ResSrcInt->isEarlyClobber;
+  ResDstInt->overlapsEarlyClobber |= ResSrcInt->overlapsEarlyClobber;
+
   if (isInsSubReg)
     // Avoid:
     // r1024 = op





More information about the llvm-commits mailing list