Repository navigation
Merged
Conversation
…never the name looked up again (#2723) MirLower took a plain call's signature from Sema's resolved_call_sigs when there was one, else resolved the callee's name again (call_sig_for_sym -> Sema.get_sig). Sema recorded the resolution only for method calls, and get_sig answers relative to Sema's current module, which during MIR lowering is whatever module it checked last, not the caller's. On Windows the runtime declares Winsock's `extern fn accept(s: i64, addr, addrlen)`, so a program's own `fn accept(value: G)` was lowered against the extern's signature: the argument became `copy _2` (an i64 parameter consumes nothing) and the caller dropped `_2` after accept had dropped it. `analyze` on --target=windows_x86_64 showed `accept copy copy _2` against darwin's `move move _2`, and sig 938 (the extern, 3 parameters) beside sig 940. The argument's ownership was decided the same way: lower_call_arg asks extern_param_is_bit_copy (MirLower.w 12969), which judged by the flat symbol (`extern_fn_names.contains(fn_sym)`), so with sig 940 resolved the argument was still re-issued as `copy _2`; it now returns 0 for a signature that is not an extern's (extern_sig_modules). check_call also records the signature it resolved for every direct call, so MirLower reads Sema's answer (D65: one owner for the call target). da_generic_call_results failed on Windows for this reason. Test: test/behavior/behav_2723_call_lowers_against_sema_signature.w (prints "2 3 5" on Windows before the fix, "1 2 3" after).
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.
MirLower took a plain call's signature from Sema's resolved_call_sigs when
there was one, else resolved the callee's name again (call_sig_for_sym ->
Sema.get_sig). Sema recorded the resolution only for method calls, and
get_sig answers relative to Sema's current module, which during MIR lowering
is whatever module it checked last, not the caller's. On Windows the runtime
declares Winsock's
extern fn accept(s: i64, addr, addrlen), so a program'sown
fn accept(value: G)was lowered against the extern's signature: theargument became
copy _2(an i64 parameter consumes nothing) and thecaller dropped
_2after accept had dropped it.analyzeon--target=windows_x86_64 showed
accept copy copy _2against darwin'smove move _2, and sig 938 (the extern, 3 parameters) beside sig 940.The argument's ownership was decided the same way: lower_call_arg asks
extern_param_is_bit_copy (MirLower.w 12969), which judged by the flat
symbol (
extern_fn_names.contains(fn_sym)), so with sig 940 resolved theargument was still re-issued as
copy _2; it now returns 0 for asignature that is not an extern's (extern_sig_modules). check_call also
records the signature it resolved for every direct call,
so MirLower reads Sema's answer (D65: one owner for the call target).
da_generic_call_results failed on Windows for this reason.
Test: test/behavior/behav_2723_call_lowers_against_sema_signature.w
(prints "2 3 5" on Windows before the fix, "1 2 3" after).
Closes #2723