-
Notifications
You must be signed in to change notification settings - Fork 39
Description
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:
- LLVM DebugInfoMetadata.h: DIDerivedType::extraData field
- DWARF 5 Specification: Section 5.7.10 (Variant Entries)