Repository navigation
Conversation
The C backend's effect dispatch calls _flow_unhandled_effect when no installed handler has the operation: under strict effects (the default) it prints 'flow: unhandled effect E.op (...)' to stderr and aborts, and only FLOW_PERMISSIVE_EFFECTS=1 at run time restores the zero default. mlirgen returned the zero default unconditionally, so 19 corpus programs exited 0 under MLIR and 134 under C. The MLIR dispatch functions now call __flow_unhandled_effect on both unhandled paths (no handler, or a handler without the operation). The helper reads FLOW_PERMISSIVE_EFFECTS at run time, or is fixed strict under FLOWC_STRICT_EFFECTS=1, as flowc_cgen_eff_strict does. compiler/fixtures/mlir/effects.flow now ends on a handler that lacks an operation, so its recorded run exits 134; the old backend printed a zero and exited 0. Corpus digests moved for the programs that declare or import an effect.
godofecht
force-pushed
the
fix/mlir-unhandled-effect
branch
from
October 14, 2026 12:14
5b6f7b1 to
5358054
Compare
github-merge-queue
Bot
removed this pull request from the merge queue due to a conflict with the base branch
Oct 14, 2026
#1594) Resolved merge conflicts in: - `compiler/bootstrap/flowc_stage_a` - `compiler/fixtures/mlir/corpus.txt` Regenerated `docs/demos/overview.md` to fix the stale documentation CI failure. Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com> Co-authored-by: godofecht <[email protected]>
Contributor
Author
|
Superseded by #1680, which explicitly migrates this unhandled-effect MLIR behavior onto the current |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Cause
The C backend's effect dispatch (
E_opin cgen.flow) calls_flow_unhandled_effectwhen no installed handler has the operation. Under strict effects, the default, that printsflow: unhandled effect E.op (set FLOW_PERMISSIVE_EFFECTS=1 to allow zero defaults)to stderr and aborts. OnlyFLOW_PERMISSIVE_EFFECTS=1at run time restores the zero default.mlirgen's dispatch functions returned the zero default unconditionally. 19 corpus programs exited 0 under MLIR and 134 under C.
Fix
Both unhandled paths in the MLIR dispatch (no handler installed, or a handler without the operation) now call a new module helper,
__flow_unhandled_effect("E.op"). It readsFLOW_PERMISSIVE_EFFECTSat run time and, when that is not1, writes the same message to fd 2 and callsabort(). UnderFLOWC_STRICT_EFFECTS=1it is fixed strict, asflowc_cgen_eff_strictis.getenvis declared through a newLC_GETENVbit unless the memory profiler already declares it.Regression test
compiler/fixtures/mlir/effects.flownow runs its handled cases first, flushes stdout, then performs an operation its handler lacks. The recorded run (effects.out) endsexit=134. The old backend printedpartial 0.000000and exited 0.Counts (mlir_vs_c, full corpus, --jobs 8, macOS arm64, LLVM 22.1.7)
19 programs move from
run-exit (C 134, MLIR 0)tosame. The other changes are timing:examples/ai/flowlm_charlm.flow(run-timeout) andtests/lang/test_loops.flow/compiler/fixtures/mlir/loops.flow(c-fail-mlir) are now same, andtests/lang/test_c_import_string_time.flowandexamples/concurrency/work_steal.flowwent from same to nondet (clock and scheduling output). No program that was same is now failing.Gates
bootstrap_from_c.sh --regen, then--verify: PASSmlir_math_override, in its C backend half. It fails the same way with a flowc built from main's bootstrap C, so it is not from this change.Regenerated state
compiler/bootstrap/flowc_stage_a.candflowc_stage_a, in their own last commit.compiler/fixtures/mlir/effects.mlirandeffects.out, re-recorded.tests/mlir_commands/expected/for mlir_effects, llvm_effects and run_mlir_effects, re-recorded with--record, in their own commit.compiler/fixtures/mlir/corpus.txt: digests re-recorded only for the 77 programs whose MLIR changed, all of which declare or import an effect (the dispatch functions gained the unhandled call).--recordalso wanted to add 11 programs that main never recorded (from [roadmap] Certified safety profiles #1546 and earlier); those are left out.The floor in
compiler/mlir_vs_c/floor.txtis not changed.Risk
Low. Programs that perform an unhandled effect now abort under MLIR, as they already do under C. Programs relying on the zero default need
FLOW_PERMISSIVE_EFFECTS=1on both backends.The handler slot in MLIR is still one global, where C keys it on the fiber. That is a separate gap (it is why
examples/concurrency/fiber_suspend.flowstill differs).