-
Notifications
You must be signed in to change notification settings - Fork 13k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Windows x86: Change i128 to return via the vector ABI #134290
base: master
Are you sure you want to change the base?
Conversation
r? @SparrowLii rustbot has assigned @SparrowLii. Use |
This should make us consistent for now, even if Clang isn't yet doing the best thing on MSVC. The third commit's diff shows how the tests change. |
@bors try |
Windows x86: Change i128 to return via the vector ABI Clang and GCC both return `i128` in xmm0 on windows-msvc and windows-gnu. Currently, Rust returns the type on the stack. Add a calling convention adjustment so we also return scalar `i128`s using the vector ABI, which makes our `i128` compatible with C. In the future, Clang may change to return `i128` on the stack for its `-msvc` targets (more at [1]). If this happens, the change here will need to be adjusted to only affect MinGW. Link: rust-lang#134288 (does not fix) try-job: x86_64-msvc try-job: x86_64-msvc-ext1 try-job: x86_64-mingw-1 try-job: x86_64-mingw-2
This comment has been minimized.
This comment has been minimized.
💔 Test failed - checks-actions |
I validated the codegen on a non-windows machine - it looks like the default filecheck labels get applied based on the host rather than the target? That’s interesting. |
Please double check that this doesn't break ABI compat between cg_llvm and cg_clif. And
|
That link looks to be for libcalls but those have to already be correct on cranelift, right? We have a hack to use Clang/GCC's return ABI in builtins https://github.com/rust-lang/compiler-builtins/blob/a09218f1c4d23ffbd97d68f0fefb5feed2469dc5/src/macros.rs#L583C9-L583C30. What is the best way to verify Cranelift's ABI? If asm tests can run with both backends then I can add that (also does this get covered in one of the CI jobs?) |
__rust_i128_mulo and __rust_u128_mulo do change ABI with this PR:
Adjusting the lib_call function directly would also allow getting rid of the if condition at
|
I don't think these should change since they return an aggregate type https://github.com/rust-lang/compiler-builtins/blob/a09218f1c4d23ffbd97d68f0fefb5feed2469dc5/src/int/mul.rs#L131, and the change here is only for scalars. Testing with this PR the IR signature for that is: define void @__rust_i128_mulo(ptr dead_on_unwind noalias nocapture noundef writable writeonly sret([32 x i8]) align 16 dereferenceable(32) %_0, ptr noalias nocapture noundef readonly align 16 dereferenceable(16) %a, ptr noalias nocapture noundef readonly align 16 dereferenceable(16) %b) unnamed_addr #0` I can make the adjustments to |
huh, why do we rely on certain tuples having a fixed meaning in the C ABI? |
Good question :) Maybe those should change to a C-like |
706db2b
to
d5bc586
Compare
@bors try |
@bors ping |
😪 I'm awake I'm awake |
Windows x86: Change i128 to return via the vector ABI Clang and GCC both return `i128` in xmm0 on windows-msvc and windows-gnu. Currently, Rust returns the type on the stack. Add a calling convention adjustment so we also return scalar `i128`s using the vector ABI, which makes our `i128` compatible with C. In the future, Clang may change to return `i128` on the stack for its `-msvc` targets (more at [1]). If this happens, the change here will need to be adjusted to only affect MinGW. Link: rust-lang#134288 (does not fix) try-job: x86_64-msvc try-job: x86_64-msvc-ext1 try-job: x86_64-mingw-1 try-job: x86_64-mingw-2
☀️ Try build successful - checks-actions |
@bjorn3 I saw the mention in the abi-cafe issue, are you able to double check the cranelift changes here? |
I don't have a Windows machine to test it on locally. Also I assumed that the |
Oh, I was thinking they had to land the other way around. I’ll get that one ready to go then, but unfortunately updating compiler-builtins in r-l/rust is temporarily blocked on something like #13527 (or me reverting the libm submodule updates so the diagnostics don’t show up, but I’m hoping to not need that). |
I think you missed a digit in the issue number. |
Sorry, #135278 to fix new |
Currently we both pass and return `i128` indirectly on Windows for MSVC and MinGW, but this will be adjusted. Introduce a test verifying the current state.
3557d39
to
6acd4e6
Compare
The @bors try |
Windows x86: Change i128 to return via the vector ABI Clang and GCC both return `i128` in xmm0 on windows-msvc and windows-gnu. Currently, Rust returns the type on the stack. Add a calling convention adjustment so we also return scalar `i128`s using the vector ABI, which makes our `i128` compatible with C. In the future, Clang may change to return `i128` on the stack for its `-msvc` targets (more at [1]). If this happens, the change here will need to be adjusted to only affect MinGW. Link: rust-lang#134288 (does not fix) [1] try-job: x86_64-msvc try-job: x86_64-msvc-ext1 try-job: x86_64-mingw-1 try-job: x86_64-mingw-2
☀️ Try build successful - checks-actions |
@bjorn3 what exactly needs to happen in the cg_cranelift repo to test this? I don't see any obvious point that the toolchain should be changed. Also unsure whether I should have run a dist job. |
Clang and GCC both return `i128` in xmm0 on windows-msvc and windows-gnu. Currently, Rust returns the type on the stack. Add a calling convention adjustment so we also return scalar `i128`s using the vector ABI, which makes our `i128` compatible with C. In the future, Clang may change to return `i128` on the stack for its `-msvc` targets (more at [1]). If this happens, the change here will need to be adjusted to only affect MinGW. Link: rust-lang#134288
6f893f9
to
2f13d43
Compare
…bjorn3,wesleywiser Windows x86: Change i128 to return via the vector ABI Clang and GCC both return `i128` in xmm0 on windows-msvc and windows-gnu. Currently, Rust returns the type on the stack. Add a calling convention adjustment so we also return scalar `i128`s using the vector ABI, which makes our `i128` compatible with C. In the future, Clang may change to return `i128` on the stack for its `-msvc` targets (more at [1]). If this happens, the change here will need to be adjusted to only affect MinGW. Link: rust-lang#134288 (does not fix) [1] try-job: x86_64-msvc try-job: x86_64-msvc-ext1 try-job: x86_64-mingw-1 try-job: x86_64-mingw-2
…iaskrgr Rollup of 7 pull requests Successful merges: - rust-lang#131806 (Treat other items as functions for the purpose of type-based search) - rust-lang#134290 (Windows x86: Change i128 to return via the vector ABI) - rust-lang#134980 (Location-sensitive polonius prototype: endgame) - rust-lang#135558 (Detect if-else chains with a missing final else in type errors) - rust-lang#135594 (fix error for when results in a rustdoc-js test are in the wrong order) - rust-lang#135601 (Fix suggestion to convert dereference of raw pointer to ref) - rust-lang#135604 (Expand docs for `E0207` with additional example) r? `@ghost` `@rustbot` modify labels: rollup
@bors r- rollup=iffy |
Clang and GCC both return
i128
in xmm0 on windows-msvc and windows-gnu. Currently, Rust returns the type on the stack. Add a calling convention adjustment so we also return scalari128
s using the vector ABI, which makes ouri128
compatible with C.In the future, Clang may change to return
i128
on the stack for its-msvc
targets (more at [1]). If this happens, the change here will need to be adjusted to only affect MinGW.Link: #134288 (does not fix) [1]
try-job: x86_64-msvc
try-job: x86_64-msvc-ext1
try-job: x86_64-mingw-1
try-job: x86_64-mingw-2