Skip to content

Commit 39a69a9

Browse files
committed
vectorcall should also ignore ZST
1 parent 7661923 commit 39a69a9

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

compiler/rustc_target/src/callconv/x86_win64.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,12 @@ pub(crate) fn compute_abi_info<Ty>(cx: &impl HasTargetSpec, fn_abi: &mut FnAbi<'
4242
}
4343
for arg in fn_abi.args.iter_mut() {
4444
if arg.is_ignore() {
45-
// x86_64-pc-windows-gnu doesn't ignore ZSTs -- except in `extern "win64"`
46-
// functions which are supposed to match MSVC.
45+
// x86_64-pc-windows-gnu doesn't ignore ZSTs for their native "C" ABI.
46+
// However, other special ABIs ("win64", "fastcall", etc) should match MSVC behavior.
4747
if cx.target_spec().os == "windows"
4848
&& cx.target_spec().env == "gnu"
4949
&& arg.layout.is_zst()
50-
&& fn_abi.conv != Conv::X86_64Win64
50+
&& fn_abi.conv == Conv::C
5151
{
5252
arg.make_indirect_from_ignore();
5353
}

tests/codegen/abi-win64-zst.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
//@[windows-msvc] compile-flags: --target x86_64-pc-windows-msvc
1111
//@[windows-msvc] needs-llvm-components: x86
1212

13-
#![feature(no_core, lang_items, rustc_attrs)]
13+
#![feature(no_core, lang_items, rustc_attrs, abi_vectorcall)]
1414
#![no_core]
1515
#![crate_type = "lib"]
1616

@@ -27,6 +27,10 @@ extern "win64" fn pass_zst_win64(_: ()) {}
2727
#[no_mangle]
2828
extern "sysv64" fn pass_zst_sysv64(_: ()) {}
2929

30+
// CHECK: define x86_vectorcallcc void @pass_zst_vectorcall()
31+
#[no_mangle]
32+
extern "vectorcall" fn pass_zst_vectorcall(_: ()) {}
33+
3034
// For `extern "C"` functions, ZST are *not* ignored on windows-gnu.
3135
// That's likely an accident on their side but the ABI is what it is.
3236

0 commit comments

Comments
 (0)