3
3
// - `!arg.layout.is_unsized() && size <= Pointer(AddressSpace::DATA).size(cx)`
4
4
// - optimizations are turned on.
5
5
//
6
- // ignore-tidy-linelength
7
6
//@ only-64bit (presence of noundef depends on pointer width)
8
7
//@ compile-flags: -C no-prepopulate-passes -O
9
8
#![ crate_type = "lib" ]
10
9
11
- // CHECK: define noundef i64 @replace_short_array_u64x1(ptr {{.*}}, i64 noundef %{{.*}})
10
+ // CHECK: define noundef i64 @short_array_u64x1( i64 noundef %{{.*}})
12
11
#[ no_mangle]
13
- pub fn replace_short_array_u64x1 ( r : & mut [ u64 ; 1 ] , v : [ u64 ; 1 ] ) -> [ u64 ; 1 ] {
14
- std :: mem :: replace ( r , v )
12
+ pub fn short_array_u64x1 ( v : [ u64 ; 1 ] ) -> [ u64 ; 1 ] {
13
+ v
15
14
}
16
15
17
- // CHECK: define noundef i32 @replace_short_array_u32x1(ptr {{.*}}, i32 noundef %{{.*}})
16
+ // CHECK: define noundef i32 @short_array_u32x1( i32 noundef %{{.*}})
18
17
#[ no_mangle]
19
- pub fn replace_short_array_u32x1 ( r : & mut [ u32 ; 1 ] , v : [ u32 ; 1 ] ) -> [ u32 ; 1 ] {
20
- std :: mem :: replace ( r , v )
18
+ pub fn short_array_u32x1 ( v : [ u32 ; 1 ] ) -> [ u32 ; 1 ] {
19
+ v
21
20
}
22
21
23
- // CHECK: define noundef i64 @replace_short_array_u32x2(ptr {{.*}}, i64 noundef %{{.*}})
22
+ // CHECK: define noundef i64 @short_array_u32x2( i64 noundef %{{.*}})
24
23
#[ no_mangle]
25
- pub fn replace_short_array_u32x2 ( r : & mut [ u32 ; 2 ] , v : [ u32 ; 2 ] ) -> [ u32 ; 2 ] {
26
- std :: mem :: replace ( r , v )
24
+ pub fn short_array_u32x2 ( v : [ u32 ; 2 ] ) -> [ u32 ; 2 ] {
25
+ v
27
26
}
28
27
29
- // CHECK: define noundef i16 @replace_short_array_u16x1(ptr {{.*}}, i16 noundef %{{.*}})
28
+ // CHECK: define noundef i16 @short_array_u16x1( i16 noundef %{{.*}})
30
29
#[ no_mangle]
31
- pub fn replace_short_array_u16x1 ( r : & mut [ u16 ; 1 ] , v : [ u16 ; 1 ] ) -> [ u16 ; 1 ] {
32
- std :: mem :: replace ( r , v )
30
+ pub fn short_array_u16x1 ( v : [ u16 ; 1 ] ) -> [ u16 ; 1 ] {
31
+ v
33
32
}
34
33
35
- // CHECK: define noundef i32 @replace_short_array_u16x2(ptr {{.*}}, i32 noundef %{{.*}})
34
+ // CHECK: define noundef i32 @short_array_u16x2( i32 noundef %{{.*}})
36
35
#[ no_mangle]
37
- pub fn replace_short_array_u16x2 ( r : & mut [ u16 ; 2 ] , v : [ u16 ; 2 ] ) -> [ u16 ; 2 ] {
38
- std :: mem :: replace ( r , v )
36
+ pub fn short_array_u16x2 ( v : [ u16 ; 2 ] ) -> [ u16 ; 2 ] {
37
+ v
39
38
}
40
39
41
- // CHECK: define noundef i48 @replace_short_array_u16x3(ptr {{.*}}, i48 noundef %{{.*}})
40
+ // CHECK: define noundef i48 @short_array_u16x3( i48 noundef %{{.*}})
42
41
#[ no_mangle]
43
- pub fn replace_short_array_u16x3 ( r : & mut [ u16 ; 3 ] , v : [ u16 ; 3 ] ) -> [ u16 ; 3 ] {
44
- std :: mem :: replace ( r , v )
42
+ pub fn short_array_u16x3 ( v : [ u16 ; 3 ] ) -> [ u16 ; 3 ] {
43
+ v
45
44
}
46
45
47
- // CHECK: define noundef i64 @replace_short_array_u16x4(ptr {{.*}}, i64 noundef %{{.*}})
46
+ // CHECK: define noundef i64 @short_array_u16x4( i64 noundef %{{.*}})
48
47
#[ no_mangle]
49
- pub fn replace_short_array_u16x4 ( r : & mut [ u16 ; 4 ] , v : [ u16 ; 4 ] ) -> [ u16 ; 4 ] {
50
- std :: mem :: replace ( r , v )
48
+ pub fn short_array_u16x4 ( v : [ u16 ; 4 ] ) -> [ u16 ; 4 ] {
49
+ v
51
50
}
52
51
53
- // CHECK: define noundef i8 @replace_short_array_u8x1(ptr {{.*}}, i8 noundef %{{.*}})
52
+ // CHECK: define noundef i8 @short_array_u8x1( i8 noundef %{{.*}})
54
53
#[ no_mangle]
55
- pub fn replace_short_array_u8x1 ( r : & mut [ u8 ; 1 ] , v : [ u8 ; 1 ] ) -> [ u8 ; 1 ] {
56
- std :: mem :: replace ( r , v )
54
+ pub fn short_array_u8x1 ( v : [ u8 ; 1 ] ) -> [ u8 ; 1 ] {
55
+ v
57
56
}
58
57
59
- // CHECK: define noundef i16 @replace_short_array_u8x2(ptr {{.*}}, i16 noundef %{{.*}})
58
+ // CHECK: define noundef i16 @short_array_u8x2( i16 noundef %{{.*}})
60
59
#[ no_mangle]
61
- pub fn replace_short_array_u8x2 ( r : & mut [ u8 ; 2 ] , v : [ u8 ; 2 ] ) -> [ u8 ; 2 ] {
62
- std :: mem :: replace ( r , v )
60
+ pub fn short_array_u8x2 ( v : [ u8 ; 2 ] ) -> [ u8 ; 2 ] {
61
+ v
63
62
}
64
63
65
- // CHECK: define noundef i24 @replace_short_array_u8x3(ptr {{.*}}, i24 noundef %{{.*}})
64
+ // CHECK: define noundef i24 @short_array_u8x3( i24 noundef %{{.*}})
66
65
#[ no_mangle]
67
- pub fn replace_short_array_u8x3 ( r : & mut [ u8 ; 3 ] , v : [ u8 ; 3 ] ) -> [ u8 ; 3 ] {
68
- std :: mem :: replace ( r , v )
66
+ pub fn short_array_u8x3 ( v : [ u8 ; 3 ] ) -> [ u8 ; 3 ] {
67
+ v
69
68
}
70
69
71
- // CHECK: define noundef i64 @replace_short_array_u8x8(ptr {{.*}}, i64 noundef %{{.*}})
70
+ // CHECK: define noundef i64 @short_array_u8x8( i64 noundef %{{.*}})
72
71
#[ no_mangle]
73
- pub fn replace_short_array_u8x8 ( r : & mut [ u8 ; 8 ] , v : [ u8 ; 8 ] ) -> [ u8 ; 8 ] {
74
- std :: mem :: replace ( r , v )
72
+ pub fn short_array_u8x8 ( v : [ u8 ; 8 ] ) -> [ u8 ; 8 ] {
73
+ v
75
74
}
76
75
77
76
#[ repr( transparent) ]
78
77
pub struct Foo ( [ u8 ; 4 ] ) ;
79
78
80
- // CHECK: define noundef i32 @replace_repr_transparent_struct_short_array(ptr {{.*}}, i32 noundef %{{.*}})
79
+ // CHECK: define noundef i32 @repr_transparent_struct_short_array( i32 noundef %{{.*}})
81
80
#[ no_mangle]
82
- pub fn replace_repr_transparent_struct_short_array ( r : & mut Foo , v : Foo ) -> Foo {
83
- std :: mem :: replace ( r , v )
81
+ pub fn repr_transparent_struct_short_array ( v : Foo ) -> Foo {
82
+ v
84
83
}
85
84
86
85
#[ repr( transparent) ]
87
86
pub enum Bar {
88
- Default ( [ u8 ; 4 ] )
87
+ Default ( [ u8 ; 4 ] ) ,
89
88
}
90
89
91
- // CHECK: define noundef i32 @replace_repr_transparent_enum_short_array(ptr {{.*}}, i32 noundef %{{.*}})
90
+ // CHECK: define noundef i32 @repr_transparent_enum_short_array( i32 noundef %{{.*}})
92
91
#[ no_mangle]
93
- pub fn replace_repr_transparent_enum_short_array ( r : & mut Bar , v : Bar ) -> Bar {
94
- std :: mem :: replace ( r , v )
92
+ pub fn repr_transparent_enum_short_array ( v : Bar ) -> Bar {
93
+ v
95
94
}
96
95
97
96
#[ repr( transparent) ]
@@ -103,8 +102,24 @@ pub struct Uwu(Owo);
103
102
#[ repr( transparent) ]
104
103
pub struct Oowoo ( Uwu ) ;
105
104
106
- // CHECK: define noundef i32 @replace_repr_transparent_nested_struct_short_array(ptr {{.*}}, i32 noundef %{{.*}})
105
+ // CHECK: define noundef i32 @repr_transparent_nested_struct_short_array( i32 noundef %{{.*}})
107
106
#[ no_mangle]
108
- pub fn replace_repr_transparent_nested_struct_short_array ( r : & mut Oowoo , v : Oowoo ) -> Oowoo {
109
- std:: mem:: replace ( r, v)
107
+ pub fn repr_transparent_nested_struct_short_array ( v : Oowoo ) -> Oowoo {
108
+ v
109
+ }
110
+
111
+ // # Negative examples
112
+
113
+ // This inner struct is *not* `#[repr(transparent)]`, so we must not emit `noundef` for the outer
114
+ // struct.
115
+ pub struct NotTransparent ( [ u8 ; 4 ] ) ;
116
+
117
+ #[ repr( transparent) ]
118
+ pub struct Transparent ( NotTransparent ) ;
119
+
120
+ // CHECK-LABEL: not_all_transparent_nested_struct_short_array
121
+ // CHECK-NOT: noundef
122
+ #[ no_mangle]
123
+ pub fn not_all_transparent_nested_struct_short_array ( v : Transparent ) -> Transparent {
124
+ v
110
125
}
0 commit comments