reference, declarationdefinition
definition → references, declarations, derived classes, virtual overrides
reference to multiple definitions → definitions
unreferenced
    1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31
   32
   33
   34
   35
   36
   37
   38
   39
   40
   41
   42
   43
   44
   45
   46
   47
   48
   49
   50
   51
   52
   53
   54
   55
   56
   57
   58
   59
   60
   61
   62
   63
   64
   65
   66
   67
   68
   69
   70
   71
   72
   73
   74
   75
   76
   77
   78
   79
   80
   81
   82
   83
   84
   85
   86
   87
   88
   89
   90
   91
   92
   93
   94
   95
   96
   97
   98
   99
  100
  101
  102
  103
  104
  105
  106
  107
  108
  109
  110
  111
  112
  113
  114
  115
  116
  117
  118
  119
  120
  121
  122
  123
  124
  125
  126
  127
  128
  129
  130
  131
  132
  133
  134
  135
  136
  137
  138
  139
  140
  141
  142
  143
  144
  145
  146
  147
  148
  149
  150
  151
  152
  153
  154
  155
  156
  157
  158
  159
  160
  161
  162
  163
  164
  165
  166
  167
  168
  169
  170
  171
  172
  173
  174
  175
  176
  177
  178
  179
  180
  181
  182
  183
  184
  185
  186
  187
  188
  189
  190
  191
  192
  193
  194
  195
  196
# Test call site parameter encoding in DWARFv4.
# When the debugger tuning is set to gdb, use GNU opcodes.
# For lldb, use the standard DWARF5 opcodes.

# RUN: llc -debug-entry-values -debugger-tune=gdb -filetype=obj -mtriple=x86_64-unknown-unknown -start-after=machineverifier -o - %s | llvm-dwarfdump - | FileCheck %s -check-prefixes=CHECK-GNU
# RUN: llc -debug-entry-values -debugger-tune=lldb -filetype=obj -mtriple=x86_64-unknown-unknown -start-after=machineverifier -o - %s | llvm-dwarfdump - | FileCheck %s -check-prefixes=CHECK-DWARF5
#
# extern void foo(int *a, int b, int c, int d, int e, int f);
# extern int getVal();
#
# void baa(int arg1, int arg2, int arg3) {
#   int local1 = getVal();
#   foo(&local1, arg2, 10, 15, arg3 + 3, arg1 + arg2);
# }
#
# CHECK-GNU: DW_TAG_GNU_call_site
# CHECK-GNU:   DW_AT_abstract_origin {{.*}} "getVal"
#
# CHECK-GNU:       DW_TAG_GNU_call_site
# CHECK-GNU:         DW_AT_abstract_origin {{.*}} "foo"
# CHECK-GNU:         DW_AT_low_pc {{.*}}
# CHECK-GNU-EMPTY:
# CHECK-GNU:         DW_TAG_GNU_call_site_parameter
# CHECK-GNU-NEXT:      DW_AT_location      (DW_OP_reg2 RCX)
# CHECK-GNU-NEXT:      DW_AT_GNU_call_site_value   (DW_OP_lit15)
# CHECK-GNU:         DW_TAG_GNU_call_site_parameter
# CHECK-GNU-NEXT:      DW_AT_location      (DW_OP_reg1 RDX)
# CHECK-GNU-NEXT:      DW_AT_GNU_call_site_value   (DW_OP_lit10)
# CHECK-GNU:         DW_TAG_GNU_call_site_parameter
# CHECK-GNU-NEXT:      DW_AT_location      (DW_OP_reg4 RSI)
# CHECK-GNU-NEXT:      DW_AT_GNU_call_site_value   (DW_OP_breg3 RBX+0)
# CHECK-GNU:         DW_TAG_GNU_call_site_parameter
# CHECK-GNU-NEXT:      DW_AT_location      (DW_OP_reg5 RDI)
# CHECK-GNU-NEXT:      DW_AT_GNU_call_site_value   (DW_OP_fbreg +12)
# CHECK-GNU:         DW_TAG_GNU_call_site_parameter
# CHECK-GNU-NEXT:      DW_AT_location      (DW_OP_reg9 R9)
# CHECK-GNU-NEXT:      DW_AT_GNU_call_site_value   (DW_OP_breg15 R15+0, DW_OP_breg3 RBX+0, DW_OP_plus)
# CHECK-GNU:         DW_TAG_GNU_call_site_parameter
# CHECK-GNU-NEXT:      DW_AT_location      (DW_OP_reg8 R8)
# CHECK-GNU-NEXT:      DW_AT_GNU_call_site_value   (DW_OP_breg14 R14+3)

