Skip to content

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

Merged
nihalpasham merged 1 commit into
NVIDIA:mainfrom
vyncint:test/whole-aggregate-payload-property
Aug 7, 2026
Merged

nihalpasham merged 1 commit into
NVIDIA:mainfrom
vyncint:test/whole-aggregate-payload-property

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.

Single commit on top of main (981b9eb0), one file, test-only. Replaces #678,
which carried a stale "stacked on #675" description and a force-push from before
that PR merged; this branch is cut fresh so there is nothing to read around.

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 read out of 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
before #675 {[8 x i8],ptr}, {i64,ptr}, {[8 x i8],ptr} {[8 x i8],ptr}, {i64,ptr}
after #675 (now 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 point of making it. Verified by applying only this test change to the
pre-#675 tree and running it there, as well as on main.

Gates

Local, on the pinned toolchain: cargo fmt --check and
cargo test -p mir-lower --lib (167 tests) both pass, plus clippy -D warnings
and the llvm-export / dialect-mir / dialect-nvvm test crates.

The full workflow set also ran green on my fork for this same commit, which
covers what I cannot run locally (cuda-host and cuda-macros need the CUDA
driver): unit-tests / cargo test -p mir-lower, mir-importer, cuda-device,
cuda-intrinsics, cuda-async, the generated-intrinsics ABI check, plus fmt,
naming-guard, status-guard, docs and cargo-deny. Those are my runners
rather than an upstream run — the runs here need approving to go green.

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/whole-aggregate-payload-property branch from 05f7bd7 to ae645f0 Compare August 6, 2026 16:36
@nihalpasham nihalpasham added tests Adds or improves test coverage refactor Internal restructuring with no behavior change IR-lowering Lowering between dialects (dialect-mir to LLVM dialect) labels Aug 7, 2026
@nihalpasham

Copy link
Copy Markdown
Collaborator

The restructure mentioned in the #675 review:

  • the property is asserted directly (no store or load may carry a bare payload-field type, derived from the lowered tuple rather than hardcoded), with non-vacuity checks so silence cannot pass;
  • the exact total counts stay as the backstop against byte-wise decomposition, which the field filter alone would miss;
  • the assertion holds on both sides of perf(mir-lower): type an enum's unclaimed bytes as one integer #675's filler widening; cargo test -p mir-lower green here (167 + 88).

Merging.

@nihalpasham
nihalpasham merged commit 577174e into NVIDIA:main Aug 7, 2026
34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

IR-lowering Lowering between dialects (dialect-mir to LLVM dialect) refactor Internal restructuring with no behavior change tests Adds or improves test coverage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants