Convert code to compile with vc7.1.
authorReid Spencer <rspencer@reidspencer.com>
Wed, 15 Sep 2004 17:06:42 +0000 (17:06 +0000)
committerReid Spencer <rspencer@reidspencer.com>
Wed, 15 Sep 2004 17:06:42 +0000 (17:06 +0000)
Patch contributed by Paolo Invernizzi. Thanks Paolo!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16368 91177308-0d34-0410-b5e6-96231b3b80d8

16 files changed:
lib/Analysis/LoopInfo.cpp
lib/Bytecode/Reader/Reader.cpp
lib/ExecutionEngine/Interpreter/Execution.cpp
lib/Target/X86/X86ISelSimple.cpp
lib/Transforms/Scalar/ADCE.cpp
lib/Transforms/Scalar/CorrelatedExprs.cpp
lib/Transforms/Scalar/IndVarSimplify.cpp
lib/Transforms/Scalar/LoopUnroll.cpp
lib/Transforms/Scalar/SCCP.cpp
lib/Transforms/Scalar/TailDuplication.cpp
lib/Transforms/Utils/BreakCriticalEdges.cpp
lib/Transforms/Utils/CloneTrace.cpp
lib/Transforms/Utils/CodeExtractor.cpp
lib/Transforms/Utils/InlineFunction.cpp
lib/Transforms/Utils/LowerSwitch.cpp
lib/Transforms/Utils/SimplifyCFG.cpp

index 8b9b11aadc14870063fa47a6b56faabe128bdbe0..0444c84ec223f00ad262da7d1f01194dbbd82aa3 100644 (file)
@@ -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<PHINode>(I); ++I)
+  for (BasicBlock::iterator I = H->begin(); isa<PHINode>(I); ++I) {
+    PHINode *PN = cast<PHINode>(I);
     if (Instruction *Inc =
         dyn_cast<Instruction>(PN->getIncomingValueForBlock(Backedge)))
       if (Inc->getOpcode() == Instruction::Add && Inc->getOperand(0) == PN)
         if (ConstantInt *CI = dyn_cast<ConstantInt>(Inc->getOperand(1)))
           if (CI->equalsInt(1))
             return PN;
-
+  }
   return 0;
 }
 
index e821c946e16f93f1cdecfadbaf392d42e00c43e4..18780208e2b28d181dcf874581308fd9eb31626b 100644 (file)
@@ -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.");
index 5e1ae0629f8ee532379fb627ec6cf080b2740488..589ac7f99dc62a9ec67fdb03e8f48ae063b04f6d 100644 (file)
@@ -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<PHINode>(SF.CurInst);
-       ++SF.CurInst, ++i)
+  for (unsigned i = 0; isa<PHINode>(SF.CurInst); ++SF.CurInst, ++i) {
+    PHINode *PN = cast<PHINode>(SF.CurInst);
     SetValue(PN, ResultValues[i], SF);
+  }
 }
 
 //===----------------------------------------------------------------------===//
index e9dbc4b314ad5d260db286edc46f98534f3bcaaa..c3a63fedd8bcddbc4be57d63e3291ae41860f5ca 100644 (file)
@@ -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<PHINode*>(dyn_cast<PHINode>(I)); ++I) {
+    for (BasicBlock::const_iterator I = BB->begin(); isa<PHINode>(I); ++I) {
+      PHINode *PN = const_cast<PHINode*>(dyn_cast<PHINode>(I));
 
       // Create a new machine instr PHI node, and insert it.
       unsigned PHIReg = getReg(*PN);
index 5770bb692c23196095a9040e1ecfef85e3af95d3..4bd24972d5dd3021952391e7d982c539d1885af5 100644 (file)
@@ -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);
                 }
+              }
             }
           }
 
index 53c56d2631abc8aa26f982912a00279892c77186..c365622cb447659d883db7bcce6f58523f2597cc 100644 (file)
@@ -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
index a2693534879bbfae2a8c1e96c28de8556f0b94d6..3e6e960ec0b6d8105a7780ea01ab47651b7a6ba6 100644 (file)
@@ -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.
index d24b94fac85083aed077a646f14858b82e3f96c4..17fc35d6a328667a8abf149b0c051700f76e316c 100644 (file)
@@ -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)
index 497bf0ae9bb549d81a31bb13e7ea83a480cacfe3..921ff2b4a97d7fee69772ab50b73db0ac5dd6e04 100644 (file)
@@ -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");
index 717a845765ac389627e19834a40ae6ce44ec992e..491f9bff86e9c58b47a6ba9479c00efd0ff38b2d 100644 (file)
@@ -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);
index 4a5c9d904bfc531c0e1595cd2da00ba02df051c1..a34ebe031a3738eaec96609dec4d2290f3a98ce1 100644 (file)
@@ -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.
index bfd7c6f60652b11ea4224525afccdb9568a2621d..52bdd15dc310da80736ea6175ea4a3e72a911372 100644 (file)
@@ -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);
       }
     }
   }
index 5dd03bd9e75f3855327a68925d6fee7390c8f5c1..2b7eb0093feff945aa79c55bb9c7cc913f98d4a5 100644 (file)
@@ -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)))
index 51fbd14ebf161594375b36d0b3c310ad784e0c61..9f47825454ab119fe013ff2a67a4738e24fd0d58 100644 (file)
@@ -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);
+        }
       }
     }
 
index ef684e7b89df927a6b5b9a1084abfeac0d836e15..242343f652dae0125678b3c6f50839f1b9743b94 100644 (file)
@@ -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);
index 419c8a7542156fc623592c900d06d2cf1a36bba6..baa737eddb83f533b7da59f6e07e41a7e567ccaa 100644 (file)
@@ -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);