1effb87dfSFangrui Song /// Test instrumentation can handle various linkages. 2effb87dfSFangrui Song // RUN: %clang_profgen -fcoverage-mapping %s -o %t 3effb87dfSFangrui Song // RUN: env LLVM_PROFILE_FILE=%t.profraw %run %t 4effb87dfSFangrui Song // RUN: llvm-profdata show %t.profraw --all-functions | FileCheck %s 5effb87dfSFangrui Song 6*60942004SMartin Storsjö // RUN: %clang_profgen -fcoverage-mapping -ffunction-sections %if target={{.*-windows-msvc.*}} %{ -Wl,-opt:ref %} %s -o %t 7effb87dfSFangrui Song // RUN: env LLVM_PROFILE_FILE=%t.profraw %run %t 8effb87dfSFangrui Song // RUN: llvm-profdata show %t.profraw --all-functions | FileCheck %s 9effb87dfSFangrui Song 10effb87dfSFangrui Song // CHECK: {{.*}}external{{.*}}: 11effb87dfSFangrui Song // CHECK-NEXT: Hash: 12effb87dfSFangrui Song // CHECK-NEXT: Counters: 1 13effb87dfSFangrui Song // CHECK-NEXT: Function count: 1 14effb87dfSFangrui Song // CHECK: {{.*}}weak{{.*}}: 15effb87dfSFangrui Song // CHECK-NEXT: Hash: 16effb87dfSFangrui Song // CHECK-NEXT: Counters: 1 17effb87dfSFangrui Song // CHECK-NEXT: Function count: 1 18effb87dfSFangrui Song // CHECK: main: 19effb87dfSFangrui Song // CHECK-NEXT: Hash: 20effb87dfSFangrui Song // CHECK-NEXT: Counters: 1 21effb87dfSFangrui Song // CHECK-NEXT: Function count: 1 22effb87dfSFangrui Song // CHECK: {{.*}}internal{{.*}}: 23effb87dfSFangrui Song // CHECK-NEXT: Hash: 24effb87dfSFangrui Song // CHECK-NEXT: Counters: 1 25effb87dfSFangrui Song // CHECK-NEXT: Function count: 1 26effb87dfSFangrui Song // CHECK: {{.*}}linkonce_odr{{.*}}: 27effb87dfSFangrui Song // CHECK-NEXT: Hash: 28effb87dfSFangrui Song // CHECK-NEXT: Counters: 1 29effb87dfSFangrui Song // CHECK-NEXT: Function count: 1 30effb87dfSFangrui Song 31effb87dfSFangrui Song #include <stdio.h> 32effb87dfSFangrui Song discarded0()33effb87dfSFangrui Songvoid discarded0() {} discarded1()34effb87dfSFangrui Song__attribute__((weak)) void discarded1() {} 35effb87dfSFangrui Song external()36effb87dfSFangrui Songvoid external() { puts("external"); } weak()37effb87dfSFangrui Song__attribute__((weak)) void weak() { puts("weak"); } internal()38effb87dfSFangrui Songstatic void internal() { puts("internal"); } linkonce_odr()39effb87dfSFangrui Song__attribute__((noinline)) inline void linkonce_odr() { puts("linkonce_odr"); } 40effb87dfSFangrui Song main()41effb87dfSFangrui Songint main() { 42effb87dfSFangrui Song internal(); 43effb87dfSFangrui Song external(); 44effb87dfSFangrui Song weak(); 45effb87dfSFangrui Song linkonce_odr(); 46effb87dfSFangrui Song } 47