|
1 | 1 | // compile-flags: -O -C no-prepopulate-passes
|
2 | 2 |
|
3 | 3 | #![crate_type = "lib"]
|
4 |
| -#![feature(rustc_attrs)] |
5 | 4 |
|
6 | 5 | use std::mem::MaybeUninit;
|
7 | 6 | use std::num::NonZeroU64;
|
8 | 7 | use std::marker::PhantomPinned;
|
| 8 | +use std::ptr::NonNull; |
9 | 9 |
|
10 | 10 | pub struct S {
|
11 | 11 | _field: [i32; 8],
|
@@ -138,11 +138,27 @@ pub fn indirect_struct(_: S) {
|
138 | 138 | pub fn borrowed_struct(_: &S) {
|
139 | 139 | }
|
140 | 140 |
|
| 141 | +// CHECK: @option_borrow({{i32\*|ptr}} noalias noundef readonly align 4 dereferenceable_or_null(4) %x) |
| 142 | +#[no_mangle] |
| 143 | +pub fn option_borrow(x: Option<&i32>) { |
| 144 | +} |
| 145 | + |
| 146 | +// CHECK: @option_borrow_mut({{i32\*|ptr}} noalias noundef align 4 dereferenceable_or_null(4) %x) |
| 147 | +#[no_mangle] |
| 148 | +pub fn option_borrow_mut(x: Option<&mut i32>) { |
| 149 | +} |
| 150 | + |
141 | 151 | // CHECK: @raw_struct({{%S\*|ptr}} noundef %_1)
|
142 | 152 | #[no_mangle]
|
143 | 153 | pub fn raw_struct(_: *const S) {
|
144 | 154 | }
|
145 | 155 |
|
| 156 | +// CHECK: @raw_option_nonnull_struct({{i32\*|ptr}} noundef %_1) |
| 157 | +#[no_mangle] |
| 158 | +pub fn raw_option_nonnull_struct(_: Option<NonNull<S>>) { |
| 159 | +} |
| 160 | + |
| 161 | + |
146 | 162 | // `Box` can get deallocated during execution of the function, so it should
|
147 | 163 | // not get `dereferenceable`.
|
148 | 164 | // CHECK: noundef nonnull align 4 {{i32\*|ptr}} @_box({{i32\*|ptr}} noalias noundef nonnull align 4 %x)
|
@@ -200,6 +216,16 @@ pub fn str(_: &[u8]) {
|
200 | 216 | pub fn trait_borrow(_: &dyn Drop) {
|
201 | 217 | }
|
202 | 218 |
|
| 219 | +// CHECK: @option_trait_borrow({{i8\*|ptr}} noundef align 1 %x.0, {{i8\*|ptr}} %x.1) |
| 220 | +#[no_mangle] |
| 221 | +pub fn option_trait_borrow(x: Option<&dyn Drop>) { |
| 222 | +} |
| 223 | + |
| 224 | +// CHECK: @option_trait_borrow_mut({{i8\*|ptr}} noundef align 1 %x.0, {{i8\*|ptr}} %x.1) |
| 225 | +#[no_mangle] |
| 226 | +pub fn option_trait_borrow_mut(x: Option<&mut dyn Drop>) { |
| 227 | +} |
| 228 | + |
203 | 229 | // CHECK: @trait_raw({{\{\}\*|ptr}} noundef %_1.0, {{.+}} noalias noundef readonly align {{.*}} dereferenceable({{.*}}) %_1.1)
|
204 | 230 | #[no_mangle]
|
205 | 231 | pub fn trait_raw(_: *const dyn Drop) {
|
|
0 commit comments