]> git.proxmox.com Git - rustc.git/blame - src/test/codegen/function-arguments-noopt.rs
New upstream version 1.63.0+dfsg1
[rustc.git] / src / test / codegen / function-arguments-noopt.rs
CommitLineData
5e7ed085
FG
1// compile-flags: -C opt-level=0 -C no-prepopulate-passes
2
3// This test checks that arguments/returns in opt-level=0 builds,
4// while lacking attributes used for optimization, still have ABI-affecting attributes.
5
6#![crate_type = "lib"]
7#![feature(rustc_attrs)]
8
9pub struct S {
10 _field: [i32; 8],
11}
12
13// CHECK: zeroext i1 @boolean(i1 zeroext %x)
14#[no_mangle]
15pub fn boolean(x: bool) -> bool {
16 x
17}
18
19// CHECK-LABEL: @boolean_call
20#[no_mangle]
21pub fn boolean_call(x: bool, f: fn(bool) -> bool) -> bool {
22// CHECK: call zeroext i1 %f(i1 zeroext %x)
23 f(x)
24}
25
923072b8 26// CHECK: align 4 {{i32\*|ptr}} @borrow({{i32\*|ptr}} align 4 %x)
5e7ed085
FG
27#[no_mangle]
28pub fn borrow(x: &i32) -> &i32 {
29 x
30}
31
32// CHECK-LABEL: @borrow_call
33#[no_mangle]
34pub fn borrow_call(x: &i32, f: fn(&i32) -> &i32) -> &i32 {
923072b8 35 // CHECK: call align 4 {{i32\*|ptr}} %f({{i32\*|ptr}} align 4 %x)
5e7ed085
FG
36 f(x)
37}
38
923072b8 39// CHECK: void @struct_({{%S\*|ptr}} sret(%S){{( %0)?}}, {{%S\*|ptr}} %x)
5e7ed085
FG
40#[no_mangle]
41pub fn struct_(x: S) -> S {
42 x
43}
44
45// CHECK-LABEL: @struct_call
46#[no_mangle]
47pub fn struct_call(x: S, f: fn(S) -> S) -> S {
923072b8 48 // CHECK: call void %f({{%S\*|ptr}} sret(%S){{( %0)?}}, {{%S\*|ptr}} %{{.+}})
5e7ed085
FG
49 f(x)
50}
51
52// CHECK: { i8, i8 } @enum_(i1 zeroext %x.0, i8 %x.1)
53#[no_mangle]
54pub fn enum_(x: Option<u8>) -> Option<u8> {
55 x
56}
57
58// CHECK-LABEL: @enum_call
59#[no_mangle]
60pub fn enum_call(x: Option<u8>, f: fn(Option<u8>) -> Option<u8>) -> Option<u8> {
61 // CHECK: call { i8, i8 } %f(i1 zeroext %x.0, i8 %x.1)
62 f(x)
63}