# CHECK-DWARF5: [[getValue_SP:.*]]: DW_TAG_subprogram
# CHECK-DWARF5-NEXT: DW_AT_name      ("getVal")

# CHECK-DWARF5: [[foo_SP:.*]]: DW_TAG_subprogram
# CHECK-DWARF5-NEXT: DW_AT_name      ("foo")

# CHECK-DWARF5: DW_TAG_call_site
# CHECK-DWARF5:   DW_AT_call_origin ([[getValue_SP]])
#
# CHECK-DWARF5: DW_TAG_call_site
# CHECK-DWARF5:   DW_AT_call_origin ([[foo_SP]])
# CHECK-DWARF5:   DW_AT_call_return_pc {{.*}}
# CHECK-DWARF5-EMPTY:
# CHECK-DWARF5:         DW_TAG_call_site_parameter
# CHECK-DWARF5-NEXT:      DW_AT_location      (DW_OP_reg2 RCX)
# CHECK-DWARF5-NEXT:      DW_AT_call_value   (DW_OP_lit15)
# CHECK-DWARF5:         DW_TAG_call_site_parameter
# CHECK-DWARF5-NEXT:      DW_AT_location      (DW_OP_reg1 RDX)
# CHECK-DWARF5-NEXT:      DW_AT_call_value   (DW_OP_lit10)
# CHECK-DWARF5:         DW_TAG_call_site_parameter
# CHECK-DWARF5-NEXT:      DW_AT_location      (DW_OP_reg4 RSI)
# CHECK-DWARF5-NEXT:      DW_AT_call_value   (DW_OP_breg3 RBX+0)
# CHECK-DWARF5:         DW_TAG_call_site_parameter
# CHECK-DWARF5-NEXT:      DW_AT_location      (DW_OP_reg5 RDI)
# CHECK-DWARF5-NEXT:      DW_AT_call_value   (DW_OP_fbreg +12)
# CHECK-DWARF5:         DW_TAG_call_site_parameter
# CHECK-DWARF5-NEXT:      DW_AT_location      (DW_OP_reg9 R9)
# CHECK-DWARF5-NEXT:      DW_AT_call_value   (DW_OP_breg15 R15+0, DW_OP_breg3 RBX+0, DW_OP_plus)
# CHECK-DWARF5:         DW_TAG_call_site_parameter
# CHECK-DWARF5-NEXT:      DW_AT_location      (DW_OP_reg8 R8)
# CHECK-DWARF5-NEXT:      DW_AT_call_value   (DW_OP_breg14 R14+3)

