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
5
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
9
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
30
31 #include <stdio.h>
32
discarded0()33 void discarded0() {}
discarded1()34 __attribute__((weak)) void discarded1() {}
35
external()36 void external() { puts("external"); }
weak()37 __attribute__((weak)) void weak() { puts("weak"); }
internal()38 static void internal() { puts("internal"); }
linkonce_odr()39 __attribute__((noinline)) inline void linkonce_odr() { puts("linkonce_odr"); }
40
main()41 int main() {
42 internal();
43 external();
44 weak();
45 linkonce_odr();
46 }
47