Skip to content

Commit 8a527ee

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 0631ea5 commit 8a527ee

File tree

1 file changed

+18
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)