[llvm-commits] [llvm] r127965 - /llvm/trunk/lib/CodeGen/InlineSpiller.cpp

Jakob Stoklund Olesen stoklund at 2pi.dk
Sat Mar 19 22:44:58 PDT 2011


Author: stoklund
Date: Sun Mar 20 00:44:58 2011
New Revision: 127965

URL: http://llvm.org/viewvc/llvm-project?rev=127965&view=rev
Log:
Also eliminate redundant spills downstream of inserted reloads.

This can happen when multiple sibling registers are spilled after live range
splitting.

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

Modified: llvm/trunk/lib/CodeGen/InlineSpiller.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/InlineSpiller.cpp?rev=127965&r1=127964&r2=127965&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/InlineSpiller.cpp (original)
+++ llvm/trunk/lib/CodeGen/InlineSpiller.cpp Sun Mar 20 00:44:58 2011
@@ -466,6 +466,7 @@
 /// eliminateRedundantSpills - SLI:VNI is known to be on the stack. Remove any
 /// redundant spills of this value in SLI.reg and sibling copies.
 void InlineSpiller::eliminateRedundantSpills(LiveInterval &SLI, VNInfo *VNI) {
+  assert(VNI && "Missing value");
   SmallVector<std::pair<LiveInterval*, VNInfo*>, 8> WorkList;
   WorkList.push_back(std::make_pair(&SLI, VNI));
   LiveInterval &StackInt = LSS.getInterval(StackSlot);
@@ -793,15 +794,22 @@
 
     // Check for a sibling copy.
     unsigned SibReg = isFullCopyOf(MI, Reg);
-    if (!isSibling(SibReg))
-      SibReg = 0;
-
-    // Hoist the spill of a sib-reg copy.
-    if (SibReg && Writes && !Reads && hoistSpill(OldLI, MI)) {
-      // This COPY is now dead, the value is already in the stack slot.
-      MI->getOperand(0).setIsDead();
-      DeadDefs.push_back(MI);
-      continue;
+    if (SibReg && isSibling(SibReg)) {
+      if (Writes) {
+        // Hoist the spill of a sib-reg copy.
+        if (hoistSpill(OldLI, MI)) {
+          // This COPY is now dead, the value is already in the stack slot.
+          MI->getOperand(0).setIsDead();
+          DeadDefs.push_back(MI);
+          continue;
+        }
+      } else {
+        // This is a reload for a sib-reg copy. Drop spills downstream.
+        SlotIndex Idx = LIS.getInstructionIndex(MI).getDefIndex();
+        LiveInterval &SibLI = LIS.getInterval(SibReg);
+        eliminateRedundantSpills(SibLI, SibLI.getVNInfoAt(Idx));
+        // The COPY will fold to a reload below.
+      }
     }
 
     // Attempt to fold memory ops.





More information about the llvm-commits mailing list