A read only no alias reference
NotPppp1116:
The syntax is only a placeholder, names like &uniq T, &noalias T, or something else may be better.
NotPppp1116:
- the compiler can optimize based on that exclusivity.
NotPppp1116:
This is somewhat similar to C’s const T * restrict
This motivation/explanation is probably missing the fact that &T is already fully compatible with noalias in LLVM?
↝ compiler explorer demo ⮺
Edit: In fact, looking at your list
NotPppp1116:
ptr noalias readonly nonnull noundef align N dereferenceable(M)
and checking what actually happens for something like &(i32, i32) in the linked code
ptr noalias noundef readonly align 4 captures(none) dereferenceable(8) %x
that’s essentially the exact same list already. (Minus nonnull, but nonnull is implied by dereferenceable anyway!)
however
dereferenceable(<n>)does implynonnullinaddrspace(0)(which is the default address space), except if thenull_pointer_is_validfunction attribute is present (from the LLVM Manual)
Edit2: Actually, those were the things left after LLM was done optimizing. What Rustc produced was apparently
ptr noalias noundef readonly align 4 captures(address, read_provenance) dereferenceable(8) %0
containing these extra captures(address, read_provenance) annotations[1].
- by the looks of it, these make the guarantees actually weaker - the deduction of
captures(none)happened by LLVM during its own analysis of the function body ↩︎
Discussion in the ATmosphere