Skip to content

codegen: aggregate-copy memmove only across a write-free load/store pair (#1689) - #1693

Merged
ehartford merged 1 commit into
mainfrom
fix-into-iter-record-move
Sep 26, 2026
Merged

ehartford merged 1 commit into
mainfrom
fix-into-iter-record-move

Conversation

@ehartford

Copy link
Copy Markdown
Contributor

Fixes #1689. wl_lower_aggregate_copies placed the memmove at the store, reading the source after intervening writes; Vec.remove (load element, shift buffer, store result) returned the shifted slot for elements >= 64 bytes, and into_iter inherited it. The rewrite now requires an adjacent write-free load/store pair in one block. Fixture: test/behavior/behav_vec_remove_large_element.w (POD, three-str record, into_iter). Codegen change: alone in its battery, draft until green.

…tween the load and the store can write memory (#1689)

wl_lower_aggregate_copies rewrote `store (load %T, src), dst` into a
memmove positioned at the store, so the source was read after everything
between the load and the store had run. Vec.remove loads the element,
calls with_vec_remove to shift the buffer, then stores the result: for an
element of 64 bytes or more the memmove copied the shifted slot, so
`remove(0)` returned the wrong element and consuming iteration yielded the
last element at every position. The rewrite now requires the load and the
store to share a block with no store, call, fence or atomic between them
— the adjacent bulk-move shape the pass exists for (#1129).
@ehartford

Copy link
Copy Markdown
Contributor Author

Battery verdict — green. Pinned seed nightly-20260925-local-1-607a52f543e7, cold c_import epoch, on f18fa0a: build ok, :fixpoint ok, :drop-audit ok, :move-audit ok, :test ok (1295 behavior incl. the new fixture, 1142 compile-error, 210 spec, 63 phase, 17 codegen, internals), :test-green ok, :last-green ok (published), :user-programs-safe ok. Logs: ~/.local/with-staging/into-iter-1689/out/logs/. Ready for merge (codegen change; alone in its batch).

@ehartford
ehartford marked this pull request as ready for review September 25, 2026 23:26
@ehartford
ehartford merged commit 6792d41 into main Sep 26, 2026
@ehartford
ehartford deleted the fix-into-iter-record-move branch September 26, 2026 01:32
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.

Vec.remove(0) returns the wrong element for 64-byte elements (POD too); into_iter inherits it

1 participant