From c62c42b1e42abbf54213dde4a5fc071334d9240c Mon Sep 17 00:00:00 2001 From: Chandler Carruth Date: Thu, 16 Oct 2014 21:05:14 +0000 Subject: [PATCH] [SROA] More range-based cleanups to SROA, these brought to you by clang-modernize. I did have to clean up the variable types and whitespace a bit because the use of auto made the code much less readable here. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@219962 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Scalar/SROA.cpp | 37 +++++++++++----------------------- 1 file changed, 12 insertions(+), 25 deletions(-) diff --git a/lib/Transforms/Scalar/SROA.cpp b/lib/Transforms/Scalar/SROA.cpp index d6afb1795ca..a0f9a884e86 100644 --- a/lib/Transforms/Scalar/SROA.cpp +++ b/lib/Transforms/Scalar/SROA.cpp @@ -854,17 +854,12 @@ public: } void updateDebugInfo(Instruction *Inst) const override { - for (SmallVectorImpl::const_iterator I = DDIs.begin(), - E = DDIs.end(); I != E; ++I) { - DbgDeclareInst *DDI = *I; + for (DbgDeclareInst *DDI : DDIs) if (StoreInst *SI = dyn_cast(Inst)) ConvertDebugDeclareToDebugValue(DDI, SI, DIB); else if (LoadInst *LI = dyn_cast(Inst)) ConvertDebugDeclareToDebugValue(DDI, LI, DIB); - } - for (SmallVectorImpl::const_iterator I = DVIs.begin(), - E = DVIs.end(); I != E; ++I) { - DbgValueInst *DVI = *I; + for (DbgValueInst *DVI : DVIs) { Value *Arg = nullptr; if (StoreInst *SI = dyn_cast(Inst)) { // If an argument is zero extended then use argument directly. The ZExt @@ -3184,12 +3179,10 @@ bool SROA::rewritePartition(AllocaInst &AI, AllocaSlices &S, EndOffset, IsVectorPromotable, IsIntegerPromotable, PHIUsers, SelectUsers); bool Promotable = true; - for (ArrayRef::const_iterator SUI = SplitUses.begin(), - SUE = SplitUses.end(); - SUI != SUE; ++SUI) { + for (auto & SplitUse : SplitUses) { DEBUG(dbgs() << " rewriting split "); - DEBUG(S.printSlice(dbgs(), *SUI, "")); - Promotable &= Rewriter.visit(*SUI); + DEBUG(S.printSlice(dbgs(), SplitUse, "")); + Promotable &= Rewriter.visit(SplitUse); ++NumUses; } for (AllocaSlices::iterator I = B; I != E; ++I) { @@ -3232,14 +3225,10 @@ bool SROA::rewritePartition(AllocaInst &AI, AllocaSlices &S, // If we have either PHIs or Selects to speculate, add them to those // worklists and re-queue the new alloca so that we promote in on the // next iteration. - for (SmallPtrSetImpl::iterator I = PHIUsers.begin(), - E = PHIUsers.end(); - I != E; ++I) - SpeculatablePHIs.insert(*I); - for (SmallPtrSetImpl::iterator I = SelectUsers.begin(), - E = SelectUsers.end(); - I != E; ++I) - SpeculatableSelects.insert(*I); + for (PHINode *PHIUser : PHIUsers) + SpeculatablePHIs.insert(PHIUser); + for (SelectInst *SelectUser : SelectUsers) + SpeculatableSelects.insert(SelectUser); Worklist.insert(NewAI); } } else { @@ -3277,11 +3266,9 @@ removeFinishedSplitUses(SmallVectorImpl &SplitUses, // Recompute the max. While this is linear, so is remove_if. MaxSplitUseEndOffset = 0; - for (SmallVectorImpl::iterator - SUI = SplitUses.begin(), - SUE = SplitUses.end(); - SUI != SUE; ++SUI) - MaxSplitUseEndOffset = std::max((*SUI)->endOffset(), MaxSplitUseEndOffset); + for (AllocaSlices::iterator SplitUse : SplitUses) + MaxSplitUseEndOffset = + std::max(SplitUse->endOffset(), MaxSplitUseEndOffset); } /// \brief Walks the slices of an alloca and form partitions based on them, -- 2.34.1