1 ; RUN: llc -filetype=obj -o - %s | llvm-dwarfdump --name resource - | FileCheck %s
2 ; CHECK: DW_TAG_formal_parameter
3 ; CHECK: DW_TAG_formal_parameter
4 ; CHECK-NEXT: DW_AT_location (DW_OP_reg1 W1)
5 ; CHECK-NEXT: DW_AT_abstract_origin {{.*}}"resource"
7 ; Inlined variable "resource"/!37 covers all blocks in its lexical scope. Check
8 ; that it is given a single location.
11 ; typedef struct t *t_t;
12 ; extern unsigned int enable;
16 ; unsigned long long resource;
19 ; static unsigned long find(t_t t, unsigned long long resource) {
23 ; if (q->resource == resource)
28 ; int g(t_t t, unsigned long long r) {
32 ; if (__builtin_expect(enable, 0)) { }
35 ; ModuleID = 'inlined-arg.c'
36 source_filename = "inlined-arg.c"
37 target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
38 target triple = "arm64-apple-ios5.0.0"
40 %struct.t = type { %struct.q* }
41 %struct.q = type { %struct.q*, i64 }
43 @tt = common local_unnamed_addr global %struct.t* null, align 8, !dbg !0
45 ; Function Attrs: norecurse nounwind readonly ssp uwtable
46 define i32 @g(%struct.t* nocapture readonly %t, i64 %r) local_unnamed_addr !dbg !21 {
48 call void @llvm.dbg.value(metadata %struct.t* %t, metadata !27, metadata !DIExpression()), !dbg !30
49 call void @llvm.dbg.value(metadata i64 %r, metadata !28, metadata !DIExpression()), !dbg !31
50 call void @llvm.dbg.value(metadata %struct.t* %t, metadata !32, metadata !DIExpression()), !dbg !39
51 call void @llvm.dbg.value(metadata i64 %r, metadata !37, metadata !DIExpression()), !dbg !41
52 %s.i = getelementptr inbounds %struct.t, %struct.t* %t, i64 0, i32 0, !dbg !42
53 %q.05.i = load %struct.q*, %struct.q** %s.i, align 8, !dbg !43, !tbaa !44
54 call void @llvm.dbg.value(metadata %struct.q* %q.05.i, metadata !38, metadata !DIExpression()), !dbg !48
55 %tobool6.i = icmp eq %struct.q* %q.05.i, null, !dbg !49
56 br i1 %tobool6.i, label %find.exit, label %while.body.i, !dbg !49
58 while.body.i: ; preds = %entry, %if.end.i
59 %q.07.i = phi %struct.q* [ %q.0.i, %if.end.i ], [ %q.05.i, %entry ]
60 %resource1.i = getelementptr inbounds %struct.q, %struct.q* %q.07.i, i64 0, i32 1, !dbg !50
61 %0 = load i64, i64* %resource1.i, align 8, !dbg !50, !tbaa !53
62 %cmp.i = icmp eq i64 %0, %r, !dbg !56
63 br i1 %cmp.i, label %find.exit, label %if.end.i, !dbg !57
65 if.end.i: ; preds = %while.body.i
66 %next.i = getelementptr inbounds %struct.q, %struct.q* %q.07.i, i64 0, i32 0, !dbg !58
67 %q.0.i = load %struct.q*, %struct.q** %next.i, align 8, !dbg !43, !tbaa !44
68 call void @llvm.dbg.value(metadata %struct.q* %q.0.i, metadata !38, metadata !DIExpression()), !dbg !48
69 %tobool.i = icmp eq %struct.q* %q.0.i, null, !dbg !49
70 br i1 %tobool.i, label %find.exit, label %while.body.i, !dbg !49, !llvm.loop !59
72 find.exit: ; preds = %while.body.i, %if.end.i, %entry
73 call void @llvm.dbg.value(metadata %struct.q* undef, metadata !29, metadata !DIExpression()), !dbg !61
74 ret i32 undef, !dbg !62
77 ; Function Attrs: nounwind readnone speculatable
78 declare void @llvm.dbg.value(metadata, metadata, metadata)
81 !llvm.module.flags = !{!16, !17, !18, !19}
84 !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
85 !1 = distinct !DIGlobalVariable(name: "tt", scope: !2, file: !3, line: 8, type: !6, isLocal: false, isDefinition: true)
86 !2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang version 9.0.0 (https://github.com/llvm/llvm-project.git cd3671d5dabc8848619d872f994770167a44ac5a)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5, nameTableKind: GNU)
87 !3 = !DIFile(filename: "inlined-arg.c", directory: "")
90 !6 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !7, size: 64)
91 !7 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "t", file: !3, line: 3, size: 64, elements: !8)
93 !9 = !DIDerivedType(tag: DW_TAG_member, name: "s", scope: !7, file: !3, line: 7, baseType: !10, size: 64)
94 !10 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !11, size: 64)
95 !11 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "q", file: !3, line: 4, size: 128, elements: !12)
97 !13 = !DIDerivedType(tag: DW_TAG_member, name: "next", scope: !11, file: !3, line: 5, baseType: !10, size: 64)
98 !14 = !DIDerivedType(tag: DW_TAG_member, name: "resource", scope: !11, file: !3, line: 6, baseType: !15, size: 64, offset: 64)
99 !15 = !DIBasicType(name: "long long unsigned int", size: 64, encoding: DW_ATE_unsigned)
100 !16 = !{i32 2, !"Dwarf Version", i32 2}
101 !17 = !{i32 2, !"Debug Info Version", i32 3}
102 !18 = !{i32 1, !"wchar_size", i32 4}
103 !19 = !{i32 7, !"PIC Level", i32 2}
104 !20 = !{!"clang version 9.0.0 (https://github.com/llvm/llvm-project.git cd3671d5dabc8848619d872f994770167a44ac5a)"}
105 !21 = distinct !DISubprogram(name: "g", scope: !3, file: !3, line: 19, type: !22, scopeLine: 19, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !26)
106 !22 = !DISubroutineType(types: !23)
107 !23 = !{!24, !25, !15}
108 !24 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
109 !25 = !DIDerivedType(tag: DW_TAG_typedef, name: "t_t", file: !3, line: 1, baseType: !6)
110 !26 = !{!27, !28, !29}
111 !27 = !DILocalVariable(name: "t", arg: 1, scope: !21, file: !3, line: 19, type: !25)
112 !28 = !DILocalVariable(name: "r", arg: 2, scope: !21, file: !3, line: 19, type: !15)
113 !29 = !DILocalVariable(name: "q", scope: !21, file: !3, line: 20, type: !10)
114 !30 = !DILocation(line: 19, column: 11, scope: !21)
115 !31 = !DILocation(line: 19, column: 33, scope: !21)
116 !32 = !DILocalVariable(name: "t", arg: 1, scope: !33, file: !3, line: 10, type: !25)
117 !33 = distinct !DISubprogram(name: "find", scope: !3, file: !3, line: 10, type: !34, scopeLine: 10, flags: DIFlagPrototyped, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !36)
118 !34 = !DISubroutineType(types: !35)
119 !35 = !{!10, !25, !15}
120 !36 = !{!32, !37, !38}
121 !37 = !DILocalVariable(name: "resource", arg: 2, scope: !33, file: !3, line: 10, type: !15)
122 !38 = !DILocalVariable(name: "q", scope: !33, file: !3, line: 11, type: !10)
123 !39 = !DILocation(line: 10, column: 27, scope: !33, inlinedAt: !40)
124 !40 = distinct !DILocation(line: 21, column: 7, scope: !21)
125 !41 = !DILocation(line: 10, column: 49, scope: !33, inlinedAt: !40)
126 !42 = !DILocation(line: 12, column: 10, scope: !33, inlinedAt: !40)
127 !43 = !DILocation(line: 0, scope: !33, inlinedAt: !40)
128 !44 = !{!45, !45, i64 0}
129 !45 = !{!"any pointer", !46, i64 0}
130 !46 = !{!"omnipotent char", !47, i64 0}
131 !47 = !{!"Simple C/C++ TBAA"}
132 !48 = !DILocation(line: 11, column: 13, scope: !33, inlinedAt: !40)
133 !49 = !DILocation(line: 13, column: 3, scope: !33, inlinedAt: !40)
134 !50 = !DILocation(line: 14, column: 12, scope: !51, inlinedAt: !40)
135 !51 = distinct !DILexicalBlock(scope: !52, file: !3, line: 14, column: 9)
136 !52 = distinct !DILexicalBlock(scope: !33, file: !3, line: 13, column: 13)
137 !53 = !{!54, !55, i64 8}
138 !54 = !{!"q", !45, i64 0, !55, i64 8}
139 !55 = !{!"long long", !46, i64 0}
140 !56 = !DILocation(line: 14, column: 21, scope: !51, inlinedAt: !40)
141 !57 = !DILocation(line: 14, column: 9, scope: !52, inlinedAt: !40)
142 !58 = !DILocation(line: 16, column: 12, scope: !52, inlinedAt: !40)
143 !59 = distinct !{!59, !49, !60}
144 !60 = !DILocation(line: 17, column: 3, scope: !33, inlinedAt: !40)
145 !61 = !DILocation(line: 20, column: 13, scope: !21)
146 !62 = !DILocation(line: 24, column: 1, scope: !21)