[llvm-commits] CVS: reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp
Brian Gaeke
gaeke at cs.uiuc.edu
Sun Jul 11 05:04:01 PDT 2004
Changes in directory reopt/lib/LightWtProfiling:
UnpackTraceFunction.cpp updated: 1.94 -> 1.95
---
Log message:
Add a boolean 'fpIsTraceFP' used for assertions about when it is OK to call
addLiveOutCopy.
Update comments and some debug msgs.
Do trace exit phi elimination after other live-out copies, not before.
---
Diffs of the changes: (+33 -26)
Index: reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp
diff -u reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp:1.94 reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp:1.95
--- reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp:1.94 Fri Jul 9 15:55:35 2004
+++ reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp Sun Jul 11 05:02:55 2004
@@ -253,6 +253,7 @@
// reference the new frame pointer (g1).
E.push_back (BuildMI (V9::ORr, 3).addMReg (g1).addZImm (0)
.addMReg (fp, MachineOperand::Def));
+ fpIsTraceFP = true;
MachineBasicBlock::iterator MBBIt = EntryBB.begin ();
for (std::vector<MachineInstr *>::iterator ei = E.begin (), ee = E.end ();
@@ -346,6 +347,8 @@
static const unsigned sp = SparcV9::o6, fp = SparcV9::i6, g1 = SparcV9::g1,
g2 = SparcV9::g2, g3 = SparcV9::g3;
+ assert (fpIsTraceFP
+ && "Can't call addLiveOutCopy without TraceFn stack frame pointer");
assert ((Target.AllocState == AllocInfo::Allocated
|| Target.AllocState == AllocInfo::Spilled)
&& "Live-out values must be in regs or spilled in the matrixFn");
@@ -400,7 +403,8 @@
MBB.push_back (*vi);
}
-/// eliminatePhiAtTraceExit - Perform Phi elimination along trace exit edges.
+/// eliminatePhiAtTraceExit - Perform Phi elimination for PN along trace exit
+/// edges.
///
void UnpackTraceFunction::eliminatePhiAtTraceExit (MachineFunction &MF,
MachineBasicBlock &MBB,
@@ -412,24 +416,25 @@
const BasicBlock *Src = PN->getIncomingBlock (i);
if (TF->T.contains (Src)) {
BasicBlock *SrcTTF = cast<BasicBlock> (TF->getCorrespondingValue (Src));
- DEBUG (std::cerr << "rewriteEpilog: considering Phi node "
+ DEBUG (std::cerr << "eliminatePhiAtTraceExit: considering Phi node "
<< PN->getName ()
<< ", found on-trace source #" << i << " (" << Src->getName ()
<< ", corresponding to " << SrcTTF->getName () << " on trace)\n"
<< *PN << "\n");
const BasicBlock *TraceExitingBB = *pred_begin(MBB.getBasicBlock ());
- DEBUG (std::cerr << "rewriteEpilog: trace exiting BB for this block is "
+ DEBUG (std::cerr << "eliminatePhiAtTraceExit: trace exiting BB for this"
+ << " block is "
<< TraceExitingBB->getName () << "\n");
if (TraceExitingBB == SrcTTF) {
Value *V = PN->getIncomingValue (i);
- DEBUG (std::cerr << "rewriteEpilog: found match: trace exiting BB is "
- << "phi source; phi's incoming value from " << Src->getName ()
- << " is " << V->getName () << "\n");
+ DEBUG (std::cerr << "eliminatePhiAtTraceExit: found match: trace "
+ << "exiting BB is phi source; phi's incoming value from "
+ << Src->getName () << " is " << V->getName () << "\n");
std::pair<AllocInfo, AllocInfo> outgoingValueAI =
GetValueAllocState (TF, V, false);
std::pair<AllocInfo, AllocInfo> phiCpAI = // we want the PhiCp node
GetValueAllocState (TF, const_cast<PHINode *> (PN), true);
- DEBUG (std::cerr << "rewriteEpilog: Outgoing value is in ";
+ DEBUG (std::cerr << "eliminatePhiAtTraceExit: Outgoing value is in ";
PrintAI (outgoingValueAI.second);
std::cerr << " in TraceFn, and " << PN->getName()
<< "'s PhiCp node is in ";
@@ -437,7 +442,8 @@
std::cerr << " in MatrixFn\n");
AllocInfo &Target = phiCpAI.first, &Source = outgoingValueAI.second;
- DEBUG (std::cerr << "rewriteEpilog: copying live-out phi value: ";
+ DEBUG (std::cerr << "eliminatePhiAtTraceExit: copying live-out phi "
+ << "value: ";
PrintValueAIs(V->getName(), Target, Source));
addLiveOutCopy (MF, MBB, Source, Target, V,
TF->getCorrespondingValue (V, false));
@@ -458,23 +464,6 @@
// have to use a separate MBB)
MBB.clear ();
- // Find the BasicBlock in MatrixFn that this block's return instr.
- // would have returned to, by consulting the mapping information
- // generated by TraceFunctionBuilder.
- const ReturnInst *RI =
- cast<ReturnInst> (MBB.getBasicBlock ()->getTerminator ());
- const BasicBlock *RBB = TF->ReturnBlockForTraceExit[RI];
- assert (RBB && "Can't find matrix fn BB address to return to from trace");
- DEBUG (std::cerr << "rewriteEpilog: Return block for trace exit path is:\n"
- << *RBB << "\n");
-
- // If there are Phi nodes in the target of the trace-exiting branch, we must
- // eliminate them by inserting copies now.
- for (BasicBlock::const_iterator Inst = RBB->begin ();
- const PHINode *PN = dyn_cast<PHINode> (Inst); ++Inst)
- eliminatePhiAtTraceExit (MF, MBB, PN);
-//===----------------------------------------------------------------------===//
-
// Insert stores from each live-out variable's reg. in the trace
// to its stack slot in the trace function, from which it will be
// reloaded below into a register.
@@ -491,8 +480,24 @@
addLiveOutCopy (MF, MBB, Source, Target, V,
TF->getCorrespondingValue (V, false));
}
+
+ // Find the BasicBlock in MatrixFn that this block's return instr.
+ // would have returned to, by consulting the mapping information
+ // generated by TraceFunctionBuilder.
+ const ReturnInst *RI =
+ cast<ReturnInst> (MBB.getBasicBlock ()->getTerminator ());
+ const BasicBlock *RBB = TF->ReturnBlockForTraceExit[RI];
+ assert (RBB && "Can't find matrix fn BB address to return to from trace");
+ DEBUG (std::cerr << "rewriteEpilog: Return block for trace exit path is:\n"
+ << *RBB << "\n");
+
+ // If there are Phi nodes in the target of the trace-exiting branch, we must
+ // eliminate them by inserting copies now.
+ for (BasicBlock::const_iterator Inst = RBB->begin ();
+ const PHINode *PN = dyn_cast<PHINode> (Inst); ++Inst)
+ eliminatePhiAtTraceExit (MF, MBB, PN);
- // Restore old FP. Warning! After this point, addLiveOutCopy won't work
+ // Restore MatrixFn's FP. Warning! After this point, addLiveOutCopy won't work
// anymore, because it depends on being able to access TraceFn's frame
// pointer in %fp.
mvec.clear ();
@@ -501,6 +506,7 @@
for (std::vector<MachineInstr *>::iterator vi = mvec.begin (),
ve = mvec.end (); vi != ve; ++vi)
MBB.push_back (*vi);
+ fpIsTraceFP = false;
RegsToSave.erase (fp);
// Get the set of registers used in this function which we saved in
@@ -553,6 +559,7 @@
DEBUG(std::cerr << "UnpackTraceFunction: unpacking "
<< MF.getFunction()->getName() << "()\n");
+ fpIsTraceFP = false;
// Initialize RegsToSave with the set of registers we'll need to save in the
// prolog and restore in the epilog.
More information about the llvm-commits
mailing list