[llvm-commits] CVS: reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp
Brian Gaeke
gaeke at cs.uiuc.edu
Sat Mar 13 13:13:02 PST 2004
Changes in directory reopt/lib/LightWtProfiling:
UnpackTraceFunction.cpp updated: 1.44 -> 1.45
---
Log message:
Fix some debug output.
Start fixing up prolog + epilog.
---
Diffs of the changes: (+30 -3)
Index: reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp
diff -u reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp:1.44 reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp:1.45
--- reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp:1.44 Thu Mar 11 03:33:04 2004
+++ reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp Sat Mar 13 13:11:58 2004
@@ -36,12 +36,35 @@
TargetMachine *TM;
public:
SparcV9ReoptInfo (TargetMachine *_TM) : TM (_TM) {}
+ void rewritePrologEpilog (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");
+}
+
/// Insert the appropriate machine instruction(s) that copies the value in
/// Source to the location specified by Target, at the beginning of B.
///
@@ -334,7 +357,8 @@
if (MF.getFunction () != TF->TraceFn)
return false;
- DEBUG(std::cerr << "In UnpackTraceFunction for " << MF.getFunction()->getName() << "()\n");
+ DEBUG(std::cerr << "In UnpackTraceFunction for "
+ << MF.getFunction()->getName() << "()\n");
Function *TraceF = TF->TraceFn, *MatrixF = TF->MatrixFn;
LiveVariableSet &Si = TF->LiveInSet, &So = TF->LiveOutSet;
@@ -348,7 +372,9 @@
// Insert copies from each live-in variable's reg. in the matrix fn.
// to its reg. in the trace.
Value *V = *SI;
- DEBUG(std::cerr << "UnpackTraceFunction: Looking for alloc state for value: \n" << *V << "\n");
+ DEBUG(std::cerr
+ << "UnpackTraceFunction: Looking for alloc state for value: \n"
+ << *V << "\n");
AllocInfo Source = getValueAllocStateFromModule (MatrixF, V);
DEBUG(std::cerr << "UnpackTraceFunction: Source = " << Source << "\n");
AllocInfo Target =
@@ -361,9 +387,10 @@
DEBUG(std::cerr << "UnpackTraceFunction: Inserting copy MachineInstrs:\n");
for (std::vector<CopyInfo>::iterator i = EntryCopies.begin (),
e = EntryCopies.end (); i != e; ++i) {
- DEBUG(std::cerr << "UnpackTraceFunction: " << *i);
+ DEBUG(std::cerr << "UnpackTraceFunction: " << *i << "\n");
SRI.insertCopyMachineInstrs (i->Src, i->Targ, *i->Blk, i->Ty);
}
+ DEBUG(std::cerr << "-------------\n\n");
// Modify EXIT MachineBasicBlocks of MF
for (MachineFunction::iterator I = MF.begin (), E = MF.end (); I != E; ++I) {
More information about the llvm-commits
mailing list