From 02fe4248a201275d1dc517a8a592cc344ff94b89 Mon Sep 17 00:00:00 2001 From: Chad Rosier Date: Thu, 10 Dec 2015 17:27:18 +0000 Subject: [PATCH] [DeadStoreElimination] Use range-based loops. NFC. llvm-svn: 255265 --- .../Transforms/Scalar/DeadStoreElimination.cpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp index d8b08c41d0a8..ba7e98f17b85 100644 --- a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp +++ b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp @@ -678,8 +678,7 @@ bool DSE::runOnBasicBlock(BasicBlock &BB) { static void findSafePreds(SmallVectorImpl &PredBlocks, SmallSetVector &SafeBlocks, BasicBlock *BB, DominatorTree *DT) { - for (auto I = pred_begin(BB), E = pred_end(BB); I != E; ++I) { - BasicBlock *Pred = *I; + for (auto *Pred : predecessors(BB)) { if (Pred == BB) continue; // The second check below prevents adding blocks that form a cycle with BB @@ -689,8 +688,7 @@ static void findSafePreds(SmallVectorImpl &PredBlocks, continue; bool PredIsSafe = true; - for (auto II = succ_begin(Pred), EE = succ_end(Pred); II != EE; ++II) { - BasicBlock *Succ = *II; + for (auto *Succ : successors(Pred)) { if (Succ == BB || Succ == Pred) // shortcut, BB should be in SafeBlocks continue; if (!SafeBlocks.count(Succ)) { @@ -710,8 +708,7 @@ static bool underlyingObjectsDoNotAlias(StoreInst *SI, LoadInst *LI, SmallVector Pointers; GetUnderlyingObjects(LI->getPointerOperand(), Pointers, DL); - for (auto I = Pointers.begin(), E = Pointers.end(); I != E; ++I) { - Value *BObj = *I; + for (auto *BObj : Pointers) { if (!AA.isNoAlias(AObj, DL.getTypeStoreSize(AObj->getType()), BObj, DL.getTypeStoreSize(BObj->getType()))) return false; @@ -858,10 +855,10 @@ bool DSE::MemoryIsNotModifiedBetween(Instruction *FirstI, if (B != FirstBB) { assert(B != &FirstBB->getParent()->getEntryBlock() && "Should not hit the entry block because SI must be dominated by LI"); - for (auto PredI = pred_begin(B), PE = pred_end(B); PredI != PE; ++PredI) { - if (!Visited.insert(*PredI).second) + for (auto *PredI : predecessors(B)) { + if (!Visited.insert(PredI).second) continue; - WorkList.push_back(*PredI); + WorkList.push_back(PredI); } } }