-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #135204 - RalfJung:win64-zst, r=SparrowLii
fix handling of ZST in win64 ABI on windows-msvc targets The Microsoft calling conventions do not really say anything about ZST since they do not seem to exist in MSVC. However, both GCC and clang allow passing ZST over `__attribute__((ms_abi))` functions (which matches our `extern "win64" fn`) on `windows-gnu` targets, and therefore implicitly define a de-facto ABI for these types (and lucky enough they seem to define the same ABI). This ABI should be the same for windows-msvc and windows-gnu targets, so we use this as a hint for how to implement this ABI everywhere: we always pass ZST by-ref. The best alternative would be to just reject compiling functions which cannot exist in MSVC, but that would be a breaking change. Cc `@programmerjake` `@ChrisDenton` Fixes #132893
- Loading branch information
Showing
9 changed files
with
91 additions
and
271 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
//@ compile-flags: -Z merge-functions=disabled | ||
|
||
//@ revisions: windows-gnu | ||
//@[windows-gnu] compile-flags: --target x86_64-pc-windows-gnu | ||
//@[windows-gnu] needs-llvm-components: x86 | ||
|
||
//@ revisions: windows-msvc | ||
//@[windows-msvc] compile-flags: --target x86_64-pc-windows-msvc | ||
//@[windows-msvc] needs-llvm-components: x86 | ||
|
||
// Also test what happens when using a Windows ABI on Linux. | ||
//@ revisions: linux | ||
//@[linux] compile-flags: --target x86_64-unknown-linux-gnu | ||
//@[linux] needs-llvm-components: x86 | ||
|
||
#![feature(no_core, lang_items, rustc_attrs, abi_vectorcall)] | ||
#![no_core] | ||
#![crate_type = "lib"] | ||
|
||
#[lang = "sized"] | ||
trait Sized {} | ||
|
||
// Make sure the argument is always passed when explicitly requesting a Windows ABI. | ||
// Our goal here is to match clang: <https://clang.godbolt.org/z/Wr4jMWq3P>. | ||
|
||
// CHECK: define win64cc void @pass_zst_win64(ptr {{[^,]*}}) | ||
#[no_mangle] | ||
extern "win64" fn pass_zst_win64(_: ()) {} | ||
|
||
// CHECK: define x86_vectorcallcc void @pass_zst_vectorcall(ptr {{[^,]*}}) | ||
#[no_mangle] | ||
extern "vectorcall" fn pass_zst_vectorcall(_: ()) {} | ||
|
||
// windows-gnu: define void @pass_zst_fastcall(ptr {{[^,]*}}) | ||
// windows-msvc: define void @pass_zst_fastcall(ptr {{[^,]*}}) | ||
#[no_mangle] | ||
#[cfg(windows)] // "fastcall" is not valid on 64bit Linux | ||
extern "fastcall" fn pass_zst_fastcall(_: ()) {} | ||
|
||
// The sysv64 ABI ignores ZST. | ||
|
||
// CHECK: define x86_64_sysvcc void @pass_zst_sysv64() | ||
#[no_mangle] | ||
extern "sysv64" fn pass_zst_sysv64(_: ()) {} | ||
|
||
// For `extern "C"` functions, ZST are ignored on Linux put passed on Windows. | ||
|
||
// linux: define void @pass_zst_c() | ||
// windows-msvc: define void @pass_zst_c(ptr {{[^,]*}}) | ||
// windows-gnu: define void @pass_zst_c(ptr {{[^,]*}}) | ||
#[no_mangle] | ||
extern "C" fn pass_zst_c(_: ()) {} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.