diff --git a/llvm/lib/Target/AMDGPU/AMDGPULowerBufferFatPointers.cpp b/llvm/lib/Target/AMDGPU/AMDGPULowerBufferFatPointers.cpp index 766a4ea250942..a62fc60461193 100644 --- a/llvm/lib/Target/AMDGPU/AMDGPULowerBufferFatPointers.cpp +++ b/llvm/lib/Target/AMDGPU/AMDGPULowerBufferFatPointers.cpp @@ -2261,11 +2261,10 @@ PtrParts SplitPtrStructs::visitIntrinsicInst(IntrinsicInst &I) { void SplitPtrStructs::processFunction(Function &F) { ST = &TM->getSubtarget(F); - SmallVector Originals; + SmallVector Originals( + llvm::make_pointer_range(instructions(F))); LLVM_DEBUG(dbgs() << "Splitting pointer structs in function: " << F.getName() << "\n"); - for (Instruction &I : instructions(F)) - Originals.push_back(&I); for (Instruction *I : Originals) { auto [Rsrc, Off] = visit(I); assert(((Rsrc && Off) || (!Rsrc && !Off)) && diff --git a/llvm/lib/Target/AMDGPU/AMDGPURewriteOutArguments.cpp b/llvm/lib/Target/AMDGPU/AMDGPURewriteOutArguments.cpp index 6347636b60e58..bb68f4a0e70de 100644 --- a/llvm/lib/Target/AMDGPU/AMDGPURewriteOutArguments.cpp +++ b/llvm/lib/Target/AMDGPU/AMDGPURewriteOutArguments.cpp @@ -114,9 +114,7 @@ Type *AMDGPURewriteOutArguments::getStoredType(Value &Arg) const { const int MaxUses = 10; int UseCount = 0; - SmallVector Worklist; - for (Use &U : Arg.uses()) - Worklist.push_back(&U); + SmallVector Worklist(llvm::make_pointer_range(Arg.uses())); Type *StoredType = nullptr; while (!Worklist.empty()) { diff --git a/llvm/lib/Target/AMDGPU/GCNDPPCombine.cpp b/llvm/lib/Target/AMDGPU/GCNDPPCombine.cpp index 5439ea2f59111..0d8113da275bd 100644 --- a/llvm/lib/Target/AMDGPU/GCNDPPCombine.cpp +++ b/llvm/lib/Target/AMDGPU/GCNDPPCombine.cpp @@ -629,11 +629,8 @@ bool GCNDPPCombine::combineDPPMov(MachineInstr &MovMI) const { OrigMIs.push_back(&MovMI); bool Rollback = true; - SmallVector Uses; - - for (auto &Use : MRI->use_nodbg_operands(DPPMovReg)) { - Uses.push_back(&Use); - } + SmallVector Uses( + llvm::make_pointer_range(MRI->use_nodbg_operands(DPPMovReg))); while (!Uses.empty()) { MachineOperand *Use = Uses.pop_back_val(); diff --git a/llvm/lib/Target/AMDGPU/SIFoldOperands.cpp b/llvm/lib/Target/AMDGPU/SIFoldOperands.cpp index d6acf9e081b9f..5e8273a968e82 100644 --- a/llvm/lib/Target/AMDGPU/SIFoldOperands.cpp +++ b/llvm/lib/Target/AMDGPU/SIFoldOperands.cpp @@ -972,9 +972,8 @@ void SIFoldOperandsImpl::foldOperand( unsigned RegSeqDstSubReg = UseMI->getOperand(UseOpIdx + 1).getImm(); // Grab the use operands first - SmallVector UsesToProcess; - for (auto &Use : MRI->use_nodbg_operands(RegSeqDstReg)) - UsesToProcess.push_back(&Use); + SmallVector UsesToProcess( + llvm::make_pointer_range(MRI->use_nodbg_operands(RegSeqDstReg))); for (auto *RSUse : UsesToProcess) { MachineInstr *RSUseMI = RSUse->getParent(); @@ -1552,9 +1551,8 @@ bool SIFoldOperandsImpl::foldInstOperand(MachineInstr &MI, } } - SmallVector UsesToProcess; - for (auto &Use : MRI->use_nodbg_operands(Dst.getReg())) - UsesToProcess.push_back(&Use); + SmallVector UsesToProcess( + llvm::make_pointer_range(MRI->use_nodbg_operands(Dst.getReg()))); for (auto *U : UsesToProcess) { MachineInstr *UseMI = U->getParent(); foldOperand(OpToFold, UseMI, UseMI->getOperandNo(U), FoldList, @@ -2380,10 +2378,9 @@ bool SIFoldOperandsImpl::tryFoldLoad(MachineInstr &MI) { if (DefReg.isPhysical() || !TRI->isVGPR(*MRI, DefReg)) return false; - SmallVector Users; + SmallVector Users( + llvm::make_pointer_range(MRI->use_nodbg_instructions(DefReg))); SmallVector MoveRegs; - for (const MachineInstr &I : MRI->use_nodbg_instructions(DefReg)) - Users.push_back(&I); if (Users.empty()) return false;