Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / profile / Linux / coverage-linkage.cpp
blobae2d7db76467e7cc04ebaee8164c74b087dc76a9
1 /// Test instrumentation can handle various linkages.
2 // REQUIRES: lld-available
4 // FIXME: Investigate and fix.
5 // XFAIL: powerpc64-target-arch
7 // RUN: %clang_profgen -fcoverage-mapping %s -o %t
8 // RUN: env LLVM_PROFILE_FILE=%t.profraw %run %t
9 // RUN: llvm-profdata show %t.profraw --all-functions | FileCheck %s
11 // RUN: %clang_profgen -fcoverage-mapping -ffunction-sections -fuse-ld=lld -Wl,--gc-sections %s -o %t
12 // RUN: env LLVM_PROFILE_FILE=%t.profraw %run %t
13 // RUN: llvm-profdata show %t.profraw --all-functions | FileCheck %s
15 // CHECK: {{.*}}external{{.*}}:
16 // CHECK-NEXT: Hash:
17 // CHECK-NEXT: Counters: 1
18 // CHECK-NEXT: Function count: 1
19 // CHECK: {{.*}}weak{{.*}}:
20 // CHECK-NEXT: Hash:
21 // CHECK-NEXT: Counters: 1
22 // CHECK-NEXT: Function count: 1
23 // CHECK: main:
24 // CHECK-NEXT: Hash:
25 // CHECK-NEXT: Counters: 1
26 // CHECK-NEXT: Function count: 1
27 // CHECK: {{.*}}internal{{.*}}:
28 // CHECK-NEXT: Hash:
29 // CHECK-NEXT: Counters: 1
30 // CHECK-NEXT: Function count: 1
31 // CHECK: {{.*}}linkonce_odr{{.*}}:
32 // CHECK-NEXT: Hash:
33 // CHECK-NEXT: Counters: 1
34 // CHECK-NEXT: Function count: 1
36 #include <stdio.h>
38 void discarded0() {}
39 __attribute__((weak)) void discarded1() {}
41 void external() { puts("external"); }
42 __attribute__((weak)) void weak() { puts("weak"); }
43 static void internal() { puts("internal"); }
44 __attribute__((noinline)) inline void linkonce_odr() { puts("linkonce_odr"); }
46 int main() {
47 internal();
48 external();
49 weak();
50 linkonce_odr();