Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / profile / Darwin / coverage-linkage.cpp
blob062717b47bfac639995bd753547832dc8e026310
1 /// Test instrumentation can handle various linkages.
2 // RUN: %clang_profgen -fcoverage-mapping %s -o %t
3 // RUN: env LLVM_PROFILE_FILE=%t.profraw %run %t
4 // RUN: llvm-profdata show %t.profraw --all-functions | FileCheck %s
6 // RUN: %clang_profgen -fcoverage-mapping -Wl,-dead_strip %s -o %t
7 // RUN: env LLVM_PROFILE_FILE=%t.profraw %run %t
8 // RUN: llvm-profdata show %t.profraw --all-functions | FileCheck %s
10 // CHECK: {{.*}}external{{.*}}:
11 // CHECK-NEXT: Hash:
12 // CHECK-NEXT: Counters: 1
13 // CHECK-NEXT: Function count: 1
14 // CHECK: {{.*}}weak{{.*}}:
15 // CHECK-NEXT: Hash:
16 // CHECK-NEXT: Counters: 1
17 // CHECK-NEXT: Function count: 1
18 // CHECK: main:
19 // CHECK-NEXT: Hash:
20 // CHECK-NEXT: Counters: 1
21 // CHECK-NEXT: Function count: 1
22 // CHECK: {{.*}}internal{{.*}}:
23 // CHECK-NEXT: Hash:
24 // CHECK-NEXT: Counters: 1
25 // CHECK-NEXT: Function count: 1
26 // CHECK: {{.*}}linkonce_odr{{.*}}:
27 // CHECK-NEXT: Hash:
28 // CHECK-NEXT: Counters: 1
29 // CHECK-NEXT: Function count: 1
31 #include <stdio.h>
33 void discarded0() {}
34 __attribute__((weak)) void discarded1() {}
36 void external() { puts("external"); }
37 __attribute__((weak)) void weak() { puts("weak"); }
38 static void internal() { puts("internal"); }
39 __attribute__((noinline)) inline void linkonce_odr() { puts("linkonce_odr"); }
41 int main() {
42 internal();
43 external();
44 weak();
45 linkonce_odr();