[llvm-commits] CVS: reopt/lib/TraceToFunction/TraceToFunction.cpp
Brian Gaeke
gaeke at cs.uiuc.edu
Fri Jun 4 12:59:14 PDT 2004
Changes in directory reopt/lib/TraceToFunction:
TraceToFunction.cpp updated: 1.59 -> 1.60
---
Log message:
Add better debug printouts of live-out and live-in sets.
When we do replaceAllUses on a phi node, we may need to fix up whatever it
corresponded to in the O2CMap. The code for this is not right yet, so add
an assert.
---
Diffs of the changes: (+18 -15)
Index: reopt/lib/TraceToFunction/TraceToFunction.cpp
diff -u reopt/lib/TraceToFunction/TraceToFunction.cpp:1.59 reopt/lib/TraceToFunction/TraceToFunction.cpp:1.60
--- reopt/lib/TraceToFunction/TraceToFunction.cpp:1.59 Mon May 31 00:51:45 2004
+++ reopt/lib/TraceToFunction/TraceToFunction.cpp Fri Jun 4 12:58:25 2004
@@ -217,9 +217,15 @@
///
static PointerType *createLiveOutType (LiveVariableSet S) {
TypeVector T;
+ unsigned Counter = 0;
// For each variable in S, make a new entry in T having its type.
- for (LiveVariableSet::iterator I = S.begin (), E = S.end (); I != E; ++I)
+ DEBUG (std::cerr << "Live-out values:\n");
+ for (LiveVariableSet::iterator I = S.begin (), E = S.end (); I != E; ++I) {
+ DEBUG (WriteAsOperand (std::cerr, *I, true, true,
+ cast<Instruction>(*I)->getParent ()->getParent ()->getParent ());
+ std::cerr << " is at position " << Counter++ << "\n");
T.push_back ((*I)->getType ());
+ }
return PointerType::get (StructType::get (T));
}
@@ -241,8 +247,9 @@
P.push_back (V->getType ());
TF->LiveInToParameterMap[V] = P.size () - 1;
}
- // Print out mapping of instructions to arg numbers.
- DEBUG(for (ValueToIntMap::iterator I = TF->LiveInToParameterMap.begin (),
+ // Print out mapping of instructions producing live-ins to arg numbers.
+ DEBUG(std::cerr << "\nLive-in values:\n";
+ for (ValueToIntMap::iterator I = TF->LiveInToParameterMap.begin (),
E = TF->LiveInToParameterMap.end (); I != E; ++I) {
WriteAsOperand (std::cerr, I->first, true, true,
TF->MatrixFn->getParent ());
@@ -323,7 +330,7 @@
}
static void fixupPhis (BasicBlock *dstB, ValueMap &O2CMap) {
- std::vector<Instruction *> goners;
+ std::map<Instruction *, Value *> replaced;
Function *F = dstB->getParent ();
// Fix up Phi nodes:
for (BasicBlock::iterator Inst = dstB->begin ();
@@ -348,7 +355,8 @@
DEBUG(std::cerr << "Replacing Phi node" << *PN << " with its lone"
<< " on-trace input " << *PN->getIncomingValue (lastSrcFound) << "\n");
PN->replaceAllUsesWith (PN->getIncomingValue (lastSrcFound));
- goners.push_back (PN); // Delete non-used phi node later.
+ replaced[PN] = PN->getIncomingValue (lastSrcFound);
+ // Non-used phi node will be deleted later.
} else {
// Case N. If the phi node has >1 source on the trace, just
// delete sources from the Phi node that are not on the trace.
@@ -375,17 +383,12 @@
"Sorry, fixupPhis mishandled a Phi node"));
}
- while (!goners.empty ()) {
- assert (goners.back ()->use_size () == 0
+ for (std::map<Instruction *, Value *>::iterator i = replaced.begin(),
+ e = replaced.end(); i != e; ++i) {
+ assert (i->first->use_size () == 0
&& "Whoops, I was going to delete something which still has uses");
- dstB->getInstList ().erase (goners.back ());
- for (ValueMap::iterator i = O2CMap.begin(), e = O2CMap.end(); i != e; ++i) {
- if (i->second == goners.back ()) {
- O2CMap.erase (i);
- break;
- }
- }
- goners.pop_back ();
+ dstB->getInstList ().erase (i->first);
+ if (0) { O2CMap[i->first] = i->second; } else { assert (0 && "I don't think this is right - i->first is the real clone"); }
}
}
More information about the llvm-commits
mailing list