[Mlir-commits] [mlir] [MLIR][RemoveDeadValues] Mark arguments of a public function Live (PR #162038)

xin liu llvmlistbot at llvm.org
Mon Oct 6 09:24:13 PDT 2025


================
@@ -39,6 +39,20 @@ struct ForwardIterator {
   }
 };
 
+/// This iterator enumerates the elements in "backward" order.
+struct BackwardIterator {
+  template <typename T>
+  static auto makeIterable(T &range) {
+    if constexpr (std::is_same<T, Operation>()) {
+      /// Make operations iterable: return the list of regions.
+      return llvm::reverse(range.getRegions());
+    } else {
+      /// Regions and block are already iterable.
+      return llvm::reverse(range);
+    }
+  }
+};
----------------
navyxliu wrote:

hi, @joker-eph, 
> Which do you need to do this? 
I change iterator here. My intention is to visit basic block and CFG in reverse order. 
module->walk<WalkOrder::PostOrder, BackwardIterator>

> The order of the region on the op are not indicative of anything related to this.
TBH, this is the part of MLIR I don't understand. Should we also reverse Operation::getRegions()?  yes, my understanding is that the order doesn't matter for regions. 

https://github.com/llvm/llvm-project/pull/162038


More information about the Mlir-commits mailing list