aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/ProfileData/Coverage/CoverageMapping.cpp')
-rw-r--r--llvm/lib/ProfileData/Coverage/CoverageMapping.cpp37
1 files changed, 25 insertions, 12 deletions
diff --git a/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp b/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp
index 3f892d7..6454516 100644
--- a/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp
+++ b/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp
@@ -370,9 +370,16 @@ class MCDCRecordProcessor : NextIDsBuilder, mcdc::TVIdxBuilder {
/// Mapping of calculated MC/DC Independence Pairs for each condition.
MCDCRecord::TVPairMap IndependencePairs;
+ /// Storage for ExecVectors
+ /// ExecVectors is the alias of its 0th element.
+ std::array<MCDCRecord::TestVectors, 2> ExecVectorsByCond;
+
/// Actual executed Test Vectors for the boolean expression, based on
/// ExecutedTestVectorBitmap.
- MCDCRecord::TestVectors ExecVectors;
+ MCDCRecord::TestVectors &ExecVectors;
+
+ /// Number of False items in ExecVectors
+ unsigned NumExecVectorsF;
#ifndef NDEBUG
DenseSet<unsigned> TVIdxs;
@@ -385,7 +392,8 @@ public:
: NextIDsBuilder(Branches), TVIdxBuilder(this->NextIDs), Bitmap(Bitmap),
Region(Region), DecisionParams(Region.getDecisionParams()),
Branches(Branches), NumConditions(DecisionParams.NumConditions),
- Folded(NumConditions, false), IndependencePairs(NumConditions) {}
+ Folded(NumConditions, false), IndependencePairs(NumConditions),
+ ExecVectors(ExecVectorsByCond[false]) {}
private:
// Walk the binary decision diagram and try assigning both false and true to
@@ -415,11 +423,9 @@ private:
continue;
// Copy the completed test vector to the vector of testvectors.
- ExecVectors.push_back(TV);
-
// The final value (T,F) is equal to the last non-dontcare state on the
// path (in a short-circuiting system).
- ExecVectors.back().push_back(MCDCCond);
+ ExecVectorsByCond[MCDCCond].push_back({TV, MCDCCond});
}
// Reset back to DontCare.
@@ -437,6 +443,14 @@ private:
buildTestVector(TV, 0, 0, 0);
assert(TVIdxs.size() == unsigned(NumTestVectors) &&
"TVIdxs wasn't fulfilled");
+
+ // Fill ExecVectors order by False items and True items.
+ // ExecVectors is the alias of ExecVectorsByCond[false], so
+ // Append ExecVectorsByCond[true] on it.
+ NumExecVectorsF = ExecVectors.size();
+ auto &ExecVectorsT = ExecVectorsByCond[true];
+ ExecVectors.append(std::make_move_iterator(ExecVectorsT.begin()),
+ std::make_move_iterator(ExecVectorsT.end()));
}
// Find an independence pair for each condition:
@@ -445,13 +459,12 @@ private:
// - All other conditions' values must be equal or marked as "don't care".
void findIndependencePairs() {
unsigned NumTVs = ExecVectors.size();
- for (unsigned I = 1; I < NumTVs; ++I) {
- const MCDCRecord::TestVector &A = ExecVectors[I];
- for (unsigned J = 0; J < I; ++J) {
- const MCDCRecord::TestVector &B = ExecVectors[J];
- // Enumerate two execution vectors whose outcomes are different.
- if (A[NumConditions] == B[NumConditions])
- continue;
+ for (unsigned I = NumExecVectorsF; I < NumTVs; ++I) {
+ const auto &[A, ACond] = ExecVectors[I];
+ assert(ACond == MCDCRecord::MCDC_True);
+ for (unsigned J = 0; J < NumExecVectorsF; ++J) {
+ const auto &[B, BCond] = ExecVectors[J];
+ assert(BCond == MCDCRecord::MCDC_False);
unsigned Flip = NumConditions, Idx;
for (Idx = 0; Idx < NumConditions; ++Idx) {
MCDCRecord::CondState ACond = A[Idx], BCond = B[Idx];