[llvm-commits] [llvm] r48976 - /llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp

Evan Cheng evan.cheng at apple.com
Mon Mar 31 00:53:30 PDT 2008


Author: evancheng
Date: Mon Mar 31 02:53:30 2008
New Revision: 48976

URL: http://llvm.org/viewvc/llvm-project?rev=48976&view=rev
Log:
The support for remat of instructions with a register operand is hackish, to say the least. Since the register operand guaranteed to be PIC base and that it is already live at all uses, we are making sure it will not be spilled after its uses are rematerialized for both performance and correctness reasons.

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

Modified: llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp?rev=48976&r1=48975&r2=48976&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp (original)
+++ llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp Mon Mar 31 02:53:30 2008
@@ -886,15 +886,6 @@
       if (MI == ReMatOrigDefMI && CanDelete) {
         DOUT << "\t\t\t\tErasing re-materlizable def: ";
         DOUT << MI << '\n';
-        unsigned ImpUse = getReMatImplicitUse(li, MI);
-        if (ImpUse) {
-          // To be deleted MI has a virtual register operand, update the
-          // spill weight of the register interval.
-          unsigned loopDepth = loopInfo->getLoopDepth(MI->getParent());
-          LiveInterval &ImpLi = getInterval(ImpUse);
-          ImpLi.weight -=
-            getSpillWeight(false, true, loopDepth) / ImpLi.getSize();
-        }
         RemoveMachineInstrFromMaps(MI);
         vrm.RemoveMachineInstrFromMaps(MI);
         MI->eraseFromParent();
@@ -1116,6 +1107,7 @@
     MachineInstr *MI = &(*ri);
     MachineOperand &O = ri.getOperand();
     ++ri;
+    assert(!O.isImplicit() && "Spilling register that's used as implicit use?");
     unsigned index = getInstructionIndex(MI);
     if (index < start || index >= end)
       continue;
@@ -1147,11 +1139,10 @@
 
     if (ImpUse && MI != ReMatDefMI) {
       // Re-matting an instruction with virtual register use. Update the
-      // register interval's spill weight.
-      unsigned loopDepth = loopInfo->getLoopDepth(MI->getParent());
+      // register interval's spill weight to HUGE_VALF to prevent it from
+      // being spilled.
       LiveInterval &ImpLi = getInterval(ImpUse);
-      ImpLi.weight +=
-        getSpillWeight(false, true, loopDepth) * NumUses / ImpLi.getSize();
+      ImpLi.weight = HUGE_VALF;
     }
 
     unsigned MBBId = MBB->getNumber();
@@ -1575,12 +1566,10 @@
           if (ImpUse) {
             // Re-matting an instruction with virtual register use. Add the
             // register as an implicit use on the use MI and update the register
-            // interval's spill weight.
-            unsigned loopDepth = loopInfo->getLoopDepth(MI->getParent());
+            // interval's spill weight to HUGE_VALF to prevent it from being
+            // spilled.
             LiveInterval &ImpLi = getInterval(ImpUse);
-            ImpLi.weight +=
-              getSpillWeight(false, true, loopDepth) / ImpLi.getSize();
-
+            ImpLi.weight = HUGE_VALF;
             MI->addOperand(MachineOperand::CreateReg(ImpUse, false, true));
           }
         }





More information about the llvm-commits mailing list