From 6614946443f3df8c4d7263455302a5734f2c1ce3 Mon Sep 17 00:00:00 2001 From: Reid Spencer Date: Wed, 15 Sep 2004 17:06:42 +0000 Subject: [PATCH] Convert code to compile with vc7.1. Patch contributed by Paolo Invernizzi. Thanks Paolo! llvm-svn: 16368 --- llvm/lib/Analysis/LoopInfo.cpp | 6 +++--- llvm/lib/Bytecode/Reader/Reader.cpp | 6 +++--- .../ExecutionEngine/Interpreter/Execution.cpp | 5 +++-- llvm/lib/Target/X86/X86ISelSimple.cpp | 4 ++-- llvm/lib/Transforms/Scalar/ADCE.cpp | 4 +++- .../lib/Transforms/Scalar/CorrelatedExprs.cpp | 4 ++-- llvm/lib/Transforms/Scalar/IndVarSimplify.cpp | 10 +++++---- llvm/lib/Transforms/Scalar/LoopUnroll.cpp | 4 ++-- llvm/lib/Transforms/Scalar/LowerSwitch.cpp | 8 +++---- llvm/lib/Transforms/Scalar/SCCP.cpp | 5 +++-- .../lib/Transforms/Scalar/TailDuplication.cpp | 4 ++-- .../Transforms/Utils/BreakCriticalEdges.cpp | 4 ++-- llvm/lib/Transforms/Utils/CloneTrace.cpp | 21 ++++++++++--------- llvm/lib/Transforms/Utils/CodeExtractor.cpp | 15 ++++++------- llvm/lib/Transforms/Utils/InlineFunction.cpp | 13 ++++++++---- llvm/lib/Transforms/Utils/SimplifyCFG.cpp | 19 ++++++++++------- 16 files changed, 74 insertions(+), 58 deletions(-) diff --git a/llvm/lib/Analysis/LoopInfo.cpp b/llvm/lib/Analysis/LoopInfo.cpp index 8b9b11aadc14..0444c84ec223 100644 --- a/llvm/lib/Analysis/LoopInfo.cpp +++ b/llvm/lib/Analysis/LoopInfo.cpp @@ -404,15 +404,15 @@ PHINode *Loop::getCanonicalInductionVariable() const { return 0; // Loop over all of the PHI nodes, looking for a canonical indvar. - for (BasicBlock::iterator I = H->begin(); - PHINode *PN = dyn_cast(I); ++I) + for (BasicBlock::iterator I = H->begin(); isa(I); ++I) { + PHINode *PN = cast(I); if (Instruction *Inc = dyn_cast(PN->getIncomingValueForBlock(Backedge))) if (Inc->getOpcode() == Instruction::Add && Inc->getOperand(0) == PN) if (ConstantInt *CI = dyn_cast(Inc->getOperand(1))) if (CI->equalsInt(1)) return PN; - + } return 0; } diff --git a/llvm/lib/Bytecode/Reader/Reader.cpp b/llvm/lib/Bytecode/Reader/Reader.cpp index e821c946e16f..18780208e2b2 100644 --- a/llvm/lib/Bytecode/Reader/Reader.cpp +++ b/llvm/lib/Bytecode/Reader/Reader.cpp @@ -347,14 +347,14 @@ unsigned BytecodeReader::getTypeSlot(const Type *Ty) { } // Check the function level types first... - TypeListTy::iterator I = find(FunctionTypes.begin(), FunctionTypes.end(), Ty); + TypeListTy::iterator I = std::find(FunctionTypes.begin(), FunctionTypes.end(), Ty); if (I != FunctionTypes.end()) return Type::FirstDerivedTyID + ModuleTypes.size() + (&*I - &FunctionTypes[0]); // Check the module level types now... - I = find(ModuleTypes.begin(), ModuleTypes.end(), Ty); + I = std::find(ModuleTypes.begin(), ModuleTypes.end(), Ty); if (I == ModuleTypes.end()) error("Didn't find type in ModuleTypes."); return Type::FirstDerivedTyID + (&*I - &ModuleTypes[0]); @@ -381,7 +381,7 @@ const Type *BytecodeReader::getGlobalTableType(unsigned Slot) { unsigned BytecodeReader::getGlobalTableTypeSlot(const Type *Ty) { if (Ty->isPrimitiveType()) return Ty->getTypeID(); - TypeListTy::iterator I = find(ModuleTypes.begin(), + TypeListTy::iterator I = std::find(ModuleTypes.begin(), ModuleTypes.end(), Ty); if (I == ModuleTypes.end()) error("Didn't find type in ModuleTypes."); diff --git a/llvm/lib/ExecutionEngine/Interpreter/Execution.cpp b/llvm/lib/ExecutionEngine/Interpreter/Execution.cpp index 5e1ae0629f8e..589ac7f99dc6 100644 --- a/llvm/lib/ExecutionEngine/Interpreter/Execution.cpp +++ b/llvm/lib/ExecutionEngine/Interpreter/Execution.cpp @@ -679,9 +679,10 @@ void Interpreter::SwitchToNewBasicBlock(BasicBlock *Dest, ExecutionContext &SF){ // Now loop over all of the PHI nodes setting their values... SF.CurInst = SF.CurBB->begin(); - for (unsigned i = 0; PHINode *PN = dyn_cast(SF.CurInst); - ++SF.CurInst, ++i) + for (unsigned i = 0; isa(SF.CurInst); ++SF.CurInst, ++i) { + PHINode *PN = cast(SF.CurInst); SetValue(PN, ResultValues[i], SF); + } } //===----------------------------------------------------------------------===// diff --git a/llvm/lib/Target/X86/X86ISelSimple.cpp b/llvm/lib/Target/X86/X86ISelSimple.cpp index e9dbc4b314ad..c3a63fedd8bc 100644 --- a/llvm/lib/Target/X86/X86ISelSimple.cpp +++ b/llvm/lib/Target/X86/X86ISelSimple.cpp @@ -643,8 +643,8 @@ void ISel::SelectPHINodes() { // Loop over all of the PHI nodes in the LLVM basic block... MachineBasicBlock::iterator PHIInsertPoint = MBB.begin(); - for (BasicBlock::const_iterator I = BB->begin(); - PHINode *PN = const_cast(dyn_cast(I)); ++I) { + for (BasicBlock::const_iterator I = BB->begin(); isa(I); ++I) { + PHINode *PN = const_cast(dyn_cast(I)); // Create a new machine instr PHI node, and insert it. unsigned PHIReg = getReg(*PN); diff --git a/llvm/lib/Transforms/Scalar/ADCE.cpp b/llvm/lib/Transforms/Scalar/ADCE.cpp index 5770bb692c23..4bd24972d5dd 100644 --- a/llvm/lib/Transforms/Scalar/ADCE.cpp +++ b/llvm/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(II); ++II) + isa(II); ++II) { + PHINode *PN = cast(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/llvm/lib/Transforms/Scalar/CorrelatedExprs.cpp b/llvm/lib/Transforms/Scalar/CorrelatedExprs.cpp index 53c56d2631ab..c365622cb447 100644 --- a/llvm/lib/Transforms/Scalar/CorrelatedExprs.cpp +++ b/llvm/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(I); ) { + for (BasicBlock::iterator I = OldSucc->begin(); isa(I); ) { + PHINode *PN = cast(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/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp b/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp index a2693534879b..3e6e960ec0b6 100644 --- a/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp +++ b/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp @@ -570,10 +570,11 @@ void IndVarSimplify::runOnLoop(Loop *L) { BasicBlock *Preheader = L->getLoopPreheader(); std::set DeadInsts; - for (BasicBlock::iterator I = Header->begin(); - PHINode *PN = dyn_cast(I); ++I) + for (BasicBlock::iterator I = Header->begin(); isa(I); ++I) { + PHINode *PN = cast(I); if (isa(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 > IndVars; - for (BasicBlock::iterator I = Header->begin(); - PHINode *PN = dyn_cast(I); ++I) + for (BasicBlock::iterator I = Header->begin(); isa(I); ++I) { + PHINode *PN = cast(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(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/llvm/lib/Transforms/Scalar/LoopUnroll.cpp b/llvm/lib/Transforms/Scalar/LoopUnroll.cpp index d24b94fac850..17fc35d6a328 100644 --- a/llvm/lib/Transforms/Scalar/LoopUnroll.cpp +++ b/llvm/lib/Transforms/Scalar/LoopUnroll.cpp @@ -155,8 +155,8 @@ bool LoopUnroll::visitLoop(Loop *L) { // PHI nodes. Insert associations now. std::map LastValueMap; std::vector OrigPHINode; - for (BasicBlock::iterator I = BB->begin(); - PHINode *PN = dyn_cast(I); ++I) { + for (BasicBlock::iterator I = BB->begin(); isa(I); ++I) { + PHINode *PN = cast(I); OrigPHINode.push_back(PN); if (Instruction *I =dyn_cast(PN->getIncomingValueForBlock(BB))) if (I->getParent() == BB) diff --git a/llvm/lib/Transforms/Scalar/LowerSwitch.cpp b/llvm/lib/Transforms/Scalar/LowerSwitch.cpp index ef684e7b89df..242343f652da 100644 --- a/llvm/lib/Transforms/Scalar/LowerSwitch.cpp +++ b/llvm/lib/Transforms/Scalar/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(I); ++I) { + for (BasicBlock::iterator I = Succ->begin(); isa(I); ++I) { + PHINode* PN = cast(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(I); ++I) { + for (BasicBlock::iterator I = Default->begin(); isa(I); ++I) { + PHINode *PN = cast(I); int BlockIdx = PN->getBasicBlockIndex(OrigBlock); assert(BlockIdx != -1 && "Switch didn't go to this successor??"); PN->setIncomingBlock((unsigned)BlockIdx, NewDefault); diff --git a/llvm/lib/Transforms/Scalar/SCCP.cpp b/llvm/lib/Transforms/Scalar/SCCP.cpp index 497bf0ae9bb5..921ff2b4a97d 100644 --- a/llvm/lib/Transforms/Scalar/SCCP.cpp +++ b/llvm/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(I); ++I) + for (BasicBlock::iterator I = Dest->begin(); isa(I); ++I) { + PHINode *PN = cast(I); visitPHINode(*PN); + } } else { DEBUG(std::cerr << "Marking Block Executable: " << Dest->getName()<<"\n"); diff --git a/llvm/lib/Transforms/Scalar/TailDuplication.cpp b/llvm/lib/Transforms/Scalar/TailDuplication.cpp index 717a845765ac..491f9bff86e9 100644 --- a/llvm/lib/Transforms/Scalar/TailDuplication.cpp +++ b/llvm/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(PNI); ++PNI) { + for (BasicBlock::iterator PNI = Succ->begin(); isa(PNI); ++PNI) { + PHINode *PN = cast(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/llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp b/llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp index 4a5c9d904bfc..a34ebe031a37 100644 --- a/llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp +++ b/llvm/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(I); ++I) { + for (BasicBlock::iterator I = DestBB->begin(); isa(I); ++I) { + PHINode *PN = cast(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/llvm/lib/Transforms/Utils/CloneTrace.cpp b/llvm/lib/Transforms/Utils/CloneTrace.cpp index bfd7c6f60652..52bdd15dc310 100644 --- a/llvm/lib/Transforms/Utils/CloneTrace.cpp +++ b/llvm/lib/Transforms/Utils/CloneTrace.cpp @@ -50,16 +50,17 @@ llvm::CloneTrace(const std::vector &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(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(I); ++I) { + PHINode *PN = cast(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/llvm/lib/Transforms/Utils/CodeExtractor.cpp b/llvm/lib/Transforms/Utils/CodeExtractor.cpp index 5dd03bd9e75f..2b7eb0093fef 100644 --- a/llvm/lib/Transforms/Utils/CodeExtractor.cpp +++ b/llvm/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(AfterPHIs); ++AfterPHIs) { + for (AfterPHIs = OldPred->begin(); isa(AfterPHIs); ++AfterPHIs) { + PHINode *PN = cast(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 &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(I); ++I) + for (BasicBlock::iterator I = header->begin(); isa(I); ++I) { + PHINode *PN = cast(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 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(I); ++I) { + for (BasicBlock::iterator I = Succs[i]->begin(); isa(I); ++I) { + PHINode *PN = cast(I); std::set ProcessedPreds; for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i) if (BlocksToExtract.count(PN->getIncomingBlock(i))) diff --git a/llvm/lib/Transforms/Utils/InlineFunction.cpp b/llvm/lib/Transforms/Utils/InlineFunction.cpp index 51fbd14ebf16..9f47825454ab 100644 --- a/llvm/lib/Transforms/Utils/InlineFunction.cpp +++ b/llvm/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(I); ++I) + for (BasicBlock::iterator I = InvokeDest->begin(); isa(I); ++I) { + PHINode *PN = cast(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(I); ++I, ++i) + isa(I); ++I, ++i) { + PHINode *PN = cast(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(I); ++I, ++i) + isa(I); ++I, ++i) { + PHINode *PN = cast(I); PN->addIncoming(InvokeDestPHIValues[i], BB); + } } } diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp index 419c8a754215..baa737eddb83 100644 --- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/llvm/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(I); ++I) { + for (BasicBlock::iterator I = Succ->begin(); isa(I); ++I) { + PHINode *PN = cast(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(I); ++I) { + for (BasicBlock::iterator I = Succ->begin(); isa(I); ++I) { + PHINode *PN = cast(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(BBI); ++BBI) + isa(BBI); ++BBI) { + PHINode *PN = cast(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(Succ->begin())) return; // Quick exit if nothing to do - for (BasicBlock::iterator I = Succ->begin(); - PHINode *PN = dyn_cast(I); ++I) { + for (BasicBlock::iterator I = Succ->begin(); isa(I); ++I) { + PHINode *PN = cast(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(BBI); ++BBI) { + isa(BBI); ++BBI) { + PHINode *PN = cast(BBI); Value *InVal = PN->getIncomingValueForBlock(*PI); for (unsigned i = 0, e = Values.size()-1; i != e; ++i) PN->addIncoming(InVal, *PI);