1 # RUN: llc -start-before=livedebugvalues -filetype=obj -o - %s | llvm-dwarfdump - | FileCheck %s
3 # Based on the following C++ code:
4 # struct A { A(A &) {} };
7 # struct D : C { D(B); };
10 # Reproducer for PR44275. Ideally we should get an entry value location list
11 # entry for the reference parameter b, but we are currently not able to do that
12 # due to limitations in the DWARF emission code, which puts restrictions on the
13 # DIExpression. For now verify that we don't crash when trying to add such an
16 # CHECK: DW_AT_location
17 # CHECK-NEXT: [{{0x[0-9a-f]+}}, {{0x[0-9a-f]+}}): DW_OP_reg5 RDI
18 # CHECK-NEXT: [{{0x[0-9a-f]+}}, {{0x[0-9a-f]+}}): DW_OP_GNU_entry_value(DW_OP_reg5 RDI), DW_OP_stack_value)
19 # CHECK-NEXT: DW_AT_name ("this")
21 # CHECK: DW_AT_location
22 # CHECK-NEXT: [0x0000000000000000, 0x0000000000000004): DW_OP_breg4 RSI+0)
23 # TODO: Here we should ideally get a location list entry using an entry value.
24 # CHECK-NEXT: DW_AT_name ("b")
27 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
28 target triple = "x86_64-unknown-linux-gnu"
30 %struct.D = type { i8 }
31 %struct.B = type { %struct.A }
32 %struct.A = type { i8 }
33 %struct.C = type { i8 }
35 @_ZN1DC1E1B = dso_local unnamed_addr alias void (%struct.D*, %struct.B*), void (%struct.D*, %struct.B*)* @_ZN1DC2E1B
36 ; Function Attrs: uwtable
37 define dso_local void @_ZN1DC2E1B(%struct.D* %this, %struct.B* nocapture readnone %b) unnamed_addr #0 align 2 !dbg !7 {
39 %agg.tmp = alloca %struct.B, align 1
40 call void @llvm.dbg.value(metadata %struct.D* %this, metadata !32, metadata !DIExpression()), !dbg !35
41 call void @llvm.dbg.declare(metadata %struct.B* %b, metadata !34, metadata !DIExpression()), !dbg !36
42 %0 = bitcast %struct.D* %this to %struct.C*, !dbg !36
43 call void @_ZN1CC2E1B(%struct.C* %0, %struct.B* nonnull %agg.tmp), !dbg !36
47 ; Function Attrs: nounwind readnone speculatable willreturn
48 declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
50 declare dso_local void @_ZN1CC2E1B(%struct.C*, %struct.B*) unnamed_addr
52 ; Function Attrs: nounwind readnone speculatable willreturn
53 declare void @llvm.dbg.value(metadata, metadata, metadata) #1
55 attributes #0 = { uwtable }
56 attributes #1 = { nounwind readnone speculatable willreturn }
59 !llvm.module.flags = !{!3, !4, !5}
62 !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 10.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None)
63 !1 = !DIFile(filename: "foo.cpp", directory: "/")
65 !3 = !{i32 7, !"Dwarf Version", i32 4}
66 !4 = !{i32 2, !"Debug Info Version", i32 3}
67 !5 = !{i32 1, !"wchar_size", i32 4}
68 !6 = !{!"clang version 10.0.0"}
69 !7 = distinct !DISubprogram(name: "D", linkageName: "_ZN1DC2E1B", scope: !8, file: !1, line: 5, type: !28, scopeLine: 5, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, declaration: !27, retainedNodes: !31)
70 !8 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "D", file: !1, line: 4, size: 8, flags: DIFlagTypePassByValue | DIFlagNonTrivial, elements: !9, identifier: "_ZTS1D")
72 !10 = !DIDerivedType(tag: DW_TAG_inheritance, scope: !8, baseType: !11, extraData: i32 0)
73 !11 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "C", file: !1, line: 3, size: 8, flags: DIFlagTypePassByValue | DIFlagNonTrivial, elements: !12, identifier: "_ZTS1C")
75 !13 = !DISubprogram(name: "C", scope: !11, file: !1, line: 3, type: !14, scopeLine: 3, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized)
76 !14 = !DISubroutineType(types: !15)
77 !15 = !{null, !16, !17}
78 !16 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !11, size: 64, flags: DIFlagArtificial | DIFlagObjectPointer)
79 !17 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "B", file: !1, line: 2, size: 8, flags: DIFlagTypePassByReference | DIFlagNonTrivial, elements: !18, identifier: "_ZTS1B")
81 !19 = !DIDerivedType(tag: DW_TAG_member, name: "a", scope: !17, file: !1, line: 2, baseType: !20, size: 8)
82 !20 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "A", file: !1, line: 1, size: 8, flags: DIFlagTypePassByReference | DIFlagNonTrivial, elements: !21, identifier: "_ZTS1A")
84 !22 = !DISubprogram(name: "A", scope: !20, file: !1, line: 1, type: !23, scopeLine: 1, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized)
85 !23 = !DISubroutineType(types: !24)
86 !24 = !{null, !25, !26}
87 !25 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !20, size: 64, flags: DIFlagArtificial | DIFlagObjectPointer)
88 !26 = !DIDerivedType(tag: DW_TAG_reference_type, baseType: !20, size: 64)
89 !27 = !DISubprogram(name: "D", scope: !8, file: !1, line: 4, type: !28, scopeLine: 4, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized)
90 !28 = !DISubroutineType(types: !29)
91 !29 = !{null, !30, !17}
92 !30 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !8, size: 64, flags: DIFlagArtificial | DIFlagObjectPointer)
94 !32 = !DILocalVariable(name: "this", arg: 1, scope: !7, type: !33, flags: DIFlagArtificial | DIFlagObjectPointer)
95 !33 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !8, size: 64)
96 !34 = !DILocalVariable(name: "b", arg: 2, scope: !7, file: !1, line: 5, type: !17)
97 !35 = !DILocation(line: 0, scope: !7)
98 !36 = !DILocation(line: 5, scope: !7)
107 DBG_VALUE $rdi, $noreg, !32, !DIExpression(), debug-location !35
108 DBG_VALUE $rsi, $noreg, !34, !DIExpression(DW_OP_deref), debug-location !36
109 frame-setup PUSH64r undef $rax, implicit-def $rsp, implicit $rsp
110 CFI_INSTRUCTION def_cfa_offset 16
112 DBG_VALUE $rdi, $noreg, !32, !DIExpression(), debug-location !35
113 CALL64pcrel32 @_ZN1CC2E1B, csr_64, implicit $rsp, implicit $ssp, implicit $rdi, implicit $rsi, implicit-def $rsp, implicit-def $ssp, debug-location !36
114 $rax = frame-destroy POP64r implicit-def $rsp, implicit $rsp, debug-location !36
115 CFI_INSTRUCTION def_cfa_offset 8, debug-location !36
116 RETQ debug-location !36