1 ; RUN: llc -O0 %s -o - -filetype=obj \
2 ; RUN: | llvm-dwarfdump -statistics - | FileCheck %s
5 ; int GlobalConst = 42;
9 ; static const int constant = 24;
12 ; int __attribute__((always_inline)) square(int i) { return i * i; }
14 ; int squared = square(i);
18 ; GlobalConst,Global,s,s.constant,square::i,cube::i,cube::squared
19 ; CHECK: "unique source variables":7
21 ; CHECK: "source variables":8
23 ; CHECK: "variables with location":7
24 ; CHECK: "scope bytes total":[[BYTES:[0-9]+]]
25 ; Because of the dbg.value in the middle of the function, the pc range coverage
27 ; CHECK-NOT: "scope bytes covered":0
28 ; CHECK-NOT "scope bytes covered":[[BYTES]]
29 ; CHECK: "scope bytes covered":
30 ; CHECK: "total function size":[[FUNCSIZE:[0-9]+]]
31 ; CHECK: "total inlined function size":[[INLINESIZE:[0-9]+]]
34 ; ModuleID = '/tmp/quality.cpp'
35 source_filename = "/tmp/quality.cpp"
36 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
37 target triple = "x86_64-apple-macosx10.12.0"
39 %struct.S = type { i8 }
41 @GlobalConst = global i32 42, align 4, !dbg !0
42 @Global = global i32 0, align 4, !dbg !6
43 @s = global %struct.S zeroinitializer, align 1, !dbg !9
45 ; Function Attrs: alwaysinline nounwind ssp uwtable
46 define i32 @_Z6squarei(i32 %i) #0 !dbg !20 {
48 %i.addr = alloca i32, align 4
49 store i32 %i, i32* %i.addr, align 4
50 ; Modified to loose debug info for i here.
51 call void @llvm.dbg.declare(metadata i32* undef, metadata !23, metadata !24), !dbg !25
52 %0 = load i32, i32* %i.addr, align 4, !dbg !26
53 %1 = load i32, i32* %i.addr, align 4, !dbg !27
54 %mul = mul nsw i32 %0, %1, !dbg !28
55 ret i32 %mul, !dbg !29
58 ; Function Attrs: nounwind readnone speculatable
59 declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
60 declare void @llvm.dbg.value(metadata, metadata, metadata) #1
62 ; Function Attrs: noinline nounwind optnone ssp uwtable
63 define i32 @_Z4cubei(i32 %i) #2 !dbg !30 {
65 %i.addr.i = alloca i32, align 4
66 call void @llvm.dbg.declare(metadata i32* %i.addr.i, metadata !23, metadata !24), !dbg !31
67 %i.addr = alloca i32, align 4
68 %squared = alloca i32, align 4
69 store i32 %i, i32* %i.addr, align 4
70 call void @llvm.dbg.declare(metadata i32* %i.addr, metadata !33, metadata !24), !dbg !34
71 %0 = load i32, i32* %i.addr, align 4, !dbg !37
72 store i32 %0, i32* %i.addr.i, align 4
73 %1 = load i32, i32* %i.addr.i, align 4, !dbg !38
74 %2 = load i32, i32* %i.addr.i, align 4, !dbg !39
75 %mul.i = mul nsw i32 %1, %2, !dbg !40
76 ; Modified to cover only about 50% of the lexical scope.
77 call void @llvm.dbg.value(metadata i32 %mul.i, metadata !35, metadata !24), !dbg !36
78 store i32 %mul.i, i32* %squared, align 4, !dbg !36
79 %3 = load i32, i32* %squared, align 4, !dbg !41
80 call void @llvm.dbg.value(metadata i32 %3, metadata !35, metadata !24), !dbg !36
81 %4 = load i32, i32* %i.addr, align 4, !dbg !42
82 %mul = mul nsw i32 %3, %4, !dbg !43
83 ret i32 %mul, !dbg !44
86 attributes #0 = { alwaysinline nounwind ssp uwtable }
87 attributes #1 = { nounwind readnone speculatable }
88 attributes #2 = { noinline nounwind optnone ssp uwtable }
91 !llvm.module.flags = !{!15, !16, !17, !18}
94 !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
95 !1 = distinct !DIGlobalVariable(name: "GlobalConst", scope: !2, file: !3, line: 1, type: !8, isLocal: false, isDefinition: true)
96 !2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !3, producer: "clang version 6.0.0 (trunk 310529) (llvm/trunk 310534)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5)
97 !3 = !DIFile(filename: "/tmp/quality.cpp", directory: "/Volumes/Data/llvm")
100 !6 = !DIGlobalVariableExpression(var: !7, expr: !DIExpression())
101 !7 = distinct !DIGlobalVariable(name: "Global", scope: !2, file: !3, line: 2, type: !8, isLocal: false, isDefinition: true)
102 !8 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
103 !9 = !DIGlobalVariableExpression(var: !10, expr: !DIExpression())
104 !10 = distinct !DIGlobalVariable(name: "s", scope: !2, file: !3, line: 6, type: !11, isLocal: false, isDefinition: true)
105 !11 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "S", file: !3, line: 4, size: 8, elements: !12, identifier: "_ZTS1S")
107 !13 = !DIDerivedType(tag: DW_TAG_member, name: "constant", scope: !11, file: !3, line: 5, baseType: !14, flags: DIFlagStaticMember, extraData: i32 24)
108 !14 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !8)
109 !15 = !{i32 2, !"Dwarf Version", i32 4}
110 !16 = !{i32 2, !"Debug Info Version", i32 3}
111 !17 = !{i32 1, !"wchar_size", i32 4}
112 !18 = !{i32 7, !"PIC Level", i32 2}
113 !19 = !{!"clang version 6.0.0 (trunk 310529) (llvm/trunk 310534)"}
114 !20 = distinct !DISubprogram(name: "square", linkageName: "_Z6squarei", scope: !3, file: !3, line: 8, type: !21, isLocal: false, isDefinition: true, scopeLine: 8, flags: DIFlagPrototyped, isOptimized: false, unit: !2, retainedNodes: !4)
115 !21 = !DISubroutineType(types: !22)
117 !23 = !DILocalVariable(name: "i", arg: 1, scope: !20, file: !3, line: 8, type: !8)
118 !24 = !DIExpression()
119 !25 = !DILocation(line: 8, column: 47, scope: !20)
120 !26 = !DILocation(line: 8, column: 59, scope: !20)
121 !27 = !DILocation(line: 8, column: 63, scope: !20)
122 !28 = !DILocation(line: 8, column: 61, scope: !20)
123 !29 = !DILocation(line: 8, column: 52, scope: !20)
124 !30 = distinct !DISubprogram(name: "cube", linkageName: "_Z4cubei", scope: !3, file: !3, line: 9, type: !21, isLocal: false, isDefinition: true, scopeLine: 9, flags: DIFlagPrototyped, isOptimized: false, unit: !2, retainedNodes: !4)
125 !31 = !DILocation(line: 8, column: 47, scope: !20, inlinedAt: !32)
126 !32 = distinct !DILocation(line: 10, column: 17, scope: !30)
127 !33 = !DILocalVariable(name: "i", arg: 1, scope: !30, file: !3, line: 9, type: !8)
128 !34 = !DILocation(line: 9, column: 14, scope: !30)
129 !35 = !DILocalVariable(name: "squared", scope: !30, file: !3, line: 10, type: !8)
130 !36 = !DILocation(line: 10, column: 7, scope: !30)
131 !37 = !DILocation(line: 10, column: 24, scope: !30)
132 !38 = !DILocation(line: 8, column: 59, scope: !20, inlinedAt: !32)
133 !39 = !DILocation(line: 8, column: 63, scope: !20, inlinedAt: !32)
134 !40 = !DILocation(line: 8, column: 61, scope: !20, inlinedAt: !32)
135 !41 = !DILocation(line: 11, column: 10, scope: !30)
136 !42 = !DILocation(line: 11, column: 18, scope: !30)
137 !43 = !DILocation(line: 11, column: 17, scope: !30)
138 !44 = !DILocation(line: 11, column: 3, scope: !30)