aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp
diff options
context:
space:
mode:
authorHans Wennborg <hans@chromium.org>2024-06-14 10:32:39 +0200
committerHans Wennborg <hans@chromium.org>2024-06-14 10:47:41 +0200
commitb422fa6b62160f5eeb038d816d05e039182dde56 (patch)
tree1facf1d549693b6e685af22a7eebbe8b4db9daa4 /llvm/lib/ProfileData/Coverage/CoverageMapping.cpp
parent880d37038c7bbff53ef02c9d6b01cbbc87875243 (diff)
downloadllvm-b422fa6b62160f5eeb038d816d05e039182dde56.zip
llvm-b422fa6b62160f5eeb038d816d05e039182dde56.tar.gz
llvm-b422fa6b62160f5eeb038d816d05e039182dde56.tar.bz2
Revert "[MC/DC][Coverage] Loosen the limit of NumConds from 6 (#82448)"
This broke the lit tests on Mac: https://green.lab.llvm.org/job/llvm.org/job/clang-stage1-RA/1096/ > By storing possible test vectors instead of combinations of conditions, > the restriction is dramatically relaxed. > > This introduces two options to `cc1`: > > * `-fmcdc-max-conditions=32767` > * `-fmcdc-max-test-vectors=2147483646` > > This change makes coverage mapping, profraw, and profdata incompatible > with Clang-18. > > - Bitmap semantics changed. It is incompatible with previous format. > - `BitmapIdx` in `Decision` points to the end of the bitmap. > - Bitmap is packed per function. > - `llvm-cov` can understand `profdata` generated by `llvm-profdata-18`. > > RFC: > https://discourse.llvm.org/t/rfc-coverage-new-algorithm-and-file-format-for-mc-dc/76798 This reverts commit 7ead2d8c7e9114b3f23666209a1654939987cb30.
Diffstat (limited to 'llvm/lib/ProfileData/Coverage/CoverageMapping.cpp')
-rw-r--r--llvm/lib/ProfileData/Coverage/CoverageMapping.cpp34
1 files changed, 11 insertions, 23 deletions
diff --git a/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp b/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp
index 455124e..8c81bbe8 100644
--- a/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp
+++ b/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp
@@ -384,18 +384,15 @@ class MCDCRecordProcessor : NextIDsBuilder, mcdc::TVIdxBuilder {
DenseSet<unsigned> TVIdxs;
#endif
- bool IsVersion11;
-
public:
MCDCRecordProcessor(const BitVector &Bitmap,
const CounterMappingRegion &Region,
- ArrayRef<const CounterMappingRegion *> Branches,
- bool IsVersion11)
+ ArrayRef<const CounterMappingRegion *> Branches)
: 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]), IsVersion11(IsVersion11) {}
+ ExecVectors(ExecVectorsByCond[false]) {}
private:
// Walk the binary decision diagram and try assigning both false and true to
@@ -418,9 +415,7 @@ private:
assert(TVIdx < SavedNodes[ID].Width);
assert(TVIdxs.insert(NextTVIdx).second && "Duplicate TVIdx");
- if (!Bitmap[IsVersion11
- ? DecisionParams.BitmapIdx * CHAR_BIT + TV.getIndex()
- : DecisionParams.BitmapIdx - NumTestVectors + NextTVIdx])
+ if (!Bitmap[DecisionParams.BitmapIdx * CHAR_BIT + TV.getIndex()])
continue;
// Copy the completed test vector to the vector of testvectors.
@@ -526,9 +521,9 @@ public:
Expected<MCDCRecord> CounterMappingContext::evaluateMCDCRegion(
const CounterMappingRegion &Region,
- ArrayRef<const CounterMappingRegion *> Branches, bool IsVersion11) {
+ ArrayRef<const CounterMappingRegion *> Branches) {
- MCDCRecordProcessor MCDCProcessor(Bitmap, Region, Branches, IsVersion11);
+ MCDCRecordProcessor MCDCProcessor(Bitmap, Region, Branches);
return MCDCProcessor.processMCDCRecord();
}
@@ -615,8 +610,8 @@ static unsigned getMaxCounterID(const CounterMappingContext &Ctx,
}
/// Returns the bit count
-static unsigned getMaxBitmapSize(const CoverageMappingRecord &Record,
- bool IsVersion11) {
+static unsigned getMaxBitmapSize(const CounterMappingContext &Ctx,
+ const CoverageMappingRecord &Record) {
unsigned MaxBitmapIdx = 0;
unsigned NumConditions = 0;
// Scan max(BitmapIdx).
@@ -631,12 +626,8 @@ static unsigned getMaxBitmapSize(const CoverageMappingRecord &Record,
NumConditions = DecisionParams.NumConditions;
}
}
-
- if (IsVersion11)
- MaxBitmapIdx = MaxBitmapIdx * CHAR_BIT +
- llvm::alignTo(uint64_t(1) << NumConditions, CHAR_BIT);
-
- return MaxBitmapIdx;
+ unsigned SizeInBits = llvm::alignTo(uint64_t(1) << NumConditions, CHAR_BIT);
+ return MaxBitmapIdx * CHAR_BIT + SizeInBits;
}
namespace {
@@ -824,9 +815,6 @@ 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)) {
@@ -838,7 +826,7 @@ Error CoverageMapping::loadFunctionRecord(
}
if (IPE != instrprof_error::unknown_function)
return make_error<InstrProfError>(IPE);
- Bitmap = BitVector(getMaxBitmapSize(Record, IsVersion11));
+ Bitmap = BitVector(getMaxBitmapSize(Ctx, Record));
}
Ctx.setBitmap(std::move(Bitmap));
@@ -896,7 +884,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, IsVersion11);
+ Ctx.evaluateMCDCRegion(*MCDCDecision, MCDCBranches);
if (auto E = Record.takeError()) {
consumeError(std::move(E));
return Error::success();