//
// The LLVM Compiler Infrastructure
//
-// This file was developed by Owen Anderson and is distributed under the
-// University of Illinois Open Source License. See LICENSE.TXT for details.
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
virtual bool runOnLoop(Loop *L, LPPassManager &LPM);
void ProcessInstruction(Instruction* Instr,
- const std::vector<BasicBlock*>& exitBlocks);
+ const SmallVector<BasicBlock*, 8>& exitBlocks);
/// This transformation requires natural loop information & requires that
/// loop preheaders be inserted into the CFG. It maintains both of these,
std::map<DomTreeNode*, Value*> &Phis);
/// inLoop - returns true if the given block is within the current loop
- const bool inLoop(BasicBlock* B) {
+ bool inLoop(BasicBlock* B) {
return std::binary_search(LoopBlocks.begin(), LoopBlocks.end(), B);
}
};
LI = &LPM.getAnalysis<LoopInfo>();
DT = &getAnalysis<DominatorTree>();
- DominanceFrontier *DF = getAnalysisToUpdate<DominanceFrontier>();
// Speed up queries by creating a sorted list of blocks
LoopBlocks.clear();
if (AffectedValues.empty())
return false;
- std::vector<BasicBlock*> exitBlocks;
- L->getExitBlocks(exitBlocks);
-
+ SmallVector<BasicBlock*, 8> exitBlocks;
+ L->getExitBlocks(exitBlocks);
// Iterate over all affected values for this loop and insert Phi nodes
// for them in the appropriate exit blocks
/// processInstruction - Given a live-out instruction, insert LCSSA Phi nodes,
/// eliminate all out-of-loop uses.
void LCSSA::ProcessInstruction(Instruction *Instr,
- const std::vector<BasicBlock*>& exitBlocks) {
+ const SmallVector<BasicBlock*, 8>& exitBlocks) {
++NumLCSSA; // We are applying the transformation
// Keep track of the blocks that have the value available already.
// 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(),
+ for (SmallVector<BasicBlock*, 8>::const_iterator BBI = exitBlocks.begin(),
BBE = exitBlocks.end(); BBI != BBE; ++BBI) {
BasicBlock *BB = *BBI;
DomTreeNode *ExitBBNode = DT->getNode(BB);
Value *&Phi = Phis[ExitBBNode];
if (!Phi && DT->dominates(InstrNode, ExitBBNode)) {
- PHINode *PN = new PHINode(Instr->getType(), Instr->getName()+".lcssa",
- BB->begin());
+ PHINode *PN = PHINode::Create(Instr->getType(), Instr->getName()+".lcssa",
+ BB->begin());
PN->reserveOperandSpace(std::distance(pred_begin(BB), pred_end(BB)));
// Remember that this phi makes the value alive in this block.
// 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",
- BBN->begin());
+ PHINode *PN = PHINode::Create(OrigInst->getType(), OrigInst->getName()+".lcssa",
+ BBN->begin());
PN->reserveOperandSpace(std::distance(pred_begin(BBN), pred_end(BBN)));
V = PN;