Repository navigation
Perf: move of a returned record update of a local base in MLIR (#696) - #1418
Conversation
|
👋 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 New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
d83e6c8 to
50994e9
Compare
Rebased from d83e6c8 onto main without its bootstrap commit. #1420's follow-up is not folded: against main it defines mlg_expr_uses_name, mlg_rupdate_values_use_name and mlg_try_rupdate_return a second time and reverts the README statistics. Co-authored-by: godofecht <[email protected]>
The fast path checked for AST_RECORD_UPDATE, but a record update reaches the emitter as an AST_STRUCT_LIT with the base in c (the marker kind never appears there), so the path never ran. Matching the real shape exposes two defects, fixed here: a struct local is alloca-backed off wasm32, and the path read its SSA value, which a field store such as p.x = a leaves stale; and an unknown field name walked off the field list. The base is now loaded from its alloca when it has one, every field is checked before anything is emitted, and the struct type must equal the function's return type.
mlir_record_update_return returns Name { ..p, f: v } from a local base
after a field store to it. The golden has no copy through a second
alloca and reads the stored field; main's compiler fails it (it emits
the extract/insert copy and a second alloca).
…sion digests (#696) compiler/fixtures/mlir/record_update_return is now a parity fixture (run output 7 5 0 4). tests/cgen/copy_elision.flow and tests/lang/test_copy_elision.flow return record updates of local bases, so their recorded MLIR digests move; only those two corpus lines change.
50994e9 to
1049583
Compare
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, functions with a forward declaration or an overload, 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. The pointer ABI no longer depends on w.sigs_len, which grows during emission and let a prototype and its definition disagree.
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.
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.
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.
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.
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.
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.
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.
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.
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.
Part of #696. MLIR mirror of
flowc_cgen_try_rupdate_return:return Name { ..base, f: v }with a local base inserts the listed fields into the base value and returns it, with no copy through a second alloca.Merge-train rebase onto main 81ecf1e (50994e9):
AST_RECORD_UPDATE, but a record update reaches the emitter as anAST_STRUCT_LITwith the base inc. With the check corrected, two defects showed, now fixed: struct locals are alloca-backed off wasm32, and the path read the SSA value, which a field store (p.x = a) leaves stale; and an unknown field walked off the field list. The base is loaded from its alloca when it has one, fields are validated before emitting, and the struct type must equal the return type.mlg_expr_uses_name,mlg_rupdate_values_use_nameandmlg_try_rupdate_returna second time and reverts the README statistics.Gates (macOS arm64): parity_mlir PASS, mlir_commands 88/0, cgen goldens, test-lang, test-runtime, self_host_full, roundtrip. corpus_parity --check reports 1016 < floor 1033 on Darwin, identical on main here. tests/cli fails only jit_hello and test_mlir, as on main.