• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# RUN: llc -start-before=livedebugvalues -filetype=obj -o - %s | llvm-dwarfdump - | FileCheck %s
2
3# Based on the following C++ code:
4# struct A { A(A &) {} };
5# struct B { A a; };
6# struct C { C(B); };
7# struct D : C { D(B); };
8# D::D(B b) : C(b) {}
9
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
14# entry value.
15
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")
20
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")
25
26--- |
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"
29
30  %struct.D = type { i8 }
31  %struct.B = type { %struct.A }
32  %struct.A = type { i8 }
33  %struct.C = type { i8 }
34
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 {
38  entry:
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
44    ret void, !dbg !36
45  }
46
47  ; Function Attrs: nounwind readnone speculatable willreturn
48  declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
49
50  declare dso_local void @_ZN1CC2E1B(%struct.C*, %struct.B*) unnamed_addr
51
52  ; Function Attrs: nounwind readnone speculatable willreturn
53  declare void @llvm.dbg.value(metadata, metadata, metadata) #1
54
55  attributes #0 = { uwtable }
56  attributes #1 = { nounwind readnone speculatable willreturn }
57
58  !llvm.dbg.cu = !{!0}
59  !llvm.module.flags = !{!3, !4, !5}
60  !llvm.ident = !{!6}
61
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: "/")
64  !2 = !{}
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")
71  !9 = !{!10, !27}
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")
74  !12 = !{!13}
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")
80  !18 = !{!19}
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")
83  !21 = !{!22}
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)
93  !31 = !{!32, !34}
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)
99
100...
101---
102name:            _ZN1DC2E1B
103body:             |
104  bb.0.entry:
105    liveins: $rdi
106
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
111    $rsi = MOV64rr $rsp
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
117
118...
119