Skip to content

[FEA] DWARF discriminated union support for Python dynamic types in Numba-CUDAΒ #520

@jiel-nv

Description

@jiel-nv

Summary:
Add support for emitting DWARF discriminated union metadata (DW_TAG_variant_part) in the Numba-CUDA compiler to enable proper debugging of Python's dynamically-typed variables in CUDA kernels.

Motivation:
Python's dynamic type system allows variables to hold different types at runtime. When compiled to CUDA, these are represented as tagged unions (discriminated unions/variants). However, current debug info lacks the discriminant metadata that allows debuggers to automatically determine which union member is active, resulting in a less ideal debugging experience where developers see garbage values for inactive union members, and have to mentally choose the correct type and value.

Expected solution:
Generate proper DWARF discriminated union LLVM IR metadata with typed discriminant values.

One dependancy idenfied:
Needs llvmlite enhancement: Support typed constants in debug info metadata.
A PR is already submitted (PR#1326)

Some references are:

  1. LLVM DebugInfoMetadata.h: DIDerivedType::extraData field
  2. DWARF 5 Specification: Section 5.7.10 (Variant Entries)

Metadata

Metadata

Assignees

Labels

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions