[llvm] e5aef72 - [CodeGen] Use a range-based for loop (NFC) (#97177)

via llvm-commits llvm-commits at lists.llvm.org
Sat Jun 29 17:07:01 PDT 2024


Author: Kazu Hirata
Date: 2024-06-29T17:06:58-07:00
New Revision: e5aef72c0af7fd8fcdde107e31444970d3fb87ea

URL: https://github.com/llvm/llvm-project/commit/e5aef72c0af7fd8fcdde107e31444970d3fb87ea
DIFF: https://github.com/llvm/llvm-project/commit/e5aef72c0af7fd8fcdde107e31444970d3fb87ea.diff

LOG: [CodeGen] Use a range-based for loop (NFC) (#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.

Added: 
    

Modified: 
    llvm/lib/CodeGen/RegAllocBase.cpp

Removed: 
    


################################################################################
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