[clang] [llvm] [Coverage] Introduce "partial fold" on BranchRegion (PR #112694)

NAKAMURA Takumi via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 18 01:46:54 PDT 2024


================
@@ -719,10 +720,10 @@ struct FunctionRecord {
         Region.Kind == CounterMappingRegion::MCDCBranchRegion) {
       CountedBranchRegions.emplace_back(Region, Count, FalseCount,
                                         HasSingleByteCoverage);
-      // If both counters are hard-coded to zero, then this region represents a
+      // If either counters is hard-coded to zero, then this region represents a
       // constant-folded branch.
-      if (Region.Count.isZero() && Region.FalseCount.isZero())
-        CountedBranchRegions.back().Folded = true;
+      CountedBranchRegions.back().TrueFolded = Region.Count.isZero();
----------------
chapuni wrote:

`CounterMappingRegion::Count` is used in non-Branch regions. (then, `FalseCount` may be N/A)

Similar cases can be seen in `llvm::CountedRegion` and Clang's `SourceMappingRegion`. So, I think it'd be our common sense for the region to have `FalseCount` optionally.

In contrast, `Folded` is specific to Branch region. So, I think `TrueFolded` would be less intrusive.

https://github.com/llvm/llvm-project/pull/112694


More information about the cfe-commits mailing list