[llvm-commits] CVS: llvm/lib/Transforms/Utils/LCSSA.cpp
Evan Cheng
evan.cheng at apple.com
Wed Apr 18 15:39:30 PDT 2007
Changes in directory llvm/lib/Transforms/Utils:
LCSSA.cpp updated: 1.37 -> 1.38
---
Log message:
Revert Owen's last check-in. This is breaking Mac OS X / PPC llvm-gcc bootstrap.
---
Diffs of the changes: (+21 -18)
LCSSA.cpp | 39 +++++++++++++++++++++------------------
1 files changed, 21 insertions(+), 18 deletions(-)
Index: llvm/lib/Transforms/Utils/LCSSA.cpp
diff -u llvm/lib/Transforms/Utils/LCSSA.cpp:1.37 llvm/lib/Transforms/Utils/LCSSA.cpp:1.38
--- llvm/lib/Transforms/Utils/LCSSA.cpp:1.37 Tue Apr 17 23:39:32 2007
+++ llvm/lib/Transforms/Utils/LCSSA.cpp Wed Apr 18 17:39:00 2007
@@ -49,7 +49,7 @@
struct VISIBILITY_HIDDEN LCSSA : public FunctionPass {
// Cached analysis information for the current function.
LoopInfo *LI;
- ETForest *ET;
+ DominatorTree *DT;
std::vector<BasicBlock*> LoopBlocks;
virtual bool runOnFunction(Function &F);
@@ -66,14 +66,14 @@
AU.addRequiredID(LoopSimplifyID);
AU.addPreservedID(LoopSimplifyID);
AU.addRequired<LoopInfo>();
- AU.addRequired<ETForest>();
+ AU.addRequired<DominatorTree>();
}
private:
void getLoopValuesUsedOutsideLoop(Loop *L,
SetVector<Instruction*> &AffectedValues);
- Value *GetValueForBlock(BasicBlock *BB, Instruction *OrigInst,
- std::map<BasicBlock*, Value*> &Phis);
+ Value *GetValueForBlock(DominatorTree::Node *BB, Instruction *OrigInst,
+ std::map<DominatorTree::Node*, Value*> &Phis);
/// inLoop - returns true if the given block is within the current loop
const bool inLoop(BasicBlock* B) {
@@ -92,7 +92,7 @@
bool changed = false;
LI = &getAnalysis<LoopInfo>();
- ET = &getAnalysis<ETForest>();
+ DT = &getAnalysis<DominatorTree>();
for (LoopInfo::iterator I = LI->begin(), E = LI->end(); I != E; ++I)
changed |= visitSubloop(*I);
@@ -142,17 +142,18 @@
++NumLCSSA; // We are applying the transformation
// Keep track of the blocks that have the value available already.
- std::map<BasicBlock*, Value*> Phis;
+ std::map<DominatorTree::Node*, Value*> Phis;
- //ETNode *InstrNode = ET->getNodeForBlock(Instr->getParent());
+ DominatorTree::Node *InstrNode = DT->getNode(Instr->getParent());
// Insert the LCSSA phi's into the exit blocks (dominated by the value), and
// add them to the Phi's map.
for (std::vector<BasicBlock*>::const_iterator BBI = exitBlocks.begin(),
BBE = exitBlocks.end(); BBI != BBE; ++BBI) {
BasicBlock *BB = *BBI;
- Value *&Phi = Phis[BB];
- if (!Phi && ET->dominates(Instr->getParent(), BB)) {
+ DominatorTree::Node *ExitBBNode = DT->getNode(BB);
+ Value *&Phi = Phis[ExitBBNode];
+ if (!Phi && InstrNode->dominates(ExitBBNode)) {
PHINode *PN = new PHINode(Instr->getType(), Instr->getName()+".lcssa",
BB->begin());
PN->reserveOperandSpace(std::distance(pred_begin(BB), pred_end(BB)));
@@ -185,7 +186,7 @@
// Otherwise, patch up uses of the value with the appropriate LCSSA Phi,
// inserting PHI nodes into join points where needed.
- Value *Val = GetValueForBlock(UserBB, Instr, Phis);
+ Value *Val = GetValueForBlock(DT->getNode(UserBB), Instr, Phis);
// Preincrement the iterator to avoid invalidating it when we change the
// value.
@@ -224,8 +225,8 @@
/// GetValueForBlock - Get the value to use within the specified basic block.
/// available values are in Phis.
-Value *LCSSA::GetValueForBlock(BasicBlock *BB, Instruction *OrigInst,
- std::map<BasicBlock*, Value*> &Phis) {
+Value *LCSSA::GetValueForBlock(DominatorTree::Node *BB, Instruction *OrigInst,
+ std::map<DominatorTree::Node*, Value*> &Phis) {
// If there is no dominator info for this BB, it is unreachable.
if (BB == 0)
return UndefValue::get(OrigInst->getType());
@@ -234,7 +235,7 @@
Value *&V = Phis[BB];
if (V) return V;
- BasicBlock* IDom = ET->getIDom(BB);
+ DominatorTree::Node *IDom = BB->getIDom();
// Otherwise, there are two cases: we either have to insert a PHI node or we
// don't. We need to insert a PHI node if this block is not dominated by one
@@ -247,22 +248,24 @@
// dominate this block. Note that we *know* that the block defining the
// original instruction is in the idom chain, because if it weren't, then the
// original value didn't dominate this use.
- if (!inLoop(IDom)) {
+ if (!inLoop(IDom->getBlock())) {
// Idom is not in the loop, we must still be "below" the exit block and must
// be fully dominated by the value live in the idom.
return V = GetValueForBlock(IDom, OrigInst, Phis);
}
+ BasicBlock *BBN = BB->getBlock();
+
// Otherwise, the idom is the loop, so we need to insert a PHI node. Do so
// now, then get values to fill in the incoming values for the PHI.
PHINode *PN = new PHINode(OrigInst->getType(), OrigInst->getName()+".lcssa",
- BB->begin());
- PN->reserveOperandSpace(std::distance(pred_begin(BB), pred_end(BB)));
+ BBN->begin());
+ PN->reserveOperandSpace(std::distance(pred_begin(BBN), pred_end(BBN)));
V = PN;
// Fill in the incoming values for the block.
- for (pred_iterator PI = pred_begin(BB), E = pred_end(BB); PI != E; ++PI)
- PN->addIncoming(GetValueForBlock(*PI, OrigInst, Phis), *PI);
+ for (pred_iterator PI = pred_begin(BBN), E = pred_end(BBN); PI != E; ++PI)
+ PN->addIncoming(GetValueForBlock(DT->getNode(*PI), OrigInst, Phis), *PI);
return PN;
}
More information about the llvm-commits
mailing list