Skip to content

debug: preserve supported thin-pointer pointee types - #1126

Merged
nihalpasham merged 1 commit into
mainfrom
fix/debug-thin-pointer-pointees
Aug 28, 2026
Merged

nihalpasham merged 1 commit into
mainfrom
fix/debug-thin-pointer-pointees

Conversation

@nihalpasham

@nihalpasham nihalpasham commented Aug 21, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

cuda-gdb can now see and dereference the pointee type for the thin pointers we
can describe safely.

Debugger view Before After
whatis ptr *mut () *mut i32
print *ptr void/unknown pointee 10
pointer address correct unchanged

Closes #1119.

Changes

  • Add a typed-pointer debug node with a required DWARF baseType.
  • Support primitives, fixed arrays, and finite chains of thin pointers and
    references.
  • Keep the old opaque pointer node for fat, composite, cyclic, and unsupported
    pointees so existing variables do not disappear.
  • Reject malformed mixed typed/opaque trees during decoding and export.

This is deliberately partial: slices, trait objects, and recursive composite
types still need richer graph/fat-pointer metadata.

Testing

  • llvm-export and mir-importer full suites, strict Clippy, formatting,
    llvm-as, and opt passed.

  • CUDA 13.3 / RTX 5090: T06/T19 now show *mut i32 / *mut f32 and
    dereference correctly; unsupported T07/T15 variables remain visible.

  • just check passes (affected suites pass)

  • Live GPU debugger regression exercised

  • New example added (not needed; focused regression added)

Checklist

  • All commits signed off (git commit -s)
  • SPDX headers on new source files (no new source files)

Questions about the review? Ping us in #contributors on Discord.

Carry a required pointee debug type for the proven thin raw-pointer and reference subset so LLVM emits a non-null DWARF baseType. Retain the existing opaque pointer metadata for fat, composite/cyclic, and otherwise unsupported pointees so their variables remain visible without claiming unsupported structure.

Signed-off-by: nihalp <[email protected]>
@nihalpasham nihalpasham added bug Something isn't working debug info Debug information in generated PTX/IR (line/source maps) codegen Device code-generation pipeline (Rust MIR to IR to PTX) llvm-export Textual LLVM/NVVM IR exporter (llvm-export crate) labels Aug 21, 2026
@nihalpasham
nihalpasham marked this pull request as ready for review August 28, 2026 11:23
@nihalpasham
nihalpasham merged commit 3ddb6d8 into main Aug 28, 2026
50 checks passed
nihalpasham added a commit that referenced this pull request Aug 28, 2026
Reworked onto main's #1186 device-global declaration cache: debug
identity rides DeviceGlobalDeclaration as an equality-checked field
instead of a parallel record type, the promoted-key fingerprint keeps
main's align component under the domain tag, and the encoder covers
the TypedPointer debug type from #1126.

Signed-off-by: nihalp <[email protected]>
nihalpasham added a commit that referenced this pull request Aug 28, 2026
* debug: describe AS1 device globals

Reworked onto main's #1186 device-global declaration cache: debug
identity rides DeviceGlobalDeclaration as an equality-checked field
instead of a parallel record type, the promoted-key fingerprint keeps
main's align component under the domain tag, and the encoder covers
the TypedPointer debug type from #1126.

Signed-off-by: nihalp <[email protected]>

* fix(mir): keep mixed-pointee reference unions valid as device-static storage

#1186 tightened classify_union_constant_storage so SharedRef union
alternatives with different pointee types fail closed. That is right
for SSA reconstruction, which mints the carrier field's own reference
type and could claim validity for a pointee the program never wrote.
But the device-static initializer gate shares the classifier while
emitting only exact bytes plus one integer-width relocation slot; no
typed reference is ever minted, and device code reads the storage
through its own field types.

Release builds hid the regression because optimized MIR folds the
example's union load away; any unoptimized device build (including
CUDA_OXIDE_DEBUG=full) materializes the static and failed to compile
device_global's documented union { word: &'static u32, byte: &'static u8 }
shape. Thread a UnionConstantUse through the classifier so the SSA path
keeps the pointee-identity rejection and the physical-storage gate does
not, and cover the SharedRef mixed-pointee shape at both call sites.

Signed-off-by: nihalp <[email protected]>

---------

Signed-off-by: nihalp <[email protected]>
nihalpasham added a commit that referenced this pull request Aug 28, 2026
Reworked onto main's #1186 shared-globals cache: the debug identity
(variable info plus owner function) rides SharedGlobalDeclaration next
to the storage fields, physical mismatches keep main's incompatible-
declaration error, and divergent debug identities on one alloc_key now
fail open by dropping the attachment instead of failing full-debug
builds that release accepts. The physical gate uses llvm_type_size_align
(get_type_size was removed by #1186), the owner subprogram cache is
keyed by the exported linkage name to compose with #1127's source/
linkage split, and typed thin pointers from #1126 are admitted through
the shared debug-type gate.

Signed-off-by: nihalp <[email protected]>
@nihalpasham nihalpasham mentioned this pull request Aug 28, 2026
4 of 5 tasks
nihalpasham added a commit that referenced this pull request Aug 28, 2026
Reworked onto main's #1186 shared-globals cache: the debug identity
(variable info plus owner function) rides SharedGlobalDeclaration next
to the storage fields, physical mismatches keep main's incompatible-
declaration error, and divergent debug identities on one alloc_key now
fail open by dropping the attachment instead of failing full-debug
builds that release accepts. The physical gate uses llvm_type_size_align
(get_type_size was removed by #1186), the owner subprogram cache is
keyed by the exported linkage name to compose with #1127's source/
linkage split, and typed thin pointers from #1126 are admitted through
the shared debug-type gate.

Signed-off-by: nihalp <[email protected]>
nihalpasham added a commit that referenced this pull request Aug 28, 2026
Reworked onto main's #1186 shared-globals cache: the debug identity
(variable info plus owner function) rides SharedGlobalDeclaration next
to the storage fields, physical mismatches keep main's incompatible-
declaration error, and divergent debug identities on one alloc_key now
fail open by dropping the attachment instead of failing full-debug
builds that release accepts. The physical gate uses llvm_type_size_align
(get_type_size was removed by #1186), the owner subprogram cache is
keyed by the exported linkage name to compose with #1127's source/
linkage split, and typed thin pointers from #1126 are admitted through
the shared debug-type gate.

Signed-off-by: nihalp <[email protected]>
@nihalpasham nihalpasham mentioned this pull request Aug 28, 2026
4 of 5 tasks
@nihalpasham
nihalpasham deleted the fix/debug-thin-pointer-pointees branch August 28, 2026 12:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working codegen Device code-generation pipeline (Rust MIR to IR to PTX) debug info Debug information in generated PTX/IR (line/source maps) llvm-export Textual LLVM/NVVM IR exporter (llvm-export crate)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Full debug: preserve pointee types for supported thin pointers and references

1 participant