1# RUN: llc -emit-call-site-info -start-before=livedebugvalues -stop-after=machineverifier -o - %s \
2# RUN:   | FileCheck %s -check-prefix=MIR
3
4# Copied from dbgcall-site-indirect-param.mir, with hand modifications:
5# an offset is added to the indirect parameter DBG_VALUE.
6#
7# We do not support emitting an entry value in this case.
8
9# MIR:      renamable $w0 = LDRWui killed renamable $x8
10# MIR-NOT:  DBG_VALUE $x0, 0, {{.*}}, !DIExpression(DW_OP_LLVM_entry_value
11# MIR-NEXT: BL @baz
12# MIR-NEXT: frame-destroy LDPXpost
13# MIR-NEXT: TCRETURNdi @baz
14
15--- |
16  target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
17  target triple = "arm64-apple-ios10.0.0"
18
19  %struct.fat_ptr = type { i32*, i32*, i32* }
20
21  define i32 @bar(%struct.fat_ptr* nocapture readonly %f) local_unnamed_addr !dbg !13 {
22  entry:
23    call void @llvm.dbg.declare(metadata %struct.fat_ptr* %f, metadata !23, metadata !DIExpression()), !dbg !24
24    %ptr2 = bitcast %struct.fat_ptr* %f to i32**, !dbg !25
25    %0 = load i32*, i32** %ptr2, align 8, !dbg !25
26    %1 = load i32, i32* %0, align 4, !dbg !31
27    %call = tail call i32 @baz(i32 %1), !dbg !34
28    %call1 = tail call i32 @baz(i32 %call), !dbg !35
29    ret i32 %call1, !dbg !36
30  }
31
32  declare void @llvm.dbg.declare(metadata, metadata, metadata)
33
34  declare !dbg !4 i32 @baz(i32) local_unnamed_addr optsize
35
36  !llvm.dbg.cu = !{!0}
37  !llvm.module.flags = !{!8, !9, !10, !11}
38  !llvm.ident = !{!12}
39
40  !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !3, nameTableKind: None, sysroot: "/")
41  !1 = !DIFile(filename: "indirect.c", directory: "/tmp/fatptr")
42  !2 = !{}
43  !3 = !{!4}
44  !4 = !DISubprogram(name: "baz", scope: !1, file: !1, line: 4, type: !5, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2)
45  !5 = !DISubroutineType(types: !6)
46  !6 = !{!7, !7}
47  !7 = !DIBasicType(name: "int", size: 32, 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 = !{i32 7, !"PIC Level", i32 2}
52  !12 = !{!"clang"}
53  !13 = distinct !DISubprogram(name: "bar", scope: !1, file: !1, line: 5, type: !14, scopeLine: 5, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !22)
54  !14 = !DISubroutineType(types: !15)
55  !15 = !{!7, !16}
56  !16 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "fat_ptr", file: !1, line: 1, size: 192, elements: !17)
57  !17 = !{!18, !20, !21}
58  !18 = !DIDerivedType(tag: DW_TAG_member, name: "ptr", scope: !16, file: !1, line: 2, baseType: !19, size: 64)
59  !19 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !7, size: 64)
60  !20 = !DIDerivedType(tag: DW_TAG_member, name: "low", scope: !16, file: !1, line: 2, baseType: !19, size: 64, offset: 64)
61  !21 = !DIDerivedType(tag: DW_TAG_member, name: "high", scope: !16, file: !1, line: 2, baseType: !19, size: 64, offset: 128)
62  !22 = !{!23}
63  !23 = !DILocalVariable(name: "f", arg: 1, scope: !13, file: !1, line: 5, type: !16)
64  !24 = !DILocation(line: 5, column: 24, scope: !13)
65  !25 = !DILocation(line: 6, column: 23, scope: !13)
66  !31 = !DILocation(line: 6, column: 20, scope: !13)
67  !34 = !DILocation(line: 6, column: 16, scope: !13)
68  !35 = !DILocation(line: 6, column: 12, scope: !13)
69  !36 = !DILocation(line: 6, column: 5, scope: !13)
70
71...
72---
73name:            bar
74stack:
75  - { id: 0, name: '', type: spill-slot, offset: -8, size: 8, alignment: 8,
76      stack-id: default, callee-saved-register: '$lr', callee-saved-restored: true,
77      debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
78  - { id: 1, name: '', type: spill-slot, offset: -16, size: 8, alignment: 8,
79      stack-id: default, callee-saved-register: '$fp', callee-saved-restored: true,
80      debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
81callSites:
82  - { bb: 0, offset: 8, fwdArgRegs:
83      - { arg: 0, reg: '$w0' } }
84  - { bb: 0, offset: 10, fwdArgRegs:
85      - { arg: 0, reg: '$w0' } }
86body:             |
87  bb.0.entry:
88    liveins: $x0, $lr
89
90    DBG_VALUE $x0, 0, !23, !DIExpression(DW_OP_plus_uconst, 12), debug-location !24
91    early-clobber $sp = frame-setup STPXpre killed $fp, killed $lr, $sp, -2 :: (store 8 into %stack.1), (store 8 into %stack.0)
92    $fp = frame-setup ADDXri $sp, 0, 0
93    frame-setup CFI_INSTRUCTION def_cfa $w29, 16
94    frame-setup CFI_INSTRUCTION offset $w30, -8, debug-location !25
95    frame-setup CFI_INSTRUCTION offset $w29, -16, debug-location !25
96    renamable $x8 = LDRXui killed renamable $x0, 0, debug-location !25 :: (load 8 from %ir.ptr2)
97    renamable $w0 = LDRWui killed renamable $x8, 0, debug-location !31 :: (load 4 from %ir.0)
98    BL @baz, csr_aarch64_aapcs, implicit-def dead $lr, implicit $sp, implicit $w0, implicit-def $sp, implicit-def $w0, debug-location !34
99    early-clobber $sp, $fp, $lr = frame-destroy LDPXpost $sp, 2, debug-location !35 :: (load 8 from %stack.1), (load 8 from %stack.0)
100    TCRETURNdi @baz, 0, csr_aarch64_aapcs, implicit $sp, implicit $w0, debug-location !35
101
102...
103