Skip to content

Commit 275a277

Browse files
authored
[Coverage][Single] Round Counters to boolean after evaluation (#110972)
Rounding in merging segments has been done after #75425. Depends on: #113114
1 parent dbae717 commit 275a277

File tree

4 files changed

+9
-6
lines changed

4 files changed

+9
-6
lines changed

llvm/lib/ProfileData/Coverage/CoverageMapping.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -805,6 +805,7 @@ Error CoverageMapping::loadFunctionRecord(
805805
else
806806
OrigFuncName = getFuncNameWithoutPrefix(OrigFuncName, Record.Filenames[0]);
807807

808+
bool SingleByteCoverage = ProfileReader.hasSingleByteCoverage();
808809
CounterMappingContext Ctx(Record.Expressions);
809810

810811
std::vector<uint64_t> Counts;
@@ -870,8 +871,10 @@ Error CoverageMapping::loadFunctionRecord(
870871
consumeError(std::move(E));
871872
return Error::success();
872873
}
873-
Function.pushRegion(Region, *ExecutionCount, *AltExecutionCount,
874-
ProfileReader.hasSingleByteCoverage());
874+
Function.pushRegion(
875+
Region, (SingleByteCoverage && *ExecutionCount ? 1 : *ExecutionCount),
876+
(SingleByteCoverage && *AltExecutionCount ? 1 : *AltExecutionCount),
877+
SingleByteCoverage);
875878

876879
// Record ExpansionRegion.
877880
if (Region.Kind == CounterMappingRegion::ExpansionRegion) {

llvm/test/tools/llvm-cov/Inputs/branch-logical-mixed.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
#include <stdio.h>
66
#include <stdlib.h>
7-
// CHECK: |{{ +}}[[C4:4|1]]|void func(
7+
// CHECK: | [[#min(C,4)]]|void func(
88
void func(int a, int b) {
99
bool b0 = a <= b;
1010
bool b1 = a == b;

llvm/test/tools/llvm-cov/branch-macros.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
// RUN: yaml2obj %S/Inputs/branch-macros-single.yaml -o %t.o
66
// RUN: llvm-profdata merge %S/Inputs/branch-macros-single.proftext -o %t.profdata
7-
// RUN: llvm-cov show --show-expansions --show-branches=count %t.o -instr-profile %t.profdata -path-equivalence=.,%S/Inputs | FileCheck %S/Inputs/branch-macros.cpp -D#C=999
7+
// RUN: llvm-cov show --show-expansions --show-branches=count %t.o -instr-profile %t.profdata -path-equivalence=.,%S/Inputs | FileCheck %S/Inputs/branch-macros.cpp -D#C=1
88

99
// REPORT: Name Regions Miss Cover Lines Miss Cover Branches Miss Cover
1010
// REPORT-NEXT: ---

llvm/test/tools/llvm-cov/showLineExecutionCounts.test

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,5 @@
4646
// RUN: yaml2obj %S/Inputs/showLineExecutionCounts-single.yaml -o %t.o
4747
// RUN: llvm-profdata merge %S/Inputs/showLineExecutionCounts-single.proftext -o %t.profdata
4848

49-
// RUN: llvm-cov show %t.o -instr-profile %t.profdata -path-equivalence=.,%S/Inputs | FileCheck -check-prefixes=TEXT,WHOLE-FILE -D#C=161 -DC16K2=161 -DC16K1=161 %S/Inputs/showLineExecutionCounts.cpp
50-
// RUN: llvm-cov show %t.o -instr-profile %t.profdata -path-equivalence=.,%S/Inputs -name=main | FileCheck -check-prefixes=TEXT,FILTER -D#C=161 -DC16K2=161 -DC16K1=161 %S/Inputs/showLineExecutionCounts.cpp
49+
// RUN: llvm-cov show %t.o -instr-profile %t.profdata -path-equivalence=.,%S/Inputs | FileCheck -check-prefixes=TEXT,WHOLE-FILE -D#C=1 -DC16K2=1 -DC16K1=1 %S/Inputs/showLineExecutionCounts.cpp
50+
// RUN: llvm-cov show %t.o -instr-profile %t.profdata -path-equivalence=.,%S/Inputs -name=main | FileCheck -check-prefixes=TEXT,FILTER -D#C=1 -DC16K2=1 -DC16K1=1 %S/Inputs/showLineExecutionCounts.cpp

0 commit comments

Comments
 (0)