[llvm-commits] CVS: reopt/lib/TraceToFunction/TraceToFunction.cpp
Brian Gaeke
gaeke at cs.uiuc.edu
Fri May 21 05:06:01 PDT 2004
Changes in directory reopt/lib/TraceToFunction:
TraceToFunction.cpp updated: 1.53 -> 1.54
---
Log message:
Give fixupFunctionBodyBB much better debugging printouts (and make them
less incredibly verbose). Untabify.
---
Diffs of the changes: (+59 -50)
Index: reopt/lib/TraceToFunction/TraceToFunction.cpp
diff -u reopt/lib/TraceToFunction/TraceToFunction.cpp:1.53 reopt/lib/TraceToFunction/TraceToFunction.cpp:1.54
--- reopt/lib/TraceToFunction/TraceToFunction.cpp:1.53 Fri May 21 02:45:05 2004
+++ reopt/lib/TraceToFunction/TraceToFunction.cpp Fri May 21 05:05:48 2004
@@ -455,8 +455,7 @@
DEBUG (std::cerr << "threadFLIEdges: threading incoming block " << i
<< " (FLI block " << It->first->getName () << " --> <["
<< It->second.first->getName () << "], "
- << It->second.second->getName () << ">) of PHI node: "
- << *PN << "\n");
+ << It->second.second->getName () << ">) of PHI node:\n" << *PN);
PN->setIncomingBlock (i, It->second.first);
}
}
@@ -475,8 +474,7 @@
DEBUG (std::cerr << "threadFLIEdges: threading successor " << i
<< " (FLI block " << It->first->getName () << " --> <"
<< It->second.first->getName () << ", ["
- << It->second.second->getName () << "]>) of branch: "
- << *BI << "\n");
+ << It->second.second->getName () << "]>) of branch:\n" << *BI);
BI->setSuccessor (i, It->second.second);
}
}
@@ -572,61 +570,67 @@
// Fix up this exit branch.
Value *V = O2CMap[BI];
assert(V && isa<BranchInst> (V)
- && "Trace-exiting branch's clone is null, or not a branch?");
+ && "Trace-exiting branch's clone is null, or not a branch?");
BranchInst *BIinF = cast<BranchInst> (V);
for (unsigned i = 0; i < BI->getNumSuccessors (); ++i) {
BasicBlock *successor = BI->getSuccessor (i);
+ BasicBlock *newSuccessor = 0;
// Fold branches which go to FLI blocks
if (BasicBlock *backEdgeTarget =
getFLIEdgeTarget (successor)) {
- DEBUG (std::cerr << "Branch instr " << *BI << " looks like an"
- << " instrumented back-edge from " << srcB->getName()
+ DEBUG (std::cerr << "fixupFunctionBodyBB: Branch instruction:\n" << *BI
+ << " looks like an instrumented back-edge from " << srcB->getName()
<< " to " << backEdgeTarget->getName () << "\n");
successor = backEdgeTarget;
}
if (!T.contains (successor)) {
- // This is a trace-exiting destination of branch BI. Create a new
- // basic block FB for its destination in the function.
- std::string name ("exitfixup" + utostr (BranchNumber[BI]) + "_"
- + utostr (i));
- BasicBlock *FB = new BasicBlock (name, F);
- // Change BI's clone's destination to FB.
- BIinF->setSuccessor (i, FB);
- // Remember that FB's "return" instruction would involve a
- // return to the off-trace successor we just found.
- TF->ReturnBlockForTraceExit[FB] = successor;
- // Add the getelementptr/store instruction pairs here that
- // correspond to each live-out variable.
- unsigned Slot = 0;
- for (LiveVariableSet::iterator SI = So.begin (), SE = So.end ();
- SI != SE; ++SI) {
- if (dominates (T, cast<Instruction> ((*SI))->getParent (),
- BI->getParent ())) {
- std::vector<Value *> Index;
- Index.push_back (Constant::getNullValue (Type::LongTy)); //long 0
- Index.push_back (ConstantUInt::get (Type::UIntTy, Slot));//uint Slot
- GetElementPtrInst *GEP =
- new GetElementPtrInst (getFunctionArg (F, 0), Index,
- "liveOutP" + utostr (BranchNumber[BI])
- + "_" + utostr (i) + "_" + utostr (Slot));
- FB->getInstList ().push_back (GEP);
- FB->getInstList ().push_back (new StoreInst (O2CMap[*SI], GEP));
- }
- ++Slot;
- }
- // Make FB contain a return instruction that returns the
- // number of the taken exit-branch. Add it to the end of FB:
- FB->getInstList ().push_back
- (new ReturnInst (ConstantUInt::get (Type::UIntTy,
- BranchNumber[BI])));
+ // This is a trace-exiting destination of branch BI. Create a new
+ // basic block FB for its destination in the function.
+ std::string name ("exitfixup" + utostr (BranchNumber[BI]) + "_"
+ + utostr (i));
+ BasicBlock *FB = new BasicBlock (name, F);
+ // Remember to change BI's clone's destination to FB.
+ newSuccessor = FB;
+ // Remember that FB's "return" instruction would involve a
+ // return to the off-trace successor we just found.
+ TF->ReturnBlockForTraceExit[FB] = successor;
+ // Add the getelementptr/store instruction pairs here that
+ // correspond to each live-out variable.
+ unsigned Slot = 0;
+ for (LiveVariableSet::iterator SI = So.begin (), SE = So.end ();
+ SI != SE; ++SI) {
+ if (dominates (T, cast<Instruction> ((*SI))->getParent (),
+ BI->getParent ())) {
+ std::vector<Value *> Index;
+ Index.push_back (Constant::getNullValue (Type::LongTy)); //long 0
+ Index.push_back (ConstantUInt::get (Type::UIntTy, Slot));//uint Slot
+ GetElementPtrInst *GEP =
+ new GetElementPtrInst (getFunctionArg (F, 0), Index,
+ "liveOutP" + utostr (BranchNumber[BI])
+ + "_" + utostr (i) + "_" + utostr (Slot));
+ FB->getInstList ().push_back (GEP);
+ FB->getInstList ().push_back (new StoreInst (O2CMap[*SI], GEP));
+ }
+ ++Slot;
+ }
+ // Make FB contain a return instruction that returns the
+ // number of the taken exit-branch. Add it to the end of FB:
+ FB->getInstList ().push_back
+ (new ReturnInst (ConstantUInt::get (Type::UIntTy,
+ BranchNumber[BI])));
} else {
- // This is a non-trace-exiting destination of branch BI. Fix up
- // its clone's destination to point to its successor's clone.
- Value *V2 = O2CMap[successor];
- assert(V2 && isa<BasicBlock> (V2)
- && "Clone of basic block on trace not found, or not a basic block");
- BIinF->setSuccessor (i, cast<BasicBlock> (V2));
- }
+ // This is a non-trace-exiting destination of branch BI. Fix up
+ // its clone's destination to point to its successor's clone.
+ Value *V2 = O2CMap[successor];
+ assert(V2 && isa<BasicBlock> (V2)
+ && "Clone of BasicBlock on trace missing, or not a BasicBlock");
+ newSuccessor = cast<BasicBlock> (V2);
+ }
+ DEBUG(std::cerr << "fixupFunctionBodyBB: Changing successor " << i
+ << " of trace-exiting branch instruction:\n" << *BIinF << " from "
+ << BIinF->getSuccessor(i)->getName () << " to "
+ << newSuccessor->getName () << "\n");
+ BIinF->setSuccessor (i, newSuccessor);
}
}
@@ -642,8 +646,13 @@
// outside the function. Replace any reference to an operand
// which has had a clone made with a reference to its clone.
if (O2CMap.find (V) != O2CMap.end () && O2CMap[V] && !isa<Constant> (V)) {
- DEBUG(std::cerr << *V << " in instruction " << I
- << " is value " << O2CMap[V] << " in new function\n");
+ DEBUG(std::cerr << "fixupFunctionBodyBB: Replacing ";
+ WriteAsOperand (std::cerr, V, true, true,
+ TF->TraceFn->getParent ());
+ std::cerr << " in instruction:\n" << I << " with value ";
+ WriteAsOperand (std::cerr, O2CMap[V], true, true,
+ TF->TraceFn->getParent ());
+ std::cerr << "\n");
assert (V->getType () == O2CMap[V]->getType ()
&& "Value's type doesn't match clone's type");
I.setOperand(i, O2CMap[V]);
More information about the llvm-commits
mailing list