[Coverage] Suppress covmap and profdata for system headers. (#97952)
With `system-headers-coverage=false`, functions defined in system headers were not instrumented but corresponding covmaps were emitted. It caused wasting covmap and profraw. This change improves: - Reduce object size (due to reduced covmap) - Reduce size of profraw (uninstrumented system headers occupied counters) - Smarter view of coverage report. Stubs of uninstrumented system headers will be no longer seen.
This commit is contained in:
@@ -7165,6 +7165,9 @@ void CodeGenModule::AddDeferredUnusedCoverageMapping(Decl *D) {
|
||||
SourceManager &SM = getContext().getSourceManager();
|
||||
if (LimitedCoverage && SM.getMainFileID() != SM.getFileID(D->getBeginLoc()))
|
||||
break;
|
||||
if (!llvm::coverage::SystemHeadersCoverage &&
|
||||
SM.isInSystemHeader(D->getBeginLoc()))
|
||||
break;
|
||||
DeferredEmptyCoverageMappingDecls.try_emplace(D, true);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1044,13 +1044,17 @@ void CodeGenPGO::assignRegionCounters(GlobalDecl GD, llvm::Function *Fn) {
|
||||
if (Fn->hasFnAttribute(llvm::Attribute::SkipProfile))
|
||||
return;
|
||||
|
||||
SourceManager &SM = CGM.getContext().getSourceManager();
|
||||
if (!llvm::coverage::SystemHeadersCoverage &&
|
||||
SM.isInSystemHeader(D->getLocation()))
|
||||
return;
|
||||
|
||||
setFuncName(Fn);
|
||||
|
||||
mapRegionCounters(D);
|
||||
if (CGM.getCodeGenOpts().CoverageMapping)
|
||||
emitCounterRegionMapping(D);
|
||||
if (PGOReader) {
|
||||
SourceManager &SM = CGM.getContext().getSourceManager();
|
||||
loadRegionCounts(PGOReader, SM.isInMainFile(D->getLocation()));
|
||||
computeRegionCounts(D);
|
||||
applyFunctionAttributes(PGOReader, Fn);
|
||||
|
||||
@@ -5,9 +5,8 @@
|
||||
|
||||
// LL_CHECK: @__covrec_
|
||||
// LL_W_SYS: [[PROFC:@.*__profc_.*SysTmpl.*]] =
|
||||
// LL_WOSYS: [[PROFC:@.*__profc_.*SysTmpl.*]] =
|
||||
// LL_W_SYS: @{{.*}}__profd_{{.*}}SysTmpl{{.*}} =
|
||||
// LL_WOSYS: @{{.*}}__profd_{{.*}}SysTmpl{{.*}} =
|
||||
// LL_WOSYS-NOT: SysTmpl
|
||||
|
||||
// LL_CHECK: @llvm.used =
|
||||
|
||||
@@ -21,7 +20,7 @@
|
||||
template <bool f> bool SysTmpl() { return f; }
|
||||
// Check SysTmpl() is instrumented or not.
|
||||
// LL_W_SYS: load i64, ptr [[PROFC]],
|
||||
// LL_WOSYS: load i64, ptr [[PROFC]],
|
||||
// LL_WOSYS-NOT: load i64, ptr @__profc_
|
||||
|
||||
#else
|
||||
|
||||
|
||||
Reference in New Issue
Block a user