Skip to content

[Flow 2.0] Implement local region inference and automated non-aliasing proofs - #1390

Merged
godofecht merged 3 commits into
mainfrom
fix-694-region-inference-417636611563615652
Oct 6, 2026
Merged

godofecht merged 3 commits into
mainfrom
fix-694-region-inference-417636611563615652

Conversation

@godofecht

Copy link
Copy Markdown
Contributor

Part of epic #679.
Closes #694.

This commit completes the implementation of constraint-based local region inference to prove disjoint memory regions automatically, eliminating unnecessary aliasing barriers. It also provides clear diagnostics when aliasing cannot be proven safe and drops back to an unproven region (fail-closed answer).

Builds upon and supersedes cursor/region-inference-694-316b.


PR created automatically by Jules for task 417636611563615652 started by @godofecht

…g proofs

Part of epic #679.
Closes #694.

This commit completes the implementation of constraint-based local region inference
to prove disjoint memory regions automatically, eliminating unnecessary aliasing
barriers. It also provides clear diagnostics when aliasing cannot be proven safe
and drops back to an unproven region (fail-closed answer).

Builds upon and supersedes cursor/region-inference-694-316b.

Co-authored-by: godofecht <[email protected]>
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

google-labs-jules Bot and others added 2 commits October 6, 2026 03:30
…g proofs

Part of epic #679.
Closes #694.

This commit completes the implementation of constraint-based local region inference
to prove disjoint memory regions automatically, eliminating unnecessary aliasing
barriers. It also provides clear diagnostics when aliasing cannot be proven safe
and drops back to an unproven region (fail-closed answer).

Builds upon and supersedes cursor/region-inference-694-316b.

Co-authored-by: godofecht <[email protected]>
@godofecht
godofecht merged commit 38f3b79 into main Oct 6, 2026
35 checks passed
godofecht added a commit that referenced this pull request Oct 6, 2026
roundtrip2.txt and roundtrip_output.txt are logs of a roundtrip run that
were committed by accident in #1390. Nothing references them.
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
The lattice is callback < frame < request < session < application <
persistent, as accepted on 2026-10-07 (docs/project/Questions.md).
LD1-LD4 apply to both. request may allocate and is not @rt_safe.
persistent is the outermost domain: an application pointer may not be
stored in a persistent static, and an @Lifetime(application) function
may not call a persistent one. Compact summaries encode unannotated
callables as domain rank 6.

