about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-01-17 17:39:48 +0000
committerbors <bors@rust-lang.org>2023-01-17 17:39:48 +0000
commit3984bc5833db8bfb0acc522c9775383e4171f3de (patch)
treeb7b857372290acb972e12be100108d730af854a4 /compiler/rustc_codegen_llvm/src
parent38a76f33220c4b9d13dda1fa8f6c629c8a7bcc5d (diff)
parentf1255380ac1cb7be1b6b0ac0eda5b1274b29eff6 (diff)
downloadrust-3984bc5833db8bfb0acc522c9775383e4171f3de.tar.gz
rust-3984bc5833db8bfb0acc522c9775383e4171f3de.zip
Auto merge of #106294 - Nilstrieb:noundef-everything, r=nikic
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. After #99182, 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.

cc `@nagisa` `@scottmcm` `@nikic`
Diffstat (limited to 'compiler/rustc_codegen_llvm/src')
-rw-r--r--compiler/rustc_codegen_llvm/src/builder.rs2
1 files changed, 1 insertions, 1 deletions
diff --git a/compiler/rustc_codegen_llvm/src/builder.rs b/compiler/rustc_codegen_llvm/src/builder.rs
index 5bf45a81e43..5e98deae48a 100644
--- a/compiler/rustc_codegen_llvm/src/builder.rs
+++ b/compiler/rustc_codegen_llvm/src/builder.rs
@@ -501,7 +501,7 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
             layout: TyAndLayout<'tcx>,
             offset: Size,
         ) {
-            if !scalar.is_always_valid(bx) {
+            if !scalar.is_uninit_valid() {
                 bx.noundef_metadata(load);
             }