--- |
  ; ModuleID = 'test.c'
  source_filename = "test.c"
  target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
  
  ; Function Attrs: nounwind uwtable
  define dso_local void @baa(i32 %arg1, i32 %arg2, i32 %arg3) local_unnamed_addr !dbg !10 {
  entry:
    %local1 = alloca i32, align 4
    call void @llvm.dbg.value(metadata i32 %arg1, metadata !15, metadata !DIExpression()), !dbg !19
    call void @llvm.dbg.value(metadata i32 %arg2, metadata !16, metadata !DIExpression()), !dbg !20
    call void @llvm.dbg.value(metadata i32 %arg3, metadata !17, metadata !DIExpression()), !dbg !21
    %0 = bitcast i32* %local1 to i8*, !dbg !22
    %call = tail call i32 (...) @getVal(), !dbg !23
    call void @llvm.dbg.value(metadata i32 %call, metadata !18, metadata !DIExpression()), !dbg !24
    store i32 %call, i32* %local1, align 4, !dbg !24
    %add = add nsw i32 %arg3, 3, !dbg !24
    %add1 = add nsw i32 %arg2, %arg1, !dbg !24
    call void @llvm.dbg.value(metadata i32* %local1, metadata !18, metadata !DIExpression(DW_OP_deref)), !dbg !24
    call void @foo(i32* nonnull %local1, i32 %arg2, i32 10, i32 15, i32 %add, i32 %add1), !dbg !24
    ret void, !dbg !24
  }
  
  declare !dbg !4 dso_local i32 @getVal(...) local_unnamed_addr
  
  declare !dbg !5 dso_local void @foo(i32*, i32, i32, i32, i32, i32) local_unnamed_addr
  
  ; Function Attrs: nounwind readnone speculatable
  declare void @llvm.dbg.value(metadata, metadata, metadata)
  
  !llvm.dbg.cu = !{!0}
  !llvm.module.flags = !{!6, !7, !8}
  !llvm.ident = !{!9}
  
  !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 9.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !3, nameTableKind: None)
  !1 = !DIFile(filename: "test.c", directory: "/dir")
  !2 = !{}
  !3 = !{!4, !5}
  !4 = !DISubprogram(name: "getVal", scope: !1, file: !1, line: 2, spFlags: DISPFlagOptimized, retainedNodes: !2)
  !5 = !DISubprogram(name: "foo", scope: !1, file: !1, line: 1, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2)
  !6 = !{i32 2, !"Dwarf Version", i32 4}
  !7 = !{i32 2, !"Debug Info Version", i32 3}
  !8 = !{i32 1, !"wchar_size", i32 4}
  !9 = !{!"clang version 9.0.0"}
  !10 = distinct !DISubprogram(name: "baa", scope: !1, file: !1, line: 4, type: !11, scopeLine: 4, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !14)
  !11 = !DISubroutineType(types: !12)
  !12 = !{null, !13, !13, !13}
  !13 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
  !14 = !{!15, !16, !17, !18}
  !15 = !DILocalVariable(name: "arg1", arg: 1, scope: !10, file: !1, line: 4, type: !13, flags: DIFlagArgumentNotModified)
  !16 = !DILocalVariable(name: "arg2", arg: 2, scope: !10, file: !1, line: 4, type: !13, flags: DIFlagArgumentNotModified)
  !17 = !DILocalVariable(name: "arg3", arg: 3, scope: !10, file: !1, line: 4, type: !13, flags: DIFlagArgumentNotModified)
  !18 = !DILocalVariable(name: "local1", scope: !10, file: !1, line: 5, type: !13)
  !19 = !DILocation(line: 4, column: 14, scope: !10)
  !20 = !DILocation(line: 4, column: 24, scope: !10)
  !21 = !DILocation(line: 4, column: 34, scope: !10)
  !22 = !DILocation(line: 5, column: 3, scope: !10)
  !23 = !DILocation(line: 5, column: 16, scope: !10)
  !24 = !DILocation(line: 5, column: 7, scope: !10)

...
---
name:            baa
liveins:         
  - { reg: '$edi', virtual-reg: '' }
  - { reg: '$esi', virtual-reg: '' }
  - { reg: '$edx', virtual-reg: '' }
callSites:       
  - { bb: 0, offset: 21, fwdArgRegs: [] }
  - { bb: 0, offset: 31, fwdArgRegs: 
      - { arg: 0, reg: '$rdi' }
      - { arg: 1, reg: '$esi' }
      - { arg: 2, reg: '$edx' }
      - { arg: 3, reg: '$ecx' }
      - { arg: 4, reg: '$r8d' }
      - { arg: 5, reg: '$r9d' } }
