forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Coverage] Allow Clang coverage to be used with debug info correlation.
Debug info correlation is an option in InstrProfiling pass, which is used by both IR instrumentation and front-end instrumentation. So, Clang coverage can also benefits the binary size saving from it. Reviewed By: ellis Differential Revision: https://reviews.llvm.org/D157913
- Loading branch information
Showing
12 changed files
with
409 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// RUN: %clang_cc1 -debug-info-kind=standalone -fprofile-instrument=clang -fcoverage-mapping -emit-llvm -o - %s | FileCheck %s | ||
// RUN: %clang_cc1 -debug-info-kind=standalone -mllvm -debug-info-correlate -fprofile-instrument=clang -fcoverage-mapping -emit-llvm -o - %s | FileCheck %s --check-prefix=DEBUG_INFO | ||
|
||
// CHECK: @__llvm_profile_raw_version = hidden constant i64 8, comdat | ||
// DEBUG_INFO: @__llvm_profile_raw_version = hidden constant i64 576460752303423496, comdat | ||
|
||
int main() { | ||
return 0; | ||
} |
78 changes: 78 additions & 0 deletions
78
compiler-rt/test/profile/Darwin/coverage-debug-info-correlate.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
// Test debug info correlate with clang coverage. | ||
|
||
// Test the case when there is no __llvm_prf_names in the binary. | ||
// RUN: %clang_profgen -o %t.normal -fcoverage-mapping %S/../Inputs/instrprof-debug-info-correlate-main.cpp %S/../Inputs/instrprof-debug-info-correlate-foo.cpp | ||
// RUN: env LLVM_PROFILE_FILE=%t.profraw %run %t.normal | ||
// RUN: llvm-profdata merge -o %t.normal.profdata %t.profraw | ||
|
||
// RUN: %clang_profgen -o %t -g -mllvm --debug-info-correlate -fcoverage-mapping %S/../Inputs/instrprof-debug-info-correlate-main.cpp %S/../Inputs/instrprof-debug-info-correlate-foo.cpp | ||
// RUN: env LLVM_PROFILE_FILE=%t.proflite %run %t | ||
// RUN: llvm-profdata merge -o %t.profdata --debug-info=%t.dSYM %t.proflite | ||
|
||
// RUN: diff <(llvm-profdata show --all-functions --counts %t.normal.profdata) <(llvm-profdata show --all-functions --counts %t.profdata) | ||
|
||
// RUN: llvm-cov report --instr-profile=%t.profdata %t | FileCheck %s -check-prefix=NONAME | ||
|
||
// Test debug info correlate with clang coverage (online merging). | ||
|
||
// RUN: env LLVM_PROFILE_FILE=%t-1.profraw %run %t.normal | ||
// RUN: env LLVM_PROFILE_FILE=%t-2.profraw %run %t.normal | ||
// RUN: llvm-profdata merge -o %t.normal.profdata %t-1.profraw %t-2.profraw | ||
|
||
// RUN: rm -rf %t.profdir && mkdir %t.profdir | ||
// RUN: env LLVM_PROFILE_FILE=%t.profdir/%m.proflite %run %t | ||
// RUN: env LLVM_PROFILE_FILE=%t.profdir/%m.proflite %run %t | ||
// RUN: llvm-profdata merge -o %t.profdata --debug-info=%t.dSYM %t.profdir | ||
|
||
// RUN: diff <(llvm-profdata show --all-functions --counts %t.normal.profdata) <(llvm-profdata show --all-functions --counts %t.profdata) | ||
|
||
// RUN: llvm-cov report --instr-profile=%t.profdata %t | FileCheck %s -check-prefix=NONAME | ||
// RUN: llvm-cov report --instr-profile=%t.normal.profdata %t | FileCheck %s -check-prefix=NONAME | ||
|
||
// NONAME: Filename Regions Missed Regions Cover Functions Missed Functions Executed Lines Missed Lines Cover Branches Missed Branches Cover | ||
// NONAME-NEXT: -- | ||
// NONAME-NEXT: instrprof-debug-info-correlate-bar.h 3 1 66.67% 1 0 100.00% 5 1 80.00% 2 1 50.00% | ||
// NONAME-NEXT: instrprof-debug-info-correlate-foo.cpp 5 2 60.00% 2 1 50.00% 6 2 66.67% 2 1 50.00% | ||
// NONAME-NEXT: instrprof-debug-info-correlate-main.cpp 4 0 100.00% 1 0 100.00% 5 0 100.00% 2 0 100.00% | ||
// NONAME-NEXT: -- | ||
// NONAME-NEXT: TOTAL 12 3 75.00% 4 1 75.00% 16 3 81.25% 6 2 66.67% | ||
|
||
// Test the case when there is __llvm_prf_names in the binary (those are names of uninstrumented functions). | ||
// RUN: %clang_profgen -o %t.normal -fcoverage-mapping -mllvm -enable-name-compression=false %s | ||
// RUN: env LLVM_PROFILE_FILE=%t.profraw %run %t.normal | ||
// RUN: llvm-profdata merge -o %t.normal.profdata %t.profraw | ||
|
||
// RUN: %clang_profgen -o %t -g -mllvm --debug-info-correlate -fcoverage-mapping -mllvm -enable-name-compression=false %s | ||
// RUN: env LLVM_PROFILE_FILE=%t.proflite %run %t | ||
// RUN: llvm-profdata merge -o %t.profdata --debug-info=%t.dSYM %t.proflite | ||
|
||
// RUN: diff <(llvm-profdata show --all-functions --counts %t.normal.profdata) <(llvm-profdata show --all-functions --counts %t.profdata) | ||
|
||
// RUN: llvm-cov export --format=lcov --instr-profile=%t.profdata %t | FileCheck %s -check-prefix=NAME | ||
|
||
// Test debug info correlate with clang coverage (online merging). | ||
|
||
// RUN: env LLVM_PROFILE_FILE=%t-1.profraw %run %t.normal | ||
// RUN: env LLVM_PROFILE_FILE=%t-2.profraw %run %t.normal | ||
// RUN: llvm-profdata merge -o %t.normal.profdata %t-1.profraw %t-2.profraw | ||
|
||
// RUN: rm -rf %t.profdir && mkdir %t.profdir | ||
// RUN: env LLVM_PROFILE_FILE=%t.profdir/%m.proflite %run %t | ||
// RUN: env LLVM_PROFILE_FILE=%t.profdir/%m.proflite %run %t | ||
// RUN: llvm-profdata merge -o %t.profdata --debug-info=%t.dSYM %t.profdir | ||
|
||
// RUN: diff <(llvm-profdata show --all-functions --counts %t.normal.profdata) <(llvm-profdata show --all-functions --counts %t.profdata) | ||
|
||
// RUN: llvm-cov export --format=lcov --instr-profile=%t.profdata %t | FileCheck %s -check-prefix=NAME | ||
// NAME: _Z9used_funcv | ||
// NAME: main | ||
// NAME: _ZN1A11unused_funcEv | ||
|
||
struct A { | ||
void unused_func() {} | ||
}; | ||
void used_func() {} | ||
int main() { | ||
used_func(); | ||
return 0; | ||
} |
78 changes: 78 additions & 0 deletions
78
compiler-rt/test/profile/Linux/coverage-debug-info-correlate.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
// Test debug info correlate with clang coverage. | ||
|
||
// Test the case when there is no __llvm_prf_names in the binary. | ||
// RUN: %clang_profgen -o %t.normal -fcoverage-mapping %S/../Inputs/instrprof-debug-info-correlate-main.cpp %S/../Inputs/instrprof-debug-info-correlate-foo.cpp | ||
// RUN: env LLVM_PROFILE_FILE=%t.profraw %run %t.normal | ||
// RUN: llvm-profdata merge -o %t.normal.profdata %t.profraw | ||
|
||
// RUN: %clang_profgen -o %t -g -mllvm --debug-info-correlate -fcoverage-mapping %S/../Inputs/instrprof-debug-info-correlate-main.cpp %S/../Inputs/instrprof-debug-info-correlate-foo.cpp | ||
// RUN: env LLVM_PROFILE_FILE=%t.proflite %run %t | ||
// RUN: llvm-profdata merge -o %t.profdata --debug-info=%t %t.proflite | ||
|
||
// RUN: diff <(llvm-profdata show --all-functions --counts %t.normal.profdata) <(llvm-profdata show --all-functions --counts %t.profdata) | ||
|
||
// RUN: llvm-cov report --instr-profile=%t.profdata %t | FileCheck %s -check-prefix=NONAME | ||
|
||
// Test debug info correlate with clang coverage (online merging). | ||
|
||
// RUN: env LLVM_PROFILE_FILE=%t-1.profraw %run %t.normal | ||
// RUN: env LLVM_PROFILE_FILE=%t-2.profraw %run %t.normal | ||
// RUN: llvm-profdata merge -o %t.normal.profdata %t-1.profraw %t-2.profraw | ||
|
||
// RUN: rm -rf %t.profdir && mkdir %t.profdir | ||
// RUN: env LLVM_PROFILE_FILE=%t.profdir/%m.proflite %run %t | ||
// RUN: env LLVM_PROFILE_FILE=%t.profdir/%m.proflite %run %t | ||
// RUN: llvm-profdata merge -o %t.profdata --debug-info=%t %t.profdir | ||
|
||
// RUN: diff <(llvm-profdata show --all-functions --counts %t.normal.profdata) <(llvm-profdata show --all-functions --counts %t.profdata) | ||
|
||
// RUN: llvm-cov report --instr-profile=%t.profdata %t | FileCheck %s -check-prefix=NONAME | ||
// RUN: llvm-cov report --instr-profile=%t.normal.profdata %t | FileCheck %s -check-prefix=NONAME | ||
|
||
// NONAME: Filename Regions Missed Regions Cover Functions Missed Functions Executed Lines Missed Lines Cover Branches Missed Branches Cover | ||
// NONAME-NEXT: -- | ||
// NONAME-NEXT: instrprof-debug-info-correlate-bar.h 3 1 66.67% 1 0 100.00% 5 1 80.00% 2 1 50.00% | ||
// NONAME-NEXT: instrprof-debug-info-correlate-foo.cpp 5 2 60.00% 2 1 50.00% 6 2 66.67% 2 1 50.00% | ||
// NONAME-NEXT: instrprof-debug-info-correlate-main.cpp 4 0 100.00% 1 0 100.00% 5 0 100.00% 2 0 100.00% | ||
// NONAME-NEXT: -- | ||
// NONAME-NEXT: TOTAL 12 3 75.00% 4 1 75.00% 16 3 81.25% 6 2 66.67% | ||
|
||
// Test the case when there is __llvm_prf_names in the binary (those are names of uninstrumented functions). | ||
// RUN: %clang_profgen -o %t.normal -fcoverage-mapping -mllvm -enable-name-compression=false %s | ||
// RUN: env LLVM_PROFILE_FILE=%t.profraw %run %t.normal | ||
// RUN: llvm-profdata merge -o %t.normal.profdata %t.profraw | ||
|
||
// RUN: %clang_profgen -o %t -g -mllvm --debug-info-correlate -fcoverage-mapping -mllvm -enable-name-compression=false %s | ||
// RUN: env LLVM_PROFILE_FILE=%t.proflite %run %t | ||
// RUN: llvm-profdata merge -o %t.profdata --debug-info=%t %t.proflite | ||
|
||
// RUN: diff <(llvm-profdata show --all-functions --counts %t.normal.profdata) <(llvm-profdata show --all-functions --counts %t.profdata) | ||
|
||
// RUN: llvm-cov export --format=lcov --instr-profile=%t.profdata %t | FileCheck %s -check-prefix=NAME | ||
|
||
// Test debug info correlate with clang coverage (online merging). | ||
|
||
// RUN: env LLVM_PROFILE_FILE=%t-1.profraw %run %t.normal | ||
// RUN: env LLVM_PROFILE_FILE=%t-2.profraw %run %t.normal | ||
// RUN: llvm-profdata merge -o %t.normal.profdata %t-1.profraw %t-2.profraw | ||
|
||
// RUN: rm -rf %t.profdir && mkdir %t.profdir | ||
// RUN: env LLVM_PROFILE_FILE=%t.profdir/%m.proflite %run %t | ||
// RUN: env LLVM_PROFILE_FILE=%t.profdir/%m.proflite %run %t | ||
// RUN: llvm-profdata merge -o %t.profdata --debug-info=%t %t.profdir | ||
|
||
// RUN: diff <(llvm-profdata show --all-functions --counts %t.normal.profdata) <(llvm-profdata show --all-functions --counts %t.profdata) | ||
|
||
// RUN: llvm-cov export --format=lcov --instr-profile=%t.profdata %t | FileCheck %s -check-prefix=NAME | ||
// NAME: _Z9used_funcv | ||
// NAME: main | ||
// NAME: _ZN1A11unused_funcEv | ||
|
||
struct A { | ||
void unused_func() {} | ||
}; | ||
void used_func() {} | ||
int main() { | ||
used_func(); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.