Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / profile / instrprof-merging.cpp
blob6212feb19c2a838a4b39c8f31a34d61b2fc8f748
1 // UNSUPPORTED: target={{.*windows.*}}
2 // 1) Compile shared code into different object files and into an executable.
4 // RUN: %clangxx_profgen -std=c++14 -fcoverage-mapping %s -c -o %t.v1.o \
5 // RUN: -D_VERSION_1
6 // RUN: %clangxx_profgen -std=c++14 -fcoverage-mapping %s -c -o %t.v2.o \
7 // RUN: -D_VERSION_2
8 // RUN: %clangxx_profgen -std=c++14 -fcoverage-mapping %t.v1.o %t.v2.o \
9 // RUN: -o %t.exe
11 // 2) Collect profile data.
13 // RUN: env LLVM_PROFILE_FILE=%t.profraw %run %t.exe
14 // RUN: llvm-profdata merge %t.profraw -o %t.profdata
16 // 3) Generate coverage reports from the different object files and the exe.
18 // RUN: llvm-cov show %t.v1.o -instr-profile=%t.profdata | FileCheck %s -check-prefixes=V1,V1-ONLY
19 // RUN: llvm-cov show %t.v2.o -instr-profile=%t.profdata | FileCheck %s -check-prefixes=V2,V2-ONLY
20 // RUN: llvm-cov show %t.v1.o -object %t.v2.o -instr-profile=%t.profdata | FileCheck %s -check-prefixes=V1,V2
21 // RUN: llvm-cov show %t.exe -instr-profile=%t.profdata | FileCheck %s -check-prefixes=V1,V2
23 // 4) Verify that coverage reporting on the aggregate coverage mapping shows
24 // hits for all code. (We used to arbitrarily pick a mapping from one binary
25 // and prefer it over others.) When only limited coverage information is
26 // available (just from one binary), don't try to guess any region counts.
28 struct A {
29 A() {} // V1: [[@LINE]]{{ *}}|{{ *}}1
30 // V1-ONLY: [[@LINE+1]]{{ *}}|{{ *}}|
31 A(int) {} // V2-ONLY: [[@LINE-2]]{{ *}}|{{ *}}|
32 // V2: [[@LINE-1]]{{ *}}|{{ *}}1
35 #ifdef _VERSION_1
37 void foo();
39 void bar() {
40 A x; // V1: [[@LINE]]{{ *}}|{{ *}}1
43 int main() {
44 foo(); // V1: [[@LINE]]{{ *}}|{{ *}}1
45 bar();
46 return 0;
49 #endif // _VERSION_1
51 #ifdef _VERSION_2
53 void foo() {
54 A x{0}; // V2: [[@LINE]]{{ *}}|{{ *}}1
57 #endif // _VERSION_2