summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2016-06-26 17:27:42 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2016-06-26 17:27:42 +0000
commit8d0d2b6abd3dc38f5d669c45dc0525252183d1a3 (patch)
tree4351d77f9a34493ae87f2c4d6dd1b27dff77e547
parent96caeda925f38961782b182a3dbaf5cee142be38 (diff)
Apply clang-tidy's modernize-loop-convert to lib/Analysis.
Only minor manual fixes. No functionality change intended. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273816 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/llvm/Analysis/Interval.h10
-rw-r--r--lib/Analysis/AliasAnalysisEvaluator.cpp39
-rw-r--r--lib/Analysis/AliasSetTracker.cpp19
-rw-r--r--lib/Analysis/CallGraph.cpp18
-rw-r--r--lib/Analysis/CallGraphSCCPass.cpp8
-rw-r--r--lib/Analysis/CostModel.cpp9
-rw-r--r--lib/Analysis/DependenceAnalysis.cpp16
-rw-r--r--lib/Analysis/IVUsers.cpp17
-rw-r--r--lib/Analysis/Interval.cpp15
-rw-r--r--lib/Analysis/IntervalPartition.cpp5
-rw-r--r--lib/Analysis/LazyValueInfo.cpp4
-rw-r--r--lib/Analysis/LoopInfo.cpp9
-rw-r--r--lib/Analysis/LoopPass.cpp4
-rw-r--r--lib/Analysis/MemDepPrinter.cpp14
-rw-r--r--lib/Analysis/MemoryBuiltins.cpp4
-rw-r--r--lib/Analysis/ModuleSummaryAnalysis.cpp11
-rw-r--r--lib/Analysis/RegionPrinter.cpp4
-rw-r--r--lib/Analysis/ScalarEvolution.cpp16
-rw-r--r--lib/Analysis/SparsePropagation.cpp4
19 files changed, 105 insertions, 121 deletions
diff --git a/include/llvm/Analysis/Interval.h b/include/llvm/Analysis/Interval.h
index 01eba3f16c0..a904753adaa 100644
--- a/include/llvm/Analysis/Interval.h
+++ b/include/llvm/Analysis/Interval.h
@@ -67,8 +67,9 @@ public:
/// contains - Find out if a basic block is in this interval
inline bool contains(BasicBlock *BB) const {
- for (unsigned i = 0; i < Nodes.size(); ++i)
- if (Nodes[i] == BB) return true;
+ for (BasicBlock *Node : Nodes)
+ if (Node == BB)
+ return true;
return false;
// I don't want the dependency on <algorithm>
//return find(Nodes.begin(), Nodes.end(), BB) != Nodes.end();
@@ -76,8 +77,9 @@ public:
/// isSuccessor - find out if a basic block is a successor of this Interval
inline bool isSuccessor(BasicBlock *BB) const {
- for (unsigned i = 0; i < Successors.size(); ++i)
- if (Successors[i] == BB) return true;
+ for (BasicBlock *Successor : Successors)
+ if (Successor == BB)
+ return true;
return false;
// I don't want the dependency on <algorithm>
//return find(Successors.begin(), Successors.end(), BB) != Successors.end();
diff --git a/lib/Analysis/AliasAnalysisEvaluator.cpp b/lib/Analysis/AliasAnalysisEvaluator.cpp
index 74216aab069..baf8f3f881d 100644
--- a/lib/Analysis/AliasAnalysisEvaluator.cpp
+++ b/lib/Analysis/AliasAnalysisEvaluator.cpp
@@ -175,29 +175,27 @@ void AAEvaluator::runInternal(Function &F, AAResults &AA) {
if (EvalAAMD) {
// iterate over all pairs of load, store
- for (SetVector<Value *>::iterator I1 = Loads.begin(), E = Loads.end();
- I1 != E; ++I1) {
- for (SetVector<Value *>::iterator I2 = Stores.begin(), E2 = Stores.end();
- I2 != E2; ++I2) {
- switch (AA.alias(MemoryLocation::get(cast<LoadInst>(*I1)),
- MemoryLocation::get(cast<StoreInst>(*I2)))) {
+ for (Value *Load : Loads) {
+ for (Value *Store : Stores) {
+ switch (AA.alias(MemoryLocation::get(cast<LoadInst>(Load)),
+ MemoryLocation::get(cast<StoreInst>(Store)))) {
case NoAlias:
- PrintLoadStoreResults("NoAlias", PrintNoAlias, *I1, *I2,
+ PrintLoadStoreResults("NoAlias", PrintNoAlias, Load, Store,
F.getParent());
++NoAliasCount;
break;
case MayAlias:
- PrintLoadStoreResults("MayAlias", PrintMayAlias, *I1, *I2,
+ PrintLoadStoreResults("MayAlias", PrintMayAlias, Load, Store,
F.getParent());
++MayAliasCount;
break;
case PartialAlias:
- PrintLoadStoreResults("PartialAlias", PrintPartialAlias, *I1, *I2,
+ PrintLoadStoreResults("PartialAlias", PrintPartialAlias, Load, Store,
F.getParent());
++PartialAliasCount;
break;
case MustAlias:
- PrintLoadStoreResults("MustAlias", PrintMustAlias, *I1, *I2,
+ PrintLoadStoreResults("MustAlias", PrintMustAlias, Load, Store,
F.getParent());
++MustAliasCount;
break;
@@ -237,30 +235,31 @@ void AAEvaluator::runInternal(Function &F, AAResults &AA) {
}
// Mod/ref alias analysis: compare all pairs of calls and values
- for (auto C = CallSites.begin(), Ce = CallSites.end(); C != Ce; ++C) {
- Instruction *I = C->getInstruction();
+ for (CallSite C : CallSites) {
+ Instruction *I = C.getInstruction();
- for (SetVector<Value *>::iterator V = Pointers.begin(), Ve = Pointers.end();
- V != Ve; ++V) {
+ for (auto Pointer : Pointers) {
uint64_t Size = MemoryLocation::UnknownSize;
- Type *ElTy = cast<PointerType>((*V)->getType())->getElementType();
+ Type *ElTy = cast<PointerType>(Pointer->getType())->getElementType();
if (ElTy->isSized()) Size = DL.getTypeStoreSize(ElTy);
- switch (AA.getModRefInfo(*C, *V, Size)) {
+ switch (AA.getModRefInfo(C, Pointer, Size)) {
case MRI_NoModRef:
- PrintModRefResults("NoModRef", PrintNoModRef, I, *V, F.getParent());
+ PrintModRefResults("NoModRef", PrintNoModRef, I, Pointer,
+ F.getParent());
++NoModRefCount;
break;
case MRI_Mod:
- PrintModRefResults("Just Mod", PrintMod, I, *V, F.getParent());
+ PrintModRefResults("Just Mod", PrintMod, I, Pointer, F.getParent());
++ModCount;
break;
case MRI_Ref:
- PrintModRefResults("Just Ref", PrintRef, I, *V, F.getParent());
+ PrintModRefResults("Just Ref", PrintRef, I, Pointer, F.getParent());
++RefCount;
break;
case MRI_ModRef:
- PrintModRefResults("Both ModRef", PrintModRef, I, *V, F.getParent());
+ PrintModRefResults("Both ModRef", PrintModRef, I, Pointer,
+ F.getParent());
++ModRefCount;
break;
}
diff --git a/lib/Analysis/AliasSetTracker.cpp b/lib/Analysis/AliasSetTracker.cpp
index 4cf7641dd77..d349ac51a9b 100644
--- a/lib/Analysis/AliasSetTracker.cpp
+++ b/lib/Analysis/AliasSetTracker.cpp
@@ -234,15 +234,15 @@ AliasSet *AliasSetTracker::mergeAliasSetsForPointer(const Value *Ptr,
/// alias sets.
bool AliasSetTracker::containsPointer(const Value *Ptr, uint64_t Size,
const AAMDNodes &AAInfo) const {
- for (const_iterator I = begin(), E = end(); I != E; ++I)
- if (!I->Forward && I->aliasesPointer(Ptr, Size, AAInfo, AA))
+ for (const AliasSet &AS : *this)
+ if (!AS.Forward && AS.aliasesPointer(Ptr, Size, AAInfo, AA))
return true;
return false;
}
bool AliasSetTracker::containsUnknown(const Instruction *Inst) const {
- for (const_iterator I = begin(), E = end(); I != E; ++I)
- if (!I->Forward && I->aliasesUnknownInst(Inst, AA))
+ for (const AliasSet &AS : *this)
+ if (!AS.Forward && AS.aliasesUnknownInst(Inst, AA))
return true;
return false;
}
@@ -409,10 +409,9 @@ void AliasSetTracker::add(const AliasSetTracker &AST) {
// Loop over all of the alias sets in AST, adding the pointers contained
// therein into the current alias sets. This can cause alias sets to be
// merged together in the current AST.
- for (const_iterator I = AST.begin(), E = AST.end(); I != E; ++I) {
- if (I->Forward) continue; // Ignore forwarding alias sets
-
- AliasSet &AS = const_cast<AliasSet&>(*I);
+ for (const AliasSet &AS : AST) {
+ if (AS.Forward)
+ continue; // Ignore forwarding alias sets
// If there are any call sites in the alias set, add them to this AST.
for (unsigned i = 0, e = AS.UnknownInsts.size(); i != e; ++i)
@@ -648,8 +647,8 @@ void AliasSet::print(raw_ostream &OS) const {
void AliasSetTracker::print(raw_ostream &OS) const {
OS << "Alias Set Tracker: " << AliasSets.size() << " alias sets for "
<< PointerMap.size() << " pointer values.\n";
- for (const_iterator I = begin(), E = end(); I != E; ++I)
- I->print(OS);
+ for (const AliasSet &AS : *this)
+ AS.print(OS);
OS << "\n";
}
diff --git a/lib/Analysis/CallGraph.cpp b/lib/Analysis/CallGraph.cpp
index 7d9252f746d..39cb86d2ccb 100644
--- a/lib/Analysis/CallGraph.cpp
+++ b/lib/Analysis/CallGraph.cpp
@@ -80,11 +80,9 @@ void CallGraph::addToCallGraph(Function *F) {
Node->addCalledFunction(CallSite(), CallsExternalNode.get());
// Look for calls by this function.
- for (Function::iterator BB = F->begin(), BBE = F->end(); BB != BBE; ++BB)
- for (BasicBlock::iterator II = BB->begin(), IE = BB->end(); II != IE;
- ++II) {
- CallSite CS(cast<Value>(II));
- if (CS) {
+ for (BasicBlock &BB : *F)
+ for (Instruction &I : BB) {
+ if (auto CS = CallSite(&I)) {
const Function *Callee = CS.getCalledFunction();
if (!Callee || !Intrinsic::isLeaf(Callee->getIntrinsicID()))
// Indirect calls of intrinsics are not allowed so no need to check.
@@ -111,8 +109,8 @@ void CallGraph::print(raw_ostream &OS) const {
SmallVector<CallGraphNode *, 16> Nodes;
Nodes.reserve(FunctionMap.size());
- for (auto I = begin(), E = end(); I != E; ++I)
- Nodes.push_back(I->second.get());
+ for (const auto &I : *this)
+ Nodes.push_back(I.second.get());
std::sort(Nodes.begin(), Nodes.end(),
[](CallGraphNode *LHS, CallGraphNode *RHS) {
@@ -186,9 +184,9 @@ void CallGraphNode::print(raw_ostream &OS) const {
OS << "<<" << this << ">> #uses=" << getNumReferences() << '\n';
- for (const_iterator I = begin(), E = end(); I != E; ++I) {
- OS << " CS<" << I->first << "> calls ";
- if (Function *FI = I->second->getFunction())
+ for (const auto &I : *this) {
+ OS << " CS<" << I.first << "> calls ";
+ if (Function *FI = I.second->getFunction())
OS << "function '" << FI->getName() <<"'\n";
else
OS << "external node\n";
diff --git a/lib/Analysis/CallGraphSCCPass.cpp b/lib/Analysis/CallGraphSCCPass.cpp
index 29c4ba980cd..69d76735478 100644
--- a/lib/Analysis/CallGraphSCCPass.cpp
+++ b/lib/Analysis/CallGraphSCCPass.cpp
@@ -261,10 +261,10 @@ bool CGPassManager::RefreshCallGraph(CallGraphSCC &CurSCC,
// Loop over all of the instructions in the function, getting the callsites.
// Keep track of the number of direct/indirect calls added.
unsigned NumDirectAdded = 0, NumIndirectAdded = 0;
-
- for (Function::iterator BB = F->begin(), E = F->end(); BB != E; ++BB)
- for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ++I) {
- CallSite CS(cast<Value>(I));
+
+ for (BasicBlock &BB : *F)
+ for (Instruction &I : BB) {
+ CallSite CS(&I);
if (!CS) continue;
Function *Callee = CS.getCalledFunction();
if (Callee && Callee->isIntrinsic()) continue;
diff --git a/lib/Analysis/CostModel.cpp b/lib/Analysis/CostModel.cpp
index 36a1db664e1..68a4bea96ba 100644
--- a/lib/Analysis/CostModel.cpp
+++ b/lib/Analysis/CostModel.cpp
@@ -522,16 +522,15 @@ void CostModelAnalysis::print(raw_ostream &OS, const Module*) const {
if (!F)
return;
- for (Function::iterator B = F->begin(), BE = F->end(); B != BE; ++B) {
- for (BasicBlock::iterator it = B->begin(), e = B->end(); it != e; ++it) {
- Instruction *Inst = &*it;
- unsigned Cost = getInstructionCost(Inst);
+ for (BasicBlock &B : *F) {
+ for (Instruction &Inst : B) {
+ unsigned Cost = getInstructionCost(&Inst);
if (Cost != (unsigned)-1)
OS << "Cost Model: Found an estimated cost of " << Cost;
else
OS << "Cost Model: Unknown cost";
- OS << " for instruction: "<< *Inst << "\n";
+ OS << " for instruction: " << Inst << "\n";
}
}
}
diff --git a/lib/Analysis/DependenceAnalysis.cpp b/lib/Analysis/DependenceAnalysis.cpp
index 796c872f014..eb4d925fea7 100644
--- a/lib/Analysis/DependenceAnalysis.cpp
+++ b/lib/Analysis/DependenceAnalysis.cpp
@@ -781,9 +781,9 @@ void DependenceInfo::unifySubscriptType(ArrayRef<Subscript *> Pairs) {
// Go through each pair and find the widest bit to which we need
// to extend all of them.
- for (unsigned i = 0; i < Pairs.size(); i++) {
- const SCEV *Src = Pairs[i]->Src;
- const SCEV *Dst = Pairs[i]->Dst;
+ for (Subscript *Pair : Pairs) {
+ const SCEV *Src = Pair->Src;
+ const SCEV *Dst = Pair->Dst;
IntegerType *SrcTy = dyn_cast<IntegerType>(Src->getType());
IntegerType *DstTy = dyn_cast<IntegerType>(Dst->getType());
if (SrcTy == nullptr || DstTy == nullptr) {
@@ -806,9 +806,9 @@ void DependenceInfo::unifySubscriptType(ArrayRef<Subscript *> Pairs) {
assert(widestWidthSeen > 0);
// Now extend each pair to the widest seen.
- for (unsigned i = 0; i < Pairs.size(); i++) {
- const SCEV *Src = Pairs[i]->Src;
- const SCEV *Dst = Pairs[i]->Dst;
+ for (Subscript *Pair : Pairs) {
+ const SCEV *Src = Pair->Src;
+ const SCEV *Dst = Pair->Dst;
IntegerType *SrcTy = dyn_cast<IntegerType>(Src->getType());
IntegerType *DstTy = dyn_cast<IntegerType>(Dst->getType());
if (SrcTy == nullptr || DstTy == nullptr) {
@@ -819,10 +819,10 @@ void DependenceInfo::unifySubscriptType(ArrayRef<Subscript *> Pairs) {
}
if (SrcTy->getBitWidth() < widestWidthSeen)
// Sign-extend Src to widestType
- Pairs[i]->Src = SE->getSignExtendExpr(Src, widestType);
+ Pair->Src = SE->getSignExtendExpr(Src, widestType);
if (DstTy->getBitWidth() < widestWidthSeen) {
// Sign-extend Dst to widestType
- Pairs[i]->Dst = SE->getSignExtendExpr(Dst, widestType);
+ Pair->Dst = SE->getSignExtendExpr(Dst, widestType);
}
}
}
diff --git a/lib/Analysis/IVUsers.cpp b/lib/Analysis/IVUsers.cpp
index 2cd67f0a789..e974cb9e711 100644
--- a/lib/Analysis/IVUsers.cpp
+++ b/lib/Analysis/IVUsers.cpp
@@ -290,21 +290,18 @@ void IVUsers::print(raw_ostream &OS, const Module *M) const {
}
OS << ":\n";
- for (ilist<IVStrideUse>::const_iterator UI = IVUses.begin(),
- E = IVUses.end(); UI != E; ++UI) {
+ for (const IVStrideUse &IVUse : IVUses) {
OS << " ";
- UI->getOperandValToReplace()->printAsOperand(OS, false);
- OS << " = " << *getReplacementExpr(*UI);
- for (PostIncLoopSet::const_iterator
- I = UI->PostIncLoops.begin(),
- E = UI->PostIncLoops.end(); I != E; ++I) {
+ IVUse.getOperandValToReplace()->printAsOperand(OS, false);
+ OS << " = " << *getReplacementExpr(IVUse);
+ for (auto PostIncLoop : IVUse.PostIncLoops) {
OS << " (post-inc with loop ";
- (*I)->getHeader()->printAsOperand(OS, false);
+ PostIncLoop->getHeader()->printAsOperand(OS, false);
OS << ")";
}
OS << " in ";
- if (UI->getUser())
- UI->getUser()->print(OS);
+ if (IVUse.getUser())
+ IVUse.getUser()->print(OS);
else
OS << "Printing <null> User";
OS << '\n';
diff --git a/lib/Analysis/Interval.cpp b/lib/Analysis/Interval.cpp
index e3e785ffc45..6c10d73bcb4 100644
--- a/lib/Analysis/Interval.cpp
+++ b/lib/Analysis/Interval.cpp
@@ -42,17 +42,14 @@ void Interval::print(raw_ostream &OS) const {
<< "Interval Contents:\n";
// Print out all of the basic blocks in the interval...
- for (std::vector<BasicBlock*>::const_iterator I = Nodes.begin(),
- E = Nodes.end(); I != E; ++I)
- OS << **I << "\n";
+ for (const BasicBlock *Node : Nodes)
+ OS << *Node << "\n";
OS << "Interval Predecessors:\n";
- for (std::vector<BasicBlock*>::const_iterator I = Predecessors.begin(),
- E = Predecessors.end(); I != E; ++I)
- OS << **I << "\n";
+ for (const BasicBlock *Predecessor : Predecessors)
+ OS << *Predecessor << "\n";
OS << "Interval Successors:\n";
- for (std::vector<BasicBlock*>::const_iterator I = Successors.begin(),
- E = Successors.end(); I != E; ++I)
- OS << **I << "\n";
+ for (const BasicBlock *Successor : Successors)
+ OS << *Successor << "\n";
}
diff --git a/lib/Analysis/IntervalPartition.cpp b/lib/Analysis/IntervalPartition.cpp
index a0583e86d18..a4e56e0694b 100644
--- a/lib/Analysis/IntervalPartition.cpp
+++ b/lib/Analysis/IntervalPartition.cpp
@@ -57,9 +57,8 @@ void IntervalPartition::addIntervalToPartition(Interval *I) {
//
void IntervalPartition::updatePredecessors(Interval *Int) {
BasicBlock *Header = Int->getHeaderNode();
- for (Interval::succ_iterator I = Int->Successors.begin(),
- E = Int->Successors.end(); I != E; ++I)
- getBlockInterval(*I)->Predecessors.push_back(Header);
+ for (BasicBlock *Successor : Int->Successors)
+ getBlockInterval(Successor)->Predecessors.push_back(Header);
}
// IntervalPartition ctor - Build the first level interval partition for the
diff --git a/lib/Analysis/LazyValueInfo.cpp b/lib/Analysis/LazyValueInfo.cpp
index 62568f29879..fe760185835 100644
--- a/lib/Analysis/LazyValueInfo.cpp
+++ b/lib/Analysis/LazyValueInfo.cpp
@@ -563,8 +563,8 @@ void LazyValueInfoCache::eraseBlock(BasicBlock *BB) {
if (ODI != OverDefinedCache.end())
OverDefinedCache.erase(ODI);
- for (auto I = ValueCache.begin(), E = ValueCache.end(); I != E; ++I)
- I->second.erase(BB);
+ for (auto &I : ValueCache)
+ I.second.erase(BB);
}
void LazyValueInfoCache::solve() {
diff --git a/lib/Analysis/LoopInfo.cpp b/lib/Analysis/LoopInfo.cpp
index 2628d651d0c..30f7ef39242 100644
--- a/lib/Analysis/LoopInfo.cpp
+++ b/lib/Analysis/LoopInfo.cpp
@@ -434,17 +434,16 @@ void UnloopUpdater::updateBlockParents() {
// Perform a post order CFG traversal of all blocks within this loop,
// propagating the nearest loop from sucessors to predecessors.
LoopBlocksTraversal Traversal(DFS, LI);
- for (LoopBlocksTraversal::POTIterator POI = Traversal.begin(),
- POE = Traversal.end(); POI != POE; ++POI) {
+ for (BasicBlock *POI : Traversal) {
- Loop *L = LI->getLoopFor(*POI);
- Loop *NL = getNearestLoop(*POI, L);
+ Loop *L = LI->getLoopFor(POI);
+ Loop *NL = getNearestLoop(POI, L);
if (NL != L) {
// For reducible loops, NL is now an ancestor of Unloop.
assert((NL != &Unloop && (!NL || NL->contains(&Unloop))) &&
"uninitialized successor");
- LI->changeLoopFor(*POI, NL);
+ LI->changeLoopFor(POI, NL);
}
else {
// Or the current block is part of a subloop, in which case its parent
diff --git a/lib/Analysis/LoopPass.cpp b/lib/Analysis/LoopPass.cpp
index 84a5611e34d..222345c9a98 100644
--- a/lib/Analysis/LoopPass.cpp
+++ b/lib/Analysis/LoopPass.cpp
@@ -109,9 +109,7 @@ void LPPassManager::cloneBasicBlockSimpleAnalysis(BasicBlock *From,
/// deleteSimpleAnalysisValue - Invoke deleteAnalysisValue hook for all passes.
void LPPassManager::deleteSimpleAnalysisValue(Value *V, Loop *L) {
if (BasicBlock *BB = dyn_cast<BasicBlock>(V)) {
- for (BasicBlock::iterator BI = BB->begin(), BE = BB->end(); BI != BE;
- ++BI) {
- Instruction &I = *BI;
+ for (Instruction &I : *BB) {
deleteSimpleAnalysisValue(&I, L);
}
}
diff --git a/lib/Analysis/MemDepPrinter.cpp b/lib/Analysis/MemDepPrinter.cpp
index 9116b825501..e7a85ae06e6 100644
--- a/lib/Analysis/MemDepPrinter.cpp
+++ b/lib/Analysis/MemDepPrinter.cpp
@@ -111,10 +111,9 @@ bool MemDepPrinter::runOnFunction(Function &F) {
MDA.getNonLocalCallDependency(CS);
DepSet &InstDeps = Deps[Inst];
- for (MemoryDependenceResults::NonLocalDepInfo::const_iterator
- I = NLDI.begin(), E = NLDI.end(); I != E; ++I) {
- const MemDepResult &Res = I->getResult();
- InstDeps.insert(std::make_pair(getInstTypePair(Res), I->getBB()));
+ for (const NonLocalDepEntry &I : NLDI) {
+ const MemDepResult &Res = I.getResult();
+ InstDeps.insert(std::make_pair(getInstTypePair(Res), I.getBB()));
}
} else {
SmallVector<NonLocalDepResult, 4> NLDI;
@@ -123,10 +122,9 @@ bool MemDepPrinter::runOnFunction(Function &F) {
MDA.getNonLocalPointerDependency(Inst, NLDI);
DepSet &InstDeps = Deps[Inst];
- for (SmallVectorImpl<NonLocalDepResult>::const_iterator
- I = NLDI.begin(), E = NLDI.end(); I != E; ++I) {
- const MemDepResult &Res = I->getResult();
- InstDeps.insert(std::make_pair(getInstTypePair(Res), I->getBB()));
+ for (const NonLocalDepResult &I : NLDI) {
+ const MemDepResult &Res = I.getResult();
+ InstDeps.insert(std::make_pair(getInstTypePair(Res), I.getBB()));
}
}
}
diff --git a/lib/Analysis/MemoryBuiltins.cpp b/lib/Analysis/MemoryBuiltins.cpp
index e0497cbc801..d16b5f86af6 100644
--- a/lib/Analysis/MemoryBuiltins.cpp
+++ b/lib/Analysis/MemoryBuiltins.cpp
@@ -661,8 +661,8 @@ SizeOffsetEvalType ObjectSizeOffsetEvaluator::compute(Value *V) {
// erase everything that was computed in this iteration from the cache, so
// that no dangling references are left behind. We could be a bit smarter if
// we kept a dependency graph. It's probably not worth the complexity.
- for (PtrSetTy::iterator I=SeenVals.begin(), E=SeenVals.end(); I != E; ++I) {
- CacheMapTy::iterator CacheIt = CacheMap.find(*I);
+ for (const Value *SeenVal : SeenVals) {
+ CacheMapTy::iterator CacheIt = CacheMap.find(SeenVal);
// non-computable results can be safely cached
if (CacheIt != CacheMap.end() && anyKnown(CacheIt->second))
CacheMap.erase(CacheIt);
diff --git a/lib/Analysis/ModuleSummaryAnalysis.cpp b/lib/Analysis/ModuleSummaryAnalysis.cpp
index 7c57c0592e6..ff41581e599 100644
--- a/lib/Analysis/ModuleSummaryAnalysis.cpp
+++ b/lib/Analysis/ModuleSummaryAnalysis.cpp
@@ -76,24 +76,23 @@ void ModuleSummaryIndexBuilder::computeFunctionSummary(
DenseSet<const Value *> RefEdges;
SmallPtrSet<const User *, 8> Visited;
- for (Function::const_iterator BB = F.begin(), E = F.end(); BB != E; ++BB)
- for (BasicBlock::const_iterator I = BB->begin(), E = BB->end(); I != E;
- ++I) {
+ for (const BasicBlock &BB : F)
+ for (const Instruction &I : BB) {
if (!isa<DbgInfoIntrinsic>(I))
++NumInsts;
- if (auto CS = ImmutableCallSite(&*I)) {
+ if (auto CS = ImmutableCallSite(&I)) {
auto *CalledFunction = CS.getCalledFunction();
if (CalledFunction && CalledFunction->hasName() &&
!CalledFunction->isIntrinsic()) {
- auto ScaledCount = BFI ? BFI->getBlockProfileCount(&*BB) : None;
+ auto ScaledCount = BFI ? BFI->getBlockProfileCount(&BB) : None;
auto *CalleeId =
M->getValueSymbolTable().lookup(CalledFunction->getName());
CallGraphEdges[CalleeId] +=
(ScaledCount ? ScaledCount.getValue() : 0);
}
}
- findRefEdges(&*I, RefEdges, Visited);
+ findRefEdges(&I, RefEdges, Visited);
}
GlobalValueSummary::GVFlags Flags(F);
diff --git a/lib/Analysis/RegionPrinter.cpp b/lib/Analysis/RegionPrinter.cpp
index acb218d5fea..30a4e011060 100644
--- a/lib/Analysis/RegionPrinter.cpp
+++ b/lib/Analysis/RegionPrinter.cpp
@@ -117,8 +117,8 @@ struct DOTGraphTraits<RegionInfo *> : public DOTGraphTraits<RegionNode *> {
<< ((R.getDepth() * 2 % 12) + 2) << "\n";
}
- for (Region::const_iterator RI = R.begin(), RE = R.end(); RI != RE; ++RI)
- printRegionCluster(**RI, GW, depth + 1);
+ for (const auto &RI : R)
+ printRegionCluster(*RI, GW, depth + 1);
const RegionInfo &RI = *static_cast<const RegionInfo*>(R.getRegionInfo());
diff --git a/lib/Analysis/ScalarEvolution.cpp b/lib/Analysis/ScalarEvolution.cpp
index c2e1825c027..40274f77c6f 100644
--- a/lib/Analysis/ScalarEvolution.cpp
+++ b/lib/Analysis/ScalarEvolution.cpp
@@ -5485,8 +5485,8 @@ void ScalarEvolution::forgetLoop(const Loop *L) {
// Forget all contained loops too, to avoid dangling entries in the
// ValuesAtScopes map.
- for (Loop::iterator I = L->begin(), E = L->end(); I != E; ++I)
- forgetLoop(*I);
+ for (Loop *I : *L)
+ forgetLoop(I);
LoopHasNoAbnormalExits.erase(L);
}
@@ -9534,8 +9534,8 @@ bool ScalarEvolution::hasLoopInvariantBackedgeTakenCount(const Loop *L) {
static void PrintLoopInfo(raw_ostream &OS, ScalarEvolution *SE,
const Loop *L) {
// Print all inner loops first
- for (Loop::iterator I = L->begin(), E = L->end(); I != E; ++I)
- PrintLoopInfo(OS, SE, *I);
+ for (Loop *I : *L)
+ PrintLoopInfo(OS, SE, I);
OS << "Loop ";
L->getHeader()->printAsOperand(OS, /*PrintType=*/false);
@@ -9676,8 +9676,8 @@ void ScalarEvolution::print(raw_ostream &OS) const {
OS << "Determining loop execution counts for: ";
F.printAsOperand(OS, /*PrintType=*/false);
OS << "\n";
- for (LoopInfo::iterator I = LI.begin(), E = LI.end(); I != E; ++I)
- PrintLoopInfo(OS, &SE, *I);
+ for (Loop *I : LI)
+ PrintLoopInfo(OS, &SE, I);
}
ScalarEvolution::LoopDisposition
@@ -10429,8 +10429,8 @@ PredicatedScalarEvolution::PredicatedScalarEvolution(
const PredicatedScalarEvolution &Init)
: RewriteMap(Init.RewriteMap), SE(Init.SE), L(Init.L), Preds(Init.Preds),
Generation(Init.Generation), BackedgeCount(Init.BackedgeCount) {
- for (auto I = Init.FlagsMap.begin(), E = Init.FlagsMap.end(); I != E; ++I)
- FlagsMap.insert(*I);
+ for (const auto &I : Init.FlagsMap)
+ FlagsMap.insert(I);
}
void PredicatedScalarEvolution::print(raw_ostream &OS, unsigned Depth) const {
diff --git a/lib/Analysis/SparsePropagation.cpp b/lib/Analysis/SparsePropagation.cpp
index f5a927b8052..79dc84e2553 100644
--- a/lib/Analysis/SparsePropagation.cpp
+++ b/lib/Analysis/SparsePropagation.cpp
@@ -320,8 +320,8 @@ void SparseSolver::Solve(Function &F) {
// Notify all instructions in this basic block that they are newly
// executable.
- for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ++I)
- visitInst(*I);
+ for (Instruction &I : *BB)
+ visitInst(I);
}
}
}