Repository navigation
Done
Labels
craneliftIssues related to the Cranelift code generator
Description
This test:
test interpret
test run
set opt_level=speed
target x86_64
target aarch64
;; A load with no alias region may alias any region, so it must observe a
;; preceding store that carries an alias region. Alias analysis instead keys
;; the regionless load on `last_fence` only and forwards the value of the
;; earlier region0 load (v1 = 1), dropping the intervening store of 42.
function %regionless_load_after_region_store(i64) -> i32 {
ss0 = explicit_slot 4
region0 = 0 "heap"
block0(v0: i64):
v9 = stack_addr.i64 ss0
v8 = iconst.i32 1
store notrap v8, v9
v1 = load.i32 notrap region0 v9
v2 = iconst.i32 42
store notrap region0 v2, v9
v3 = load.i32 notrap v9
v4 = iadd v3, v1
return v4
}
; run: %regionless_load_after_region_store(0) == 43
fails with:
$ cargo run -p cranelift-tools test ./regionless-load.clif
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.07s
Running `/home/alex/code/wasmtime2/target/debug/clif-util test ./regionless-load.clif`
[2026-09-11T21:06:41Z ERROR cranelift_filetests::concurrent] FAIL: run
FAIL ./regionless-load.clif: run
Caused by:
Failed test: run: %regionless_load_after_region_store(0) == 43, actual: 2
1 tests
Error: 1 failure
and a similar test case:
test interpret
test run
set opt_level=speed
target x86_64
function %dse(i64) -> i32 {
ss0 = explicit_slot 4
region0 = 0 "heap"
block0(v0: i64):
v9 = stack_addr.i64 ss0
v2 = iconst.i32 42
store notrap region0 v2, v9
v3 = load.i32 notrap v9
v5 = iconst.i32 7
store notrap region0 v5, v9
return v3
}
; run: %dse(0) == 42
fails with:
$ cargo run -p cranelift-tools test ./regionless-load-dse.clif
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.12s
Running `/home/alex/code/wasmtime2/target/debug/clif-util test ./regionless-load-dse.clif`
[2026-09-11T21:07:29Z ERROR cranelift_filetests::concurrent] FAIL: run
FAIL ./regionless-load-dse.clif: run
Caused by:
Failed test: run: %dse(0) == 42, actual: -2147474110
1 tests
Error: 1 failure
a full llm-generated report is here if that's useful. I'm relatively certain that this is not UB and the tests here are correct, but I'm not 100% certain. If this is IR-level UB then this can just be closed.
cc @fitzgen
Metadata
Metadata
Assignees
Labels
craneliftIssues related to the Cranelift code generator
Activity
agourakis82 commentedon Sep 22, 2026
Opened #14373 for this.
agourakis82 commentedon Sep 22, 2026
PR: #14373
Before the patch, a regionless load only looked at
last_fence, so it could miss a laterregion0store to the same address.cfallin commentedon Sep 22, 2026
(Sorry, just saw this because of the recent comments bumping it)
In my understanding at least, "no region" is a separate region than a concrete region. The definition here is ambiguous, so happy to discuss at the Cranelift meeting and we can pin it down one way or another.
(I don't care too strongly either way, but I believe it's a little clearer to think of it in the above way, i.e. it's a simpler mental model not to have special "globally aliasing" operations; it fits how we use regions in Wasmtime just fine; and it is simpler and less error-prone to implement.)
agourakis82 commentedon Sep 22, 2026
Thanks. Docs are ambiguous either way.
#14373 follows the reading in the issue report. If the meeting lands on explicit no-region, I can close/rework it.
agourakis82 commentedon Sep 22, 2026
One concrete asymmetry in the current code:
last_fenceSo loads and stores disagree today. The two clean options seem to be:
I’m fine implementing either once that’s pinned down.
cfallin commentedon Sep 22, 2026
Interesting -- for whatever it's worth, this appears to be a behavior change with the new alias analysis work. Looking at the code as of here (Jan of this year), which is the original fixed-four-region design, no-region is explicitly a separate region when handling stores (and loads are consistent with this).
cranelift: treat regionless loads as aliasing all regions
agourakis82 commentedon Sep 22, 2026
I did try the explicit-no-region store change locally. It breaks
alias/issue-13508.clifunder the current expectations ([-1,-1,42]), because that runtest wants a regionless store to be visible to a later named-region load.That doesn’t settle the design — as noted below, the test encodes the newer semantics. Just recording what I hit when I tried the other direction.
cfallin commentedon Sep 22, 2026
Well, the test encodes the new semantics. I wouldn't say that that "falsifies" the choice. If we make the other choice, we write a test that encodes those semantics. The test appears to have been added as part of the new alias analysis work (and I even approved it and missed this change, oops!). So I think I'd still like to have the discussion, especially since this diverges from what we originally had.
(As an aside, please (i) don't use AI to write comments, and (ii) let's not attach design points to specific people; it distracts from the technical points and the real reasons we might prefer one or the other. Let's say "explicit no-region" and "no-region as fence", with the original semantics being the former and current semantics being the latter.)
agourakis82 commentedon Sep 22, 2026
Fair point on the test — it encodes the current semantics, it doesn’t prove them. Thanks for the January pointer; I hadn’t checked that the original path treated no-region as its own store bucket.
I’ll wait for the meeting and stick to “explicit no-region” vs “no-region as fence”.
If it’s explicit no-region, I can rework #14373 that way. If it’s no-region as fence, the current direction stays.
Sorry about the earlier comments.
alexcrichton commentedon Sep 22, 2026
I've personally got no horse in this race. This was an LLM-found issue which smelled fishy to me so I opened an issue, but if the conclusion is that this is working as intended then I have no objection to just closing this.
fitzgen commentedon Sep 22, 2026
I thought that we always treated regionless stores as fences that alias everything, and regionless loads as limited to the implicit "anonymous" region, and I've been somewhat bending over backwards to preserve those semantics. But given this comment it seems like I misunderstood the existing semantics and made all this up. If that's the case, then it would be much easier for us long term to simplify the semanticsand stop treating regionless stores as fences and instead just as stores to the "anonymous" region.
agourakis82 commentedon Sep 22, 2026
Reworked #14373 to restore explicit no-region (loads and stores both use the disjoint “other” bucket; only real fences touch everything). That matches the older alias-analysis behavior.
Under that rule, the original same-address mixed-tag example is outside the frontend invariant. If that is the meeting outcome, we can close this when the PR lands.