diff options
author | Reid Spencer <rspencer@reidspencer.com> | 2004-09-15 17:06:42 +0000 |
---|---|---|
committer | Reid Spencer <rspencer@reidspencer.com> | 2004-09-15 17:06:42 +0000 |
commit | 2da5c3dda6f5b9c4ec6d55008d33327764364bd4 (patch) | |
tree | ed7e2551f4d2fd2c276d842f289b4471b9d47843 /lib/Transforms | |
parent | 7e0e9c635f5439426252bd1ccbfa90b878ba0ca6 (diff) | |
download | llvm-2da5c3dda6f5b9c4ec6d55008d33327764364bd4.tar.gz llvm-2da5c3dda6f5b9c4ec6d55008d33327764364bd4.tar.bz2 llvm-2da5c3dda6f5b9c4ec6d55008d33327764364bd4.tar.xz |
Convert code to compile with vc7.1.
Patch contributed by Paolo Invernizzi. Thanks Paolo!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16368 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r-- | lib/Transforms/Scalar/ADCE.cpp | 4 | ||||
-rw-r--r-- | lib/Transforms/Scalar/CorrelatedExprs.cpp | 4 | ||||
-rw-r--r-- | lib/Transforms/Scalar/IndVarSimplify.cpp | 10 | ||||
-rw-r--r-- | lib/Transforms/Scalar/LoopUnroll.cpp | 4 | ||||
-rw-r--r-- | lib/Transforms/Scalar/SCCP.cpp | 5 | ||||
-rw-r--r-- | lib/Transforms/Scalar/TailDuplication.cpp | 4 | ||||
-rw-r--r-- | lib/Transforms/Utils/BreakCriticalEdges.cpp | 4 | ||||
-rw-r--r-- | lib/Transforms/Utils/CloneTrace.cpp | 21 | ||||
-rw-r--r-- | lib/Transforms/Utils/CodeExtractor.cpp | 15 | ||||
-rw-r--r-- | lib/Transforms/Utils/InlineFunction.cpp | 13 | ||||
-rw-r--r-- | lib/Transforms/Utils/LowerSwitch.cpp | 8 | ||||
-rw-r--r-- | lib/Transforms/Utils/SimplifyCFG.cpp | 19 |
12 files changed, 63 insertions, 48 deletions
diff --git a/lib/Transforms/Scalar/ADCE.cpp b/lib/Transforms/Scalar/ADCE.cpp index 5770bb692c..4bd24972d5 100644 --- a/lib/Transforms/Scalar/ADCE.cpp +++ b/lib/Transforms/Scalar/ADCE.cpp @@ -428,7 +428,8 @@ bool ADCE::doADCE() { // should be identical to the incoming values for LastDead. // for (BasicBlock::iterator II = NextAlive->begin(); - PHINode *PN = dyn_cast<PHINode>(II); ++II) + isa<PHINode>(II); ++II) { + PHINode *PN = cast<PHINode>(II); if (LiveSet.count(PN)) { // Only modify live phi nodes // Get the incoming value for LastDead... int OldIdx = PN->getBasicBlockIndex(LastDead); @@ -438,6 +439,7 @@ bool ADCE::doADCE() { // Add an incoming value for BB now... PN->addIncoming(InVal, BB); } + } } } diff --git a/lib/Transforms/Scalar/CorrelatedExprs.cpp b/lib/Transforms/Scalar/CorrelatedExprs.cpp index 53c56d2631..c365622cb4 100644 --- a/lib/Transforms/Scalar/CorrelatedExprs.cpp +++ b/lib/Transforms/Scalar/CorrelatedExprs.cpp @@ -572,8 +572,8 @@ void CEE::ForwardSuccessorTo(TerminatorInst *TI, unsigned SuccNo, // edge from the PHI node, and we need to replace any references to the PHI // node with a new value. // - for (BasicBlock::iterator I = OldSucc->begin(); - PHINode *PN = dyn_cast<PHINode>(I); ) { + for (BasicBlock::iterator I = OldSucc->begin(); isa<PHINode>(I); ) { + PHINode *PN = cast<PHINode>(I); // Get the value flowing across the old edge and remove the PHI node entry // for this edge: we are about to remove the edge! Don't remove the PHI diff --git a/lib/Transforms/Scalar/IndVarSimplify.cpp b/lib/Transforms/Scalar/IndVarSimplify.cpp index a269353487..3e6e960ec0 100644 --- a/lib/Transforms/Scalar/IndVarSimplify.cpp +++ b/lib/Transforms/Scalar/IndVarSimplify.cpp @@ -570,10 +570,11 @@ void IndVarSimplify::runOnLoop(Loop *L) { BasicBlock *Preheader = L->getLoopPreheader(); std::set<Instruction*> DeadInsts; - for (BasicBlock::iterator I = Header->begin(); - PHINode *PN = dyn_cast<PHINode>(I); ++I) + for (BasicBlock::iterator I = Header->begin(); isa<PHINode>(I); ++I) { + PHINode *PN = cast<PHINode>(I); if (isa<PointerType>(PN->getType())) EliminatePointerRecurrence(PN, Preheader, DeadInsts); + } if (!DeadInsts.empty()) DeleteTriviallyDeadInstructions(DeadInsts); @@ -597,8 +598,8 @@ void IndVarSimplify::runOnLoop(Loop *L) { // auxillary induction variables. std::vector<std::pair<PHINode*, SCEVHandle> > IndVars; - for (BasicBlock::iterator I = Header->begin(); - PHINode *PN = dyn_cast<PHINode>(I); ++I) + for (BasicBlock::iterator I = Header->begin(); isa<PHINode>(I); ++I) { + PHINode *PN = cast<PHINode>(I); if (PN->getType()->isInteger()) { // FIXME: when we have fast-math, enable! SCEVHandle SCEV = SE->getSCEV(PN); if (SCEV->hasComputableLoopEvolution(L)) @@ -611,6 +612,7 @@ void IndVarSimplify::runOnLoop(Loop *L) { if (AR->getNumOperands() == 2 && isa<SCEVConstant>(AR->getOperand(1))) IndVars.push_back(std::make_pair(PN, SCEV)); } + } // If there are no induction variables in the loop, there is nothing more to // do. diff --git a/lib/Transforms/Scalar/LoopUnroll.cpp b/lib/Transforms/Scalar/LoopUnroll.cpp index d24b94fac8..17fc35d6a3 100644 --- a/lib/Transforms/Scalar/LoopUnroll.cpp +++ b/lib/Transforms/Scalar/LoopUnroll.cpp @@ -155,8 +155,8 @@ bool LoopUnroll::visitLoop(Loop *L) { // PHI nodes. Insert associations now. std::map<const Value*, Value*> LastValueMap; std::vector<PHINode*> OrigPHINode; - for (BasicBlock::iterator I = BB->begin(); - PHINode *PN = dyn_cast<PHINode>(I); ++I) { + for (BasicBlock::iterator I = BB->begin(); isa<PHINode>(I); ++I) { + PHINode *PN = cast<PHINode>(I); OrigPHINode.push_back(PN); if (Instruction *I =dyn_cast<Instruction>(PN->getIncomingValueForBlock(BB))) if (I->getParent() == BB) diff --git a/lib/Transforms/Scalar/SCCP.cpp b/lib/Transforms/Scalar/SCCP.cpp index 497bf0ae9b..921ff2b4a9 100644 --- a/lib/Transforms/Scalar/SCCP.cpp +++ b/lib/Transforms/Scalar/SCCP.cpp @@ -198,9 +198,10 @@ private: // The destination is already executable, but we just made an edge // feasible that wasn't before. Revisit the PHI nodes in the block // because they have potentially new operands. - for (BasicBlock::iterator I = Dest->begin(); - PHINode *PN = dyn_cast<PHINode>(I); ++I) + for (BasicBlock::iterator I = Dest->begin(); isa<PHINode>(I); ++I) { + PHINode *PN = cast<PHINode>(I); visitPHINode(*PN); + } } else { DEBUG(std::cerr << "Marking Block Executable: " << Dest->getName()<<"\n"); diff --git a/lib/Transforms/Scalar/TailDuplication.cpp b/lib/Transforms/Scalar/TailDuplication.cpp index 717a845765..491f9bff86 100644 --- a/lib/Transforms/Scalar/TailDuplication.cpp +++ b/lib/Transforms/Scalar/TailDuplication.cpp @@ -214,8 +214,8 @@ void TailDup::eliminateUnconditionalBranch(BranchInst *Branch) { for (succ_iterator SI = succ_begin(DestBlock), SE = succ_end(DestBlock); SI != SE; ++SI) { BasicBlock *Succ = *SI; - for (BasicBlock::iterator PNI = Succ->begin(); - PHINode *PN = dyn_cast<PHINode>(PNI); ++PNI) { + for (BasicBlock::iterator PNI = Succ->begin(); isa<PHINode>(PNI); ++PNI) { + PHINode *PN = cast<PHINode>(PNI); // Ok, we have a PHI node. Figure out what the incoming value was for the // DestBlock. Value *IV = PN->getIncomingValueForBlock(DestBlock); diff --git a/lib/Transforms/Utils/BreakCriticalEdges.cpp b/lib/Transforms/Utils/BreakCriticalEdges.cpp index 4a5c9d904b..a34ebe031a 100644 --- a/lib/Transforms/Utils/BreakCriticalEdges.cpp +++ b/lib/Transforms/Utils/BreakCriticalEdges.cpp @@ -118,8 +118,8 @@ bool llvm::SplitCriticalEdge(TerminatorInst *TI, unsigned SuccNum, Pass *P) { // If there are any PHI nodes in DestBB, we need to update them so that they // merge incoming values from NewBB instead of from TIBB. // - for (BasicBlock::iterator I = DestBB->begin(); - PHINode *PN = dyn_cast<PHINode>(I); ++I) { + for (BasicBlock::iterator I = DestBB->begin(); isa<PHINode>(I); ++I) { + PHINode *PN = cast<PHINode>(I); // We no longer enter through TIBB, now we come in through NewBB. Revector // exactly one entry in the PHI node that used to come from TIBB to come // from NewBB. diff --git a/lib/Transforms/Utils/CloneTrace.cpp b/lib/Transforms/Utils/CloneTrace.cpp index bfd7c6f606..52bdd15dc3 100644 --- a/lib/Transforms/Utils/CloneTrace.cpp +++ b/lib/Transforms/Utils/CloneTrace.cpp @@ -50,16 +50,17 @@ llvm::CloneTrace(const std::vector<BasicBlock*> &origTrace) { //only do this if we are NOT the first block if(T != origTrace.begin()) { for (BasicBlock::iterator I = clonedBlock->begin(); - PHINode *PN = dyn_cast<PHINode>(I); ++I) { - //get incoming value for the previous BB - Value *V = PN->getIncomingValueForBlock(*(T-1)); - assert(V && "No incoming value from a BasicBlock in our trace!"); - - //remap our phi node to point to incoming value - ValueMap[*&I] = V; - - //remove phi node - clonedBlock->getInstList().erase(PN); + isa<PHINode>(I); ++I) { + PHINode *PN = cast<PHINode>(I); + //get incoming value for the previous BB + Value *V = PN->getIncomingValueForBlock(*(T-1)); + assert(V && "No incoming value from a BasicBlock in our trace!"); + + //remap our phi node to point to incoming value + ValueMap[*&I] = V; + + //remove phi node + clonedBlock->getInstList().erase(PN); } } } diff --git a/lib/Transforms/Utils/CodeExtractor.cpp b/lib/Transforms/Utils/CodeExtractor.cpp index 5dd03bd9e7..2b7eb0093f 100644 --- a/lib/Transforms/Utils/CodeExtractor.cpp +++ b/lib/Transforms/Utils/CodeExtractor.cpp @@ -166,8 +166,8 @@ void CodeExtractor::severSplitPHINodes(BasicBlock *&Header) { // Okay, everthing within the region is now branching to the right block, we // just have to update the PHI nodes now, inserting PHI nodes into NewBB. - for (AfterPHIs = OldPred->begin(); - PHINode *PN = dyn_cast<PHINode>(AfterPHIs); ++AfterPHIs) { + for (AfterPHIs = OldPred->begin(); isa<PHINode>(AfterPHIs); ++AfterPHIs) { + PHINode *PN = cast<PHINode>(AfterPHIs); // Create a new PHI node in the new region, which has an incoming value // from OldPred of PN. PHINode *NewPN = new PHINode(PN->getType(), PN->getName()+".ce", @@ -644,20 +644,21 @@ ExtractCodeRegion(const std::vector<BasicBlock*> &code) { // Loop over all of the PHI nodes in the header block, and change any // references to the old incoming edge to be the new incoming edge. - for (BasicBlock::iterator I = header->begin(); - PHINode *PN = dyn_cast<PHINode>(I); ++I) + for (BasicBlock::iterator I = header->begin(); isa<PHINode>(I); ++I) { + PHINode *PN = cast<PHINode>(I); for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i) if (!BlocksToExtract.count(PN->getIncomingBlock(i))) PN->setIncomingBlock(i, newFuncRoot); - + } + // Look at all successors of the codeReplacer block. If any of these blocks // had PHI nodes in them, we need to update the "from" block to be the code // replacer, not the original block in the extracted region. std::vector<BasicBlock*> Succs(succ_begin(codeReplacer), succ_end(codeReplacer)); for (unsigned i = 0, e = Succs.size(); i != e; ++i) - for (BasicBlock::iterator I = Succs[i]->begin(); - PHINode *PN = dyn_cast<PHINode>(I); ++I) { + for (BasicBlock::iterator I = Succs[i]->begin(); isa<PHINode>(I); ++I) { + PHINode *PN = cast<PHINode>(I); std::set<BasicBlock*> ProcessedPreds; for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i) if (BlocksToExtract.count(PN->getIncomingBlock(i))) diff --git a/lib/Transforms/Utils/InlineFunction.cpp b/lib/Transforms/Utils/InlineFunction.cpp index 51fbd14ebf..9f47825454 100644 --- a/lib/Transforms/Utils/InlineFunction.cpp +++ b/lib/Transforms/Utils/InlineFunction.cpp @@ -111,10 +111,11 @@ bool llvm::InlineFunction(CallSite CS) { // If there are PHI nodes in the exceptional destination block, we need to // keep track of which values came into them from this invoke, then remove // the entry for this block. - for (BasicBlock::iterator I = InvokeDest->begin(); - PHINode *PN = dyn_cast<PHINode>(I); ++I) + for (BasicBlock::iterator I = InvokeDest->begin(); isa<PHINode>(I); ++I) { + PHINode *PN = cast<PHINode>(I); // Save the value to use for this edge... InvokeDestPHIValues.push_back(PN->getIncomingValueForBlock(OrigBB)); + } for (Function::iterator BB = FirstNewBlock, E = Caller->end(); BB != E; ++BB) { @@ -149,8 +150,10 @@ bool llvm::InlineFunction(CallSite CS) { // there is now a new entry in them. unsigned i = 0; for (BasicBlock::iterator I = InvokeDest->begin(); - PHINode *PN = dyn_cast<PHINode>(I); ++I, ++i) + isa<PHINode>(I); ++I, ++i) { + PHINode *PN = cast<PHINode>(I); PN->addIncoming(InvokeDestPHIValues[i], BB); + } // This basic block is now complete, start scanning the next one. break; @@ -174,8 +177,10 @@ bool llvm::InlineFunction(CallSite CS) { // there is now a new entry in them. unsigned i = 0; for (BasicBlock::iterator I = InvokeDest->begin(); - PHINode *PN = dyn_cast<PHINode>(I); ++I, ++i) + isa<PHINode>(I); ++I, ++i) { + PHINode *PN = cast<PHINode>(I); PN->addIncoming(InvokeDestPHIValues[i], BB); + } } } diff --git a/lib/Transforms/Utils/LowerSwitch.cpp b/lib/Transforms/Utils/LowerSwitch.cpp index ef684e7b89..242343f652 100644 --- a/lib/Transforms/Utils/LowerSwitch.cpp +++ b/lib/Transforms/Utils/LowerSwitch.cpp @@ -160,8 +160,8 @@ BasicBlock* LowerSwitch::newLeafBlock(Case& Leaf, Value* Val, // If there were any PHI nodes in this successor, rewrite one entry // from OrigBlock to come from NewLeaf. - for (BasicBlock::iterator I = Succ->begin(); - PHINode* PN = dyn_cast<PHINode>(I); ++I) { + for (BasicBlock::iterator I = Succ->begin(); isa<PHINode>(I); ++I) { + PHINode* PN = cast<PHINode>(I); int BlockIdx = PN->getBasicBlockIndex(OrigBlock); assert(BlockIdx != -1 && "Switch didn't go to this successor??"); PN->setIncomingBlock((unsigned)BlockIdx, NewLeaf); @@ -196,8 +196,8 @@ void LowerSwitch::processSwitchInst(SwitchInst *SI) { // If there is an entry in any PHI nodes for the default edge, make sure // to update them as well. - for (BasicBlock::iterator I = Default->begin(); - PHINode *PN = dyn_cast<PHINode>(I); ++I) { + for (BasicBlock::iterator I = Default->begin(); isa<PHINode>(I); ++I) { + PHINode *PN = cast<PHINode>(I); int BlockIdx = PN->getBasicBlockIndex(OrigBlock); assert(BlockIdx != -1 && "Switch didn't go to this successor??"); PN->setIncomingBlock((unsigned)BlockIdx, NewDefault); diff --git a/lib/Transforms/Utils/SimplifyCFG.cpp b/lib/Transforms/Utils/SimplifyCFG.cpp index 419c8a7542..baa737eddb 100644 --- a/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/lib/Transforms/Utils/SimplifyCFG.cpp @@ -52,8 +52,8 @@ static bool PropagatePredecessorsForPHIs(BasicBlock *BB, BasicBlock *Succ) { if (std::find(BBPreds.begin(), BBPreds.end(), *PI) != BBPreds.end()) { // Loop over all of the PHI nodes checking to see if there are // incompatible values coming in. - for (BasicBlock::iterator I = Succ->begin(); - PHINode *PN = dyn_cast<PHINode>(I); ++I) { + for (BasicBlock::iterator I = Succ->begin(); isa<PHINode>(I); ++I) { + PHINode *PN = cast<PHINode>(I); // Loop up the entries in the PHI node for BB and for *PI if the values // coming in are non-equal, we cannot merge these two blocks (instead we // should insert a conditional move or something, then merge the @@ -68,8 +68,8 @@ static bool PropagatePredecessorsForPHIs(BasicBlock *BB, BasicBlock *Succ) { } // Loop over all of the PHI nodes in the successor BB. - for (BasicBlock::iterator I = Succ->begin(); - PHINode *PN = dyn_cast<PHINode>(I); ++I) { + for (BasicBlock::iterator I = Succ->begin(); isa<PHINode>(I); ++I) { + PHINode *PN = cast<PHINode>(I); Value *OldVal = PN->removeIncomingValue(BB, false); assert(OldVal && "No entry in PHI for Pred BB!"); @@ -341,10 +341,12 @@ static bool SafeToMergeTerminators(TerminatorInst *SI1, TerminatorInst *SI2) { for (succ_iterator I = succ_begin(SI2BB), E = succ_end(SI2BB); I != E; ++I) if (SI1Succs.count(*I)) for (BasicBlock::iterator BBI = (*I)->begin(); - PHINode *PN = dyn_cast<PHINode>(BBI); ++BBI) + isa<PHINode>(BBI); ++BBI) { + PHINode *PN = cast<PHINode>(BBI); if (PN->getIncomingValueForBlock(SI1BB) != PN->getIncomingValueForBlock(SI2BB)) return false; + } return true; } @@ -359,8 +361,8 @@ static void AddPredecessorToBlock(BasicBlock *Succ, BasicBlock *NewPred, succ_end(ExistPred) && "ExistPred is not a predecessor of Succ!"); if (!isa<PHINode>(Succ->begin())) return; // Quick exit if nothing to do - for (BasicBlock::iterator I = Succ->begin(); - PHINode *PN = dyn_cast<PHINode>(I); ++I) { + for (BasicBlock::iterator I = Succ->begin(); isa<PHINode>(I); ++I) { + PHINode *PN = cast<PHINode>(I); Value *V = PN->getIncomingValueForBlock(ExistPred); PN->addIncoming(V, NewPred); } @@ -994,7 +996,8 @@ bool llvm::SimplifyCFG(BasicBlock *BB) { // PHI nodes in EdgeBB, they need entries to be added corresponding to // the number of edges added. for (BasicBlock::iterator BBI = EdgeBB->begin(); - PHINode *PN = dyn_cast<PHINode>(BBI); ++BBI) { + isa<PHINode>(BBI); ++BBI) { + PHINode *PN = cast<PHINode>(BBI); Value *InVal = PN->getIncomingValueForBlock(*PI); for (unsigned i = 0, e = Values.size()-1; i != e; ++i) PN->addIncoming(InVal, *PI); |