Skip to content

Commit 069bf8e

Browse files
committed
CoverageMappingWriter: Emit Decision before Expansion
1 parent f5e58a0 commit 069bf8e

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

llvm/lib/ProfileData/Coverage/CoverageMappingWriter.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,18 @@ void CoverageMappingWriter::write(raw_ostream &OS) {
167167
return LHS.FileID < RHS.FileID;
168168
if (LHS.startLoc() != RHS.startLoc())
169169
return LHS.startLoc() < RHS.startLoc();
170-
return LHS.Kind < RHS.Kind;
170+
171+
// Put `Decision` before `Expansion`.
172+
auto getKindKey = [](CounterMappingRegion::RegionKind Kind) {
173+
return (Kind == CounterMappingRegion::MCDCDecisionRegion
174+
? 2 * CounterMappingRegion::ExpansionRegion - 1
175+
: 2 * Kind);
176+
};
177+
178+
auto LHSKindKey = getKindKey(LHS.Kind);
179+
auto RHSKindKey = getKindKey(RHS.Kind);
180+
181+
return LHSKindKey < RHSKindKey;
171182
});
172183

173184
// Write out the fileid -> filename mapping.

0 commit comments

Comments
 (0)