Skip to content

Commit d4518a4

Browse files
committed
Merge branches 'users/chapuni/cov/single/getpair' and 'users/chapuni/cov/single/replace' into users/chapuni/cov/single/nextcount-base
3 parents 12abd89 + ad13691 + f0afd04 commit d4518a4

File tree

2 files changed

+6
-13
lines changed

2 files changed

+6
-13
lines changed

clang/lib/CodeGen/CoverageMappingGen.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1795,10 +1795,7 @@ struct CounterCoverageMappingBuilder
17951795
if (llvm::EnableSingleByteCoverage)
17961796
OutCount = getRegionCounter(S);
17971797
else {
1798-
LoopCount =
1799-
(ParentCount.isZero()
1800-
? ParentCount
1801-
: addCounters(ParentCount, BackedgeCount, BC.ContinueCount));
1798+
LoopCount = addCounters(ParentCount, BackedgeCount, BC.ContinueCount);
18021799
auto [ExecCount, SkipCount] = getBranchCounterPair(S, LoopCount);
18031800
ExitCount = SkipCount;
18041801
assert(ExecCount.isZero() || ExecCount == BodyCount);
@@ -1834,9 +1831,7 @@ struct CounterCoverageMappingBuilder
18341831
fillGapAreaWithCount(Gap->getBegin(), Gap->getEnd(), BodyCount);
18351832

18361833
Counter LoopCount =
1837-
(ParentCount.isZero()
1838-
? ParentCount
1839-
: addCounters(ParentCount, BackedgeCount, BC.ContinueCount));
1834+
addCounters(ParentCount, BackedgeCount, BC.ContinueCount);
18401835
auto [ExecCount, ExitCount] = getBranchCounterPair(S, LoopCount);
18411836
assert(ExecCount.isZero() || ExecCount == BodyCount);
18421837
Counter OutCount = addCounters(BC.BreakCount, ExitCount);

llvm/lib/ProfileData/Coverage/CoverageMapping.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -136,16 +136,14 @@ Counter CounterExpressionBuilder::subtract(Counter LHS, Counter RHS,
136136
}
137137

138138
Counter CounterExpressionBuilder::replace(Counter C, const ReplaceMap &Map) {
139-
auto I = Map.find(C);
140-
141-
// Replace C with the Map even if C is Expression.
142-
if (I != Map.end())
139+
// Replace C with the value found in Map even if C is Expression.
140+
if (auto I = Map.find(C); I != Map.end())
143141
return I->second;
144142

145-
// Traverse only Expression.
146143
if (!C.isExpression())
147144
return C;
148145

146+
// Traverse both sides of Expression.
149147
auto CE = Expressions[C.getExpressionID()];
150148
auto NewLHS = replace(CE.LHS, Map);
151149
auto NewRHS = replace(CE.RHS, Map);
@@ -161,7 +159,7 @@ Counter CounterExpressionBuilder::replace(Counter C, const ReplaceMap &Map) {
161159
}
162160

163161
// Reconfirm if the reconstructed expression would hit the Map.
164-
if ((I = Map.find(C)) != Map.end())
162+
if (auto I = Map.find(C); I != Map.end())
165163
return I->second;
166164

167165
return C;

0 commit comments

Comments
 (0)