Skip to content

fix(cuda_std): pack warp shuffle/match return into i64 for LLVM 19 verifier - #391

Open
brandonros wants to merge 1 commit into
Rust-GPU:mainfrom
brandonros:llvm-19-fixes
Open

fix(cuda_std): pack warp shuffle/match return into i64 for LLVM 19 verifier#391
brandonros wants to merge 1 commit into
Rust-GPU:mainfrom
brandonros:llvm-19-fixes

Conversation

@brandonros

@brandonros brandonros commented May 3, 2026

Copy link
Copy Markdown
Contributor

if we land #386 this becomes smaller, opening it for now

fixes

Compiling cuda_std v0.2.2 (https://github.com/brandonros/Rust-CUDA.git?rev=38212ab745b6d257992e37bc0bc2b7b659bebed4#38212ab7)
  error: LLVM module verification failed for cuda_std.ee6756d2761d070-cgu.0: Attribute 'align 4' applied to incompatible type!
           %6 = call align 4 { i32, i8 } @__nvvm_warp_shuffle(i32 %mask, i32 %mode, i32 %value, i32 %b, i32 %5)
         Attribute 'align 4' applied to incompatible type!
         ptr @__nvvm_warp_shuffle
         

  error: could not compile `cuda_std` (lib) due to 1 previous error

  thread 'main' (192541) panicked at cli/build.rs:33:10:
  called `Result::unwrap()` on an `Err` value: BuildFailed
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

…rifier

LLVM 19's verifier rejects the `align N` return-attribute that rustc's
C ABI lowering attaches to calls returning small aggregates like
{ i32, i8 } (align is only valid on pointer returns). Three intrinsic
wrappers in libintrinsics.ll triggered this:
  - __nvvm_warp_shuffle
  - __nvvm_warp_match_all_32
  - __nvvm_warp_match_all_64

Switch their return type from { i32, i8 } to a packed i64 (low 32 bits
= value, bit 32 = predicate). Primitive integer return ⇒ no struct ABI
⇒ no spurious return-attribute. Uses only LLVM 1.0-era IR primitives
(zext/shl/or), so it's safe under both LLVM 7 (CUDA 12.x libnvvm) and
LLVM 19 (CUDA 13.x libnvvm). Removes the now-redundant
WarpShuffleResult struct.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@brandonros
brandonros marked this pull request as ready for review August 14, 2026 11:52
@brandonros

Copy link
Copy Markdown
Contributor Author

@LegNeato if we could land this one please, thank you very much

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.

1 participant