Skip to content

Commit 36b4aaf

Browse files
committed
[Coverage] Make MCDCRecord::Folded as [false/true] with BitVector. NFC.
1 parent 3d9f968 commit 36b4aaf

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

llvm/include/llvm/ProfileData/Coverage/CoverageMapping.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ struct MCDCRecord {
442442
};
443443

444444
using TestVectors = llvm::SmallVector<std::pair<TestVector, CondState>>;
445-
using BoolVector = llvm::SmallVector<bool>;
445+
using BoolVector = std::array<BitVector, 2>;
446446
using TVRowPair = std::pair<unsigned, unsigned>;
447447
using TVPairMap = llvm::DenseMap<unsigned, TVRowPair>;
448448
using CondIDMap = llvm::DenseMap<unsigned, unsigned>;
@@ -470,7 +470,9 @@ struct MCDCRecord {
470470
return Region.getDecisionParams().NumConditions;
471471
}
472472
unsigned getNumTestVectors() const { return TV.size(); }
473-
bool isCondFolded(unsigned Condition) const { return Folded[Condition]; }
473+
bool isCondFolded(unsigned Condition) const {
474+
return Folded[false][Condition] || Folded[true][Condition];
475+
}
474476

475477
/// Return the evaluation of a condition (indicated by Condition) in an
476478
/// executed test vector (indicated by TestVectorIndex), which will be True,

llvm/lib/ProfileData/Coverage/CoverageMapping.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -392,8 +392,9 @@ class MCDCRecordProcessor : NextIDsBuilder, mcdc::TVIdxBuilder {
392392
: NextIDsBuilder(Branches), TVIdxBuilder(this->NextIDs), Bitmap(Bitmap),
393393
Region(Region), DecisionParams(Region.getDecisionParams()),
394394
Branches(Branches), NumConditions(DecisionParams.NumConditions),
395-
Folded(NumConditions, false), IndependencePairs(NumConditions),
396-
ExecVectors(ExecVectorsByCond[false]), IsVersion11(IsVersion11) {}
395+
Folded{{BitVector(NumConditions), BitVector(NumConditions)}},
396+
IndependencePairs(NumConditions), ExecVectors(ExecVectorsByCond[false]),
397+
IsVersion11(IsVersion11) {}
397398

398399
private:
399400
// Walk the binary decision diagram and try assigning both false and true to
@@ -485,7 +486,6 @@ class MCDCRecordProcessor : NextIDsBuilder, mcdc::TVIdxBuilder {
485486
/// location is also tracked, as well as whether it is constant folded (in
486487
/// which case it is excuded from the metric).
487488
MCDCRecord processMCDCRecord() {
488-
unsigned I = 0;
489489
MCDCRecord::CondIDMap PosToID;
490490
MCDCRecord::LineColPairMap CondLoc;
491491

@@ -499,11 +499,12 @@ class MCDCRecordProcessor : NextIDsBuilder, mcdc::TVIdxBuilder {
499499
// visualize where the condition is.
500500
// - Record whether the condition is constant folded so that we exclude it
501501
// from being measured.
502-
for (const auto *B : Branches) {
502+
for (auto [I, B] : enumerate(Branches)) {
503503
const auto &BranchParams = B->getBranchParams();
504504
PosToID[I] = BranchParams.ID;
505505
CondLoc[I] = B->startLoc();
506-
Folded[I++] = (B->Count.isZero() || B->FalseCount.isZero());
506+
Folded[false][I] = B->FalseCount.isZero();
507+
Folded[true][I] = B->Count.isZero();
507508
}
508509

509510
// Using Profile Bitmap from runtime, mark the executed test vectors.

0 commit comments

Comments
 (0)