]> git.lizzy.rs Git - rust.git/blob - tests/codegen/layout-size-checks.rs
Rollup merge of #107555 - edward-shen:edward-shen/dup-trait-suggestion, r=compiler...
[rust.git] / tests / codegen / layout-size-checks.rs
1 // compile-flags: -O
2 // only-x86_64
3 // ignore-debug: the debug assertions get in the way
4
5 #![crate_type = "lib"]
6
7 use std::alloc::Layout;
8
9 type RGB48 = [u16; 3];
10
11 // CHECK-LABEL: @layout_array_rgb48
12 #[no_mangle]
13 pub fn layout_array_rgb48(n: usize) -> Layout {
14     // CHECK-NOT: llvm.umul.with.overflow.i64
15     // CHECK: icmp ugt i64 %n, 1537228672809129301
16     // CHECK-NOT: llvm.umul.with.overflow.i64
17     // CHECK: mul nuw nsw i64 %n, 6
18     // CHECK-NOT: llvm.umul.with.overflow.i64
19     Layout::array::<RGB48>(n).unwrap()
20 }
21
22 // CHECK-LABEL: @layout_array_i32
23 #[no_mangle]
24 pub fn layout_array_i32(n: usize) -> Layout {
25     // CHECK-NOT: llvm.umul.with.overflow.i64
26     // CHECK: icmp ugt i64 %n, 2305843009213693951
27     // CHECK-NOT: llvm.umul.with.overflow.i64
28     // CHECK: shl nuw nsw i64 %n, 2
29     // CHECK-NOT: llvm.umul.with.overflow.i64
30     Layout::array::<i32>(n).unwrap()
31 }