[clang] 599c2a0 - [Coverage][Single] Enable Branch coverage for loop statements (#113109)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Jan 28 14:46:23 PST 2026
Author: NAKAMURA Takumi
Date: 2026-01-29T07:46:19+09:00
New Revision: 599c2a006324ef42cceb0fd1c626e767a4cbbef8
URL: https://github.com/llvm/llvm-project/commit/599c2a006324ef42cceb0fd1c626e767a4cbbef8
DIFF: https://github.com/llvm/llvm-project/commit/599c2a006324ef42cceb0fd1c626e767a4cbbef8.diff
LOG: [Coverage][Single] Enable Branch coverage for loop statements (#113109)
Depends on: #112730 #113114
https://discourse.llvm.org/t/rfc-integrating-singlebytecoverage-with-branch-coverage/82492
Added:
Modified:
clang/lib/CodeGen/CGStmt.cpp
clang/lib/CodeGen/CodeGenFunction.cpp
clang/lib/CodeGen/CodeGenPGO.cpp
clang/lib/CodeGen/CoverageMappingGen.cpp
clang/test/CoverageMapping/single-byte-counters.cpp
llvm/test/tools/llvm-cov/Inputs/branch-c-general-single.proftext
llvm/test/tools/llvm-cov/Inputs/branch-c-general-single.yaml
llvm/test/tools/llvm-cov/Inputs/branch-c-general.c
llvm/test/tools/llvm-cov/Inputs/showLineExecutionCounts-single.proftext
llvm/test/tools/llvm-cov/Inputs/showLineExecutionCounts-single.yaml
Removed:
################################################################################
diff --git a/clang/lib/CodeGen/CGStmt.cpp b/clang/lib/CodeGen/CGStmt.cpp
index cf5ddb78c3a1d..fe509c47977cf 100644
--- a/clang/lib/CodeGen/CGStmt.cpp
+++ b/clang/lib/CodeGen/CGStmt.cpp
@@ -1123,15 +1123,11 @@ void CodeGenFunction::EmitWhileStmt(const WhileStmt &S,
SourceLocToDebugLoc(R.getEnd()),
checkIfLoopMustProgress(S.getCond(), hasEmptyLoopBody(S)));
- // When single byte coverage mode is enabled, add a counter to loop condition.
- if (llvm::EnableSingleByteCoverage)
- incrementProfileCounter(S.getCond());
-
// As long as the condition is true, go to the loop body.
llvm::BasicBlock *LoopBody = createBasicBlock("while.body");
if (EmitBoolCondBranch) {
llvm::BasicBlock *ExitBlock = LoopExit.getBlock();
- if (ConditionScope.requiresCleanups())
+ if (hasSkipCounter(&S) || ConditionScope.requiresCleanups())
ExitBlock = createBasicBlock("while.exit");
llvm::MDNode *Weights =
createProfileWeightsForLoop(S.getCond(), getProfileCount(S.getBody()));
@@ -1150,6 +1146,7 @@ void CodeGenFunction::EmitWhileStmt(const WhileStmt &S,
if (ExitBlock != LoopExit.getBlock()) {
EmitBlock(ExitBlock);
+ incrementProfileCounter(UseSkipPath, &S);
EmitBranchThroughCleanup(LoopExit);
}
} else if (const Attr *A = Stmt::getLikelihoodAttr(S.getBody())) {
@@ -1167,11 +1164,7 @@ void CodeGenFunction::EmitWhileStmt(const WhileStmt &S,
{
RunCleanupsScope BodyScope(*this);
EmitBlock(LoopBody);
- // When single byte coverage mode is enabled, add a counter to the body.
- if (llvm::EnableSingleByteCoverage)
- incrementProfileCounter(S.getBody());
- else
- incrementProfileCounter(&S);
+ incrementProfileCounter(UseExecPath, &S);
EmitStmt(S.getBody());
}
@@ -1191,13 +1184,10 @@ void CodeGenFunction::EmitWhileStmt(const WhileStmt &S,
// The LoopHeader typically is just a branch if we skipped emitting
// a branch, try to erase it.
- if (!EmitBoolCondBranch)
+ if (!EmitBoolCondBranch) {
SimplifyForwardingBlocks(LoopHeader.getBlock());
-
- // When single byte coverage mode is enabled, add a counter to continuation
- // block.
- if (llvm::EnableSingleByteCoverage)
- incrementProfileCounter(&S);
+ PGO->markStmtAsUsed(true, &S);
+ }
if (CGM.shouldEmitConvergenceTokens())
ConvergenceTokenStack.pop_back();
@@ -1216,10 +1206,7 @@ void CodeGenFunction::EmitDoStmt(const DoStmt &S,
// Emit the body of the loop.
llvm::BasicBlock *LoopBody = createBasicBlock("do.body");
- if (llvm::EnableSingleByteCoverage)
- EmitBlockWithFallThrough(LoopBody, S.getBody());
- else
- EmitBlockWithFallThrough(LoopBody, &S);
+ EmitBlockWithFallThrough(LoopBody, &S);
if (CGM.shouldEmitConvergenceTokens())
ConvergenceTokenStack.push_back(emitConvergenceLoopToken(LoopBody));
@@ -1230,9 +1217,6 @@ void CodeGenFunction::EmitDoStmt(const DoStmt &S,
}
EmitBlock(LoopCond.getBlock());
- // When single byte coverage mode is enabled, add a counter to loop condition.
- if (llvm::EnableSingleByteCoverage)
- incrementProfileCounter(S.getCond());
// C99 6.8.5.2: "The evaluation of the controlling expression takes place
// after each execution of the loop body."
@@ -1255,11 +1239,14 @@ void CodeGenFunction::EmitDoStmt(const DoStmt &S,
SourceLocToDebugLoc(R.getEnd()),
checkIfLoopMustProgress(S.getCond(), hasEmptyLoopBody(S)));
+ auto *LoopFalse = (hasSkipCounter(&S) ? createBasicBlock("do.loopfalse")
+ : LoopExit.getBlock());
+
// As long as the condition is true, iterate the loop.
if (EmitBoolCondBranch) {
uint64_t BackedgeCount = getProfileCount(S.getBody()) - ParentCount;
auto *I = Builder.CreateCondBr(
- BoolCondVal, LoopBody, LoopExit.getBlock(),
+ BoolCondVal, LoopBody, LoopFalse,
createProfileWeightsForLoop(S.getCond(), BackedgeCount));
// Key Instructions: Emit the condition and branch as separate source
@@ -1274,6 +1261,11 @@ void CodeGenFunction::EmitDoStmt(const DoStmt &S,
LoopStack.pop();
+ if (LoopFalse != LoopExit.getBlock()) {
+ EmitBlock(LoopFalse);
+ incrementProfileCounter(UseSkipPath, &S, /*UseBoth=*/true);
+ }
+
// Emit the exit block.
EmitBlock(LoopExit.getBlock());
@@ -1282,11 +1274,6 @@ void CodeGenFunction::EmitDoStmt(const DoStmt &S,
if (!EmitBoolCondBranch)
SimplifyForwardingBlocks(LoopCond.getBlock());
- // When single byte coverage mode is enabled, add a counter to continuation
- // block.
- if (llvm::EnableSingleByteCoverage)
- incrementProfileCounter(&S);
-
if (CGM.shouldEmitConvergenceTokens())
ConvergenceTokenStack.pop_back();
}
@@ -1348,15 +1335,10 @@ void CodeGenFunction::EmitForStmt(const ForStmt &S,
BreakContinueStack.back().ContinueBlock = Continue;
}
- // When single byte coverage mode is enabled, add a counter to loop
- // condition.
- if (llvm::EnableSingleByteCoverage)
- incrementProfileCounter(S.getCond());
-
llvm::BasicBlock *ExitBlock = LoopExit.getBlock();
// If there are any cleanups between here and the loop-exit scope,
// create a block to stage a loop exit along.
- if (ForScope && ForScope->requiresCleanups())
+ if (hasSkipCounter(&S) || (ForScope && ForScope->requiresCleanups()))
ExitBlock = createBasicBlock("for.cond.cleanup");
// As long as the condition is true, iterate the loop.
@@ -1385,6 +1367,7 @@ void CodeGenFunction::EmitForStmt(const ForStmt &S,
if (ExitBlock != LoopExit.getBlock()) {
EmitBlock(ExitBlock);
+ incrementProfileCounter(UseSkipPath, &S);
EmitBranchThroughCleanup(LoopExit);
}
@@ -1392,13 +1375,11 @@ void CodeGenFunction::EmitForStmt(const ForStmt &S,
} else {
// Treat it as a non-zero constant. Don't even create a new block for the
// body, just fall into it.
+ PGO->markStmtAsUsed(true, &S);
}
- // When single byte coverage mode is enabled, add a counter to the body.
- if (llvm::EnableSingleByteCoverage)
- incrementProfileCounter(S.getBody());
- else
- incrementProfileCounter(&S);
+ incrementProfileCounter(UseExecPath, &S);
+
{
// Create a separate cleanup scope for the body, in case it is not
// a compound statement.
@@ -1414,8 +1395,6 @@ void CodeGenFunction::EmitForStmt(const ForStmt &S,
if (S.getInc()) {
EmitBlock(Continue.getBlock());
EmitStmt(S.getInc());
- if (llvm::EnableSingleByteCoverage)
- incrementProfileCounter(S.getInc());
}
BreakContinueStack.pop_back();
@@ -1433,11 +1412,6 @@ void CodeGenFunction::EmitForStmt(const ForStmt &S,
// Emit the fall-through block.
EmitBlock(LoopExit.getBlock(), true);
- // When single byte coverage mode is enabled, add a counter to continuation
- // block.
- if (llvm::EnableSingleByteCoverage)
- incrementProfileCounter(&S);
-
if (CGM.shouldEmitConvergenceTokens())
ConvergenceTokenStack.pop_back();
@@ -1479,7 +1453,7 @@ CodeGenFunction::EmitCXXForRangeStmt(const CXXForRangeStmt &S,
// If there are any cleanups between here and the loop-exit scope,
// create a block to stage a loop exit along.
llvm::BasicBlock *ExitBlock = LoopExit.getBlock();
- if (ForScope.requiresCleanups())
+ if (hasSkipCounter(&S) || ForScope.requiresCleanups())
ExitBlock = createBasicBlock("for.cond.cleanup");
// The loop body, consisting of the specified body and the loop variable.
@@ -1504,14 +1478,12 @@ CodeGenFunction::EmitCXXForRangeStmt(const CXXForRangeStmt &S,
if (ExitBlock != LoopExit.getBlock()) {
EmitBlock(ExitBlock);
+ incrementProfileCounter(UseSkipPath, &S);
EmitBranchThroughCleanup(LoopExit);
}
EmitBlock(ForBody);
- if (llvm::EnableSingleByteCoverage)
- incrementProfileCounter(S.getBody());
- else
- incrementProfileCounter(&S);
+ incrementProfileCounter(UseExecPath, &S);
// Create a block for the increment. In case of a 'continue', we jump there.
JumpDest Continue = getJumpDestInCurrentScope("for.inc");
@@ -1545,11 +1517,6 @@ CodeGenFunction::EmitCXXForRangeStmt(const CXXForRangeStmt &S,
// Emit the fall-through block.
EmitBlock(LoopExit.getBlock(), true);
- // When single byte coverage mode is enabled, add a counter to continuation
- // block.
- if (llvm::EnableSingleByteCoverage)
- incrementProfileCounter(&S);
-
if (CGM.shouldEmitConvergenceTokens())
ConvergenceTokenStack.pop_back();
diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp
index fbae2433ec278..1e66c22759fa9 100644
--- a/clang/lib/CodeGen/CodeGenFunction.cpp
+++ b/clang/lib/CodeGen/CodeGenFunction.cpp
@@ -55,10 +55,6 @@
using namespace clang;
using namespace CodeGen;
-namespace llvm {
-extern cl::opt<bool> EnableSingleByteCoverage;
-} // namespace llvm
-
/// shouldEmitLifetimeMarkers - Decide whether we need emit the life-time
/// markers.
static bool shouldEmitLifetimeMarkers(const CodeGenOptions &CGOpts,
@@ -1385,10 +1381,7 @@ void CodeGenFunction::EmitFunctionBody(const Stmt *Body) {
void CodeGenFunction::EmitBlockWithFallThrough(llvm::BasicBlock *BB,
const Stmt *S) {
llvm::BasicBlock *SkipCountBB = nullptr;
- // Do not skip over the instrumentation when single byte coverage mode is
- // enabled.
- if (HaveInsertPoint() && CGM.getCodeGenOpts().hasProfileClangInstr() &&
- !llvm::EnableSingleByteCoverage) {
+ if (HaveInsertPoint() && CGM.getCodeGenOpts().hasProfileClangInstr()) {
// When instrumenting for profiling, the fallthrough to certain
// statements needs to skip over the instrumentation code so that we
// get an accurate count.
@@ -1397,7 +1390,7 @@ void CodeGenFunction::EmitBlockWithFallThrough(llvm::BasicBlock *BB,
}
EmitBlock(BB);
uint64_t CurrentCount = getCurrentProfileCount();
- incrementProfileCounter(S);
+ incrementProfileCounter(UseExecPath, S);
setCurrentProfileCount(getCurrentProfileCount() + CurrentCount);
if (SkipCountBB)
EmitBlock(SkipCountBB);
diff --git a/clang/lib/CodeGen/CodeGenPGO.cpp b/clang/lib/CodeGen/CodeGenPGO.cpp
index b4de643d90a75..6020216ff4e7e 100644
--- a/clang/lib/CodeGen/CodeGenPGO.cpp
+++ b/clang/lib/CodeGen/CodeGenPGO.cpp
@@ -383,81 +383,6 @@ struct MapRegionCounters : public RecursiveASTVisitor<MapRegionCounters> {
return true;
}
- bool TraverseWhileStmt(WhileStmt *While) {
- // When single byte coverage mode is enabled, add a counter to condition and
- // body.
- bool NoSingleByteCoverage = !llvm::EnableSingleByteCoverage;
- for (Stmt *CS : While->children()) {
- if (!CS || NoSingleByteCoverage)
- continue;
- if (CS == While->getCond())
- CounterMap[While->getCond()] = NextCounter++;
- else if (CS == While->getBody())
- CounterMap[While->getBody()] = NextCounter++;
- }
-
- Base::TraverseWhileStmt(While);
- if (Hash.getHashVersion() != PGO_HASH_V1)
- Hash.combine(PGOHash::EndOfScope);
- return true;
- }
-
- bool TraverseDoStmt(DoStmt *Do) {
- // When single byte coverage mode is enabled, add a counter to condition and
- // body.
- bool NoSingleByteCoverage = !llvm::EnableSingleByteCoverage;
- for (Stmt *CS : Do->children()) {
- if (!CS || NoSingleByteCoverage)
- continue;
- if (CS == Do->getCond())
- CounterMap[Do->getCond()] = NextCounter++;
- else if (CS == Do->getBody())
- CounterMap[Do->getBody()] = NextCounter++;
- }
-
- Base::TraverseDoStmt(Do);
- if (Hash.getHashVersion() != PGO_HASH_V1)
- Hash.combine(PGOHash::EndOfScope);
- return true;
- }
-
- bool TraverseForStmt(ForStmt *For) {
- // When single byte coverage mode is enabled, add a counter to condition,
- // increment and body.
- bool NoSingleByteCoverage = !llvm::EnableSingleByteCoverage;
- for (Stmt *CS : For->children()) {
- if (!CS || NoSingleByteCoverage)
- continue;
- if (CS == For->getCond())
- CounterMap[For->getCond()] = NextCounter++;
- else if (CS == For->getInc())
- CounterMap[For->getInc()] = NextCounter++;
- else if (CS == For->getBody())
- CounterMap[For->getBody()] = NextCounter++;
- }
-
- Base::TraverseForStmt(For);
- if (Hash.getHashVersion() != PGO_HASH_V1)
- Hash.combine(PGOHash::EndOfScope);
- return true;
- }
-
- bool TraverseCXXForRangeStmt(CXXForRangeStmt *ForRange) {
- // When single byte coverage mode is enabled, add a counter to body.
- bool NoSingleByteCoverage = !llvm::EnableSingleByteCoverage;
- for (Stmt *CS : ForRange->children()) {
- if (!CS || NoSingleByteCoverage)
- continue;
- if (CS == ForRange->getBody())
- CounterMap[ForRange->getBody()] = NextCounter++;
- }
-
- Base::TraverseCXXForRangeStmt(ForRange);
- if (Hash.getHashVersion() != PGO_HASH_V1)
- Hash.combine(PGOHash::EndOfScope);
- return true;
- }
-
// If the statement type \p N is nestable, and its nesting impacts profile
// stability, define a custom traversal which tracks the end of the statement
// in the hash (provided we're not using the V1 hash).
@@ -469,6 +394,10 @@ struct MapRegionCounters : public RecursiveASTVisitor<MapRegionCounters> {
return true; \
}
+ DEFINE_NESTABLE_TRAVERSAL(WhileStmt)
+ DEFINE_NESTABLE_TRAVERSAL(DoStmt)
+ DEFINE_NESTABLE_TRAVERSAL(ForStmt)
+ DEFINE_NESTABLE_TRAVERSAL(CXXForRangeStmt)
DEFINE_NESTABLE_TRAVERSAL(ObjCForCollectionStmt)
DEFINE_NESTABLE_TRAVERSAL(CXXTryStmt)
DEFINE_NESTABLE_TRAVERSAL(CXXCatchStmt)
diff --git a/clang/lib/CodeGen/CoverageMappingGen.cpp b/clang/lib/CodeGen/CoverageMappingGen.cpp
index e4efa774b2da2..4a80480dd2507 100644
--- a/clang/lib/CodeGen/CoverageMappingGen.cpp
+++ b/clang/lib/CodeGen/CoverageMappingGen.cpp
@@ -1653,9 +1653,8 @@ struct CounterCoverageMappingBuilder
void VisitBreakStmt(const BreakStmt *S) {
assert(!BreakContinueStack.empty() && "break not in a loop or switch!");
- if (!llvm::EnableSingleByteCoverage)
- BreakContinueStack.back().BreakCount = addCounters(
- BreakContinueStack.back().BreakCount, getRegion().getCounter());
+ BreakContinueStack.back().BreakCount = addCounters(
+ BreakContinueStack.back().BreakCount, getRegion().getCounter());
// FIXME: a break in a switch should terminate regions for all preceding
// case statements, not just the most recent one.
terminateRegion(S);
@@ -1663,9 +1662,8 @@ struct CounterCoverageMappingBuilder
void VisitContinueStmt(const ContinueStmt *S) {
assert(!BreakContinueStack.empty() && "continue stmt not in a loop!");
- if (!llvm::EnableSingleByteCoverage)
- BreakContinueStack.back().ContinueCount = addCounters(
- BreakContinueStack.back().ContinueCount, getRegion().getCounter());
+ BreakContinueStack.back().ContinueCount = addCounters(
+ BreakContinueStack.back().ContinueCount, getRegion().getCounter());
terminateRegion(S);
}
@@ -1683,9 +1681,7 @@ struct CounterCoverageMappingBuilder
extendRegion(S);
Counter ParentCount = getRegion().getCounter();
- Counter BodyCount = llvm::EnableSingleByteCoverage
- ? getRegionCounter(S->getBody())
- : getRegionCounter(S);
+ Counter BodyCount = getRegionCounter(S);
// Handle the body first so that we can get the backedge count.
BreakContinueStack.push_back(BreakContinue());
@@ -1698,12 +1694,9 @@ struct CounterCoverageMappingBuilder
// Go back to handle the condition.
Counter CondCount =
- llvm::EnableSingleByteCoverage
- ? getRegionCounter(S->getCond())
- : addCounters(ParentCount, BackedgeCount, BC.ContinueCount);
- auto BranchCount = getBranchCounterPair(S, CondCount, getRegionCounter(S));
- assert(BranchCount.Executed.isZero() || BranchCount.Executed == BodyCount ||
- llvm::EnableSingleByteCoverage);
+ addCounters(ParentCount, BackedgeCount, BC.ContinueCount);
+ auto BranchCount = getBranchCounterPair(S, CondCount);
+ assert(BranchCount.Executed.isZero() || BranchCount.Executed == BodyCount);
propagateCounts(CondCount, S->getCond());
adjustForOutOfOrderTraversal(getEnd(S));
@@ -1713,9 +1706,6 @@ struct CounterCoverageMappingBuilder
if (Gap)
fillGapAreaWithCount(Gap->getBegin(), Gap->getEnd(), BodyCount);
- assert(
- !llvm::EnableSingleByteCoverage ||
- (BC.BreakCount.isZero() && BranchCount.Skipped == getRegionCounter(S)));
Counter OutCount = addCounters(BC.BreakCount, BranchCount.Skipped);
if (!IsCounterEqual(OutCount, ParentCount)) {
pushRegion(OutCount);
@@ -1725,45 +1715,32 @@ struct CounterCoverageMappingBuilder
}
// Create Branch Region around condition.
- if (!llvm::EnableSingleByteCoverage)
- createBranchRegion(S->getCond(), BodyCount, BranchCount.Skipped);
+ createBranchRegion(S->getCond(), BodyCount, BranchCount.Skipped);
}
void VisitDoStmt(const DoStmt *S) {
extendRegion(S);
Counter ParentCount = getRegion().getCounter();
- Counter BodyCount = llvm::EnableSingleByteCoverage
- ? getRegionCounter(S->getBody())
- : getRegionCounter(S);
+ Counter BodyCount = getRegionCounter(S);
BreakContinueStack.push_back(BreakContinue());
extendRegion(S->getBody());
- Counter BackedgeCount;
- if (llvm::EnableSingleByteCoverage)
- propagateCounts(BodyCount, S->getBody());
- else
- BackedgeCount =
- propagateCounts(addCounters(ParentCount, BodyCount), S->getBody());
+ Counter BackedgeCount =
+ propagateCounts(addCounters(ParentCount, BodyCount), S->getBody());
BreakContinue BC = BreakContinueStack.pop_back_val();
bool BodyHasTerminateStmt = HasTerminateStmt;
HasTerminateStmt = false;
- Counter CondCount = llvm::EnableSingleByteCoverage
- ? getRegionCounter(S->getCond())
- : addCounters(BackedgeCount, BC.ContinueCount);
- auto BranchCount = getBranchCounterPair(S, CondCount, getRegionCounter(S));
- assert(BranchCount.Executed.isZero() || BranchCount.Executed == BodyCount ||
- llvm::EnableSingleByteCoverage);
+ Counter CondCount = addCounters(BackedgeCount, BC.ContinueCount);
+ auto BranchCount = getBranchCounterPair(S, CondCount);
+ assert(BranchCount.Executed.isZero() || BranchCount.Executed == BodyCount);
propagateCounts(CondCount, S->getCond());
- assert(
- !llvm::EnableSingleByteCoverage ||
- (BC.BreakCount.isZero() && BranchCount.Skipped == getRegionCounter(S)));
Counter OutCount = addCounters(BC.BreakCount, BranchCount.Skipped);
if (!IsCounterEqual(OutCount, ParentCount)) {
pushRegion(OutCount);
@@ -1773,8 +1750,7 @@ struct CounterCoverageMappingBuilder
}
// Create Branch Region around condition.
- if (!llvm::EnableSingleByteCoverage)
- createBranchRegion(S->getCond(), BodyCount, BranchCount.Skipped);
+ createBranchRegion(S->getCond(), BodyCount, BranchCount.Skipped);
}
void VisitForStmt(const ForStmt *S) {
@@ -1783,9 +1759,7 @@ struct CounterCoverageMappingBuilder
Visit(S->getInit());
Counter ParentCount = getRegion().getCounter();
- Counter BodyCount = llvm::EnableSingleByteCoverage
- ? getRegionCounter(S->getBody())
- : getRegionCounter(S);
+ Counter BodyCount = getRegionCounter(S);
// The loop increment may contain a break or continue.
if (S->getInc())
@@ -1804,25 +1778,16 @@ struct CounterCoverageMappingBuilder
// the count for all the continue statements.
BreakContinue IncrementBC;
if (const Stmt *Inc = S->getInc()) {
- Counter IncCount;
- if (llvm::EnableSingleByteCoverage)
- IncCount = getRegionCounter(S->getInc());
- else
- IncCount = addCounters(BackedgeCount, BodyBC.ContinueCount);
- propagateCounts(IncCount, Inc);
+ propagateCounts(addCounters(BackedgeCount, BodyBC.ContinueCount), Inc);
IncrementBC = BreakContinueStack.pop_back_val();
}
// Go back to handle the condition.
- Counter CondCount =
- llvm::EnableSingleByteCoverage
- ? getRegionCounter(S->getCond())
- : addCounters(
- addCounters(ParentCount, BackedgeCount, BodyBC.ContinueCount),
- IncrementBC.ContinueCount);
- auto BranchCount = getBranchCounterPair(S, CondCount, getRegionCounter(S));
- assert(BranchCount.Executed.isZero() || BranchCount.Executed == BodyCount ||
- llvm::EnableSingleByteCoverage);
+ Counter CondCount = addCounters(
+ addCounters(ParentCount, BackedgeCount, BodyBC.ContinueCount),
+ IncrementBC.ContinueCount);
+ auto BranchCount = getBranchCounterPair(S, CondCount);
+ assert(BranchCount.Executed.isZero() || BranchCount.Executed == BodyCount);
if (const Expr *Cond = S->getCond()) {
propagateCounts(CondCount, Cond);
@@ -1834,8 +1799,6 @@ struct CounterCoverageMappingBuilder
if (Gap)
fillGapAreaWithCount(Gap->getBegin(), Gap->getEnd(), BodyCount);
- assert(!llvm::EnableSingleByteCoverage ||
- (BodyBC.BreakCount.isZero() && IncrementBC.BreakCount.isZero()));
Counter OutCount = addCounters(BodyBC.BreakCount, IncrementBC.BreakCount,
BranchCount.Skipped);
if (!IsCounterEqual(OutCount, ParentCount)) {
@@ -1846,8 +1809,7 @@ struct CounterCoverageMappingBuilder
}
// Create Branch Region around condition.
- if (!llvm::EnableSingleByteCoverage)
- createBranchRegion(S->getCond(), BodyCount, BranchCount.Skipped);
+ createBranchRegion(S->getCond(), BodyCount, BranchCount.Skipped);
}
void VisitCXXForRangeStmt(const CXXForRangeStmt *S) {
@@ -1858,9 +1820,7 @@ struct CounterCoverageMappingBuilder
Visit(S->getRangeStmt());
Counter ParentCount = getRegion().getCounter();
- Counter BodyCount = llvm::EnableSingleByteCoverage
- ? getRegionCounter(S->getBody())
- : getRegionCounter(S);
+ Counter BodyCount = getRegionCounter(S);
BreakContinueStack.push_back(BreakContinue());
extendRegion(S->getBody());
@@ -1877,12 +1837,8 @@ struct CounterCoverageMappingBuilder
Counter LoopCount =
addCounters(ParentCount, BackedgeCount, BC.ContinueCount);
- auto BranchCount = getBranchCounterPair(S, LoopCount, getRegionCounter(S));
- assert(BranchCount.Executed.isZero() || BranchCount.Executed == BodyCount ||
- llvm::EnableSingleByteCoverage);
- assert(
- !llvm::EnableSingleByteCoverage ||
- (BC.BreakCount.isZero() && BranchCount.Skipped == getRegionCounter(S)));
+ auto BranchCount = getBranchCounterPair(S, LoopCount);
+ assert(BranchCount.Executed.isZero() || BranchCount.Executed == BodyCount);
Counter OutCount = addCounters(BC.BreakCount, BranchCount.Skipped);
if (!IsCounterEqual(OutCount, ParentCount)) {
@@ -1893,8 +1849,7 @@ struct CounterCoverageMappingBuilder
}
// Create Branch Region around condition.
- if (!llvm::EnableSingleByteCoverage)
- createBranchRegion(S->getCond(), BodyCount, BranchCount.Skipped);
+ createBranchRegion(S->getCond(), BodyCount, BranchCount.Skipped);
}
void VisitObjCForCollectionStmt(const ObjCForCollectionStmt *S) {
diff --git a/clang/test/CoverageMapping/single-byte-counters.cpp b/clang/test/CoverageMapping/single-byte-counters.cpp
index 056d5134b0b87..1680a7a682432 100644
--- a/clang/test/CoverageMapping/single-byte-counters.cpp
+++ b/clang/test/CoverageMapping/single-byte-counters.cpp
@@ -76,83 +76,83 @@ int testSwitch(int x) { // CHECK-NEXT: File 0, [[@LINE]]:23 -> [[@LINE+20]]:2 =
int testWhile() { // CHECK-NEXT: File 0, [[@LINE]]:17 -> [[@LINE+12]]:2 = [[C40:#0]]
int i = 0;
int sum = 0;
- while (i < 10) { // CHECK-NEXT: File 0, [[@LINE]]:10 -> [[@LINE]]:16 = [[C4C:#1]]
-
- // CHECK-NEXT: Gap,File 0, [[@LINE-2]]:17 -> [[@LINE-2]]:18 = [[C4T:#2]]
+ while (i < 10) { // CHECK-NEXT: File 0, [[@LINE]]:10 -> [[@LINE]]:16 = ([[C40]] + [[C4T:#1]])
+ // CHECK-NEXT: Branch,File 0, [[@LINE-1]]:10 -> [[@LINE-1]]:16 = [[C4T]], [[C4F:#0]]
+ // CHECK-NEXT: Gap,File 0, [[@LINE-2]]:17 -> [[@LINE-2]]:18 = [[C4T]]
// CHECK-NEXT: File 0, [[@LINE-3]]:18 -> [[@LINE+3]]:4 = [[C4T]]
sum += i;
i++;
}
- return sum; // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE]]:13 = [[C4E:#3]]
+ return sum; // #0
}
// CHECK-NEXT: testContinueBreak
-int testContinueBreak() { // CHECK-NEXT: File 0, [[@LINE]]:25 -> [[@LINE+23]]:2 = #0
+int testContinueBreak() { // CHECK-NEXT: File 0, [[@LINE]]:25 -> [[@LINE+23]]:2 = [[C50:#0]]
int i = 0;
int sum = 0;
- while (i < 10) { // CHECK-NEXT: File 0, [[@LINE]]:10 -> [[@LINE]]:16 = #1
-
- // CHECK-NEXT: Gap,File 0, [[@LINE-2]]:17 -> [[@LINE-2]]:18 = [[C5B:#2]]
+ while (i < 10) { // CHECK-NEXT: File 0, [[@LINE]]:10 -> [[@LINE]]:16 = (([[C50]] + [[C5T:#2]]) + [[C5F1:#5]])
+ // CHECK-NEXT: Branch,File 0, [[@LINE-1]]:10 -> [[@LINE-1]]:16 = [[C5B:#1]], [[C5E:#6]]
+ // CHECK-NEXT: Gap,File 0, [[@LINE-2]]:17 -> [[@LINE-2]]:18 = [[C5B]]
// CHECK-NEXT: File 0, [[@LINE-3]]:18 -> [[@LINE+14]]:4 = [[C5B]]
if (i == 4) // CHECK-NEXT: File 0, [[@LINE]]:9 -> [[@LINE]]:15 = [[C5B]]
- // CHECK-NEXT: Gap,File 0, [[@LINE-2]]:16 -> [[@LINE+1]]:7 = [[C5T:#4]]
+ // CHECK-NEXT: Gap,File 0, [[@LINE-2]]:16 -> [[@LINE+1]]:7 = [[C5T]]
continue; // CHECK-NEXT: File 0, [[@LINE]]:7 -> [[@LINE]]:15 = [[C5T]]
- // CHECK-NEXT: Gap,File 0, [[@LINE-1]]:16 -> [[@LINE+2]]:5 = [[C5F:#5]]
+ // CHECK-NEXT: Gap,File 0, [[@LINE-1]]:16 -> [[@LINE+2]]:5 = [[C5F:#3]]
// CHECK-NEXT: File 0, [[@LINE+1]]:5 -> [[@LINE+8]]:4 = [[C5F]]
if (i == 5) // CHECK-NEXT: File 0, [[@LINE]]:9 -> [[@LINE]]:15 = [[C5F]]
- // CHECK-NEXT: Gap,File 0, [[@LINE-2]]:16 -> [[@LINE+1]]:7 = [[C5T1:#6]]
+ // CHECK-NEXT: Gap,File 0, [[@LINE-2]]:16 -> [[@LINE+1]]:7 = [[C5T1:#4]]
break; // CHECK-NEXT: File 0, [[@LINE]]:7 -> [[@LINE]]:12 = [[C5T1]]
- // CHECK-NEXT: Gap,File 0, [[@LINE-1]]:13 -> [[@LINE+1]]:5 = [[C5F1:#7]]
+ // CHECK-NEXT: Gap,File 0, [[@LINE-1]]:13 -> [[@LINE+1]]:5 = [[C5F1]]
sum += i; // CHECK-NEXT: File 0, [[@LINE]]:5 -> [[@LINE+2]]:4 = [[C5F1]]
i++;
}
- // CHECK-NEXT: Gap,File 0, [[@LINE-1]]:4 -> [[@LINE+1]]:3 = [[C5E:#3]]
- return sum; // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE]]:13 = [[C5E]]
+ // CHECK-NEXT: Gap,File 0, [[@LINE-1]]:4 -> [[@LINE+1]]:3 = ([[C5T1]] + [[C5E]])
+ return sum; // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE]]:13 = ([[C5T1]] + [[C5E]])
}
// CHECK-NEXT: testFor
int testFor() { // CHECK-NEXT: File 0, [[@LINE]]:15 -> [[@LINE+13]]:2 = [[C60:#0]]
int i;
int sum = 0;
- // CHECK-NEXT: File 0, [[@LINE+3]]:19 -> [[@LINE+3]]:25 = [[C61:#1]]
-
- // CHECK-NEXT: File 0, [[@LINE+1]]:27 -> [[@LINE+1]]:30 = [[C6C:#2]]
+ // CHECK-NEXT: File 0, [[@LINE+3]]:19 -> [[@LINE+3]]:25 = ([[C60]] + [[C6B:#1]])
+ // CHECK-NEXT: Branch,File 0, [[@LINE+2]]:19 -> [[@LINE+2]]:25 = [[C6B]], [[C6E:#0]]
+ // CHECK-NEXT: File 0, [[@LINE+1]]:27 -> [[@LINE+1]]:30 = [[C6B]]
for (int i = 0; i < 10; i++) {
- // CHECK-NEXT: Gap,File 0, [[@LINE-1]]:31 -> [[@LINE-1]]:32 = [[C6B:#3]]
+ // CHECK-NEXT: Gap,File 0, [[@LINE-1]]:31 -> [[@LINE-1]]:32 = [[C6B]]
// CHECK-NEXT: File 0, [[@LINE-2]]:32 -> [[@LINE+2]]:4 = [[C6B]]
sum += i;
}
- return sum; // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE]]:13 = [[C6E:#4]]
+ return sum; // #0
}
// CHECK-NEXT: testForRange
int testForRange() { // CHECK-NEXT: File 0, [[@LINE]]:20 -> [[@LINE+11]]:2 = [[C70:#0]]
int sum = 0;
int array[] = {1, 2, 3, 4, 5};
-
+ // CHECK-NEXT: Branch,File 0, [[@LINE+1]]:20 -> [[@LINE+1]]:21 = [[C7B:#1]], [[C7E:#0]]
for (int element : array) {
- // CHECK-NEXT: Gap,File 0, [[@LINE-1]]:28 -> [[@LINE-1]]:29 = [[C7B:#1]]
+ // CHECK-NEXT: Gap,File 0, [[@LINE-1]]:28 -> [[@LINE-1]]:29 = [[C7B]]
// CHECK-NEXT: File 0, [[@LINE-2]]:29 -> [[@LINE+2]]:4 = [[C7B]]
sum += element;
}
- return sum; // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE]]:13 = [[C7E:#2]]
+ return sum; // #0
}
// CHECK-NEXT: testDo
int testDo() { // CHECK-NEXT: File 0, [[@LINE]]:14 -> [[@LINE+9]]:2 = [[C80:#0]]
int i = 0;
int sum = 0;
- do { // CHECK-NEXT: File 0, [[@LINE]]:6 -> [[@LINE+3]]:4 = [[C8B:#1]]
+ do { // CHECK-NEXT: File 0, [[@LINE]]:6 -> [[@LINE+3]]:4 = ([[C80]] + [[C8B:#1]])
sum += i;
i++;
- } while (i < 5); // CHECK-NEXT: File 0, [[@LINE]]:12 -> [[@LINE]]:17 = [[C8C:#2]]
-
- return sum; // CHECK-NEXT: File 0, [[@LINE]]:3 -> [[@LINE]]:13 = [[C8E:#3]]
+ } while (i < 5); // CHECK-NEXT: File 0, [[@LINE]]:12 -> [[@LINE]]:17 = ([[C80]] + [[C8B]])
+ // CHECK-NEXT: Branch,File 0, [[@LINE-1]]:12 -> [[@LINE-1]]:17 = [[C8B]], [[C8E:#0]]
+ return sum; // #0
}
// CHECK-NEXT: testConditional
diff --git a/llvm/test/tools/llvm-cov/Inputs/branch-c-general-single.proftext b/llvm/test/tools/llvm-cov/Inputs/branch-c-general-single.proftext
index d7e78369c4504..61e2ad4e2d094 100644
--- a/llvm/test/tools/llvm-cov/Inputs/branch-c-general-single.proftext
+++ b/llvm/test/tools/llvm-cov/Inputs/branch-c-general-single.proftext
@@ -4,15 +4,12 @@ big_switch
# Func Hash:
13144136522122330070
# Num Counters:
-27
+25
# Counter Values:
1
1
1
1
-1
-1
-1
0
1
1
@@ -33,12 +30,13 @@ big_switch
1
1
1
+1
boolean_operators
# Func Hash:
1245693242827665
# Num Counters:
-17
+14
# Counter Values:
1
1
@@ -54,35 +52,22 @@ boolean_operators
1
1
1
-1
-1
-1
boolop_loops
# Func Hash:
12402604614320574815
# Num Counters:
-23
+13
# Counter Values:
1
-0
-1
-1
-1
-1
-0
-1
1
1
1
-0
1
1
1
1
1
-0
-1
1
1
1
@@ -92,13 +77,10 @@ branch-c-general.c:static_func
# Func Hash:
18129
# Num Counters:
-5
+2
# Counter Values:
1
1
-1
-1
-1
conditional_operator
# Func Hash:
@@ -116,14 +98,11 @@ conditionals
# Func Hash:
4904767535850050386
# Num Counters:
-25
+22
# Counter Values:
1
1
1
-1
-1
-1
0
1
1
@@ -148,7 +127,7 @@ do_fallthrough
# Func Hash:
8714614136504380050
# Num Counters:
-10
+7
# Counter Values:
1
1
@@ -157,15 +136,12 @@ do_fallthrough
1
1
1
-1
-1
-1
early_exits
# Func Hash:
2880354649761471549
# Num Counters:
-20
+18
# Counter Values:
1
0
@@ -182,9 +158,7 @@ early_exits
1
1
0
-1
-1
-1
+0
0
0
@@ -192,22 +166,17 @@ jumps
# Func Hash:
15051420506203462683
# Num Counters:
-38
+32
# Counter Values:
1
1
0
-1
-0
-0
0
1
0
1
-1
0
1
-1
0
1
1
@@ -215,20 +184,19 @@ jumps
1
1
1
-1
0
1
-1
0
1
1
1
1
+0
+0
1
1
1
0
-0
1
1
1
@@ -245,25 +213,18 @@ simple_loops
# Func Hash:
1245818015463121
# Num Counters:
-11
+4
# Counter Values:
1
1
1
1
-1
-1
-1
-1
-1
-1
-1
switches
# Func Hash:
43242458792028222
# Num Counters:
-29
+27
# Counter Values:
1
1
@@ -274,9 +235,6 @@ switches
0
1
1
-0
-1
-1
1
1
1
@@ -294,4 +252,5 @@ switches
1
0
0
+0
diff --git a/llvm/test/tools/llvm-cov/Inputs/branch-c-general-single.yaml b/llvm/test/tools/llvm-cov/Inputs/branch-c-general-single.yaml
index 60de270939725..75436559c2767 100644
--- a/llvm/test/tools/llvm-cov/Inputs/branch-c-general-single.yaml
+++ b/llvm/test/tools/llvm-cov/Inputs/branch-c-general-single.yaml
@@ -11,42 +11,42 @@ Sections:
Type: SHT_PROGBITS
Flags: [ SHF_GNU_RETAIN ]
AddressAlign: 0x8
- Content: D7878914FBE99B074D000000D136449C106D04004C551E9517F40F4F0101000D010715080205020F0016090018001B0D001C009D808080080D001D0104110203040215000A000F19001001858080800819010500081D01030202210006000825001000181001010001
+ Content: D7878914FBE99B0760000000D136449C106D04004C551E9517F40F4F01010401050109010D010D0E010715080203020F0016200501000F0016050018001B05001C009D8080800805001D010407020A000F200901000A000F09001001858080800809010500080F010600080F00100018200D01001000181001010001
- Name: '__llvm_covfun (1)'
Type: SHT_PROGBITS
Flags: [ SHF_GNU_RETAIN ]
AddressAlign: 0x8
- Content: 83AD05A5F1438E68EA00000052D33558163C11444C551E9517F40F4F010100260111150E02050113001A09001C001F0D002000A1808080080D00210B040D0109000E15000F009080808008150010020615010B000C21000D008E8080800821000E0010310106008C8080800831000C04063100100015290016009780808008290017020629010B000C35000D008E8080800835000E00102D0106008C808080082D000C02062D010B000C3D000D008E808080083D000E0010100201005B1D010502041D0009000A1D0009000F4D000E000F45001000918080800845001100134901050104490009000A490009000F5D000E000F55001000918080800855001100131002010001
+ Content: 83AD05A5F1438E68F300000052D33558163C11444C551E9517F40F4F010101014D270111150E02030113001A2005550013001A4D001C001F05002000A1808080080500210B04050109000E09000F009080808008090010020609010B000C15000D008E8080800815000E0010250106008C8080800825000C040625001000151D00160097808080081D001702061D010B000C29000D008E8080800829000E0010210106008C8080800821000C020621010B000C31000D008E8080800831000E0010100201005B1101050204110009000A110009000F41000E000F39001000918080800839001100133D010501043D0009000A3D0009000F51000E000F49001000918080800849001100131002010001
- Name: '__llvm_covfun (2)'
Type: SHT_PROGBITS
Flags: [ SHF_GNU_RETAIN ]
AddressAlign: 0x8
- Content: 0449C70428C57369F80000003D5C2D0E4B13F9274C551E9517F40F4F01010028012114180210020100010101070008050009008A8080800805000A000C100101000109010313020D000A00111100120093808080081100130604110209000F190010018780808008190107000C1D000D0185808080081D010502041D0009000E21000F018780808008210107000F15010402838080800810010100011501030B021500070008290009008A8080800829000A000C10010100012D010309023100060504310109000F3D00100187808080083D0107000D41000E028780808008410207000A35010C0013390015028380808008100101000139010302023900070008490009008A8080800849000A000C1001010001
+ Content: 0449C70428C57369140100003D5C2D0E4B13F9274C551E9517F40F4F010107071D0919114111411141252925292A012114180210020100010101070008050009008A8080800805000A000C1001010001090103130203000A0011200D41000A00110D00120093808080080D001306040D0209000F110010018780808008110107000C15000D0185808080081501050204150009000E19000F018780808008190107000F13010402838080800810010100011301030B021300070008210009008A8080800821000A000C100101000125010309021B000605041B0109000F2D00100187808080082D0107000D31000E028780808008310207000A35010C0013202945000C0013450015028380808008100101000145010302024500070008390009008A8080800839000A000C1001010001
- Name: '__llvm_covfun (3)'
Type: SHT_PROGBITS
Flags: [ SHF_GNU_RETAIN ]
AddressAlign: 0x8
- Content: 55947829059F255EB80100001B9C495D3463E1D04C551E9517F40F4F01010046013B0E2F02100201000105010F001409001600190D001A009B808080080D001B040400011402858080800810010100230001050104000009000A15000B008C8080800815000C000E11010402818080800810010100011D010126021D01070008210009008A8080800821000A000C1001010001250103000D25000E0283808080081001010001000103210229000A000B2D000C008D808080082D000D03043501030204350109000A39000B008C8080800839000C000E1002010001310103000D31000E0181808080084101011B024501011A024901011902490207000C4D000D0185808080084D0105000F5100100283808080081001010001510103140255000A000F5900100091808080085900110A04610103090400011006918080800869010501110001120185808080086D0105011200011301858080800871010501115D030402838080800810010100015D0103080275000F0015790017001A7D001B009C808080087D001C0604000115028580808008100101003F0001050304000009000A8501000B008C808080088501000C000E8D01010302048D010109000A9101000B008C808080089101000C000E1002010001
+ Content: 55947829059F255ED40100001B9C495D3463E1D04C551E9517F40F4F010103010D3D496D794A013B0E2F02100201000103010F0014200571000F00140D0016001905001A009B8080800805001B040400011402858080800810010100230001050104000009000A09000B008C8080800809000C000E710104028180808008100101000111010126021101070008150009008A8080800815000A000C1001010001190103000D19000E0283808080081001010001000103210229000A000B201D75000A000B1D000C008D808080081D000D03042101030204210109000A25000B008C8080800825000C000E1002010001750103000D75000E0181808080082D01011B023101011A023501011902350207000C39000D018580808008390105000F3D001002838080800810010100013D0103140207000A000F204179000A000F4100100091808080084100110A0445010309040001100691808080084D0105011100011201858080800851010501120001130185808080085501050111790304028380808008100101000179010308020B000F001520597D000F00156D0017001A59001B009C8080800859001C0604000115028580808008100101003F0001050304000009000A5D000B008C808080085D000C000E6501030204650109000A69000B008C8080800869000C000E1002010001
- Name: '__llvm_covfun (4)'
Type: SHT_PROGBITS
Flags: [ SHF_GNU_RETAIN ]
AddressAlign: 0x8
- Content: 7129CA3C268292BF4D0100003E688383C9A099004C551E9517F40F4F01010035016C112502100201011C000217028A80808008090103010A05020402838080800810010100620501031C020D003F0046110048004B15004C00CD8080800815004D1704000119148F80808008210105130F21010B000C25000D008E8080800825000E001010010100152D0105100F2D010B000C31000D008E8080800831000E0010350107000C35000D0185808080083901050D0F39010B000C3D000D008E808080083D000E0010410107000F4100100185808080084501050A0F45010B000C49000D008E8080800849000E00104D0107080F000012039180808008550107021155010D000E59000F00908080800859001000125D010900115101080285808080081001010001610105020F61010B0017650018018980808008650109000F1902040383808080081001010121190203020219000700116D00120093808080086D001300151001010001
+ Content: 7129CA3C268292BF560100003E688383C9A099004C551E9517F40F4F010101051136016C112502100201011C000217028A80808008090103010A05020402838080800810010100620501031C0203003F0046200D69003F0046110048004B0D004C00CD808080080D004D1704000119148F80808008150105130F15010B000C19000D008E8080800819000E00101001010015210105100F21010B000C25000D008E8080800825000E0010290107000C29000D0185808080082D01050D0F2D010B000C31000D008E8080800831000E0010350107000F3500100185808080083901050A0F39010B000C3D000D008E808080083D000E0010410107080F000012039180808008490107021149010D000E4D000F0090808080084D0010001251010900114501080285808080081001010001550105020F55010B0017590018018980808008590109000F69020403838080800810010101216902030202690007001161001200938080800861001300151001010001
- Name: '__llvm_covfun (5)'
Type: SHT_PROGBITS
Flags: [ SHF_GNU_RETAIN ]
AddressAlign: 0x8
- Content: 3F4D1C6E6087417B32010000D6FF56B8865A69B64C551E9517F40F4F01010031019301131F02050113001909001B001E0D001F00A0808080080D00201C04000115198C80808008190105180C19010B000C1D000D008E808080081D000E00101001010015250105150C25010B000C29000D008E8080800829000E00102D0107000C2D000D018580808008310105120C31010B000C35000D008E8080800835000E0010390107000C39000D03858080800810010101013D02050D0C3D010B000C41000D008E8080800841000E0010450107000C45000D0185808080084901050A0C49010B000C4D000D008E808080084D000E0010510107000C51000D0385808080081001010101550205050C55010B000C59000D008E8080800859000E00105D0107000C5D000D018580808008610105020C61010B000C65000D008E8080800865000E0010690107000C1003010001
+ Content: 3F4D1C6E6087417B3B010000D6FF56B8865A69B64C551E9517F40F4F010101010932019301131F0203011300192005610013001909001B001E05001F00A0808080080500201C04000115198C808080080D0105180C0D010B000C11000D008E8080800811000E00101001010015190105150C19010B000C1D000D008E808080081D000E0010210107000C21000D018580808008250105120C25010B000C29000D008E8080800829000E00102D0107000C2D000D03858080800810010101013102050D0C31010B000C35000D008E8080800835000E0010390107000C39000D0185808080083D01050A0C3D010B000C41000D008E8080800841000E0010450107000C45000D0385808080081001010101490205050C49010B000C4D000D008E808080084D000E0010510107000C51000D018580808008550105020C55010B000C59000D008E8080800859000E00105D0107000C1003010001
- Name: '__llvm_covfun (6)'
Type: SHT_PROGBITS
Flags: [ SHF_GNU_RETAIN ]
AddressAlign: 0x8
- Content: 59A48AA8899AA3587200000091E33C8FF36C04004C551E9517F40F4F0101001501B4011A0C02050213001A09001C001F0D002000A1808080080D002108040D0109000E1500120013100101005D0D0109000E1D00120013100101005D0D0109000E0D000900172D0012001725001B001C10010100630D0109000E0D000900173D0012001735001B001C1002010063
+ Content: 59A48AA8899AA3587B00000091E33C8FF36C04004C551E9517F40F4F01010101051601B4011A0C02030213001A2005010013001A05001C001F05002000A1808080080500210804050109000E0900120013100101005D050109000E1100120013100101005D050109000E0500090017210012001719001B001C1001010063050109000E0500090017310012001729001B001C1002010063
- Name: '__llvm_covfun (7)'
Type: SHT_PROGBITS
Flags: [ SHF_GNU_RETAIN ]
AddressAlign: 0x8
- Content: F5953D044B505D139E0000005FD132562FE71EAC4C551E9517F40F4F0101001D01C201150D02100201000111010A000B11000A001511000F0015090016018580808008090105000810010100010D0103070225000A001125000A001C250015001C1D001D0185808080081D01050008100101000121010304023D001100123D0011001C3D0016001C31001E002135002200231001010061390103020255000A001155000A001C550015001C49001E00214D002200231001010061
+ Content: F5953D044B505D139D0000005FD132562FE71EAC4C551E9517F40F4F010107010501110111011D011D012901291A01C201150D02100201000103010A000B03000A001509000F0015050016018580808008050105000810010100010B010A00110B000A001C150015001C11001D018580808008110105000810010100011301110012130011001C210016001C1D001E00211D0022002310010100611B010A00111B000A001C2D0015001C29001E002129002200231001010061
- Name: '__llvm_covfun (8)'
Type: SHT_PROGBITS
Flags: [ SHF_GNU_RETAIN ]
@@ -56,7 +56,7 @@ Sections:
Type: SHT_PROGBITS
Flags: [ SHF_GNU_RETAIN ]
AddressAlign: 0x8
- Content: 7DE8E7C47096EB425200000092EAF0986287F0784C551E9517F40F4F0101000D01DA01170B02050113001909001B001E0D001F00A0808080080D002009041502080606100101024D15030B00102100110092808080082100120017250018018780808008250107010619010E0013
+ Content: 7DE8E7C47096EB426A00000092EAF0986287F0784C551E9517F40F4F0101050715010D0D15050905090F01DA01170B020301130019200519001300190B001B001E05001F00A08080800805002009041302080606100101024D13030B00100D00110092808080080D00120017110018018780808008110107010611010E0013200915000E0013
- Name: '__llvm_covfun (10)'
Type: SHT_PROGBITS
Flags: [ SHF_GNU_RETAIN ]
@@ -66,7 +66,7 @@ Sections:
Type: SHT_PROGBITS
Flags: [ SHF_GNU_RETAIN ]
AddressAlign: 0x8
- Content: 4CB4F49D6737EBF922000000D1460000000000004C551E9517F40F4F0101000501E7011B0302050113001909001B001E0D001F00A0808080080D00200104
+ Content: 4CB4F49D6737EBF92B000000D1460000000000004C551E9517F40F4F01010101050601E7011B030203011300192005010013001905001B001E05001F00A0808080080500200104
- Name: __llvm_covmap
Type: SHT_PROGBITS
Flags: [ SHF_GNU_RETAIN ]
@@ -106,49 +106,49 @@ Symbols:
Type: STT_OBJECT
Section: __llvm_covfun
Binding: STB_WEAK
- Size: 0x69
+ Size: 0x7C
Other: [ STV_HIDDEN ]
- Name: __covrec_688E43F1A505AD83u
Type: STT_OBJECT
Section: '__llvm_covfun (1)'
Binding: STB_WEAK
- Size: 0x106
+ Size: 0x10F
Other: [ STV_HIDDEN ]
- Name: __covrec_6973C52804C74904u
Type: STT_OBJECT
Section: '__llvm_covfun (2)'
Binding: STB_WEAK
- Size: 0x114
+ Size: 0x130
Other: [ STV_HIDDEN ]
- Name: __covrec_5E259F0529789455u
Type: STT_OBJECT
Section: '__llvm_covfun (3)'
Binding: STB_WEAK
- Size: 0x1D4
+ Size: 0x1F0
Other: [ STV_HIDDEN ]
- Name: __covrec_BF9282263CCA2971u
Type: STT_OBJECT
Section: '__llvm_covfun (4)'
Binding: STB_WEAK
- Size: 0x169
+ Size: 0x172
Other: [ STV_HIDDEN ]
- Name: __covrec_7B4187606E1C4D3Fu
Type: STT_OBJECT
Section: '__llvm_covfun (5)'
Binding: STB_WEAK
- Size: 0x14E
+ Size: 0x157
Other: [ STV_HIDDEN ]
- Name: __covrec_58A39A89A88AA459u
Type: STT_OBJECT
Section: '__llvm_covfun (6)'
Binding: STB_WEAK
- Size: 0x8E
+ Size: 0x97
Other: [ STV_HIDDEN ]
- Name: __covrec_135D504B043D95F5u
Type: STT_OBJECT
Section: '__llvm_covfun (7)'
Binding: STB_WEAK
- Size: 0xBA
+ Size: 0xB9
Other: [ STV_HIDDEN ]
- Name: __covrec_795CF1BD69C3E520u
Type: STT_OBJECT
@@ -160,7 +160,7 @@ Symbols:
Type: STT_OBJECT
Section: '__llvm_covfun (9)'
Binding: STB_WEAK
- Size: 0x6E
+ Size: 0x86
Other: [ STV_HIDDEN ]
- Name: __covrec_DB956436E78DD5FAu
Type: STT_OBJECT
@@ -172,6 +172,6 @@ Symbols:
Type: STT_OBJECT
Section: '__llvm_covfun (11)'
Binding: STB_WEAK
- Size: 0x3E
+ Size: 0x47
Other: [ STV_HIDDEN ]
...
diff --git a/llvm/test/tools/llvm-cov/Inputs/branch-c-general.c b/llvm/test/tools/llvm-cov/Inputs/branch-c-general.c
index 5c5a112f00421..375217ca9618f 100644
--- a/llvm/test/tools/llvm-cov/Inputs/branch-c-general.c
+++ b/llvm/test/tools/llvm-cov/Inputs/branch-c-general.c
@@ -6,16 +6,16 @@
void simple_loops() { // CHECK: @LINE|{{.*}}simple_loops()
int i;
- for (i = 0; i < 100; ++i) { // BRCOV: Branch ([[@LINE]]:15): [True: [[#min(C,100)]], False: 1]
+ for (i = 0; i < 100; ++i) { // CHECK: Branch ([[@LINE]]:15): [True: [[#min(C,100)]], False: 1]
}
- while (i > 0) // BRCOV: Branch ([[@LINE]]:10): [True: [[#min(C,100)]], False: 1]
+ while (i > 0) // CHECK: Branch ([[@LINE]]:10): [True: [[#min(C,100)]], False: 1]
i--;
- do {} while (i++ < 75); // BRCOV: Branch ([[@LINE]]:16): [True: [[#min(C,75)]], False: 1]
+ do {} while (i++ < 75); // CHECK: Branch ([[@LINE]]:16): [True: [[#min(C,75)]], False: 1]
}
void conditionals() { // CHECK: @LINE|{{.*}}conditionals()
- for (int i = 0; i < 100; ++i) {//BRCOV: Branch ([[@LINE]]:19): [True: [[#min(C,100)]], False: 1]
+ for (int i = 0; i < 100; ++i) {//CHECK: Branch ([[@LINE]]:19): [True: [[#min(C,100)]], False: 1]
if (i % 2) { // BRCOV: Branch ([[@LINE]]:9): [True: [[#min(C,50)]], False: [[#min(C,50)]]]
if (i) {} // BRCOV: Branch ([[@LINE]]:11): [True: [[#min(C,50)]], False: 0]
} else if (i % 3) { // BRCOV: Branch ([[@LINE]]:16): [True: [[#min(C,33)]], False: [[#min(C,17)]]]
@@ -35,7 +35,7 @@ void early_exits() { // CHECK: @LINE|{{.*}}early_exits()
if (i) {} // BRCOV: Branch ([[@LINE]]:7): [True: 0, False: 1]
- while (i < 100) { // BRCOV: Branch ([[@LINE]]:10): [True: [[#min(C,51)]], False: 0]
+ while (i < 100) { // CHECK: Branch ([[@LINE]]:10): [True: [[#min(C,51)]], False: 0]
i++;
if (i > 50) // BRCOV: Branch ([[@LINE]]:9): [True: 1, False: [[#min(C,50)]]]
break;
@@ -50,7 +50,7 @@ void early_exits() { // CHECK: @LINE|{{.*}}early_exits()
return;
else
i++;
- } while (i < 100); // BRCOV: Branch ([[@LINE]]:12): [True: [[#min(C,25)]], False: 0]
+ } while (i < 100); // CHECK: Branch ([[@LINE]]:12): [True: [[#min(C,25)]], False: 0]
if (i) {} // BRCOV: Branch ([[@LINE]]:7): [True: 0, False: 0]
@@ -59,7 +59,7 @@ void early_exits() { // CHECK: @LINE|{{.*}}early_exits()
void jumps() { // CHECK: @LINE|{{.*}}jumps()
int i;
- for (i = 0; i < 2; ++i) { // BRCOV: Branch ([[@LINE]]:15): [True: 1, False: 0]
+ for (i = 0; i < 2; ++i) { // CHECK: Branch ([[@LINE]]:15): [True: 1, False: 0]
goto outofloop;
// Never reached -> no weights
if (i) {} // BRCOV: Branch ([[@LINE]]:9): [True: 0, False: 0]
@@ -70,7 +70,7 @@ void jumps() { // CHECK: @LINE|{{.*}}jumps()
goto loop1;
- while (i) { // BRCOV: Branch ([[@LINE]]:10): [True: 0, False: 1]
+ while (i) { // CHECK: Branch ([[@LINE]]:10): [True: 0, False: 1]
loop1:
if (i) {} // BRCOV: Branch ([[@LINE]]:9): [True: 0, False: 1]
}
@@ -83,7 +83,7 @@ void jumps() { // CHECK: @LINE|{{.*}}jumps()
if (i < 3) // BRCOV: Branch ([[@LINE]]:7): [True: [[#min(C,2)]], False: 1]
goto loop2;
- while (i < 3) { // BRCOV: Branch ([[@LINE]]:10): [True: 0, False: 1]
+ while (i < 3) { // CHECK: Branch ([[@LINE]]:10): [True: 0, False: 1]
loop2:
switch (i) {
case 0: // BRCOV: Branch ([[@LINE]]:5): [True: 1, Folded]
@@ -95,7 +95,7 @@ void jumps() { // CHECK: @LINE|{{.*}}jumps()
}
}
- for (i = 0; i < 10; ++i) { // BRCOV: Branch ([[@LINE]]:15): [True: [[#min(C,10)]], False: 1]
+ for (i = 0; i < 10; ++i) { // CHECK: Branch ([[@LINE]]:15): [True: [[#min(C,10)]], False: 1]
goto withinloop;
// never reached -> no weights
if (i) {} // BRCOV: Branch ([[@LINE]]:9): [True: 0, False: 0]
@@ -113,7 +113,7 @@ void switches() { // CHECK: @LINE|{{.*}}switches()
default: // BRCOV: Branch ([[@LINE]]:3): [True: 1, Folded]
break;
}
- // BRCOV: Branch ([[@LINE+1]]:63): [True: [[#min(C,15)]], False: 0]
+ // CHECK: Branch ([[@LINE+1]]:63): [True: [[#min(C,15)]], False: 0]
for (int i = 0, len = sizeof(weights) / sizeof(weights[0]); i < len; ++i) {
switch (i[weights]) {
case 1: // BRCOV: Branch ([[@LINE]]:5): [True: 1, Folded]
@@ -145,7 +145,7 @@ void switches() { // CHECK: @LINE|{{.*}}switches()
}
void big_switch() { // CHECK: @LINE|{{.*}}big_switch()
- for (int i = 0; i < 32; ++i) {// BRCOV: Branch ([[@LINE]]:19): [True: [[#min(C,32)]], False: 1]
+ for (int i = 0; i < 32; ++i) {// CHECK: Branch ([[@LINE]]:19): [True: [[#min(C,32)]], False: 1]
switch (1 << i) {
case (1 << 0): // BRCOV: Branch ([[@LINE]]:5): [True: 1, Folded]
if (i) {} // BRCOV: Branch ([[@LINE]]:11): [True: 0, False: 1]
@@ -216,7 +216,7 @@ void conditional_operator() { // CHECK: @LINE|{{.*}}conditional_operator()
}
void do_fallthrough() { // CHECK: @LINE|{{.*}}do_fallthrough()
- for (int i = 0; i < 10; ++i) {// BRCOV: Branch ([[@LINE]]:19): [True: [[#min(C,10)]], False: 1]
+ for (int i = 0; i < 10; ++i) {// CHECK: Branch ([[@LINE]]:19): [True: [[#min(C,10)]], False: 1]
int j = 0;
do {
// The number of exits out of this do-loop via the break statement
@@ -224,12 +224,12 @@ void do_fallthrough() { // CHECK: @LINE|{{.*}}do_fallthrough()
// fallthrough count). Make sure that does not violate any assertions.
if (i < 8) break;
j++;
- } while (j < 2); // BRCOV: Branch ([[@LINE]]:14): [True: [[#min(C,2)]], False: [[#min(C,2)]]]
+ } while (j < 2); // CHECK: Branch ([[@LINE]]:14): [True: [[#min(C,2)]], False: [[#min(C,2)]]]
}
}
static void static_func() { // CHECK: @LINE|{{.*}}static_func()
- for (int i = 0; i < 10; ++i) {// BRCOV: Branch ([[@LINE]]:19): [True: [[#min(C,10)]], False: 1]
+ for (int i = 0; i < 10; ++i) {// CHECK: Branch ([[@LINE]]:19): [True: [[#min(C,10)]], False: 1]
}
}
diff --git a/llvm/test/tools/llvm-cov/Inputs/showLineExecutionCounts-single.proftext b/llvm/test/tools/llvm-cov/Inputs/showLineExecutionCounts-single.proftext
index d8af6ef7fc615..bd3ce1c51e785 100644
--- a/llvm/test/tools/llvm-cov/Inputs/showLineExecutionCounts-single.proftext
+++ b/llvm/test/tools/llvm-cov/Inputs/showLineExecutionCounts-single.proftext
@@ -2,9 +2,9 @@
:single_byte_coverage
main
# Func Hash:
-15239891155360101223
+251911595471090535
# Num Counters:
-12
+9
# Counter Values:
161
0
@@ -12,9 +12,6 @@ main
161
161
161
-161
-161
-161
0
0
161
diff --git a/llvm/test/tools/llvm-cov/Inputs/showLineExecutionCounts-single.yaml b/llvm/test/tools/llvm-cov/Inputs/showLineExecutionCounts-single.yaml
index a836189245273..934cea985a109 100644
--- a/llvm/test/tools/llvm-cov/Inputs/showLineExecutionCounts-single.yaml
+++ b/llvm/test/tools/llvm-cov/Inputs/showLineExecutionCounts-single.yaml
@@ -11,7 +11,7 @@ Sections:
Type: SHT_PROGBITS
Flags: [ SHF_GNU_RETAIN ]
AddressAlign: 0x8
- Content: FAD58DE7366495DB9E0000006733DBEA42F87ED3C60E0B951FF3509D0101001A01060C130210020100010101070008050009008A8080800805000A0204090204008A8080800809000A020410030100010D01030A02110013001A15001C001F19002000A180808008190021020410030100011D0103050B1D0007000D2021290007000D21000F0090808080082100100015290018001D1D0107000D20252D0007000D25000F018980808008250109000E2D0109000E1001010001
+ Content: FAD58DE7366495DBA20000006733DBEA42F87E03C60E0B951FF3509D0101010D111A01060C130210020100010101070008050009008A8080800805000A0204090204008A8080800809000A020410030100010D0103090B030013001A20110D0013001A11001C001F11002000A180808008110021020410030100010D0107000D20151D0007000D15000F00908080800815001000151D0018001D0D0107000D2019210007000D19000F018980808008190109000E210109000E1001010001
- Name: __llvm_covmap
Type: SHT_PROGBITS
Flags: [ SHF_GNU_RETAIN ]
@@ -40,6 +40,6 @@ Symbols:
Type: STT_OBJECT
Section: __llvm_covfun
Binding: STB_WEAK
- Size: 0xBA
+ Size: 0xBE
Other: [ STV_HIDDEN ]
...
More information about the cfe-commits
mailing list