Description
LLVM 11 introduces a new noundef
attribute, with the following semantics:
This attribute applies to parameters and return values. If the value representation contains any undefined or poison bits, the behavior is undefined. Note that this does not refer to padding introduced by the type’s storage representation.
In LLVM 11 itself it doesn't do anything yet, but this will become important in the future to reduce the impact of freeze
instructions.
We need to figure out for which parameters / return values we can emit this attribute. We generally can't do so if any bits are unspecified, e.g. due to padding. More problematic for Rust is rust-lang/unsafe-code-guidelines#71, i.e. the question of whether integers are allowed to contain uninitialized bits without going through something like MaybeUninit.
If we go with aggressive emission of noundef, we probably need to punish safe-guard mem::uninitialized()
users with liberal application of freeze
.
cc @RalfJung