Skip to content

Report llvmcall of unknown intrinsics at compile time - #958

Merged
maleadt merged 1 commit into
mainfrom
tb/unknown-intrinsic
Sep 26, 2026
Merged

maleadt merged 1 commit into
mainfrom
tb/unknown-intrinsic

Conversation

@maleadt

@maleadt maleadt commented Sep 25, 2026

Copy link
Copy Markdown
Member

Julia's codegen replaces an llvmcall of an intrinsic it doesn't know (ccall("llvm.foo", llvmcall, ...)) with a run-time jl_error("llvmcall only supports intrinsic calls"). GPUCompiler then lowers that to an anonymous device-side exception. That's how LLVM 21 removing llvm.nvvm.barrier0 and friends (which Julia 1.14 hits, being on LLVM 22) showed up in CUDA.jl: every kernel using sync_threads threw ERROR: a error was thrown during kernel execution.

This detects that specific jl_error both in lower_throw! (GPU targets) and in check_ir (targets that keep runtime calls), and raises an InvalidIRError pointing at the offending call:

InvalidIRError: compiling MethodInstance for kernel() resulted in invalid LLVM IR
Reason: unsupported call to an unknown LLVM intrinsic
Stacktrace:
 [1] kernel

Tested on native and PTX, on Julia 1.10 and nightly.

Julia's codegen replaces an `llvmcall` of an intrinsic it doesn't know
with a run-time `jl_error`, which we then lower to an anonymous device
exception. That made the removal of NVVM intrinsics in LLVM 21 (as used
by Julia 1.14) show up as every kernel calling `sync_threads` throwing
"a error" at run time. Detect the message and raise an InvalidIRError
pointing at the offending call instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Sep 26, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 62.06897% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.48%. Comparing base (0d06ee4) to head (1664b32).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
src/validation.jl 56.00% 11 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #958      +/-   ##
==========================================
- Coverage   86.54%   85.48%   -1.06%     
==========================================
  Files          29       29              
  Lines        5729     5830     +101     
==========================================
+ Hits         4958     4984      +26     
- Misses        771      846      +75     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@maleadt
maleadt merged commit 1a14748 into main Sep 26, 2026
31 of 33 checks passed
@maleadt
maleadt deleted the tb/unknown-intrinsic branch September 26, 2026 06:00
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