Skip to content

Commit 755d8f2

Browse files
committed
[coverage] Count false counters when calculating max counter id
1 parent eb9af19 commit 755d8f2

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

clang/lib/CodeGen/CoverageMappingGen.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1122,8 +1122,8 @@ struct CounterCoverageMappingBuilder
11221122
BranchParams = mcdc::BranchParameters{ID, Conds};
11231123

11241124
// If a condition can fold to true or false, the corresponding branch
1125-
// will be removed. Create a region with both counters hard-coded to
1126-
// zero. This allows us to visualize them in a special way.
1125+
// will be removed. Create a region with the relative counter hard-coded
1126+
// to zero. This allows us to visualize them in a special way.
11271127
// Alternatively, we can prevent any optimization done via
11281128
// constant-folding by ensuring that ConstantFoldsToSimpleInteger() in
11291129
// CodeGenFunction.c always returns false, but that is very heavy-handed.

llvm/lib/ProfileData/Coverage/CoverageMapping.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,8 @@ static unsigned getMaxCounterID(const CounterMappingContext &Ctx,
608608
unsigned MaxCounterID = 0;
609609
for (const auto &Region : Record.MappingRegions) {
610610
MaxCounterID = std::max(MaxCounterID, Ctx.getMaxCounterID(Region.Count));
611+
MaxCounterID =
612+
std::max(MaxCounterID, Ctx.getMaxCounterID(Region.FalseCount));
611613
}
612614
return MaxCounterID;
613615
}

0 commit comments

Comments
 (0)