forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rust_for_linux: -Zreg-struct-return commandline flag for X86 (rust-la…
- Loading branch information
Showing
8 changed files
with
72 additions
and
4 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
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,53 @@ | ||
// Checks how `reg-struct-return` flag works with different calling conventions: | ||
// Return struct with 8/16/32/64 bit size will be converted into i8/i16/i32/i64 | ||
// (like abi_return_struct_as_int target spec). | ||
// x86 only. | ||
|
||
//@ compile-flags: --target i686-unknown-linux-gnu -Zreg-struct-return -O -C no-prepopulate-passes | ||
//@ needs-llvm-components: x86 | ||
|
||
#![crate_type = "lib"] | ||
|
||
pub mod tests { | ||
#[repr(C)] | ||
pub struct Foo { | ||
x: u32, | ||
y: u32, | ||
} | ||
// CHECK: i64 @f1(i32 inreg noundef %_1, i32 inreg noundef %_2) | ||
#[no_mangle] | ||
pub extern "fastcall" fn f1(x: u32, y: u32) -> Foo { | ||
Foo { x, y } | ||
} | ||
|
||
// reg-struct-return doesn't work for "Rust" calling conv | ||
// CHECK: { i32, i32 } @f2(i32 inreg noundef %_1, i32 inreg noundef %_2) | ||
#[no_mangle] | ||
pub extern "Rust" fn f2(x: u32, y: u32) -> Foo { | ||
Foo { x, y } | ||
} | ||
|
||
// CHECK: i64 @f3(i32 inreg noundef %_1, i32 inreg noundef %_2) | ||
#[no_mangle] | ||
pub extern "C" fn f3(x: u32, y: u32) -> Foo { | ||
Foo { x, y } | ||
} | ||
|
||
// CHECK: i64 @f4(i32 inreg noundef %_1, i32 inreg noundef %_2) | ||
#[no_mangle] | ||
pub extern "cdecl" fn f4(x: u32, y: u32) -> Foo { | ||
Foo { x, y } | ||
} | ||
|
||
// CHECK: i64 @f5(i32 inreg noundef %_1, i32 inreg noundef %_2) | ||
#[no_mangle] | ||
pub extern "stdcall" fn f5(x: u32, y: u32) -> Foo { | ||
Foo { x, y } | ||
} | ||
|
||
// CHECK: i64 @f6(i32 inreg noundef %_1, i32 inreg noundef %_2) | ||
#[no_mangle] | ||
pub extern "thiscall" fn f6(x: u32, y: u32) -> Foo { | ||
Foo { x, y } | ||
} | ||
} |