about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src
diff options
context:
space:
mode:
authorErik Desjardins <erikdesjardins@users.noreply.github.com>2022-02-05 01:00:37 -0500
committerErik Desjardins <erikdesjardins@users.noreply.github.com>2022-02-05 01:09:52 -0500
commit8cb0b6ca5bf1321d38f4602113b0f41c837d0586 (patch)
treeceb48b535511ea78faaa617e20cdef30f20ff4b9 /compiler/rustc_codegen_llvm/src
parent71226d717a1fb57122e47e63b97295e703319cb0 (diff)
downloadrust-8cb0b6ca5bf1321d38f4602113b0f41c837d0586.tar.gz
rust-8cb0b6ca5bf1321d38f4602113b0f41c837d0586.zip
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 for some types (like `&Struct` and `&mut Struct`),
we already apply `dereferenceable`, which implies `noundef`,
so the IR does not change.
Diffstat (limited to 'compiler/rustc_codegen_llvm/src')
-rw-r--r--compiler/rustc_codegen_llvm/src/abi.rs6
-rw-r--r--compiler/rustc_codegen_llvm/src/llvm/ffi.rs1
2 files changed, 6 insertions, 1 deletions
diff --git a/compiler/rustc_codegen_llvm/src/abi.rs b/compiler/rustc_codegen_llvm/src/abi.rs
index e9b66b54c58..ff03df79ab1 100644
--- a/compiler/rustc_codegen_llvm/src/abi.rs
+++ b/compiler/rustc_codegen_llvm/src/abi.rs
@@ -37,7 +37,7 @@ impl ArgAttributeExt for ArgAttribute {
     where
         F: FnMut(llvm::Attribute),
     {
-        for_each_kind!(self, f, NoAlias, NoCapture, NonNull, ReadOnly, InReg)
+        for_each_kind!(self, f, NoAlias, NoCapture, NonNull, ReadOnly, InReg, NoUndef)
     }
 }
 
@@ -69,7 +69,9 @@ impl ArgAttributesExt for ArgAttributes {
                 } else {
                     llvm::LLVMRustAddDereferenceableOrNullAttr(llfn, idx.as_uint(), deref);
                 }
+                // dereferenceable implies nonnull noundef; dereferenceable_or_null implies noundef
                 regular -= ArgAttribute::NonNull;
+                regular -= ArgAttribute::NoUndef;
             }
             if let Some(align) = self.pointee_align {
                 llvm::LLVMRustAddAlignmentAttr(llfn, idx.as_uint(), align.bytes() as u32);
@@ -109,7 +111,9 @@ impl ArgAttributesExt for ArgAttributes {
                         deref,
                     );
                 }
+                // dereferenceable implies nonnull noundef; dereferenceable_or_null implies noundef
                 regular -= ArgAttribute::NonNull;
+                regular -= ArgAttribute::NoUndef;
             }
             if let Some(align) = self.pointee_align {
                 llvm::LLVMRustAddAlignmentCallSiteAttr(
diff --git a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs
index 367c86a1dc9..4f62c685568 100644
--- a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs
+++ b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs
@@ -189,6 +189,7 @@ pub enum Attribute {
     StackProtectReq = 30,
     StackProtectStrong = 31,
     StackProtect = 32,
+    NoUndef = 33,
 }
 
 /// LLVMIntPredicate