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

Brian Gaeke gaeke at cs.uiuc.edu
Wed Mar 31 15:06:01 PST 2004


Changes in directory reopt/lib/LightWtProfiling:

UnpackTraceFunction.cpp updated: 1.46 -> 1.47

---
Log message:

Blow away rewritePrologEpilog; copy in getStaticStackSize... we're
going to work on REALLY rewriting the prolog and epilog


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

Index: reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp
diff -u reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp:1.46 reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp:1.47
--- reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp:1.46	Wed Mar 31 10:29:53 2004
+++ reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp	Wed Mar 31 15:05:35 2004
@@ -15,6 +15,7 @@
 
 #include "TraceToFunction.h"
 #include "llvm/CodeGen/MachineFunctionPass.h"
+#include "llvm/CodeGen/MachineFunctionInfo.h"
 #include "llvm/CodeGen/MachineInstr.h"
 #include "llvm/IntrinsicLowering.h"
 #include "llvm/Module.h"
@@ -37,33 +38,26 @@
   TargetMachine *TM;
 public:
   SparcV9ReoptInfo (TargetMachine *_TM) : TM (_TM) {}
-  void rewritePrologEpilog (MachineFunction &MF);
+  unsigned getStaticStackSize (MachineFunction &MF);
   void insertCopyMachineInstrs (AllocInfo &Source, AllocInfo &Target,
                                 MachineBasicBlock &B, const Type *Ty);
   void insertBranchMachineInstrs (uint64_t Target, MachineBasicBlock &B);
   const MachineInstr *containsReturnInstr (MachineBasicBlock &B);
 };
 
-void SparcV9ReoptInfo::rewritePrologEpilog (MachineFunction &MF) {
-  bool foundSave = false, foundRestore = false;
-  int stackOffset = 0;
-  for (MachineFunction::iterator fi = MF.begin (), fe = MF.end (); fi != fe; ++fi) {
-    for (MachineBasicBlock::iterator bi = fi->begin (), be = fi->end (); bi != be; ++bi) {
-      MachineInstr &mi = *bi;
-      if (mi.getOpcode () == V9::SAVEi) {
-        mi.setOpcode (V9::ADDi);
-        foundSave = true;
-        for (unsigned i = 0, e = mi.getNumOperands (); i != e; ++i) {
-          if (mi.getOperand (i).isImmediate ()) {
-            stackOffset = mi.getOperand (i).getImmedValue ();
-          }
-        }
-      }
-    }
-  }
-  assert (foundSave && "Didn't find SAVE instruction in prolog");
-  assert (stackOffset != 0 && "Didn't find frame size in SAVE instruction");
-  assert (foundRestore && "Didn't find RESTORE instruction in prolog");
+// Ripped off from SparcV9PrologEpilogInserter
+unsigned SparcV9ReoptInfo::getStaticStackSize (MachineFunction &MF) {
+  const TargetFrameInfo& frameInfo = MF.getTarget().getFrameInfo();
+
+  unsigned staticStackSize = MF.getInfo()->getStaticStackSize();
+
+  if (staticStackSize < (unsigned) frameInfo.getMinStackFrameSize())
+    staticStackSize = (unsigned) frameInfo.getMinStackFrameSize();
+  if (unsigned padsz = (staticStackSize %
+                        (unsigned) frameInfo.getStackFrameSizeAlignment()))
+    staticStackSize += frameInfo.getStackFrameSizeAlignment() - padsz;
+
+  return staticStackSize;
 }
 
 /// Insert the appropriate machine instruction(s) that copies the value in





More information about the llvm-commits mailing list