1# Test of the llmv-dwarfdump --statistics with split dwarf (dwo files)
2# (version >= 3).
3#
4# Create a directory in which to put all files, so .o file can find .dwo file.
5RUN: rm -rf %t && mkdir -p %t
6RUN: cp -f %S/Inputs/statistics-fib.split-dwarf.s %t/.
7RUN: cd %t
8RUN: llvm-mc -triple x86_64-unknown-linux-gnu statistics-fib.split-dwarf.s -filetype=obj -split-dwarf-file statistics-fib.split-dwarf.dwo -o statistics-fib.split-dwarf.o
9RUN: llvm-dwarfdump --statistics statistics-fib.split-dwarf.o | FileCheck %s
10
11# Source program - A version of Fibonacci
12# Compilation options:  -gsplit-dwarf -O3 -c -S
13#
14# int
15# real_fib (int x, int answers[11])
16# {
17#   int result;
18#
19#   if ((answers)[x] != -1)
20#     return (answers)[x];
21#
22#   result = real_fib(x-1, answers) + real_fib(x-2, answers);
23#   (answers)[x] = result;
24#
25#   return result;
26# }
27#
28# int
29# fib (int x)
30# {
31#   int answers[11];
32#   int i;
33#
34#   if (x > 10)
35#     return -1;
36#
37#   for (i = 0; i < 11; i++)
38#     answers[i] = -1;
39#
40#   answers[0] = 0;
41#   answers[1] = 1;
42#   answers[2] = 1;
43#
44#   return real_fib(x, answers);
45# }
46#
47# int main (int argc, char **argv)
48# {
49#   int result;
50#
51#   result = fib(3);
52#   printf ("fibonacci(3) = %d\n", result);
53#   result = fib(4);
54#   printf ("fibonacci(4) = %d\n", result);
55#   result = fib(5);
56#   printf ("fibonacci(5) = %d\n", result);
57#   result = fib(6);
58#   printf ("fibonacci(6) = %d\n", result);
59#   result = fib(7);
60#   printf ("fibonacci(7) = %d\n", result);
61#   result = fib(8);
62#   printf ("fibonacci(8) = %d\n", result);
63#   result = fib(9);
64#   printf ("fibonacci(9) = %d\n", result);
65#   result = fib(10);
66#   printf ("fibonacci(10) = %d\n", result);
67#
68#   return 0;
69# }
70#
71
72CHECK:      "version": 6,
73CHECK:      "#functions": 3,
74CHECK:      "#functions with location": 3,
75CHECK:      "#inlined functions": 7,
76CHECK:      "#inlined functions with abstract origins": 7,
77CHECK:      "#unique source variables": 9,
78CHECK:      "#source variables": 30,
79
80# Ideally the value below would be 33 but currently it's not.
81CHECK:      "#source variables with location": 22,
82CHECK:      "#call site entries": 7,
83CHECK:      "sum_all_variables(#bytes in parent scope)": 2817,
84CHECK:      "sum_all_variables(#bytes in parent scope covered by DW_AT_location)": 1160,
85CHECK:      "#bytes within functions": 594,
86CHECK:      "#bytes within inlined functions": 345,
87CHECK:      "#params": 12,
88CHECK-NEXT: "#params with source location": 12,
89CHECK-NEXT: "#params with type": 12,
90CHECK-NEXT: "#params with binary location": 12,
91CHECK-NEXT: "#local vars": 18,
92CHECK-NEXT: "#local vars with source location": 18,
93CHECK-NEXT: "#local vars with type": 18,
94
95# Ideally the value below would be 18, but currently it's not.
96CHECK:      "#local vars with binary location": 10,
97