about summary refs log tree commit diff
path: root/tests/codegen/loads.rs
diff options
context:
space:
mode:
authorNilstrieb <48135649+Nilstrieb@users.noreply.github.com>2022-12-30 15:55:05 +0100
committernils <48135649+Nilstrieb@users.noreply.github.com>2023-01-17 08:14:35 +0100
commit645c0fddd2e0446cc0e6eecd8a78de4b5ab5a967 (patch)
tree70751b76743a039689b4efe6184bce0b3d2c3c62 /tests/codegen/loads.rs
parent4781233a77e879e49cb5ce3c98d2abba6a6ade7a (diff)
downloadrust-645c0fddd2e0446cc0e6eecd8a78de4b5ab5a967.tar.gz
rust-645c0fddd2e0446cc0e6eecd8a78de4b5ab5a967.zip
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.
Diffstat (limited to 'tests/codegen/loads.rs')
-rw-r--r--tests/codegen/loads.rs6
1 files changed, 3 insertions, 3 deletions
diff --git a/tests/codegen/loads.rs b/tests/codegen/loads.rs
index f448306ba1b..c9728197092 100644
--- a/tests/codegen/loads.rs
+++ b/tests/codegen/loads.rs
@@ -51,7 +51,7 @@ pub fn load_scalar_pair<'a>(x: &(&'a i32, &'a Align16)) -> (&'a i32, &'a Align16
 #[no_mangle]
 pub fn load_raw_pointer<'a>(x: &*const i32) -> *const i32 {
     // loaded raw pointer should not have !nonnull, !align, or !noundef metadata
-    // CHECK: load {{i32\*|ptr}}, {{i32\*\*|ptr}} %x, align [[PTR_ALIGNMENT]]{{$}}
+    // CHECK: load {{i32\*|ptr}}, {{i32\*\*|ptr}} %x, align [[PTR_ALIGNMENT]], !noundef !2{{$}}
     *x
 }
 
@@ -93,7 +93,7 @@ pub fn load_maybeuninit_enum_bool(x: &MaybeUninit<MyBool>) -> MaybeUninit<MyBool
 // CHECK-LABEL: @load_int
 #[no_mangle]
 pub fn load_int(x: &u16) -> u16 {
-    // CHECK: load i16, {{i16\*|ptr}} %x, align 2{{$}}
+    // CHECK: load i16, {{i16\*|ptr}} %x, align 2, !noundef !2{{$}}
     *x
 }
 
@@ -107,7 +107,7 @@ pub fn load_nonzero_int(x: &NonZeroU16) -> NonZeroU16 {
 // CHECK-LABEL: @load_option_nonzero_int
 #[no_mangle]
 pub fn load_option_nonzero_int(x: &Option<NonZeroU16>) -> Option<NonZeroU16> {
-    // CHECK: load i16, {{i16\*|ptr}} %x, align 2{{$}}
+    // CHECK: load i16, {{i16\*|ptr}} %x, align 2, !noundef !2{{$}}
     *x
 }