1# RUN: llc -start-before=livedebugvalues -filetype=obj -o - %s | llvm-dwarfdump - | FileCheck %s 2# RUN: llc --force-instr-ref-livedebugvalues -start-before=livedebugvalues -filetype=obj -o - %s | llvm-dwarfdump - | FileCheck %s 3 4# Based on the following C++ code: 5# struct A { A(A &) {} }; 6# struct B { A a; }; 7# struct C { C(B); }; 8# struct D : C { D(B); }; 9# D::D(B b) : C(b) {} 10 11# Reproducer for PR44275. 12 13# CHECK: DW_AT_location 14# CHECK-NEXT: [{{0x[0-9a-f]+}}, {{0x[0-9a-f]+}}): DW_OP_reg5 RDI 15# CHECK-NEXT: [{{0x[0-9a-f]+}}, {{0x[0-9a-f]+}}): DW_OP_GNU_entry_value(DW_OP_reg5 RDI), DW_OP_stack_value) 16# CHECK-NEXT: DW_AT_name ("this") 17 18# CHECK: DW_AT_location 19# CHECK-NEXT: [0x0000000000000000, 0x0000000000000004): DW_OP_breg4 RSI+0 20# CHECK-NEXT: [0x0000000000000004, 0x000000000000000b): DW_OP_GNU_entry_value(DW_OP_reg4 RSI)) 21# CHECK-NEXT: DW_AT_name ("b") 22 23--- | 24 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" 25 target triple = "x86_64-unknown-linux-gnu" 26 27 %struct.D = type { i8 } 28 %struct.B = type { %struct.A } 29 %struct.A = type { i8 } 30 %struct.C = type { i8 } 31 32 @_ZN1DC1E1B = dso_local unnamed_addr alias void (ptr, ptr), ptr @_ZN1DC2E1B 33 ; Function Attrs: uwtable 34 define dso_local void @_ZN1DC2E1B(ptr %this, ptr nocapture readnone %b) unnamed_addr #0 align 2 !dbg !7 { 35 entry: 36 %agg.tmp = alloca %struct.B, align 1 37 call void @llvm.dbg.value(metadata ptr %this, metadata !32, metadata !DIExpression()), !dbg !35 38 call void @llvm.dbg.declare(metadata ptr %b, metadata !34, metadata !DIExpression()), !dbg !36 39 %0 = bitcast ptr %this to ptr, !dbg !36 40 call void @_ZN1CC2E1B(ptr %0, ptr nonnull %agg.tmp), !dbg !36 41 ret void, !dbg !36 42 } 43 44 ; Function Attrs: nounwind readnone speculatable willreturn 45 declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 46 47 declare dso_local void @_ZN1CC2E1B(ptr, ptr) unnamed_addr 48 49 ; Function Attrs: nounwind readnone speculatable willreturn 50 declare void @llvm.dbg.value(metadata, metadata, metadata) #1 51 52 attributes #0 = { uwtable } 53 attributes #1 = { nounwind readnone speculatable willreturn } 54 55 !llvm.dbg.cu = !{!0} 56 !llvm.module.flags = !{!3, !4, !5} 57 !llvm.ident = !{!6} 58 59 !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) 60 !1 = !DIFile(filename: "foo.cpp", directory: "/") 61 !2 = !{} 62 !3 = !{i32 7, !"Dwarf Version", i32 4} 63 !4 = !{i32 2, !"Debug Info Version", i32 3} 64 !5 = !{i32 1, !"wchar_size", i32 4} 65 !6 = !{!"clang version 10.0.0"} 66 !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) 67 !8 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "D", file: !1, line: 4, size: 8, flags: DIFlagTypePassByValue | DIFlagNonTrivial, elements: !9, identifier: "_ZTS1D") 68 !9 = !{!10, !27} 69 !10 = !DIDerivedType(tag: DW_TAG_inheritance, scope: !8, baseType: !11, extraData: i32 0) 70 !11 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "C", file: !1, line: 3, size: 8, flags: DIFlagTypePassByValue | DIFlagNonTrivial, elements: !12, identifier: "_ZTS1C") 71 !12 = !{!13} 72 !13 = !DISubprogram(name: "C", scope: !11, file: !1, line: 3, type: !14, scopeLine: 3, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized) 73 !14 = !DISubroutineType(types: !15) 74 !15 = !{null, !16, !17} 75 !16 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !11, size: 64, flags: DIFlagArtificial | DIFlagObjectPointer) 76 !17 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "B", file: !1, line: 2, size: 8, flags: DIFlagTypePassByReference | DIFlagNonTrivial, elements: !18, identifier: "_ZTS1B") 77 !18 = !{!19} 78 !19 = !DIDerivedType(tag: DW_TAG_member, name: "a", scope: !17, file: !1, line: 2, baseType: !20, size: 8) 79 !20 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "A", file: !1, line: 1, size: 8, flags: DIFlagTypePassByReference | DIFlagNonTrivial, elements: !21, identifier: "_ZTS1A") 80 !21 = !{!22} 81 !22 = !DISubprogram(name: "A", scope: !20, file: !1, line: 1, type: !23, scopeLine: 1, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized) 82 !23 = !DISubroutineType(types: !24) 83 !24 = !{null, !25, !26} 84 !25 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !20, size: 64, flags: DIFlagArtificial | DIFlagObjectPointer) 85 !26 = !DIDerivedType(tag: DW_TAG_reference_type, baseType: !20, size: 64) 86 !27 = !DISubprogram(name: "D", scope: !8, file: !1, line: 4, type: !28, scopeLine: 4, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized) 87 !28 = !DISubroutineType(types: !29) 88 !29 = !{null, !30, !17} 89 !30 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !8, size: 64, flags: DIFlagArtificial | DIFlagObjectPointer) 90 !31 = !{!32, !34} 91 !32 = !DILocalVariable(name: "this", arg: 1, scope: !7, type: !33, flags: DIFlagArtificial | DIFlagObjectPointer) 92 !33 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !8, size: 64) 93 !34 = !DILocalVariable(name: "b", arg: 2, scope: !7, file: !1, line: 5, type: !17) 94 !35 = !DILocation(line: 0, scope: !7) 95 !36 = !DILocation(line: 5, scope: !7) 96 97... 98--- 99name: _ZN1DC2E1B 100body: | 101 bb.0.entry: 102 liveins: $rdi 103 104 DBG_VALUE $rdi, $noreg, !32, !DIExpression(), debug-location !35 105 DBG_VALUE $rsi, $noreg, !34, !DIExpression(DW_OP_deref), debug-location !36 106 frame-setup PUSH64r undef $rax, implicit-def $rsp, implicit $rsp 107 CFI_INSTRUCTION def_cfa_offset 16 108 $rsi = MOV64rr $rsp 109 CALL64pcrel32 @_ZN1CC2E1B, csr_64, implicit $rsp, implicit $ssp, implicit $rdi, implicit $rsi, implicit-def $rsp, implicit-def $ssp, debug-location !36 110 $rax = frame-destroy POP64r implicit-def $rsp, implicit $rsp, debug-location !36 111 CFI_INSTRUCTION def_cfa_offset 8, debug-location !36 112 RET64 debug-location !36 113 114... 115