[llvm-commits] CVS: reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp

Brian Gaeke gaeke at cs.uiuc.edu
Tue Oct 26 13:08:28 PDT 2004



Changes in directory reopt/lib/LightWtProfiling:

UnpackTraceFunction.cpp updated: 1.116 -> 1.117
---
Log message:

Finish writing placeSpilledArgs(). This fixes a couple of the broken
traces in 164.gzip.  Also, improve eliminatePhiAtTraceExit's doxygen
comment a little.


---
Diffs of the changes:  (+27 -10)

Index: reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp
diff -u reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp:1.116 reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp:1.117
--- reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp:1.116	Thu Oct 21 12:48:10 2004
+++ reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp	Tue Oct 26 15:08:18 2004
@@ -59,8 +59,10 @@
 }
 
 // defined in ValueAllocState.cpp:
-extern std::pair<AllocInfo, AllocInfo>
-GetValueAllocState (TraceFunction *TF, Value *V, bool preferLiveIn = true);
+extern std::pair<AllocInfo, AllocInfo> GetValueAllocState (TraceFunction *TF, Value *V, bool preferLiveIn = true);
+extern AllocInfo GetTraceFnValueAllocState (TraceFunction *TF, Value *V, bool preferLiveIn);
+extern AllocInfo GetMatrixFnValueAllocState (TraceFunction *TF, Value *V, bool
+preferLiveIn);
 
 // Commonly used registers:
 static const unsigned sp = SparcV9::o6, MatrixFP = SparcV9::i6,
@@ -432,7 +434,7 @@
 }
 
 /// eliminatePhiAtTraceExit - Perform Phi elimination for PN along trace exit
-/// edges.
+/// edges. Uses addLiveOutCopy to perform the actual copy insertion.
 ///
 void UnpackTraceFunction::eliminatePhiAtTraceExit (MachineFunction &MF,
                                                    MachineBasicBlock &MBB,
@@ -638,24 +640,39 @@
 /// stack frame.
 void UnpackTraceFunction::placeSpilledArgs () {
   SpilledArgMap.clear ();
-  for (unsigned a = 6, s = TF->TraceFn->asize(); a < s; ++a) {
-    // Get old position for argument #a using GetValueAllocState.  If it
-    // is not spilled in the TraceFn to an offset which is > 2047, then
+  if (6 >= TF->TraceFn->asize ())
+    return;
+  Function::aiterator argit = TF->TraceFn->abegin ();
+  std::advance (argit, 6);
+  for (unsigned a = 6, s = TF->TraceFn->asize (); a < s; ++a, ++argit) {
+    // Get old position for argument #a using GetValueAllocState.
+    AllocInfo TraceAI = GetTraceFnValueAllocState (TF, argit, true);
+    
+    // If it is not spilled in the TraceFn to an offset which is > 2047, then
     // it isn't in an invalid region of the stack frame, and we don't
     // have to relocate it.
-
+    if (TraceAI.AllocState != AllocInfo::Spilled || TraceAI.Placement < 2047)
+      continue;
+    
     // Find a new position for argument #a by using a similar formula to
     // that of stackOffsetForReg(). For the formula's purposes, we can
     // treat excess args as being "registers" numbered starting with
     // SparcV9::fsr + 1.
-
+    static const unsigned LastReg = SparcV9::fsr; // highest-numbered reg.
+    int newStackOffset = stackOffsetForReg (LastReg + (a - (6 - 1)));
+    
     // Use the new position (which is relative to sp) to calculate an
     // offset from fp instead, by subtracting the TotalStackSize. The
     // result should be > 0 and < 2047.
-
+    int newFramePtrOffset = newStackOffset - TotalStackSize;
+    DEBUG (std::cerr << "placeSpilledArgs: Repositioning arg #" << a << " ("
+           << *argit << ") from spill slot at " << TraceAI.Placement
+           << " to new stack offset " << newStackOffset
+           << " = new frame ptr offset " << newFramePtrOffset << "\n");
+    
     // Put the <old position, new position> pair into the SpilledArgMap.
+    SpilledArgMap[TraceAI.Placement] = newFramePtrOffset;
   }
-  // FIXME - implement
 }
 
 int UnpackTraceFunction::fixupSpilledArgPlacement (int offset) {






More information about the llvm-commits mailing list