Repository navigation
test(mir-lower): assert the whole-aggregate payload move as a property - #680
Merged
nihalpasham merged 1 commit intoAug 7, 2026
Merged
Conversation
This was referenced Aug 6, 2026
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
force-pushed
the
test/whole-aggregate-payload-property
branch
from
August 6, 2026 16:36
05f7bd7 to
ae645f0
Compare
Collaborator
|
The restructure mentioned in the #675 review:
Merging. |
nihalpasham
approved these changes
Aug 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The test restructure you said was welcome as a follow-up on #675.
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 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 read out of
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:
{[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, so thenew 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 --checkandcargo test -p mir-lower --lib(167 tests) both pass, plusclippy -D warningsand the
llvm-export/dialect-mir/dialect-nvvmtest crates.The full workflow set also ran green on my fork for this same commit, which
covers what I cannot run locally (
cuda-hostandcuda-macrosneed the CUDAdriver):
unit-tests / cargo test -p mir-lower,mir-importer,cuda-device,cuda-intrinsics,cuda-async, the generated-intrinsics ABI check, plusfmt,naming-guard,status-guard,docsandcargo-deny. Those are my runnersrather 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