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 | |
38 | void discarded0() {} |
39 | __attribute__((weak)) void discarded1() {} |
40 | |
41 | void external() { puts(s: "external" ); } |
42 | __attribute__((weak)) void weak() { puts(s: "weak" ); } |
43 | static void internal() { puts(s: "internal" ); } |
44 | __attribute__((noinline)) inline void linkonce_odr() { puts(s: "linkonce_odr" ); } |
45 | |
46 | int main() { |
47 | internal(); |
48 | external(); |
49 | weak(); |
50 | linkonce_odr(); |
51 | } |
52 | |