diff options
author | NAKAMURA Takumi <geek4civic@gmail.com> | 2024-02-09 06:11:20 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-09 06:11:20 +0900 |
commit | 3f9d8d892e2de2ac2542cb8e88ae5317f3282244 (patch) | |
tree | 3bb6e0dc35fe60ea42dc803c111d25ce6fcbf530 /llvm/lib/ProfileData | |
parent | 5f4b40c90a51248b097de7b5bc89c6976d4c3298 (diff) | |
download | llvm-3f9d8d892e2de2ac2542cb8e88ae5317f3282244.zip llvm-3f9d8d892e2de2ac2542cb8e88ae5317f3282244.tar.gz llvm-3f9d8d892e2de2ac2542cb8e88ae5317f3282244.tar.bz2 |
[Coverage] MCDCRecordProcessor: Find `ExecVectors` directly (#80816)
Deprecate `TestVectors`, since no one uses it.
This affects the output order of ExecVectors.
The current impl emits sorted by binary value of ExecVector. This impl
emits along the traversal of `buildTestVector()`.
Diffstat (limited to 'llvm/lib/ProfileData')
-rw-r--r-- | llvm/lib/ProfileData/Coverage/CoverageMapping.cpp | 31 |
1 files changed, 11 insertions, 20 deletions
diff --git a/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp b/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp index 6b189c3..eb0996e 100644 --- a/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp +++ b/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp @@ -253,9 +253,6 @@ class MCDCRecordProcessor { /// Mapping of calculated MC/DC Independence Pairs for each condition. MCDCRecord::TVPairMap IndependencePairs; - /// Total number of possible Test Vectors for the boolean expression. - MCDCRecord::TestVectors TestVectors; - /// Actual executed Test Vectors for the boolean expression, based on /// ExecutedTestVectorBitmap. MCDCRecord::TestVectors ExecVectors; @@ -267,18 +264,20 @@ public: : Bitmap(Bitmap), Region(Region), Branches(Branches), NumConditions(Region.MCDCParams.NumConditions), BitmapIdx(Region.MCDCParams.BitmapIdx * CHAR_BIT), - Folded(NumConditions, false), IndependencePairs(NumConditions), - TestVectors((size_t)1 << NumConditions) {} + Folded(NumConditions, false), IndependencePairs(NumConditions) {} private: void recordTestVector(MCDCRecord::TestVector &TV, unsigned Index, MCDCRecord::CondState Result) { + if (!Bitmap[BitmapIdx + Index]) + return; + // Copy the completed test vector to the vector of testvectors. - TestVectors[Index] = TV; + 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). - TestVectors[Index].push_back(Result); + ExecVectors.back().push_back(Result); } // Walk the binary decision diagram and try assigning both false and true to @@ -308,13 +307,11 @@ private: /// Walk the bits in the bitmap. A bit set to '1' indicates that the test /// vector at the corresponding index was executed during a test run. void findExecutedTestVectors() { - for (unsigned Idx = 0; Idx < (1u << NumConditions); ++Idx) { - assert(BitmapIdx + Idx < Bitmap.size() && "Bitmap overrun"); - if (Bitmap[BitmapIdx + Idx] == 0) - continue; - assert(!TestVectors[Idx].empty() && "Test Vector doesn't exist."); - ExecVectors.push_back(TestVectors[Idx]); - } + // Walk the binary decision diagram to enumerate all possible test vectors. + // We start at the root node (ID == 1) with all values being DontCare. + // `Index` encodes the bitmask of true values and is initially 0. + MCDCRecord::TestVector TV(NumConditions, MCDCRecord::MCDC_DontCare); + buildTestVector(TV, 1, 0); } // Find an independence pair for each condition: @@ -380,12 +377,6 @@ public: Folded[I++] = (B->Count.isZero() && B->FalseCount.isZero()); } - // Walk the binary decision diagram to enumerate all possible test vectors. - // We start at the root node (ID == 1) with all values being DontCare. - // `Index` encodes the bitmask of true values and is initially 0. - MCDCRecord::TestVector TV(NumConditions, MCDCRecord::MCDC_DontCare); - buildTestVector(TV, 1, 0); - // Using Profile Bitmap from runtime, mark the executed test vectors. findExecutedTestVectors(); |