[llvm] [Coverage] Rework Decision/Expansion/Branch (PR #78969)
Jessica Paquette via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 22 06:11:35 PST 2024
================
@@ -662,23 +724,39 @@ Error CoverageMapping::loadFunctionRecord(
}
Function.pushRegion(Region, *ExecutionCount, *AltExecutionCount);
+ if (Region.Kind == CounterMappingRegion::ExpansionRegion) {
+ for (auto &Decision : reverse(Decisions)) {
+ if (Decision.updateExpansion(Region))
+ break;
+ }
+ continue;
+ }
+
+ if (Region.Kind != CounterMappingRegion::MCDCBranchRegion)
+ continue;
+
// If a MCDCDecisionRegion was seen, store the BranchRegions that
// correspond to it in a vector, according to the number of conditions
// recorded for the region (tracked by NumConds).
- if (NumConds > 0 && Region.Kind == CounterMappingRegion::MCDCBranchRegion) {
- MCDCBranches.push_back(Region);
+ for (int I = Decisions.size() - 1; I >= 0; --I) {
+ auto &Decision = Decisions[I];
// As we move through all of the MCDCBranchRegions that follow the
// MCDCDecisionRegion, decrement NumConds to make sure we account for
// them all before we calculate the bitmap of executed test vectors.
- if (--NumConds == 0) {
+ switch (Decision.updateBranch(Region)) {
+ case DecisionRow::UpdateResult::NotFound:
+ continue;
+ case DecisionRow::UpdateResult::Updated:
+ goto branch_found;
----------------
ornata wrote:
Why `goto`?
```
bool BranchFound = false;
switch(...) {
case DecisionRow::UpdateResult::Updated:
BranchFound = true;
break;
...
}
(void)BranchFound;
assert(BranchFound && "Did not find a branch?!");
```
Alternatively, we could return an `Error` when `BranchFound == false`.
https://github.com/llvm/llvm-project/pull/78969
More information about the llvm-commits
mailing list