]> git.lizzy.rs Git - rust.git/blob - tests/codegen/nrvo.rs
Rollup merge of #106470 - ehuss:tidy-no-wasm, r=Mark-Simulacrum
[rust.git] / tests / codegen / nrvo.rs
1 // compile-flags: -O
2
3 #![crate_type = "lib"]
4
5 // Ensure that we do not call `memcpy` for the following function.
6 // `memset` and `init` should be called directly on the return pointer.
7 #[no_mangle]
8 pub fn nrvo(init: fn(&mut [u8; 4096])) -> [u8; 4096] {
9     // CHECK-LABEL: nrvo
10     // CHECK: @llvm.memset
11     // CHECK-NOT: @llvm.memcpy
12     // CHECK: ret
13     // CHECK-EMPTY
14     let mut buf = [0; 4096];
15     init(&mut buf);
16     buf
17 }