Skip to content

Commit cbf3b24

Browse files
committed
Add test for #98294
Add a test to make that the failure condition for this pattern is optimized away. Fixes #98294.
1 parent 406e03f commit cbf3b24

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// min-llvm-version: 15.0.0
2+
// ignore-debug: The debug assertions get in the way
3+
// compile-flags: -O
4+
5+
#![crate_type = "lib"]
6+
7+
// There should be no calls to panic / len_mismatch_fail.
8+
9+
#[no_mangle]
10+
pub fn test(a: &mut [u8], offset: usize, bytes: &[u8]) {
11+
// CHECK-LABEL: @test(
12+
// CHECK-NOT: call
13+
// CHECK: call void @llvm.memcpy
14+
// CHECK-NOT: call
15+
// CHECK: }
16+
if let Some(dst) = a.get_mut(offset..offset + bytes.len()) {
17+
dst.copy_from_slice(bytes);
18+
}
19+
}

0 commit comments

Comments
 (0)