Skip to content

Commit 592cdbd

Browse files
authored
[DWARF] Ignore DW_ATE_lo_user to hi_user in DebugHandlerBase assertion (#161695)
Fixes #140362
1 parent a0ed47d commit 592cdbd

File tree

2 files changed

+61
-0
lines changed

2 files changed

+61
-0
lines changed

llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,8 @@ bool DebugHandlerBase::isUnsignedDIType(const DIType *Ty) {
240240
Encoding == dwarf::DW_ATE_complex_float ||
241241
Encoding == dwarf::DW_ATE_signed_fixed ||
242242
Encoding == dwarf::DW_ATE_unsigned_fixed ||
243+
(Encoding >= dwarf::DW_ATE_lo_user &&
244+
Encoding <= dwarf::DW_ATE_hi_user) ||
243245
(Ty->getTag() == dwarf::DW_TAG_unspecified_type &&
244246
Ty->getName() == "decltype(nullptr)")) &&
245247
"Unsupported encoding");
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
; REQUIRES: object-emission
2+
; RUN: %llc_dwarf %s -filetype=obj -o - | llvm-dwarfdump - | FileCheck %s
3+
4+
;; https://github.com/llvm/llvm-project/issues/140362
5+
;; Don't assert when emitting a complex integer type in DWARF.
6+
7+
;; C source:
8+
;; int g;
9+
;;
10+
;; void foo(_Complex short c) { __builtin_memmove(&g, (char *)&c, 2); }
11+
;;
12+
;; void bar() { foo(0); }
13+
14+
; CHECK: DW_AT_type ([[complex:0x[0-9a-f]+]] "complex")
15+
16+
; CHECK: [[complex]]: DW_TAG_base_type
17+
; CHECK-NEXT: DW_AT_name ("complex")
18+
; CHECK-NEXT: DW_AT_encoding (0x80)
19+
; CHECK-NEXT: DW_AT_byte_size (0x04)
20+
21+
@g = dso_local local_unnamed_addr global i32 0, align 4, !dbg !0
22+
23+
define dso_local void @bar() local_unnamed_addr !dbg !18 {
24+
entry:
25+
#dbg_value(i32 0, !21, !DIExpression(), !27)
26+
store i16 0, ptr @g, align 4, !dbg !29
27+
ret void, !dbg !30
28+
}
29+
30+
!llvm.dbg.cu = !{!2}
31+
!llvm.module.flags = !{!10, !11}
32+
!llvm.ident = !{!17}
33+
34+
!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
35+
!1 = distinct !DIGlobalVariable(name: "g", scope: !2, file: !8, line: 1, type: !9, isLocal: false, isDefinition: true)
36+
!2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !3, producer: "clang version 22.0.0git", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, retainedTypes: !4, globals: !7, splitDebugInlining: false, nameTableKind: None)
37+
!3 = !DIFile(filename: "/app/example.cpp", directory: "/app")
38+
!4 = !{!5}
39+
!5 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !6, size: 64)
40+
!6 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char)
41+
!7 = !{!0}
42+
!8 = !DIFile(filename: "example.cpp", directory: "/app")
43+
!9 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
44+
!10 = !{i32 7, !"Dwarf Version", i32 5}
45+
!11 = !{i32 2, !"Debug Info Version", i32 3}
46+
!17 = !{!"clang version 22.0.0git"}
47+
!18 = distinct !DISubprogram(name: "bar", linkageName: "bar()", scope: !8, file: !8, line: 5, type: !19, scopeLine: 5, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, keyInstructions: true)
48+
!19 = !DISubroutineType(types: !20)
49+
!20 = !{null}
50+
!21 = !DILocalVariable(name: "c", arg: 1, scope: !22, file: !8, line: 3, type: !25)
51+
!22 = distinct !DISubprogram(name: "foo", linkageName: "_ZL3fooCs", scope: !8, file: !8, line: 3, type: !23, scopeLine: 3, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !26, keyInstructions: true)
52+
!23 = !DISubroutineType(types: !24)
53+
!24 = !{null, !25}
54+
!25 = !DIBasicType(name: "complex", size: 32, encoding: 128)
55+
!26 = !{!21}
56+
!27 = !DILocation(line: 0, scope: !22, inlinedAt: !28)
57+
!28 = distinct !DILocation(line: 5, column: 14, scope: !18)
58+
!29 = !DILocation(line: 3, column: 37, scope: !22, inlinedAt: !28, atomGroup: 1, atomRank: 1)
59+
!30 = !DILocation(line: 5, column: 22, scope: !18, atomGroup: 1, atomRank: 1)

0 commit comments

Comments
 (0)