about summary refs log tree commit diff
path: root/compiler/rustc_target/src/abi/call
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2022-02-13 00:14:52 +0000
committerbors <bors@rust-lang.org>2022-02-13 00:14:52 +0000
commit5c30d6568383916ce97cdf20ceb61a8b9e5bb5a8 (patch)
treef46d936ef6bc64bd6f032bca84e9711a0e572d7b /compiler/rustc_target/src/abi/call
parent3cfa4def7c87d571bd46d92fed608edf8fad236e (diff)
parent401307759aaf6f1e49c8a2c840a76ae41ec1f865 (diff)
downloadrust-5c30d6568383916ce97cdf20ceb61a8b9e5bb5a8.tar.gz
rust-5c30d6568383916ce97cdf20ceb61a8b9e5bb5a8.zip
Auto merge of #93670 - erikdesjardins:noundef, r=nikic
Apply noundef attribute to &T, &mut T, Box<T>, bool

This doesn't handle `char` because it's a bit awkward to distinguish it from `u32` at this point in codegen.

Note that this _does not_ change whether or not it is UB for `&`, `&mut`, or `Box` to point to undef. It only applies to the pointer itself, not the pointed-to memory.

Fixes (partially) #74378.

r? `@nikic` cc `@RalfJung`
Diffstat (limited to 'compiler/rustc_target/src/abi/call')
-rw-r--r--compiler/rustc_target/src/abi/call/mod.rs7
1 files changed, 6 insertions, 1 deletions
diff --git a/compiler/rustc_target/src/abi/call/mod.rs b/compiler/rustc_target/src/abi/call/mod.rs
index 0870b1054e4..34324a58297 100644
--- a/compiler/rustc_target/src/abi/call/mod.rs
+++ b/compiler/rustc_target/src/abi/call/mod.rs
@@ -74,6 +74,7 @@ mod attr_impl {
             // or not to actually emit the attribute. It can also be controlled
             // with the `-Zmutable-noalias` debugging option.
             const NoAliasMutRef = 1 << 6;
+            const NoUndef = 1 << 7;
         }
     }
 }
@@ -495,7 +496,11 @@ impl<'a, Ty> ArgAbi<'a, Ty> {
         // For non-immediate arguments the callee gets its own copy of
         // the value on the stack, so there are no aliases. It's also
         // program-invisible so can't possibly capture
-        attrs.set(ArgAttribute::NoAlias).set(ArgAttribute::NoCapture).set(ArgAttribute::NonNull);
+        attrs
+            .set(ArgAttribute::NoAlias)
+            .set(ArgAttribute::NoCapture)
+            .set(ArgAttribute::NonNull)
+            .set(ArgAttribute::NoUndef);
         attrs.pointee_size = layout.size;
         // FIXME(eddyb) We should be doing this, but at least on
         // i686-pc-windows-msvc, it results in wrong stack offsets.