[llvm] [Coverage] Rework Decision/Expansion/Branch (PR #78969)
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Sat Jan 27 21:12:43 PST 2024
================
@@ -638,20 +810,13 @@ Error CoverageMapping::loadFunctionRecord(
Record.MappingRegions[0].Count.isZero() && Counts[0] > 0)
return Error::success();
- unsigned NumConds = 0;
- const CounterMappingRegion *MCDCDecision;
- std::vector<const CounterMappingRegion *> MCDCBranches;
-
+ MCDCDecisionRecorder MCDCDecisions;
FunctionRecord Function(OrigFuncName, Record.Filenames);
for (const auto &Region : Record.MappingRegions) {
- // If an MCDCDecisionRegion is seen, track the BranchRegions that follow
- // it according to Region.NumConditions.
- if (Region.Kind == CounterMappingRegion::MCDCDecisionRegion) {
- assert(NumConds == 0);
- MCDCDecision = &Region;
- NumConds = Region.MCDCParams.NumConditions;
+ // MCDCDecisionRegion should be handled first since it overlaps with
+ // others inside.
+ if (MCDCDecisions.registerDecision(Region))
----------------
MaskRay wrote:
I think it reads better if the `CounterMappingRegion::MCDCDecisionRegion` guard is moved here. The same applies to `MCDCDecisions.processRegion(Region);`
I.e. we check different types of `Region` here and dispatch actions to `MCDCDecisions`.
https://github.com/llvm/llvm-project/pull/78969
More information about the llvm-commits
mailing list