Skip to content

Commit 645c0fd

Browse files
committed
Put noundef on all scalars that don't allow uninit
Previously, it was only put on scalars with range validity invariants like bool, was uninit was obviously invalid for those. Since then, we have normatively declared all uninit primitives to be undefined behavior and can therefore put `noundef` on them. The remaining concern was the `mem::uninitialized` function, which cause quite a lot of UB in the older parts of the ecosystem. This function now doesn't return uninit values anymore, making users of it safe from this change. The only real sources of UB where people could encounter uninit primitives are `MaybeUninit::uninit().assume_init()`, which has always be clear in the docs about being UB and from heap allocations (like reading from the spare capacity of a vec. This is hopefully rare enough to not break anything.
1 parent 4781233 commit 645c0fd

35 files changed

+176
-176
lines changed

compiler/rustc_codegen_llvm/src/builder.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
501501
layout: TyAndLayout<'tcx>,
502502
offset: Size,
503503
) {
504-
if !scalar.is_always_valid(bx) {
504+
if !scalar.is_uninit_valid() {
505505
bx.noundef_metadata(load);
506506
}
507507

compiler/rustc_ty_utils/src/abi.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ fn adjust_for_rust_scalar<'tcx>(
220220
}
221221

222222
// Scalars which have invalid values cannot be undef.
223-
if !scalar.is_always_valid(&cx) {
223+
if !scalar.is_uninit_valid() {
224224
attrs.set(ArgAttribute::NoUndef);
225225
}
226226

tests/codegen/abi-sysv64.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ trait Sized {}
1515
trait Copy {}
1616
impl Copy for i64 {}
1717

18-
// CHECK: define x86_64_sysvcc i64 @has_sysv64_abi
18+
// CHECK: define x86_64_sysvcc noundef i64 @has_sysv64_abi
1919
#[no_mangle]
2020
pub extern "sysv64" fn has_sysv64_abi(a: i64) -> i64 {
2121
a

tests/codegen/abi-x86-interrupt.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ trait Sized {}
1515
trait Copy {}
1616
impl Copy for i64 {}
1717

18-
// CHECK: define x86_intrcc i64 @has_x86_interrupt_abi
18+
// CHECK: define x86_intrcc noundef i64 @has_x86_interrupt_abi
1919
#[no_mangle]
2020
pub extern "x86-interrupt" fn has_x86_interrupt_abi(a: i64) -> i64 {
2121
a

tests/codegen/adjustments.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#![crate_type = "lib"]
44

55
// Hack to get the correct size for the length part in slices
6-
// CHECK: @helper([[USIZE:i[0-9]+]] %_1)
6+
// CHECK: @helper([[USIZE:i[0-9]+]] noundef %_1)
77
#[no_mangle]
88
pub fn helper(_: usize) {
99
}

tests/codegen/box-maybe-uninit-llvm14.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@ pub fn box_uninitialized2() -> Box<MaybeUninit<[usize; 1024 * 1024]>> {
3131
// Hide the LLVM 15+ `allocalign` attribute in the declaration of __rust_alloc
3232
// from the CHECK-NOT above. We don't check the attributes here because we can't rely
3333
// on all of them being set until LLVM 15.
34-
// CHECK: declare noalias{{.*}} @__rust_alloc(i{{[0-9]+}}, i{{[0-9]+.*}})
34+
// CHECK: declare noalias{{.*}} @__rust_alloc(i{{[0-9]+}} noundef, i{{[0-9]+.*}} noundef)

tests/codegen/box-maybe-uninit.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@ pub fn box_uninitialized2() -> Box<MaybeUninit<[usize; 1024 * 1024]>> {
2828

2929
// Hide the `allocalign` attribute in the declaration of __rust_alloc
3030
// from the CHECK-NOT above, and also verify the attributes got set reasonably.
31-
// CHECK: declare noalias ptr @__rust_alloc(i{{[0-9]+}}, i{{[0-9]+}} allocalign) unnamed_addr [[RUST_ALLOC_ATTRS:#[0-9]+]]
31+
// CHECK: declare noalias noundef ptr @__rust_alloc(i{{[0-9]+}} noundef, i{{[0-9]+}} allocalign noundef) unnamed_addr [[RUST_ALLOC_ATTRS:#[0-9]+]]
3232

3333
// CHECK-DAG: attributes [[RUST_ALLOC_ATTRS]] = { {{.*}} allockind("alloc,uninitialized,aligned") allocsize(0) uwtable "alloc-family"="__rust_alloc" {{.*}} }

tests/codegen/c-variadic.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ extern "C" {
1515

1616
pub unsafe extern "C" fn use_foreign_c_variadic_0() {
1717
// Ensure that we correctly call foreign C-variadic functions.
18-
// CHECK: call void (i32, ...) @foreign_c_variadic_0([[PARAM:i32( signext)?]] 0)
18+
// CHECK: call void (i32, ...) @foreign_c_variadic_0([[PARAM:i32 noundef( signext)?]] 0)
1919
foreign_c_variadic_0(0);
2020
// CHECK: call void (i32, ...) @foreign_c_variadic_0([[PARAM]] 0, [[PARAM]] 42)
2121
foreign_c_variadic_0(0, 42i32);
@@ -61,7 +61,7 @@ pub unsafe extern "C" fn c_variadic(n: i32, mut ap: ...) -> i32 {
6161
// Ensure that we generate the correct `call` signature when calling a Rust
6262
// defined C-variadic.
6363
pub unsafe fn test_c_variadic_call() {
64-
// CHECK: call [[RET:(signext )?i32]] (i32, ...) @c_variadic([[PARAM]] 0)
64+
// CHECK: call [[RET:noundef( signext)? i32]] (i32, ...) @c_variadic([[PARAM]] 0)
6565
c_variadic(0);
6666
// CHECK: call [[RET]] (i32, ...) @c_variadic([[PARAM]] 0, [[PARAM]] 42)
6767
c_variadic(0, 42i32);

tests/codegen/call-llvm-intrinsics.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ pub fn do_call() {
2323

2424
unsafe {
2525
// Ensure that we `call` LLVM intrinsics instead of trying to `invoke` them
26-
// CHECK: call float @llvm.sqrt.f32(float 4.000000e+00
26+
// CHECK: call noundef float @llvm.sqrt.f32(float noundef 4.000000e+00
2727
sqrt(4.0);
2828
}
2929
}

tests/codegen/comparison-operators-newtype.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use std::cmp::Ordering;
1313
pub struct Foo(u16);
1414

1515
// CHECK-LABEL: @check_lt
16-
// CHECK-SAME: (i16 %[[A:.+]], i16 %[[B:.+]])
16+
// CHECK-SAME: (i16 noundef %[[A:.+]], i16 noundef %[[B:.+]])
1717
#[no_mangle]
1818
pub fn check_lt(a: Foo, b: Foo) -> bool {
1919
// CHECK: %[[R:.+]] = icmp ult i16 %[[A]], %[[B]]
@@ -22,7 +22,7 @@ pub fn check_lt(a: Foo, b: Foo) -> bool {
2222
}
2323

2424
// CHECK-LABEL: @check_le
25-
// CHECK-SAME: (i16 %[[A:.+]], i16 %[[B:.+]])
25+
// CHECK-SAME: (i16 noundef %[[A:.+]], i16 noundef %[[B:.+]])
2626
#[no_mangle]
2727
pub fn check_le(a: Foo, b: Foo) -> bool {
2828
// CHECK: %[[R:.+]] = icmp ule i16 %[[A]], %[[B]]
@@ -31,7 +31,7 @@ pub fn check_le(a: Foo, b: Foo) -> bool {
3131
}
3232

3333
// CHECK-LABEL: @check_gt
34-
// CHECK-SAME: (i16 %[[A:.+]], i16 %[[B:.+]])
34+
// CHECK-SAME: (i16 noundef %[[A:.+]], i16 noundef %[[B:.+]])
3535
#[no_mangle]
3636
pub fn check_gt(a: Foo, b: Foo) -> bool {
3737
// CHECK: %[[R:.+]] = icmp ugt i16 %[[A]], %[[B]]
@@ -40,7 +40,7 @@ pub fn check_gt(a: Foo, b: Foo) -> bool {
4040
}
4141

4242
// CHECK-LABEL: @check_ge
43-
// CHECK-SAME: (i16 %[[A:.+]], i16 %[[B:.+]])
43+
// CHECK-SAME: (i16 noundef %[[A:.+]], i16 noundef %[[B:.+]])
4444
#[no_mangle]
4545
pub fn check_ge(a: Foo, b: Foo) -> bool {
4646
// CHECK: %[[R:.+]] = icmp uge i16 %[[A]], %[[B]]

tests/codegen/enum-match.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ pub enum Enum0 {
1111
B,
1212
}
1313

14-
// CHECK: define i8 @match0{{.*}}
14+
// CHECK: define noundef i8 @match0{{.*}}
1515
// CHECK-NEXT: start:
1616
// CHECK-NEXT: %1 = icmp eq i8 %0, 2
1717
// CHECK-NEXT: %2 = and i8 %0, 1
@@ -32,7 +32,7 @@ pub enum Enum1 {
3232
C,
3333
}
3434

35-
// CHECK: define i8 @match1{{.*}}
35+
// CHECK: define noundef i8 @match1{{.*}}
3636
// CHECK-NEXT: start:
3737
// CHECK-NEXT: [[DISCR:%.*]] = {{.*}}call i8 @llvm.usub.sat.i8(i8 %0, i8 1)
3838
// CHECK-NEXT: switch i8 [[DISCR]], label {{.*}} [
@@ -88,7 +88,7 @@ pub enum Enum2 {
8888
E,
8989
}
9090

91-
// CHECK: define i8 @match2{{.*}}
91+
// CHECK: define noundef i8 @match2{{.*}}
9292
// CHECK-NEXT: start:
9393
// CHECK-NEXT: %1 = add i8 %0, 2
9494
// CHECK-NEXT: %2 = zext i8 %1 to i64

tests/codegen/fastcall-inreg.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,27 @@ trait Sized {}
1515
trait Copy {}
1616

1717
pub mod tests {
18-
// CHECK: @f1(i32 inreg %_1, i32 inreg %_2, i32 %_3)
18+
// CHECK: @f1(i32 inreg noundef %_1, i32 inreg noundef %_2, i32 noundef %_3)
1919
#[no_mangle]
2020
pub extern "fastcall" fn f1(_: i32, _: i32, _: i32) {}
2121

22-
// CHECK: @f2({{i32\*|ptr}} inreg %_1, {{i32\*|ptr}} inreg %_2, {{i32\*|ptr}} %_3)
22+
// CHECK: @f2({{i32\*|ptr}} inreg noundef %_1, {{i32\*|ptr}} inreg noundef %_2, {{i32\*|ptr}} noundef %_3)
2323
#[no_mangle]
2424
pub extern "fastcall" fn f2(_: *const i32, _: *const i32, _: *const i32) {}
2525

26-
// CHECK: @f3(float %_1, i32 inreg %_2, i32 inreg %_3, i32 %_4)
26+
// CHECK: @f3(float noundef %_1, i32 inreg noundef %_2, i32 inreg noundef %_3, i32 noundef %_4)
2727
#[no_mangle]
2828
pub extern "fastcall" fn f3(_: f32, _: i32, _: i32, _: i32) {}
2929

30-
// CHECK: @f4(i32 inreg %_1, float %_2, i32 inreg %_3, i32 %_4)
30+
// CHECK: @f4(i32 inreg noundef %_1, float noundef %_2, i32 inreg noundef %_3, i32 noundef %_4)
3131
#[no_mangle]
3232
pub extern "fastcall" fn f4(_: i32, _: f32, _: i32, _: i32) {}
3333

34-
// CHECK: @f5(i64 %_1, i32 %_2)
34+
// CHECK: @f5(i64 noundef %_1, i32 noundef %_2)
3535
#[no_mangle]
3636
pub extern "fastcall" fn f5(_: i64, _: i32) {}
3737

38-
// CHECK: @f6(i1 inreg noundef zeroext %_1, i32 inreg %_2, i32 %_3)
38+
// CHECK: @f6(i1 inreg noundef zeroext %_1, i32 inreg noundef %_2, i32 noundef %_3)
3939
#[no_mangle]
4040
pub extern "fastcall" fn f6(_: bool, _: i32, _: i32) {}
4141
}

tests/codegen/fewer-names.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77

88
#[no_mangle]
99
pub fn sum(x: u32, y: u32) -> u32 {
10-
// YES-LABEL: define{{.*}}i32 @sum(i32 %0, i32 %1)
10+
// YES-LABEL: define{{.*}}i32 @sum(i32 noundef %0, i32 noundef %1)
1111
// YES-NEXT: %3 = add i32 %1, %0
1212
// YES-NEXT: ret i32 %3
1313

14-
// NO-LABEL: define{{.*}}i32 @sum(i32 %x, i32 %y)
14+
// NO-LABEL: define{{.*}}i32 @sum(i32 noundef %x, i32 noundef %y)
1515
// NO-NEXT: start:
1616
// NO-NEXT: %z = add i32 %y, %x
1717
// NO-NEXT: ret i32 %z

tests/codegen/frame-pointer.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ trait Copy { }
2020
impl Copy for u32 {}
2121

2222

23-
// CHECK: define i32 @peach{{.*}}[[PEACH_ATTRS:\#[0-9]+]] {
23+
// CHECK: define noundef i32 @peach{{.*}}[[PEACH_ATTRS:\#[0-9]+]] {
2424
#[no_mangle]
2525
pub fn peach(x: u32) -> u32 {
2626
x

tests/codegen/function-arguments.rs

+15-15
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ pub fn maybeuninit_char(x: MaybeUninit<char>) -> MaybeUninit<char> {
6161
x
6262
}
6363

64-
// CHECK: i64 @int(i64 %x)
64+
// CHECK: noundef i64 @int(i64 noundef %x)
6565
#[no_mangle]
6666
pub fn int(x: u64) -> u64 {
6767
x
@@ -73,7 +73,7 @@ pub fn nonzero_int(x: NonZeroU64) -> NonZeroU64 {
7373
x
7474
}
7575

76-
// CHECK: i64 @option_nonzero_int(i64 %x)
76+
// CHECK: noundef i64 @option_nonzero_int(i64 noundef %x)
7777
#[no_mangle]
7878
pub fn option_nonzero_int(x: Option<NonZeroU64>) -> Option<NonZeroU64> {
7979
x
@@ -138,7 +138,7 @@ pub fn indirect_struct(_: S) {
138138
pub fn borrowed_struct(_: &S) {
139139
}
140140

141-
// CHECK: @raw_struct({{%S\*|ptr}} %_1)
141+
// CHECK: @raw_struct({{%S\*|ptr}} noundef %_1)
142142
#[no_mangle]
143143
pub fn raw_struct(_: *const S) {
144144
}
@@ -160,35 +160,35 @@ pub fn struct_return() -> S {
160160
}
161161

162162
// Hack to get the correct size for the length part in slices
163-
// CHECK: @helper([[USIZE:i[0-9]+]] %_1)
163+
// CHECK: @helper([[USIZE:i[0-9]+]] noundef %_1)
164164
#[no_mangle]
165165
pub fn helper(_: usize) {
166166
}
167167

168-
// CHECK: @slice({{\[0 x i8\]\*|ptr}} noalias noundef nonnull readonly align 1 %_1.0, [[USIZE]] %_1.1)
168+
// CHECK: @slice({{\[0 x i8\]\*|ptr}} noalias noundef nonnull readonly align 1 %_1.0, [[USIZE]] noundef %_1.1)
169169
// FIXME #25759 This should also have `nocapture`
170170
#[no_mangle]
171171
pub fn slice(_: &[u8]) {
172172
}
173173

174-
// CHECK: @mutable_slice({{\[0 x i8\]\*|ptr}} noalias noundef nonnull align 1 %_1.0, [[USIZE]] %_1.1)
174+
// CHECK: @mutable_slice({{\[0 x i8\]\*|ptr}} noalias noundef nonnull align 1 %_1.0, [[USIZE]] noundef %_1.1)
175175
// FIXME #25759 This should also have `nocapture`
176176
#[no_mangle]
177177
pub fn mutable_slice(_: &mut [u8]) {
178178
}
179179

180-
// CHECK: @unsafe_slice({{\[0 x i16\]\*|ptr}} noundef nonnull align 2 %_1.0, [[USIZE]] %_1.1)
180+
// CHECK: @unsafe_slice({{\[0 x i16\]\*|ptr}} noundef nonnull align 2 %_1.0, [[USIZE]] noundef %_1.1)
181181
// unsafe interior means this isn't actually readonly and there may be aliases ...
182182
#[no_mangle]
183183
pub fn unsafe_slice(_: &[UnsafeInner]) {
184184
}
185185

186-
// CHECK: @raw_slice({{\[0 x i8\]\*|ptr}} %_1.0, [[USIZE]] %_1.1)
186+
// CHECK: @raw_slice({{\[0 x i8\]\*|ptr}} noundef %_1.0, [[USIZE]] noundef %_1.1)
187187
#[no_mangle]
188188
pub fn raw_slice(_: *const [u8]) {
189189
}
190190

191-
// CHECK: @str({{\[0 x i8\]\*|ptr}} noalias noundef nonnull readonly align 1 %_1.0, [[USIZE]] %_1.1)
191+
// CHECK: @str({{\[0 x i8\]\*|ptr}} noalias noundef nonnull readonly align 1 %_1.0, [[USIZE]] noundef %_1.1)
192192
// FIXME #25759 This should also have `nocapture`
193193
#[no_mangle]
194194
pub fn str(_: &[u8]) {
@@ -197,26 +197,26 @@ pub fn str(_: &[u8]) {
197197
// CHECK: @trait_borrow({{\{\}\*|ptr}} noundef nonnull align 1 %_1.0, {{.+}} noalias noundef readonly align {{.*}} dereferenceable({{.*}}) %_1.1)
198198
// FIXME #25759 This should also have `nocapture`
199199
#[no_mangle]
200-
pub fn trait_borrow(_: &Drop) {
200+
pub fn trait_borrow(_: &dyn Drop) {
201201
}
202202

203-
// CHECK: @trait_raw({{\{\}\*|ptr}} %_1.0, {{.+}} noalias noundef readonly align {{.*}} dereferenceable({{.*}}) %_1.1)
203+
// CHECK: @trait_raw({{\{\}\*|ptr}} noundef %_1.0, {{.+}} noalias noundef readonly align {{.*}} dereferenceable({{.*}}) %_1.1)
204204
#[no_mangle]
205-
pub fn trait_raw(_: *const Drop) {
205+
pub fn trait_raw(_: *const dyn Drop) {
206206
}
207207

208208
// CHECK: @trait_box({{\{\}\*|ptr}} noalias noundef nonnull align 1{{( %0)?}}, {{.+}} noalias noundef readonly align {{.*}} dereferenceable({{.*}}){{( %1)?}})
209209
#[no_mangle]
210-
pub fn trait_box(_: Box<Drop>) {
210+
pub fn trait_box(_: Box<dyn Drop>) {
211211
}
212212

213213
// CHECK: { {{i8\*|ptr}}, {{i8\*|ptr}} } @trait_option({{i8\*|ptr}} noalias noundef align 1 %x.0, {{i8\*|ptr}} %x.1)
214214
#[no_mangle]
215-
pub fn trait_option(x: Option<Box<Drop>>) -> Option<Box<Drop>> {
215+
pub fn trait_option(x: Option<Box<dyn Drop>>) -> Option<Box<dyn Drop>> {
216216
x
217217
}
218218

219-
// CHECK: { {{\[0 x i16\]\*|ptr}}, [[USIZE]] } @return_slice({{\[0 x i16\]\*|ptr}} noalias noundef nonnull readonly align 2 %x.0, [[USIZE]] %x.1)
219+
// CHECK: { {{\[0 x i16\]\*|ptr}}, [[USIZE]] } @return_slice({{\[0 x i16\]\*|ptr}} noalias noundef nonnull readonly align 2 %x.0, [[USIZE]] noundef %x.1)
220220
#[no_mangle]
221221
pub fn return_slice(x: &[u16]) -> &[u16] {
222222
x

tests/codegen/intrinsics/const_eval_select.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ pub fn hi(n: i32) -> i32 { n }
1313

1414
#[no_mangle]
1515
pub unsafe fn hey() {
16-
// CHECK: call i32 @hi(i32
16+
// CHECK: call noundef i32 @hi(i32
1717
const_eval_select((42,), foo, hi);
1818
}

tests/codegen/intrinsics/mask.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#![feature(core_intrinsics)]
33

44
// CHECK-LABEL: @mask_ptr
5-
// CHECK-SAME: [[WORD:i[0-9]+]] %mask
5+
// CHECK-SAME: [[WORD:i[0-9]+]] noundef %mask
66
#[no_mangle]
77
pub fn mask_ptr(ptr: *const u16, mask: usize) -> *const u16 {
88
// CHECK: call

tests/codegen/issue-32031.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#[no_mangle]
66
pub struct F32(f32);
77

8-
// CHECK: define{{.*}}float @add_newtype_f32(float %a, float %b)
8+
// CHECK: define{{.*}}float @add_newtype_f32(float noundef %a, float noundef %b)
99
#[inline(never)]
1010
#[no_mangle]
1111
pub fn add_newtype_f32(a: F32, b: F32) -> F32 {
@@ -15,7 +15,7 @@ pub fn add_newtype_f32(a: F32, b: F32) -> F32 {
1515
#[no_mangle]
1616
pub struct F64(f64);
1717

18-
// CHECK: define{{.*}}double @add_newtype_f64(double %a, double %b)
18+
// CHECK: define{{.*}}double @add_newtype_f64(double noundef %a, double noundef %b)
1919
#[inline(never)]
2020
#[no_mangle]
2121
pub fn add_newtype_f64(a: F64, b: F64) -> F64 {

tests/codegen/issue-58881.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ struct Bar(u64, u64, u64);
1616

1717
// Ensure that emit arguments of the correct type.
1818
pub unsafe fn test_call_variadic() {
19-
// CHECK: call void (i32, ...) @variadic_fn(i32 0, i8 {{.*}}, {{%Bar\*|ptr}} {{.*}})
19+
// CHECK: call void (i32, ...) @variadic_fn(i32 noundef 0, i8 {{.*}}, {{%Bar\*|ptr}} {{.*}})
2020
variadic_fn(0, Foo(0), Bar(0, 0, 0))
2121
}

tests/codegen/loads.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ pub fn load_scalar_pair<'a>(x: &(&'a i32, &'a Align16)) -> (&'a i32, &'a Align16
5151
#[no_mangle]
5252
pub fn load_raw_pointer<'a>(x: &*const i32) -> *const i32 {
5353
// loaded raw pointer should not have !nonnull, !align, or !noundef metadata
54-
// CHECK: load {{i32\*|ptr}}, {{i32\*\*|ptr}} %x, align [[PTR_ALIGNMENT]]{{$}}
54+
// CHECK: load {{i32\*|ptr}}, {{i32\*\*|ptr}} %x, align [[PTR_ALIGNMENT]], !noundef !2{{$}}
5555
*x
5656
}
5757

@@ -93,7 +93,7 @@ pub fn load_maybeuninit_enum_bool(x: &MaybeUninit<MyBool>) -> MaybeUninit<MyBool
9393
// CHECK-LABEL: @load_int
9494
#[no_mangle]
9595
pub fn load_int(x: &u16) -> u16 {
96-
// CHECK: load i16, {{i16\*|ptr}} %x, align 2{{$}}
96+
// CHECK: load i16, {{i16\*|ptr}} %x, align 2, !noundef !2{{$}}
9797
*x
9898
}
9999

@@ -107,7 +107,7 @@ pub fn load_nonzero_int(x: &NonZeroU16) -> NonZeroU16 {
107107
// CHECK-LABEL: @load_option_nonzero_int
108108
#[no_mangle]
109109
pub fn load_option_nonzero_int(x: &Option<NonZeroU16>) -> Option<NonZeroU16> {
110-
// CHECK: load i16, {{i16\*|ptr}} %x, align 2{{$}}
110+
// CHECK: load i16, {{i16\*|ptr}} %x, align 2, !noundef !2{{$}}
111111
*x
112112
}
113113

tests/codegen/naked-functions.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pub unsafe extern "C" fn naked_empty() {
1919
}
2020

2121
// CHECK: Function Attrs: naked
22-
// CHECK-NEXT: define{{.*}}i{{[0-9]+}} @naked_with_args_and_return(i64 %a, i64 %b)
22+
// CHECK-NEXT: define{{.*}}i{{[0-9]+}} @naked_with_args_and_return(i64 noundef %a, i64 noundef %b)
2323
#[no_mangle]
2424
#[naked]
2525
pub unsafe extern "C" fn naked_with_args_and_return(a: isize, b: isize) -> isize {

0 commit comments

Comments
 (0)