Skip to content

Commit 8af71d2

Browse files
committed
add a codegen-llvm test for ManuallyDrop
1 parent babf188 commit 8af71d2

1 file changed

Lines changed: 43 additions & 0 deletions

File tree

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// This test checks for absence of noalias and dereferenceable attributes on
2+
// arguments wrapped in `ManuallyDrop`.
3+
//
4+
//@ compile-flags: -Copt-level=3 -Zmerge-functions=disabled
5+
#![crate_type = "lib"]
6+
7+
use std::mem::ManuallyDrop;
8+
9+
// CHECK: define {{(dso_local )?}}noundef nonnull ptr @f(ptr noalias noundef nonnull readnone returned {{(captures\(ret: address, provenance\))?}} %x) unnamed_addr
10+
#[no_mangle]
11+
pub fn f(x: ManuallyDrop<Box<u8>>) -> ManuallyDrop<Box<u8>> {
12+
x
13+
}
14+
15+
// CHECK: define {{(dso_local )?}}noundef nonnull ptr @g(ptr noalias noundef readonly returned {{(captures\(ret: address, read_provenance\))?}} dereferenceable(1) %x) unnamed_addr
16+
#[no_mangle]
17+
pub fn g(x: ManuallyDrop<&u8>) -> ManuallyDrop<&u8> {
18+
x
19+
}
20+
21+
// CHECK: define {{(dso_local )?}}noundef nonnull ptr @h(ptr noalias noundef readnone returned {{(captures\(ret: address, provenance\))?}} dereferenceable(1) %x) unnamed_addr
22+
#[no_mangle]
23+
pub fn h(x: ManuallyDrop<&mut u8>) -> ManuallyDrop<&mut u8> {
24+
x
25+
}
26+
27+
// CHECK: define {{(dso_local )?}}noundef nonnull align 4 ptr @i(ptr noalias noundef nonnull readnone returned align 4 {{(captures\(ret: address, provenance\))?}} %x) unnamed_addr
28+
#[no_mangle]
29+
pub fn i(x: ManuallyDrop<Box<u32>>) -> ManuallyDrop<Box<u32>> {
30+
x
31+
}
32+
33+
// CHECK: define {{(dso_local )?}}noundef nonnull align 4 ptr @j(ptr noalias noundef readonly returned align 4 {{(captures\(ret: address, read_provenance\))?}} dereferenceable(4) %x) unnamed_addr
34+
#[no_mangle]
35+
pub fn j(x: ManuallyDrop<&u32>) -> ManuallyDrop<&u32> {
36+
x
37+
}
38+
39+
// CHECK: define {{(dso_local )?}}noundef nonnull align 4 ptr @k(ptr noalias noundef readnone returned align 4 {{(captures\(ret: address, provenance\))?}} dereferenceable(4) %x) unnamed_addr
40+
#[no_mangle]
41+
pub fn k(x: ManuallyDrop<&mut u32>) -> ManuallyDrop<&mut u32> {
42+
x
43+
}

0 commit comments

Comments
 (0)