Repository navigation
codegen(win64): sret-lower collect[String] runtime call (#806) - #822
Merged
ropoctl merged 3 commits intoAug 18, 2026
Merged
Conversation
ropoctl
force-pushed
the
windows-806-collect-string
branch
from
August 18, 2026 01:16
df30c13 to
9ab35c3
Compare
ropoctl
force-pushed
the
windows-806-collect-string
branch
from
August 18, 2026 02:24
9ab35c3 to
10f1060
Compare
mir_emit_iter_collect hand-rolled a direct-return LLVM signature for the with_str_from_vec_u8 runtime call — `declare %str @with_str_from_vec_u8(ptr)` called as `%v = call %str ...`. On win64 a 16-byte str is returned via sret (hidden pointer first arg), so the callee prologue and every other call site lower it as `void @with_str_from_vec_u8(ptr sret(%str), ptr)`. The collect site was the single divergent caller: it read a 16-byte value out of a function that writes through an sret pointer, so collect[String] produced a corrupt str and the spec test exited non-zero on native Windows. Route the call through the single FnAbi path instead of a per-site ABI guess (D6): declare the callee sret-aware via internal_abi_needs_sret + wl_add_sret_attr + record_c_abi_transform, then call through build_call_fn_value, which allocates the sret slot and loads the result. Gated on internal_abi_needs_sret, so SysV (16B in RAX:RDX) is unchanged. Verified: win64 IR collect site becomes `call void @with_str_from_vec_u8(ptr sret(%str) %slot, ptr)`, matching the callee and sibling calls; linux IR stays direct-return. Cross-built and run on the real Windows VM: collect[String] repro and spec_ss13_3_collect_targets (all six targets) both print ok.
The collect[String] sret fix makes all six collect targets (Vec/HashSet/HashMap/BTreeSet/BTreeMap/String) produce correct output on native Windows. Verified on the real VM: the cross-built test prints ok. Remove the skip-windows gate.
ropoctl
force-pushed
the
windows-806-collect-string
branch
from
August 18, 2026 02:58
10f1060 to
a9cd505
Compare
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.
Problem
collect[String]produced corrupt output on win64 (exit 5/1).mir_emit_iter_collecthand-rolled a direct-return signature for thewith_str_from_vec_u8runtime call, but win64 returns a 16-bytestraggregate via sret (hidden pointer first param). This is exactly the per-path ABI divergence D6 forbids: one call site re-derivedvalue vs sretlocally instead of reading the singleFnAbi/build_call_fn_valuepath.Fix
Route the
with_str_from_vec_u8call throughinternal_abi_needs_sret+record_c_abi_transform+build_call_fn_value— the same single sret-aware path every other call uses. No per-path ABI decision remains.Verification
call %str @with_str_from_vec_u8(ptr %v)(direct)call void @with_str_from_vec_u8(ptr sret(%str) %out, ptr %v)— matches callee prologue and sibling call sitesct_string.exe→ ok EXIT=0;ct_collect_targets.exe→ ok EXIT=0 (all 6 collect targets: Vec/HashSet/HashMap/BTreeSet/BTreeMap/String)test/spec/spec_ss13_3_collect_targets.won WindowsStacked on #821 (windows-806-combinator-indirect).