Fix return type and argument types for AMD intrinsics - #246
Merged
Conversation
idubinov
marked this pull request as draft
July 10, 2026 16:00
Collaborator
|
Both failing checks unrelated to this PR, and are WIP to fix |
Contributor
Author
|
also discussed in #186 |
aobolensk
reviewed
Jul 14, 2026
aobolensk
approved these changes
Jul 15, 2026
Contributor
Author
|
@MrSidims , @AlexVlx , @lamb-j , @jmmartinez |
idubinov
added a commit
that referenced
this pull request
Aug 10, 2026
Covers the reader-side counterpart of #246: a non-overloaded AMDGCN intrinsic that returns a pointer in the constant address space (llvm.amdgcn.implicitarg.ptr, ptr addrspace(4)) must be reconstructed from its canonical intrinsic declaration on reverse translation. The intrinsic is imported as an external function whose pointer return uses the Function storage class (addrspace(0)). Without the fix the reader rebuilds the declaration from that SPIR-V function type, dropping addrspace(4) and producing verifier-invalid IR; the test fails in that case.
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.
Recover AMDGCN intrinsic pointer address spaces from LLVM's intrinsic tables
Some AMDGCN intrinsics declare pointer operands/results in a specific address space — e.g. llvm.amdgcn.dispatch.ptr returns addrspace(4) (Constant). SPIR-V encodes pointers by storage class, so on a round-trip the reader reconstructs these as Generic, mismatching the intrinsic's declared type. The result is invalid IR (e.g. a ret ptr against a ptr addrspace(4) signature), which downstream crashes the COMGR JIT at first kernel launch.
This recovers the canonical (non-overloaded) function type from LLVM's intrinsic tables (generated from IntrinsicsAMDGPU.td) and uses it to re-tag both the return type and the parameters. Deriving the address spaces from the tables — instead of hardcoding intrinsic names or a fixed Constant AS — keeps the affected set of intrinsics tracking LLVM automatically and replaces the previous per-name special cases.