Skip to content

perf: interprocedural noalias clones, span .data restrict, field provenance (#731) - #1368

Closed
godofecht wants to merge 2 commits into
mainfrom
cursor/noalias-specialization-731-ee8f
Closed

godofecht wants to merge 2 commits into
mainfrom
cursor/noalias-specialization-731-ee8f

Conversation

@godofecht

Copy link
Copy Markdown
Contributor

Intent

Part of #731 (parent #727). Related: #733 (vectorization-improvement tests), #694, #664.

PR #1344 landed the first fail-closed certificate and restrict/{llvm.noalias} emission. This slice fills the remaining listed gaps: mixed-site specialization clones (option 3), span .data restrict temps, struct-field provenance, and structural vectorization-improvement tests.

Smallest useful change: extend noalias.flow plus the two backends; add C/MLIR/lang/vectorize proofs and docs/language/noalias.md. No frontend syntax change.

Overlap check

  • I searched open pull requests and recent commits for overlapping work.
  • This does not duplicate another active implementation, or the relationship is explained below.

Overlap / dependency notes:

Evidence

Baseline before this change: #1344 on main (9a278876). Mixed sites stayed fully aliasable; span params had no .data restrict temps; embedded struct fields did not get distinct LOCAL roots; no vectorize golden existed.

Targeted proof that exercises the changed behaviour (pre-testing revision 206cddff; gates follow on this PR):

  • Host emit of mix_add: aliasable original + __flowc_na_mix_add restrict clone; proven call rewritten, overlapping call stays on the original.
  • Host emit of span_add: T* restrict __flowc_na_d_<name> = name.data temps.
  • Host emit of field_add / px/py: restrict on distinct embedded fields.
  • Host emit of scale_into: float* restrict plus omp/clang/GCC vectorize hints; scale_alias stays unqualified.

Why that proof would detect the old failure or regression: C goldens (noalias_restrict, noalias_vectorize) and tests/scripts/noalias_mlir.flow assert the new tokens; lang tests check mixed-clone and field-copy semantics still match sequential assignment.

Repository gate(s) run:

  • Evidence will be updated after: flowc host selftest, ./flow test-lang, ./flow tool tests/cgen/run.flow (noalias goldens), ./flow tool tests/scripts/noalias_mlir.flow, ./flow tool tests/scripts/noalias_vectorize.flow, ./flow tool scripts/check_pkg_parity.flow, ./flow tool compiler/scripts/parity_mlir.flow.
  • Bootstrap C is not in this commit. A follow-up commit will run ./compiler/scripts/bootstrap_from_c.sh --regen then --verify.

Generated/bootstrap state, if any:

  • Source-only commit 206cddff. Bootstrap regeneration is a separate commit.

Risk

C/MLIR output changes only when the certificate proves disjointness or a mixed-site clone is emitted. Wrong restrict remains undefined behaviour; the analysis stays fail-closed.

  • No unresolved language/API design decision is being implemented implicitly.
  • No unrelated generated artifacts or local state are included.
  • Docs changed when user-visible behaviour or syntax changed (docs/language/noalias.md registered in docs/nav.json; spans.md and CHANGELOG updated).
  • docs/project/Questions.md updated if this needs a language-design decision. (No new language-design decision.)

Compatibility

  • No user-visible compatibility change.
  • Compatibility change is documented in docs/project/CHANGELOG.md. (Backend-only annotation; CHANGELOG notes the new clone / span / field rules.)

Remaining gaps

Part of #731. Still fail-closed (not this slice):

  • Dynamic slice bounds (runtime lo/hi) stay unknown.
  • Calls that launder a pointer or span erase provenance rather than invent a root.

Agent handoff

Agent/provider/session: Cursor Cloud Agent (bc-1a5194fe-61a7-57d7-82d1-1633c816ee8f).

Any remaining blocker is recorded in GitHub rather than only in local/session state. Do not merge until review.

Open in Web Open in Cursor 

cursoragent and others added 2 commits October 5, 2026 12:00
…731)

Emit __flowc_na_ clones when some call sites are proven, extract restrict
temps from span .data, and treat embedded struct fields as distinct LOCAL
roots. Add C/MLIR/vectorize goldens and a language/noalias page.

Co-authored-by: Abhishek Shivakumar <[email protected]>
The negative token `mix_add(int32_t* restrict` is a substring of the
specialized clone. Expect 4.0 after the aliasing scale of the already
doubled buffer.

Co-authored-by: Abhishek Shivakumar <[email protected]>
godofecht added a commit that referenced this pull request Oct 6, 2026
Propagates local region/non-alias proofs into parameters and temporaries, defines the soundness boundary for restrict/LLVM noalias metadata, and hardens the predicate against signed-overflow mis-certification. Supersedes #1368.

Closes #731.
🤖 Generated with Codebuff
Co-Authored-By: Codebuff <[email protected]>
@godofecht

Copy link
Copy Markdown
Contributor Author

Superseded by #1388 (merged as 7cd0ce3), which landed the mixed-site noalias clones, span .data restrict temporaries and field provenance from this branch (compiler/src/noalias.flow, cgen/mlirgen changes, tests/cgen/noalias_restrict, tests/cgen/noalias_vectorize, tests/lang/test_noalias_mix_clone.flow, tests/lang/test_noalias_struct_fields.flow, tests/scripts/noalias_mlir.flow, tests/scripts/noalias_vectorize.flow). The one piece main lacks is the short note in docs/language/spans.md that links noalias.md; it is listed for the docs salvage PR in the merge queue. Closing during PR triage; the branch is kept.

@godofecht godofecht closed this Oct 7, 2026
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.
@godofecht
godofecht deleted the cursor/noalias-specialization-731-ee8f 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.

2 participants