Skip to content

Commit 9f48a85

Browse files
committed
Auto merge of rust-lang#115050 - khei4:khei4/codegen-move-before-nocapture, r=nikic
add codegen test for the move before passing to nocapture, by shared-ref arg This PR adds codegen test for rust-lang#107436 (comment) (It seems like this works from llvm-16?) Fixes rust-lang#107436
2 parents c587fd4 + d88c80f commit 9f48a85

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

Diff for: tests/codegen/move-before-nocapture-ref-arg.rs

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Verify that move before the call of the function with noalias, nocapture, readonly.
2+
// #107436
3+
// compile-flags: -O
4+
// min-llvm-version: 17
5+
6+
#![crate_type = "lib"]
7+
8+
#[repr(C)]
9+
pub struct ThreeSlices<'a>(&'a [u32], &'a [u32], &'a [u32]);
10+
11+
#[no_mangle]
12+
pub fn sum_slices(val: ThreeSlices) -> u32 {
13+
// CHECK-NOT: memcpy
14+
let val = val;
15+
sum(&val)
16+
}
17+
18+
#[no_mangle]
19+
#[inline(never)]
20+
pub fn sum(val: &ThreeSlices) -> u32 {
21+
val.0.iter().sum::<u32>() + val.1.iter().sum::<u32>() + val.2.iter().sum::<u32>()
22+
}

0 commit comments

Comments
 (0)