Skip to content

Commit 1707521

Browse files
committed
[coverage] Count false counters when calculating max counter id
1 parent 75dd411 commit 1707521

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
@@ -1159,8 +1159,8 @@ struct CounterCoverageMappingBuilder
11591159
BranchParams = mcdc::BranchParameters{ID, Conds};
11601160

11611161
// If a condition can fold to true or false, the corresponding branch
1162-
// will be removed. Create a region with both counters hard-coded to
1163-
// zero. This allows us to visualize them in a special way.
1162+
// will be removed. Create a region with the relative counter hard-coded
1163+
// to zero. This allows us to visualize them in a special way.
11641164
// Alternatively, we can prevent any optimization done via
11651165
// constant-folding by ensuring that ConstantFoldsToSimpleInteger() in
11661166
// 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
@@ -637,6 +637,8 @@ static unsigned getMaxCounterID(const CounterMappingContext &Ctx,
637637
unsigned MaxCounterID = 0;
638638
for (const auto &Region : Record.MappingRegions) {
639639
MaxCounterID = std::max(MaxCounterID, Ctx.getMaxCounterID(Region.Count));
640+
MaxCounterID =
641+
std::max(MaxCounterID, Ctx.getMaxCounterID(Region.FalseCount));
640642
}
641643
return MaxCounterID;
642644
}

0 commit comments

Comments
 (0)