Skip to content

[nvq++] Remove kernel bodies in fixup-linkage#3874

Queued
lmondada wants to merge 2 commits intoNVIDIA:mainfrom
lmondada:lm/fixup-linkage-llvm
Queued

[nvq++] Remove kernel bodies in fixup-linkage#3874
lmondada wants to merge 2 commits intoNVIDIA:mainfrom
lmondada:lm/fixup-linkage-llvm

Conversation

@lmondada
Copy link
Collaborator

@lmondada lmondada commented Feb 5, 2026

Currently, in MLIR mode kernel bodies are compiled by clang but never called: the MLIR-compiled kernels always shadow the LLVM-compiled ones. This PR removes these kernel bodies in the LLVM IR, when in MLIR mode. This will speed-up compilation and (in MLIR mode) will allow us to remove definitions of C++ types and functions that are only used within kernels (e.g. cudaq::qvector).

This PR is made of 2 commits, which can be reviewed independently:

  • the first commit rewrites the fixup-linkage script using LLVM instead of ad-hoc string/regexp parsing of .ll files. The rewritten script is equivalent to the original
  • the second commit uses the parsed LLVM module to replace the body of each kernel function with a body made of a single unreachable op. If this op is ever reached, the program would crash, but because the program control flow is always redirected to the MLIR kernels, this can never happen.

Signed-off-by: Luca Mondada <luca@mondada.net>
Signed-off-by: Luca Mondada <luca@mondada.net>
@lmondada lmondada marked this pull request as ready for review February 5, 2026 22:34
@lmondada lmondada requested a review from 1tnguyen February 5, 2026 22:34
github-actions bot pushed a commit that referenced this pull request Feb 5, 2026
@github-actions
Copy link

github-actions bot commented Feb 5, 2026

CUDA Quantum Docs Bot: A preview of the documentation can be found here.

@lmondada lmondada requested a review from Renaud-K February 5, 2026 23:12
@lmondada lmondada enabled auto-merge February 5, 2026 23:12
Copy link
Collaborator

@1tnguyen 1tnguyen left a comment

Choose a reason for hiding this comment

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

👍

@lmondada lmondada added this pull request to the merge queue Feb 6, 2026
@lmondada lmondada removed this pull request from the merge queue due to a manual request Feb 6, 2026
@lmondada lmondada added this pull request to the merge queue Feb 6, 2026
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.

2 participants