Skip to content

fix: sanitize DICompositeType identifier symbols for NVVM compatibility (fixes #876) - #934

Open
reginaldalfret wants to merge 1 commit into
NVIDIA:mainfrom
reginaldalfret:fix/issue-876-lineinfo-symbol-safe-identifier
Open

reginaldalfret wants to merge 1 commit into
NVIDIA:mainfrom
reginaldalfret:fix/issue-876-lineinfo-symbol-safe-identifier

Conversation

@reginaldalfret

Copy link
Copy Markdown

Fixes #876.

Problem

When compiling kernels with debug info or lineinfo=True, composite types (such as structures, arrays, and tuples) emit LLVM DICompositeType metadata nodes.
Previously, DIBuilder populated the identifier attribute with str(lltype) directly (e.g. "{i8*, i8*, i64, i64, [16 x i8]*, [1 x i64], [1 x i64]}").
NVVM treats the DICompositeType identifier field 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:

error: Symbol name with unsupported characters

Solution

  1. Introduced helper _symbol_safe_identifier(lltype_str) in debuginfo.py that generates safe PTX symbol identifiers matching ^[0-9A-Za-z_]+$ using a sanitized prefix and a deterministic SHA-1 digest (preserving ODR type uniqueness).
  2. Updated all identifier: str(lltype) emission points in DIBuilder and CUDADIBuilder to use _symbol_safe_identifier.
  3. Added regression test test_composite_type_identifier_symbol_safe to verify that generated LLVM IR contains only symbol-safe identifiers for DICompositeType.
  4. Added unit test TestSymbolSafeIdentifier verifying character compliance, determinism, and collision resistance across arbitrary type strings.

@copy-pr-bot

copy-pr-bot Bot commented Sep 23, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

This branch has not been deployed

No deployments
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.

[BUG] Compilation with lineinfo detonates on large kernels

1 participant