From 94106f21e8a2eec4433fed3c966a556364dace8f Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Fri, 22 Jan 2021 23:25:01 -0800 Subject: [PATCH] [Analysis] Use llvm::append_range (NFC) --- lib/Analysis/BasicAliasAnalysis.cpp | 3 +-- lib/Analysis/DDG.cpp | 6 ++---- lib/Analysis/DependenceGraphBuilder.cpp | 3 +-- lib/Analysis/DevelopmentModeInlineAdvisor.cpp | 6 ++---- lib/Analysis/LoopCacheAnalysis.cpp | 3 +-- lib/Analysis/LoopNestAnalysis.cpp | 3 +-- lib/Analysis/MemoryDependenceAnalysis.cpp | 6 ++---- lib/Analysis/MustExecute.cpp | 3 +-- lib/Analysis/ValueTracking.cpp | 7 ++----- 9 files changed, 13 insertions(+), 27 deletions(-) diff --git a/lib/Analysis/BasicAliasAnalysis.cpp b/lib/Analysis/BasicAliasAnalysis.cpp index 3d638c1c36c..97d0cb63ef9 100644 --- a/lib/Analysis/BasicAliasAnalysis.cpp +++ b/lib/Analysis/BasicAliasAnalysis.cpp @@ -652,8 +652,7 @@ bool BasicAAResult::pointsToConstantMemory(const MemoryLocation &Loc, Visited.clear(); return AAResultBase::pointsToConstantMemory(Loc, AAQI, OrLocal); } - for (Value *IncValue : PN->incoming_values()) - Worklist.push_back(IncValue); + append_range(Worklist, PN->incoming_values()); continue; } diff --git a/lib/Analysis/DDG.cpp b/lib/Analysis/DDG.cpp index b2aa322454e..da5de75a038 100644 --- a/lib/Analysis/DDG.cpp +++ b/lib/Analysis/DDG.cpp @@ -190,8 +190,7 @@ DataDependenceGraph::DataDependenceGraph(Function &F, DependenceInfo &D) // directions. BasicBlockListType BBList; for (auto &SCC : make_range(scc_begin(&F), scc_end(&F))) - for (BasicBlock * BB : SCC) - BBList.push_back(BB); + append_range(BBList, SCC); std::reverse(BBList.begin(), BBList.end()); DDGBuilder(*this, D, BBList).populate(); } @@ -207,8 +206,7 @@ DataDependenceGraph::DataDependenceGraph(Loop &L, LoopInfo &LI, LoopBlocksDFS DFS(&L); DFS.perform(&LI); BasicBlockListType BBList; - for (BasicBlock *BB : make_range(DFS.beginRPO(), DFS.endRPO())) - BBList.push_back(BB); + append_range(BBList, make_range(DFS.beginRPO(), DFS.endRPO())); DDGBuilder(*this, D, BBList).populate(); } diff --git a/lib/Analysis/DependenceGraphBuilder.cpp b/lib/Analysis/DependenceGraphBuilder.cpp index 04a34472659..6b90db4bafe 100644 --- a/lib/Analysis/DependenceGraphBuilder.cpp +++ b/lib/Analysis/DependenceGraphBuilder.cpp @@ -498,8 +498,7 @@ void AbstractDependenceGraphBuilder::sortNodesTopologically() { size_t OldSize = Graph.Nodes.size(); Graph.Nodes.clear(); - for (NodeType *N : reverse(NodesInPO)) - Graph.Nodes.push_back(N); + append_range(Graph.Nodes, reverse(NodesInPO)); if (Graph.Nodes.size() != OldSize) assert(false && "Expected the number of nodes to stay the same after the sort"); diff --git a/lib/Analysis/DevelopmentModeInlineAdvisor.cpp b/lib/Analysis/DevelopmentModeInlineAdvisor.cpp index 551add6900b..e138e82c8b0 100644 --- a/lib/Analysis/DevelopmentModeInlineAdvisor.cpp +++ b/lib/Analysis/DevelopmentModeInlineAdvisor.cpp @@ -331,8 +331,7 @@ TrainingLogger::TrainingLogger(StringRef LogFileName, FT.push_back( {TensorSpec::createSpec(FeatureNameMap.at(I), {1}), None}); if (MUTR && MUTR->outputLoggedFeatureSpecs().size() > 1) - FT.insert(FT.end(), MUTR->outputLoggedFeatureSpecs().begin() + 1, - MUTR->outputLoggedFeatureSpecs().end()); + append_range(FT, drop_begin(MUTR->outputLoggedFeatureSpecs())); DefaultDecisionPos = FT.size(); FT.push_back( @@ -465,8 +464,7 @@ ModelUnderTrainingRunner::ModelUnderTrainingRunner(LLVMContext &Ctx, for (size_t I = 0; I < NumberOfFeatures; ++I) InputSpecs.push_back( TensorSpec::createSpec(TFFeedPrefix + FeatureNameMap[I], {1})); - InputSpecs.insert(InputSpecs.end(), TrainingOnlyFeatures.begin(), - TrainingOnlyFeatures.end()); + append_range(InputSpecs, TrainingOnlyFeatures); if (auto MaybeOutSpecs = loadOutputSpecs(Ctx, DecisionName, ModelPath, TFOutputSpecOverride)) OutputSpecs = std::move(*MaybeOutSpecs); diff --git a/lib/Analysis/LoopCacheAnalysis.cpp b/lib/Analysis/LoopCacheAnalysis.cpp index 6c490411d10..cf68596bfbc 100644 --- a/lib/Analysis/LoopCacheAnalysis.cpp +++ b/lib/Analysis/LoopCacheAnalysis.cpp @@ -505,8 +505,7 @@ CacheCost::getCacheCost(Loop &Root, LoopStandardAnalysisResults &AR, } LoopVectorTy Loops; - for (Loop *L : breadth_first(&Root)) - Loops.push_back(L); + append_range(Loops, breadth_first(&Root)); if (!getInnerMostLoop(Loops)) { LLVM_DEBUG(dbgs() << "Cannot compute cache cost of loop nest with more " diff --git a/lib/Analysis/LoopNestAnalysis.cpp b/lib/Analysis/LoopNestAnalysis.cpp index f3aa0d76742..7133abcc350 100644 --- a/lib/Analysis/LoopNestAnalysis.cpp +++ b/lib/Analysis/LoopNestAnalysis.cpp @@ -42,8 +42,7 @@ static bool checkLoopsStructure(const Loop &OuterLoop, const Loop &InnerLoop, LoopNest::LoopNest(Loop &Root, ScalarEvolution &SE) : MaxPerfectDepth(getMaxPerfectDepth(Root, SE)) { - for (Loop *L : breadth_first(&Root)) - Loops.push_back(L); + append_range(Loops, breadth_first(&Root)); } std::unique_ptr LoopNest::getLoopNest(Loop &Root, diff --git a/lib/Analysis/MemoryDependenceAnalysis.cpp b/lib/Analysis/MemoryDependenceAnalysis.cpp index 57fefc17a97..4e7a16efea4 100644 --- a/lib/Analysis/MemoryDependenceAnalysis.cpp +++ b/lib/Analysis/MemoryDependenceAnalysis.cpp @@ -752,8 +752,7 @@ MemoryDependenceResults::getNonLocalCallDependency(CallBase *QueryCall) { } else { // Seed DirtyBlocks with each of the preds of QueryInst's block. BasicBlock *QueryBB = QueryCall->getParent(); - for (BasicBlock *Pred : PredCache.get(QueryBB)) - DirtyBlocks.push_back(Pred); + append_range(DirtyBlocks, PredCache.get(QueryBB)); ++NumUncacheNonLocal; } @@ -838,8 +837,7 @@ MemoryDependenceResults::getNonLocalCallDependency(CallBase *QueryCall) { // If the block *is* completely transparent to the load, we need to check // the predecessors of this block. Add them to our worklist. - for (BasicBlock *Pred : PredCache.get(DirtyBB)) - DirtyBlocks.push_back(Pred); + append_range(DirtyBlocks, PredCache.get(DirtyBB)); } } diff --git a/lib/Analysis/MustExecute.cpp b/lib/Analysis/MustExecute.cpp index cb77a87bd1a..1e7626013ee 100644 --- a/lib/Analysis/MustExecute.cpp +++ b/lib/Analysis/MustExecute.cpp @@ -631,8 +631,7 @@ MustBeExecutedContextExplorer::findForwardJoinPoint(const BasicBlock *InitBB) { if (!TransfersExecution) return nullptr; - for (const BasicBlock *AdjacentBB : successors(ToBB)) - Worklist.push_back(AdjacentBB); + append_range(Worklist, successors(ToBB)); } } diff --git a/lib/Analysis/ValueTracking.cpp b/lib/Analysis/ValueTracking.cpp index ef3558ef136..672497d8cac 100644 --- a/lib/Analysis/ValueTracking.cpp +++ b/lib/Analysis/ValueTracking.cpp @@ -509,9 +509,7 @@ static bool isEphemeralValueOf(const Instruction *I, const Value *E) { if (V == I || isSafeToSpeculativelyExecute(V)) { EphValues.insert(V); if (const User *U = dyn_cast(V)) - for (User::const_op_iterator J = U->op_begin(), JE = U->op_end(); - J != JE; ++J) - WorkSet.push_back(*J); + append_range(WorkSet, U->operands()); } } } @@ -4209,8 +4207,7 @@ void llvm::getUnderlyingObjects(const Value *V, // underlying objects. if (!LI || !LI->isLoopHeader(PN->getParent()) || isSameUnderlyingObjectInLoop(PN, LI)) - for (Value *IncValue : PN->incoming_values()) - Worklist.push_back(IncValue); + append_range(Worklist, PN->incoming_values()); continue; }