[llvm] [CodeGen] Use a range-based for loop (NFC) (PR #97177)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Sat Jun 29 12:13:36 PDT 2024
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/97177
I++ in the loop might appear to indicate that the loop modifies the
container in some way (deletion or insertion), but the loop just
examines the container.
>From f78e3b706f4c03056fc56c7f4ac9830fe3448ebc Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Sat, 29 Jun 2024 12:06:25 -0700
Subject: [PATCH] [CodeGen] Use a range-based for loop (NFC)
I++ in the loop might appear to indicate that the loop modifies the
container in some way (deletion or insertion), but the loop just
examines the container.
---
llvm/lib/CodeGen/RegAllocBase.cpp | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/llvm/lib/CodeGen/RegAllocBase.cpp b/llvm/lib/CodeGen/RegAllocBase.cpp
index 648036e5d89da..fb18f5a8a884a 100644
--- a/llvm/lib/CodeGen/RegAllocBase.cpp
+++ b/llvm/lib/CodeGen/RegAllocBase.cpp
@@ -116,11 +116,8 @@ void RegAllocBase::allocatePhysRegs() {
// selectOrSplit failed to find a register!
// Probably caused by an inline asm.
MachineInstr *MI = nullptr;
- for (MachineRegisterInfo::reg_instr_iterator
- I = MRI->reg_instr_begin(VirtReg->reg()),
- E = MRI->reg_instr_end();
- I != E;) {
- MI = &*(I++);
+ for (MachineInstr &MIR : MRI->reg_instructions(VirtReg->reg())) {
+ MI = &MIR;
if (MI->isInlineAsm())
break;
}
More information about the llvm-commits
mailing list