From e2b536431d85c49cdfad5106d116ced683a0667a Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Mon, 2 Jun 2025 09:51:54 +0200 Subject: [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%. --- clang/lib/CodeGen/CodeGenFunction.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'clang/lib/CodeGen/CodeGenFunction.cpp') diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp index 4193f0a..0388c67 100644 --- a/clang/lib/CodeGen/CodeGenFunction.cpp +++ b/clang/lib/CodeGen/CodeGenFunction.cpp @@ -80,7 +80,8 @@ CodeGenFunction::CodeGenFunction(CodeGenModule &cgm, bool suppressNewContext) Builder(cgm, cgm.getModule().getContext(), llvm::ConstantFolder(), CGBuilderInserterTy(this)), SanOpts(CGM.getLangOpts().Sanitize), CurFPFeatures(CGM.getLangOpts()), - DebugInfo(CGM.getModuleDebugInfo()), PGO(cgm), + DebugInfo(CGM.getModuleDebugInfo()), + PGO(std::make_unique(cgm)), ShouldEmitLifetimeMarkers( shouldEmitLifetimeMarkers(CGM.getCodeGenOpts(), CGM.getLangOpts())) { if (!suppressNewContext) @@ -1564,7 +1565,7 @@ void CodeGenFunction::GenerateCode(GlobalDecl GD, llvm::Function *Fn, CurFn->addFnAttr(llvm::Attribute::MustProgress); // Generate the body of the function. - PGO.assignRegionCounters(GD, CurFn); + PGO->assignRegionCounters(GD, CurFn); if (isa(FD)) EmitDestructorBody(Args); else if (isa(FD)) @@ -1650,7 +1651,7 @@ void CodeGenFunction::GenerateCode(GlobalDecl GD, llvm::Function *Fn, // Emit the standard function epilogue. FinishFunction(BodyRange.getEnd()); - PGO.verifyCounterMap(); + PGO->verifyCounterMap(); // If we haven't marked the function nothrow through other means, do // a quick pass now to see if we can. @@ -1774,7 +1775,7 @@ bool CodeGenFunction::ConstantFoldsToSimpleInteger(const Expr *Cond, if (!AllowLabels && CodeGenFunction::ContainsLabel(Cond)) return false; // Contains a label. - PGO.markStmtMaybeUsed(Cond); + PGO->markStmtMaybeUsed(Cond); ResultInt = Int; return true; } @@ -3355,4 +3356,4 @@ void CodeGenFunction::addInstToNewSourceAtom(llvm::Instruction *KeyInstruction, ApplyAtomGroup Grp(getDebugInfo()); DI->addInstToCurrentSourceAtom(KeyInstruction, Backup); } -} \ No newline at end of file +} -- cgit v1.1