-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[Coverage] Make additional counters available for BranchRegion. NFC. #120930
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
This return a counter for each term in the expression replaced by ReplaceMap. At the moment, this doesn't update the Map, so Map is marked as `const`.
This aggregates the generation of branch counter pair as `ExecCnt` and `SkipCnt`, to aggregate `CounterExpr::subtract`. At the moment: - This change preserves the behavior of `llvm::EnableSingleByteCoverage`. Almost of SingleByteCoverage will be cleaned up by coming commits. - `getBranchCounterPair()` is not called in `llvm::EnableSingleByteCoverage`. I will implement the new behavior of SingleByteCoverage in it. - `IsCounterEqual(Out, Par)` is introduced instead of `Counter::operator==`. Tweaks would be required for the comparison for additional counters. - Braces around `assert()` is intentional. I will add a statement there. https://discourse.llvm.org/t/rfc-integrating-singlebytecoverage-with-branch-coverage/82492
`CounterPair` can hold `<uint32_t, uint32_t>` instead of current `unsigned`, to hold also the counter number of SkipPath. For now, this change provides the skeleton and only `CounterPair::first` is used. Each counter number can have `None` to suppress emitting counter increment. `second` is initialized as `None` by default, since most `Stmt*` don't have a pair of counters. This change also provides stubs for the verifyer. I'll provide the impl of verifier for `+Asserts` later. `markStmtAsUsed(bool, Stmt*)` may be used to inform that other side counter may not emitted. `markStmtMaybeUsed(S)` may be used for the `Stmt` and its inner will be excluded for emission in the case of skipping by constant folding. I put it into places where I found. `verifyCounterMap()` will check the coverage map the counter map and can be used to report inconsistency. These verifier methods shall be eliminated in `-Asserts`. https://discourse.llvm.org/t/rfc-integrating-singlebytecoverage-with-branch-coverage/82492
…/single/replace' and 'users/chapuni/cov/single/pair' into HEAD
`getBranchCounterPair()` allocates an additional Counter to SkipPath in `SingleByteCoverage`. `IsCounterEqual()` calculates the comparison with rewinding counter replacements. `NumRegionCounters` is updated to take additional counters in account. `incrementProfileCounter()` has a few additiona arguments. - `UseSkipPath=true`, to specify setting counters for SkipPath. It assumes `UseSkipPath=false` is used together. - `UseBoth` may be specified for marking another path. It introduces the same effect as issueing `markStmtAsUsed(!SkipPath, S)`. `llvm-cov` discovers counters in `FalseCount` to allocate `MaxCounterID` for empty profile data.
…cov/single/replace' into users/chapuni/cov/single/nextcount-base
…puni/cov/single/nextcount
Currently `first` is not None by default.
…/single/getpair' into users/chapuni/cov/single/nextcount-base
Conflicts: clang/lib/CodeGen/CoverageMappingGen.cpp
…ingle/nextcount-base
…v/single/nextcount-base
…v/single/nextcount-base
…puni/cov/single/nextcount Conflicts: clang/lib/CodeGen/CoverageMappingGen.cpp
Conflicts: clang/lib/CodeGen/CoverageMappingGen.cpp llvm/include/llvm/ProfileData/Coverage/CoverageMapping.h
…puni/cov/single/nextcount Conflicts: clang/lib/CodeGen/CodeGenPGO.cpp clang/lib/CodeGen/CoverageMappingGen.cpp
…v/single/nextcount-base
…puni/cov/single/nextcount
…v/single/nextcount-base
…puni/cov/single/nextcount Conflicts: clang/lib/CodeGen/CoverageMappingGen.cpp
@@ -1627,14 +1627,31 @@ class CodeGenFunction : public CodeGenTypeCache { | |||
} | |||
void markStmtMaybeUsed(const Stmt *S) { PGO.markStmtMaybeUsed(S); } | |||
|
|||
enum CounterForIncrement { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doxygen comment would be useful here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is the meaning of "exec counter" and "skip counter" defined anywhere? if not, it would be good to do that here.
@@ -884,6 +884,9 @@ struct CounterCoverageMappingBuilder | |||
/// The map of statements to count values. | |||
llvm::DenseMap<const Stmt *, CounterPair> &CounterMap; | |||
|
|||
CounterExpressionBuilder::SubstMap MapToExpand; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MapToExpand could use a doxygen comment explaining what it is
…ingle/nextcount-base
…puni/cov/single/nextcount
getBranchCounterPair()
allocates an additional Counter to SkipPath inSingleByteCoverage
.IsCounterEqual()
calculates the comparison with rewinding counter replacements.NumRegionCounters
is updated to take additional counters in account.incrementProfileCounter()
has a few additiona arguments.UseSkipPath=true
, to specify setting counters for SkipPath. It assumesUseSkipPath=false
is used together.UseBoth
may be specified for marking another path. It introduces the same effect as issueingmarkStmtAsUsed(!SkipPath, S)
.llvm-cov
discovers counters inFalseCount
to allocateMaxCounterID
for empty profile data.https://discourse.llvm.org/t/rfc-integrating-singlebytecoverage-with-branch-coverage/82492
Resumes: #112730
Depends on: #112698 #112702 #112724