[llvm-commits] CVS: reopt/lib/TraceToFunction/TraceToFunction.cpp
Brian Gaeke
gaeke at cs.uiuc.edu
Sat May 22 01:57:14 PDT 2004
Changes in directory reopt/lib/TraceToFunction:
TraceToFunction.cpp updated: 1.56 -> 1.57
---
Log message:
Three important changes regarding trace entry-BB Phi nodes:
1) In DEBUG mode, change their names to reflect their special status, and add
better debug messages.
2) Assert that they are live-in (fixing a longstanding FIXME).
3) Rewrite their off-trace incoming values to be the argument of the TraceFn
which carries their live-in value.
---
Diffs of the changes: (+28 -12)
Index: reopt/lib/TraceToFunction/TraceToFunction.cpp
diff -u reopt/lib/TraceToFunction/TraceToFunction.cpp:1.56 reopt/lib/TraceToFunction/TraceToFunction.cpp:1.57
--- reopt/lib/TraceToFunction/TraceToFunction.cpp:1.56 Fri May 21 15:54:44 2004
+++ reopt/lib/TraceToFunction/TraceToFunction.cpp Sat May 22 01:56:39 2004
@@ -546,26 +546,42 @@
if (srcB == T.getEntryBasicBlock ()) {
BasicBlock *EntryFixup = new BasicBlock ("entryfixup", F, dstB);
EntryFixup->getInstList ().push_back (new BranchInst (dstB));
- // Replace the references to the trace's predecessor with a
- // reference to EntryFixup now. This is kind of a dodge because we
- // don't have a pointer to the trace's predecessor, so we have
- // to guess which one it is. Assume it's any phi value source in
- // the entry BB which is not in the trace.
+ // Rewrite phi nodes in the entry basic block, which carry values
+ // that are live-in to the trace: Off-trace phi sources must be
+ // rewritten to take their value from the entryfixup block, and get
+ // their value from the argument which carries the live-in value.
for (BasicBlock::iterator BI = srcB->begin ();
- PHINode *PN = dyn_cast<PHINode> (BI); ++BI)
- for (unsigned i = 0; i < PN->getNumIncomingValues (); ++i) {
+ PHINode *oldPN = dyn_cast<PHINode> (BI); ++BI) {
+ DEBUG (std::cerr << "fixupFunctionBodyBB: Changing name of trace"
+ << " entry block Phi node:\n" << O2CMap[oldPN] << " to "
+ << O2CMap[oldPN]->getName() << ".phifixup\n";
+ O2CMap[oldPN]->setName (O2CMap[oldPN]->getName () + ".phifixup"));
+ assert (TF->LiveInSet.find (oldPN) != TF->LiveInSet.end ()
+ && "Phi nodes in trace entry BB must be live-in");
+ unsigned argNum = TF->LiveInToParameterMap [oldPN];
+ Argument *phiLiveIn = getFunctionArg (F, argNum);
+ for (unsigned i = 0; i < oldPN->getNumIncomingValues (); ++i) {
// Fold Phi sources which come from FLI blocks
- BasicBlock *phiSource = PN->getIncomingBlock (i);
+ BasicBlock *phiSource = oldPN->getIncomingBlock (i);
if (BasicBlock *realSource = getFLIEdgeSource (phiSource))
phiSource = realSource;
if (!T.contains (phiSource)) {
- // FIXME: Assert that O2CMap[PN]'s value i is live in.
- Value *V = O2CMap[PN];
+ Value *V = O2CMap[oldPN];
assert (V && isa<PHINode> (V)
&& "Clone of PHINode from trace entry BB missing or mangled");
- cast<PHINode> (V)->setIncomingBlock (i, EntryFixup);
+ PHINode *newPN = cast<PHINode> (V);
+ DEBUG (std::cerr << "fixupFunctionBodyBB: Changing incoming block "
+ << i << " of trace entry block Phi node:\n" << *newPN << " from "
+ << newPN->getIncomingBlock (i)->getName () << " to entry-fixup "
+ << "block, and incoming value to argument " << argNum << " (";
+ WriteAsOperand (std::cerr, phiLiveIn, true, true,
+ TF->TraceFn->getParent ());
+ std::cerr << ")\n");
+ newPN->setIncomingBlock (i, EntryFixup);
+ newPN->setIncomingValue (i, phiLiveIn);
}
- }
+ }
+ }
}
// If srcB contains a trace-exiting branch B, fix up B's clone in
More information about the llvm-commits
mailing list