[llvm] [coverage] keep relative order of mcdc branch and decision mapping regions (PR #91600)
via llvm-commits
llvm-commits at lists.llvm.org
Thu May 9 07:54:49 PDT 2024
https://github.com/Lambdaris updated https://github.com/llvm/llvm-project/pull/91600
>From e469a3ebc8708fce8a129187862a7f5613bd58d6 Mon Sep 17 00:00:00 2001
From: Lambdaris <lambdaris at outlook.com>
Date: Thu, 9 May 2024 21:35:33 +0800
Subject: [PATCH] [coverage] keep relative order of mcdc branch and decision
mapping regions
---
.../lib/ProfileData/Coverage/CoverageMappingWriter.cpp | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/llvm/lib/ProfileData/Coverage/CoverageMappingWriter.cpp b/llvm/lib/ProfileData/Coverage/CoverageMappingWriter.cpp
index 5036bde5aca72..c58fc9a46f57d 100644
--- a/llvm/lib/ProfileData/Coverage/CoverageMappingWriter.cpp
+++ b/llvm/lib/ProfileData/Coverage/CoverageMappingWriter.cpp
@@ -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`.
More information about the llvm-commits
mailing list