36 lines · cpp
1// RUN: %clang_profgen -fuse-ld=gold -O2 -fdata-sections -ffunction-sections -fcoverage-mapping -Wl,--gc-sections -o %t %s2// RUN: env LLVM_PROFILE_FILE=%t.profraw %run %t3// RUN: llvm-profdata merge -o %t.profdata %t.profraw4// RUN: llvm-cov show %t -instr-profile %t.profdata 2>&1 | FileCheck %s5// BFD linker older than 2.26 has a bug that per-func profile data will be wrongly garbage collected when GC is turned on. We only do end-to-end test here without GC:6// RUN: %clang_profgen -O2 -fcoverage-mapping -o %t.2 %s7// RUN: env LLVM_PROFILE_FILE=%t.2.profraw %run %t.28// RUN: llvm-profdata merge -o %t.2.profdata %t.2.profraw9// RUN: llvm-cov show %t.2 -instr-profile %t.2.profdata 2>&1 | FileCheck %s10// Check covmap is not garbage collected when GC is turned on with BFD linker. Due to the bug mentioned above, we can only11// do the check with objdump:12// RUN: %clang_profgen -O2 -fcoverage-mapping -Wl,--gc-sections -o %t.3 %s13// RUN: llvm-objdump -h %t.3 | FileCheck --check-prefix COVMAP %s14// Check PIE option15// RUN: %clang_profgen -fuse-ld=gold -O2 -fdata-sections -ffunction-sections -fPIE -pie -fcoverage-mapping -Wl,--gc-sections -o %t.pie %s16// RUN: env LLVM_PROFILE_FILE=%t.pie.profraw %run %t.pie17// RUN: llvm-profdata merge -o %t.pie.profdata %t.pie.profraw18// RUN: llvm-cov show %t.pie -instr-profile %t.pie.profdata 2>&1 | FileCheck %s19 20void foo(bool cond) { // CHECK: [[@LINE]]| 1|void foo(21 if (cond) { // CHECK: [[@LINE]]| 1| if (cond) {22 } // CHECK: [[@LINE]]| 0| }23} // CHECK: [[@LINE]]| 1|}24void bar() { // CHECK: [[@LINE]]| 1|void bar() {25} // CHECK: [[@LINE]]| 1|}26void func() { // CHECK: [[@LINE]]| 0|void func(27} // CHECK: [[@LINE]]| 0|}28int main() { // CHECK: [[@LINE]]| 1|int main(29 foo(false); // CHECK: [[@LINE]]| 1| foo(30 bar(); // CHECK: [[@LINE]]| 1| bar(31 return 0; // CHECK: [[@LINE]]| 1| return32} // CHECK: [[@LINE]]| 1|}33 34// COVMAP: __llvm_covmap {{.*}}35 36