mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-04-06 09:44:39 +00:00
Use do+while instead of while for loops which obviously have a
non-zero trip count. Use SmallVector's pop_back_val(). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92734 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
b7a9f2b504
commit
321a813c53
@ -1000,9 +1000,8 @@ static bool AddReachableCodeToWorklist(BasicBlock *BB,
|
||||
|
||||
SmallPtrSet<ConstantExpr*, 64> FoldedConstants;
|
||||
|
||||
while (!Worklist.empty()) {
|
||||
BB = Worklist.back();
|
||||
Worklist.pop_back();
|
||||
do {
|
||||
BB = Worklist.pop_back_val();
|
||||
|
||||
// We have now visited this block! If we've already been here, ignore it.
|
||||
if (!Visited.insert(BB)) continue;
|
||||
@ -1082,7 +1081,7 @@ static bool AddReachableCodeToWorklist(BasicBlock *BB,
|
||||
|
||||
for (unsigned i = 0, e = TI->getNumSuccessors(); i != e; ++i)
|
||||
Worklist.push_back(TI->getSuccessor(i));
|
||||
}
|
||||
} while (!Worklist.empty());
|
||||
|
||||
// Once we've found all of the instructions to add to instcombine's worklist,
|
||||
// add them in reverse order. This way instcombine will visit from the top
|
||||
|
@ -62,8 +62,7 @@ bool ADCE::runOnFunction(Function& F) {
|
||||
|
||||
// Propagate liveness backwards to operands.
|
||||
while (!worklist.empty()) {
|
||||
Instruction* curr = worklist.back();
|
||||
worklist.pop_back();
|
||||
Instruction* curr = worklist.pop_back_val();
|
||||
|
||||
for (Instruction::op_iterator OI = curr->op_begin(), OE = curr->op_end();
|
||||
OI != OE; ++OI)
|
||||
|
@ -523,9 +523,8 @@ void DSE::DeleteDeadInstruction(Instruction *I,
|
||||
|
||||
// Before we touch this instruction, remove it from memdep!
|
||||
MemoryDependenceAnalysis &MDA = getAnalysis<MemoryDependenceAnalysis>();
|
||||
while (!NowDeadInsts.empty()) {
|
||||
Instruction *DeadInst = NowDeadInsts.back();
|
||||
NowDeadInsts.pop_back();
|
||||
do {
|
||||
Instruction *DeadInst = NowDeadInsts.pop_back_val();
|
||||
|
||||
++NumFastOther;
|
||||
|
||||
@ -549,7 +548,7 @@ void DSE::DeleteDeadInstruction(Instruction *I,
|
||||
DeadInst->eraseFromParent();
|
||||
|
||||
if (ValueSet) ValueSet->erase(DeadInst);
|
||||
}
|
||||
} while (!NowDeadInsts.empty());
|
||||
}
|
||||
|
||||
unsigned DSE::getPointerSize(Value *V) const {
|
||||
|
@ -829,7 +829,7 @@ SpeculationFailure:
|
||||
SmallVector<BasicBlock*, 32> BBWorklist;
|
||||
BBWorklist.push_back(BB);
|
||||
|
||||
while (!BBWorklist.empty()) {
|
||||
do {
|
||||
BasicBlock *Entry = BBWorklist.pop_back_val();
|
||||
// Note that this sets blocks to 0 (unavailable) if they happen to not
|
||||
// already be in FullyAvailableBlocks. This is safe.
|
||||
@ -841,7 +841,7 @@ SpeculationFailure:
|
||||
|
||||
for (succ_iterator I = succ_begin(Entry), E = succ_end(Entry); I != E; ++I)
|
||||
BBWorklist.push_back(*I);
|
||||
}
|
||||
} while (!BBWorklist.empty());
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -708,7 +708,7 @@ void LoopIndexSplit::removeBlocks(BasicBlock *DeadBB, Loop *LP,
|
||||
}
|
||||
|
||||
while (!WorkList.empty()) {
|
||||
BasicBlock *BB = WorkList.back(); WorkList.pop_back();
|
||||
BasicBlock *BB = WorkList.pop_back_val();
|
||||
LPM->deleteSimpleAnalysisValue(BB, LP);
|
||||
for(BasicBlock::iterator BBI = BB->begin(), BBE = BB->end();
|
||||
BBI != BBE; ) {
|
||||
@ -726,7 +726,7 @@ void LoopIndexSplit::removeBlocks(BasicBlock *DeadBB, Loop *LP,
|
||||
|
||||
// Update Frontier BBs' dominator info.
|
||||
while (!FrontierBBs.empty()) {
|
||||
BasicBlock *FBB = FrontierBBs.back(); FrontierBBs.pop_back();
|
||||
BasicBlock *FBB = FrontierBBs.pop_back_val();
|
||||
BasicBlock *NewDominator = FBB->getSinglePredecessor();
|
||||
if (!NewDominator) {
|
||||
pred_iterator PI = pred_begin(FBB), PE = pred_end(FBB);
|
||||
|
@ -562,8 +562,7 @@ bool MemCpyOpt::performCallSlotOptzn(MemCpyInst *cpy, CallInst *C) {
|
||||
SmallVector<User*, 8> srcUseList(srcAlloca->use_begin(),
|
||||
srcAlloca->use_end());
|
||||
while (!srcUseList.empty()) {
|
||||
User *UI = srcUseList.back();
|
||||
srcUseList.pop_back();
|
||||
User *UI = srcUseList.pop_back_val();
|
||||
|
||||
if (isa<BitCastInst>(UI)) {
|
||||
for (User::use_iterator I = UI->use_begin(), E = UI->use_end();
|
||||
|
@ -678,8 +678,7 @@ bool SCCVN::runOnFunction(Function& F) {
|
||||
stack.push_back(*PI);
|
||||
|
||||
while (!stack.empty()) {
|
||||
BasicBlock* CurrBB = stack.back();
|
||||
stack.pop_back();
|
||||
BasicBlock* CurrBB = stack.pop_back_val();
|
||||
visited.insert(CurrBB);
|
||||
|
||||
ValueNumberScope* S = BBMap[CurrBB];
|
||||
|
@ -1181,7 +1181,7 @@ void SROA::CleanupAllocaUsers(Value *V) {
|
||||
if (!isa<StoreInst>(I) && OnlyUsedByDbgInfoIntrinsics(I, &DbgInUses)) {
|
||||
// Safe to remove debug info uses.
|
||||
while (!DbgInUses.empty()) {
|
||||
DbgInfoIntrinsic *DI = DbgInUses.back(); DbgInUses.pop_back();
|
||||
DbgInfoIntrinsic *DI = DbgInUses.pop_back_val();
|
||||
DI->eraseFromParent();
|
||||
}
|
||||
I->eraseFromParent();
|
||||
|
@ -99,9 +99,8 @@ static bool MarkAliveBlocks(BasicBlock *BB,
|
||||
SmallVector<BasicBlock*, 128> Worklist;
|
||||
Worklist.push_back(BB);
|
||||
bool Changed = false;
|
||||
while (!Worklist.empty()) {
|
||||
BB = Worklist.back();
|
||||
Worklist.pop_back();
|
||||
do {
|
||||
BB = Worklist.pop_back_val();
|
||||
|
||||
if (!Reachable.insert(BB))
|
||||
continue;
|
||||
@ -150,7 +149,7 @@ static bool MarkAliveBlocks(BasicBlock *BB,
|
||||
Changed |= ConstantFoldTerminator(BB);
|
||||
for (succ_iterator SI = succ_begin(BB), SE = succ_end(BB); SI != SE; ++SI)
|
||||
Worklist.push_back(*SI);
|
||||
}
|
||||
} while (!Worklist.empty());
|
||||
return Changed;
|
||||
}
|
||||
|
||||
|
@ -91,7 +91,7 @@ Loop *llvm::CloneLoop(Loop *OrigL, LPPassManager *LPM, LoopInfo *LI,
|
||||
|
||||
|
||||
Loop *NewParentLoop = NULL;
|
||||
while (!LoopNest.empty()) {
|
||||
do {
|
||||
Loop *L = LoopNest.pop_back_val();
|
||||
Loop *NewLoop = new Loop();
|
||||
|
||||
@ -123,7 +123,7 @@ Loop *llvm::CloneLoop(Loop *OrigL, LPPassManager *LPM, LoopInfo *LI,
|
||||
// Process sub loops
|
||||
for (Loop::iterator I = L->begin(), E = L->end(); I != E; ++I)
|
||||
LoopNest.push_back(*I);
|
||||
}
|
||||
} while (!LoopNest.empty());
|
||||
|
||||
// Remap instructions to reference operands from ValueMap.
|
||||
for(SmallVector<BasicBlock *, 16>::iterator NBItr = NewBlocks.begin(),
|
||||
|
@ -278,7 +278,7 @@ bool llvm::RecursivelyDeleteTriviallyDeadInstructions(Value *V) {
|
||||
SmallVector<Instruction*, 16> DeadInsts;
|
||||
DeadInsts.push_back(I);
|
||||
|
||||
while (!DeadInsts.empty()) {
|
||||
do {
|
||||
I = DeadInsts.pop_back_val();
|
||||
|
||||
// Null out all of the instruction's operands to see if any operand becomes
|
||||
@ -298,7 +298,7 @@ bool llvm::RecursivelyDeleteTriviallyDeadInstructions(Value *V) {
|
||||
}
|
||||
|
||||
I->eraseFromParent();
|
||||
}
|
||||
} while (!DeadInsts.empty());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -448,13 +448,13 @@ void PromoteMem2Reg::run() {
|
||||
//
|
||||
std::vector<RenamePassData> RenamePassWorkList;
|
||||
RenamePassWorkList.push_back(RenamePassData(F.begin(), 0, Values));
|
||||
while (!RenamePassWorkList.empty()) {
|
||||
do {
|
||||
RenamePassData RPD;
|
||||
RPD.swap(RenamePassWorkList.back());
|
||||
RenamePassWorkList.pop_back();
|
||||
// RenamePass may add new worklist entries.
|
||||
RenamePass(RPD.BB, RPD.Pred, RPD.Values, RenamePassWorkList);
|
||||
}
|
||||
} while (!RenamePassWorkList.empty());
|
||||
|
||||
// The renamer uses the Visited set to avoid infinite loops. Clear it now.
|
||||
Visited.clear();
|
||||
|
Loading…
x
Reference in New Issue
Block a user