From 7505b7045f7cc887efffee7a312084bd248a1f1e Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Sat, 13 Nov 2021 21:43:28 -0800 Subject: [PATCH] [llvm] Use GetElementPtrInst::indices (NFC) --- llvm/lib/Target/Hexagon/HexagonCommonGEP.cpp | 5 ++--- llvm/lib/Transforms/IPO/AttributorAttributes.cpp | 2 +- llvm/lib/Transforms/Scalar/GVN.cpp | 6 ++---- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/llvm/lib/Target/Hexagon/HexagonCommonGEP.cpp b/llvm/lib/Target/Hexagon/HexagonCommonGEP.cpp index 9f18d0b..43f0758 100644 --- a/llvm/lib/Target/Hexagon/HexagonCommonGEP.cpp +++ b/llvm/lib/Target/Hexagon/HexagonCommonGEP.cpp @@ -386,9 +386,8 @@ void HexagonCommonGEP::processGepInst(GetElementPtrInst *GepI, // dereferences the pointer operand. GepNode *PN = N; Type *PtrTy = GepI->getSourceElementType(); - for (User::op_iterator OI = GepI->idx_begin()+1, OE = GepI->idx_end(); - OI != OE; ++OI) { - Value *Op = *OI; + for (Use &U : llvm::drop_begin(GepI->indices())) { + Value *Op = U; GepNode *Nx = new (*Mem) GepNode; Nx->Parent = PN; // Link Nx to the previous node. Nx->Flags |= GepNode::Internal | InBounds; diff --git a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp index 213cf48..ec08287 100644 --- a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp +++ b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp @@ -1193,7 +1193,7 @@ struct AAPointerInfoFloating : public AAPointerInfoImpl { } SmallVector Indices; - for (Use &Idx : llvm::make_range(GEP->idx_begin(), GEP->idx_end())) { + for (Use &Idx : GEP->indices()) { if (auto *CIdx = dyn_cast(Idx)) { Indices.push_back(CIdx); continue; diff --git a/llvm/lib/Transforms/Scalar/GVN.cpp b/llvm/lib/Transforms/Scalar/GVN.cpp index 06ced8a..00506fb 100644 --- a/llvm/lib/Transforms/Scalar/GVN.cpp +++ b/llvm/lib/Transforms/Scalar/GVN.cpp @@ -1643,10 +1643,8 @@ bool GVNPass::processNonLocalLoad(LoadInst *Load) { // If this load follows a GEP, see if we can PRE the indices before analyzing. if (GetElementPtrInst *GEP = dyn_cast(Load->getOperand(0))) { - for (GetElementPtrInst::op_iterator OI = GEP->idx_begin(), - OE = GEP->idx_end(); - OI != OE; ++OI) - if (Instruction *I = dyn_cast(OI->get())) + for (Use &U : GEP->indices()) + if (Instruction *I = dyn_cast(U.get())) Changed |= performScalarPRE(I); } -- 2.7.4