]> git.lizzy.rs Git - rust.git/blob - tests/codegen/issue-37945.rs
Rollup merge of #107769 - compiler-errors:pointer-like, r=eholk
[rust.git] / tests / codegen / issue-37945.rs
1 // compile-flags: -O -Zmerge-functions=disabled
2 // ignore-x86
3 // ignore-arm
4 // ignore-emscripten
5 // ignore-gnux32
6 // ignore 32-bit platforms (LLVM has a bug with them)
7
8 // Check that LLVM understands that `Iter` pointer is not null. Issue #37945.
9
10 #![crate_type = "lib"]
11
12 use std::slice::Iter;
13
14 #[no_mangle]
15 pub fn is_empty_1(xs: Iter<f32>) -> bool {
16 // CHECK-LABEL: @is_empty_1(
17 // CHECK-NEXT:  start:
18 // CHECK-NEXT:    [[A:%.*]] = icmp ne {{i32\*|ptr}} {{%xs.0|%xs.1}}, null
19 // CHECK-NEXT:    tail call void @llvm.assume(i1 [[A]])
20 // The order between %xs.0 and %xs.1 on the next line doesn't matter
21 // and different LLVM versions produce different order.
22 // CHECK-NEXT:    [[B:%.*]] = icmp eq {{i32\*|ptr}} {{%xs.0, %xs.1|%xs.1, %xs.0}}
23 // CHECK-NEXT:    ret i1 [[B:%.*]]
24     {xs}.next().is_none()
25 }
26
27 #[no_mangle]
28 pub fn is_empty_2(xs: Iter<f32>) -> bool {
29 // CHECK-LABEL: @is_empty_2
30 // CHECK-NEXT:  start:
31 // CHECK-NEXT:    [[C:%.*]] = icmp ne {{i32\*|ptr}} {{%xs.0|%xs.1}}, null
32 // CHECK-NEXT:    tail call void @llvm.assume(i1 [[C]])
33 // The order between %xs.0 and %xs.1 on the next line doesn't matter
34 // and different LLVM versions produce different order.
35 // CHECK-NEXT:    [[D:%.*]] = icmp eq {{i32\*|ptr}} {{%xs.0, %xs.1|%xs.1, %xs.0}}
36 // CHECK-NEXT:    ret i1 [[D:%.*]]
37     xs.map(|&x| x).next().is_none()
38 }