[llvm] c121f3a - [CodeGen] Use range-based for loops (NFC)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Sat Apr 8 16:22:53 PDT 2023


Author: Kazu Hirata
Date: 2023-04-08T16:22:39-07:00
New Revision: c121f3a9fbf1bcabfd64a62edec79a292e1f7d51

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

LOG: [CodeGen] Use range-based for loops (NFC)

Added: 
    

Modified: 
    llvm/lib/CodeGen/LiveVariables.cpp
    llvm/lib/CodeGen/MachineInstrBundle.cpp
    llvm/lib/CodeGen/MachinePipeliner.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/LiveVariables.cpp b/llvm/lib/CodeGen/LiveVariables.cpp
index 547e9a9443af3..905d268d5ac2c 100644
--- a/llvm/lib/CodeGen/LiveVariables.cpp
+++ b/llvm/lib/CodeGen/LiveVariables.cpp
@@ -208,8 +208,7 @@ LiveVariables::FindLastPartialDef(Register Reg,
     return nullptr;
 
   PartDefRegs.insert(LastDefReg);
-  for (unsigned i = 0, e = LastDef->getNumOperands(); i != e; ++i) {
-    MachineOperand &MO = LastDef->getOperand(i);
+  for (MachineOperand &MO : LastDef->operands()) {
     if (!MO.isReg() || !MO.isDef() || MO.getReg() == 0)
       continue;
     Register DefReg = MO.getReg();

diff  --git a/llvm/lib/CodeGen/MachineInstrBundle.cpp b/llvm/lib/CodeGen/MachineInstrBundle.cpp
index 0c059a145ca42..c64e577d463fc 100644
--- a/llvm/lib/CodeGen/MachineInstrBundle.cpp
+++ b/llvm/lib/CodeGen/MachineInstrBundle.cpp
@@ -58,8 +58,7 @@ bool UnpackMachineBundles::runOnMachineFunction(MachineFunction &MF) {
       if (MI->isBundle()) {
         while (++MII != MIE && MII->isBundledWithPred()) {
           MII->unbundleFromPred();
-          for (unsigned i = 0, e = MII->getNumOperands(); i != e; ++i) {
-            MachineOperand &MO = MII->getOperand(i);
+          for (MachineOperand &MO  : MII->operands()) {
             if (MO.isReg() && MO.isInternalRead())
               MO.setIsInternalRead(false);
           }
@@ -149,8 +148,7 @@ void llvm::finalizeBundle(MachineBasicBlock &MBB,
     if (MII->isDebugInstr())
       continue;
 
-    for (unsigned i = 0, e = MII->getNumOperands(); i != e; ++i) {
-      MachineOperand &MO = MII->getOperand(i);
+    for (MachineOperand &MO : MII->operands()) {
       if (!MO.isReg())
         continue;
       if (MO.isDef()) {

diff  --git a/llvm/lib/CodeGen/MachinePipeliner.cpp b/llvm/lib/CodeGen/MachinePipeliner.cpp
index d64548452b416..dbdae987b3428 100644
--- a/llvm/lib/CodeGen/MachinePipeliner.cpp
+++ b/llvm/lib/CodeGen/MachinePipeliner.cpp
@@ -2652,8 +2652,7 @@ bool SMSchedule::isLoopCarriedDefOfUse(SwingSchedulerDAG *SSD,
   if (!isLoopCarried(SSD, *Phi))
     return false;
   unsigned LoopReg = getLoopPhiReg(*Phi, Phi->getParent());
-  for (unsigned i = 0, e = Def->getNumOperands(); i != e; ++i) {
-    MachineOperand &DMO = Def->getOperand(i);
+  for (MachineOperand &DMO : Def->operands()) {
     if (!DMO.isReg() || !DMO.isDef())
       continue;
     if (DMO.getReg() == LoopReg)


        


More information about the llvm-commits mailing list