1 ; UNSUPPORTED: system-windows
2 ; REQUIRES: x86-registered-target
3 ; RUN: llc %s -o %t0.o -filetype=obj -experimental-debug-variable-locations=true
4 ; RUN: %llvm-locstats %t0.o | FileCheck %s --check-prefix=LOCSTATS
6 ; Test the llvm-locstats output.
8 ; LOCSTATS: (0%,10%) 0 0%
9 ; LOCSTATS: [10%,20%) 0 0%
10 ; LOCSTATS: [20%,30%) 1 11%
11 ; LOCSTATS: [30%,40%) 0 0%
12 ; LOCSTATS: [40%,50%) 0 0%
13 ; LOCSTATS: [50%,60%) 0 0%
14 ; LOCSTATS: [60%,70%) 0 0%
15 ; LOCSTATS: [70%,80%) 1 11%
16 ; LOCSTATS: [80%,90%) 2 22%
17 ; LOCSTATS: [90%,100%) 1 11%
18 ; LOCSTATS: 100% 4 44%
20 ; The source code of the test case:
21 ;extern int fn2 (int);
23 ;__attribute__((noinline))
43 ; local -= fn2 (local2);
47 ;__attribute__((noinline))
52 ; res += fn1 (&l, &k);
56 ; ModuleID = 'locstats.c'
57 source_filename = "locstats.c"
58 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
59 target triple = "x86_64-unknown-linux-gnu"
61 ; Function Attrs: noinline nounwind uwtable
62 define dso_local i32 @fn1(ptr nocapture readonly %0, ptr nocapture readonly %1) local_unnamed_addr !dbg !7 {
63 call void @llvm.dbg.value(metadata ptr %0, metadata !13, metadata !DIExpression()), !dbg !19
64 call void @llvm.dbg.value(metadata ptr %1, metadata !14, metadata !DIExpression()), !dbg !19
65 %3 = load i32, ptr %0, align 4, !dbg !20
66 call void @llvm.dbg.value(metadata i32 %3, metadata !15, metadata !DIExpression()), !dbg !19
67 %4 = load i32, ptr %1, align 4, !dbg !20
68 call void @llvm.dbg.value(metadata i32 %4, metadata !16, metadata !DIExpression()), !dbg !19
69 %5 = add nsw i32 %4, %3, !dbg !20
70 call void @llvm.dbg.value(metadata i32 %5, metadata !17, metadata !DIExpression()), !dbg !19
71 %6 = icmp sgt i32 %3, 1, !dbg !20
72 br i1 %6, label %7, label %13, !dbg !22
75 call void @llvm.dbg.value(metadata i32 %5, metadata !17, metadata !DIExpression(DW_OP_plus_uconst, 2, DW_OP_stack_value)), !dbg !19
76 %8 = add nsw i32 %5, 3, !dbg !23
77 call void @llvm.dbg.value(metadata i32 %8, metadata !17, metadata !DIExpression()), !dbg !19
78 %9 = icmp sgt i32 %8, 200, !dbg !25
79 br i1 %9, label %10, label %17, !dbg !27
82 %11 = tail call i32 @fn2(i32 %3), !dbg !27
83 %12 = sub nsw i32 %8, %11, !dbg !27
84 call void @llvm.dbg.value(metadata i32 %12, metadata !17, metadata !DIExpression()), !dbg !19
85 br label %17, !dbg !27
88 call void @llvm.dbg.value(metadata i32 %5, metadata !17, metadata !DIExpression(DW_OP_plus_uconst, 3, DW_OP_stack_value)), !dbg !19
89 %14 = add nsw i32 %5, 4, !dbg !28
90 call void @llvm.dbg.value(metadata i32 %14, metadata !17, metadata !DIExpression()), !dbg !19
91 %15 = tail call i32 @fn2(i32 %3), !dbg !30
92 %16 = add nsw i32 %14, %15, !dbg !30
93 call void @llvm.dbg.value(metadata i32 %16, metadata !17, metadata !DIExpression()), !dbg !19
96 17: ; preds = %7, %10, %13
97 %18 = phi i32 [ %12, %10 ], [ %8, %7 ], [ %16, %13 ], !dbg !31
98 call void @llvm.dbg.value(metadata i32 %18, metadata !17, metadata !DIExpression()), !dbg !19
99 %19 = icmp sgt i32 %4, 4, !dbg !32
100 %20 = select i1 %19, i32 %3, i32 0, !dbg !34
101 %21 = add nsw i32 %18, %20, !dbg !34
102 call void @llvm.dbg.value(metadata i32 %21, metadata !17, metadata !DIExpression()), !dbg !19
103 call void @llvm.dbg.value(metadata i32 7, metadata !18, metadata !DIExpression()), !dbg !19
104 %22 = tail call i32 @fn2(i32 7), !dbg !34
105 %23 = sub i32 %21, %22, !dbg !34
106 call void @llvm.dbg.value(metadata i32 %23, metadata !17, metadata !DIExpression()), !dbg !19
107 ret i32 %23, !dbg !34
110 declare dso_local i32 @fn2(i32) local_unnamed_addr
112 ; Function Attrs: noinline nounwind uwtable
113 define dso_local i32 @f() local_unnamed_addr !dbg !35 {
114 %1 = alloca i32, align 4
115 %2 = alloca i32, align 4
116 call void @llvm.dbg.value(metadata i32 0, metadata !41, metadata !DIExpression()), !dbg !42
117 call void @llvm.dbg.value(metadata ptr %1, metadata !39, metadata !DIExpression(DW_OP_deref)), !dbg !42
118 call void @llvm.dbg.value(metadata ptr %2, metadata !40, metadata !DIExpression(DW_OP_deref)), !dbg !42
119 %3 = call i32 @fn1(ptr nonnull %1, ptr nonnull %2), !dbg !42
120 call void @llvm.dbg.value(metadata i32 %3, metadata !41, metadata !DIExpression()), !dbg !42
124 ; Function Attrs: nounwind readnone speculatable willreturn
125 declare void @llvm.dbg.value(metadata, metadata, metadata)
128 !llvm.module.flags = !{!3, !4, !5}
131 !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 10.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, nameTableKind: None)
132 !1 = !DIFile(filename: "locstats.c", directory: "/dir")
134 !3 = !{i32 2, !"Dwarf Version", i32 4}
135 !4 = !{i32 2, !"Debug Info Version", i32 3}
136 !5 = !{i32 1, !"wchar_size", i32 4}
137 !6 = !{!"clang version 10.0.0"}
138 !7 = distinct !DISubprogram(name: "fn1", scope: !1, file: !1, line: 5, type: !8, scopeLine: 6, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !12)
139 !8 = !DISubroutineType(types: !9)
140 !9 = !{!10, !11, !11}
141 !10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
142 !11 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !10, size: 64)
143 !12 = !{!13, !14, !15, !16, !17, !18}
144 !13 = !DILocalVariable(name: "x", arg: 1, scope: !7, file: !1, line: 5, type: !11)
145 !14 = !DILocalVariable(name: "y", arg: 2, scope: !7, file: !1, line: 5, type: !11)
146 !15 = !DILocalVariable(name: "a", scope: !7, file: !1, line: 7, type: !10)
147 !16 = !DILocalVariable(name: "b", scope: !7, file: !1, line: 8, type: !10)
148 !17 = !DILocalVariable(name: "local", scope: !7, file: !1, line: 9, type: !10)
149 !18 = !DILocalVariable(name: "local2", scope: !7, file: !1, line: 22, type: !10)
150 !19 = !DILocation(line: 0, scope: !7)
151 !20 = !DILocation(line: 7, column: 11, scope: !7)
152 !21 = distinct !DILexicalBlock(scope: !7, file: !1, line: 10, column: 7)
153 !22 = !DILocation(line: 10, column: 7, scope: !7)
154 !23 = !DILocation(line: 12, column: 5, scope: !24)
155 !24 = distinct !DILexicalBlock(scope: !21, file: !1, line: 10, column: 14)
156 !25 = !DILocation(line: 13, column: 15, scope: !26)
157 !26 = distinct !DILexicalBlock(scope: !24, file: !1, line: 13, column: 9)
158 !27 = !DILocation(line: 13, column: 9, scope: !24)
159 !28 = !DILocation(line: 17, column: 5, scope: !26)
160 !29 = distinct !DILexicalBlock(scope: !21, file: !1, line: 15, column: 10)
161 !30 = !DILocation(line: 18, column: 14, scope: !29)
162 !31 = !DILocation(line: 0, scope: !21)
163 !32 = !DILocation(line: 20, column: 9, scope: !33)
164 !33 = distinct !DILexicalBlock(scope: !7, file: !1, line: 20, column: 7)
165 !34 = !DILocation(line: 20, column: 7, scope: !7)
166 !35 = distinct !DISubprogram(name: "f", scope: !1, file: !1, line: 28, type: !36, scopeLine: 29, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !38)
167 !36 = !DISubroutineType(types: !37)
169 !38 = !{!39, !40, !41}
170 !39 = !DILocalVariable(name: "l", scope: !35, file: !1, line: 30, type: !10)
171 !40 = !DILocalVariable(name: "k", scope: !35, file: !1, line: 30, type: !10)
172 !41 = !DILocalVariable(name: "res", scope: !35, file: !1, line: 31, type: !10)
173 !42 = !DILocation(line: 30, column: 3, scope: !35)