Skip to content

Commit 4cd4e8e

Browse files
Fix an issue with casting types in debig-info extension implementation
1 parent c7dbf20 commit 4cd4e8e

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

llvm/lib/Target/SPIRV/SPIRVEmitNonSemanticDI.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,9 @@ bool SPIRVEmitNonSemanticDI::emitGlobalDI(MachineFunction &MF) {
158158
// pointed on from other DI types
159159
// DerivedType->getBaseType is null when pointer
160160
// is representing a void type
161-
if (DerivedType->getBaseType())
162-
BasicTypes.insert(
163-
cast<DIBasicType>(DerivedType->getBaseType()));
161+
if (auto *BT = dyn_cast_or_null<DIBasicType>(
162+
DerivedType->getBaseType()))
163+
BasicTypes.insert(BT);
164164
}
165165
}
166166
}

llvm/test/CodeGen/SPIRV/debug-info/debug-type-pointer.ll

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@
8181

8282
; CHECK-OPTION-NOT: DebugTypePointer
8383

84+
%struct_wrapper = type { i32 }
85+
8486
@gi0 = dso_local addrspace(1) global ptr addrspace(4) null, align 4, !dbg !0
8587
@gv0 = dso_local addrspace(1) global ptr addrspace(4) null, align 4, !dbg !5
8688

@@ -278,3 +280,4 @@ define spir_func i32 @test1() !dbg !72 {
278280
!98 = !DILocalVariable(name: "arr1", scope: !72, file: !3, line: 35, type: !67)
279281
!99 = !DILocation(line: 35, column: 7, scope: !72)
280282
!100 = !DILocation(line: 36, column: 3, scope: !72)
283+
!101 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !67, size: 32, dwarfAddressSpace: 4)

0 commit comments

Comments
 (0)