Skip to content

[SPIR-V] Fix an issue with casting types in debug-info extension implementation #129721

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions llvm/lib/Target/SPIRV/SPIRVEmitNonSemanticDI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,9 @@ bool SPIRVEmitNonSemanticDI::emitGlobalDI(MachineFunction &MF) {
// pointed on from other DI types
// DerivedType->getBaseType is null when pointer
// is representing a void type
if (DerivedType->getBaseType())
BasicTypes.insert(
cast<DIBasicType>(DerivedType->getBaseType()));
if (auto *BT = dyn_cast_or_null<DIBasicType>(
DerivedType->getBaseType()))
BasicTypes.insert(BT);
}
}
}
Expand Down Expand Up @@ -330,7 +330,7 @@ bool SPIRVEmitNonSemanticDI::emitGlobalDI(MachineFunction &MF) {
// If the Pointer is representing a void type it's getBaseType
// is a nullptr
const auto *MaybeNestedBasicType =
cast_or_null<DIBasicType>(PointerDerivedType->getBaseType());
dyn_cast_or_null<DIBasicType>(PointerDerivedType->getBaseType());
if (MaybeNestedBasicType) {
for (const auto &BasicTypeRegPair : BasicTypeRegPairs) {
const auto &[DefinedBasicType, BasicTypeReg] = BasicTypeRegPair;
Expand Down
1 change: 1 addition & 0 deletions llvm/test/CodeGen/SPIRV/debug-info/debug-type-pointer.ll
Original file line number Diff line number Diff line change
Expand Up @@ -278,3 +278,4 @@ define spir_func i32 @test1() !dbg !72 {
!98 = !DILocalVariable(name: "arr1", scope: !72, file: !3, line: 35, type: !67)
!99 = !DILocation(line: 35, column: 7, scope: !72)
!100 = !DILocation(line: 36, column: 3, scope: !72)
!101 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !67, size: 32, dwarfAddressSpace: 4)