[llvm] Restore #125407, Make covmap tolerant of nested Decisions (PR #183073)
NAKAMURA Takumi via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 4 04:23:33 PST 2026
================
@@ -907,56 +919,14 @@ Error CoverageMapping::loadFunctionRecord(
Record.MappingRegions[0].Count.isZero() && Counts[0] > 0)
return Error::success();
- MCDCDecisionRecorder MCDCDecisions;
FunctionRecord Function(OrigFuncName, Record.Filenames);
- for (const auto &Region : Record.MappingRegions) {
- // MCDCDecisionRegion should be handled first since it overlaps with
- // others inside.
- if (Region.Kind == CounterMappingRegion::MCDCDecisionRegion) {
- MCDCDecisions.registerDecision(Region);
- continue;
- }
- Expected<int64_t> ExecutionCount = Ctx.evaluate(Region.Count);
- if (auto E = ExecutionCount.takeError()) {
- consumeError(std::move(E));
- return Error::success();
- }
- Expected<int64_t> AltExecutionCount = Ctx.evaluate(Region.FalseCount);
- if (auto E = AltExecutionCount.takeError()) {
- consumeError(std::move(E));
- return Error::success();
- }
- Function.pushRegion(Region, *ExecutionCount, *AltExecutionCount);
-
- // Record ExpansionRegion.
- if (Region.Kind == CounterMappingRegion::ExpansionRegion) {
- MCDCDecisions.recordExpansion(Region);
- continue;
- }
-
- // Do nothing unless MCDCBranchRegion.
- if (Region.Kind != CounterMappingRegion::MCDCBranchRegion)
- continue;
- auto Result = MCDCDecisions.processBranch(Region);
- if (!Result) // Any Decision doesn't complete.
- continue;
-
- auto MCDCDecision = Result->first;
- auto &MCDCBranches = Result->second;
-
- // Since the bitmap identifies the executed test vectors for an MC/DC
- // DecisionRegion, all of the information is now available to process.
- // This is where the bulk of the MC/DC progressing takes place.
- Expected<MCDCRecord> Record =
- Ctx.evaluateMCDCRegion(*MCDCDecision, MCDCBranches, IsVersion11);
- if (auto E = Record.takeError()) {
- consumeError(std::move(E));
- return Error::success();
- }
-
- // Save the MC/DC Record so that it can be visualized later.
- Function.pushMCDCRecord(std::move(*Record));
+ // Emit CountedRegions into FunctionRecord.
+ if (auto E = CountedRegionEmitter(Record, Ctx, Function, IsVersion11)
+ .emitCountedRegions()) {
+ errs() << "warning: " << Record.FunctionName << ": ";
+ logAllUnhandledErrors(std::move(E), errs());
+ return Error::success();
----------------
chapuni wrote:
I have not been able to identify any issues caused by my changes so far.
I guess the root cause would be possibly in the correlation resolution in `llvm-profdata merge`.
I was trying to reproduce issues with `check-llvm` by seeing the commad line introduced in #180277.
In my attempts, incorrect correlation sometimes select improper `prf_cnts` as if it were right, to lead warnings. I don't know how `llvm-profdata merge` would be handled in you environment.
Eventually, I succeeded `llvm-cov` with the binary correlation without any "noisy" warnings.
1. Give `-profile-correlate=binary --build-id`
2. Write and run the script that pick up corresponding elf and profraw(s) by build-id and merge them to *-correlate-resolved.profdata
3. Run `llvm-profdata merge *-correlate-resolved.profdata` (not `profraw`) as the final stage
Note, I was not able to validate or repair the provided profdata. I guess it would be broken with reasons above.
https://github.com/llvm/llvm-project/pull/183073
More information about the llvm-commits
mailing list