63182c2ac0
gcov is an "Edge Profiling with Edge Counters" application according to Optimally Profiling and Tracing Programs (1994). The minimum number of counters necessary is |E|-(|V|-1). The unmeasured edges form a spanning tree. Both GCC --coverage and clang -fprofile-generate leverage this optimization. This patch implements the optimization for clang --coverage. The produced .gcda files are much smaller now.
28 lines
1.4 KiB
C
28 lines
1.4 KiB
C
/// Test we close file handle on flush, so the .gcda file can be deleted on
|
|
/// Windows while the process is still running. In addition, test we create
|
|
/// a new .gcda on flush, so there is a file when the process exists.
|
|
// RUN: mkdir -p %t.d && cd %t.d
|
|
// RUN: %clang --coverage -o %t %s
|
|
// RUN: test -f gcov-dump-and-remove.gcno
|
|
|
|
// RUN: rm -f gcov-dump-and-remove.gcda && %run %t
|
|
// RUN: llvm-cov gcov -t gcov-dump-and-remove.gcda | FileCheck %s
|
|
|
|
extern void __gcov_dump(void);
|
|
extern void __gcov_reset(void);
|
|
extern int remove(const char *); // CHECK: -: [[#@LINE]]:extern int remove
|
|
int main(void) { // CHECK-NEXT: 1: [[#@LINE]]:
|
|
__gcov_dump(); // CHECK-NEXT: 1: [[#@LINE]]:
|
|
__gcov_reset(); // CHECK-NEXT: 1: [[#@LINE]]:
|
|
if (remove("gcov-dump-and-remove.gcda") != 0) // CHECK-NEXT: 1: [[#@LINE]]:
|
|
return 1; // CHECK-NEXT: #####: [[#@LINE]]: return 1;
|
|
// CHECK-NEXT: -: [[#@LINE]]:
|
|
__gcov_dump(); // CHECK-NEXT: 1: [[#@LINE]]:
|
|
__gcov_reset(); // CHECK-NEXT: 1: [[#@LINE]]:
|
|
__gcov_dump(); // CHECK-NEXT: 1: [[#@LINE]]:
|
|
if (remove("gcov-dump-and-remove.gcda") != 0) // CHECK-NEXT: 1: [[#@LINE]]:
|
|
return 1; // CHECK-NEXT: #####: [[#@LINE]]: return 1;
|
|
|
|
return 0;
|
|
}
|