Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MC/DC][Coverage] Loosen the limit of NumConds from 6 #82448

Merged
merged 48 commits into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
d168e0c
Implement MCDCTVIdxBuilder and MCDCTestVectorBuilder (LLVM side)
chapuni Feb 4, 2024
35b19ea
Revert "Implement MCDCTVIdxBuilder and MCDCTestVectorBuilder (LLVM si…
chapuni Feb 6, 2024
8c777eb
[Coverage] MCDCRecordProcessor: Find `ExecVectors` directly
chapuni Feb 6, 2024
56042d3
Merge branch 'mcdc/xv' into HEAD
chapuni Feb 6, 2024
5432aec
Implement MCDCTVIdxBuilder (LLVM side)
chapuni Feb 4, 2024
3ee8a61
Update comments and assertions
chapuni Feb 6, 2024
2fd504a
Merge remote-tracking branch 'origin/main' into mcdc/tvidx
chapuni Feb 8, 2024
1f0f3fc
Reorganize TVIdxBuilder
chapuni Feb 12, 2024
06c0801
Merge remote-tracking branch 'origin/main' into mcdc/tvidx
chapuni Feb 13, 2024
aa5b2f5
Merge remote-tracking branch 'origin/main' into HEAD
chapuni Feb 15, 2024
e3de647
[CoverageMapping] Refactor `mcdc::TVIdxBuilder`
chapuni Feb 15, 2024
753d0ad
remove <functional>
chapuni Feb 15, 2024
17cbac7
Update comments.
chapuni Feb 21, 2024
1a4ffa7
Add unittest
chapuni Feb 21, 2024
b5ecfcc
[MC/DC][Coverage] Loosen the limit of NumConds from 6
chapuni Feb 15, 2024
0ffad9c
Update testcases
chapuni Feb 21, 2024
c96fd2c
Use llvm::sort
chapuni Feb 21, 2024
357a693
EXPECT_
chapuni Feb 21, 2024
83d104c
Merge branch 'mcdc/tvidx' into HEAD
chapuni Feb 21, 2024
14c795e
Hide NConds
chapuni Feb 21, 2024
b6c1174
Merge remote-tracking branch 'chapuni/main' into mcdc/tvidx
chapuni Feb 25, 2024
cf936f6
Merge branch 'users/chapuni/mcdc/tvidx' into HEAD
chapuni Feb 25, 2024
662bdd6
Reformat
chapuni Feb 25, 2024
ac16655
Merge remote-tracking branch 'origin/main' into mcdc/clangtvidx
chapuni Feb 26, 2024
90bf8e9
Clarify bool
chapuni Feb 26, 2024
9eb6951
Update comments
chapuni Feb 26, 2024
86d67c6
Use MutableArrayRef :)
chapuni Feb 26, 2024
01abca2
Merge remote-tracking branch 'origin/main' into mcdc/clangtvidx
chapuni Feb 27, 2024
183c706
Merge branch 'main' into mcdc/clangtvidx
chapuni Apr 19, 2024
dd6f8be
Clarify 3rd arg of mcdc.tvbitmap.update is unused
chapuni May 9, 2024
cdd5531
Modify 3rd arg of mcdc.parameters to bits
chapuni May 8, 2024
54e6044
isMCDCBranch: Remove assert
chapuni May 9, 2024
b1a7100
isMCDCDecision: Remove assert
chapuni May 9, 2024
39802c5
Make llvm-cov capable of clang-18's profdata
chapuni May 14, 2024
f54c64d
Fix unittest
chapuni May 15, 2024
a6f7eef
Introduce `-fmcdc-max-conditions` and `-fmcdc-max-test-vectors`
chapuni May 16, 2024
0dd7ead
Merge branch 'main' into HEAD
chapuni May 20, 2024
cf837ae
mcdc-system-headers.cpp: Update
chapuni May 20, 2024
9e14c2a
llvm-cov tests for old (Version11) files
chapuni May 20, 2024
04f18ae
Merge branch 'main' into mcdc/clangtvidx
chapuni May 27, 2024
3ff3eb7
Update CoverageMapping/mcdc-scratch-space.c
chapuni May 27, 2024
296f5c5
Don't create tvbitmap_update if the record is allocated but excluded.
chapuni May 27, 2024
722424b
Update mcdc-error-conditions.cpp
chapuni Jun 10, 2024
183bc52
Update documents
chapuni Jun 10, 2024
83088f1
mcdc.tvupdate doesn't depend on condupdate
chapuni Jun 10, 2024
40872f5
Update SourceBasedCodeCoverage.rst
chapuni Jun 11, 2024
be5b28b
SourceBasedCodeCoverage.rst: s/you/users/
chapuni Jun 11, 2024
450d86b
SourceBasedCodeCoverage.rst: Clarify to be excluded.
chapuni Jun 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge remote-tracking branch 'origin/main' into HEAD
  • Loading branch information
chapuni committed Feb 15, 2024
commit aa5b2f5c6401df8ae68caab5b1de13da727ce6f6
6 changes: 3 additions & 3 deletions llvm/include/llvm/ProfileData/Coverage/CoverageMapping.h
Original file line number Diff line number Diff line change
Expand Up @@ -579,9 +579,9 @@ class MCDCTVIdxBuilder {

public:
/// Inputs: to gather MCDCBranch-like ID to construct the BDD.
using NodeIDs = std::tuple<mcdc::ConditionID, // ID1 (ends with 0)
mcdc::ConditionID, // ID1 for False
mcdc::ConditionID // ID1 for True
using NodeIDs = std::tuple<mcdc::ConditionID, // ID (ends with -1)
mcdc::ConditionID, // ID for False
mcdc::ConditionID // ID for True
>;

/// Calculate and assign Indices
Expand Down
78 changes: 37 additions & 41 deletions llvm/lib/ProfileData/Coverage/CoverageMapping.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,19 +226,18 @@ Expected<int64_t> CounterMappingContext::evaluate(const Counter &C) const {
MCDCTVIdxBuilder::MCDCTVIdxBuilder(
std::function<NodeIDs(bool TellSize)> Fetcher, int Offset) {
// Construct Nodes and set up each InCount
int MaxID = -1;
mcdc::ConditionID MaxID = -1;
auto N = std::get<0>(Fetcher(true));
SmallVector<MCDCNode> Nodes(N);
Indices.resize(N);
while (true) {
auto [ID1, FalseID1, TrueID1] = Fetcher(false);
if (ID1 == 0)
auto [ID, FalseID, TrueID] = Fetcher(false);
if (ID < 0)
break;
int ID = ID1 - 1;
MaxID = std::max(MaxID, ID);
auto &Node = Nodes[ID];
Node.NextIDs[0] = FalseID1 - 1;
Node.NextIDs[1] = TrueID1 - 1;
Node.NextIDs[0] = FalseID;
Node.NextIDs[1] = TrueID;
for (unsigned I = 0; I < 2; ++I) {
#ifndef NDEBUG
Indices[ID][I] = INT_MIN;
Expand Down Expand Up @@ -350,9 +349,9 @@ class BranchProvider {
if (TellSize)
return NodeIDs(Branches.size(), 0, 0);
if (BranchIdx >= Branches.size())
return NodeIDs(0, 0, 0);
return NodeIDs(-1, 0, 0);
const auto &B = Branches[BranchIdx++]->getBranchParams();
return NodeIDs(B.ID, B.FalseID, B.TrueID);
return NodeIDs(B.ID, B.Conds[false], B.Conds[true]);
};
}
};
Expand All @@ -377,8 +376,8 @@ class MCDCRecordProcessor : MCDCTVIdxBuilder {

unsigned BitmapIdx;

/// Mapping of a condition ID to its corresponding branch region.
llvm::DenseMap<int, std::array<int, 2>> NextIDsMap;
/// Mapping of a condition ID to its corresponding branch params.
llvm::DenseMap<mcdc::ConditionID, mcdc::ConditionIDs> NextIDsMap;

/// Vector used to track whether a condition is constant folded.
MCDCRecord::BoolVector Folded;
Expand All @@ -405,40 +404,38 @@ class MCDCRecordProcessor : MCDCTVIdxBuilder {
Folded(NumConditions, false), IndependencePairs(NumConditions) {}

private:
void recordTestVector(MCDCRecord::TestVector &TV, int TVIdx, unsigned Index,
MCDCRecord::CondState Result) {
assert(TVIdxs.insert(TVIdx).second && "Duplicate TVIdx");

if (!Bitmap[BitmapIdx + Index])
return;

// 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(Result);
}

// Walk the binary decision diagram and try assigning both false and true to
// each node. When a terminal node (ID == 0) is reached, fill in the value in
// the truth table.
void buildTestVector(MCDCRecord::TestVector &TV, int ID, int TVIdx,
unsigned Index) {
const auto &NextIDs = NextIDsMap[ID];

for (unsigned I = 0; I < 2; ++I) {
auto MCDCCond = (I ? MCDCRecord::MCDC_True : MCDCRecord::MCDC_False);
auto NextID = NextIDs[I];
assert(NextID == SavedNodes[ID].NextIDs[I]);
Index |= I << ID;
void buildTestVector(MCDCRecord::TestVector &TV, mcdc::ConditionID ID,
int TVIdx, unsigned Index) {
assert((Index & (1 << ID)) == 0);

for (auto MCDCCond : {MCDCRecord::MCDC_False, MCDCRecord::MCDC_True}) {
static_assert(MCDCRecord::MCDC_False == 0);
static_assert(MCDCRecord::MCDC_True == 1);
Index |= MCDCCond << ID;
TV[ID] = MCDCCond;
auto NextID = NextIDsMap[ID][MCDCCond];
auto NextTVIdx = TVIdx + Indices[ID][MCDCCond];
assert(NextID == SavedNodes[ID].NextIDs[MCDCCond]);
if (NextID >= 0) {
buildTestVector(TV, NextID, TVIdx + Indices[ID][I], Index);
} else {
assert(TVIdx < SavedNodes[ID].Width);
recordTestVector(TV, Indices[ID][I] + TVIdx, Index, MCDCCond);
buildTestVector(TV, NextID, NextTVIdx, Index);
continue;
}

assert(TVIdx < SavedNodes[ID].Width);
assert(TVIdxs.insert(NextTVIdx).second && "Duplicate TVIdx");

if (!Bitmap[BitmapIdx + Index])
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);
}

// Reset back to DontCare.
Expand Down Expand Up @@ -516,9 +513,8 @@ class MCDCRecordProcessor : MCDCTVIdxBuilder {
// from being measured.
for (const auto *B : Branches) {
const auto &BranchParams = B->getBranchParams();
NextIDsMap[BranchParams.ID - 1] = {int(BranchParams.FalseID) - 1,
int(BranchParams.TrueID) - 1};
PosToID[I] = BranchParams.ID - 1;
NextIDsMap[BranchParams.ID] = BranchParams.Conds;
PosToID[I] = BranchParams.ID;
CondLoc[I] = B->startLoc();
Folded[I++] = (B->Count.isZero() && B->FalseCount.isZero());
}
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.