1 # RUN: llc -start-after=livedebugvalues --filetype=obj %s -o - \
2 # RUN: | llvm-dwarfdump -v --name local* --regex - | FileCheck %s
4 # Generated with opt -sroa, llc -stop-after=livedebugvalues, with some metadata
11 # // Location should start here.
22 # // Location should start here.
23 # memcpy(localtwo.b, 0, 2);
28 # Check that the local variables each have a location range which reflects the
29 # fact that they're both unavailable at the start of the functions.
31 # CHECK: DW_TAG_variable [
32 # CHECK-NEXT: DW_AT_location [DW_FORM_sec_offset]
33 # CHECK-NEXT: [0x{{[0-9a-z]+}}, 0x{{[0-9a-z]+}})
34 # CHECK-NEXT: DW_AT_name {{.*}} = "localone"
36 # CHECK: DW_TAG_variable [
37 # CHECK-NEXT: DW_AT_location [DW_FORM_sec_offset]
38 # CHECK-NEXT: [0x{{[0-9a-z]+}}, 0x{{[0-9a-z]+}})
39 # CHECK-NEXT: DW_AT_name {{.*}} = "localtwo"
42 target triple = "x86_64-unknown-linux-gnu"
44 @c = dso_local global i64 0, align 8, !dbg !0
45 @b = dso_local global i64 0, align 8, !dbg !9
46 @a = dso_local global i64 0, align 8, !dbg !6
48 define dso_local i64 @funone() !dbg !15 {
50 %0 = load i64, i64* @c, align 8, !dbg !21
51 %tobool = icmp ne i64 %0, 0, !dbg !21
52 br i1 %tobool, label %if.then, label %if.end, !dbg !27
54 if.then: ; preds = %entry
55 %1 = load i64, i64* @b, align 8, !dbg !21
56 br label %cleanup, !dbg !21
58 if.end: ; preds = %entry
59 call void @llvm.dbg.value(metadata i32 0, metadata !19, metadata !DIExpression()), !dbg !27
60 %2 = load i64, i64* @a, align 8, !dbg !27
61 br label %cleanup, !dbg !27
63 cleanup: ; preds = %if.end, %if.then
64 %retval.0 = phi i64 [ %1, %if.then ], [ %2, %if.end ], !dbg !27
65 ret i64 %retval.0, !dbg !27
68 define dso_local signext i16 @funtwo() !dbg !34 {
70 %localtwo.sroa.0.0.copyload = load i16, i16* null, align 1, !dbg !48
71 call void @llvm.dbg.value(metadata i16 %localtwo.sroa.0.0.copyload, metadata !39, metadata !DIExpression()), !dbg !51
72 ret i16 %localtwo.sroa.0.0.copyload, !dbg !51
75 declare void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i64, i1 immarg)
76 declare void @llvm.dbg.value(metadata, metadata, metadata)
79 !llvm.module.flags = !{!11, !12, !13}
82 !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
83 !1 = distinct !DIGlobalVariable(name: "c", scope: !2, file: !3, line: 2, type: !8, isLocal: false, isDefinition: true)
84 !2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang version 11.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5, splitDebugInlining: false, nameTableKind: None)
85 !3 = !DIFile(filename: "test.c", directory: "/")
88 !6 = !DIGlobalVariableExpression(var: !7, expr: !DIExpression())
89 !7 = distinct !DIGlobalVariable(name: "a", scope: !2, file: !3, line: 2, type: !8, isLocal: false, isDefinition: true)
90 !8 = !DIBasicType(name: "long int", size: 64, encoding: DW_ATE_signed)
91 !9 = !DIGlobalVariableExpression(var: !10, expr: !DIExpression())
92 !10 = distinct !DIGlobalVariable(name: "b", scope: !2, file: !3, line: 2, type: !8, isLocal: false, isDefinition: true)
93 !11 = !{i32 7, !"Dwarf Version", i32 4}
94 !12 = !{i32 2, !"Debug Info Version", i32 3}
95 !13 = !{i32 1, !"wchar_size", i32 4}
96 !14 = !{!"clang version 11.0.0"}
97 !15 = distinct !DISubprogram(name: "funone", scope: !3, file: !3, line: 3, type: !16, scopeLine: 3, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !18)
98 !16 = !DISubroutineType(types: !17)
101 !19 = !DILocalVariable(name: "localone", scope: !15, file: !3, line: 4, type: !20)
102 !20 = !DIBasicType(name: "unsigned int", size: 32, encoding: DW_ATE_unsigned)
103 !21 = !DILocation(line: 5, column: 7, scope: !22)
104 !22 = distinct !DILexicalBlock(scope: !15, file: !3, line: 5, column: 7)
105 !27 = !DILocation(line: 5, column: 7, scope: !15)
106 !34 = distinct !DISubprogram(name: "funtwo", scope: !3, file: !3, line: 13, type: !35, scopeLine: 13, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !38)
107 !35 = !DISubroutineType(types: !36)
109 !37 = !DIBasicType(name: "short", size: 16, encoding: DW_ATE_signed)
111 !39 = !DILocalVariable(name: "localtwo", scope: !34, file: !3, line: 17, type: !40)
112 !40 = distinct !DICompositeType(tag: DW_TAG_union_type, scope: !34, file: !3, line: 14, size: 16, elements: !41)
114 !42 = !DIDerivedType(tag: DW_TAG_member, name: "b", scope: !40, file: !3, line: 15, baseType: !43, size: 16)
115 !43 = !DICompositeType(tag: DW_TAG_array_type, baseType: !44, size: 16, elements: !45)
116 !44 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char)
118 !46 = !DISubrange(count: 2)
119 !47 = !DIDerivedType(tag: DW_TAG_member, name: "c", scope: !40, file: !3, line: 16, baseType: !37, size: 16)
120 !48 = !DILocation(line: 20, column: 5, scope: !49)
121 !49 = distinct !DILexicalBlock(scope: !34, file: !3, line: 18, column: 3)
122 !51 = !DILocation(line: 22, column: 3, scope: !34)
129 successors: %bb.1(0x50000000), %bb.2(0x30000000)
131 CMP64mi8 $rip, 1, $noreg, @c, $noreg, 0, implicit-def $eflags, debug-location !21 :: (dereferenceable load (s64) from @c)
132 JCC_1 %bb.2, 4, implicit killed $eflags, debug-location !27
135 renamable $rax = MOV64rm $rip, 1, $noreg, @b, $noreg, debug-location !21 :: (dereferenceable load (s64) from @b)
136 RETQ $rax, debug-location !27
139 DBG_VALUE 0, $noreg, !19, !DIExpression(), debug-location !27
140 renamable $rax = MOV64rm $rip, 1, $noreg, @a, $noreg, debug-location !27 :: (dereferenceable load (s64) from @a)
141 RETQ $rax, debug-location !27
148 $eax = MOVZX32rm16 $noreg, 1, $noreg, 0, $noreg, debug-location !48 :: (load (s16) from `i16* null`, align 1)
149 DBG_VALUE $ax, $noreg, !39, !DIExpression(), debug-location !51
150 RETQ $ax, debug-location !51