Repository navigation
Conversation
The nested-niche test pinned its central property -- that an enum payload
moves as one unit, never field by field -- by counting accesses whose type
equalled the lowered payload tuple. That count is not a property of the
lowering under test. It depends on whether the enum's physical storage type
happens to coincide with the payload's.
For `Option<(i64, &T)>` it now does. The niche carrier claims the pointer at
byte 8, the 8 bytes below it lower to one `i64` filler, and the storage is
therefore `{i64, ptr}` -- the same interned type as the payload tuple. Every
whole-aggregate access carries that type, so the expected counts had to move
from 1 and 1 to 3 and 2, for a reason with nothing to do with what the test
checks. A type filter also stopped being able to tell the payload write from
the enum spill.
Assert the property directly instead. A lowering that decomposed the payload
is recognisable by what it emits: traffic in the tuple's *field* types. So
require that no store or load moves a bare `i64` or a bare `ptr`, and add two
non-vacuity checks that the complete tuple really is moved at least once each
way -- without those, a lowering that emitted no payload traffic at all would
pass.
Measured on both sides of the filler widening, the field-typed count is zero
either way while the tuple-typed counts differ:
before the widening stores: {[8 x i8],ptr} {i64,ptr} {[8 x i8],ptr}
loads: {[8 x i8],ptr} {i64,ptr}
after the widening stores: {i64,ptr} x3
loads: {i64,ptr} x2
The new assertion holds unchanged across that, which is the point of making
it. Verified by running the test at `upstream/main` with only this change
applied, as well as on top of the widening.
Refs NVIDIA#675
Signed-off-by: Vyncint Ng <[email protected]>
7f1f675 to
35558a8
Compare
|
Rebased onto Re-verified against the new
The two count assertions above the restructured block (3 stores, 2 loads) are unchanged from |
|
Gates are green. The upstream runs for this branch sit at
That closes the gap I flagged in the description: Caveat worth stating: these are my fork's runners, not an upstream run. Same workflow definitions, but if you would rather see it go green here, the runs just need approving. |
|
Superseded by #680 — same single commit, cut fresh from Closing this one because its history is noise now: the description was written while it was stacked on #675, and it carries a force-push from before that merged. #680 has none of that and a self-contained description. No change to the diff. |
The test restructure you said was welcome as a follow-up on #675.
#675 has merged, so this is now rebased onto
mainas a single commit(
35558a85) — the stacking note that was here is obsolete.What was weak
The test pinned its central property — an enum payload moves as one unit, never
field by field — by counting accesses whose type equalled the lowered payload
tuple. That count is not a property of the lowering under test. It depends on
whether the enum's physical storage type happens to coincide with the payload's.
For
Option<(i64, &T)>it now does: the niche carrier claims the pointer at byte8, the 8 bytes below it become one
i64filler, and the storage is{i64, ptr}— the same interned type as the payload tuple. So every whole-aggregate access
carries that type, the expected counts had to move from 1 and 1 to 3 and 2, and a
type filter stopped being able to separate the payload write from the enum spill.
What it asserts now
A lowering that decomposed the payload is recognisable by what it emits:
traffic in the tuple's field types. So the test now requires that no store or
load moves a bare
i64or a bareptr, with two non-vacuity checks that thecomplete tuple really is moved at least once each way — without those, a lowering
that emitted no payload traffic at all would pass.
The field types are taken from
lowered_tuplerather than hardcoded, so theassertion follows the tuple if its shape changes.
Why this is the right shape
I ran the same assertion on both sides of the filler widening. The field-typed
count is zero either way; only the tuple-typed counts differ:
upstream/main{[8 x i8],ptr},{i64,ptr},{[8 x i8],ptr}{[8 x i8],ptr},{i64,ptr}main){i64,ptr}×3{i64,ptr}×2field_tysis[i64, ptr]in both cases, and nothing matches it in either. Sothe new assertion holds unchanged across the change that broke the old one —
which is the whole point of making it.
Verified by applying only this test change to
upstream/main(without thewidening) and running it there, as well as on top of the widening.
Gates
cargo fmt --check— passcargo test -p mir-lower -p llvm-export -p dialect-mir -p dialect-nvvm --lib --tests— pass (165mir-lowertests, 88llvm-export)cuda-hostandcuda-macroscould not run on that machine —cuda-bindingsneeds the CUDA driver — so I ran the full workflow set on my fork instead; see the
comment below. No GPU is needed for any of this: the test is hardware-free.
Refs #675