[Mlir-commits] [mlir] [mlir][dataflow] Add new visitNonControlFlowArgumentst API to SparseDataFlowAnalysis and apply it in LivenessAnalysis/RemoveDeadValues/IntegerRangeAnalysis (PR #169816)

Oleksandr Alex Zinenko llvmlistbot at llvm.org
Wed Dec 31 00:29:41 PST 2025


================
@@ -609,12 +609,27 @@ void AbstractSparseBackwardDataFlowAnalysis::visitRegionSuccessors(
            *getLatticeElementFor(getProgramPointAfter(op), input));
       unaccounted.reset(operand.getOperandNumber());
     }
+
+    if (successor.isParent())
+      continue;
+    MutableArrayRef<BlockArgument> arguments =
+        successor.getSuccessor()->getArguments();
+    for (BlockArgument argument : arguments) {
+      // Visit property blockArgument of RegionBranchOp which isn't "control
+      // flow block arguments". For example, the IV of a loop.
+      if (!llvm::is_contained(inputs, argument)) {
+        regionArguments.push_back(argument);
+      }
+    }
   }
   // All operands not forwarded to regions are typically parameters of the
   // branch operation itself (for example the boolean for if/else).
   for (int index : unaccounted.set_bits()) {
     visitBranchOperand(op->getOpOperand(index));
   }
+  for (BlockArgument argument : regionArguments) {
+    visitNonControlFlowArguments(argument);
+  }
----------------
ftynse wrote:

It looks like `regionArguments` is a flat list containing arguments from _all_ successor regions indistinguishably. While it is possible to recover the owning region from `BlockArgument`, I'd consider aligning this method on `visitNonControlFlowArguments` method of the forward analysis that takes a reference to `RegionSuccessor` and a _list_ of arguments -- as the name indicates -- for that specific successor.

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


More information about the Mlir-commits mailing list