Repository navigation
Conversation
Add a fail-closed intraprocedural region analysis in flowc: distinct owned locals occupy distinct storage, a fresh local is disjoint from every parameter, and pointer arithmetic inherits its base. Two parameters, a reassignment, a call result, and two views of the same identity stay may-alias. Proven-disjoint unit-stride copies lower to memcpy instead of memmove. FLOWC_REGION_CHECK diagnoses overlapping pointer arguments; FLOWC_REGION_REPORT names each binding's region. Restrict emission remains #731. Co-authored-by: Abhishek Shivakumar <[email protected]>
Keep compiler/bootstrap/flowc_stage_a.c byte-identical to flowc's bundle emit of compiler/src/main.flow. Fixed point at gen2. Co-authored-by: Abhishek Shivakumar <[email protected]>
GitHub never started the main CI workflow for this PR despite an open pull_request targeting main; bpfel/wasm32 only ran on push. Empty commit to fire the pull_request synchronize event. Co-authored-by: Abhishek Shivakumar <[email protected]>
Contributor
Author
|
Superseded by #1390 (merged as 38f3b79), which landed this PR's compiler/src/region.flow, the cgen/main/sem_check changes and tests/lang/test_region_inference.flow. #1390 did not bring the docs and C goldens. They are listed for a docs-and-goldens salvage PR in the merge queue: docs/language/region-inference.md, tests/cgen/region_inference.{flow,expect}, tests/cgen/region_unproven.{flow,expect}, and the LANGUAGE_SPEC.md, book chapter 10, spans.md, lifetime-domains.md, spec-index.md and CHANGELOG lines. Closing during PR triage; the branch is kept. |
godofecht
added a commit
that referenced
this pull request
Oct 7, 2026
…om closed PRs Salvaged from closed pull requests whose code already landed: - #1360 (region inference, code merged as #1390): region-inference.md, the tests/cgen region_inference and region_unproven goldens, and the spec, book, spans, lifetime-domains, README, spec-index, nav and CHANGELOG lines. - #1368 (noalias, code merged as #1388): the spans.md paragraph on restrict .data temporaries and its noalias.md link. - #1380 (tail-resumptive effects, code merged as #1349): the spec-index row for effects-continuations.md. #1417 landed after #1360 and keeps an unproven forward copy as an ordered element loop. The region_inference golden and the docs now say that, in place of the memmove the closed branch expected. The golden fails on the pre-#1417 compiler, which emitted memmove.
godofecht
added a commit
that referenced
this pull request
Oct 7, 2026
…om closed PRs (#1425) Salvaged from closed #1360 (region-inference.md, region_inference and region_unproven goldens, spec/book/index lines), #1368 (spans.md restrict .data paragraph) and #1380 (spec-index row for effects-continuations.md). The region_inference golden and docs follow #1417: an unproven parameter copy stays an ordered loop.
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.
Closes #694
Intent
Linked issue or roadmap item: #694 (epic #679). Archive tag
archive/feat/694-region-inference.What changed, and why is this the smallest useful change?
flowc infers abstract storage regions inside one function body and proves a conservative set of non-aliasing facts with no annotations. Distinct owned locals occupy distinct storage; a fresh local is disjoint from every parameter; pointer arithmetic inherits its base. Two parameters, a reassignment, a call result, and two views of the same identity stay may-alias. Proven-disjoint unit-stride copies lower to
memcpyinstead ofmemmove.FLOWC_REGION_CHECK=1diagnoses overlapping pointer arguments;FLOWC_REGION_REPORT=1writes per-binding remarks. Restrict /{llvm.noalias}emission remains #731.Overlap check
Overlap / dependency notes: Sibling agents own #684 (lifetime domains through fields), #690 (arena domains), #696 (move inference), and #731 (restrict/noalias emission). This PR adds
compiler/src/region.flowand consumes the proofs only for memcpy-vs-memmove and diagnostics. It does not changenoalias.flow.Evidence
Baseline before this change: flowc had no region-inference module; contiguous copies always used
memmove. The Python prototype lived only atarchive/feat/694-region-inference.Targeted proof that exercises the changed behaviour:
region_ok=1(distinct locals, local vs param, two params, reassignment, call result, restrict candidates, pointer arithmetic)./flow test-lang tests/lang/test_region_inference.flow./flow tool tests/cgen/run.flow region_inference region_unproven noalias_restrict for_simd_hot_loops for_simd_carried(5 passed)./compiler/scripts/bootstrap_from_c.sh --regen(fixed point at gen2) and--verify(PASS)Why that proof would detect the old failure or regression: the selftest asserts the Python prototype's soundness contract; the cgen golden fails if disjoint copies stay
memmoveor if parameters incorrectly becomememcpy; the reject golden fails if the overlapping-borrow diagnostic is missing.Repository gate(s) run: flowc selftest; targeted
tests/cgengoldens including #731 noalias and SIMD copy goldens;test-langfor the new file; bootstrap--regenand--verify.Generated/bootstrap state:
compiler/bootstrap/flowc_stage_a.cregenerated in a separate commit;--verifyreports the bootstrap C matches compiler/src.Risk
Compatibility, performance, security, lifetime, backend, or release implications: fail-closed analysis; default programs still compile. Contiguous copies of proven-disjoint locals now use
memcpy(defined for non-overlapping objects). Opt-in diagnostics only underFLOWC_REGION_CHECK=1. Documented gaps (interprocedural parameter disjointness, constant-slice intervals) stay fail-closed and are owned by #731.docs/project/Questions.mdupdated if this needs a language-design decision.Compatibility
docs/project/CHANGELOG.md.(Default language behaviour is unchanged; the memcpy lowering and opt-in flags are documented in CHANGELOG.)
Agent handoff
Agent/provider/session: Cursor cloud agent.
Any remaining blocker is recorded in GitHub rather than only in local/session state: none. Do not merge; this PR is ready for review.