================ @@ -1128,15 +1132,22 @@ struct CounterCoverageMappingBuilder BranchParams = mcdc::BranchParameters{ID, Conds}; // If a condition can fold to true or false, the corresponding branch - // will be removed. Create a region with both counters hard-coded to - // zero. This allows us to visualize them in a special way. + // will be removed. Create a region with the relative counter hard-coded + // to zero. This allows us to visualize them in a special way. // Alternatively, we can prevent any optimization done via // constant-folding by ensuring that ConstantFoldsToSimpleInteger() in // CodeGenFunction.c always returns false, but that is very heavy-handed. - if (ConditionFoldsToBool(C)) - popRegions(pushRegion(Counter::getZero(), getStart(C), getEnd(C), - Counter::getZero(), BranchParams)); - else + bool ConstantBool = false; + if (ConditionFoldsToBool(C, ConstantBool)) { + if (ConstantBool) { + popRegions(pushRegion(TrueCnt, getStart(C), getEnd(C), + Counter::getZero(), BranchParams)); + } else { + popRegions(pushRegion(Counter::getZero(), getStart(C), getEnd(C), ---------------- Lambdaris wrote:
The only code where I found it may cause side effect seems never impact `BranchRegion` or `MCDCBranchRegion`: https://github.com/llvm/llvm-project/blob/327edbe07ab4370ceb20ea7c805f64950871d835/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp#L854 https://github.com/llvm/llvm-project/pull/94137 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits