Skip to content

[Coverage] Sort MCDCRecord::ExecVectors order by Bitmap index #121195

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

Open
wants to merge 45 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
178b57c
[Coverage] Move SingleByteCoverage out of CountedRegion
chapuni Oct 2, 2024
aacb50d
[Coverage] Make SingleByteCoverage work consistent to merging
chapuni Oct 2, 2024
b9bbc7c
Rework. (Also reverts "[Coverage] Move SingleByteCoverage out of Cou…
chapuni Oct 5, 2024
52f072e
clang/test/CoverageMapping/single-byte-counters.cpp: Rewrite counter …
chapuni Oct 17, 2024
97a4a8f
test/llvm-cov: Transform %.c* tests to {%.test, Inputs/%.c*}
chapuni Nov 20, 2024
c50c492
Introduce test/llvm-cov/Inputs/yaml.makefile for convenience.
chapuni Nov 20, 2024
d7c5b44
Add tests for SingleByteCoverage
chapuni Nov 20, 2024
6675226
Merge branch 'users/chapuni/cov/single/test' into users/chapuni/cov/s…
chapuni Nov 20, 2024
5fc3408
Fix a test to fix linecount=1
chapuni Nov 20, 2024
eb7fff9
threads.c: Fixup on the clean testdir
chapuni Nov 20, 2024
7543095
Rename threads.c to threads.test since it is no longer C source file.
chapuni Nov 21, 2024
00ac90d
llvm/test/tools/llvm-cov/Inputs: Avoid wildcards `rm -rf %t*.dir`
chapuni Nov 21, 2024
fcb3ee8
Merge branch 'main' into users/chapuni/cov/single/test
chapuni Dec 21, 2024
5fa862a
Use `[[#min(C,n)]]` for tests
chapuni Dec 21, 2024
805e9a9
llvm-cov: Introduce `--binary-counters`
chapuni Dec 21, 2024
5b6c0b0
LLVMCoverage: Unify getCoverageForFile and getCoverageForFunction
chapuni Dec 21, 2024
68d7b3b
Merge branch 'users/chapuni/cov/single/test' into users/chapuni/cov/s…
chapuni Dec 21, 2024
24457a7
Update tests
chapuni Dec 21, 2024
805dbd9
Merge branches 'users/chapuni/cov/single/merge' and 'users/chapuni/co…
chapuni Dec 21, 2024
f96b435
New SingleByteCoverage
chapuni Dec 21, 2024
47550d1
threads.c => threads.test (following #113114)
chapuni Dec 22, 2024
f4dc4eb
s/Count1/BinaryCount/
chapuni Dec 23, 2024
822620b
Update desc
chapuni Dec 23, 2024
658bd48
Merge branch 'main' into users/chapuni/cov/binary
chapuni Dec 24, 2024
0780993
Merge branch 'users/chapuni/cov/binary' into users/chapuni/cov/single…
chapuni Dec 24, 2024
dfc99ba
Fix wrong merge resolutions
chapuni Dec 24, 2024
f3c9593
Reorganize CoverageMapping::SingleByteCoverage
chapuni Dec 24, 2024
3780e07
Prune commented-out line
chapuni Dec 24, 2024
36b4aaf
[Coverage] Make `MCDCRecord::Folded` as `[false/true]` with BitVector…
chapuni Dec 27, 2024
978070d
[Coverage] MCDC: Move `findIndependencePairs` into `MCDCRecord`
chapuni Dec 27, 2024
f42bb83
Merge branches 'users/chapuni/cov/merge/mcdcfold' and 'users/chapuni/…
chapuni Dec 27, 2024
3abe2ac
[Coverage] Sort `MCDCRecord::ExecVectors` order by Bitmap index
chapuni Dec 27, 2024
f86c537
llvm-cov: Refactor CoverageSummaryInfo. NFC.
chapuni Dec 27, 2024
2293b8d
Merge remote-tracking branches 'origin/users/chapuni/cov/single/refac…
chapuni Dec 27, 2024
894c383
Merge branch 'main' into users/chapuni/cov/single/refactor
chapuni Dec 27, 2024
7c26a2a
Merge branch 'main' into users/chapuni/cov/single/refactor
chapuni Dec 27, 2024
184dc0c
Merge branch 'users/chapuni/cov/single/refactor' into users/chapuni/c…
chapuni Dec 27, 2024
764b14b
Merge branch 'main' into users/chapuni/cov/merge/summaryinfo
chapuni Dec 28, 2024
85b1602
Merge branch 'users/chapuni/cov/merge/summaryinfo' into users/chapuni…
chapuni Dec 28, 2024
ad6726d
Merge branch 'main' into users/chapuni/cov/merge/mcdcsort-base
chapuni Jan 7, 2025
10517c4
Merge branch 'main' into users/chapuni/cov/single/unify
chapuni Jan 7, 2025
c33e898
Merge branch 'users/chapuni/cov/single/unify' into users/chapuni/cov/…
chapuni Jan 7, 2025
fa45418
Merge branch 'users/chapuni/cov/merge/mcdcsort-base' into users/chapu…
chapuni Jan 7, 2025
694a772
Revert "Merge branch 'users/chapuni/cov/single/unify' into users/chap…
chapuni Jan 7, 2025
8b02a27
Merge branch 'main' into users/chapuni/cov/merge/mcdcsort
chapuni Jan 10, 2025
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
40 changes: 27 additions & 13 deletions llvm/lib/ProfileData/Coverage/CoverageMapping.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -426,13 +426,27 @@ 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;
/// Helper for sorting ExecVectors.
struct TVIdxTuple {
MCDCRecord::CondState MCDCCond; /// True/False
unsigned BIdx; /// Bitmap Index
unsigned Ord; /// Last position on ExecVectors

TVIdxTuple(MCDCRecord::CondState MCDCCond, unsigned BIdx, unsigned Ord)
: MCDCCond(MCDCCond), BIdx(BIdx), Ord(Ord) {}

bool operator<(const TVIdxTuple &RHS) const {
return (std::tie(this->MCDCCond, this->BIdx, this->Ord) <
std::tie(RHS.MCDCCond, RHS.BIdx, RHS.Ord));
}
};

// Indices for sorted TestVectors;
std::vector<TVIdxTuple> ExecVectorIdxs;

/// Actual executed Test Vectors for the boolean expression, based on
/// ExecutedTestVectorBitmap.
MCDCRecord::TestVectors &ExecVectors;
MCDCRecord::TestVectors ExecVectors;

#ifndef NDEBUG
DenseSet<unsigned> TVIdxs;
Expand All @@ -449,8 +463,7 @@ class MCDCRecordProcessor : NextIDsBuilder, mcdc::TVIdxBuilder {
Region(Region), DecisionParams(Region.getDecisionParams()),
Branches(Branches), NumConditions(DecisionParams.NumConditions),
Folded{{BitVector(NumConditions), BitVector(NumConditions)}},
IndependencePairs(NumConditions), ExecVectors(ExecVectorsByCond[false]),
IsVersion11(IsVersion11) {}
IndependencePairs(NumConditions), IsVersion11(IsVersion11) {}

private:
// Walk the binary decision diagram and try assigning both false and true to
Expand Down Expand Up @@ -478,10 +491,12 @@ class MCDCRecordProcessor : NextIDsBuilder, mcdc::TVIdxBuilder {
: DecisionParams.BitmapIdx - NumTestVectors + NextTVIdx])
continue;

ExecVectorIdxs.emplace_back(MCDCCond, NextTVIdx, ExecVectors.size());

// Copy the completed test vector to the vector of testvectors.
// The final value (T,F) is equal to the last non-dontcare state on the
// path (in a short-circuiting system).
ExecVectorsByCond[MCDCCond].push_back({TV, MCDCCond});
ExecVectors.push_back({TV, MCDCCond});
}

// Reset back to DontCare.
Expand All @@ -500,12 +515,11 @@ class MCDCRecordProcessor : NextIDsBuilder, mcdc::TVIdxBuilder {
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.
auto &ExecVectorsT = ExecVectorsByCond[true];
ExecVectors.append(std::make_move_iterator(ExecVectorsT.begin()),
std::make_move_iterator(ExecVectorsT.end()));
llvm::sort(ExecVectorIdxs);
MCDCRecord::TestVectors NewTestVectors;
for (const auto &IdxTuple : ExecVectorIdxs)
NewTestVectors.push_back(std::move(ExecVectors[IdxTuple.Ord]));
ExecVectors = std::move(NewTestVectors);
}

public:
Expand Down
32 changes: 16 additions & 16 deletions llvm/test/tools/llvm-cov/mcdc-const.test
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@
// CHECKFULLCASE: | C1-Pair: constant folded
// CHECKFULLCASE-NEXT: | C2-Pair: not covered
// CHECKFULLCASE: | MC/DC Coverage for Decision: 0.00%
// CHECKFULLCASE: | 1 { F, C = T }
// CHECKFULLCASE-NEXT: | 2 { T, C = T }
// CHECKFULLCASE: | 1 { T, C = T }
// CHECKFULLCASE-NEXT: | 2 { F, C = T }
// CHECKFULLCASE: | C1-Pair: not covered
// CHECKFULLCASE-NEXT: | C2-Pair: constant folded
// CHECKFULLCASE: | MC/DC Coverage for Decision: 0.00%
Expand Down Expand Up @@ -106,20 +106,20 @@
// CHECKFULLCASE-NEXT: | C2-Pair: not covered
// CHECKFULLCASE-NEXT: | C3-Pair: not covered
// CHECKFULLCASE: | MC/DC Coverage for Decision: 0.00%
// CHECKFULLCASE: | 1 { F, C, - = T }
// CHECKFULLCASE-NEXT: | 2 { T, C, - = T }
// CHECKFULLCASE: | 1 { T, C, - = T }
// CHECKFULLCASE-NEXT: | 2 { F, C, - = T }
// CHECKFULLCASE: | C1-Pair: not covered
// CHECKFULLCASE-NEXT: | C2-Pair: constant folded
// CHECKFULLCASE-NEXT: | C3-Pair: not covered
// CHECKFULLCASE: | MC/DC Coverage for Decision: 0.00%
// CHECKFULLCASE: | 1 { C, F, T = T }
// CHECKFULLCASE-NEXT: | 2 { C, T, - = T }
// CHECKFULLCASE: | 1 { C, T, - = T }
// CHECKFULLCASE-NEXT: | 2 { C, F, T = T }
// CHECKFULLCASE: | C1-Pair: constant folded
// CHECKFULLCASE-NEXT: | C2-Pair: not covered
// CHECKFULLCASE-NEXT: | C3-Pair: not covered
// CHECKFULLCASE: | MC/DC Coverage for Decision: 0.00%
// CHECKFULLCASE: | 1 { F, C, T = T }
// CHECKFULLCASE-NEXT: | 2 { T, C, - = T }
// CHECKFULLCASE: | 1 { T, C, - = T }
// CHECKFULLCASE-NEXT: | 2 { F, C, T = T }
// CHECKFULLCASE: | C1-Pair: not covered
// CHECKFULLCASE-NEXT: | C2-Pair: constant folded
// CHECKFULLCASE-NEXT: | C3-Pair: not covered
Expand Down Expand Up @@ -151,26 +151,26 @@
// CHECKFULLCASE-NEXT: | C2-Pair: constant folded
// CHECKFULLCASE-NEXT: | C3-Pair: covered: (2,3)
// CHECKFULLCASE: | MC/DC Coverage for Decision: 100.00%
// CHECKFULLCASE: | 1 { F, T, C = T }
// CHECKFULLCASE-NEXT: | 2 { T, -, C = T }
// CHECKFULLCASE: | 1 { T, -, C = T }
// CHECKFULLCASE-NEXT: | 2 { F, T, C = T }
// CHECKFULLCASE: | C1-Pair: not covered
// CHECKFULLCASE-NEXT: | C2-Pair: not covered
// CHECKFULLCASE-NEXT: | C3-Pair: constant folded
// CHECKFULLCASE: | MC/DC Coverage for Decision: 0.00%
// CHECKFULLCASE: | 1 { F, C, - = T }
// CHECKFULLCASE-NEXT: | 2 { T, C, - = T }
// CHECKFULLCASE: | 1 { T, C, - = T }
// CHECKFULLCASE-NEXT: | 2 { F, C, - = T }
// CHECKFULLCASE: | C1-Pair: not covered
// CHECKFULLCASE-NEXT: | C2-Pair: constant folded
// CHECKFULLCASE-NEXT: | C3-Pair: not covered
// CHECKFULLCASE: | MC/DC Coverage for Decision: 0.00%
// CHECKFULLCASE: | 1 { F, T, C = T }
// CHECKFULLCASE-NEXT: | 2 { T, -, C = T }
// CHECKFULLCASE: | 1 { T, -, C = T }
// CHECKFULLCASE-NEXT: | 2 { F, T, C = T }
// CHECKFULLCASE: | C1-Pair: not covered
// CHECKFULLCASE-NEXT: | C2-Pair: not covered
// CHECKFULLCASE-NEXT: | C3-Pair: constant folded
// CHECKFULLCASE: | MC/DC Coverage for Decision: 0.00%
// CHECKFULLCASE: | 1 { F, C, T = T }
// CHECKFULLCASE-NEXT: | 2 { T, C, - = T }
// CHECKFULLCASE: | 1 { T, C, - = T }
// CHECKFULLCASE-NEXT: | 2 { F, C, T = T }
// CHECKFULLCASE: | C1-Pair: not covered
// CHECKFULLCASE-NEXT: | C2-Pair: constant folded
// CHECKFULLCASE-NEXT: | C3-Pair: not covered
Expand Down
8 changes: 4 additions & 4 deletions llvm/test/tools/llvm-cov/mcdc-general.test
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@
// CHECK-NEXT: |
// CHECK-NEXT: | C1, C2, C3, C4 Result
// CHECK-NEXT: | 1 { F, -, F, - = F }
// CHECK-NEXT: | 2 { F, -, T, F = F }
// CHECK-NEXT: | 3 { T, F, F, - = F }
// CHECK-NEXT: | 2 { T, F, F, - = F }
// CHECK-NEXT: | 3 { F, -, T, F = F }
// CHECK-NEXT: | 4 { T, F, T, F = F }
// CHECK-NEXT: | 5 { T, F, T, T = T }
// CHECK-NEXT: | 6 { T, T, -, - = T }
// CHECK-NEXT: |
// CHECK-NEXT: | C1-Pair: covered: (1,6)
// CHECK-NEXT: | C2-Pair: covered: (3,6)
// CHECK-NEXT: | C3-Pair: covered: (3,5)
// CHECK-NEXT: | C2-Pair: covered: (2,6)
// CHECK-NEXT: | C3-Pair: covered: (2,5)
// CHECK-NEXT: | C4-Pair: covered: (4,5)
// CHECK-NEXT: | MC/DC Coverage for Decision: 100.00%
// CHECK-NEXT: |
Expand Down
Loading