1717#include " CGLoopInfo.h"
1818#include " CGValue.h"
1919#include " CodeGenModule.h"
20- #include " CodeGenPGO.h"
2120#include " EHScopeStack.h"
2221#include " VarBypassDetector.h"
2322#include " clang/AST/CharUnits.h"
@@ -90,6 +89,7 @@ class OSLogBufferLayout;
9089
9190namespace CodeGen {
9291class CodeGenTypes ;
92+ class CodeGenPGO ;
9393class CGCallee ;
9494class CGFunctionInfo ;
9595class CGBlockInfo ;
@@ -1670,7 +1670,7 @@ class CodeGenFunction : public CodeGenTypeCache {
16701670 llvm::Value *emitCondLikelihoodViaExpectIntrinsic (llvm::Value *Cond,
16711671 Stmt::Likelihood LH);
16721672
1673- CodeGenPGO PGO;
1673+ std::unique_ptr< CodeGenPGO> PGO;
16741674
16751675 // / Bitmap used by MC/DC to track condition outcomes of a boolean expression.
16761676 Address MCDCCondBitmapAddr = Address::invalid();
@@ -1683,12 +1683,9 @@ class CodeGenFunction : public CodeGenTypeCache {
16831683 uint64_t LoopCount) const ;
16841684
16851685public:
1686- auto getIsCounterPair (const Stmt *S) const { return PGO.getIsCounterPair (S); }
1687-
1688- void markStmtAsUsed (bool Skipped, const Stmt *S) {
1689- PGO.markStmtAsUsed (Skipped, S);
1690- }
1691- void markStmtMaybeUsed (const Stmt *S) { PGO.markStmtMaybeUsed (S); }
1686+ std::pair<bool , bool > getIsCounterPair (const Stmt *S) const ;
1687+ void markStmtAsUsed (bool Skipped, const Stmt *S);
1688+ void markStmtMaybeUsed (const Stmt *S);
16921689
16931690 // / Increment the profiler's counter for the given statement by \p StepV.
16941691 // / If \p StepV is null, the default increment is 1.
@@ -1702,57 +1699,32 @@ class CodeGenFunction : public CodeGenTypeCache {
17021699
17031700 // / Allocate a temp value on the stack that MCDC can use to track condition
17041701 // / results.
1705- void maybeCreateMCDCCondBitmap () {
1706- if (isMCDCCoverageEnabled ()) {
1707- PGO.emitMCDCParameters (Builder);
1708- MCDCCondBitmapAddr =
1709- CreateIRTemp (getContext ().UnsignedIntTy , " mcdc.addr" );
1710- }
1711- }
1702+ void maybeCreateMCDCCondBitmap ();
17121703
17131704 bool isBinaryLogicalOp (const Expr *E) const {
17141705 const BinaryOperator *BOp = dyn_cast<BinaryOperator>(E->IgnoreParens ());
17151706 return (BOp && BOp->isLogicalOp ());
17161707 }
17171708
17181709 // / Zero-init the MCDC temp value.
1719- void maybeResetMCDCCondBitmap (const Expr *E) {
1720- if (isMCDCCoverageEnabled () && isBinaryLogicalOp (E)) {
1721- PGO.emitMCDCCondBitmapReset (Builder, E, MCDCCondBitmapAddr);
1722- PGO.setCurrentStmt (E);
1723- }
1724- }
1710+ void maybeResetMCDCCondBitmap (const Expr *E);
17251711
17261712 // / Increment the profiler's counter for the given expression by \p StepV.
17271713 // / If \p StepV is null, the default increment is 1.
1728- void maybeUpdateMCDCTestVectorBitmap (const Expr *E) {
1729- if (isMCDCCoverageEnabled () && isBinaryLogicalOp (E)) {
1730- PGO.emitMCDCTestVectorBitmapUpdate (Builder, E, MCDCCondBitmapAddr, *this );
1731- PGO.setCurrentStmt (E);
1732- }
1733- }
1714+ void maybeUpdateMCDCTestVectorBitmap (const Expr *E);
17341715
17351716 // / Update the MCDC temp value with the condition's evaluated result.
1736- void maybeUpdateMCDCCondBitmap (const Expr *E, llvm::Value *Val) {
1737- if (isMCDCCoverageEnabled ()) {
1738- PGO.emitMCDCCondBitmapUpdate (Builder, E, MCDCCondBitmapAddr, Val, *this );
1739- PGO.setCurrentStmt (E);
1740- }
1741- }
1717+ void maybeUpdateMCDCCondBitmap (const Expr *E, llvm::Value *Val);
17421718
17431719 // / Get the profiler's count for the given statement.
1744- uint64_t getProfileCount (const Stmt *S) {
1745- return PGO.getStmtCount (S).value_or (0 );
1746- }
1720+ uint64_t getProfileCount (const Stmt *S);
17471721
17481722 // / Set the profiler's current count.
1749- void setCurrentProfileCount (uint64_t Count) {
1750- PGO.setCurrentRegionCount (Count);
1751- }
1723+ void setCurrentProfileCount (uint64_t Count);
17521724
17531725 // / Get the profiler's current count. This is generally the count for the most
17541726 // / recently incremented counter.
1755- uint64_t getCurrentProfileCount () { return PGO. getCurrentRegionCount (); }
1727+ uint64_t getCurrentProfileCount ();
17561728
17571729 // / See CGDebugInfo::addInstToCurrentSourceAtom.
17581730 void addInstToCurrentSourceAtom (llvm::Instruction *KeyInstruction,
0 commit comments