1/// Test instrumentation can handle various linkages.
2// REQUIRES: lld-available
3
4// FIXME: Investigate and fix.
5// XFAIL: powerpc64-target-arch
6
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
10
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
14
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
35
36#include <stdio.h>
37
38void discarded0() {}
39__attribute__((weak)) void discarded1() {}
40
41void external() { puts(s: "external"); }
42__attribute__((weak)) void weak() { puts(s: "weak"); }
43static void internal() { puts(s: "internal"); }
44__attribute__((noinline)) inline void linkonce_odr() { puts(s: "linkonce_odr"); }
45
46int main() {
47 internal();
48 external();
49 weak();
50 linkonce_odr();
51}
52

source code of compiler-rt/test/profile/Linux/coverage-linkage.cpp