rust/tests/codegen/issues/issue-107681-unwrap_unchecked.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

21 lines
454 B
Rust
Raw Normal View History

2024-08-02 22:18:00 -05:00
//@ compile-flags: -O
//@ min-llvm-version: 19
// Test for #107681.
// Make sure we don't create `br` or `select` instructions.
#![crate_type = "lib"]
use std::iter::Copied;
use std::slice::Iter;
#[no_mangle]
pub unsafe fn foo(x: &mut Copied<Iter<'_, u32>>) -> u32 {
// CHECK-LABEL: @foo(
// CHECK-NOT: br
// CHECK-NOT: select
// CHECK: [[RET:%.*]] = load i32, ptr
// CHECK-NEXT: ret i32 [[RET]]
x.next().unwrap_unchecked()
}