Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR upgrades the QIR-QIS compiler from LLVM 14 to LLVM 21 and adds support for QIR 2.0 (opaque pointer) conversion. The changes span the entire compilation pipeline: parsing, decomposition, conversion, optimization, verification, and testing. Significant effort is spent on Windows compatibility workarounds where LLVM 21 APIs behave differently.
Changes:
- Upgrade from LLVM 14 (
llvm-sys 140,inkwell llvm14-0) to LLVM 21 (llvm-sys 211,inkwell llvm21-1), migrating all typed pointer APIs (%Qubit*,i8*,i64*) to opaque pointer (ptr) APIs and updatingbuild_gep/build_loadsignatures to include explicit types. - Add QIR 2.0 support: new test fixtures (
qir2_base.ll,qir2_adaptive.ll), updated module flag validation to acceptqir_major_version1 or 2, newparse_geplogic to resolve unnamed globals via LLVM C APIs, and direct-to-module decomposition building (replacing module linking + inlining). - Windows-specific safety workarounds: custom
llvm_verifymodule,#[cfg(windows)]guards for target initialization, CPU feature detection, metadata validation, and test snapshot skipping; plus build system updates (pyproject.toml,Cargo.toml) for LLVM 21 on all platforms.
Reviewed changes
Copilot reviewed 26 out of 27 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
Cargo.toml / Cargo.lock |
Upgrade inkwell to llvm21-1 and llvm-sys to 211.0.0 |
src/lib.rs |
Update entry processing to pass array types, Windows cfg guards, QIR 2.0 major version acceptance, trace logging, attribute cleanup changes |
src/convert.rs |
Migrate to opaque pointer LLVM APIs, new get_required_num_qubits_strict, parse_gep rewrite with LLVM C API fallback, prune_unused_ir_qis_helpers, sanitize_label_for_global_name, test helper changes |
src/decompose.rs |
Build decompositions directly into module (no linking), add per-step verification, use get_or_create_decomposition_function, change linkage from LinkOnceODR to External for native gates |
src/opt.rs |
Early return for O0, Windows cfg guards for CPU features and native target init, trace logging |
src/llvm_verify.rs |
New module for platform-safe LLVM module verification via C API |
pyproject.toml |
Update build config for LLVM 21 on Linux/macOS/Windows |
README.md / qtm-qir-reference.md |
Document LLVM 21 requirement and QIR 1.0/2.0 pointer forms |
tests/data/qir2_base.ll / tests/data/qir2_adaptive.ll |
New QIR 2.0 test fixtures |
tests/snaps/*.snap |
Updated snapshots for opaque pointer output, new global naming, and reordered declarations |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This was referenced Mar 6, 2026
This was referenced Mar 6, 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.
Summary
Support QIR 2.0 conversion and fold in the LLVM 21 CI, wheel, and release updates needed for this work to validate cleanly.
Closes #3
Included
Limitations
native,opt_level=0) rather than the cross-targetaarch64optimized path still exercised on Linux and macOS.aarch64optimized example compilation has been flaky there. Keeping Windows on the host-target path preserves meaningful API and codegen coverage without blocking the PR on a Windows-specific backend issue.