From 7d967ffa8df2ae74e4cff5d5ed7b53adedac00a2 Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Mon, 20 May 2024 19:52:30 +0000 Subject: [PATCH] add codegen test for #109328 --- .../codegen/issues/issue-109328-split_first.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 tests/codegen/issues/issue-109328-split_first.rs diff --git a/tests/codegen/issues/issue-109328-split_first.rs b/tests/codegen/issues/issue-109328-split_first.rs new file mode 100644 index 0000000000000..a43e653e1a264 --- /dev/null +++ b/tests/codegen/issues/issue-109328-split_first.rs @@ -0,0 +1,17 @@ +//@ compile-flags: -O +//@ min-llvm-version: 17 + +#![crate_type = "lib"] + +#[no_mangle] +// CHECK-LABEL: @foo +// CHECK: getelementptr inbounds +// CHECK-NEXT: load i64 +// CHECK-NEXT: icmp eq i64 +// CHECK-NEXT: br i1 +#[no_mangle] +pub fn foo(input: &mut &[u64]) -> Option { + let (first, rest) = input.split_first()?; + *input = rest; + Some(*first) +}