[llvm-commits] CVS: reopt/lib/TraceToFunction/TraceToFunction.cpp
Brian Gaeke
gaeke at cs.uiuc.edu
Fri May 21 05:29:02 PDT 2004
Changes in directory reopt/lib/TraceToFunction:
TraceToFunction.cpp updated: 1.54 -> 1.55
---
Log message:
Minor cleanups in fillInFunctionBody(): Make 'function before fixups'
debug message stand out more. Eliminate a dyn_cast.
In fixupFunctionBodyBB(), reduce the number of times we look each
operand up in O2CMap from 5 to 1, and don't look constants or global
values up at all.
---
Diffs of the changes: (+12 -10)
Index: reopt/lib/TraceToFunction/TraceToFunction.cpp
diff -u reopt/lib/TraceToFunction/TraceToFunction.cpp:1.54 reopt/lib/TraceToFunction/TraceToFunction.cpp:1.55
--- reopt/lib/TraceToFunction/TraceToFunction.cpp:1.54 Fri May 21 05:05:48 2004
+++ reopt/lib/TraceToFunction/TraceToFunction.cpp Fri May 21 05:28:42 2004
@@ -388,8 +388,6 @@
///
void TraceFunctionBuilder::fillInFunctionBody (Trace &T, Function *F,
LiveVariableSet &So) {
- ValueMap &O2CMap = TF->O2CMap;
-
buildFLIMap (T, FLIMap);
// First copy the basic blocks from the trace.
@@ -399,15 +397,16 @@
numberExitBranchesInTrace (T, BranchNumber);
- DEBUG (std::cerr << "\n FUNCTION BEFORE FIXUPS: \n" << *F << "\n\n");
+ DEBUG (std::cerr << "\n ---- FUNCTION BEFORE FIXUPS: --- \n" << *F << "\n\n");
// Fix up the cloned basic blocks of the function so that they are
// internally consistent.
+ ValueMap &O2CMap = TF->O2CMap;
for (Trace::iterator TI = T.begin (), TE = T.end (); TI != TE; ++TI) {
BasicBlock *srcB = *TI;
- assert (O2CMap[srcB] && "Can't find clone of basic block I just cloned");
- BasicBlock *dstB = dyn_cast<BasicBlock> (O2CMap[srcB]);
- assert (dstB && "Clone of basic block I just cloned is not a basic block");
+ assert (O2CMap[srcB] && isa<BasicBlock> (O2CMap[srcB])
+ && "Clone of trace BasicBlock is missing or not a BasicBlock");
+ BasicBlock *dstB = cast<BasicBlock> (O2CMap[srcB]);
fixupFunctionBodyBB (T, F, srcB, dstB, O2CMap, So);
}
for (Function::iterator FI = F->begin (), FE = F->end (); FI != FE; ++FI)
@@ -645,17 +644,20 @@
// function, and I will still reference the version from
// 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)) {
+ if (isa<Constant> (V) || isa<GlobalValue> (V)) continue;
+ ValueMap::iterator It = O2CMap.find (V);
+ if (It != O2CMap.end ()) {
+ Value *newV = It->second;
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,
+ WriteAsOperand (std::cerr, newV, true, true,
TF->TraceFn->getParent ());
std::cerr << "\n");
- assert (V->getType () == O2CMap[V]->getType ()
+ assert (V->getType () == newV->getType ()
&& "Value's type doesn't match clone's type");
- I.setOperand(i, O2CMap[V]);
+ I.setOperand(i, newV);
}
}
More information about the llvm-commits
mailing list