Repository navigation
Lane B train: RT-safe callable contracts (#766), destination-passing and copy_count (#732), memory profiler sites (#740), mixed concat and parse_float (#747) [#1348 #1367 #1366 #1356] - #1348
Merged
Conversation
godofecht
marked this pull request as ready for review
October 5, 2026 02:14
This was referenced Oct 5, 2026
godofecht
force-pushed
the
cursor/rt-safe-callable-contracts-7ce9
branch
from
October 7, 2026 18:48
a5bc260 to
1ed6901
Compare
godofecht
force-pushed
the
cursor/rt-safe-callable-contracts-7ce9
branch
2 times, most recently
from
October 7, 2026 20:27
cc1e6a4 to
5a1bcdb
Compare
7 of 8 tasks
godofecht
force-pushed
the
cursor/rt-safe-callable-contracts-7ce9
branch
from
October 8, 2026 00:02
5a1bcdb to
75d990b
Compare
This was referenced Oct 8, 2026
godofecht
enabled auto-merge
October 8, 2026 00:25
godofecht
force-pushed
the
cursor/rt-safe-callable-contracts-7ce9
branch
from
October 8, 2026 00:27
75d990b to
64e07e3
Compare
godofecht
added a commit
that referenced
this pull request
Oct 8, 2026
…#765) Close the remaining #765 gaps on top of the landed first slice: a known-safe extern allow-list so unknown is a hard error from @rt_safe, impl methods in the call graph (closures stay with #766 / PR #1348), LD1 through static fields and malloc stores, and a refinement-keyed incremental summary cache. Co-authored-by: Abhishek Shivakumar <[email protected]>
godofecht
force-pushed
the
cursor/rt-safe-callable-contracts-7ce9
branch
from
October 8, 2026 01:04
64e07e3 to
8caba56
Compare
github-merge-queue
Bot
removed this pull request from the merge queue due to a conflict with the base branch
Oct 8, 2026
godofecht
force-pushed
the
cursor/rt-safe-callable-contracts-7ce9
branch
from
October 8, 2026 02:38
8caba56 to
f241386
Compare
godofecht
enabled auto-merge
October 8, 2026 02:38
godofecht
force-pushed
the
cursor/rt-safe-callable-contracts-7ce9
branch
from
October 8, 2026 02:51
f241386 to
30c308d
Compare
github-merge-queue
Bot
removed this pull request from the merge queue due to a conflict with the base branch
Oct 8, 2026
godofecht
force-pushed
the
cursor/rt-safe-callable-contracts-7ce9
branch
from
October 8, 2026 03:35
30c308d to
e91f723
Compare
godofecht
enabled auto-merge
October 8, 2026 03:36
github-merge-queue
Bot
removed this pull request from the merge queue due to a conflict with the base branch
Oct 8, 2026
Extend the #1310 `with rt_safe` function-pointer contract so a callback-safe higher-order function can accept a proven-safe named function or closure and reject an allocating one. Closures get a compile-time summary: the body is walked into the existing pointer/span captures are rejected, and diagnostics name the closure and the unsafe op. The contract is erased before codegen. Stop `with E1, E2` on a nested function type from swallowing the next parameter (`f: (T) -> R with rt_safe, x: i32`). Trait-method contracts remain a documented gap. Part of #766. Co-authored-by: Abhishek Shivakumar <[email protected]>
…itialized locals (#766)
Single-module functions that return a named struct take a hidden `T* __flowc_sret` destination; in bundle mode (FLOWC_BUNDLE=1) the callee keeps a local sret slot so the pointer ABI is not exposed across modules. Record updates whose destination overlaps a source read go through a temporary (overwrite dependence); others build in place. The runtime profile and the #728 harness report copy_count (aggregate copy operations) next to copies (bytes). Rebased from PR #1367 onto current main. cgen conflicts with the span data temps (#729/#1383) and the noalias clone flag (#731): the function prologue emits the sret slot, then the span temps, then the body; the buffer keeps na_clone, bounds_hi_* and sret. Doc and harness comment conflicts keep both sides. On rebase: `export function`s keep the value-return C signature (no pointer sret), because a module compiled on its own (roundtrip.flow, stage_a_self_emit) only sees that declaration; the PR as written failed roundtrip with "too few arguments" in lexer_flowc.c. The record-update MLIR goldens (fixture, corpus digests for the three copy-elision programs, mlir_commands) are re-recorded on top of #1418; parity_mlir runs all 24 fixtures through MLIR and they pass.
Extend the opt-in FLOW_MEM_PROFILE runtime with hashed live-block accounting, stack/arena promotion counters, per-compiler-site attribution, and matching MLIR wrappers. This is runtime accounting only and does not overlap the #669 static-lifetime work. Co-authored-by: Abhishek Shivakumar <[email protected]>
The MLIR profiler preamble passed llvm.mlir.addressof @flow_mem_report to atexit, but @flow_mem_report is a func.func until func-to-llvm, and addressof must name an llvm.func or a global. Every program failed to verify (parity_mlir: fixtures did not lower or link). func.constant plus an unrealized cast to !llvm.ptr lowers to the same addressof once the function is converted.
Every allocating program now carries the flow_mem_* profiler code, so parity_mlir fixture goldens and corpus digests (merged onto the old file, keeping entries this macOS host does not record), ten mlir_commands goldens, and the compile_hello / compile_isolated_root / python_source checksums change (darwin and linux hold the same values). parity_mlir PASS, mlir_commands 88/0.
Finish the remaining #747 gaps after the first slice: flatten mixed numeric + chains to one concatn, lower n-way string + in MLIR as one malloc plus per-part memcpy, add a linear parse_float and fail-closed UTF-8 helpers, and print allocation/copy counters on the harness rows. Co-authored-by: Abhishek Shivakumar <[email protected]>
… 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.
…n; operator-sugar targets keep the value return (#732) The strict corpus (tests/core/test_production_features, tests/lang/ test_lowered_forms, tests/lang/test_dual_operator_sugar) failed to compile: `expr?` inside a pointer-ABI sret function emitted `return __flowc_try;` from a void function, and the Dual operator sugar calls add/sub/mul/div/neg by name with the value-return arguments. The try now stores through `*__flowc_sret` and returns; the operator-sugar names keep the plain C signature.
godofecht
force-pushed
the
cursor/rt-safe-callable-contracts-7ce9
branch
from
October 8, 2026 05:52
e91f723 to
2d8c1ce
Compare
godofecht
enabled auto-merge
October 8, 2026 05:53
godofecht
added a commit
that referenced
this pull request
Oct 8, 2026
…#765) Close the remaining #765 gaps on top of the landed first slice: a known-safe extern allow-list so unknown is a hard error from @rt_safe, impl methods in the call graph (closures stay with #766 / PR #1348), LD1 through static fields and malloc stores, and a refinement-keyed incremental summary cache. Co-authored-by: Abhishek Shivakumar <[email protected]>
8 tasks done
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.
Lane B train: #1348, #1367, #1366 and #1356 rebased onto main together, with one bootstrap regeneration.
Closes #732
Part of #766 (trait-method RT contracts follow in a separate PR)
Closes #740
Closes #747
What each PR brings
with rt_safecallable contracts. HOF parameters withwith rt_safeparse. Casts and uninitialized locals cannot launder a contract.T* __flowc_sretdestination. Same-storage record updates go through a temporary when a field read overlaps. The profile and the [Performance] Build a cross-dimensional Python comparison harness and required regression gates #728 harness reportcopy_count.flow_mem_*hooks.+chains lower to one__flowc_str_concatn, MLIR strcat lowering,parse_float, and the UTF-8 policy. Includes the Fix CI failures on PR #1356 (issue #747) #1376 follow-up.Train resolution
compiler/bootstrap/flowc_stage_a.cis regenerated once, in the last commit (fixed point at gen3,--verifyPASS).flow_mem_copy_countand thecopy_count:report key from #732: destination-passing ABI, overwrite-dependence, and copy_count #1367 and the site, promotion and live-map counters from feat: remaining #740 memory profiler (sites, promotion, live map, MLIR) #1366.flow_mem_note_copyandflow_mem_note_copy_siteboth count a copy operation. The sized-array assignment uses feat: remaining #740 memory profiler (sites, promotion, live map, MLIR) #1366'sflow_mem_memcpy_site(..., FLOW_MEM_SITE_ARRAY), which counts it.docs/library/memory.mdfollows feat: remaining #740 memory profiler (sites, promotion, live map, MLIR) #1366 (the counter list moved tomemory-profile.md);copy_countis added to that page's table.tests/cgen/mem_profile.expectandtests/scripts/mem_profile.flowcheck both PRs' keys.export functions so a module compiled alone keeps the C signature; MLIR profiler report address viafunc.constant).rt_safe_cast_launderfixture had no# expect:header and failed typecheck_rules. The cast is rejected first (Cannot cast (i32) -> i32 to (i32) -> i32 with rt_safe) and the RT-safety violation namingunsafe_fnandmallocfollows; the header records the first.stdlib-api.mdis regenerated.parity_mlir --record, no entry dropped), CLI checksums for compile_hello, compile_isolated_root and python_source (darwin and linux hold the same values), the MLIR command goldens from feat: remaining #740 memory profiler (sites, promotion, live map, MLIR) #1366, the LSP completion golden (four newstd.stringexports) and the FIRarena_framegolden (arena_allocandframe_allocnow callflow_mem_note_arena).Gates (macOS arm64)
On the train rebased onto main 32401c7 (after the lane A and lane C trains), bootstrap regenerated there, with a fresh Stage-A driver:
flowc_hostselftest:flowc: PASSbootstrap_from_c.sh --regen: fixed point at gen3;--verify: PASS./flow test --tier2 --strict: 0 transpile and 0 clang failures./flow test-lang,./flow test-runtime: passtests/cgen/run.flow,parity_mlir.flow,tests/mlir_commands/run.flow: passtypecheck_rules.flow,parity_typecheck.flow --check,tests/scripts/rt_callable.flow,tests/scripts/mem_profile.flow,tests/bench_harness/run.flow,tests/fir/run.flow: passself_host_full.flow(gen2.o == gen3.o),roundtrip.flow,selfcompile_audit.flow: passtests/tools/run.flow,tests/conformance/run.flow: passtests/cli/run.flow: all pass except jit_hello and test_mlirgen_stdlib_docs --check,doc_examples --check-ledger,fmt_check --check,parse_coverage --check,python_ratchet,script_refs,./flow test-scripts: passFixes found by the train gates and the first CI run:
expr?inside a pointer-ABI sret function emittedreturn __flowc_try;from a void function; it now stores through*__flowc_sretand returns. The Dual operator sugar callsadd/sub/mul/div/negby name with value-return arguments, so those names keep the plain C signature.roundtrip.flowfailed incompile_module regionwith conflicting types: #732: destination-passing ABI, overwrite-dependence, and copy_count #1367's pointer-ABI sret applied to a definition whose bodyless forward declaration incompiler/src/region.flow([Flow 2.0] Implement local region inference and automated non-aliasing proofs #1390) kept the value-return prototype. A function name shared by a forward declaration or an overload now keeps the plain C signature. Earlier local roundtrip runs had passed only because a stalestage_a_driver_flowfrom before the change was reused.roundtrip.flow's stage_a_infer_struct check accepts the sret form of the typed let (Pair p;thenmake_pair(&p, 20, 22);).arena_framegolden gainsflow_mem_note_arena([Performance #727] Instrument runtime allocation, peak RSS, stack/arena promotion and temporary lifetimes #740).Known local drifts on this Mac: tests/cli jit_hello and test_mlir.