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 ] ,
@@ -61,7 +61,7 @@ pub fn maybeuninit_char(x: MaybeUninit<char>) -> MaybeUninit<char> {
61
61
x
62
62
}
63
63
64
- // CHECK: i64 @int(i64 %x)
64
+ // CHECK: noundef i64 @int(i64 noundef %x)
65
65
#[ no_mangle]
66
66
pub fn int ( x : u64 ) -> u64 {
67
67
x
@@ -73,7 +73,7 @@ pub fn nonzero_int(x: NonZeroU64) -> NonZeroU64 {
73
73
x
74
74
}
75
75
76
- // CHECK: i64 @option_nonzero_int(i64 %x)
76
+ // CHECK: noundef i64 @option_nonzero_int(i64 noundef %x)
77
77
#[ no_mangle]
78
78
pub fn option_nonzero_int ( x : Option < NonZeroU64 > ) -> Option < NonZeroU64 > {
79
79
x
@@ -138,11 +138,27 @@ pub fn indirect_struct(_: S) {
138
138
pub fn borrowed_struct ( _: & S ) {
139
139
}
140
140
141
- // CHECK: @raw_struct({{%S\*|ptr}} %_1)
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
+
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)
@@ -160,35 +176,35 @@ pub fn struct_return() -> S {
160
176
}
161
177
162
178
// Hack to get the correct size for the length part in slices
163
- // CHECK: @helper([[USIZE:i[0-9]+]] %_1)
179
+ // CHECK: @helper([[USIZE:i[0-9]+]] noundef %_1)
164
180
#[ no_mangle]
165
181
pub fn helper ( _: usize ) {
166
182
}
167
183
168
- // CHECK: @slice({{\[0 x i8\]\*|ptr}} noalias noundef nonnull readonly align 1 %_1.0, [[USIZE]] %_1.1)
184
+ // CHECK: @slice({{\[0 x i8\]\*|ptr}} noalias noundef nonnull readonly align 1 %_1.0, [[USIZE]] noundef %_1.1)
169
185
// FIXME #25759 This should also have `nocapture`
170
186
#[ no_mangle]
171
187
pub fn slice ( _: & [ u8 ] ) {
172
188
}
173
189
174
- // CHECK: @mutable_slice({{\[0 x i8\]\*|ptr}} noalias noundef nonnull align 1 %_1.0, [[USIZE]] %_1.1)
190
+ // CHECK: @mutable_slice({{\[0 x i8\]\*|ptr}} noalias noundef nonnull align 1 %_1.0, [[USIZE]] noundef %_1.1)
175
191
// FIXME #25759 This should also have `nocapture`
176
192
#[ no_mangle]
177
193
pub fn mutable_slice ( _: & mut [ u8 ] ) {
178
194
}
179
195
180
- // CHECK: @unsafe_slice({{\[0 x i16\]\*|ptr}} noundef nonnull align 2 %_1.0, [[USIZE]] %_1.1)
196
+ // CHECK: @unsafe_slice({{\[0 x i16\]\*|ptr}} noundef nonnull align 2 %_1.0, [[USIZE]] noundef %_1.1)
181
197
// unsafe interior means this isn't actually readonly and there may be aliases ...
182
198
#[ no_mangle]
183
199
pub fn unsafe_slice ( _: & [ UnsafeInner ] ) {
184
200
}
185
201
186
- // CHECK: @raw_slice({{\[0 x i8\]\*|ptr}} %_1.0, [[USIZE]] %_1.1)
202
+ // CHECK: @raw_slice({{\[0 x i8\]\*|ptr}} noundef %_1.0, [[USIZE]] noundef %_1.1)
187
203
#[ no_mangle]
188
204
pub fn raw_slice ( _: * const [ u8 ] ) {
189
205
}
190
206
191
- // CHECK: @str({{\[0 x i8\]\*|ptr}} noalias noundef nonnull readonly align 1 %_1.0, [[USIZE]] %_1.1)
207
+ // CHECK: @str({{\[0 x i8\]\*|ptr}} noalias noundef nonnull readonly align 1 %_1.0, [[USIZE]] noundef %_1.1)
192
208
// FIXME #25759 This should also have `nocapture`
193
209
#[ no_mangle]
194
210
pub fn str ( _: & [ u8 ] ) {
@@ -197,26 +213,36 @@ pub fn str(_: &[u8]) {
197
213
// CHECK: @trait_borrow({{\{\}\*|ptr}} noundef nonnull align 1 %_1.0, {{.+}} noalias noundef readonly align {{.*}} dereferenceable({{.*}}) %_1.1)
198
214
// FIXME #25759 This should also have `nocapture`
199
215
#[ no_mangle]
200
- pub fn trait_borrow ( _: & Drop ) {
216
+ pub fn trait_borrow ( _: & dyn Drop ) {
217
+ }
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 > ) {
201
227
}
202
228
203
- // CHECK: @trait_raw({{\{\}\*|ptr}} %_1.0, {{.+}} noalias noundef readonly align {{.*}} dereferenceable({{.*}}) %_1.1)
229
+ // CHECK: @trait_raw({{\{\}\*|ptr}} noundef %_1.0, {{.+}} noalias noundef readonly align {{.*}} dereferenceable({{.*}}) %_1.1)
204
230
#[ no_mangle]
205
- pub fn trait_raw ( _: * const Drop ) {
231
+ pub fn trait_raw ( _: * const dyn Drop ) {
206
232
}
207
233
208
234
// CHECK: @trait_box({{\{\}\*|ptr}} noalias noundef nonnull align 1{{( %0)?}}, {{.+}} noalias noundef readonly align {{.*}} dereferenceable({{.*}}){{( %1)?}})
209
235
#[ no_mangle]
210
- pub fn trait_box ( _: Box < Drop > ) {
236
+ pub fn trait_box ( _: Box < dyn Drop > ) {
211
237
}
212
238
213
239
// CHECK: { {{i8\*|ptr}}, {{i8\*|ptr}} } @trait_option({{i8\*|ptr}} noalias noundef align 1 %x.0, {{i8\*|ptr}} %x.1)
214
240
#[ no_mangle]
215
- pub fn trait_option ( x : Option < Box < Drop > > ) -> Option < Box < Drop > > {
241
+ pub fn trait_option ( x : Option < Box < dyn Drop > > ) -> Option < Box < dyn Drop > > {
216
242
x
217
243
}
218
244
219
- // CHECK: { {{\[0 x i16\]\*|ptr}}, [[USIZE]] } @return_slice({{\[0 x i16\]\*|ptr}} noalias noundef nonnull readonly align 2 %x.0, [[USIZE]] %x.1)
245
+ // CHECK: { {{\[0 x i16\]\*|ptr}}, [[USIZE]] } @return_slice({{\[0 x i16\]\*|ptr}} noalias noundef nonnull readonly align 2 %x.0, [[USIZE]] noundef %x.1)
220
246
#[ no_mangle]
221
247
pub fn return_slice ( x : & [ u16 ] ) -> & [ u16 ] {
222
248
x
0 commit comments