1 /// Test instrumentation can handle various linkages.
2 // REQUIRES: lld-available
3 // RUN: %clang_profgen -fcoverage-mapping %s -o %t
4 // RUN: env LLVM_PROFILE_FILE=%t.profraw %run %t
5 // RUN: llvm-profdata show %t.profraw --all-functions | FileCheck %s
6
7 // RUN: %clang_profgen -fcoverage-mapping -ffunction-sections -fuse-ld=lld -Wl,--gc-sections %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 // CHECK: {{.*}}external{{.*}}:
12 // CHECK-NEXT: Hash:
13 // CHECK-NEXT: Counters: 1
14 // CHECK-NEXT: Function count: 1
15 // CHECK: {{.*}}weak{{.*}}:
16 // CHECK-NEXT: Hash:
17 // CHECK-NEXT: Counters: 1
18 // CHECK-NEXT: Function count: 1
19 // CHECK: main:
20 // CHECK-NEXT: Hash:
21 // CHECK-NEXT: Counters: 1
22 // CHECK-NEXT: Function count: 1
23 // CHECK: {{.*}}internal{{.*}}:
24 // CHECK-NEXT: Hash:
25 // CHECK-NEXT: Counters: 1
26 // CHECK-NEXT: Function count: 1
27 // CHECK: {{.*}}linkonce_odr{{.*}}:
28 // CHECK-NEXT: Hash:
29 // CHECK-NEXT: Counters: 1
30 // CHECK-NEXT: Function count: 1
31
32 #include <stdio.h>
33
discarded0()34 void discarded0() {}
discarded1()35 __attribute__((weak)) void discarded1() {}
36
external()37 void external() { puts("external"); }
weak()38 __attribute__((weak)) void weak() { puts("weak"); }
internal()39 static void internal() { puts("internal"); }
linkonce_odr()40 __attribute__((noinline)) inline void linkonce_odr() { puts("linkonce_odr"); }
41
main()42 int main() {
43 internal();
44 external();
45 weak();
46 linkonce_odr();
47 }
48