Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 4 additions & 2 deletions llvm/include/llvm/ProfileData/Coverage/CoverageMapping.h
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ struct MCDCRecord {
};

using TestVectors = llvm::SmallVector<std::pair<TestVector, CondState>>;
using BoolVector = llvm::SmallVector<bool>;
using BoolVector = std::array<BitVector, 2>;
using TVRowPair = std::pair<unsigned, unsigned>;
using TVPairMap = llvm::DenseMap<unsigned, TVRowPair>;
using CondIDMap = llvm::DenseMap<unsigned, unsigned>;
Expand Down Expand Up @@ -470,7 +470,9 @@ struct MCDCRecord {
return Region.getDecisionParams().NumConditions;
}
unsigned getNumTestVectors() const { return TV.size(); }
bool isCondFolded(unsigned Condition) const { return Folded[Condition]; }
bool isCondFolded(unsigned Condition) const {
return Folded[false][Condition] || Folded[true][Condition];
}

/// Return the evaluation of a condition (indicated by Condition) in an
/// executed test vector (indicated by TestVectorIndex), which will be True,
Expand Down
11 changes: 6 additions & 5 deletions llvm/lib/ProfileData/Coverage/CoverageMapping.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -392,8 +392,9 @@ class MCDCRecordProcessor : NextIDsBuilder, mcdc::TVIdxBuilder {
: 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) {}
Folded{{BitVector(NumConditions), BitVector(NumConditions)}},
IndependencePairs(NumConditions), ExecVectors(ExecVectorsByCond[false]),
IsVersion11(IsVersion11) {}

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

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

// Using Profile Bitmap from runtime, mark the executed test vectors.
Expand Down
Loading