[PATCH] D150854: MachineTraceMetrics: modernize loops (NFC)

Ramkumar Ramachandra via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 18 04:11:59 PDT 2023


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb4038fb72f0a: MachineTraceMetrics: modernize loops (NFC) (authored by artagnon).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D150854/new/

https://reviews.llvm.org/D150854

Files:
  llvm/lib/CodeGen/MachineTraceMetrics.cpp


Index: llvm/lib/CodeGen/MachineTraceMetrics.cpp
===================================================================
--- llvm/lib/CodeGen/MachineTraceMetrics.cpp
+++ llvm/lib/CodeGen/MachineTraceMetrics.cpp
@@ -1099,10 +1099,7 @@
     }
 
     // Go through the block backwards.
-    for (MachineBasicBlock::const_iterator BI = MBB->end(), BB = MBB->begin();
-         BI != BB;) {
-      const MachineInstr &MI = *--BI;
-
+    for (const MachineInstr &MI : reverse(*MBB)) {
       // Find the MI height as determined by virtual register uses in the
       // trace below.
       unsigned Cycle = 0;
@@ -1149,11 +1146,10 @@
     }
 
     // Transfer the live regunits to the live-in list.
-    for (SparseSet<LiveRegUnit>::const_iterator
-         RI = RegUnits.begin(), RE = RegUnits.end(); RI != RE; ++RI) {
-      TBI.LiveIns.push_back(LiveInReg(RI->RegUnit, RI->Cycle));
-      LLVM_DEBUG(dbgs() << ' ' << printRegUnit(RI->RegUnit, MTM.TRI) << '@'
-                        << RI->Cycle);
+    for (const LiveRegUnit &RU : RegUnits) {
+      TBI.LiveIns.push_back(LiveInReg(RU.RegUnit, RU.Cycle));
+      LLVM_DEBUG(dbgs() << ' ' << printRegUnit(RU.RegUnit, MTM.TRI) << '@'
+                        << RU.Cycle);
     }
     LLVM_DEBUG(dbgs() << '\n');
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D150854.523334.patch
Type: text/x-patch
Size: 1257 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230518/b6358346/attachment.bin>


More information about the llvm-commits mailing list