teak-llvm/clang/test/CoverageMapping/header.cpp
Vedant Kumar 0acf3434e7 [Coverage] Add an option to emit limited coverage info
Add an option to emit limited coverage info for unused decls. It's just a
cl::opt for now to allow us to experiment quickly.

When building llc, this results in an 84% size reduction in the llvm_covmap
section, and a similar size reduction in the llvm_prf_names section. In
practice I expect the size reduction to be roughly quadratic with the size of
the program.

The downside is that coverage for headers will no longer be complete. This will
make the line/function/region coverage metrics incorrect, since they will be
artificially high. One mitigation would be to somehow disable those metrics
when using limited-coverage=true.

This is related to: llvm.org/PR34533 (make SourceBasedCodeCoverage scale)

Differential Revision: https://reviews.llvm.org/D38107

llvm-svn: 314002
2017-09-22 18:23:04 +00:00

30 lines
1.2 KiB
C++

// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name header.cpp %s > %tmapping
// RUN: FileCheck -input-file %tmapping %s --check-prefix=CHECK-FUNC
// RUN: FileCheck -input-file %tmapping %s --check-prefix=CHECK-STATIC-FUNC
// RUN: FileCheck -input-file %tmapping %s --check-prefix=CHECK-STATIC-FUNC2
//
// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -mllvm -limited-coverage-experimental=true -dump-coverage-mapping -emit-llvm-only -main-file-name header.cpp %s > %tmapping.limited
// RUN: FileCheck -input-file %tmapping.limited %s --check-prefix=CHECK-LIMITED
#include "Inputs/header1.h"
int main() {
func(1);
static_func(2);
}
// CHECK-FUNC: func
// CHECK-FUNC: File 0, 4:25 -> 11:2 = #0
// CHECK-FUNC: File 0, 6:15 -> 8:4 = #1
// CHECK-FUNC: File 0, 8:10 -> 10:4 = (#0 - #1)
// CHECK-STATIC-FUNC: static_func
// CHECK-STATIC-FUNC: File 0, 12:32 -> 20:2 = #0
// CHECK-STATIC-FUNC: File 0, 14:15 -> 16:4 = #1
// CHECK-STATIC-FUNC: File 0, 16:10 -> 18:4 = (#0 - #1)
// CHECK-STATIC-FUNC2: static_func2
// CHECK-STATIC-FUNC2: File 0, 21:33 -> 29:2 = 0
// CHECK-LIMITED-NOT: static_func2