1 # RUN: llc -start-after=livedebugvalues --filetype=obj %s -o - \
2 # RUN: | llvm-dwarfdump -v --name local - \
5 ## Generated with opt -inline -mem2reg, llc -stop-after=livedebugvalues from:
10 ## __attribute__((always_inline))
11 ## static int inline_me() {
23 ## glob = inline_me();
27 ## Check that the location for inlined variable 'local' (RBX), which spans
28 ## multiple basic blocks, is given a single location.
30 # CHECK: DW_AT_location [DW_FORM_exprloc] (DW_OP_reg3 RBX)
31 # CHECK-NEXT: DW_AT_abstract_origin [DW_FORM_ref4] ({{.*}}"local")
34 target triple = "x86_64-unknown-linux-gnu"
36 @glob = dso_local global i32 0, align 4, !dbg !0
38 define dso_local i32 @_Z3funi(i32 %p) !dbg !11 {
40 call void @llvm.dbg.value(metadata i32 %p, metadata !15, metadata !DIExpression()), !dbg !16
41 store i32 %p, ptr @glob, align 4, !dbg !17
42 %0 = load i32, ptr @glob, align 4, !dbg !22
43 call void @llvm.dbg.value(metadata i32 %0, metadata !27, metadata !DIExpression()), !dbg !30
44 call void @llvm.dbg.value(metadata i32 0, metadata !28, metadata !DIExpression()), !dbg !30
45 %tobool.i = icmp ne i32 %0, 0, !dbg !31
46 br i1 %tobool.i, label %if.then.i, label %if.else.i, !dbg !33
48 if.then.i: ; preds = %entry
49 %call.i = call i32 @_Z4ext1i(i32 %0), !dbg !34
50 call void @llvm.dbg.value(metadata i32 %call.i, metadata !28, metadata !DIExpression()), !dbg !30
51 br label %_ZL9inline_mev.exit, !dbg !35
53 if.else.i: ; preds = %entry
54 %call1.i = call i32 @_Z4ext2i(i32 %0), !dbg !36
55 call void @llvm.dbg.value(metadata i32 %call1.i, metadata !28, metadata !DIExpression()), !dbg !30
56 br label %_ZL9inline_mev.exit
58 _ZL9inline_mev.exit: ; preds = %if.else.i, %if.then.i
59 %r.0.i = phi i32 [ %call.i, %if.then.i ], [ %call1.i, %if.else.i ], !dbg !37
60 call void @llvm.dbg.value(metadata i32 %r.0.i, metadata !28, metadata !DIExpression()), !dbg !30
61 %mul.i = mul nsw i32 %r.0.i, %0, !dbg !38
62 store i32 %mul.i, ptr @glob, align 4, !dbg !39
66 declare !dbg !41 dso_local i32 @_Z4ext1i(i32)
67 declare !dbg !42 dso_local i32 @_Z4ext2i(i32)
68 declare void @llvm.dbg.value(metadata, metadata, metadata)
71 !llvm.module.flags = !{!7, !8, !9}
74 !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
75 !1 = distinct !DIGlobalVariable(name: "glob", scope: !2, file: !3, line: 1, type: !6, isLocal: false, isDefinition: true)
76 !2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !3, producer: "clang version 12.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5, splitDebugInlining: false, nameTableKind: None)
77 !3 = !DIFile(filename: "test.cpp", directory: "/")
80 !6 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
81 !7 = !{i32 7, !"Dwarf Version", i32 4}
82 !8 = !{i32 2, !"Debug Info Version", i32 3}
83 !9 = !{i32 1, !"wchar_size", i32 4}
84 !10 = !{!"clang version 12.0.0"}
85 !11 = distinct !DISubprogram(name: "fun", linkageName: "_Z3funi", scope: !3, file: !3, line: 16, type: !12, scopeLine: 16, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !14)
86 !12 = !DISubroutineType(types: !13)
89 !15 = !DILocalVariable(name: "p", arg: 1, scope: !11, file: !3, line: 16, type: !6)
90 !16 = !DILocation(line: 0, scope: !11)
91 !17 = !DILocation(line: 17, column: 8, scope: !11)
92 !22 = !DILocation(line: 7, column: 15, scope: !23, inlinedAt: !29)
93 !23 = distinct !DISubprogram(name: "inline_me", linkageName: "_ZL9inline_mev", scope: !3, file: !3, line: 6, type: !24, scopeLine: 6, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !26)
94 !24 = !DISubroutineType(types: !25)
97 !27 = !DILocalVariable(name: "local", scope: !23, file: !3, line: 7, type: !6)
98 !28 = !DILocalVariable(name: "r", scope: !23, file: !3, line: 8, type: !6)
99 !29 = distinct !DILocation(line: 18, column: 10, scope: !11)
100 !30 = !DILocation(line: 0, scope: !23, inlinedAt: !29)
101 !31 = !DILocation(line: 9, column: 7, scope: !32, inlinedAt: !29)
102 !32 = distinct !DILexicalBlock(scope: !23, file: !3, line: 9, column: 7)
103 !33 = !DILocation(line: 9, column: 7, scope: !23, inlinedAt: !29)
104 !34 = !DILocation(line: 10, column: 9, scope: !32, inlinedAt: !29)
105 !35 = !DILocation(line: 10, column: 5, scope: !32, inlinedAt: !29)
106 !36 = !DILocation(line: 12, column: 9, scope: !32, inlinedAt: !29)
107 !37 = !DILocation(line: 0, scope: !32, inlinedAt: !29)
108 !38 = !DILocation(line: 13, column: 12, scope: !23, inlinedAt: !29)
109 !39 = !DILocation(line: 18, column: 8, scope: !11)
110 !40 = !DILocation(line: 19, column: 3, scope: !11)
111 !41 = !DISubprogram(name: "ext1", linkageName: "_Z4ext1i", scope: !3, file: !3, line: 2, type: !12, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !4)
112 !42 = !DISubprogram(name: "ext2", linkageName: "_Z4ext2i", scope: !3, file: !3, line: 3, type: !12, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !4)
119 successors: %bb.1(0x50000000), %bb.2(0x30000000)
122 DBG_VALUE $edi, $noreg, !15, !DIExpression(), debug-location !16
123 frame-setup PUSH64r killed $rbx, implicit-def $rsp, implicit $rsp
124 CFI_INSTRUCTION def_cfa_offset 16
125 CFI_INSTRUCTION offset $rbx, -16
127 DBG_VALUE $ebx, $noreg, !15, !DIExpression(), debug-location !16
128 MOV32mr $rip, 1, $noreg, @glob, $noreg, $edi, debug-location !17 :: (store (s32) into @glob)
129 DBG_VALUE $ebx, $noreg, !27, !DIExpression(), debug-location !30
130 DBG_VALUE 0, $noreg, !28, !DIExpression(), debug-location !30
131 TEST32rr $edi, $edi, implicit-def $eflags, debug-location !31
132 JCC_1 %bb.2, 4, implicit killed $eflags, debug-location !33
135 successors: %bb.3(0x80000000)
138 DBG_VALUE $ebx, $noreg, !27, !DIExpression(), debug-location !30
139 DBG_VALUE $ebx, $noreg, !15, !DIExpression(), debug-location !16
140 DBG_VALUE 0, $noreg, !28, !DIExpression(), debug-location !30
141 $edi = MOV32rr $ebx, debug-location !34
142 CALL64pcrel32 @_Z4ext1i, csr_64, implicit $rsp, implicit $ssp, implicit $edi, implicit-def $rsp, implicit-def $ssp, implicit-def $eax, debug-location !34
143 DBG_VALUE $eax, $noreg, !28, !DIExpression(), debug-location !30
147 successors: %bb.3(0x80000000)
150 DBG_VALUE $ebx, $noreg, !27, !DIExpression(), debug-location !30
151 DBG_VALUE $ebx, $noreg, !15, !DIExpression(), debug-location !16
152 DBG_VALUE 0, $noreg, !28, !DIExpression(), debug-location !30
153 $edi = MOV32rr $ebx, debug-location !36
154 CALL64pcrel32 @_Z4ext2i, csr_64, implicit $rsp, implicit $ssp, implicit $edi, implicit-def $rsp, implicit-def $ssp, implicit-def $eax, debug-location !36
155 DBG_VALUE $eax, $noreg, !28, !DIExpression(), debug-location !30
157 bb.3._ZL9inline_mev.exit:
160 DBG_VALUE $ebx, $noreg, !27, !DIExpression(), debug-location !30
161 DBG_VALUE $ebx, $noreg, !15, !DIExpression(), debug-location !16
162 DBG_VALUE $eax, $noreg, !28, !DIExpression(), debug-location !30
163 DBG_VALUE $eax, $noreg, !28, !DIExpression(), debug-location !30
164 renamable $eax = nsw IMUL32rr killed renamable $eax, killed renamable $ebx, implicit-def dead $eflags, debug-location !38
165 MOV32mr $rip, 1, $noreg, @glob, $noreg, killed renamable $eax, debug-location !39 :: (store (s32) into @glob)
166 $eax = XOR32rr undef $eax, undef $eax, implicit-def dead $eflags, debug-location !40
167 $rbx = frame-destroy POP64r implicit-def $rsp, implicit $rsp, debug-location !40
168 DBG_VALUE $edi, $noreg, !15, !DIExpression(DW_OP_LLVM_entry_value, 1), debug-location !16
169 CFI_INSTRUCTION def_cfa_offset 8, debug-location !40
170 RET64 $eax, debug-location !40