[Mlir-commits] [mlir] [MLIR] Introduce support for early exits (PR #166688)

Matthias Springer llvmlistbot at llvm.org
Fri Jun 12 03:18:11 PDT 2026


================
@@ -61,4 +61,88 @@ def GraphRegionNoTerminator : TraitList<[
     HasOnlyGraphRegion
   ]>;
 
+// Indicates that this op may propagate a breaking control-flow event from a
+// nested region upward to the addressed HasBreakingControlFlowOpInterface
+// operation. The op does NOT consume the break itself; it is merely transparent
+// to it. All ops that sit between a breaking terminator and the
+// HasBreakingControlFlowOpInterface ancestor that will ultimately receive the
+// break must carry this trait.
+def PropagateControlFlowBreak : NativeOpTrait<"PropagateControlFlowBreak">;
+
+def HasBreakingControlFlowOpInterface : OpInterface<"HasBreakingControlFlowOpInterface"> {
+  let description = [{
+    Interface for operations that act as the target of a breaking control-flow
+    event (e.g. `scf.break` or `scf.continue`). Every intermediate op must
+    carry the `PropagateControlFlowBreak` trait. The terminator may identify the
+    receiver with any dialect-defined mechanism, such as a builtin token value,
+    an attribute, or a symbolic relationship to an enclosing operation.
+  }];
+  let cppNamespace = "::mlir";
+
+  let methods = [
+    StaticInterfaceMethod<
+      /*desc=*/[{
+        Return true if this operation accepts the given terminator operation
+        as a breaking-control-flow predecessor. Ops that also use
+        `HasNestedTerminator<[...]>` should delegate to the terminator list
----------------
matthias-springer wrote:

I had to read this sentence a few times to understand this. I think it means that `HasNestedTerminator` provides the `acceptsTerminator` implementation, so when you have `HasNestedTerminator`, you don't need to implement this interface method?

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


More information about the Mlir-commits mailing list