[llvm] ee6f10d - [Coverage] Make `MCDCRecord::Folded` as `[false/true]` with BitVector. NFC. (#121190)
via llvm-commits
llvm-commits at lists.llvm.org
Sat Dec 28 00:48:33 PST 2024
Author: NAKAMURA Takumi
Date: 2024-12-28T17:48:30+09:00
New Revision: ee6f10d37232627137ce97388a5eb21b90907bfb
URL: https://github.com/llvm/llvm-project/commit/ee6f10d37232627137ce97388a5eb21b90907bfb
DIFF: https://github.com/llvm/llvm-project/commit/ee6f10d37232627137ce97388a5eb21b90907bfb.diff
LOG: [Coverage] Make `MCDCRecord::Folded` as `[false/true]` with BitVector. NFC. (#121190)
For merging `MCDCRecord`s, `Folded` is expected to be promoted as
"Non-folded".
Added:
Modified:
llvm/include/llvm/ProfileData/Coverage/CoverageMapping.h
llvm/lib/ProfileData/Coverage/CoverageMapping.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/ProfileData/Coverage/CoverageMapping.h b/llvm/include/llvm/ProfileData/Coverage/CoverageMapping.h
index 0ad6f07bde989b..3a018d2a95c6b1 100644
--- a/llvm/include/llvm/ProfileData/Coverage/CoverageMapping.h
+++ b/llvm/include/llvm/ProfileData/Coverage/CoverageMapping.h
@@ -439,7 +439,7 @@ struct MCDCRecord {
};
using TestVectors = llvm::SmallVector<std::pair<TestVector, CondState>>;
- using BoolVector = llvm::SmallVector<bool>;
+ using BoolVector = std::array<BitVector, 2>;
using TVRowPair = std::pair<unsigned, unsigned>;
using TVPairMap = llvm::DenseMap<unsigned, TVRowPair>;
using CondIDMap = llvm::DenseMap<unsigned, unsigned>;
@@ -467,7 +467,9 @@ struct MCDCRecord {
return Region.getDecisionParams().NumConditions;
}
unsigned getNumTestVectors() const { return TV.size(); }
- bool isCondFolded(unsigned Condition) const { return Folded[Condition]; }
+ bool isCondFolded(unsigned Condition) const {
+ return Folded[false][Condition] || Folded[true][Condition];
+ }
/// Return the evaluation of a condition (indicated by Condition) in an
/// executed test vector (indicated by TestVectorIndex), which will be True,
diff --git a/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp b/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp
index 1bf2e8d627bc4d..f95e311e09de67 100644
--- a/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp
+++ b/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp
@@ -392,8 +392,9 @@ class MCDCRecordProcessor : NextIDsBuilder, mcdc::TVIdxBuilder {
: NextIDsBuilder(Branches), TVIdxBuilder(this->NextIDs), Bitmap(Bitmap),
Region(Region), DecisionParams(Region.getDecisionParams()),
Branches(Branches), NumConditions(DecisionParams.NumConditions),
- Folded(NumConditions, false), IndependencePairs(NumConditions),
- ExecVectors(ExecVectorsByCond[false]), IsVersion11(IsVersion11) {}
+ Folded{{BitVector(NumConditions), BitVector(NumConditions)}},
+ IndependencePairs(NumConditions), ExecVectors(ExecVectorsByCond[false]),
+ IsVersion11(IsVersion11) {}
private:
// Walk the binary decision diagram and try assigning both false and true to
@@ -485,7 +486,6 @@ class MCDCRecordProcessor : NextIDsBuilder, mcdc::TVIdxBuilder {
/// location is also tracked, as well as whether it is constant folded (in
/// which case it is excuded from the metric).
MCDCRecord processMCDCRecord() {
- unsigned I = 0;
MCDCRecord::CondIDMap PosToID;
MCDCRecord::LineColPairMap CondLoc;
@@ -499,11 +499,12 @@ class MCDCRecordProcessor : NextIDsBuilder, mcdc::TVIdxBuilder {
// visualize where the condition is.
// - Record whether the condition is constant folded so that we exclude it
// from being measured.
- for (const auto *B : Branches) {
+ for (auto [I, B] : enumerate(Branches)) {
const auto &BranchParams = B->getBranchParams();
PosToID[I] = BranchParams.ID;
CondLoc[I] = B->startLoc();
- Folded[I++] = (B->Count.isZero() || B->FalseCount.isZero());
+ Folded[false][I] = B->FalseCount.isZero();
+ Folded[true][I] = B->Count.isZero();
}
// Using Profile Bitmap from runtime, mark the executed test vectors.
More information about the llvm-commits
mailing list