145 lines · plain
1# RUN: llc %s -o - -experimental-debug-variable-locations=true \2# RUN: -run-pass=livedebugvalues \3# RUN: | FileCheck %s --implicit-check-not=DBG_VALUE4# RUN: llc %s -o - -experimental-debug-variable-locations=true \5# RUN: -start-before=livedebugvalues -filetype=obj \6# RUN: | llvm-dwarfdump - | FileCheck %s --check-prefix=DWARF7 8## Test that we can spill indirect plain variable locations, and those with9## non-empty expressions, to the stack. And that the derefs go in the right10## place.11 12## Capture variable num,13# CHECK-DAG: ![[VARNUM:[0-9]+]] = !DILocalVariable(name: "nt",14 15# DWARF: DW_TAG_formal_parameter16# DWARF-NEXT: DW_AT_location17# DWARF-NEXT: DW_OP_breg5 RDI+018##19## First location: variable pointed to by basereg $rdi20##21# DWARF-NEXT: DW_OP_breg7 RSP-8, DW_OP_deref22##23## Spilt to stack: push stack address and deref, variable pointed to by the24## pointer loaded off the stack.25##26# DWARF-NEXT: DW_OP_breg5 RDI+827## 28## Second location, variable pointed to by the register value plus eight.29##30# DWARF-NEXT: DW_OP_breg7 RSP-8, DW_OP_deref, DW_OP_lit8, DW_OP_plus)31##32## Spilt to stack: push stack location and deref the pointer onto the dwarf33## expr stack. Then add eight to it, and it points to the variable.34##35 36 37--- |38 source_filename = "t.cpp"39 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"40 target triple = "x86_64--linux"41 42 %struct.NonTrivial = type { i32 }43 44 ; Function Attrs: nounwind uwtable45 define i32 @_Z3foo10NonTrivial(ptr nocapture readonly %nt) local_unnamed_addr #0 !dbg !7 {46 entry:47 tail call void @llvm.dbg.declare(metadata ptr %nt, metadata !20, metadata !DIExpression()), !dbg !2148 tail call void asm sideeffect "", "~{rax},~{rbx},~{rcx},~{rdx},~{rsi},~{rdi},~{rbp},~{r8},~{r9},~{r10},~{r11},~{r12},~{r13},~{r14},~{r15},~{dirflag},~{fpsr},~{flags}"() #2, !dbg !22, !srcloc !2349 %i1 = bitcast ptr %nt to ptr, !dbg !2450 %0 = load i32, ptr %i1, align 4, !dbg !24, !tbaa !2551 ret i32 %0, !dbg !3052 }53 54 ; Function Attrs: nocallback nofree nosync nounwind readnone speculatable willreturn55 declare void @llvm.dbg.declare(metadata, metadata, metadata) #156 57 attributes #0 = { nounwind uwtable }58 attributes #1 = { nocallback nofree nosync nounwind readnone speculatable willreturn }59 attributes #2 = { nounwind }60 61 !llvm.dbg.cu = !{!0}62 !llvm.module.flags = !{!3, !4, !5}63 !llvm.ident = !{!6}64 65 !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 6.0.0 ", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)66 !1 = !DIFile(filename: "t.cpp", directory: "C:\\src\\llvm-project\\build")67 !2 = !{}68 !3 = !{i32 2, !"Dwarf Version", i32 4}69 !4 = !{i32 2, !"Debug Info Version", i32 3}70 !5 = !{i32 1, !"wchar_size", i32 4}71 !6 = !{!"clang version 6.0.0 "}72 !7 = distinct !DISubprogram(name: "foo", linkageName: "_Z3foo10NonTrivial", scope: !1, file: !1, line: 10, type: !8, scopeLine: 10, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !19)73 !8 = !DISubroutineType(types: !9)74 !9 = !{!10, !11}75 !10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)76 !11 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "NonTrivial", file: !1, line: 5, size: 32, elements: !12, identifier: "_ZTS10NonTrivial")77 !12 = !{!13, !14, !18}78 !13 = !DIDerivedType(tag: DW_TAG_member, name: "i", scope: !11, file: !1, line: 8, baseType: !10, size: 32)79 !14 = !DISubprogram(name: "NonTrivial", scope: !11, file: !1, line: 6, type: !15, scopeLine: 6, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized)80 !15 = !DISubroutineType(types: !16)81 !16 = !{null, !17}82 !17 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !11, size: 64, flags: DIFlagArtificial | DIFlagObjectPointer)83 !18 = !DISubprogram(name: "~NonTrivial", scope: !11, file: !1, line: 7, type: !15, scopeLine: 7, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized)84 !19 = !{!20}85 !20 = !DILocalVariable(name: "nt", arg: 1, scope: !7, file: !1, line: 10, type: !11)86 !21 = !DILocation(line: 10, column: 20, scope: !7)87 !22 = !DILocation(line: 11, column: 3, scope: !7)88 !23 = !{i32 -2147471481}89 !24 = !DILocation(line: 12, column: 13, scope: !7)90 !25 = !{!26, !27, i64 0}91 !26 = !{!"_ZTS10NonTrivial", !27, i64 0}92 !27 = !{!"int", !28, i64 0}93 !28 = !{!"omnipotent char", !29, i64 0}94 !29 = !{!"Simple C++ TBAA"}95 !30 = !DILocation(line: 12, column: 3, scope: !7)96 97...98---99name: _Z3foo10NonTrivial100alignment: 16101tracksRegLiveness: true102debugInstrRef: true103tracksDebugUserValues: true104liveins:105 - { reg: '$rdi' }106frameInfo:107 stackSize: 48108 offsetAdjustment: -48109 maxAlignment: 8110 maxCallFrameSize: 0111 cvBytesOfCalleeSavedRegisters: 48112fixedStack:113 - { id: 0, type: spill-slot, offset: -56, size: 8, alignment: 8, callee-saved-register: '$rbx' }114 - { id: 1, type: spill-slot, offset: -48, size: 8, alignment: 16, callee-saved-register: '$r12' }115 - { id: 2, type: spill-slot, offset: -40, size: 8, alignment: 8, callee-saved-register: '$r13' }116 - { id: 3, type: spill-slot, offset: -32, size: 8, alignment: 16, callee-saved-register: '$r14' }117 - { id: 4, type: spill-slot, offset: -24, size: 8, alignment: 8, callee-saved-register: '$r15' }118 - { id: 5, type: spill-slot, offset: -16, size: 8, alignment: 16, callee-saved-register: '$rbp' }119stack:120 - { id: 0, type: spill-slot, offset: -64, size: 8, alignment: 8 }121machineFunctionInfo: {}122body: |123 bb.0.entry:124 liveins: $rdi, $rbp, $r15, $r14, $r13, $r12, $rbx125 126 DBG_VALUE $rdi, 0, !20, !DIExpression(), debug-location !21127 ; CHECK: DBG_VALUE $rdi,128 MOV64mr $rsp, 1, $noreg, -8, $noreg, $rdi :: (store (s64) into %stack.0)129 $rdi = MOV64ri 0130 ; CHECK: DBG_VALUE $rsp, 0, ![[VARNUM]], !DIExpression(DW_OP_constu, 8, DW_OP_minus, DW_OP_deref),131 132 $rdi = MOV64ri 0 ; dummy instr for the above DBG_VALUE to cover in a loclist133 134 DBG_VALUE $rdi, 0, !20, !DIExpression(DW_OP_constu, 8, DW_OP_plus), debug-location !21135 ; CHECK: DBG_VALUE $rdi,136 MOV64mr $rsp, 1, $noreg, -8, $noreg, $rdi :: (store (s64) into %stack.0)137 $rdi = MOV64ri 0138 ; CHECK: DBG_VALUE $rsp, 0, ![[VARNUM]], !DIExpression(DW_OP_constu, 8, DW_OP_minus, DW_OP_deref, DW_OP_constu, 8, DW_OP_plus),139 140 renamable $rax = MOV64rm $rsp, 1, $noreg, -8, $noreg :: (load (s64) from %stack.0)141 renamable $eax = MOV32rm killed renamable $rax, 1, $noreg, 0, $noreg, debug-location !24 :: (load (s32) from %ir.i1, !tbaa !25)142 RET64 $eax, debug-location !30143 144...145