{
"$type": "site.standard.document",
"bskyPostRef": {
"cid": "bafyreid3cnff37kbyeuwvet2yzbjo657zekd4frgec3m4pbsvn7jwgxkpu",
"uri": "at://did:plc:ivbknywyskln22er3nkssdhl/app.bsky.feed.post/3mp2d3jragjl2"
},
"path": "/t/a-read-only-no-alias-reference/24410#post_3",
"publishedAt": "2026-06-24T11:59:58.000Z",
"site": "https://internals.rust-lang.org",
"tags": [
"↝ compiler explorer demo ⮺",
"LLVM Manual",
"[1]",
"↩︎"
],
"textContent": "NotPppp1116:\n\n> The syntax is only a placeholder, names like &uniq T, &noalias T, or something else may be better.\n\nNotPppp1116:\n\n> * the compiler can optimize based on that exclusivity.\n>\n\n\nNotPppp1116:\n\n> This is somewhat similar to C’s const T * restrict\n\nThis motivation/explanation is probably missing the fact that `&T` is already fully compatible with `noalias` in LLVM?\n\n↝ compiler explorer demo ⮺\n\n* * *\n\n_Edit:_ In fact, looking at your list\n\nNotPppp1116:\n\n> ptr noalias readonly nonnull noundef align N dereferenceable(M)\n\nand checking what actually happens for something like `&(i32, i32)` in the linked code\n\n\n ptr noalias noundef readonly align 4 captures(none) dereferenceable(8) %x\n\n\nthat’s essentially the exact same list already. (Minus `nonnull`, but `nonnull` is _implied_ by `dereferenceable` anyway!)\n\n> however `dereferenceable(<n>)` does imply `nonnull` in `addrspace(0)` (which is the default address space), except if the `null_pointer_is_valid` function attribute is present (from the LLVM Manual)\n\n_Edit2:_ Actually, those were the things left after LLM was done optimizing. What Rustc produced was apparently\n\n\n ptr noalias noundef readonly align 4 captures(address, read_provenance) dereferenceable(8) %0\n\n\ncontaining these extra `captures(address, read_provenance)` annotations[1].\n\n* * *\n\n 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 ↩︎\n\n\n",
"title": "A read only no alias reference"
}