Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / profile / instrprof-darwin-dead-strip.c
blob79182938b10aabb952564e31c7e71632e7695022
1 // REQUIRES: osx-ld64-live_support
2 // REQUIRES: lto
4 // RUN: %clang_profgen=%t.profraw -fcoverage-mapping -mllvm -enable-name-compression=false -DCODE=1 -Wl,-dead_strip -o %t %s
5 // RUN: %run %t
6 // RUN: llvm-profdata merge -o %t.profdata %t.profraw
7 // RUN: llvm-profdata show --all-functions %t.profdata | FileCheck %s -check-prefix=PROF
8 // RUN: llvm-cov show %t -instr-profile %t.profdata | FileCheck %s -check-prefix=COV
9 // RUN: nm %t | FileCheck %s -check-prefix=NM
10 // RUN: otool -V -s __DATA __llvm_prf_names %t | FileCheck %s -check-prefix=PRF_NAMES
11 // RUN: otool -V -s __DATA __llvm_prf_cnts %t | FileCheck %s -check-prefix=PRF_CNTS
13 // RUN: %clang_lto_profgen=%t.lto.profraw -fcoverage-mapping -mllvm -enable-name-compression=false -DCODE=1 -Wl,-dead_strip -flto -o %t.lto %s
14 // RUN: %run %t.lto
15 // RUN: llvm-profdata merge -o %t.lto.profdata %t.lto.profraw
16 // RUN: llvm-profdata show --all-functions %t.lto.profdata | FileCheck %s -check-prefix=PROF
17 // RUN: llvm-cov show %t.lto -instr-profile %t.lto.profdata | FileCheck %s -check-prefix=COV
18 // RUN: nm %t.lto | FileCheck %s -check-prefix=NM
19 // RUN: otool -V -s __DATA __llvm_prf_names %t.lto | FileCheck %s -check-prefix=PRF_NAMES
20 // RUN: otool -V -s __DATA __llvm_prf_cnts %t.lto | FileCheck %s -check-prefix=PRF_CNTS
22 // Note: We expect foo() and some of the profiling data associated with it to
23 // be dead-stripped.
25 // Note: When there is no code in a program, we expect to see the exact same
26 // set of external functions provided by the profile runtime.
28 // RUN: %clang_profgen -fcoverage-mapping -Wl,-dead_strip -dynamiclib -o %t.nocode.dylib %s
29 // RUN: nm -jgU %t.nocode.dylib > %t.nocode.syms
30 // RUN: nm -jgU %t | sed -e '/_\{1,\}main/d' -e '/_\{1,\}mh_execute_header/d' > %t.code.syms
31 // RUN: diff %t.nocode.syms %t.code.syms
33 #ifdef CODE
35 // COV: [[@LINE+1]]{{ *}}|{{ *}}0|void foo()
36 void foo() {}
38 // COV: [[@LINE+1]]{{ *}}|{{ *}}1|int main
39 int main() { return 0; }
41 #endif // CODE
43 // NM-NOT: foo
45 // PROF: Counters:
46 // PROF-NEXT: main:
47 // PROF-NEXT: Hash:
48 // PROF-NEXT: Counters: 1
49 // PROF-NEXT: Function count: 1
50 // PROF-NEXT: Instrumentation level: Front-end
51 // PROF-NEXT: Functions shown: 1
52 // PROF-NEXT: Total functions: 1
53 // PROF-NEXT: Maximum function count: 1
54 // PROF-NEXT: Maximum internal block count: 0
56 // Note: We don't expect the names of dead-stripped functions to disappear from
57 // __llvm_prf_names, because collectPGOFuncNameStrings() glues the names
58 // together.
60 // PRF_NAMES: Contents of (__DATA,__llvm_prf_names) section
61 // PRF_NAMES-NEXT: {{.*}} 08 00 66 6f 6f 01 6d 61 69 6e
62 // | | f o o # m a i n
63 // | |___________|
64 // | |
65 // UncompressedLen = 8 |
66 // |
67 // CompressedLen = 0
69 // Note: We expect the profile counters for dead-stripped functions to also be
70 // dead-stripped.
72 // PRF_CNTS: Contents of (__DATA,__llvm_prf_cnts) section
73 // PRF_CNTS-NEXT: {{.*}} 00 00 00 00 00 00 00 00