[Mlir-commits] [mlir] Hold a queue of iterator ranges (not operations) in wouldOpBeTriviallyDead (PR #123642)

Jacques Pienaar llvmlistbot at llvm.org
Mon Jan 20 17:07:11 PST 2025


================
@@ -41,10 +42,17 @@ bool mlir::isOpTriviallyDead(Operation *op) {
 /// allows for marking region operations as trivially dead without always being
 /// conservative of terminators.
 static bool wouldOpBeTriviallyDeadImpl(Operation *rootOp) {
-  // The set of operations to consider when checking for side effects.
-  SmallVector<Operation *, 1> effectingOps(1, rootOp);
+  // The set of operation intervals (end-exclusive) to consider when checking
+  // for side effects.
+  SmallVector<std::pair<Block::iterator, Block::iterator>, 1> effectingOps = {
+      std::make_pair(Block::iterator(rootOp), ++Block::iterator(rootOp))};
   while (!effectingOps.empty()) {
-    Operation *op = effectingOps.pop_back_val();
+    if (it == end) {
----------------
jpienaar wrote:

Typo? This should probably be below their declaration below.

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


More information about the Mlir-commits mailing list