================ @@ -943,19 +942,43 @@ struct CounterCoverageMappingBuilder std::pair<Counter, Counter> getBranchCounterPair(const Stmt *S, Counter ParentCnt) { - Counter ExecCnt = getRegionCounter(S); - return {ExecCnt, Builder.subtract(ParentCnt, ExecCnt)}; + auto &TheMap = CounterMap[S]; + auto ExecCnt = Counter::getCounter(TheMap.first); + auto SkipExpr = Builder.subtract(ParentCnt, ExecCnt); + + if (!llvm::EnableSingleByteCoverage || !SkipExpr.isExpression()) { + assert( + !TheMap.getIsCounterPair().second && + "SkipCnt shouldn't be allocated but refer to an existing counter."); + return {ExecCnt, SkipExpr}; + } + + // Assign second if second is not assigned yet. + if (!TheMap.getIsCounterPair().second) + TheMap.second = NextCounterNum++; + + Counter SkipCnt = Counter::getCounter(TheMap.second); + MapToExpand[SkipCnt] = SkipExpr; + return {ExecCnt, SkipCnt}; } Counter getSwitchImplicitDefaultCounter(const Stmt *Cond, Counter ParentCount, Counter CaseCountSum) { - return Builder.subtract(ParentCount, CaseCountSum); + return ( + llvm::EnableSingleByteCoverage + ? Counter::getCounter(CounterMap[Cond].second = NextCounterNum++) + : Builder.subtract(ParentCount, CaseCountSum)); } bool IsCounterEqual(Counter OutCount, Counter ParentCount) { if (OutCount == ParentCount) return true; + // Try comaparison with pre-replaced expressions. ---------------- ornata wrote:
Can you put a small example in the comment here? https://github.com/llvm/llvm-project/pull/112730 _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits