-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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 (#116973)
- Loading branch information
Showing
8 changed files
with
83 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,64 @@ | ||
// 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"] | ||
#![no_std] | ||
#![no_core] | ||
#![feature(no_core, lang_items)] | ||
|
||
#[lang = "sized"] | ||
trait Sized {} | ||
#[lang = "copy"] | ||
trait Copy {} | ||
|
||
#[repr(C)] | ||
pub struct Foo { | ||
x: u32, | ||
y: u32, | ||
} | ||
|
||
pub mod tests { | ||
use Foo; | ||
|
||
// CHECK: i64 @f1() | ||
#[no_mangle] | ||
pub extern "fastcall" fn f1() -> Foo { | ||
Foo { x: 1, y: 2 } | ||
} | ||
|
||
// reg-struct-return doesn't work for "Rust" calling conv | ||
// CHECK: { i32, i32 } @f2() | ||
#[no_mangle] | ||
pub extern "Rust" fn f2() -> Foo { | ||
Foo { x: 1, y: 2 } | ||
} | ||
|
||
// CHECK: i64 @f3() | ||
#[no_mangle] | ||
pub extern "C" fn f3() -> Foo { | ||
Foo { x: 1, y: 2 } | ||
} | ||
|
||
// CHECK: i64 @f4() | ||
#[no_mangle] | ||
pub extern "cdecl" fn f4() -> Foo { | ||
Foo { x: 1, y: 2 } | ||
} | ||
|
||
// CHECK: i64 @f5() | ||
#[no_mangle] | ||
pub extern "stdcall" fn f5() -> Foo { | ||
Foo { x: 1, y: 2 } | ||
} | ||
|
||
// CHECK: i64 @f6() | ||
#[no_mangle] | ||
pub extern "thiscall" fn f6() -> Foo { | ||
Foo { x: 1, y: 2 } | ||
} | ||
} |