From 3dd7bf5e76229bdcd1d0271bef80e12d8cee0067 Mon Sep 17 00:00:00 2001 From: Nico Rieck Date: Thu, 6 Aug 2015 19:10:45 +0000 Subject: [PATCH] Rename inst_range() to instructions() for consistency. NFC git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@244248 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/InstIterator.h | 18 ++++++++++-------- lib/Analysis/DivergenceAnalysis.cpp | 6 +++--- lib/Analysis/IPA/GlobalsModRef.cpp | 2 +- lib/Analysis/MemDepPrinter.cpp | 4 ++-- lib/Analysis/MemDerefPrinter.cpp | 2 +- lib/CodeGen/InterleavedAccessPass.cpp | 2 +- lib/Target/AArch64/AArch64PromoteConstant.cpp | 2 +- lib/Transforms/Instrumentation/SafeStack.cpp | 2 +- lib/Transforms/Scalar/ADCE.cpp | 4 ++-- lib/Transforms/Scalar/BDCE.cpp | 4 ++-- lib/Transforms/Scalar/Float2Int.cpp | 2 +- lib/Transforms/Scalar/PlaceSafepoints.cpp | 2 +- .../Scalar/RewriteStatepointsForGC.cpp | 4 ++-- 13 files changed, 28 insertions(+), 26 deletions(-) diff --git a/include/llvm/IR/InstIterator.h b/include/llvm/IR/InstIterator.h index f3ce6490fb6..40f66c8d98b 100644 --- a/include/llvm/IR/InstIterator.h +++ b/include/llvm/IR/InstIterator.h @@ -123,11 +123,13 @@ typedef InstIterator, Function::const_iterator, BasicBlock::const_iterator, const Instruction> const_inst_iterator; +typedef iterator_range inst_range; +typedef iterator_range const_inst_range; inline inst_iterator inst_begin(Function *F) { return inst_iterator(*F); } inline inst_iterator inst_end(Function *F) { return inst_iterator(*F, true); } -inline iterator_range inst_range(Function *F) { - return iterator_range(inst_begin(F), inst_end(F)); +inline inst_range instructions(Function *F) { + return inst_range(inst_begin(F), inst_end(F)); } inline const_inst_iterator inst_begin(const Function *F) { return const_inst_iterator(*F); @@ -135,13 +137,13 @@ inline const_inst_iterator inst_begin(const Function *F) { inline const_inst_iterator inst_end(const Function *F) { return const_inst_iterator(*F, true); } -inline iterator_range inst_range(const Function *F) { - return iterator_range(inst_begin(F), inst_end(F)); +inline const_inst_range instructions(const Function *F) { + return const_inst_range(inst_begin(F), inst_end(F)); } inline inst_iterator inst_begin(Function &F) { return inst_iterator(F); } inline inst_iterator inst_end(Function &F) { return inst_iterator(F, true); } -inline iterator_range inst_range(Function &F) { - return iterator_range(inst_begin(F), inst_end(F)); +inline inst_range instructions(Function &F) { + return inst_range(inst_begin(F), inst_end(F)); } inline const_inst_iterator inst_begin(const Function &F) { return const_inst_iterator(F); @@ -149,8 +151,8 @@ inline const_inst_iterator inst_begin(const Function &F) { inline const_inst_iterator inst_end(const Function &F) { return const_inst_iterator(F, true); } -inline iterator_range inst_range(const Function &F) { - return iterator_range(inst_begin(F), inst_end(F)); +inline const_inst_range instructions(const Function &F) { + return const_inst_range(inst_begin(F), inst_end(F)); } } // End llvm namespace diff --git a/lib/Analysis/DivergenceAnalysis.cpp b/lib/Analysis/DivergenceAnalysis.cpp index e5ee2959c15..f3fc7844020 100644 --- a/lib/Analysis/DivergenceAnalysis.cpp +++ b/lib/Analysis/DivergenceAnalysis.cpp @@ -159,7 +159,7 @@ private: void DivergencePropagator::populateWithSourcesOfDivergence() { Worklist.clear(); DV.clear(); - for (auto &I : inst_range(F)) { + for (auto &I : instructions(F)) { if (TTI.isSourceOfDivergence(&I)) { Worklist.push_back(&I); DV.insert(&I); @@ -329,8 +329,8 @@ void DivergenceAnalysis::print(raw_ostream &OS, const Module *) const { if (DivergentValues.count(&Arg)) OS << "DIVERGENT: " << Arg << "\n"; } - // Iterate instructions using inst_range to ensure a deterministic order. - for (auto &I : inst_range(F)) { + // Iterate instructions using instructions() to ensure a deterministic order. + for (auto &I : instructions(F)) { if (DivergentValues.count(&I)) OS << "DIVERGENT:" << I << "\n"; } diff --git a/lib/Analysis/IPA/GlobalsModRef.cpp b/lib/Analysis/IPA/GlobalsModRef.cpp index 4345f6b6813..f7b55c2cf8f 100644 --- a/lib/Analysis/IPA/GlobalsModRef.cpp +++ b/lib/Analysis/IPA/GlobalsModRef.cpp @@ -627,7 +627,7 @@ void GlobalsModRef::AnalyzeCallGraph(CallGraph &CG, Module &M) { for (auto *Node : SCC) { if (FI.getModRefInfo() == MRI_ModRef) break; // The mod/ref lattice saturates here. - for (Instruction &I : inst_range(Node->getFunction())) { + for (Instruction &I : instructions(Node->getFunction())) { if (FI.getModRefInfo() == MRI_ModRef) break; // The mod/ref lattice saturates here. diff --git a/lib/Analysis/MemDepPrinter.cpp b/lib/Analysis/MemDepPrinter.cpp index da3b829b6d3..4d7c9b040b5 100644 --- a/lib/Analysis/MemDepPrinter.cpp +++ b/lib/Analysis/MemDepPrinter.cpp @@ -96,7 +96,7 @@ bool MemDepPrinter::runOnFunction(Function &F) { // All this code uses non-const interfaces because MemDep is not // const-friendly, though nothing is actually modified. - for (auto &I : inst_range(F)) { + for (auto &I : instructions(F)) { Instruction *Inst = &I; if (!Inst->mayReadFromMemory() && !Inst->mayWriteToMemory()) @@ -135,7 +135,7 @@ bool MemDepPrinter::runOnFunction(Function &F) { } void MemDepPrinter::print(raw_ostream &OS, const Module *M) const { - for (const auto &I : inst_range(*F)) { + for (const auto &I : instructions(*F)) { const Instruction *Inst = &I; DepSetMap::const_iterator DI = Deps.find(Inst); diff --git a/lib/Analysis/MemDerefPrinter.cpp b/lib/Analysis/MemDerefPrinter.cpp index fa292a28ec8..ef2de41e120 100644 --- a/lib/Analysis/MemDerefPrinter.cpp +++ b/lib/Analysis/MemDerefPrinter.cpp @@ -51,7 +51,7 @@ FunctionPass *llvm::createMemDerefPrinter() { bool MemDerefPrinter::runOnFunction(Function &F) { const DataLayout &DL = F.getParent()->getDataLayout(); - for (auto &I: inst_range(F)) { + for (auto &I: instructions(F)) { if (LoadInst *LI = dyn_cast(&I)) { Value *PO = LI->getPointerOperand(); if (isDereferenceablePointer(PO, DL)) diff --git a/lib/CodeGen/InterleavedAccessPass.cpp b/lib/CodeGen/InterleavedAccessPass.cpp index 53c8adc05d7..baacf1ad9e1 100644 --- a/lib/CodeGen/InterleavedAccessPass.cpp +++ b/lib/CodeGen/InterleavedAccessPass.cpp @@ -271,7 +271,7 @@ bool InterleavedAccess::runOnFunction(Function &F) { SmallVector DeadInsts; bool Changed = false; - for (auto &I : inst_range(F)) { + for (auto &I : instructions(F)) { if (LoadInst *LI = dyn_cast(&I)) Changed |= lowerInterleavedLoad(LI, DeadInsts); diff --git a/lib/Target/AArch64/AArch64PromoteConstant.cpp b/lib/Target/AArch64/AArch64PromoteConstant.cpp index e1b93bf07c8..74b2e2fb88b 100644 --- a/lib/Target/AArch64/AArch64PromoteConstant.cpp +++ b/lib/Target/AArch64/AArch64PromoteConstant.cpp @@ -540,7 +540,7 @@ bool AArch64PromoteConstant::runOnFunction(Function &F) { bool LocalChange = false; SmallPtrSet AlreadyChecked; - for (Instruction &I : inst_range(&F)) { + for (Instruction &I : instructions(&F)) { // Traverse the operand, looking for constant vectors. Replace them by a // load of a global variable of constant vector type. for (Value *Op : I.operand_values()) { diff --git a/lib/Transforms/Instrumentation/SafeStack.cpp b/lib/Transforms/Instrumentation/SafeStack.cpp index 6b185a2b127..ac2775b6397 100644 --- a/lib/Transforms/Instrumentation/SafeStack.cpp +++ b/lib/Transforms/Instrumentation/SafeStack.cpp @@ -275,7 +275,7 @@ void SafeStack::findInsts(Function &F, SmallVectorImpl &DynamicAllocas, SmallVectorImpl &Returns, SmallVectorImpl &StackRestorePoints) { - for (Instruction &I : inst_range(&F)) { + for (Instruction &I : instructions(&F)) { if (auto AI = dyn_cast(&I)) { ++NumAllocas; diff --git a/lib/Transforms/Scalar/ADCE.cpp b/lib/Transforms/Scalar/ADCE.cpp index 824342ad7e3..96a0107ce18 100644 --- a/lib/Transforms/Scalar/ADCE.cpp +++ b/lib/Transforms/Scalar/ADCE.cpp @@ -57,7 +57,7 @@ bool ADCE::runOnFunction(Function& F) { SmallVector Worklist; // Collect the set of "root" instructions that are known live. - for (Instruction &I : inst_range(F)) { + for (Instruction &I : instructions(F)) { if (isa(I) || isa(I) || I.isEHPad() || I.mayHaveSideEffects()) { Alive.insert(&I); @@ -79,7 +79,7 @@ bool ADCE::runOnFunction(Function& F) { // which have no side effects and do not influence the control flow or return // value of the function, and may therefore be deleted safely. // NOTE: We reuse the Worklist vector here for memory efficiency. - for (Instruction &I : inst_range(F)) { + for (Instruction &I : instructions(F)) { if (!Alive.count(&I)) { Worklist.push_back(&I); I.dropAllReferences(); diff --git a/lib/Transforms/Scalar/BDCE.cpp b/lib/Transforms/Scalar/BDCE.cpp index 7252db0a6cd..909a86f740b 100644 --- a/lib/Transforms/Scalar/BDCE.cpp +++ b/lib/Transforms/Scalar/BDCE.cpp @@ -272,7 +272,7 @@ bool BDCE::runOnFunction(Function& F) { SmallPtrSet Visited; // Collect the set of "root" instructions that are known live. - for (Instruction &I : inst_range(F)) { + for (Instruction &I : instructions(F)) { if (!isAlwaysLive(&I)) continue; @@ -365,7 +365,7 @@ bool BDCE::runOnFunction(Function& F) { // which have no side effects and do not influence the control flow or return // value of the function, and may therefore be deleted safely. // NOTE: We reuse the Worklist vector here for memory efficiency. - for (Instruction &I : inst_range(F)) { + for (Instruction &I : instructions(F)) { // For live instructions that have all dead bits, first make them dead by // replacing all uses with something else. Then, if they don't need to // remain live (because they have side effects, etc.) we can remove them. diff --git a/lib/Transforms/Scalar/Float2Int.cpp b/lib/Transforms/Scalar/Float2Int.cpp index 8c1dce1c9fb..f52c32b9721 100644 --- a/lib/Transforms/Scalar/Float2Int.cpp +++ b/lib/Transforms/Scalar/Float2Int.cpp @@ -127,7 +127,7 @@ static Instruction::BinaryOps mapBinOpcode(unsigned Opcode) { // Find the roots - instructions that convert from the FP domain to // integer domain. void Float2Int::findRoots(Function &F, SmallPtrSet &Roots) { - for (auto &I : inst_range(F)) { + for (auto &I : instructions(F)) { switch (I.getOpcode()) { default: break; case Instruction::FPToUI: diff --git a/lib/Transforms/Scalar/PlaceSafepoints.cpp b/lib/Transforms/Scalar/PlaceSafepoints.cpp index 098e6eff15f..d6a48c783b4 100644 --- a/lib/Transforms/Scalar/PlaceSafepoints.cpp +++ b/lib/Transforms/Scalar/PlaceSafepoints.cpp @@ -466,7 +466,7 @@ static Instruction *findLocationForEntrySafepoint(Function &F, static void findCallSafepoints(Function &F, std::vector &Found /*rval*/) { assert(Found.empty() && "must be empty!"); - for (Instruction &I : inst_range(F)) { + for (Instruction &I : instructions(F)) { Instruction *inst = &I; if (isa(inst) || isa(inst)) { CallSite CS(inst); diff --git a/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp b/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp index 53975e254b1..6f70147c2a0 100644 --- a/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp +++ b/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp @@ -2310,7 +2310,7 @@ void RewriteStatepointsForGC::stripDereferenceabilityInfoFromBody(Function &F) { LLVMContext &Ctx = F.getContext(); MDBuilder Builder(Ctx); - for (Instruction &I : inst_range(F)) { + for (Instruction &I : instructions(F)) { if (const MDNode *MD = I.getMetadata(LLVMContext::MD_tbaa)) { assert(MD->getNumOperands() < 5 && "unrecognized metadata shape!"); bool IsImmutableTBAA = @@ -2384,7 +2384,7 @@ bool RewriteStatepointsForGC::runOnFunction(Function &F) { // when rewriting. We'll delete the unreachable ones in a moment. SmallVector ParsePointNeeded; bool HasUnreachableStatepoint = false; - for (Instruction &I : inst_range(F)) { + for (Instruction &I : instructions(F)) { // TODO: only the ones with the flag set! if (isStatepoint(I)) { if (DT.isReachableFromEntry(I.getParent())) -- 2.34.1