This reverts commit 569ad99864.
The PR widened the effect of this from enums with the 0..=1 range to
those with any range if they had more than 1 byte.
Unfortunately, our LLVMIR now incurs miscompilations, so revert until
we find a better fix.
As discussed in the long-closed issue referenced by the FIXMEs, it would
be unsound to add nocapture to all reference arguments. The canonical
example is taking &T and returning *const T, i.e., `std::ptr::from_ref`.
Some of the removed test cases suggest that named vs elided vs static
lifetime on the reference would make a difference for capturing, which
is incompatible with all modern takes on Rust opsem.
Hypothetically, we could add some kind of escape analysis on MIR to
determine which arguments can be marked as nocapture. But LLVM can do
that too (often better), so why should we? Plus, if we started doing
such analysis, the test that had the FIXMEs would not be a good place to
exercise it, as all the function bodies are trivial.
Treat the semantics of pointee.size as "dereferenceable-at-point"
and always specify the size. Instead, use a separate NoFree attribute
to determine whether dereferenceability extends to the whole function.
Then in the LLVM backend, only actually emit dereferenceable if
nofree is also set, as dereferenceable currently implies nofree.
In addition, explicitly emit the nofree attribute, which will help
when LLVM switches dereferenceable to be at-point.
Instead of defaulting to `None` it now defaults to `Align::ONE` i.e.
no alignment restriction. Codegen test changes are due to us now skipping
`align 1` annotations (they are useless; not skipping them makes all the
raw pointers gain an `align 1` annotation which doesn't seem any good)
The attribute now has a size parameter and sorts differently:
* Explicitly omit size parameter during construction on 23+
* Tolerate alternate sorting in tests
https://github.com/llvm/llvm-project/pull/171712
Add LLVM range attributes to slice length parameters
It'll take a bunch more work to do this in layout -- because of cycles in `struct Foo<'a>(&'a Foo<'a>);` -- so until we figure out how to do that well, just look for slices specifically and add the proper range for the length.
Extend attribute deduction to determine whether parameters using
indirect pass mode might have their address captured. Similarly to
the deduction of `readonly` attribute this information facilitates
memcpy optimizations.
`&Freeze` parameters are not only `readonly` within the function,
but any captures of the pointer can also only be used for reads.
This can now be encoded using the `captures(address, read_provenance)`
attribute.
Set the dead_on_return attribute (added in LLVM 21) for arguments
that are passed indirectly, but not byval.
This indicates that the value of the argument on return does not
matter, enabling additional dead store elimination.