Commit Graph

17 Commits

Author SHA1 Message Date
Jubilee Young
71d2d3d782 Revert "Only exclude the 155473 change for 1-byte bool-likes"
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.
2026-07-09 18:44:12 -07:00
Hanna Kruppe
460f825263 Remove old FIXMEs about nocapture attribute
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.
2026-06-11 00:22:57 +02:00
Nikita Popov
cb09a42d7e Emit nofree attribute
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.
2026-06-04 15:19:24 +02:00
Oli Scherer
11d88ee42b Rip out rustc_layout_scalar_valid_range_* attribute support 2026-05-03 10:59:52 +02:00
Scott McMurray
569ad99864 Only exclude the 155473 change for 1-byte bool-likes
That's the thing we handle differently in codegen (see `to_immediate_scalar`) so if the other ones are fine, that helps narrow it down further.
2026-04-26 18:03:56 -07:00
Waffle Lapkin
11bcf3759e make PointeeInfo::align non-optional
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)
2026-03-05 11:53:38 +01:00
Ralf Jung
b56949bddf extend unpin noalias tests to cover mutable references 2026-02-22 15:24:20 +01:00
Ralf Jung
590c1c9966 UnsafePinned: implement opsem effects of UnsafeUnpin 2026-02-12 09:09:35 +01:00
Matthew Maurer
b639b0a4d8 llvm: Tolerate dead_on_return attribute changes
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
2026-01-21 23:39:03 +00:00
Waffle Lapkin
e72613030e stop applying dereferenceable(n) to return types 2025-12-13 13:43:02 +01:00
bors
20383c9f1d Auto merge of #148350 - scottmcm:slice-range-attributes, r=JonathanBrouwer,davidtwco
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.
2025-11-03 19:36:42 +00:00
Scott McMurray
0ba7bcfc44 Add LLVM range attributes to slice length parameters 2025-10-31 16:12:30 -07:00
Tomasz Miąsko
2a03a948b9 Deduce captures(none) for a return place and parameters
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.
2025-10-25 22:53:52 +02:00
Nikita Popov
c3ab409b4f Use captures(address) instead of captures(none) for indirect args
While provenance cannot be captured through these arguments, the
address / object identity can.
2025-08-26 16:16:23 +02:00
Nikita Popov
d71ed8d19b Tell LLVM about read-only captures
`&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.
2025-08-20 19:08:16 +02:00
Nikita Popov
ebef9d7f63 Set dead_on_return attribute for indirect arguments
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.
2025-08-11 12:39:23 +02:00
Guillaume Gomez
a27f3e3fd1 Rename tests/codegen into tests/codegen-llvm 2025-07-22 14:28:48 +02:00