Skip to content

Commit

Permalink
[coverage] keep relative order of mcdc branch and decision mapping re…
Browse files Browse the repository at this point in the history
…gions
  • Loading branch information
Lambdaris committed May 9, 2024
1 parent 6f1013a commit e469a3e
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion llvm/lib/ProfileData/Coverage/CoverageMappingWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,15 @@ void CoverageMappingWriter::write(raw_ostream &OS) {
const CounterMappingRegion &RHS) {
if (LHS.FileID != RHS.FileID)
return LHS.FileID < RHS.FileID;
if (LHS.startLoc() != RHS.startLoc())

auto ignoreLocationComparison = [](const CounterMappingRegion &LHS,
const CounterMappingRegion &RHS) {
return (LHS.Kind == CounterMappingRegion::MCDCBranchRegion ||
LHS.Kind == CounterMappingRegion::MCDCDecisionRegion) &&
LHS.Kind == RHS.Kind;
};

if (!ignoreLocationComparison(LHS, RHS) && LHS.startLoc() != RHS.startLoc())
return LHS.startLoc() < RHS.startLoc();

// Put `Decision` before `Expansion`.
Expand Down

0 comments on commit e469a3e

Please sign in to comment.