Rebased from PR #1369 onto current main; doc conflicts with region
inference (#1390) and the arena-domain rows (#690) kept both sides.
Whether persistent values must be TransportSafe is #1421.

The #690 arena-domain check hard-coded application as 3, which is
session once request is inserted; it now uses FLOWC_RT_DOM_APPLICATION
(domain_arena_ok_unannotated failed without this).
godofecht added a commit that referenced this pull request Oct 7, 2026
The lattice is callback < frame < request < session < application <
persistent, as accepted on 2026-10-07 (docs/project/Questions.md).
LD1-LD4 apply to both. request may allocate and is not @rt_safe.
persistent is the outermost domain: an application pointer may not be
stored in a persistent static, and an @Lifetime(application) function
may not call a persistent one. Compact summaries encode unannotated
callables as domain rank 6.

Rebased from PR #1369 onto current main; doc conflicts with region
inference (#1390) and the arena-domain rows (#690) kept both sides.
Whether persistent values must be TransportSafe is #1421.

The #690 arena-domain check hard-coded application as 3, which is
session once request is inserted; it now uses FLOWC_RT_DOM_APPLICATION
(domain_arena_ok_unannotated failed without this).
godofecht added a commit that referenced this pull request Oct 7, 2026
… declaration (#732)

Pointer-ABI sret applied to the definition while the bodyless forward
declaration kept the value-return prototype and call sites resolved the
first node of the name. compiler/src/region.flow (#1390) has such
declarations, so roundtrip's compile_module region failed with
conflicting types. A name shared by a forward declaration or an overload
keeps the plain C signature. roundtrip's stage_a_infer_struct check
accepts the sret form of the typed let.
godofecht added a commit that referenced this pull request Oct 7, 2026
… declaration (#732)

Pointer-ABI sret applied to the definition while the bodyless forward
declaration kept the value-return prototype and call sites resolved the
first node of the name. compiler/src/region.flow (#1390) has such
declarations, so roundtrip's compile_module region failed with
conflicting types. A name shared by a forward declaration or an overload
keeps the plain C signature. roundtrip's stage_a_infer_struct check
accepts the sret form of the typed let.
godofecht added a commit that referenced this pull request Oct 7, 2026
The lattice is callback < frame < request < session < application <
persistent, as accepted on 2026-10-07 (docs/project/Questions.md).
LD1-LD4 apply to both. request may allocate and is not @rt_safe.
persistent is the outermost domain: an application pointer may not be
stored in a persistent static, and an @Lifetime(application) function
may not call a persistent one. Compact summaries encode unannotated
callables as domain rank 6.

Rebased from PR #1369 onto current main; doc conflicts with region
inference (#1390) and the arena-domain rows (#690) kept both sides.
Whether persistent values must be TransportSafe is #1421.

The #690 arena-domain check hard-coded application as 3, which is
session once request is inserted; it now uses FLOWC_RT_DOM_APPLICATION
(domain_arena_ok_unannotated failed without this).
godofecht added a commit that referenced this pull request Oct 8, 2026
… declaration (#732)

Pointer-ABI sret applied to the definition while the bodyless forward
declaration kept the value-return prototype and call sites resolved the
first node of the name. compiler/src/region.flow (#1390) has such
declarations, so roundtrip's compile_module region failed with
conflicting types. A name shared by a forward declaration or an overload
keeps the plain C signature. roundtrip's stage_a_infer_struct check
accepts the sret form of the typed let.
godofecht added a commit that referenced this pull request Oct 8, 2026
… declaration (#732)

Pointer-ABI sret applied to the definition while the bodyless forward
declaration kept the value-return prototype and call sites resolved the
first node of the name. compiler/src/region.flow (#1390) has such
declarations, so roundtrip's compile_module region failed with
conflicting types. A name shared by a forward declaration or an overload
keeps the plain C signature. roundtrip's stage_a_infer_struct check
accepts the sret form of the typed let.
godofecht added a commit that referenced this pull request Oct 8, 2026
… declaration (#732)

Pointer-ABI sret applied to the definition while the bodyless forward
declaration kept the value-return prototype and call sites resolved the
first node of the name. compiler/src/region.flow (#1390) has such
declarations, so roundtrip's compile_module region failed with
conflicting types. A name shared by a forward declaration or an overload
keeps the plain C signature. roundtrip's stage_a_infer_struct check
accepts the sret form of the typed let.
godofecht added a commit that referenced this pull request Oct 8, 2026
… declaration (#732)

Pointer-ABI sret applied to the definition while the bodyless forward
declaration kept the value-return prototype and call sites resolved the
first node of the name. compiler/src/region.flow (#1390) has such
declarations, so roundtrip's compile_module region failed with
conflicting types. A name shared by a forward declaration or an overload
keeps the plain C signature. roundtrip's stage_a_infer_struct check
accepts the sret form of the typed let.
godofecht added a commit that referenced this pull request Oct 8, 2026
… declaration (#732)

Pointer-ABI sret applied to the definition while the bodyless forward
declaration kept the value-return prototype and call sites resolved the
first node of the name. compiler/src/region.flow (#1390) has such
declarations, so roundtrip's compile_module region failed with
conflicting types. A name shared by a forward declaration or an overload
keeps the plain C signature. roundtrip's stage_a_infer_struct check
accepts the sret form of the typed let.
godofecht added a commit that referenced this pull request Oct 8, 2026
… declaration (#732)

Pointer-ABI sret applied to the definition while the bodyless forward
declaration kept the value-return prototype and call sites resolved the
first node of the name. compiler/src/region.flow (#1390) has such
declarations, so roundtrip's compile_module region failed with
conflicting types. A name shared by a forward declaration or an overload
keeps the plain C signature. roundtrip's stage_a_infer_struct check
accepts the sret form of the typed let.
godofecht added a commit that referenced this pull request Oct 8, 2026
… declaration (#732)

Pointer-ABI sret applied to the definition while the bodyless forward
declaration kept the value-return prototype and call sites resolved the
first node of the name. compiler/src/region.flow (#1390) has such
declarations, so roundtrip's compile_module region failed with
conflicting types. A name shared by a forward declaration or an overload
keeps the plain C signature. roundtrip's stage_a_infer_struct check
accepts the sret form of the typed let.
@godofecht
godofecht deleted the fix-694-region-inference-417636611563615652 branch October 12, 2026 23:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Flow 2.0] Local region inference and automated non-aliasing proofs

1 participant