body:             |
  bb.0.entry:
    liveins: $edi, $edx, $esi, $r15, $r14, $rbx
  
    DBG_VALUE $edi, $noreg, !15, !DIExpression(), debug-location !19
    DBG_VALUE $esi, $noreg, !16, !DIExpression(), debug-location !20
    DBG_VALUE $edx, $noreg, !17, !DIExpression(), debug-location !21
    frame-setup PUSH64r killed $r15, implicit-def $rsp, implicit $rsp
    CFI_INSTRUCTION def_cfa_offset 16
    frame-setup PUSH64r killed $r14, implicit-def $rsp, implicit $rsp
    CFI_INSTRUCTION def_cfa_offset 24
    frame-setup PUSH64r killed $rbx, implicit-def $rsp, implicit $rsp
    CFI_INSTRUCTION def_cfa_offset 32
    $rsp = frame-setup SUB64ri8 $rsp, 16, implicit-def dead $eflags
    CFI_INSTRUCTION def_cfa_offset 48
    CFI_INSTRUCTION offset $rbx, -32
    CFI_INSTRUCTION offset $r14, -24
    CFI_INSTRUCTION offset $r15, -16
    $r14d = MOV32rr $edx, implicit-def $r14
    $ebx = MOV32rr $esi, implicit-def $rbx
    $r15d = MOV32rr $edi, implicit-def $r15
    DBG_VALUE $r14d, $noreg, !17, !DIExpression(), debug-location !21
    DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !20
    DBG_VALUE $r15d, $noreg, !15, !DIExpression(), debug-location !19
    dead $eax = XOR32rr undef $eax, undef $eax, implicit-def dead $eflags, implicit-def $al, debug-location !23
    CALL64pcrel32 @getVal, csr_64, implicit $rsp, implicit $ssp, implicit $al, implicit-def $rsp, implicit-def $ssp, implicit-def $eax, debug-location !23
    DBG_VALUE $eax, $noreg, !18, !DIExpression(), debug-location !24
    MOV32mr $rsp, 1, $noreg, 12, $noreg, killed renamable $eax, debug-location !24 :: (store 4 into %ir.local1)
    renamable $r8d = LEA64_32r killed renamable $r14, 1, $noreg, 3, $noreg, debug-location !24
    renamable $r9d = LEA64_32r killed renamable $r15, 1, renamable $rbx, 0, $noreg, debug-location !24
    DBG_VALUE $rsp, $noreg, !18, !DIExpression(DW_OP_plus_uconst, 12, DW_OP_deref), debug-location !24
    renamable $rdi = LEA64r $rsp, 1, $noreg, 12, $noreg
    $esi = MOV32rr $ebx, implicit killed $rbx, debug-location !24
    $edx = MOV32ri 10, debug-location !24
    $ecx = MOV32ri 15, debug-location !24
    CALL64pcrel32 @foo, csr_64, implicit $rsp, implicit $ssp, implicit $rdi, implicit $esi, implicit $edx, implicit killed $ecx, implicit $r8d, implicit $r9d, implicit-def $rsp, implicit-def $ssp, debug-location !24
    $rsp = frame-destroy ADD64ri8 $rsp, 16, implicit-def dead $eflags, debug-location !24
    CFI_INSTRUCTION def_cfa_offset 32, debug-location !24
    $rbx = frame-destroy POP64r implicit-def $rsp, implicit $rsp, debug-location !24
    CFI_INSTRUCTION def_cfa_offset 24, debug-location !24
    $r14 = frame-destroy POP64r implicit-def $rsp, implicit $rsp, debug-location !24
    CFI_INSTRUCTION def_cfa_offset 16, debug-location !24
    $r15 = frame-destroy POP64r implicit-def $rsp, implicit $rsp, debug-location !24
    CFI_INSTRUCTION def_cfa_offset 8, debug-location !24
    RETQ debug-location !24

...