[llvm-commits] CVS: reopt/lib/TraceToFunction/TraceToFunction.cpp
Brian Gaeke
gaeke at cs.uiuc.edu
Mon May 17 16:32:02 PDT 2004
Changes in directory reopt/lib/TraceToFunction:
TraceToFunction.cpp updated: 1.36 -> 1.37
---
Log message:
Rename isFirstLevelInstrumentationBlock to getFLIEdgeTarget.
Add corresponding getFLIEdgeSource method.
Wrap long comment lines.
Only get branch successor node once, and store it in a value, in
fixupFunctionBodyBB().
---
Diffs of the changes: (+34 -10)
Index: reopt/lib/TraceToFunction/TraceToFunction.cpp
diff -u reopt/lib/TraceToFunction/TraceToFunction.cpp:1.36 reopt/lib/TraceToFunction/TraceToFunction.cpp:1.37
--- reopt/lib/TraceToFunction/TraceToFunction.cpp:1.36 Mon May 17 16:00:47 2004
+++ reopt/lib/TraceToFunction/TraceToFunction.cpp Mon May 17 16:30:55 2004
@@ -410,24 +410,47 @@
fixupPhisAndCalls (FI, O2CMap);
}
-/// isFirstLevelInstrumentationBlock - returns a nonzero value iff BB is a
+/// getFLIEdgeTarget - returns a nonzero value iff BB is a
/// basic block containing only a call to the first-level instrumentation
/// function. Basic blocks of this form are inserted by the -instloops pass on
/// loop back-edges. The return value is the target of the back-edge.
///
-static BasicBlock *isFirstLevelInstrumentationBlock (BasicBlock *BB) {
+static BasicBlock *getFLIEdgeTarget (BasicBlock *BB) {
BasicBlock::iterator i = BB->begin ();
// starts with llvm_first_trigger call
if (!isFirstTriggerCall (*i))
- return false;
- // Next instr. should be an unconditional branch - return its target, or NULL if
- // there is a mismatch.
+ return 0;
+ // Next instr. should be an unconditional branch - return its target,
+ // or NULL if there is a mismatch.
BranchInst *BI = dyn_cast<BranchInst> (++i);
if (!(BI && BI->isUnconditional()))
return 0;
return BI->getSuccessor (0);
}
+/// getFLIEdgeSource - returns a nonzero value iff BB is a
+/// basic block containing only a call to the first-level instrumentation
+/// function. Basic blocks of this form are inserted by the -instloops pass on
+/// loop back-edges. The return value is the source of the back-edge.
+///
+static BasicBlock *getFLIEdgeSource (BasicBlock *BB) {
+ BasicBlock::iterator i = BB->begin ();
+ // starts with llvm_first_trigger call
+ if (!isFirstTriggerCall (*i))
+ return 0;
+ // Next instr. should be an unconditional branch. Return NULL if
+ // there is a mismatch.
+ BranchInst *BI = dyn_cast<BranchInst> (++i);
+ if (!(BI && BI->isUnconditional()))
+ return 0;
+ // Use CFG predecessor iterator to get the predecessor of the FLI block
+ pred_iterator PI = pred_begin (BB);
+ DEBUG(pred_iterator NextPI = PI; ++NextPI;
+ assert (NextPI == pred_end (BB) &&
+ "FLI block must have only one predecessor"));
+ return *PI;
+}
+
/// fixupFunctionBodyBB - Given srcB in T and its clone dstB in F, and
/// the map O2CMap detailing the correspondences between values in T
/// and values in F, fix up dstB so that its contents are internally
@@ -480,13 +503,14 @@
&& "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);
if (BasicBlock *backEdgeTarget =
- isFirstLevelInstrumentationBlock (BI->getSuccessor (i))) {
+ getFLIEdgeTarget (successor)) {
std::cerr << "Branch instr " << *BI << " looks like an instrumented "
<< "backedge from " << srcB->getName() << " to "
<< backEdgeTarget->getName () << "\n";
}
- if (!T.contains (BI->getSuccessor (i))) {
+ 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]) + "_"
@@ -496,7 +520,7 @@
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] = BI->getSuccessor (i);
+ TF->ReturnBlockForTraceExit[FB] = successor;
// Add the getelementptr/store instruction pairs here that
// correspond to each live-out variable.
unsigned Slot = 0;
@@ -524,13 +548,13 @@
} 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[BI->getSuccessor (i)];
+ Value *V2 = O2CMap[successor];
DEBUG(if (!V2) {
std::cerr
<< "I'm confused: saw non-trace-exiting dest. of branch "
<< *BI << " whose clone is " << *BIinF
<< " successor number is " << i << " and successor is "
- << *BI->getSuccessor (i) << ", but where's its clone?\n";
+ << *successor << ", but where's its clone?\n";
assert(V2 && "Clone of basic block on trace is null?");
});
assert(isa<BasicBlock> (V2)
More information about the llvm-commits
mailing list