diff options
author | Alan Phipps <a-phipps@ti.com> | 2020-12-28 11:20:48 -0600 |
---|---|---|
committer | Alan Phipps <a-phipps@ti.com> | 2021-01-05 09:51:51 -0600 |
commit | 9f2967bcfe2f7d1fc02281f0098306c90c2c10a5 (patch) | |
tree | a29793dac7b81d67601905911a389a2cf2cdde2e /clang/lib/CodeGen/CodeGenFunction.h | |
parent | 53c3acb89fcc25ba7ef1f1d76a79c241eeacb7f0 (diff) | |
download | llvm-9f2967bcfe2f7d1fc02281f0098306c90c2c10a5.zip llvm-9f2967bcfe2f7d1fc02281f0098306c90c2c10a5.tar.gz llvm-9f2967bcfe2f7d1fc02281f0098306c90c2c10a5.tar.bz2 |
[Coverage] Add support for Branch Coverage in LLVM Source-Based Code Coverage
This is an enhancement to LLVM Source-Based Code Coverage in clang to track how
many times individual branch-generating conditions are taken (evaluate to TRUE)
and not taken (evaluate to FALSE). Individual conditions may comprise larger
boolean expressions using boolean logical operators. This functionality is
very similar to what is supported by GCOV except that it is very closely
anchored to the ASTs.
Differential Revision: https://reviews.llvm.org/D84467
Diffstat (limited to 'clang/lib/CodeGen/CodeGenFunction.h')
-rw-r--r-- | clang/lib/CodeGen/CodeGenFunction.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CodeGenFunction.h b/clang/lib/CodeGen/CodeGenFunction.h index 142cf5d..9d11466 100644 --- a/clang/lib/CodeGen/CodeGenFunction.h +++ b/clang/lib/CodeGen/CodeGenFunction.h @@ -4394,6 +4394,21 @@ public: bool ConstantFoldsToSimpleInteger(const Expr *Cond, llvm::APSInt &Result, bool AllowLabels = false); + /// isInstrumentedCondition - Determine whether the given condition is an + /// instrumentable condition (i.e. no "&&" or "||"). + static bool isInstrumentedCondition(const Expr *C); + + /// EmitBranchToCounterBlock - Emit a conditional branch to a new block that + /// increments a profile counter based on the semantics of the given logical + /// operator opcode. This is used to instrument branch condition coverage + /// for logical operators. + void EmitBranchToCounterBlock(const Expr *Cond, BinaryOperator::Opcode LOp, + llvm::BasicBlock *TrueBlock, + llvm::BasicBlock *FalseBlock, + uint64_t TrueCount = 0, + Stmt::Likelihood LH = Stmt::LH_None, + const Expr *CntrIdx = nullptr); + /// EmitBranchOnBoolExpr - Emit a branch on a boolean condition (e.g. for an /// if statement) to the specified blocks. Based on the condition, this might /// try to simplify the codegen of the conditional based on the branch. |