Skip to content

Commit 7f26a57

Browse files
Dinistroaniplcc
authored andcommitted
[MLIR][LLVM] Add vector exception to composite type element ignore mode (llvm#89385)
This commit fixes a bug in the DICompositeType element ignore mode. It seems that vectors require the presence of elements, as they otherwise do not pass the verifier.
1 parent 774a00b commit 7f26a57

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

mlir/lib/Target/LLVMIR/DebugImporter.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,10 @@ DICompileUnitAttr DebugImporter::translateImpl(llvm::DICompileUnit *node) {
7171
DICompositeTypeAttr DebugImporter::translateImpl(llvm::DICompositeType *node) {
7272
std::optional<DIFlags> flags = symbolizeDIFlags(node->getFlags());
7373
SmallVector<DINodeAttr> elements;
74-
if (!dropDICompositeTypeElements) {
74+
75+
// A vector always requires an element.
76+
bool isVectorType = flags && bitEnumContainsAll(*flags, DIFlags::Vector);
77+
if (isVectorType || !dropDICompositeTypeElements) {
7578
for (llvm::DINode *element : node->getElements()) {
7679
assert(element && "expected a non-null element type");
7780
elements.push_back(translate(element));

mlir/test/Target/LLVMIR/Import/ignore-composite-type-elements.ll

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
; RUN: mlir-translate -import-llvm -mlir-print-debuginfo -split-input-file -drop-di-composite-type-elements %s | FileCheck %s
1+
; RUN: mlir-translate -import-llvm -mlir-print-debuginfo -split-input-file -drop-di-composite-type-elements -split-input-file %s | FileCheck %s
22

33
; Verifies that the according flag avoids the conversion of the elements of the
44
; DICompositeType.
@@ -23,3 +23,25 @@ define void @composite_type() !dbg !3 {
2323
!7 = !{!9}
2424
!8 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !6, flags: DIFlagArtificial | DIFlagObjectPointer)
2525
!9 = !DIDerivedType(tag: DW_TAG_member, name: "call_field", file: !2, baseType: !8)
26+
27+
; // -----
28+
29+
; CHECK: #{{.+}} = #llvm.di_composite_type<tag = DW_TAG_array_type, name = "vector",
30+
; CHECK-SAME: baseType = #{{.*}}, flags = Vector, elements = #llvm.di_subrange<count = 4 : i64>
31+
32+
define void @composite_type() !dbg !3 {
33+
ret void
34+
}
35+
36+
!llvm.dbg.cu = !{!1}
37+
!llvm.module.flags = !{!0}
38+
!0 = !{i32 2, !"Debug Info Version", i32 3}
39+
!1 = distinct !DICompileUnit(language: DW_LANG_C, file: !2)
40+
!2 = !DIFile(filename: "debug-info.ll", directory: "/")
41+
!3 = distinct !DISubprogram(name: "composite_type", scope: !2, file: !2, spFlags: DISPFlagDefinition, unit: !1, type: !4)
42+
!4 = !DISubroutineType(types: !5)
43+
!5 = !{!7}
44+
!6 = !DIBasicType(name: "int")
45+
!7 = !DICompositeType(tag: DW_TAG_array_type, name: "vector", flags: DIFlagVector, elements: !8, baseType: !6)
46+
!8 = !{!9}
47+
!9 = !DISubrange(count: 4)

0 commit comments

Comments
 (0)