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
Make llvm-cov capable of clang-18's profdata
  • Loading branch information
chapuni committed May 14, 2024
commit 39802c5daa26921886b449e2359daf26c8f7bc82
3 changes: 2 additions & 1 deletion llvm/include/llvm/ProfileData/Coverage/CoverageMapping.h
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,8 @@ class CounterMappingContext {
/// pairs.
Expected<MCDCRecord>
evaluateMCDCRegion(const CounterMappingRegion &Region,
ArrayRef<const CounterMappingRegion *> Branches);
ArrayRef<const CounterMappingRegion *> Branches,
bool IsVersion11);

unsigned getMaxCounterID(const Counter &C) const;
};
Expand Down
2 changes: 1 addition & 1 deletion llvm/include/llvm/ProfileData/InstrProf.h
Original file line number Diff line number Diff line change
Expand Up @@ -1144,7 +1144,7 @@ enum ProfVersion {
Version10 = 10,
// An additional field is used for bitmap bytes.
Version11 = 11,
// VTable profiling,
// VTable profiling, decision record and bitmap are modified for mcdc.
Version12 = 12,
// The current version is 12.
CurrentVersion = INSTR_PROF_INDEX_VERSION
Expand Down
45 changes: 33 additions & 12 deletions llvm/lib/ProfileData/Coverage/CoverageMapping.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -385,15 +385,18 @@ class MCDCRecordProcessor : NextIDsBuilder, mcdc::TVIdxBuilder {
DenseSet<unsigned> TVIdxs;
#endif

bool IsVersion11;

public:
MCDCRecordProcessor(const BitVector &Bitmap,
const CounterMappingRegion &Region,
ArrayRef<const CounterMappingRegion *> Branches)
ArrayRef<const CounterMappingRegion *> Branches,
bool IsVersion11)
: 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]) {}
ExecVectors(ExecVectorsByCond[false]), IsVersion11(IsVersion11) {}

private:
// Walk the binary decision diagram and try assigning both false and true to
Expand All @@ -416,7 +419,9 @@ class MCDCRecordProcessor : NextIDsBuilder, mcdc::TVIdxBuilder {
assert(TVIdx < SavedNodes[ID].Width);
assert(TVIdxs.insert(NextTVIdx).second && "Duplicate TVIdx");

if (!Bitmap[DecisionParams.BitmapIdx - NumTestVectors + NextTVIdx])
if (!Bitmap[IsVersion11
? DecisionParams.BitmapIdx * CHAR_BIT + TV.getIndex()
: DecisionParams.BitmapIdx - NumTestVectors + NextTVIdx])
continue;

// Copy the completed test vector to the vector of testvectors.
Expand Down Expand Up @@ -522,9 +527,9 @@ class MCDCRecordProcessor : NextIDsBuilder, mcdc::TVIdxBuilder {

Expected<MCDCRecord> CounterMappingContext::evaluateMCDCRegion(
const CounterMappingRegion &Region,
ArrayRef<const CounterMappingRegion *> Branches) {
ArrayRef<const CounterMappingRegion *> Branches, bool IsVersion11) {

MCDCRecordProcessor MCDCProcessor(Bitmap, Region, Branches);
MCDCRecordProcessor MCDCProcessor(Bitmap, Region, Branches, IsVersion11);
return MCDCProcessor.processMCDCRecord();
}

Expand Down Expand Up @@ -611,14 +616,27 @@ static unsigned getMaxCounterID(const CounterMappingContext &Ctx,
}

/// Returns the bit count
static unsigned getMaxBitmapSize(const CounterMappingContext &Ctx,
const CoverageMappingRecord &Record) {
static unsigned getMaxBitmapSize(const CoverageMappingRecord &Record,
bool IsVersion11) {
unsigned MaxBitmapIdx = 0;
unsigned NumConditions = 0;
// Scan max(BitmapIdx).
// Note that `<=` is used insted of `<`, because `BitmapIdx == 0` is valid
// and `MaxBitmapIdx is `unsigned`. `BitmapIdx` is unique in the record.
for (const auto &Region : reverse(Record.MappingRegions)) {
if (Region.Kind == CounterMappingRegion::MCDCDecisionRegion)
MaxBitmapIdx =
std::max(MaxBitmapIdx, Region.getDecisionParams().BitmapIdx);
if (Region.Kind != CounterMappingRegion::MCDCDecisionRegion)
continue;
const auto &DecisionParams = Region.getDecisionParams();
if (MaxBitmapIdx <= DecisionParams.BitmapIdx) {
MaxBitmapIdx = DecisionParams.BitmapIdx;
NumConditions = DecisionParams.NumConditions;
}
}

if (IsVersion11)
MaxBitmapIdx = MaxBitmapIdx * CHAR_BIT +
llvm::alignTo(uint64_t(1) << NumConditions, CHAR_BIT);

return MaxBitmapIdx;
}

Expand Down Expand Up @@ -808,6 +826,9 @@ Error CoverageMapping::loadFunctionRecord(
}
Ctx.setCounts(Counts);

bool IsVersion11 =
ProfileReader.getVersion() < IndexedInstrProf::ProfVersion::Version12;

BitVector Bitmap;
if (Error E = ProfileReader.getFunctionBitmap(Record.FunctionName,
Record.FunctionHash, Bitmap)) {
Expand All @@ -819,7 +840,7 @@ Error CoverageMapping::loadFunctionRecord(
}
if (IPE != instrprof_error::unknown_function)
return make_error<InstrProfError>(IPE);
Bitmap = BitVector(getMaxBitmapSize(Ctx, Record));
Bitmap = BitVector(getMaxBitmapSize(Record, IsVersion11));
}
Ctx.setBitmap(std::move(Bitmap));

Expand Down Expand Up @@ -877,7 +898,7 @@ Error CoverageMapping::loadFunctionRecord(
// DecisionRegion, all of the information is now available to process.
// This is where the bulk of the MC/DC progressing takes place.
Expected<MCDCRecord> Record =
Ctx.evaluateMCDCRegion(*MCDCDecision, MCDCBranches);
Ctx.evaluateMCDCRegion(*MCDCDecision, MCDCBranches, IsVersion11);
if (auto E = Record.takeError()) {
consumeError(std::move(E));
return Error::success();
Expand Down
Loading