Skip to content

refactor(llvm): use upstream inline asm semantics - #1309

Merged
nihalpasham merged 2 commits into
NVIDIA:mainfrom
uurl:refactor/llvm-inline-asm-upstream
Sep 23, 2026
Merged

nihalpasham merged 2 commits into
NVIDIA:mainfrom
uurl:refactor/llvm-inline-asm-upstream

Conversation

@uurl

@uurl uurl commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

What this fixes

Inline assembly now stores its side effects and convergence using upstream Pliron attributes. The dependency update and all constructor migrations are kept together because the final InlineAsmOp::new boolean changed from convergence to side effects.

before: private CUDA attributes duplicate inline-asm semantics
 after: upstream side-effect flag + unit convergent call-site attribute

AsmKind remains a convenience builder/query for the four supported combinations. LLVM export reads the upstream representation directly.

Maintainer follow-up

The upstream generic attribute container accepts more than this exporter implements. Added one shared check so the exporter and classification query accept absent attributes or unit convergent, and report unsupported names or value forms. Attributes such as noduplicate must not silently disappear.

Verification

  • Tests cover all four side-effect/convergence combinations using upstream constructors.
  • Verifier-valid noduplicate, integer-valued convergent, and string-valued convergent are rejected with precise diagnostics.
  • just check passed: 5,425 tests/doctests, formatting, strict Clippy, repository/license guards, intrinsic checks and warning-free docs. The suite intentionally ignored 168 tests/doctests.
  • RTX 5090: inline_ptx and barrier passed. Inline PTX memcheck and barrier synccheck report zero errors.
  • All seven hosted workflows passed at 85eb881c.

Supported scope

This migrates existing inline-asm semantics. It does not implement arbitrary generic LLVM function/call-site attributes.

Closes #1308 within the existing inline-asm attribute scope.

@uurl
uurl force-pushed the refactor/llvm-inline-asm-upstream branch from c8c279a to f809f6d Compare September 19, 2026 23:33
@nihalpasham
nihalpasham force-pushed the refactor/llvm-inline-asm-upstream branch from f809f6d to 85eb881 Compare September 23, 2026 06:12
@nihalpasham nihalpasham added 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 supply-chain Dependency policy: licenses, sources, security advisories, lock files labels Sep 23, 2026

@nihalpasham nihalpasham left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I kept the dependency and constructor migration together, and added one exporter check for the new generic attribute container. The four existing inline-asm combinations remain supported; attributes such as noduplicate now produce a clear error instead of silently disappearing, and convergent requires its unit form.

The added tests exercise upstream constructors and verifier-valid unsupported attributes. just check passes with 5,425 tests/doctests. The inline-PTX and barrier examples also pass on RTX 5090, with clean memcheck/synccheck. All seven hosted workflows passed at 85eb881c.

This addresses #1308 within the existing inline-asm attribute scope.

@nihalpasham
nihalpasham merged commit 40ad317 into NVIDIA:main Sep 23, 2026
55 checks passed
pifu-zh added a commit to pifu-zh/cuda-oxide that referenced this pull request Oct 6, 2026
…4 restored)

Rebase onto upstream ec4aa47 (74 commits) changed the exported .ll
shapes; four adaptations, each semantics-preserving:

- Step 4: tid.y/tid.z -> llvm.amdgcn.workitem.id.y/z (upstream NVIDIA#1311
  computes in-block rank via 3-D coords; on 1-D launches both sides
  return 0). Declares added to the mapped-strip list.
- Step 10: accept dynamic membermask ((1<<live)-1 from the partial-warp
  collectives) and clamp=0 for .up (PTX clamp is the min-source-lane
  bound for .up; ds_bpermute's data movement is mask-independent and
  the convergent marker carries the all-lanes-execute requirement).
- Step 12d: parse asm operands with top-level comma splitting - NVIDIA#1327
  packed-as3 emits constant-expression pointers
  (ptr addrspacecast (ptr addrspace(3) @sym to ptr)) that the old
  [^,)] captures could not span.
- Step 12e: panic trap is now inline PTX asm "trap;" (NVIDIA#1309) which the
  AMDGPU backend rejects; map to llvm.trap() (lowers to s_trap).

Batch tool: select artifacts by exact name - the old "*.opt.ll" glob
also matched the integrated pipeline's leftover *.amdgcn.preopt.opt.ll
(sorted first), so the Python dimension double-rewrote the wrong file;
the recorded 9/17 was measurement poisoning as much as shape drift.

Verified: batch 14/14 llc-pass; tests/test_gfx1030.py 14 passed.
pifu-zh added a commit to pifu-zh/cuda-oxide that referenced this pull request Oct 6, 2026
…tions

Mirror of the Python-pipeline adaptation (35bed77) on the integrated
path, for the two shapes the Rust prep pass also meets:

- Step 10 envelope: dynamic membermask accepted (upstream NVIDIA#1311
  partial-warp collectives emit (1<<live)-1 as SSA; ds_bpermute's data
  movement is mask-independent, convergent survives), and .up clamp=0
  accepted (PTX clamp bounds the lowest source lane for .up; the other
  modes keep width-1=31). Literal non-(-1) masks still fall through for
  llc to reject explicitly.
- Step 12e: panic trap is inline PTX asm post-NVIDIA#1309 and the AMDGPU
  backend rejects the mnemonic; map the exact shape to llvm.trap()
  (s_trap on gfx1030).

12d's store/load operand parsing already handled NVIDIA#1327 constant-
expression pointers via split_top_level_commas (no change needed).

Verified: dynamic-mask up@0 + trap-asm unit tests; lib 1252 green.
@uurl
uurl deleted the refactor/llvm-inline-asm-upstream branch November 21, 2026 03:30
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) llvm-export Textual LLVM/NVVM IR exporter (llvm-export crate) refactor Internal restructuring with no behavior change supply-chain Dependency policy: licenses, sources, security advisories, lock files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Migrate LLVM inline asm semantics to upstream Pliron attributes

2 participants