Repository navigation
fix: sanitize DICompositeType identifier symbols for NVVM compatibility (fixes #876) - #934
Open
reginaldalfret wants to merge 1 commit into
Conversation
This branch has not been deployed
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.
Fixes #876.
Problem
When compiling kernels with debug info or
lineinfo=True, composite types (such as structures, arrays, and tuples) emit LLVMDICompositeTypemetadata nodes.Previously,
DIBuilderpopulated theidentifierattribute withstr(lltype)directly (e.g."{i8*, i8*, i64, i64, [16 x i8]*, [1 x i64], [1 x i64]}").NVVM treats the
DICompositeTypeidentifierfield as a PTX symbol name for DWARF ODR type uniquing. Characters such as{,},[,],*,,, and whitespace are not valid PTX identifier characters. When kernels contain complex or nested record types, NVVM fails during compilation with:Solution
_symbol_safe_identifier(lltype_str)indebuginfo.pythat generates safe PTX symbol identifiers matching^[0-9A-Za-z_]+$using a sanitized prefix and a deterministic SHA-1 digest (preserving ODR type uniqueness).identifier: str(lltype)emission points inDIBuilderandCUDADIBuilderto use_symbol_safe_identifier.test_composite_type_identifier_symbol_safeto verify that generated LLVM IR contains only symbol-safe identifiers forDICompositeType.TestSymbolSafeIdentifierverifying character compliance, determinism, and collision resistance across arbitrary type strings.