[llvm-commits] CVS: reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp
Brian Gaeke
gaeke at cs.uiuc.edu
Thu Jul 1 03:41:02 PDT 2004
Changes in directory reopt/lib/LightWtProfiling:
UnpackTraceFunction.cpp updated: 1.89 -> 1.90
---
Log message:
Support live-out values which are spilled in the MatrixFn. (This appears to
fix Stanford/Towers.) Minor refactorings.
---
Diffs of the changes: (+29 -10)
Index: reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp
diff -u reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp:1.89 reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp:1.90
--- reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp:1.89 Fri Jun 25 23:56:14 2004
+++ reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp Thu Jul 1 03:39:48 2004
@@ -338,12 +338,15 @@
const SparcV9RegInfo &TRI = *TM->getRegInfo ();
std::vector<MachineInstr *> mvec;
static const unsigned sp = SparcV9::o6, fp = SparcV9::i6, g1 = SparcV9::g1,
- g2 = SparcV9::g2;
-
- assert (Target.AllocState == AllocInfo::Allocated
- && "Live-out values must be in regs in the matrixFn");
+ g2 = SparcV9::g2, g3 = SparcV9::g3;
+
+ assert ((Target.AllocState == AllocInfo::Allocated
+ || Target.AllocState == AllocInfo::Spilled)
+ && "Live-out values must be in regs or spilled in the matrixFn");
+
mvec.clear ();
- if (RegsToSave.find (Target.Placement) == RegsToSave.end ()) {
+ if (Target.AllocState == AllocInfo::Allocated
+ && RegsToSave.find (Target.Placement) == RegsToSave.end ()) {
DEBUG (std::cerr << "addLiveOutCopy: Adding live-out's matrixFn "
<< RegStr (Target.Placement) << " to RegsToSave set\n");
RegsToSave.insert (Target.Placement);
@@ -360,16 +363,32 @@
DEBUG (std::cerr << "addLiveOutCopy: " << liveOutValue->getName()
<< " is a constant in TraceFn\n");
// Copy the constant to the register.
- copyConstantToRegister (MF, cast<Constant> (liveOutTraceValue), g1,
+ copyConstantToRegister (MF, cast<Constant> (liveOutTraceValue), R,
g2, mvec);
} else if (Source.AllocState == AllocInfo::Spilled) {
// Copy live-out value from TraceFn's stack to the register.
TRI.cpMem2RegMI (mvec, fp, Source.Placement, R, RegType, g2);
}
- // Copy the live-out value from the register to the place on the
- // stack from which it will be restored to MatrixFn's register.
- TRI.cpReg2MemMI (mvec, R, sp, stackOffsetForReg (Target.Placement),
- RegType, g2);
+
+ // Most live-outs are in registers in MatrixFn. They get saved on TraceFn's
+ // stack (so sp is the base reg for the store) and reloaded from their
+ // individual slots (computed by stackOffsetForReg).
+ unsigned BaseReg = sp;
+ int Offset = stackOffsetForReg(Target.Placement);
+ if (Target.AllocState == AllocInfo::Spilled) {
+ // Since this live-out is spilled in MatrixFn, we'll need to copy the
+ // live-out value from the register to the place where it lives on
+ // MatrixFn's stack, so MatrixFn's frame pointer will be the base
+ // register. But first we need to load it from the stack (FIXME: we
+ // should only do this once!)
+ TRI.cpMem2RegMI (mvec, sp, stackOffsetForReg (fp), g3, TRI.getRegType(g3),
+ g2);
+ DEBUG (std::cerr << "addLiveOutCopy: loading matrixFn's frame pointer; "
+ << "value is spilled at offset = " << Target.Placement << "\n");
+ BaseReg = g3;
+ Offset = Target.Placement;
+ }
+ TRI.cpReg2MemMI (mvec, R, BaseReg, Offset, RegType, g2);
for (std::vector<MachineInstr *>::iterator vi = mvec.begin (),
ve = mvec.end (); vi != ve; ++vi)
MBB.push_back (*vi);
More information about the llvm-commits
mailing list