brintos

brintos / llvm-project-archived public Read only

0
0
Text · 10.5 KiB · a9c20d7 Raw
222 lines · plain
1## Test the call site encoding in DWARF5 vs GNU extensions.2 3## === DWARF4, tune for gdb ===4# RUN: llc -emit-call-site-info -dwarf-version 4 -debugger-tune=gdb -filetype=obj \5# RUN:     -mtriple=x86_64-unknown-unknown -start-after=machineverifier -o - %s  \6# RUN:     | llvm-dwarfdump - | FileCheck %s -check-prefixes=CHECK-GNU -implicit-check-not=DW_AT_call7 8# === DWARF5, tune for gdb ===9# RUN: llc -dwarf-version 5 -debugger-tune=gdb -emit-call-site-info -filetype=obj \10# RUN:     -mtriple=x86_64-unknown-unknown -start-after=machineverifier -o - %s  \11# RUN:     | llvm-dwarfdump - | FileCheck %s -check-prefixes=CHECK-DWARF5 -implicit-check-not=DW_AT_call12 13## === DWARF4, tune for lldb ===14# RUN: llc -dwarf-version 4 -debugger-tune=lldb -emit-call-site-info -filetype=obj \15# RUN:     -mtriple=x86_64-unknown-unknown -start-after=machineverifier -o - %s   \16# RUN:     | llvm-dwarfdump - | FileCheck %s -check-prefixes=CHECK-DWARF5 -implicit-check-not=DW_AT_call17 18## === DWARF5, tune for lldb ===19# RUN: llc -dwarf-version 5 -debugger-tune=lldb -emit-call-site-info -filetype=obj \20# RUN:     -mtriple=x86_64-unknown-unknown -start-after=machineverifier -o - %s   \21# RUN:     | llvm-dwarfdump - | FileCheck %s -check-prefixes=CHECK-DWARF5 -implicit-check-not=DW_AT_call22 23## === DWARF4, tune for sce ===24# RUN: llc -emit-call-site-info -dwarf-version 4 -filetype=obj -debugger-tune=sce \25# RUN:     -debug-entry-values -mtriple=x86_64-unknown-unknown \26# RUN:     -start-after=machineverifier -o - %s | llvm-dwarfdump - | FileCheck %s -check-prefixes=CHECK-GNU27 28## === DWARF5, tune for sce ===29# RUN: llc -emit-call-site-info -dwarf-version 5 -filetype=obj -debugger-tune=sce \30# RUN:     -debug-entry-values -mtriple=x86_64-unknown-unknown \31# RUN:     -start-after=machineverifier -o - %s | llvm-dwarfdump - | FileCheck %s -check-prefixes=CHECK-DWARF532 33## === DWARF3, tune for gdb ===34# RUN: llc -emit-call-site-info -dwarf-version 3 -debugger-tune=gdb -filetype=obj \35# RUN:     -mtriple=x86_64-unknown-unknown -start-after=machineverifier -o - %s  \36# RUN:     | llvm-dwarfdump - | FileCheck %s -implicit-check-not=DW_AT_call37 38## === DWARF3, tune for lldb ===39# RUN: llc -dwarf-version 3 -debugger-tune=lldb -emit-call-site-info -filetype=obj \40# RUN:     -mtriple=x86_64-unknown-unknown -start-after=machineverifier -o - %s   \41# RUN:     | llvm-dwarfdump - | FileCheck %s -implicit-check-not=DW_AT_GNU_call42 43## === DWARF3, tune for sce ===44# RUN: llc -emit-call-site-info -dwarf-version 3 -filetype=obj -debugger-tune=sce \45# RUN:     -debug-entry-values -mtriple=x86_64-unknown-unknown \46# RUN:     -start-after=machineverifier -o - %s | llvm-dwarfdump - | FileCheck %s -implicit-check-not=DW_AT_call47 48## This is based on the following reproducer:49##50## extern void fn();51## extern void fn2(int x);52## extern int fn3();53##54## int fn1(int (*fn4) ()) {55##   fn();56##   fn2(5);57##58##   int x = (*fn4)();59##   if (!x)60##     return fn3();61##   else62##     return -1;63## }64 65## Check GNU extensions:66 67# CHECK-GNU:        DW_TAG_subprogram68# CHECK-GNU:          DW_AT_GNU_all_call_sites    (true)69# CHECK-GNU:        DW_TAG_GNU_call_site70# CHECK-GNU-NEXT:     DW_AT_abstract_origin71# CHECK-GNU-NEXT:     DW_AT_low_pc72# CHECK-GNU:          DW_TAG_GNU_call_site_parameter73# CHECK-GNU-NEXT:       DW_AT_location74# CHECK-GNU-NEXT:       DW_AT_GNU_call_site_value75# CHECK-GNU:        DW_TAG_GNU_call_site76# CHECK-GNU-NEXT:       DW_AT_GNU_call_site_target77# CHECK-GNU-NEXT:       DW_AT_low_pc78# CHECK-GNU:        DW_TAG_GNU_call_site79# CHECK-GNU-NEXT:     DW_AT_abstract_origin80# CHECK-GNU-NEXT:     DW_AT_GNU_tail_call81# CHECK-GNU-NEXT:     DW_AT_low_pc82 83## Check DWARF 5:84 85# CHECK-DWARF5:        DW_TAG_subprogram86# CHECK-DWARF5:          DW_AT_call_all_calls    (true)87# CHECK-DWARF5:        DW_TAG_call_site88# CHECK-DWARF5-NEXT:     DW_AT_call_origin89# CHECK-DWARF5-NEXT:     DW_AT_call_return_pc90# CHECK-DWARF5:        DW_TAG_call_site91# CHECK-DWARF5-NEXT:     DW_AT_call_origin92# CHECK-DWARF5-NEXT:     DW_AT_call_return_pc93# CHECK-DWARF5:          DW_TAG_call_site_parameter94# CHECK-DWARF5-NEXT:       DW_AT_location95# CHECK-DWARF5-NEXT:       DW_AT_call_value96# CHECK-DWARF5:        DW_TAG_call_site97# CHECK-DWARF5-NEXT:     DW_AT_call_target98# CHECK-DWARF5-NEXT:     DW_AT_call_return_pc99# CHECK-DWARF5:        DW_TAG_call_site100# CHECK-DWARF5-NEXT:     DW_AT_call_origin101# CHECK-DWARF5-NEXT:     DW_AT_call_tail_call102# CHECK-DWARF5-NEXT:     DW_AT_call_pc103 104--- |105  ; ModuleID = 'call-site-attrs.c'106  source_filename = "call-site-attrs.c"107  target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"108  target triple = "x86_64-unknown-linux-gnu"109  ; Function Attrs: nounwind uwtable110  define dso_local i32 @fn1(ptr nocapture %fn4) local_unnamed_addr !dbg !18 {111  entry:112    call void @llvm.dbg.value(metadata ptr %fn4, metadata !23, metadata !DIExpression()), !dbg !25113    tail call void (...) @fn(), !dbg !26114    tail call void @fn2(i32 5), !dbg !27115    %call = tail call i32 (...) %fn4(), !dbg !28116    call void @llvm.dbg.value(metadata i32 %call, metadata !24, metadata !DIExpression()), !dbg !25117    %tobool = icmp eq i32 %call, 0, !dbg !29118    br i1 %tobool, label %if.then, label %cleanup, !dbg !31119  120  if.then:                                          ; preds = %entry121    %call1 = tail call i32 (...) @fn3(), !dbg !32122    ret i32 %call1, !dbg !33123  124  cleanup:                                          ; preds = %entry125    ret i32 -1, !dbg !33126  }127  declare !dbg !4 dso_local void @fn(...) local_unnamed_addr128  declare !dbg !7 dso_local void @fn2(i32) local_unnamed_addr129  declare !dbg !11 dso_local i32 @fn3(...) local_unnamed_addr130  ; Function Attrs: nounwind readnone speculatable willreturn131  declare void @llvm.dbg.value(metadata, metadata, metadata)132  133  !llvm.dbg.cu = !{!0}134  !llvm.module.flags = !{!14, !15, !16}135  !llvm.ident = !{!17}136  137  !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 11.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !3, splitDebugInlining: false, nameTableKind: None)138  !1 = !DIFile(filename: "call-site-attrs.c", directory: "/")139  !2 = !{}140  !3 = !{!4, !7, !11}141  !4 = !DISubprogram(name: "fn", scope: !1, file: !1, line: 1, type: !5, spFlags: DISPFlagOptimized, retainedNodes: !2)142  !5 = !DISubroutineType(types: !6)143  !6 = !{null, null}144  !7 = !DISubprogram(name: "fn2", scope: !1, file: !1, line: 2, type: !8, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2)145  !8 = !DISubroutineType(types: !9)146  !9 = !{null, !10}147  !10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)148  !11 = !DISubprogram(name: "fn3", scope: !1, file: !1, line: 3, type: !12, spFlags: DISPFlagOptimized, retainedNodes: !2)149  !12 = !DISubroutineType(types: !13)150  !13 = !{!10, null}151  !14 = !{i32 7, !"Dwarf Version", i32 4}152  !15 = !{i32 2, !"Debug Info Version", i32 3}153  !16 = !{i32 1, !"wchar_size", i32 4}154  !17 = !{!"clang version 11.0.0"}155  !18 = distinct !DISubprogram(name: "fn1", scope: !1, file: !1, line: 5, type: !19, scopeLine: 5, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !22)156  !19 = !DISubroutineType(types: !20)157  !20 = !{!10, !21}158  !21 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !12, size: 64)159  !22 = !{!23, !24}160  !23 = !DILocalVariable(name: "fn4", arg: 1, scope: !18, file: !1, line: 5, type: !21)161  !24 = !DILocalVariable(name: "x", scope: !18, file: !1, line: 9, type: !10)162  !25 = !DILocation(line: 0, scope: !18)163  !26 = !DILocation(line: 6, column: 3, scope: !18)164  !27 = !DILocation(line: 7, column: 3, scope: !18)165  !28 = !DILocation(line: 9, column: 11, scope: !18)166  !29 = !DILocation(line: 10, column: 8, scope: !30)167  !30 = distinct !DILexicalBlock(scope: !18, file: !1, line: 10, column: 7)168  !31 = !DILocation(line: 10, column: 7, scope: !18)169  !32 = !DILocation(line: 11, column: 12, scope: !30)170  !33 = !DILocation(line: 14, column: 1, scope: !18)171 172...173---174name:            fn1175callSites:176  - { bb: 0, offset: 7, fwdArgRegs: [] }177  - { bb: 0, offset: 9, fwdArgRegs: 178      - { arg: 0, reg: '$edi' } }179  - { bb: 0, offset: 11, fwdArgRegs: [] }180  - { bb: 2, offset: 7, fwdArgRegs: [] }181body:             |182  bb.0.entry:183    successors: %bb.2(0x30000000), %bb.1(0x50000000)184    liveins: $rdi, $rbx185  186    DBG_VALUE $rdi, $noreg, !23, !DIExpression(), debug-location !25187    frame-setup PUSH64r killed $rbx, implicit-def $rsp, implicit $rsp188    CFI_INSTRUCTION def_cfa_offset 16189    CFI_INSTRUCTION offset $rbx, -16190    $rbx = MOV64rr $rdi191    DBG_VALUE $rbx, $noreg, !23, !DIExpression(), debug-location !25192    dead $eax = XOR32rr undef $eax, undef $eax, implicit-def dead $eflags, implicit-def $al, debug-location !26193    CALL64pcrel32 @fn, csr_64, implicit $rsp, implicit $ssp, implicit $al, implicit-def $rsp, implicit-def $ssp, debug-location !26194    $edi = MOV32ri 5, debug-location !27195    CALL64pcrel32 @fn2, csr_64, implicit $rsp, implicit $ssp, implicit $edi, implicit-def $rsp, implicit-def $ssp, debug-location !27196    dead $eax = XOR32rr undef $eax, undef $eax, implicit-def dead $eflags, implicit-def $al, debug-location !28197    CALL64r killed renamable $rbx, csr_64, implicit $rsp, implicit $ssp, implicit $al, implicit-def $rsp, implicit-def $ssp, implicit-def $eax, debug-location !28198    DBG_VALUE $eax, $noreg, !24, !DIExpression(), debug-location !25199    TEST32rr killed renamable $eax, renamable $eax, implicit-def $eflags, debug-location !29200    JCC_1 %bb.2, 4, implicit $eflags, debug-location !31201  202  bb.1.cleanup:203    DBG_VALUE $eax, $noreg, !24, !DIExpression(), debug-location !25204    DBG_VALUE $rbx, $noreg, !23, !DIExpression(), debug-location !25205    $eax = MOV32ri -1, debug-location !33206    $rbx = frame-destroy POP64r implicit-def $rsp, implicit $rsp, debug-location !33207    DBG_VALUE $rdi, $noreg, !23, !DIExpression(DW_OP_LLVM_entry_value, 1), debug-location !25208    CFI_INSTRUCTION def_cfa_offset 8, debug-location !33209    RET64 $eax, debug-location !33210  211  bb.2.if.then:212    CFI_INSTRUCTION def_cfa_offset 16, debug-location !32213    DBG_VALUE $eax, $noreg, !24, !DIExpression(), debug-location !25214    DBG_VALUE $rbx, $noreg, !23, !DIExpression(), debug-location !25215    dead $eax = XOR32rr undef $eax, undef $eax, implicit-def dead $eflags, implicit-def $al, debug-location !32216    $rbx = frame-destroy POP64r implicit-def $rsp, implicit $rsp, debug-location !32217    DBG_VALUE $rdi, $noreg, !23, !DIExpression(DW_OP_LLVM_entry_value, 1), debug-location !25218    CFI_INSTRUCTION def_cfa_offset 8, debug-location !32219    TAILJMPd64 @fn3, csr_64, implicit $rsp, implicit $ssp, implicit $rsp, implicit $ssp, implicit $al, debug-location !32220 221...222