Skip to content

Commit 6bf21cf

Browse files
committed
codegen: update array-immediate-param-noundef test
1 parent 8ed0f3f commit 6bf21cf

File tree

1 file changed

+59
-44
lines changed

1 file changed

+59
-44
lines changed

tests/codegen/array-immediate-param-noundef.rs

+59-44
Original file line numberDiff line numberDiff line change
@@ -3,95 +3,94 @@
33
// - `!arg.layout.is_unsized() && size <= Pointer(AddressSpace::DATA).size(cx)`
44
// - optimizations are turned on.
55
//
6-
// ignore-tidy-linelength
76
//@ only-64bit (presence of noundef depends on pointer width)
87
//@ compile-flags: -C no-prepopulate-passes -O
98
#![crate_type = "lib"]
109

11-
// CHECK: define noundef i64 @replace_short_array_u64x1(ptr {{.*}}, i64 noundef %{{.*}})
10+
// CHECK: define noundef i64 @short_array_u64x1(i64 noundef %{{.*}})
1211
#[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
1514
}
1615

17-
// CHECK: define noundef i32 @replace_short_array_u32x1(ptr {{.*}}, i32 noundef %{{.*}})
16+
// CHECK: define noundef i32 @short_array_u32x1(i32 noundef %{{.*}})
1817
#[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
2120
}
2221

23-
// CHECK: define noundef i64 @replace_short_array_u32x2(ptr {{.*}}, i64 noundef %{{.*}})
22+
// CHECK: define noundef i64 @short_array_u32x2(i64 noundef %{{.*}})
2423
#[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
2726
}
2827

29-
// CHECK: define noundef i16 @replace_short_array_u16x1(ptr {{.*}}, i16 noundef %{{.*}})
28+
// CHECK: define noundef i16 @short_array_u16x1(i16 noundef %{{.*}})
3029
#[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
3332
}
3433

35-
// CHECK: define noundef i32 @replace_short_array_u16x2(ptr {{.*}}, i32 noundef %{{.*}})
34+
// CHECK: define noundef i32 @short_array_u16x2(i32 noundef %{{.*}})
3635
#[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
3938
}
4039

41-
// CHECK: define noundef i48 @replace_short_array_u16x3(ptr {{.*}}, i48 noundef %{{.*}})
40+
// CHECK: define noundef i48 @short_array_u16x3(i48 noundef %{{.*}})
4241
#[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
4544
}
4645

47-
// CHECK: define noundef i64 @replace_short_array_u16x4(ptr {{.*}}, i64 noundef %{{.*}})
46+
// CHECK: define noundef i64 @short_array_u16x4(i64 noundef %{{.*}})
4847
#[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
5150
}
5251

53-
// CHECK: define noundef i8 @replace_short_array_u8x1(ptr {{.*}}, i8 noundef %{{.*}})
52+
// CHECK: define noundef i8 @short_array_u8x1(i8 noundef %{{.*}})
5453
#[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
5756
}
5857

59-
// CHECK: define noundef i16 @replace_short_array_u8x2(ptr {{.*}}, i16 noundef %{{.*}})
58+
// CHECK: define noundef i16 @short_array_u8x2(i16 noundef %{{.*}})
6059
#[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
6362
}
6463

65-
// CHECK: define noundef i24 @replace_short_array_u8x3(ptr {{.*}}, i24 noundef %{{.*}})
64+
// CHECK: define noundef i24 @short_array_u8x3(i24 noundef %{{.*}})
6665
#[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
6968
}
7069

71-
// CHECK: define noundef i64 @replace_short_array_u8x8(ptr {{.*}}, i64 noundef %{{.*}})
70+
// CHECK: define noundef i64 @short_array_u8x8(i64 noundef %{{.*}})
7271
#[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
7574
}
7675

7776
#[repr(transparent)]
7877
pub struct Foo([u8; 4]);
7978

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 %{{.*}})
8180
#[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
8483
}
8584

8685
#[repr(transparent)]
8786
pub enum Bar {
88-
Default([u8; 4])
87+
Default([u8; 4]),
8988
}
9089

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 %{{.*}})
9291
#[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
9594
}
9695

9796
#[repr(transparent)]
@@ -103,8 +102,24 @@ pub struct Uwu(Owo);
103102
#[repr(transparent)]
104103
pub struct Oowoo(Uwu);
105104

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 %{{.*}})
107106
#[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
110125
}

0 commit comments

Comments
 (0)