Skip to content

test(mir-lower): assert the whole-aggregate payload move as a property - #678

Closed
vyncint wants to merge 1 commit into
NVIDIA:mainfrom
vyncint:test/nested-niche-whole-aggregate
Closed

vyncint wants to merge 1 commit into
NVIDIA:mainfrom
vyncint:test/nested-niche-whole-aggregate

Conversation

@vyncint

@vyncint vyncint commented Aug 6, 2026 •

Copy link
Copy Markdown
Contributor

The test restructure you said was welcome as a follow-up on #675.

the weakened type-discrimination in the nested-niche test is fine as-is;
the restructure you offered is welcome as a follow-up.

#675 has merged, so this is now rebased onto main as 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 byte
8, the 8 bytes below it become one i64 filler, 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 i64 or a bare ptr, with 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.

The field types are taken from lowered_tuple rather than hardcoded, so the
assertion 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:

stores loads
at upstream/main {[8 x i8],ptr}, {i64,ptr}, {[8 x i8],ptr} {[8 x i8],ptr}, {i64,ptr}
with #675 (now on main) {i64,ptr} ×3 {i64,ptr} ×2

field_tys is [i64, ptr] in both cases, and nothing matches it in either. So
the 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 the
widening) and running it there, as well as on top of the widening.

Gates

  • cargo fmt --check — pass
  • cargo test -p mir-lower -p llvm-export -p dialect-mir -p dialect-nvvm --lib --tests — pass (165 mir-lower tests, 88 llvm-export)

cuda-host and cuda-macros could not run on that machine — cuda-bindings
needs 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

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]>
@vyncint
vyncint force-pushed the test/nested-niche-whole-aggregate branch from 7f1f675 to 35558a8 Compare August 6, 2026 15:05
@vyncint

vyncint commented Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto main now that #675 has merged: dropped the duplicated commit and this is a single commit, 35558a85. The stacking note in the description is gone.

Re-verified against the new main rather than assuming, since #673 landed in between and touches enum payload writing (its aggregate.rs change turned out to be an error-message string only):

  • cargo fmt --check — pass
  • cargo test -p mir-lower -p llvm-export -p dialect-mir -p dialect-nvvm --lib --tests — pass (167 mir-lower, 88 llvm-export)
  • cargo clippy -D warnings on those four crates — pass

The two count assertions above the restructured block (3 stores, 2 loads) are unchanged from main and still hold, so #673 did not move them.

@vyncint

vyncint commented Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

Gates are green. The upstream runs for this branch sit at action_required pending approval, so I ran the same workflows on my fork (base synced to 981b9eb0, so the diff is exactly the one commit here):

  • unit-tests / cargo test -p mir-lower — success
  • unit-tests also green for mir-importer, cuda-device, cuda-intrinsics, cuda-async, and the generated-intrinsics ABI check
  • fmt, naming-guard, status-guard, docs, cargo-deny / dependency-licenses.csv — success

That closes the gap I flagged in the description: cuda-host and cuda-macros could not run on the machine I used, because cuda-bindings needs the CUDA driver, and CI covers them.

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.

@vyncint

vyncint commented Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

Superseded by #680 — same single commit, cut fresh from main (981b9eb0).

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.

@vyncint vyncint closed this Aug 6, 2026
@vyncint
vyncint deleted the test/nested-niche-whole-aggregate branch August 6, 2026 15:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant