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

Brian Gaeke gaeke at cs.uiuc.edu
Wed May 26 04:45:01 PDT 2004


Changes in directory reopt/lib/LightWtProfiling:

UnpackTraceFunction.cpp updated: 1.72 -> 1.73

---
Log message:

Remember to copy caller's sp to callee's fp at end of saves.
Replace erroneous use of MachineOperand::UseAndDef with Def.
Don't bother with the if (Source!=Target) optimization.


---
Diffs of the changes:  (+21 -18)

Index: reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp
diff -u reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp:1.72 reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp:1.73
--- reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp:1.72	Tue May 25 15:43:48 2004
+++ reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp	Wed May 26 04:43:49 2004
@@ -217,7 +217,8 @@
 void UnpackTraceFunction::rewriteProlog (MachineFunction &MF,
                                          MachineBasicBlock &E) {
   const TargetRegInfo &TRI = TM->getRegInfo ();
-  static const unsigned sp = SparcV9::o6, g1 = SparcV9::g1, g2 = SparcV9::g2;
+  static const unsigned sp = SparcV9::o6, fp = SparcV9::i6, g1 = SparcV9::g1,
+    g2 = SparcV9::g2;
 
   // UTF prolog: start out by clearing everything out of the entry basic block
   // (FIXME: may not work once we start doing optimizations!!! We will probably
@@ -226,7 +227,7 @@
 
   // 0. Save caller's stack pointer in %g1.
   E.push_back (BuildMI (V9::ORr, 3).addMReg (sp).addZImm (0).addMReg (g1,
-    MachineOperand::UseAndDef));
+    MachineOperand::Def));
 
   // 1. Emit ADD instruction to allocate the right amount of stack space.
   E.push_back (BuildMI (V9::ADDi, 3).addMReg (sp).addSImm (-TotalStackSize)
@@ -278,6 +279,10 @@
       E.push_back (*vi);
   }
 
+  // Caller's stack pointer becomes our frame pointer.
+  E.push_back (BuildMI (V9::ORr, 3).addMReg (g1).addZImm (0).addMReg (fp,
+    MachineOperand::Def));
+
   // 4. Insert a copy for each live-in variable to copy it from the stack
   // to the register that was allocated for it in the TraceFn.
   for (LiveVariableSet::iterator SI = Si.begin (), SE = Si.end (); SI != SE;
@@ -285,22 +290,20 @@
     Value *V = *SI;
     std::pair<AllocInfo, AllocInfo> &ai = AllocStates[V];
     AllocInfo &Source = ai.first, &Target = ai.second;
-    if (Source != Target) {
-      assert (Target.AllocState == AllocInfo::Allocated
-              && "FIXME: can't do mem-->mem copy of live-ins yet");
-      // FIXME: The following should really be using insertCopyMachineInstrs or
-      // something like it.
-      mvec.clear ();
-      assert (TRI.getRegType (Target.Placement)
-              == TRI.getRegType (Source.Placement)
-              && "Live-in value changed reg type?!");
-      unsigned RegType = TRI.getRegType (Target.Placement);
-      TRI.cpMem2RegMI (mvec, sp, stackOffsetForReg (Source.Placement),
-                       Target.Placement, RegType, g2);
-      for (std::vector<MachineInstr *>::iterator vi = mvec.begin (),
-             ve = mvec.end (); vi != ve; ++vi)
-        E.push_back (*vi);
-    }
+    assert (Target.AllocState == AllocInfo::Allocated
+            && "FIXME: can't do mem-->mem copy of live-ins yet");
+    // FIXME: The following should really be using insertCopyMachineInstrs or
+    // something like it.
+    mvec.clear ();
+    assert (TRI.getRegType (Target.Placement)
+            == TRI.getRegType (Source.Placement)
+            && "Live-in value changed reg type?!");
+    unsigned RegType = TRI.getRegType (Target.Placement);
+    TRI.cpMem2RegMI (mvec, sp, stackOffsetForReg (Source.Placement),
+                     Target.Placement, RegType, g2);
+    for (std::vector<MachineInstr *>::iterator vi = mvec.begin (),
+           ve = mvec.end (); vi != ve; ++vi)
+      E.push_back (*vi);
   }
 }
 





More information about the llvm-commits mailing list