Add DWARF variant part support for polymorphic variables in CUDA debug info #544
All Vouch review confidence checks passed
Residual risk 0.18 = Change Risk (0.45) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.45 · 431 lines diff across 5 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.363
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #544"
general
weight: 0.35
jiel-nv
Overview
This PR implements proper DWARF debug information generation for polymorphic variables in Numba CUDA kernels using
DW_TAG_variant_part(discriminated unions). This enables debuggers like cuda-gdb to correctly inspect polymorphic variables that can hold different types throughout their lifetime.Key Changes
1. Enhanced Polymorphic Variable Lowering (
lowering.py)CUDA_DEBUG_POLYenabled:- Allocates storage for discriminant + data
- Stores discriminant at offset 0 and data at offset
sizeof(fetype)- Retrieves data pointer with proper offset calculation
- Memory layout:
``
[discriminant: 8 bits][padding][data: varies by type]
`variant_wrapper_struct (DW_TAG_structure_type)
├── discriminator (DW_TAG_member, 8 bits)
└── variant_part (DW_TAG_variant_part)
├── _bool (DW_TAG_member, extraData: 0, offset: 8)
├── _float64 (DW_TAG_member, extraData: 1, offset: 64)
├── _int32 (DW_TAG_member, extraData: 2, offset: 32)
└── _int64 (DW_TAG_member, extraData: 3, offset: 64)
Added llvmlite version-dependent logic for extraDataemission:i8 N- Typed constant (
) for newer llvmlite versions (> 0.45)CUDA_DEBUG_POLY_USE_TYPED_CONST- Metadata node reference for older versions (<= 0.45), requires an in progress nvvm patch
- Controlled by
config flag
Added CTK version threshold check:
test_debuginfo.py- Feature enabled: When CTK > 13.1
- Feature disabled: When CTK <= 13.1
3. Test Coverage (
)
Added a new test test_poly_variant_part()to verify DWARF output:CUDA_DEBUG_POLY- Conditionally turns on, opt-in via
configuration flagCUDA_DEBUG_POLY_USE_TYPED_CONST- Validates complete hierarchical structure: DILocalVariable → wrapper struct → elements list → discriminator + variant_part → variant members
- Dynamically adapts FileCheck patterns based on
Without CUDA_DEBUG_POLY- Verifies all variant members (_bool, _float64, _int32, _int64) with correct offsets
4. Backward Compatibility
: Falls back to existing behavior, i.e. user mentally choose runtime type from a union like types wrapper in a debugging session.
Older test ( test_union_poly_types`) preserved and conditionally skippedThis change implements issue#520.
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
Summary by CodeRabbit
New Features
Added support for polymorphic debug information for CUDA union types, enabling enhanced debugging capabilities with structured variant metadata.
Introduced new configuration flags to control polymorphic debug behavior and data representation modes.
Tests
* Added test coverage for polymorphic variant-part debugging information under various configuration scenarios.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->