Skip to content

[CodeGen] Construct SmallVector with iterator ranges (NFC) #136258

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions llvm/lib/CodeGen/CodeGenPrepare.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -834,9 +834,8 @@ bool CodeGenPrepare::eliminateFallThrough(Function &F, DominatorTree *DT) {
// Scan all of the blocks in the function, except for the entry block.
// Use a temporary array to avoid iterator being invalidated when
// deleting blocks.
SmallVector<WeakTrackingVH, 16> Blocks;
for (auto &Block : llvm::drop_begin(F))
Blocks.push_back(&Block);
SmallVector<WeakTrackingVH, 16> Blocks(
llvm::make_pointer_range(llvm::drop_begin(F)));

SmallSet<WeakTrackingVH, 16> Preds;
for (auto &Block : Blocks) {
Expand Down
5 changes: 2 additions & 3 deletions llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -867,9 +867,8 @@ void CombinerHelper::applyCombineExtendingLoads(

// Rewrite all the uses to fix up the types.
auto &LoadValue = MI.getOperand(0);
SmallVector<MachineOperand *, 4> Uses;
for (auto &UseMO : MRI.use_operands(LoadValue.getReg()))
Uses.push_back(&UseMO);
SmallVector<MachineOperand *, 4> Uses(
llvm::make_pointer_range(MRI.use_operands(LoadValue.getReg())));

for (auto *UseMO : Uses) {
MachineInstr *UseMI = UseMO->getParent();
Expand Down
5 changes: 2 additions & 3 deletions llvm/lib/CodeGen/MachineInstr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2442,9 +2442,8 @@ static const DIExpression *computeExprForSpill(
static const DIExpression *computeExprForSpill(const MachineInstr &MI,
Register SpillReg) {
assert(MI.hasDebugOperandForReg(SpillReg) && "Spill Reg is not used in MI.");
SmallVector<const MachineOperand *> SpillOperands;
for (const MachineOperand &Op : MI.getDebugOperandsForReg(SpillReg))
SpillOperands.push_back(&Op);
SmallVector<const MachineOperand *> SpillOperands(
llvm::make_pointer_range(MI.getDebugOperandsForReg(SpillReg)));
return computeExprForSpill(MI, SpillOperands);
}

Expand Down
5 changes: 2 additions & 3 deletions llvm/lib/CodeGen/RegAllocFast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1733,9 +1733,8 @@ void RegAllocFastImpl::handleDebugValue(MachineInstr &MI) {
// See if this virtual register has already been allocated to a physical
// register or spilled to a stack slot.
LiveRegMap::iterator LRI = findLiveVirtReg(Reg);
SmallVector<MachineOperand *> DbgOps;
for (MachineOperand &Op : MI.getDebugOperandsForReg(Reg))
DbgOps.push_back(&Op);
SmallVector<MachineOperand *> DbgOps(
llvm::make_pointer_range(MI.getDebugOperandsForReg(Reg)));

if (LRI != LiveVirtRegs.end() && LRI->PhysReg) {
// Update every use of Reg within MI.
Expand Down
6 changes: 2 additions & 4 deletions llvm/lib/CodeGen/RegisterUsageInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,9 @@ PhysicalRegisterUsageInfo::getRegUsageInfo(const Function &FP) {
void PhysicalRegisterUsageInfo::print(raw_ostream &OS, const Module *M) const {
using FuncPtrRegMaskPair = std::pair<const Function *, std::vector<uint32_t>>;

SmallVector<const FuncPtrRegMaskPair *, 64> FPRMPairVector;

// Create a vector of pointer to RegMasks entries
for (const auto &RegMask : RegMasks)
FPRMPairVector.push_back(&RegMask);
SmallVector<const FuncPtrRegMaskPair *, 64> FPRMPairVector(
llvm::make_pointer_range(RegMasks));

// sort the vector to print analysis in alphabatic order of function name.
llvm::sort(
Expand Down
Loading