@@ -964,6 +964,10 @@ struct CounterCoverageMappingBuilder
964
964
std::pair<Counter, Counter>
965
965
getSwitchImplicitDefaultCounterPair (const Stmt *Cond, Counter ParentCount,
966
966
Counter CaseCountSum) {
967
+ if (llvm::EnableSingleByteCoverage)
968
+ return {Counter::getZero (), // Folded
969
+ Counter::getCounter (CounterMap[Cond].second = NextCounterNum++)};
970
+
967
971
// Simplify is skipped while building the counters above: it can get
968
972
// really slow on top of switches with thousands of cases. Instead,
969
973
// trigger simplification by adding zero to the last counter.
@@ -1195,12 +1199,14 @@ struct CounterCoverageMappingBuilder
1195
1199
// / and add it to the function's SourceRegions.
1196
1200
// / Returns Counter that corresponds to SC.
1197
1201
Counter createSwitchCaseRegion (const SwitchCase *SC, Counter ParentCount) {
1202
+ Counter TrueCnt = getRegionCounter (SC);
1203
+ Counter FalseCnt = (llvm::EnableSingleByteCoverage
1204
+ ? Counter::getZero () // Folded
1205
+ : subtractCounters (ParentCount, TrueCnt));
1198
1206
// Push region onto RegionStack but immediately pop it (which adds it to
1199
1207
// the function's SourceRegions) because it doesn't apply to any other
1200
1208
// source other than the SwitchCase.
1201
- Counter TrueCnt = getRegionCounter (SC);
1202
- popRegions (pushRegion (TrueCnt, getStart (SC), SC->getColonLoc (),
1203
- subtractCounters (ParentCount, TrueCnt)));
1209
+ popRegions (pushRegion (TrueCnt, getStart (SC), SC->getColonLoc (), FalseCnt));
1204
1210
return TrueCnt;
1205
1211
}
1206
1212
0 commit comments