1# RUN: llc -mtriple aarch64-linux-gnu -emit-call-site-info -debug-entry-values -start-after=livedebugvalues -filetype=obj -o - %s \ 2# RUN: | llvm-dwarfdump - | FileCheck %s --implicit-check-not=DW_TAG_GNU_call_site_parameter 3# 4# Based on the following C reproducer: 5# 6# extern void call(long, long, long); 7# extern long global; 8# 9# long foo() { 10# long local = global; 11# call(local + 123, local - 456, local + 789); 12# return local; 13# } 14 15--- | 16 target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128" 17 target triple = "aarch64" 18 19 @global = external dso_local local_unnamed_addr global i64, align 8 20 21 define dso_local i64 @foo() local_unnamed_addr !dbg !12 { 22 entry: 23 %0 = load i64, i64* @global, align 8, !dbg !17 24 call void @llvm.dbg.value(metadata i64 %0, metadata !16, metadata !DIExpression()), !dbg !17 25 %add = add nsw i64 %0, 123, !dbg !17 26 %sub = add nsw i64 %0, -456, !dbg !17 27 %add1 = add nsw i64 %0, 789, !dbg !17 28 call void @call(i64 %add, i64 %sub, i64 %add1), !dbg !17 29 ret i64 %0, !dbg !17 30 } 31 32 declare !dbg !4 dso_local void @call(i64, i64, i64) local_unnamed_addr 33 34 declare void @llvm.dbg.value(metadata, metadata, metadata) 35 36 !llvm.dbg.cu = !{!0} 37 !llvm.module.flags = !{!8, !9, !10} 38 !llvm.ident = !{!11} 39 40 !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) 41 !1 = !DIFile(filename: "dbgcall-site-expr-chain.c", directory: "/") 42 !2 = !{} 43 !3 = !{!4} 44 !4 = !DISubprogram(name: "call", scope: !1, file: !1, line: 1, type: !5, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2) 45 !5 = !DISubroutineType(types: !6) 46 !6 = !{null, !7, !7, !7} 47 !7 = !DIBasicType(name: "long int", size: 64, encoding: DW_ATE_signed) 48 !8 = !{i32 7, !"Dwarf Version", i32 4} 49 !9 = !{i32 2, !"Debug Info Version", i32 3} 50 !10 = !{i32 1, !"wchar_size", i32 4} 51 !11 = !{!"clang version 11.0.0 "} 52 !12 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 5, type: !13, scopeLine: 5, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !15) 53 !13 = !DISubroutineType(types: !14) 54 !14 = !{!7} 55 !15 = !{!16} 56 !16 = !DILocalVariable(name: "local", scope: !12, file: !1, line: 6, type: !7) 57 !17 = !DILocation(line: 6, scope: !12) 58 59... 60--- 61name: foo 62tracksRegLiveness: true 63stack: 64 - { id: 0, type: spill-slot, offset: -16, size: 8, alignment: 16, callee-saved-register: '$x19' } 65 - { id: 1, type: spill-slot, offset: -24, size: 8, alignment: 8, callee-saved-register: '$lr' } 66 - { id: 2, type: spill-slot, offset: -32, size: 8, alignment: 8, callee-saved-register: '$fp' } 67callSites: 68 - { bb: 0, offset: 17, fwdArgRegs: 69 - { arg: 0, reg: '$x0' } 70 - { arg: 1, reg: '$x1' } 71 - { arg: 2, reg: '$x2' } } 72body: | 73 bb.0.entry: 74 liveins: $lr, $x19 75 76 early-clobber $sp = frame-setup STPXpre $fp, killed $lr, $sp, -4 :: (store 8 into %stack.2), (store 8 into %stack.1) 77 frame-setup STRXui killed $x19, $sp, 2 :: (store 8 into %stack.0) 78 $fp = frame-setup ADDXri $sp, 0, 0 79 frame-setup CFI_INSTRUCTION def_cfa $w29, 32 80 frame-setup CFI_INSTRUCTION offset $w19, -16, debug-location !17 81 frame-setup CFI_INSTRUCTION offset $w30, -24, debug-location !17 82 frame-setup CFI_INSTRUCTION offset $w29, -32, debug-location !17 83 renamable $x8 = ADRP target-flags(aarch64-page) @global, debug-location !17 84 renamable $x19 = LDRXui killed renamable $x8, target-flags(aarch64-pageoff, aarch64-nc) @global, debug-location !17 :: (dereferenceable load 8 from @global) 85 DBG_VALUE $x19, $noreg, !16, !DIExpression(), debug-location !17 86 renamable $x0 = nsw ADDXri renamable $x19, 100, 0, debug-location !17 87 renamable $x8 = nsw SUBXri renamable $x19, 406, 0, debug-location !17 88 renamable $x0 = nsw ADDXri renamable $x0, 23, 0, debug-location !17 89 renamable $x1 = nsw SUBXri renamable $x8, 50, 0, debug-location !17 90 renamable $x2 = nsw ADDXri renamable $x19, 700, 0, debug-location !17 91 renamable $x2 = nsw ADDXri renamable $x2, 9, 0, debug-location !17 92 renamable $x2 = nsw ADDXri renamable $x2, 80, 0, debug-location !17 93 BL @call, csr_aarch64_aapcs, implicit-def dead $lr, implicit $sp, implicit killed $x0, implicit killed $x1, implicit killed $x2, implicit-def $sp, debug-location !17 94 $x0 = ORRXrs $xzr, killed $x19, 0, debug-location !17 95 $x19 = frame-destroy LDRXui $sp, 2, debug-location !17 :: (load 8 from %stack.0) 96 early-clobber $sp, $fp, $lr = frame-destroy LDPXpost $sp, 4, debug-location !17 :: (load 8 from %stack.2), (load 8 from %stack.1) 97 RET undef $lr, implicit killed $x0, debug-location !17 98 99... 100 101# Verify that call site entries are emitted for all three parameters. 102# 103# The MIR has been hand-modified to build up the call site values using chains 104# of ADDXri/SUBXri instructions instead of a single instruction per parameter. 105 106# CHECK: DW_TAG_GNU_call_site_parameter 107# CHECK-NEXT: DW_AT_location (DW_OP_reg2 W2) 108# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_breg19 W19+700, DW_OP_plus_uconst 0x9, DW_OP_plus_uconst 0x50) 109 110# CHECK: DW_TAG_GNU_call_site_parameter 111# CHECK-NEXT: DW_AT_location (DW_OP_reg1 W1) 112# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_breg19 W19-406, DW_OP_constu 0x32, DW_OP_minus) 113 114# CHECK: DW_TAG_GNU_call_site_parameter 115# CHECK-NEXT: DW_AT_location (DW_OP_reg0 W0) 116# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_breg19 W19+100, DW_OP_plus_uconst 0x17) 117