[llvm-commits] CVS: reopt/lib/TraceToFunction/TraceToFunction.cpp
Brian Gaeke
gaeke at cs.uiuc.edu
Tue Jul 20 15:52:09 PDT 2004
Changes in directory reopt/lib/TraceToFunction:
TraceToFunction.cpp updated: 1.77 -> 1.78
---
Log message:
Fix bugs in hasUseDominatedByEdge having to do with the dominance properties
of Phi nodes.
---
Diffs of the changes: (+28 -3)
Index: reopt/lib/TraceToFunction/TraceToFunction.cpp
diff -u reopt/lib/TraceToFunction/TraceToFunction.cpp:1.77 reopt/lib/TraceToFunction/TraceToFunction.cpp:1.78
--- reopt/lib/TraceToFunction/TraceToFunction.cpp:1.77 Thu Jul 15 17:05:15 2004
+++ reopt/lib/TraceToFunction/TraceToFunction.cpp Tue Jul 20 17:51:59 2004
@@ -658,17 +658,42 @@
BasicBlock *target) {
for (Value::use_iterator UI = defInst->use_begin (), UE =
defInst->use_end (); UI != UE; ++UI) {
+ DEBUG (std::cerr << "hasUseDominatedByEdge: considering whether the "
+ << "edge from %" << source->getName () << " to %"
+ << target->getName () << " dominates user:\n" << **UI);
if (Instruction *useInst = dyn_cast<Instruction> (*UI)) {
- if (DS->dominates (&target->front(), useInst))
+ DEBUG (std::cerr << "hasUseDominatedByEdge: user is in BB %"
+ << useInst->getParent()->getName () << "\n");
+ bool dom;
+ if (PHINode *PN = dyn_cast<PHINode>(useInst)) {
+ BasicBlock *predBlock = 0;
+ for (unsigned i = 0; i < PN->getNumIncomingValues (); ++i)
+ if (PN->getIncomingValue (i) == defInst) {
+ predBlock = PN->getIncomingBlock (i);
+ break;
+ }
+ assert (predBlock
+ && "Couldn't find phi node pred block given incoming value");
+ DEBUG (std::cerr << "hasUseDominatedByEdge: it's a phi node; pred. block is %"
+ << predBlock->getName () << "\n");
+ dom = DS->dominates (&target->front(), predBlock->getTerminator());
+ } else {
+ dom = DS->dominates (&target->front(), useInst);
+ }
+ if (dom) {
+ DEBUG (std::cerr << "hasUseDominatedByEdge: DOMINATED\n");
return true;
+ } else {
+ DEBUG (std::cerr << "hasUseDominatedByEdge: NOT DOMINATED\n");
+ }
} else {
// Gack, it's not an Instruction.
assert (0 && "Found non-Instruction User, don't know dominator info");
}
}
DEBUG (std::cerr << "hasUseDominatedByEdge: found no dominated use"
- << " starting from " << target->getName () << " for:\n"
- << *defInst);
+ << " starting from " << target->getName () << " for:\n"
+ << *defInst);
return false;
}
More information about the llvm-commits
mailing list