diff options
| author | bors <bors@rust-lang.org> | 2023-08-28 15:30:28 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-08-28 15:30:28 +0000 |
| commit | 9f48a8544799c65a597302886d5143456fcb340f (patch) | |
| tree | 44994b0a18d36cc7eb20e59e5e0532cc77759f7b | |
| parent | c587fd418521c841f8683c58872293475b8d9b3b (diff) | |
| parent | d88c80f5de09d62a5c5d726274e3362a6c4f8ddd (diff) | |
| download | rust-9f48a8544799c65a597302886d5143456fcb340f.tar.gz rust-9f48a8544799c65a597302886d5143456fcb340f.zip | |
Auto merge of #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 https://github.com/rust-lang/rust/issues/107436#issuecomment-1685792517 (It seems like this works from llvm-16?) Fixes #107436
| -rw-r--r-- | tests/codegen/move-before-nocapture-ref-arg.rs | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/codegen/move-before-nocapture-ref-arg.rs b/tests/codegen/move-before-nocapture-ref-arg.rs new file mode 100644 index 00000000000..c7b400c8f8d --- /dev/null +++ b/tests/codegen/move-before-nocapture-ref-arg.rs @@ -0,0 +1,22 @@ +// Verify that move before the call of the function with noalias, nocapture, readonly. +// #107436 +// compile-flags: -O +// min-llvm-version: 17 + +#![crate_type = "lib"] + +#[repr(C)] +pub struct ThreeSlices<'a>(&'a [u32], &'a [u32], &'a [u32]); + +#[no_mangle] +pub fn sum_slices(val: ThreeSlices) -> u32 { + // CHECK-NOT: memcpy + let val = val; + sum(&val) +} + +#[no_mangle] +#[inline(never)] +pub fn sum(val: &ThreeSlices) -> u32 { + val.0.iter().sum::<u32>() + val.1.iter().sum::<u32>() + val.2.iter().sum::<u32>() +} |
