1// XFAIL: target={{.*}}-aix{{.*}}
2// Test that the instrumentation puts the right linkage on the profile data for
3// inline functions.
4// RUN: %clang_profgen -g -fcoverage-mapping -c -o %t1.o %s -DOBJECT_1
5// RUN: %clang_profgen -g -fcoverage-mapping -c -o %t2.o %s
6// RUN: %clang_profgen -g -fcoverage-mapping %t1.o %t2.o -o %t.exe
7// RUN: env LLVM_PROFILE_FILE=%t.profraw %run %t.exe
8// RUN: llvm-profdata show %t.profraw -all-functions | FileCheck %s
9
10// Again, with optimizations and inlining. This tests that we use comdats
11// correctly.
12// RUN: %clang_profgen -O2 -g -fcoverage-mapping -c -o %t1.o %s -DOBJECT_1
13// RUN: %clang_profgen -O2 -g -fcoverage-mapping -c -o %t2.o %s
14// RUN: %clang_profgen -g -fcoverage-mapping %t1.o %t2.o -o %t.exe
15// RUN: env LLVM_PROFILE_FILE=%t.profraw %run %t.exe
16// RUN: llvm-profdata show %t.profraw -all-functions | FileCheck %s
17
18// CHECK: {{.*}}foo{{.*}}:
19// CHECK-NEXT: Hash:
20// CHECK-NEXT: Counters: 1
21// CHECK-NEXT: Function count: 1
22// CHECK: {{.*}}inline_wrapper{{.*}}:
23// CHECK-NEXT: Hash:
24// CHECK-NEXT: Counters: 1
25// CHECK-NEXT: Function count: 2
26// CHECK: main:
27// CHECK-NEXT: Hash:
28// CHECK-NEXT: Counters: 1
29// CHECK-NEXT: Function count: 1
30
31extern "C" int puts(const char *);
32
33inline void inline_wrapper(const char *msg) {
34 puts(msg);
35}
36
37void foo();
38
39#ifdef OBJECT_1
40void foo() {
41 inline_wrapper("foo");
42}
43#else
44int main() {
45 inline_wrapper(msg: "main");
46 foo();
47}
48#endif
49

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