[llvm-commits] CVS: reopt/lib/LightWtProfiling/TraceToFunction.cpp
Brian Gaeke
gaeke at cs.uiuc.edu
Sat May 15 19:53:01 PDT 2004
Changes in directory reopt/lib/LightWtProfiling:
TraceToFunction.cpp updated: 1.34 -> 1.35
---
Log message:
Since FLI blocks are only inserted on back-edges, make
isFirstLevelInstrumentationBlock() return the back-edge target.
This should allow us to fold the branch into the block's predecessor.
Make fixupFunctionBodyBB() call it to try to detect FLI blocks.
---
Diffs of the changes: (+17 -11)
Index: reopt/lib/LightWtProfiling/TraceToFunction.cpp
diff -u reopt/lib/LightWtProfiling/TraceToFunction.cpp:1.34 reopt/lib/LightWtProfiling/TraceToFunction.cpp:1.35
--- reopt/lib/LightWtProfiling/TraceToFunction.cpp:1.34 Sat May 15 19:28:41 2004
+++ reopt/lib/LightWtProfiling/TraceToFunction.cpp Sat May 15 19:52:05 2004
@@ -410,22 +410,22 @@
fixupPhisAndCalls (FI, O2CMap);
}
-/// isFirstLevelInstrumentationBlock - returns true 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.
+/// isFirstLevelInstrumentationBlock - 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 bool isFirstLevelInstrumentationBlock (BasicBlock *BB) {
+static BasicBlock *isFirstLevelInstrumentationBlock (BasicBlock *BB) {
BasicBlock::iterator i = BB->begin ();
// starts with llvm_first_trigger call
if (!isFirstTriggerCall (*i))
return false;
- // next thing is an unconditional branch
- ++i;
- if (!(isa<BranchInst> (i) && cast<BranchInst> (i)->isUnconditional ()))
- return false;
- // looks like the real thing to me...
- return true;
+ // 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);
}
/// fixupFunctionBodyBB - Given srcB in T and its clone dstB in F, and
@@ -480,6 +480,12 @@
&& "Trace-exiting branch's clone is null, or not a branch?");
BranchInst *BIinF = cast<BranchInst> (V);
for (unsigned i = 0; i < BI->getNumSuccessors (); ++i) {
+ if (BasicBlock *backEdgeTarget =
+ isFirstLevelInstrumentationBlock (BI->getSuccessor (i))) {
+ std::cerr << "Branch instr " << *BI << " looks like an instrumented "
+ << "backedge from " << srcB->getName() << " to "
+ << backEdgeTarget->getName () << "\n";
+ }
if (!T.contains (BI->getSuccessor (i))) {
// This is a trace-exiting destination of branch BI. Create a new
// basic block FB for its destination in the function.
More information about the llvm-commits
mailing list