Skip to content

chore(deps): update Pliron for explicit struct layouts - #919

Merged
nihalpasham merged 2 commits into
NVIDIA:mainfrom
uurl:chore/update-pliron-struct-layout
Aug 16, 2026
Merged

nihalpasham merged 2 commits into
NVIDIA:mainfrom
uurl:chore/update-pliron-struct-layout

Conversation

@uurl

@uurl uurl commented Aug 15, 2026 •

Copy link
Copy Markdown
Contributor

Closes #918

Problem

  • LLVM has two struct layouts, and pliron previously could not tell them apart:
{ i8, i64 }     natural layout: 7 padding bytes after the i8, align 8
<{ i8, i64 }>   packed layout:  no padding, i64 sits at offset 1, align 1
  • pliron 0.17 (pliron#232) makes the layout explicit: every StructType construction now declares Unpacked or Packed. cuda-oxide had 31 construction sites and 3 struct-rebuild paths that needed to say which one they mean.
  • Without this, packed carriers (needed by Support pointer relocations in packed static initializers #930 for pointer relocations in repr(packed) statics) are not even representable in the IR.

Fix

  • bump pliron, pliron-derive, and pliron-llvm to the upstream revision containing pliron#232 (both the root workspace and crates/rustc-codegen-cuda move together, they must share one rev or types stop unifying)
  • all 31 synthetic construction sites pass StructLayout::Unpacked explicitly
  • the 3 paths that rebuild an existing struct (enum payload storage, type conversion, the byte-faithful twin) preserve the source layout instead of assuming one
  • adapt generated intrinsic construction and its generator, plus Identifier uses, to the 0.17 API
  • review follow-up c17e49e: the textual exporter now fails closed on a Packed struct with a clear error instead of silently printing it as unpacked { ... } (fix(mir-lower): preserve relocations in packed static initializers #931 replaces this guard with real <{ ... }> printing)

Gotchas

  • this PR makes packed representable but never uses it: no cuda-oxide code selects Packed yet, and behavior is unchanged
  • the bump carries 28 upstream pliron commits beyond the struct API (dialect conversion, hashing, containers), which is why validation below is the full sweep
  • merge order: this lands before fix(mir-lower): preserve relocations in packed static initializers #931, which builds the first real packed carriers on top

Testing and validation

  • full workspace tests, clippy on both workspaces, cargo deny check sources green on the pliron-org pin
  • generated-intrinsics consistency check, ABI history intact at 986 entries, all 986 intrinsic probes
  • full GPU smoketest on sm_120: 209/209 pass
  • CI green (43/43)

@nihalpasham nihalpasham added refactor Internal restructuring with no behavior change build-related Build scripts, toolchain discovery, or compilation setup Depends Blocked on another PR/issue or an upstream dependency labels Aug 16, 2026
@uurl
uurl force-pushed the chore/update-pliron-struct-layout branch from cdce5da to 24df1fc Compare August 16, 2026 04:41
@uurl
uurl marked this pull request as ready for review August 16, 2026 04:43
@nihalpasham nihalpasham added IR-lowering Lowering between dialects (dialect-mir to LLVM dialect) llvm-export Textual LLVM/NVVM IR exporter (llvm-export crate) and removed Depends Blocked on another PR/issue or an upstream dependency labels Aug 16, 2026
…xporter

The pliron bump to 8447aa42 introduces explicit StructLayout, but this
branch only prints the unpacked `{ ... }` spelling. A future Packed
struct reaching export_type would silently print as unpacked and change
the in-memory layout LLVM computes. Error out with a clear message
instead, and add a unit test constructing a Packed struct and asserting
the export fails.

Review follow-up for NVIDIA#919; real packed printing lands separately.
@nihalpasham

nihalpasham commented Aug 16, 2026 •

Copy link
Copy Markdown
Collaborator

Gist: clean migration, and thanks for the quick re-pin to upstream after pliron#232 merged. All 31 construction sites pass an explicit layout, the three rebuild paths preserve the source layout, and nothing in cuda-oxide selects Packed yet, which is the right scope for this PR.

What I checked and did (this one got the full treatment since the bump carries 28 upstream pliron commits, not just the struct API):

  • full workspace tests, clippy on both workspaces, cargo deny check sources (green on the pliron-org pin)
  • generated-intrinsics regen check, ABI history intact at 986 entries, all 986 intrinsic probes
  • full GPU smoketest on sm_120: 209/209 pass
  • pushed c17e49e: a fail-closed arm in the textual exporter so a Packed struct errors out instead of silently printing as unpacked { ... }; fix(mir-lower): preserve relocations in packed static initializers #931 replaces this guard with real <{ ... }> printing
  • CI fully green

Merge-order note: this lands before #931 so that branch can rebase down to just its relocation work. Closes #918 on merge.

@nihalpasham
nihalpasham merged commit 642eacf into NVIDIA:main Aug 16, 2026
45 of 47 checks passed
@uurl
uurl deleted the chore/update-pliron-struct-layout branch August 16, 2026 18:16
nihalpasham added a commit that referenced this pull request Aug 17, 2026
…m the tree (#964)

* docs(book): the dialect inventories in mlir-dialects have drifted from the tree

All four hand-maintained inventories on this page are stale and nothing
checks any of them. Counts below are from the tree at a766fc2.

**dialect-mir types: seven -> nine.** `mir.union` (Rust unions, every field
a view of the same bytes) and `mir.fp16` (`f16`) both have
`#[pliron_type(...)]` declarations in `dialect-mir/src/types.rs` and no row.
`mir.union` is load-bearing right now -- #857 and #927 are both about union
constants.

**dialect-mir operations: 54 across 11 categories -> 62 across 12.** Six
categories are short and one whole module is missing:

  control_flow   5 -> 6    `mir.unroll_hint`
  memory         9 -> 11   `mir.memcpy`, `mir.memmove`
  comparison     6 -> 7    `mir.cmp`
  aggregate      8 -> 10   `mir.construct_slice`, `mir.construct_disjoint_slice`
  enum_ops       3 -> 4    `mir.set_discriminant`
  debug          - -> 1    `mir.dbg_value`, absent from the table entirely

**LLVM dialect: 62 -> 69**, counted at the pinned `pliron` revision
(8447aa42), where `pliron-llvm/src/ops.rs` declares 51 ops with
`#[pliron_op(` plus 18 through its binop macros. The table gains
`indirectbr`, `insert_element`, `shuffle_vector`, `poison`, and a row for
the four with no existing category (`freeze`, `va_arg`, `blockaddress`,
`blocktag`).

Two of the names in it are wrong rather than merely missing:

  * `inline_asm_multi` does not exist. It is in no version of `pliron-llvm`
    and nowhere in this repository -- this page is the only place the string
    appears. Same shape as the fictional `shuffle_xor_{f32,i32}` rows #815
    removed from the API quick reference.
  * `extractelement` is spelled `llvm.extract_element`.

Also notes that `llvm-export` contributes one op of its own, `llvm.dbg_value`,
which the surrounding prose did not mention, and that this table tracks an
upstream crate -- so it moves when the pin moves (as it did in #919), not
when this repository changes.

**dialect-nvvm: 123 -> 543.** This one is not a drift so much as a different
tree. Six of the twelve modules listed no longer exist: `thread` and `warp`
are gone (the warp ops are now split across `warp_shuffle`, `redux`, `vote`,
`warp_match`, `warp_barrier`, `active_mask` and `elect`), and `mbarrier`
split into `mbarrier_basic` and `mbarrier_extended`. The counts for those
that do exist are 4x-9x low: `tcgen05` is listed at 24 and has 210, `tma` at
15 and has 111. Eighteen modules are missing outright, including `sreg` at 44
ops.

Rewritten around the split `adding-new-intrinsics.md` already documents --
7 hand-written modules (18 ops) against 34 generated ones (525 ops, resolved
from 986 catalog entries) -- because that is what decides where a
contributor would add an op, and a table that says `warp` when the file is
`ops/generated/warp_shuffle.rs` sends them to the wrong place.

The per-module "Minimum SM / GPU Family" columns go with it. Those
requirements are per intrinsic, not per module, and the catalog already
records them: `intrinsics/generated-reference.md` renders the PTX version and
minimum SM for each of the 986 entries and is regenerated with the ops. The
page now points there instead of keeping a second copy by hand.

`crates/dialect-mir/README.md` carries its own copy of the operation
inventory, stale in the same way and by a different amount (it says 55, and
already had `set_discriminant` the book was missing). That is a separate
file with no overlap here and is fixed separately.

Verified: every count above recomputed from the tree; `just book`
(`sphinx-build -W --keep-going`) succeeds; check-book-api-names,
check-toolchain-parity and check-cli-doc-coverage all pass.

Signed-off-by: Vyncint Ng <[email protected]>

* docs(book): stamp the dialect-nvvm counts to the catalog SHA

The page's own thesis is that unchecked hand counts drift. The LLVM
table got an "at the pinned pliron revision" stamp; give the
dialect-nvvm totals the equivalent anchor: the catalog SHA-256 that
every ops/generated/ file header prints. A reader can now tell at a
glance whether 543/41/986 describe the catalog they are looking at.

---------

Signed-off-by: Vyncint Ng <[email protected]>
Co-authored-by: nihalpasham <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build-related Build scripts, toolchain discovery, or compilation setup IR-lowering Lowering between dialects (dialect-mir to LLVM dialect) llvm-export Textual LLVM/NVVM IR exporter (llvm-export crate) refactor Internal restructuring with no behavior change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update Pliron dependency for explicit LLVM struct layouts

2 participants