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
This commit is contained in:
Reid Spencer 2004-09-15 17:06:42 +00:00
parent 7e0e9c635f
commit 2da5c3dda6
16 changed files with 74 additions and 58 deletions

View 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;
}

View 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.");

View 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);
}
}
//===----------------------------------------------------------------------===//

View 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);

View 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);
}
}
}
}

View 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

View 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.

View 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)

View 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");

View 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);

View 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.

View 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);
}
}
}

View 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)))

View 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);
}
}
}

View 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);

View 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);