aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CodeGenFunction.h
diff options
context:
space:
mode:
authorNikita Popov <npopov@redhat.com>2025-06-02 09:51:54 +0200
committerGitHub <noreply@github.com>2025-06-02 09:51:54 +0200
commite2b536431d85c49cdfad5106d116ced683a0667a (patch)
tree2bdba9709f113c45d9ff4d8f591a72013b81264e /clang/lib/CodeGen/CodeGenFunction.h
parent9801fdf669bf6e61e276732a95c2f885cb2a39d9 (diff)
downloadllvm-e2b536431d85c49cdfad5106d116ced683a0667a.zip
llvm-e2b536431d85c49cdfad5106d116ced683a0667a.tar.gz
llvm-e2b536431d85c49cdfad5106d116ced683a0667a.tar.bz2
[CodeGen] Move CodeGenPGO behind unique_ptr (NFC) (#142155)
The InstrProf headers are very expensive. Avoid including them in all of CodeGen/ by moving the CodeGenPGO member behind a unqiue_ptr. This reduces clang build time by 0.8%.
Diffstat (limited to 'clang/lib/CodeGen/CodeGenFunction.h')
-rw-r--r--clang/lib/CodeGen/CodeGenFunction.h52
1 files changed, 12 insertions, 40 deletions
diff --git a/clang/lib/CodeGen/CodeGenFunction.h b/clang/lib/CodeGen/CodeGenFunction.h
index 92e9ab8..bdd19f4 100644
--- a/clang/lib/CodeGen/CodeGenFunction.h
+++ b/clang/lib/CodeGen/CodeGenFunction.h
@@ -17,7 +17,6 @@
#include "CGLoopInfo.h"
#include "CGValue.h"
#include "CodeGenModule.h"
-#include "CodeGenPGO.h"
#include "EHScopeStack.h"
#include "VarBypassDetector.h"
#include "clang/AST/CharUnits.h"
@@ -90,6 +89,7 @@ class OSLogBufferLayout;
namespace CodeGen {
class CodeGenTypes;
+class CodeGenPGO;
class CGCallee;
class CGFunctionInfo;
class CGBlockInfo;
@@ -1670,7 +1670,7 @@ private:
llvm::Value *emitCondLikelihoodViaExpectIntrinsic(llvm::Value *Cond,
Stmt::Likelihood LH);
- CodeGenPGO PGO;
+ std::unique_ptr<CodeGenPGO> PGO;
/// Bitmap used by MC/DC to track condition outcomes of a boolean expression.
Address MCDCCondBitmapAddr = Address::invalid();
@@ -1683,12 +1683,9 @@ private:
uint64_t LoopCount) const;
public:
- auto getIsCounterPair(const Stmt *S) const { return PGO.getIsCounterPair(S); }
-
- void markStmtAsUsed(bool Skipped, const Stmt *S) {
- PGO.markStmtAsUsed(Skipped, S);
- }
- void markStmtMaybeUsed(const Stmt *S) { PGO.markStmtMaybeUsed(S); }
+ std::pair<bool, bool> getIsCounterPair(const Stmt *S) const;
+ void markStmtAsUsed(bool Skipped, const Stmt *S);
+ void markStmtMaybeUsed(const Stmt *S);
/// Increment the profiler's counter for the given statement by \p StepV.
/// If \p StepV is null, the default increment is 1.
@@ -1702,13 +1699,7 @@ public:
/// Allocate a temp value on the stack that MCDC can use to track condition
/// results.
- void maybeCreateMCDCCondBitmap() {
- if (isMCDCCoverageEnabled()) {
- PGO.emitMCDCParameters(Builder);
- MCDCCondBitmapAddr =
- CreateIRTemp(getContext().UnsignedIntTy, "mcdc.addr");
- }
- }
+ void maybeCreateMCDCCondBitmap();
bool isBinaryLogicalOp(const Expr *E) const {
const BinaryOperator *BOp = dyn_cast<BinaryOperator>(E->IgnoreParens());
@@ -1716,43 +1707,24 @@ public:
}
/// Zero-init the MCDC temp value.
- void maybeResetMCDCCondBitmap(const Expr *E) {
- if (isMCDCCoverageEnabled() && isBinaryLogicalOp(E)) {
- PGO.emitMCDCCondBitmapReset(Builder, E, MCDCCondBitmapAddr);
- PGO.setCurrentStmt(E);
- }
- }
+ void maybeResetMCDCCondBitmap(const Expr *E);
/// Increment the profiler's counter for the given expression by \p StepV.
/// If \p StepV is null, the default increment is 1.
- void maybeUpdateMCDCTestVectorBitmap(const Expr *E) {
- if (isMCDCCoverageEnabled() && isBinaryLogicalOp(E)) {
- PGO.emitMCDCTestVectorBitmapUpdate(Builder, E, MCDCCondBitmapAddr, *this);
- PGO.setCurrentStmt(E);
- }
- }
+ void maybeUpdateMCDCTestVectorBitmap(const Expr *E);
/// Update the MCDC temp value with the condition's evaluated result.
- void maybeUpdateMCDCCondBitmap(const Expr *E, llvm::Value *Val) {
- if (isMCDCCoverageEnabled()) {
- PGO.emitMCDCCondBitmapUpdate(Builder, E, MCDCCondBitmapAddr, Val, *this);
- PGO.setCurrentStmt(E);
- }
- }
+ void maybeUpdateMCDCCondBitmap(const Expr *E, llvm::Value *Val);
/// Get the profiler's count for the given statement.
- uint64_t getProfileCount(const Stmt *S) {
- return PGO.getStmtCount(S).value_or(0);
- }
+ uint64_t getProfileCount(const Stmt *S);
/// Set the profiler's current count.
- void setCurrentProfileCount(uint64_t Count) {
- PGO.setCurrentRegionCount(Count);
- }
+ void setCurrentProfileCount(uint64_t Count);
/// Get the profiler's current count. This is generally the count for the most
/// recently incremented counter.
- uint64_t getCurrentProfileCount() { return PGO.getCurrentRegionCount(); }
+ uint64_t getCurrentProfileCount();
/// See CGDebugInfo::addInstToCurrentSourceAtom.
void addInstToCurrentSourceAtom(llvm::Instruction *KeyInstruction,