]>
Commit | Line | Data |
---|---|---|
62682a34 SL |
1 | // Copyright 2015 The Rust Project Developers. See the COPYRIGHT |
2 | // file at the top-level directory of this distribution and at | |
3 | // http://rust-lang.org/COPYRIGHT. | |
4 | // | |
5 | // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | |
6 | // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | |
7 | // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | |
8 | // option. This file may not be copied, modified, or distributed | |
9 | // except according to those terms. | |
10 | ||
11 | // compile-flags: -C no-prepopulate-passes | |
12 | ||
b039eaaf | 13 | #![crate_type = "lib"] |
54a0048b | 14 | #![feature(rustc_attrs)] |
b039eaaf | 15 | |
62682a34 SL |
16 | pub struct Bytes { |
17 | a: u8, | |
18 | b: u8, | |
19 | c: u8, | |
20 | d: u8, | |
21 | } | |
22 | ||
23 | // CHECK-LABEL: small_array_alignment | |
24 | // The array is stored as i32, but its alignment is lower, go with 1 byte to avoid target | |
25 | // dependent alignment | |
26 | #[no_mangle] | |
54a0048b SL |
27 | #[rustc_no_mir] // FIXME #27840 MIR has different codegen. |
28 | pub fn small_array_alignment(x: &mut [i8; 4], y: [i8; 4]) { | |
29 | // CHECK: [[VAR:%[0-9]+]] = bitcast [4 x i8]* %y to i32* | |
30 | // CHECK: store i32 %{{.*}}, i32* [[VAR]], align 1 | |
31 | *x = y; | |
62682a34 SL |
32 | } |
33 | ||
34 | // CHECK-LABEL: small_struct_alignment | |
35 | // The struct is stored as i32, but its alignment is lower, go with 1 byte to avoid target | |
36 | // dependent alignment | |
37 | #[no_mangle] | |
54a0048b SL |
38 | #[rustc_no_mir] // FIXME #27840 MIR has different codegen. |
39 | pub fn small_struct_alignment(x: &mut Bytes, y: Bytes) { | |
40 | // CHECK: [[VAR:%[0-9]+]] = bitcast %Bytes* %y to i32* | |
41 | // CHECK: store i32 %{{.*}}, i32* [[VAR]], align 1 | |
42 | *x = y; | |
62682a34 | 43 | } |