2015-05-24 16:07:52 +00:00
|
|
|
// compile-flags: -C no-prepopulate-passes
|
|
|
|
|
2015-09-15 21:22:16 +00:00
|
|
|
#![crate_type = "lib"]
|
|
|
|
|
2015-05-24 16:07:52 +00:00
|
|
|
pub struct Bytes {
|
|
|
|
a: u8,
|
|
|
|
b: u8,
|
|
|
|
c: u8,
|
|
|
|
d: u8,
|
|
|
|
}
|
|
|
|
|
|
|
|
// CHECK-LABEL: @borrow
|
|
|
|
#[no_mangle]
|
|
|
|
pub fn borrow(x: &i32) -> &i32 {
|
2015-08-11 21:46:32 +00:00
|
|
|
// CHECK: load {{(i32\*, )?}}i32** %x{{.*}}, !nonnull
|
2016-08-24 03:36:37 +00:00
|
|
|
&x; // keep variable in an alloca
|
2015-05-24 16:07:52 +00:00
|
|
|
x
|
|
|
|
}
|
|
|
|
|
|
|
|
// CHECK-LABEL: @_box
|
|
|
|
#[no_mangle]
|
|
|
|
pub fn _box(x: Box<i32>) -> i32 {
|
2015-08-11 21:46:32 +00:00
|
|
|
// CHECK: load {{(i32\*, )?}}i32** %x{{.*}}, !nonnull
|
2015-05-24 16:07:52 +00:00
|
|
|
*x
|
|
|
|
}
|
|
|
|
|
|
|
|
// CHECK-LABEL: small_array_alignment
|
|
|
|
// The array is loaded as i32, but its alignment is lower, go with 1 byte to avoid target
|
|
|
|
// dependent alignment
|
|
|
|
#[no_mangle]
|
|
|
|
pub fn small_array_alignment(x: [i8; 4]) -> [i8; 4] {
|
2015-08-11 21:46:32 +00:00
|
|
|
// CHECK: [[VAR:%[0-9]+]] = load {{(i32, )?}}i32* %{{.*}}, align 1
|
2015-05-24 16:07:52 +00:00
|
|
|
// CHECK: ret i32 [[VAR]]
|
|
|
|
x
|
|
|
|
}
|
|
|
|
|
|
|
|
// CHECK-LABEL: small_struct_alignment
|
|
|
|
// The struct is loaded as i32, but its alignment is lower, go with 1 byte to avoid target
|
|
|
|
// dependent alignment
|
|
|
|
#[no_mangle]
|
|
|
|
pub fn small_struct_alignment(x: Bytes) -> Bytes {
|
2015-08-11 21:46:32 +00:00
|
|
|
// CHECK: [[VAR:%[0-9]+]] = load {{(i32, )?}}i32* %{{.*}}, align 1
|
2015-05-24 16:07:52 +00:00
|
|
|
// CHECK: ret i32 [[VAR]]
|
|
|
|
x
|
|
|
|
}
|