1 | // REQUIRES: linux, lld-available |
2 | |
3 | // FIXME: Investigate and fix. |
4 | // XFAIL: powerpc64-target-arch |
5 | |
6 | // RUN: rm -rf %t.profraw |
7 | // RUN: %clang_profgen=%t.profraw -fuse-ld=lld -fcoverage-mapping -mllvm -enable-name-compression=false -DCODE=1 -ffunction-sections -fdata-sections -Wl,--gc-sections -o %t %s |
8 | // RUN: %run %t |
9 | // RUN: llvm-profdata merge -o %t.profdata %t.profraw |
10 | // RUN: llvm-profdata show --all-functions %t.profdata | FileCheck %s -check-prefix=PROF |
11 | // RUN: llvm-cov show %t -instr-profile %t.profdata | FileCheck %s -check-prefix=COV |
12 | // RUN: llvm-nm %t | FileCheck %s -check-prefix=NM |
13 | // RUN: llvm-readelf -x __llvm_prf_names %t | FileCheck %s -check-prefix=PRF_NAMES |
14 | // RUN: llvm-size -A %t | FileCheck %s -check-prefix=PRF_CNTS |
15 | |
16 | // RUN: rm -rf %t.lto.profraw |
17 | // RUN: %clang_lto_profgen=%t.lto.profraw -fuse-ld=lld -fcoverage-mapping -mllvm -enable-name-compression=false -DCODE=1 -ffunction-sections -fdata-sections -Wl,--gc-sections -flto -o %t.lto %s |
18 | // RUN: %run %t.lto |
19 | // RUN: llvm-profdata merge -o %t.lto.profdata %t.lto.profraw |
20 | // RUN: llvm-profdata show --all-functions %t.lto.profdata | FileCheck %s -check-prefix=PROF |
21 | // RUN: llvm-cov show %t.lto -instr-profile %t.lto.profdata | FileCheck %s -check-prefix=COV |
22 | // RUN: llvm-nm %t.lto | FileCheck %s -check-prefix=NM |
23 | // RUN: llvm-readelf -x __llvm_prf_names %t.lto | FileCheck %s -check-prefix=PRF_NAMES |
24 | // RUN: llvm-size -A %t.lto | FileCheck %s -check-prefix=PRF_CNTS |
25 | |
26 | // Note: We expect foo() and some of the profiling data associated with it to |
27 | // be garbage collected. |
28 | |
29 | // Note: When there is no code in a program, we expect to see the exact same |
30 | // set of external functions provided by the profile runtime. |
31 | |
32 | // Note: We also check the IR instrumentation and expect foo() to be garbage |
33 | // collected as well. |
34 | |
35 | // RUN: rm -rf %t.pgo.profraw |
36 | // RUN: %clang_pgogen=%t.pgo.profraw -fuse-ld=lld -DCODE=1 -ffunction-sections -fdata-sections -Wl,--gc-sections -o %t.pgo %s |
37 | // RUN: %run %t.pgo |
38 | // RUN: llvm-profdata merge -o %t.pgo.profdata %t.pgo.profraw |
39 | // RUN: llvm-profdata show --all-functions %t.pgo.profdata | FileCheck %s -check-prefix=PGO |
40 | // RUN: llvm-nm %t.pgo | FileCheck %s -check-prefix=NM |
41 | |
42 | #ifdef CODE |
43 | |
44 | // COV: [[@LINE+1]]{{ *}}|{{ *}}0|void foo() |
45 | void foo() {} |
46 | |
47 | // COV: [[@LINE+1]]{{ *}}|{{ *}}1|int main |
48 | int main() { return 0; } |
49 | |
50 | #endif // CODE |
51 | |
52 | // NM-NOT: foo |
53 | |
54 | // PROF: Counters: |
55 | // PROF-NEXT: main: |
56 | // PROF-NEXT: Hash: |
57 | // PROF-NEXT: Counters: 1 |
58 | // PROF-NEXT: Function count: 1 |
59 | // PROF-NEXT: Instrumentation level: Front-end |
60 | // PROF-NEXT: Functions shown: 1 |
61 | // PROF-NEXT: Total functions: 1 |
62 | // PROF-NEXT: Maximum function count: |
63 | // PROF-NEXT: Maximum internal block count: |
64 | |
65 | // Note: We don't expect the names of garbage collected functions to disappear |
66 | // from __llvm_prf_names, because collectPGOFuncNameStrings() glues the names |
67 | // together. |
68 | |
69 | // PRF_NAMES: Hex dump of section '__llvm_prf_names': |
70 | // PRF_NAMES-NEXT: {{.*}} 0800666f 6f016d61 696e{{.*$}} |
71 | // | | f o o # m a i n |
72 | // | |___________| |
73 | // | | |
74 | // UncompressedLen = 8 | |
75 | // | |
76 | // CompressedLen = 0 |
77 | |
78 | // Note: We expect the profile counters for garbage collected functions to also |
79 | // be garbage collected. |
80 | |
81 | // PRF_CNTS: __llvm_prf_cnts 8 |
82 | |
83 | // PGO: Counters: |
84 | // PGO-NEXT: main: |
85 | // PGO-NEXT: Hash: |
86 | // PGO-NEXT: Counters: 1 |
87 | // PGO-NEXT: Instrumentation level: IR |
88 | // PGO-NEXT: Functions shown: 1 |
89 | // PGO-NEXT: Total functions: 1 |
90 | // PGO-NEXT: Maximum function count: |
91 | // PGO-NEXT: Maximum internal block count: |
92 | |