fitzgen opened PR #13354 from fitzgen:alias-region-entity to bytecodealliance:main:
Generalize from
enum AliasRegion { Heap, Table, Vmctx, }into a proper entity, allowing users to define arbitrary numbers of custom alias
regions.
MemFlagsDatagrows aregion: PackedOption<AliasRegion>field instead of
bitpacking the alias region with the rest of its flags.The CLIF text format is also updated to support alias region declarations in the
function header, e.g.region0 = 0 "heap", with memflags referencing regions by
entity name instead of the old hardcoded keywords.Depends on https://github.com/bytecodealliance/wasmtime/pull/13353
fitzgen requested wasmtime-compiler-reviewers for a review on PR #13354.
fitzgen requested cfallin for a review on PR #13354.
fitzgen requested wasmtime-compiler-s390x-reviewers for a review on PR #13354.
fitzgen requested wasmtime-core-reviewers for a review on PR #13354.
fitzgen updated PR #13354.
github-actions[bot] added the label cranelift:area:aarch64 on PR #13354.
github-actions[bot] added the label cranelift on PR #13354.
github-actions[bot] added the label cranelift:meta on PR #13354.
github-actions[bot] added the label isle on PR #13354.
github-actions[bot] commented on PR #13354:
Subscribe to Label Action
cc @cfallin, @fitzgen
<details>
This issue or pull request has been labeled: "cranelift", "cranelift:area:aarch64", "cranelift:meta", "isle"Thus the following users have been cc'd because of the following labels:
- cfallin: isle
- fitzgen: isle
To subscribe or unsubscribe from this label, edit the <code>.github/subscribe-to-label.json</code> configuration file.
Learn more.
</details>
:memo: cfallin submitted PR review:
Thanks! Some thoughts below but overall shape looks good. Happy this worked out w.r.t. compile-time overheads!
:speech_balloon: cfallin created PR review comment:
we can just say "unused" here I guess -- no need to embed the history of the bits in the comment?
:speech_balloon: cfallin created PR review comment:
Duplicated comment (maybe a merge or rebase issue?)
:speech_balloon: cfallin created PR review comment:
PackedOptionmaybe soNonecan fit in thereserved_valueniche? I know this won't be as memory-critical today because it's dedup'd but if we end up with a lot of these it might still matter...
:speech_balloon: cfallin created PR review comment:
As long as we're manually implementing
Hashwe could do so forPartialEq/Eqas well for efficiency, since we can skipdedupe_mapfor that too (it's purely derived data), right?
:speech_balloon: cfallin created PR review comment:
Should this be the point in the API that's fallible, so we can propagate the u16-index-space allocation failure upward (e.g. to
wasmtime-craneliftwhen it uses these for a user-controlled number of regions)?
:speech_balloon: cfallin created PR review comment:
Since the last-fence becomes the fallback, could we clear
regionshere instead?
:speech_balloon: cfallin created PR review comment:
This seems like a fairly awkward and inefficient bit of plumbing to get the
MemFlagsSetdown to the point of emission -- maybe we could pass a borrow intoMachInst::emitinstead?Also, separately, it's a somewhat conspicuous layering violation: we have an IR type all the way down in the VCode. I'm not completely categorically opposed to that in all cases, but I wonder if we could lower
MemFlagDatato a "core" memflags actually semantically meaningful at the VCode layer (so, no alias regions any more, just trap info and the like) and use that in the backends?
:speech_balloon: cfallin created PR review comment:
here's another example where we might benefit from having a VCode-specific "core memflags": the printed form here is relatively useless (refers to an index of an entity that we don't print anywhere else in the disassembly) whereas ideally we'd print the same as before, after lowering.
fitzgen updated PR #13354.
fitzgen commented on PR #13354:
@cfallin okay I fixed the rebase, cleaned up the region clearing, and introduced
MachMemFlags. Think this is ready for re-review!
github-actions[bot] added the label cranelift:area:x64 on PR #13354.
:thumbs_up: cfallin submitted PR review:
Generally looks good -- just some nits below. Thanks!
:speech_balloon: cfallin created PR review comment:
Maybe we could move the definition here instead of defining it in
irand aliasing it?
:speech_balloon: cfallin created PR review comment:
Eek -- unsafe-transmute: can we add a const constructor if we need one instead?
:speech_balloon: cfallin created PR review comment:
comment nit: same as
MemFlagsData's previous representation, but we've now moved it solely into this type (and composed the outer struct around it), no? It might be good to also move the bitpacking comment here (to the field) since we discarded it above.
fitzgen updated PR #13354.
:memo: fitzgen submitted PR review.
:speech_balloon: fitzgen created PR review comment:
I had thought this would require invasive changes to the
ReservedValuetrait, but realized I could avoid that by adding a raw constructor toPackedOptionthat just takes the inner value and itsSomeif the raw inner value is not the reserved value, andNoneotherwise.
fitzgen updated PR #13354.
fitzgen updated PR #13354.
fitzgen has enabled auto merge for PR #13354.
fitzgen updated PR #13354.
fitzgen updated PR #13354.
fitzgen updated PR #13354.
fitzgen updated PR #13354.
fitzgen added PR #13354 cranelift: Turn AliasRegion into an entity stored in the DFG to the merge queue.
github-merge-queue[bot] removed PR #13354 cranelift: Turn AliasRegion into an entity stored in the DFG from the merge queue.
fitzgen updated PR #13354.
fitzgen has enabled auto merge for PR #13354.
fitzgen added PR #13354 cranelift: Turn AliasRegion into an entity stored in the DFG to the merge queue.
github-merge-queue[bot] removed PR #13354 cranelift: Turn AliasRegion into an entity stored in the DFG from the merge queue.
fitzgen updated PR #13354.
fitzgen has enabled auto merge for PR #13354.
fitzgen added PR #13354 cranelift: Turn AliasRegion into an entity stored in the DFG to the merge queue.
:check: fitzgen merged PR #13354.
fitzgen removed PR #13354 cranelift: Turn AliasRegion into an entity stored in the DFG from the merge queue.
Last updated: Jun 01 2026 at 09:49 UTC