[llvm] [CodeGen] Use range-based for loops (NFC) (PR #97467)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 2 12:46:39 PDT 2024
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/97467
None
>From afd2ab71784f5e37b1f17ee0812e8019ecc56837 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Tue, 2 Jul 2024 12:29:35 -0700
Subject: [PATCH] [CodeGen] Use range-based for loops (NFC)
---
llvm/lib/CodeGen/AggressiveAntiDepBreaker.cpp | 6 +++---
llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp | 6 +++---
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp | 8 ++++----
3 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/llvm/lib/CodeGen/AggressiveAntiDepBreaker.cpp b/llvm/lib/CodeGen/AggressiveAntiDepBreaker.cpp
index e91750afd28171..bccd9b04cd2c5c 100644
--- a/llvm/lib/CodeGen/AggressiveAntiDepBreaker.cpp
+++ b/llvm/lib/CodeGen/AggressiveAntiDepBreaker.cpp
@@ -124,13 +124,13 @@ AggressiveAntiDepBreaker::AggressiveAntiDepBreaker(
TRI(MF.getSubtarget().getRegisterInfo()), RegClassInfo(RCI) {
/* Collect a bitset of all registers that are only broken if they
are on the critical path. */
- for (unsigned i = 0, e = CriticalPathRCs.size(); i < e; ++i) {
- BitVector CPSet = TRI->getAllocatableSet(MF, CriticalPathRCs[i]);
+ for (const TargetRegisterClass *RC : CriticalPathRCs) {
+ BitVector CPSet = TRI->getAllocatableSet(MF, RC);
if (CriticalPathSet.none())
CriticalPathSet = CPSet;
else
CriticalPathSet |= CPSet;
- }
+ }
LLVM_DEBUG(dbgs() << "AntiDep Critical-Path Registers:");
LLVM_DEBUG(for (unsigned r
diff --git a/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp b/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
index d57dd6fca01403..945bd8bab16489 100644
--- a/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
@@ -438,11 +438,11 @@ void CombinerHelper::applyCombineShuffleConcat(MachineInstr &MI,
LLT SrcTy = MRI.getType(Ops[0]);
Register UndefReg = 0;
- for (unsigned i = 0; i < Ops.size(); i++) {
- if (Ops[i] == 0) {
+ for (Register &Reg : Ops) {
+ if (Reg == 0) {
if (UndefReg == 0)
UndefReg = Builder.buildUndef(SrcTy).getReg(0);
- Ops[i] = UndefReg;
+ Reg = UndefReg;
}
}
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
index 465919d03d8cae..2f9128eeae848b 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -10236,8 +10236,8 @@ void SelectionDAGBuilder::emitInlineAsmError(const CallBase &Call,
return;
SmallVector<SDValue, 1> Ops;
- for (unsigned i = 0, e = ValueVTs.size(); i != e; ++i)
- Ops.push_back(DAG.getUNDEF(ValueVTs[i]));
+ for (const EVT &VT : ValueVTs)
+ Ops.push_back(DAG.getUNDEF(VT));
setValue(&Call, DAG.getMergeValues(Ops, getCurSDLoc()));
}
@@ -12514,12 +12514,12 @@ void SelectionDAGBuilder::visitCallBrLandingPad(const CallInst &I) {
// getRegistersForValue may produce 1 to many registers based on whether
// the OpInfo.ConstraintVT is legal on the target or not.
- for (size_t i = 0, e = OpInfo.AssignedRegs.Regs.size(); i != e; ++i) {
+ for (unsigned &Reg : OpInfo.AssignedRegs.Regs) {
Register OriginalDef = FollowCopyChain(MRI, InitialDef++);
if (Register::isPhysicalRegister(OriginalDef))
FuncInfo.MBB->addLiveIn(OriginalDef);
// Update the assigned registers to use the original defs.
- OpInfo.AssignedRegs.Regs[i] = OriginalDef;
+ Reg = OriginalDef;
}
SDValue V = OpInfo.AssignedRegs.getCopyFromRegs(
More information about the llvm-commits
mailing list