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.
This commit is contained in:
parent
71226d717a
commit
8cb0b6ca5b
10 changed files with 56 additions and 22 deletions
|
@ -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(
|
||||
|
|
|
@ -189,6 +189,7 @@ pub enum Attribute {
|
|||
StackProtectReq = 30,
|
||||
StackProtectStrong = 31,
|
||||
StackProtect = 32,
|
||||
NoUndef = 33,
|
||||
}
|
||||
|
||||
/// LLVMIntPredicate
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue