-
Notifications
You must be signed in to change notification settings - Fork 13.3k
[CodeGen] Use pimpl idiom for CVTables (NFC) #134217
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
Avoid pulling in the CVTables.h header in CodeGenModules.h by putting the member behind a unique_ptr. This had less impact than I was hoping, with only a 0.15% reduction in build time for clang. Apparently the expensive parts of CGVTables.h still get included via other pathways.
@llvm/pr-subscribers-backend-loongarch @llvm/pr-subscribers-clang Author: Nikita Popov (nikic) ChangesAvoid pulling in the CVTables.h header in CodeGenModules.h by putting the member behind a unique_ptr. This had less impact than I was hoping, with only a 0.15% reduction in build time for clang. Apparently the expensive parts of CGVTables.h still get included via other pathways. Full diff: https://github.com/llvm/llvm-project/pull/134217.diff 24 Files Affected:
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 310addebd50e9..0ab0bb860bfa2 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -25,6 +25,7 @@
#include "PatternInit.h"
#include "TargetInfo.h"
#include "clang/AST/OSLog.h"
+#include "clang/AST/RecordLayout.h"
#include "clang/AST/StmtVisitor.h"
#include "clang/Basic/TargetBuiltins.h"
#include "clang/Basic/TargetInfo.h"
diff --git a/clang/lib/CodeGen/CGCXX.cpp b/clang/lib/CodeGen/CGCXX.cpp
index 6f47e24eed5b3..668812b498e1c 100644
--- a/clang/lib/CodeGen/CGCXX.cpp
+++ b/clang/lib/CodeGen/CGCXX.cpp
@@ -13,6 +13,7 @@
// We might split this into multiple files if it gets too unwieldy
#include "CGCXXABI.h"
+#include "CGVTables.h"
#include "CodeGenFunction.h"
#include "CodeGenModule.h"
#include "clang/AST/ASTContext.h"
diff --git a/clang/lib/CodeGen/CGCXXABI.cpp b/clang/lib/CodeGen/CGCXXABI.cpp
index 9f77fbec21380..7e21d5a72616e 100644
--- a/clang/lib/CodeGen/CGCXXABI.cpp
+++ b/clang/lib/CodeGen/CGCXXABI.cpp
@@ -14,6 +14,7 @@
#include "CGCXXABI.h"
#include "CGCleanup.h"
#include "clang/AST/Attr.h"
+#include "clang/AST/RecordLayout.h"
using namespace clang;
using namespace CodeGen;
diff --git a/clang/lib/CodeGen/CGCXXABI.h b/clang/lib/CodeGen/CGCXXABI.h
index 148a7ba6df7e6..ed4c9fdf8540a 100644
--- a/clang/lib/CodeGen/CGCXXABI.h
+++ b/clang/lib/CodeGen/CGCXXABI.h
@@ -32,6 +32,7 @@ class CXXDestructorDecl;
class CXXMethodDecl;
class CXXRecordDecl;
class MangleContext;
+struct ReturnAdjustment;
namespace CodeGen {
class CGCallee;
diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index b202255c3a15b..0b2947256af0f 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -26,6 +26,7 @@
#include "clang/AST/Decl.h"
#include "clang/AST/DeclCXX.h"
#include "clang/AST/DeclObjC.h"
+#include "clang/AST/RecordLayout.h"
#include "clang/Basic/CodeGenOptions.h"
#include "clang/Basic/TargetInfo.h"
#include "clang/CodeGen/CGFunctionInfo.h"
diff --git a/clang/lib/CodeGen/CGClass.cpp b/clang/lib/CodeGen/CGClass.cpp
index c683dbb0af825..0d6c50d9cb00f 100644
--- a/clang/lib/CodeGen/CGClass.cpp
+++ b/clang/lib/CodeGen/CGClass.cpp
@@ -15,6 +15,7 @@
#include "CGCXXABI.h"
#include "CGDebugInfo.h"
#include "CGRecordLayout.h"
+#include "CGVTables.h"
#include "CodeGenFunction.h"
#include "TargetInfo.h"
#include "clang/AST/Attr.h"
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp
index d659243d38d5f..abdb0827ff5c5 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -15,6 +15,7 @@
#include "CGCXXABI.h"
#include "CGObjCRuntime.h"
#include "CGRecordLayout.h"
+#include "CGVTables.h"
#include "CodeGenFunction.h"
#include "CodeGenModule.h"
#include "ConstantEmitter.h"
diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index 3d3a111f0514a..a29c3014740d6 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -28,6 +28,7 @@
#include "clang/AST/Attr.h"
#include "clang/AST/DeclObjC.h"
#include "clang/AST/NSAPI.h"
+#include "clang/AST/RecordLayout.h"
#include "clang/AST/StmtVisitor.h"
#include "clang/Basic/Builtins.h"
#include "clang/Basic/CodeGenOptions.h"
diff --git a/clang/lib/CodeGen/CGExprAgg.cpp b/clang/lib/CodeGen/CGExprAgg.cpp
index 87b2a73fb0c03..87a85fb67c482 100644
--- a/clang/lib/CodeGen/CGExprAgg.cpp
+++ b/clang/lib/CodeGen/CGExprAgg.cpp
@@ -24,6 +24,7 @@
#include "clang/AST/Attr.h"
#include "clang/AST/DeclCXX.h"
#include "clang/AST/DeclTemplate.h"
+#include "clang/AST/RecordLayout.h"
#include "clang/AST/StmtVisitor.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/Function.h"
diff --git a/clang/lib/CodeGen/CGExprCXX.cpp b/clang/lib/CodeGen/CGExprCXX.cpp
index 5c11c0bceade7..11f26f362ba14 100644
--- a/clang/lib/CodeGen/CGExprCXX.cpp
+++ b/clang/lib/CodeGen/CGExprCXX.cpp
@@ -17,6 +17,7 @@
#include "CodeGenFunction.h"
#include "ConstantEmitter.h"
#include "TargetInfo.h"
+#include "clang/AST/RecordLayout.h"
#include "clang/Basic/CodeGenOptions.h"
#include "clang/CodeGen/CGFunctionInfo.h"
#include "llvm/IR/Intrinsics.h"
diff --git a/clang/lib/CodeGen/CGNonTrivialStruct.cpp b/clang/lib/CodeGen/CGNonTrivialStruct.cpp
index c634b5c010e2d..b8a99744429b5 100644
--- a/clang/lib/CodeGen/CGNonTrivialStruct.cpp
+++ b/clang/lib/CodeGen/CGNonTrivialStruct.cpp
@@ -15,6 +15,7 @@
#include "CodeGenFunction.h"
#include "CodeGenModule.h"
#include "clang/AST/NonTrivialTypeVisitor.h"
+#include "clang/AST/RecordLayout.h"
#include "clang/CodeGen/CodeGenABITypes.h"
#include "llvm/Support/ScopedPrinter.h"
#include <array>
diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index 5736864d4cc6b..27a04e0fbb80f 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -22,6 +22,7 @@
#include "clang/AST/Attr.h"
#include "clang/AST/Decl.h"
#include "clang/AST/OpenMPClause.h"
+#include "clang/AST/RecordLayout.h"
#include "clang/AST/StmtOpenMP.h"
#include "clang/AST/StmtVisitor.h"
#include "clang/Basic/OpenMPKinds.h"
diff --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp b/clang/lib/CodeGen/CGStmtOpenMP.cpp
index 156f64bb5f508..6d2c45bf6e8ae 100644
--- a/clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -20,6 +20,7 @@
#include "clang/AST/Attr.h"
#include "clang/AST/DeclOpenMP.h"
#include "clang/AST/OpenMPClause.h"
+#include "clang/AST/RecordLayout.h"
#include "clang/AST/Stmt.h"
#include "clang/AST/StmtOpenMP.h"
#include "clang/AST/StmtVisitor.h"
diff --git a/clang/lib/CodeGen/CGVTT.cpp b/clang/lib/CodeGen/CGVTT.cpp
index 989a07d09d50e..3b7ed00a3e484 100644
--- a/clang/lib/CodeGen/CGVTT.cpp
+++ b/clang/lib/CodeGen/CGVTT.cpp
@@ -10,8 +10,9 @@
//
//===----------------------------------------------------------------------===//
-#include "CodeGenModule.h"
#include "CGCXXABI.h"
+#include "CGVTables.h"
+#include "CodeGenModule.h"
#include "clang/AST/RecordLayout.h"
#include "clang/AST/VTTBuilder.h"
using namespace clang;
diff --git a/clang/lib/CodeGen/CGVTables.cpp b/clang/lib/CodeGen/CGVTables.cpp
index 0a1cf24fbfa56..60e0f4ab54bcf 100644
--- a/clang/lib/CodeGen/CGVTables.cpp
+++ b/clang/lib/CodeGen/CGVTables.cpp
@@ -10,6 +10,7 @@
//
//===----------------------------------------------------------------------===//
+#include "CGVTables.h"
#include "CGCXXABI.h"
#include "CGDebugInfo.h"
#include "CodeGenFunction.h"
@@ -1190,7 +1191,7 @@ CodeGenModule::getVTableLinkage(const CXXRecordDecl *RD) {
/// functions). For weak vtables, CodeGen tracks when they are needed and
/// emits them as-needed.
void CodeGenModule::EmitVTable(CXXRecordDecl *theClass) {
- VTables.GenerateClassData(theClass);
+ VTables->GenerateClassData(theClass);
}
void
@@ -1275,7 +1276,7 @@ void CodeGenModule::EmitDeferredVTables() {
for (const CXXRecordDecl *RD : DeferredVTables)
if (shouldEmitVTableAtEndOfTranslationUnit(*this, RD))
- VTables.GenerateClassData(RD);
+ VTables->GenerateClassData(RD);
else if (shouldOpportunisticallyEmitVTables())
OpportunisticVTables.push_back(RD);
@@ -1417,3 +1418,15 @@ void CodeGenModule::EmitVTableTypeMetadata(const CXXRecordDecl *RD,
VTable->setVCallVisibilityMetadata(TypeVis);
}
}
+
+ItaniumVTableContext &CodeGenModule::getItaniumVTableContext() {
+ return VTables->getItaniumVTableContext();
+}
+
+const ItaniumVTableContext &CodeGenModule::getItaniumVTableContext() const {
+ return VTables->getItaniumVTableContext();
+}
+
+MicrosoftVTableContext &CodeGenModule::getMicrosoftVTableContext() {
+ return VTables->getMicrosoftVTableContext();
+}
diff --git a/clang/lib/CodeGen/CodeGenFunction.h b/clang/lib/CodeGen/CodeGenFunction.h
index af9798b30fbcf..1bc248c46bbc3 100644
--- a/clang/lib/CodeGen/CodeGenFunction.h
+++ b/clang/lib/CodeGen/CodeGenFunction.h
@@ -20,6 +20,7 @@
#include "CodeGenPGO.h"
#include "EHScopeStack.h"
#include "VarBypassDetector.h"
+#include "clang/AST/BaseSubobject.h"
#include "clang/AST/CharUnits.h"
#include "clang/AST/CurrentSourceLocExprScope.h"
#include "clang/AST/ExprCXX.h"
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index 8f9cf965af2b9..0c1c7f6220f79 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -22,6 +22,7 @@
#include "CGOpenCLRuntime.h"
#include "CGOpenMPRuntime.h"
#include "CGOpenMPRuntimeGPU.h"
+#include "CGVTables.h"
#include "CodeGenFunction.h"
#include "CodeGenPGO.h"
#include "ConstantEmitter.h"
@@ -341,7 +342,8 @@ CodeGenModule::CodeGenModule(ASTContext &C,
: Context(C), LangOpts(C.getLangOpts()), FS(FS), HeaderSearchOpts(HSO),
PreprocessorOpts(PPO), CodeGenOpts(CGO), TheModule(M), Diags(diags),
Target(C.getTargetInfo()), ABI(createCXXABI(*this)),
- VMContext(M.getContext()), VTables(*this), StackHandler(diags),
+ VMContext(M.getContext()),
+ VTables(std::make_unique<CodeGenVTables>(*this)), StackHandler(diags),
SanitizerMD(new SanitizerMetadata(*this)),
AtomicOpts(Target.getAtomicOpts()) {
@@ -3357,7 +3359,7 @@ void CodeGenModule::EmitVTablesOpportunistically() {
assert(getVTables().isVTableExternal(RD) &&
"This queue should only contain external vtables");
if (getCXXABI().canSpeculativelyEmitVTable(RD))
- VTables.GenerateClassData(RD);
+ VTables->GenerateClassData(RD);
}
OpportunisticVTables.clear();
}
diff --git a/clang/lib/CodeGen/CodeGenModule.h b/clang/lib/CodeGen/CodeGenModule.h
index 2cf15e24180b3..261fc4ee53eb9 100644
--- a/clang/lib/CodeGen/CodeGenModule.h
+++ b/clang/lib/CodeGen/CodeGenModule.h
@@ -13,7 +13,6 @@
#ifndef LLVM_CLANG_LIB_CODEGEN_CODEGENMODULE_H
#define LLVM_CLANG_LIB_CODEGEN_CODEGENMODULE_H
-#include "CGVTables.h"
#include "CodeGenTypeCache.h"
#include "CodeGenTypes.h"
#include "SanitizerMetadata.h"
@@ -22,6 +21,7 @@
#include "clang/AST/DeclOpenMP.h"
#include "clang/AST/GlobalDecl.h"
#include "clang/AST/Mangle.h"
+#include "clang/AST/TypeOrdering.h"
#include "clang/Basic/ABI.h"
#include "clang/Basic/LangOptions.h"
#include "clang/Basic/NoSanitizeList.h"
@@ -61,6 +61,7 @@ class ASTContext;
class AtomicType;
class FunctionDecl;
class IdentifierInfo;
+class ItaniumVTableContext;
class ObjCImplementationDecl;
class ObjCEncodeExpr;
class BlockExpr;
@@ -69,10 +70,12 @@ class Decl;
class Expr;
class Stmt;
class StringLiteral;
+class MicrosoftVTableContext;
class NamedDecl;
class PointerAuthSchema;
class ValueDecl;
class VarDecl;
+class VTableLayout;
class LangOptions;
class CodeGenOptions;
class HeaderSearchOptions;
@@ -87,6 +90,7 @@ namespace CodeGen {
class CodeGenFunction;
class CodeGenTBAA;
+class CodeGenVTables;
class CGCXXABI;
class CGDebugInfo;
class CGObjCRuntime;
@@ -368,7 +372,7 @@ class CodeGenModule : public CodeGenTypeCache {
std::unique_ptr<CodeGenTypes> Types;
/// Holds information about C++ vtables.
- CodeGenVTables VTables;
+ std::unique_ptr<CodeGenVTables> VTables;
std::unique_ptr<CGObjCRuntime> ObjCRuntime;
std::unique_ptr<CGOpenCLRuntime> OpenCLRuntime;
@@ -845,19 +849,11 @@ class CodeGenModule : public CodeGenTypeCache {
CodeGenTypes &getTypes() { return *Types; }
- CodeGenVTables &getVTables() { return VTables; }
+ CodeGenVTables &getVTables() { return *VTables; }
- ItaniumVTableContext &getItaniumVTableContext() {
- return VTables.getItaniumVTableContext();
- }
-
- const ItaniumVTableContext &getItaniumVTableContext() const {
- return VTables.getItaniumVTableContext();
- }
-
- MicrosoftVTableContext &getMicrosoftVTableContext() {
- return VTables.getMicrosoftVTableContext();
- }
+ ItaniumVTableContext &getItaniumVTableContext();
+ const ItaniumVTableContext &getItaniumVTableContext() const;
+ MicrosoftVTableContext &getMicrosoftVTableContext();
CtorList &getGlobalCtors() { return GlobalCtors; }
CtorList &getGlobalDtors() { return GlobalDtors; }
diff --git a/clang/lib/CodeGen/SwiftCallingConv.cpp b/clang/lib/CodeGen/SwiftCallingConv.cpp
index 10f9f20bca313..243ca86ce3e4a 100644
--- a/clang/lib/CodeGen/SwiftCallingConv.cpp
+++ b/clang/lib/CodeGen/SwiftCallingConv.cpp
@@ -14,6 +14,7 @@
#include "ABIInfo.h"
#include "CodeGenModule.h"
#include "TargetInfo.h"
+#include "clang/AST/RecordLayout.h"
#include "clang/Basic/TargetInfo.h"
using namespace clang;
diff --git a/clang/lib/CodeGen/Targets/ARM.cpp b/clang/lib/CodeGen/Targets/ARM.cpp
index a6d9a5549355c..3c3315a7ba5ed 100644
--- a/clang/lib/CodeGen/Targets/ARM.cpp
+++ b/clang/lib/CodeGen/Targets/ARM.cpp
@@ -8,6 +8,7 @@
#include "ABIInfoImpl.h"
#include "TargetInfo.h"
+#include "clang/AST/RecordLayout.h"
using namespace clang;
using namespace clang::CodeGen;
diff --git a/clang/lib/CodeGen/Targets/LoongArch.cpp b/clang/lib/CodeGen/Targets/LoongArch.cpp
index 0f689371a60db..f43990472e735 100644
--- a/clang/lib/CodeGen/Targets/LoongArch.cpp
+++ b/clang/lib/CodeGen/Targets/LoongArch.cpp
@@ -8,6 +8,7 @@
#include "ABIInfoImpl.h"
#include "TargetInfo.h"
+#include "clang/AST/RecordLayout.h"
using namespace clang;
using namespace clang::CodeGen;
diff --git a/clang/lib/CodeGen/Targets/Mips.cpp b/clang/lib/CodeGen/Targets/Mips.cpp
index c025f7312959c..1aa87b1a3895e 100644
--- a/clang/lib/CodeGen/Targets/Mips.cpp
+++ b/clang/lib/CodeGen/Targets/Mips.cpp
@@ -8,6 +8,7 @@
#include "ABIInfoImpl.h"
#include "TargetInfo.h"
+#include "clang/AST/RecordLayout.h"
using namespace clang;
using namespace clang::CodeGen;
diff --git a/clang/lib/CodeGen/Targets/RISCV.cpp b/clang/lib/CodeGen/Targets/RISCV.cpp
index 5aa10ba41f5ed..bf578a95762ac 100644
--- a/clang/lib/CodeGen/Targets/RISCV.cpp
+++ b/clang/lib/CodeGen/Targets/RISCV.cpp
@@ -8,6 +8,7 @@
#include "ABIInfoImpl.h"
#include "TargetInfo.h"
+#include "clang/AST/RecordLayout.h"
#include "llvm/TargetParser/RISCVTargetParser.h"
using namespace clang;
diff --git a/clang/lib/CodeGen/Targets/X86.cpp b/clang/lib/CodeGen/Targets/X86.cpp
index b36a6e1396653..2d90851e3dcdd 100644
--- a/clang/lib/CodeGen/Targets/X86.cpp
+++ b/clang/lib/CodeGen/Targets/X86.cpp
@@ -8,6 +8,7 @@
#include "ABIInfoImpl.h"
#include "TargetInfo.h"
+#include "clang/AST/RecordLayout.h"
#include "clang/Basic/DiagnosticFrontend.h"
#include "llvm/ADT/SmallBitVector.h"
|
@llvm/pr-subscribers-backend-x86 Author: Nikita Popov (nikic) ChangesAvoid pulling in the CVTables.h header in CodeGenModules.h by putting the member behind a unique_ptr. This had less impact than I was hoping, with only a 0.15% reduction in build time for clang. Apparently the expensive parts of CGVTables.h still get included via other pathways. Full diff: https://github.com/llvm/llvm-project/pull/134217.diff 24 Files Affected:
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 310addebd50e9..0ab0bb860bfa2 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -25,6 +25,7 @@
#include "PatternInit.h"
#include "TargetInfo.h"
#include "clang/AST/OSLog.h"
+#include "clang/AST/RecordLayout.h"
#include "clang/AST/StmtVisitor.h"
#include "clang/Basic/TargetBuiltins.h"
#include "clang/Basic/TargetInfo.h"
diff --git a/clang/lib/CodeGen/CGCXX.cpp b/clang/lib/CodeGen/CGCXX.cpp
index 6f47e24eed5b3..668812b498e1c 100644
--- a/clang/lib/CodeGen/CGCXX.cpp
+++ b/clang/lib/CodeGen/CGCXX.cpp
@@ -13,6 +13,7 @@
// We might split this into multiple files if it gets too unwieldy
#include "CGCXXABI.h"
+#include "CGVTables.h"
#include "CodeGenFunction.h"
#include "CodeGenModule.h"
#include "clang/AST/ASTContext.h"
diff --git a/clang/lib/CodeGen/CGCXXABI.cpp b/clang/lib/CodeGen/CGCXXABI.cpp
index 9f77fbec21380..7e21d5a72616e 100644
--- a/clang/lib/CodeGen/CGCXXABI.cpp
+++ b/clang/lib/CodeGen/CGCXXABI.cpp
@@ -14,6 +14,7 @@
#include "CGCXXABI.h"
#include "CGCleanup.h"
#include "clang/AST/Attr.h"
+#include "clang/AST/RecordLayout.h"
using namespace clang;
using namespace CodeGen;
diff --git a/clang/lib/CodeGen/CGCXXABI.h b/clang/lib/CodeGen/CGCXXABI.h
index 148a7ba6df7e6..ed4c9fdf8540a 100644
--- a/clang/lib/CodeGen/CGCXXABI.h
+++ b/clang/lib/CodeGen/CGCXXABI.h
@@ -32,6 +32,7 @@ class CXXDestructorDecl;
class CXXMethodDecl;
class CXXRecordDecl;
class MangleContext;
+struct ReturnAdjustment;
namespace CodeGen {
class CGCallee;
diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index b202255c3a15b..0b2947256af0f 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -26,6 +26,7 @@
#include "clang/AST/Decl.h"
#include "clang/AST/DeclCXX.h"
#include "clang/AST/DeclObjC.h"
+#include "clang/AST/RecordLayout.h"
#include "clang/Basic/CodeGenOptions.h"
#include "clang/Basic/TargetInfo.h"
#include "clang/CodeGen/CGFunctionInfo.h"
diff --git a/clang/lib/CodeGen/CGClass.cpp b/clang/lib/CodeGen/CGClass.cpp
index c683dbb0af825..0d6c50d9cb00f 100644
--- a/clang/lib/CodeGen/CGClass.cpp
+++ b/clang/lib/CodeGen/CGClass.cpp
@@ -15,6 +15,7 @@
#include "CGCXXABI.h"
#include "CGDebugInfo.h"
#include "CGRecordLayout.h"
+#include "CGVTables.h"
#include "CodeGenFunction.h"
#include "TargetInfo.h"
#include "clang/AST/Attr.h"
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp
index d659243d38d5f..abdb0827ff5c5 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -15,6 +15,7 @@
#include "CGCXXABI.h"
#include "CGObjCRuntime.h"
#include "CGRecordLayout.h"
+#include "CGVTables.h"
#include "CodeGenFunction.h"
#include "CodeGenModule.h"
#include "ConstantEmitter.h"
diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index 3d3a111f0514a..a29c3014740d6 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -28,6 +28,7 @@
#include "clang/AST/Attr.h"
#include "clang/AST/DeclObjC.h"
#include "clang/AST/NSAPI.h"
+#include "clang/AST/RecordLayout.h"
#include "clang/AST/StmtVisitor.h"
#include "clang/Basic/Builtins.h"
#include "clang/Basic/CodeGenOptions.h"
diff --git a/clang/lib/CodeGen/CGExprAgg.cpp b/clang/lib/CodeGen/CGExprAgg.cpp
index 87b2a73fb0c03..87a85fb67c482 100644
--- a/clang/lib/CodeGen/CGExprAgg.cpp
+++ b/clang/lib/CodeGen/CGExprAgg.cpp
@@ -24,6 +24,7 @@
#include "clang/AST/Attr.h"
#include "clang/AST/DeclCXX.h"
#include "clang/AST/DeclTemplate.h"
+#include "clang/AST/RecordLayout.h"
#include "clang/AST/StmtVisitor.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/Function.h"
diff --git a/clang/lib/CodeGen/CGExprCXX.cpp b/clang/lib/CodeGen/CGExprCXX.cpp
index 5c11c0bceade7..11f26f362ba14 100644
--- a/clang/lib/CodeGen/CGExprCXX.cpp
+++ b/clang/lib/CodeGen/CGExprCXX.cpp
@@ -17,6 +17,7 @@
#include "CodeGenFunction.h"
#include "ConstantEmitter.h"
#include "TargetInfo.h"
+#include "clang/AST/RecordLayout.h"
#include "clang/Basic/CodeGenOptions.h"
#include "clang/CodeGen/CGFunctionInfo.h"
#include "llvm/IR/Intrinsics.h"
diff --git a/clang/lib/CodeGen/CGNonTrivialStruct.cpp b/clang/lib/CodeGen/CGNonTrivialStruct.cpp
index c634b5c010e2d..b8a99744429b5 100644
--- a/clang/lib/CodeGen/CGNonTrivialStruct.cpp
+++ b/clang/lib/CodeGen/CGNonTrivialStruct.cpp
@@ -15,6 +15,7 @@
#include "CodeGenFunction.h"
#include "CodeGenModule.h"
#include "clang/AST/NonTrivialTypeVisitor.h"
+#include "clang/AST/RecordLayout.h"
#include "clang/CodeGen/CodeGenABITypes.h"
#include "llvm/Support/ScopedPrinter.h"
#include <array>
diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index 5736864d4cc6b..27a04e0fbb80f 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -22,6 +22,7 @@
#include "clang/AST/Attr.h"
#include "clang/AST/Decl.h"
#include "clang/AST/OpenMPClause.h"
+#include "clang/AST/RecordLayout.h"
#include "clang/AST/StmtOpenMP.h"
#include "clang/AST/StmtVisitor.h"
#include "clang/Basic/OpenMPKinds.h"
diff --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp b/clang/lib/CodeGen/CGStmtOpenMP.cpp
index 156f64bb5f508..6d2c45bf6e8ae 100644
--- a/clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -20,6 +20,7 @@
#include "clang/AST/Attr.h"
#include "clang/AST/DeclOpenMP.h"
#include "clang/AST/OpenMPClause.h"
+#include "clang/AST/RecordLayout.h"
#include "clang/AST/Stmt.h"
#include "clang/AST/StmtOpenMP.h"
#include "clang/AST/StmtVisitor.h"
diff --git a/clang/lib/CodeGen/CGVTT.cpp b/clang/lib/CodeGen/CGVTT.cpp
index 989a07d09d50e..3b7ed00a3e484 100644
--- a/clang/lib/CodeGen/CGVTT.cpp
+++ b/clang/lib/CodeGen/CGVTT.cpp
@@ -10,8 +10,9 @@
//
//===----------------------------------------------------------------------===//
-#include "CodeGenModule.h"
#include "CGCXXABI.h"
+#include "CGVTables.h"
+#include "CodeGenModule.h"
#include "clang/AST/RecordLayout.h"
#include "clang/AST/VTTBuilder.h"
using namespace clang;
diff --git a/clang/lib/CodeGen/CGVTables.cpp b/clang/lib/CodeGen/CGVTables.cpp
index 0a1cf24fbfa56..60e0f4ab54bcf 100644
--- a/clang/lib/CodeGen/CGVTables.cpp
+++ b/clang/lib/CodeGen/CGVTables.cpp
@@ -10,6 +10,7 @@
//
//===----------------------------------------------------------------------===//
+#include "CGVTables.h"
#include "CGCXXABI.h"
#include "CGDebugInfo.h"
#include "CodeGenFunction.h"
@@ -1190,7 +1191,7 @@ CodeGenModule::getVTableLinkage(const CXXRecordDecl *RD) {
/// functions). For weak vtables, CodeGen tracks when they are needed and
/// emits them as-needed.
void CodeGenModule::EmitVTable(CXXRecordDecl *theClass) {
- VTables.GenerateClassData(theClass);
+ VTables->GenerateClassData(theClass);
}
void
@@ -1275,7 +1276,7 @@ void CodeGenModule::EmitDeferredVTables() {
for (const CXXRecordDecl *RD : DeferredVTables)
if (shouldEmitVTableAtEndOfTranslationUnit(*this, RD))
- VTables.GenerateClassData(RD);
+ VTables->GenerateClassData(RD);
else if (shouldOpportunisticallyEmitVTables())
OpportunisticVTables.push_back(RD);
@@ -1417,3 +1418,15 @@ void CodeGenModule::EmitVTableTypeMetadata(const CXXRecordDecl *RD,
VTable->setVCallVisibilityMetadata(TypeVis);
}
}
+
+ItaniumVTableContext &CodeGenModule::getItaniumVTableContext() {
+ return VTables->getItaniumVTableContext();
+}
+
+const ItaniumVTableContext &CodeGenModule::getItaniumVTableContext() const {
+ return VTables->getItaniumVTableContext();
+}
+
+MicrosoftVTableContext &CodeGenModule::getMicrosoftVTableContext() {
+ return VTables->getMicrosoftVTableContext();
+}
diff --git a/clang/lib/CodeGen/CodeGenFunction.h b/clang/lib/CodeGen/CodeGenFunction.h
index af9798b30fbcf..1bc248c46bbc3 100644
--- a/clang/lib/CodeGen/CodeGenFunction.h
+++ b/clang/lib/CodeGen/CodeGenFunction.h
@@ -20,6 +20,7 @@
#include "CodeGenPGO.h"
#include "EHScopeStack.h"
#include "VarBypassDetector.h"
+#include "clang/AST/BaseSubobject.h"
#include "clang/AST/CharUnits.h"
#include "clang/AST/CurrentSourceLocExprScope.h"
#include "clang/AST/ExprCXX.h"
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index 8f9cf965af2b9..0c1c7f6220f79 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -22,6 +22,7 @@
#include "CGOpenCLRuntime.h"
#include "CGOpenMPRuntime.h"
#include "CGOpenMPRuntimeGPU.h"
+#include "CGVTables.h"
#include "CodeGenFunction.h"
#include "CodeGenPGO.h"
#include "ConstantEmitter.h"
@@ -341,7 +342,8 @@ CodeGenModule::CodeGenModule(ASTContext &C,
: Context(C), LangOpts(C.getLangOpts()), FS(FS), HeaderSearchOpts(HSO),
PreprocessorOpts(PPO), CodeGenOpts(CGO), TheModule(M), Diags(diags),
Target(C.getTargetInfo()), ABI(createCXXABI(*this)),
- VMContext(M.getContext()), VTables(*this), StackHandler(diags),
+ VMContext(M.getContext()),
+ VTables(std::make_unique<CodeGenVTables>(*this)), StackHandler(diags),
SanitizerMD(new SanitizerMetadata(*this)),
AtomicOpts(Target.getAtomicOpts()) {
@@ -3357,7 +3359,7 @@ void CodeGenModule::EmitVTablesOpportunistically() {
assert(getVTables().isVTableExternal(RD) &&
"This queue should only contain external vtables");
if (getCXXABI().canSpeculativelyEmitVTable(RD))
- VTables.GenerateClassData(RD);
+ VTables->GenerateClassData(RD);
}
OpportunisticVTables.clear();
}
diff --git a/clang/lib/CodeGen/CodeGenModule.h b/clang/lib/CodeGen/CodeGenModule.h
index 2cf15e24180b3..261fc4ee53eb9 100644
--- a/clang/lib/CodeGen/CodeGenModule.h
+++ b/clang/lib/CodeGen/CodeGenModule.h
@@ -13,7 +13,6 @@
#ifndef LLVM_CLANG_LIB_CODEGEN_CODEGENMODULE_H
#define LLVM_CLANG_LIB_CODEGEN_CODEGENMODULE_H
-#include "CGVTables.h"
#include "CodeGenTypeCache.h"
#include "CodeGenTypes.h"
#include "SanitizerMetadata.h"
@@ -22,6 +21,7 @@
#include "clang/AST/DeclOpenMP.h"
#include "clang/AST/GlobalDecl.h"
#include "clang/AST/Mangle.h"
+#include "clang/AST/TypeOrdering.h"
#include "clang/Basic/ABI.h"
#include "clang/Basic/LangOptions.h"
#include "clang/Basic/NoSanitizeList.h"
@@ -61,6 +61,7 @@ class ASTContext;
class AtomicType;
class FunctionDecl;
class IdentifierInfo;
+class ItaniumVTableContext;
class ObjCImplementationDecl;
class ObjCEncodeExpr;
class BlockExpr;
@@ -69,10 +70,12 @@ class Decl;
class Expr;
class Stmt;
class StringLiteral;
+class MicrosoftVTableContext;
class NamedDecl;
class PointerAuthSchema;
class ValueDecl;
class VarDecl;
+class VTableLayout;
class LangOptions;
class CodeGenOptions;
class HeaderSearchOptions;
@@ -87,6 +90,7 @@ namespace CodeGen {
class CodeGenFunction;
class CodeGenTBAA;
+class CodeGenVTables;
class CGCXXABI;
class CGDebugInfo;
class CGObjCRuntime;
@@ -368,7 +372,7 @@ class CodeGenModule : public CodeGenTypeCache {
std::unique_ptr<CodeGenTypes> Types;
/// Holds information about C++ vtables.
- CodeGenVTables VTables;
+ std::unique_ptr<CodeGenVTables> VTables;
std::unique_ptr<CGObjCRuntime> ObjCRuntime;
std::unique_ptr<CGOpenCLRuntime> OpenCLRuntime;
@@ -845,19 +849,11 @@ class CodeGenModule : public CodeGenTypeCache {
CodeGenTypes &getTypes() { return *Types; }
- CodeGenVTables &getVTables() { return VTables; }
+ CodeGenVTables &getVTables() { return *VTables; }
- ItaniumVTableContext &getItaniumVTableContext() {
- return VTables.getItaniumVTableContext();
- }
-
- const ItaniumVTableContext &getItaniumVTableContext() const {
- return VTables.getItaniumVTableContext();
- }
-
- MicrosoftVTableContext &getMicrosoftVTableContext() {
- return VTables.getMicrosoftVTableContext();
- }
+ ItaniumVTableContext &getItaniumVTableContext();
+ const ItaniumVTableContext &getItaniumVTableContext() const;
+ MicrosoftVTableContext &getMicrosoftVTableContext();
CtorList &getGlobalCtors() { return GlobalCtors; }
CtorList &getGlobalDtors() { return GlobalDtors; }
diff --git a/clang/lib/CodeGen/SwiftCallingConv.cpp b/clang/lib/CodeGen/SwiftCallingConv.cpp
index 10f9f20bca313..243ca86ce3e4a 100644
--- a/clang/lib/CodeGen/SwiftCallingConv.cpp
+++ b/clang/lib/CodeGen/SwiftCallingConv.cpp
@@ -14,6 +14,7 @@
#include "ABIInfo.h"
#include "CodeGenModule.h"
#include "TargetInfo.h"
+#include "clang/AST/RecordLayout.h"
#include "clang/Basic/TargetInfo.h"
using namespace clang;
diff --git a/clang/lib/CodeGen/Targets/ARM.cpp b/clang/lib/CodeGen/Targets/ARM.cpp
index a6d9a5549355c..3c3315a7ba5ed 100644
--- a/clang/lib/CodeGen/Targets/ARM.cpp
+++ b/clang/lib/CodeGen/Targets/ARM.cpp
@@ -8,6 +8,7 @@
#include "ABIInfoImpl.h"
#include "TargetInfo.h"
+#include "clang/AST/RecordLayout.h"
using namespace clang;
using namespace clang::CodeGen;
diff --git a/clang/lib/CodeGen/Targets/LoongArch.cpp b/clang/lib/CodeGen/Targets/LoongArch.cpp
index 0f689371a60db..f43990472e735 100644
--- a/clang/lib/CodeGen/Targets/LoongArch.cpp
+++ b/clang/lib/CodeGen/Targets/LoongArch.cpp
@@ -8,6 +8,7 @@
#include "ABIInfoImpl.h"
#include "TargetInfo.h"
+#include "clang/AST/RecordLayout.h"
using namespace clang;
using namespace clang::CodeGen;
diff --git a/clang/lib/CodeGen/Targets/Mips.cpp b/clang/lib/CodeGen/Targets/Mips.cpp
index c025f7312959c..1aa87b1a3895e 100644
--- a/clang/lib/CodeGen/Targets/Mips.cpp
+++ b/clang/lib/CodeGen/Targets/Mips.cpp
@@ -8,6 +8,7 @@
#include "ABIInfoImpl.h"
#include "TargetInfo.h"
+#include "clang/AST/RecordLayout.h"
using namespace clang;
using namespace clang::CodeGen;
diff --git a/clang/lib/CodeGen/Targets/RISCV.cpp b/clang/lib/CodeGen/Targets/RISCV.cpp
index 5aa10ba41f5ed..bf578a95762ac 100644
--- a/clang/lib/CodeGen/Targets/RISCV.cpp
+++ b/clang/lib/CodeGen/Targets/RISCV.cpp
@@ -8,6 +8,7 @@
#include "ABIInfoImpl.h"
#include "TargetInfo.h"
+#include "clang/AST/RecordLayout.h"
#include "llvm/TargetParser/RISCVTargetParser.h"
using namespace clang;
diff --git a/clang/lib/CodeGen/Targets/X86.cpp b/clang/lib/CodeGen/Targets/X86.cpp
index b36a6e1396653..2d90851e3dcdd 100644
--- a/clang/lib/CodeGen/Targets/X86.cpp
+++ b/clang/lib/CodeGen/Targets/X86.cpp
@@ -8,6 +8,7 @@
#include "ABIInfoImpl.h"
#include "TargetInfo.h"
+#include "clang/AST/RecordLayout.h"
#include "clang/Basic/DiagnosticFrontend.h"
#include "llvm/ADT/SmallBitVector.h"
|
@llvm/pr-subscribers-clang-codegen Author: Nikita Popov (nikic) ChangesAvoid pulling in the CVTables.h header in CodeGenModules.h by putting the member behind a unique_ptr. This had less impact than I was hoping, with only a 0.15% reduction in build time for clang. Apparently the expensive parts of CGVTables.h still get included via other pathways. Full diff: https://github.com/llvm/llvm-project/pull/134217.diff 24 Files Affected:
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 310addebd50e9..0ab0bb860bfa2 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -25,6 +25,7 @@
#include "PatternInit.h"
#include "TargetInfo.h"
#include "clang/AST/OSLog.h"
+#include "clang/AST/RecordLayout.h"
#include "clang/AST/StmtVisitor.h"
#include "clang/Basic/TargetBuiltins.h"
#include "clang/Basic/TargetInfo.h"
diff --git a/clang/lib/CodeGen/CGCXX.cpp b/clang/lib/CodeGen/CGCXX.cpp
index 6f47e24eed5b3..668812b498e1c 100644
--- a/clang/lib/CodeGen/CGCXX.cpp
+++ b/clang/lib/CodeGen/CGCXX.cpp
@@ -13,6 +13,7 @@
// We might split this into multiple files if it gets too unwieldy
#include "CGCXXABI.h"
+#include "CGVTables.h"
#include "CodeGenFunction.h"
#include "CodeGenModule.h"
#include "clang/AST/ASTContext.h"
diff --git a/clang/lib/CodeGen/CGCXXABI.cpp b/clang/lib/CodeGen/CGCXXABI.cpp
index 9f77fbec21380..7e21d5a72616e 100644
--- a/clang/lib/CodeGen/CGCXXABI.cpp
+++ b/clang/lib/CodeGen/CGCXXABI.cpp
@@ -14,6 +14,7 @@
#include "CGCXXABI.h"
#include "CGCleanup.h"
#include "clang/AST/Attr.h"
+#include "clang/AST/RecordLayout.h"
using namespace clang;
using namespace CodeGen;
diff --git a/clang/lib/CodeGen/CGCXXABI.h b/clang/lib/CodeGen/CGCXXABI.h
index 148a7ba6df7e6..ed4c9fdf8540a 100644
--- a/clang/lib/CodeGen/CGCXXABI.h
+++ b/clang/lib/CodeGen/CGCXXABI.h
@@ -32,6 +32,7 @@ class CXXDestructorDecl;
class CXXMethodDecl;
class CXXRecordDecl;
class MangleContext;
+struct ReturnAdjustment;
namespace CodeGen {
class CGCallee;
diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index b202255c3a15b..0b2947256af0f 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -26,6 +26,7 @@
#include "clang/AST/Decl.h"
#include "clang/AST/DeclCXX.h"
#include "clang/AST/DeclObjC.h"
+#include "clang/AST/RecordLayout.h"
#include "clang/Basic/CodeGenOptions.h"
#include "clang/Basic/TargetInfo.h"
#include "clang/CodeGen/CGFunctionInfo.h"
diff --git a/clang/lib/CodeGen/CGClass.cpp b/clang/lib/CodeGen/CGClass.cpp
index c683dbb0af825..0d6c50d9cb00f 100644
--- a/clang/lib/CodeGen/CGClass.cpp
+++ b/clang/lib/CodeGen/CGClass.cpp
@@ -15,6 +15,7 @@
#include "CGCXXABI.h"
#include "CGDebugInfo.h"
#include "CGRecordLayout.h"
+#include "CGVTables.h"
#include "CodeGenFunction.h"
#include "TargetInfo.h"
#include "clang/AST/Attr.h"
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp
index d659243d38d5f..abdb0827ff5c5 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -15,6 +15,7 @@
#include "CGCXXABI.h"
#include "CGObjCRuntime.h"
#include "CGRecordLayout.h"
+#include "CGVTables.h"
#include "CodeGenFunction.h"
#include "CodeGenModule.h"
#include "ConstantEmitter.h"
diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index 3d3a111f0514a..a29c3014740d6 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -28,6 +28,7 @@
#include "clang/AST/Attr.h"
#include "clang/AST/DeclObjC.h"
#include "clang/AST/NSAPI.h"
+#include "clang/AST/RecordLayout.h"
#include "clang/AST/StmtVisitor.h"
#include "clang/Basic/Builtins.h"
#include "clang/Basic/CodeGenOptions.h"
diff --git a/clang/lib/CodeGen/CGExprAgg.cpp b/clang/lib/CodeGen/CGExprAgg.cpp
index 87b2a73fb0c03..87a85fb67c482 100644
--- a/clang/lib/CodeGen/CGExprAgg.cpp
+++ b/clang/lib/CodeGen/CGExprAgg.cpp
@@ -24,6 +24,7 @@
#include "clang/AST/Attr.h"
#include "clang/AST/DeclCXX.h"
#include "clang/AST/DeclTemplate.h"
+#include "clang/AST/RecordLayout.h"
#include "clang/AST/StmtVisitor.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/Function.h"
diff --git a/clang/lib/CodeGen/CGExprCXX.cpp b/clang/lib/CodeGen/CGExprCXX.cpp
index 5c11c0bceade7..11f26f362ba14 100644
--- a/clang/lib/CodeGen/CGExprCXX.cpp
+++ b/clang/lib/CodeGen/CGExprCXX.cpp
@@ -17,6 +17,7 @@
#include "CodeGenFunction.h"
#include "ConstantEmitter.h"
#include "TargetInfo.h"
+#include "clang/AST/RecordLayout.h"
#include "clang/Basic/CodeGenOptions.h"
#include "clang/CodeGen/CGFunctionInfo.h"
#include "llvm/IR/Intrinsics.h"
diff --git a/clang/lib/CodeGen/CGNonTrivialStruct.cpp b/clang/lib/CodeGen/CGNonTrivialStruct.cpp
index c634b5c010e2d..b8a99744429b5 100644
--- a/clang/lib/CodeGen/CGNonTrivialStruct.cpp
+++ b/clang/lib/CodeGen/CGNonTrivialStruct.cpp
@@ -15,6 +15,7 @@
#include "CodeGenFunction.h"
#include "CodeGenModule.h"
#include "clang/AST/NonTrivialTypeVisitor.h"
+#include "clang/AST/RecordLayout.h"
#include "clang/CodeGen/CodeGenABITypes.h"
#include "llvm/Support/ScopedPrinter.h"
#include <array>
diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index 5736864d4cc6b..27a04e0fbb80f 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -22,6 +22,7 @@
#include "clang/AST/Attr.h"
#include "clang/AST/Decl.h"
#include "clang/AST/OpenMPClause.h"
+#include "clang/AST/RecordLayout.h"
#include "clang/AST/StmtOpenMP.h"
#include "clang/AST/StmtVisitor.h"
#include "clang/Basic/OpenMPKinds.h"
diff --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp b/clang/lib/CodeGen/CGStmtOpenMP.cpp
index 156f64bb5f508..6d2c45bf6e8ae 100644
--- a/clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -20,6 +20,7 @@
#include "clang/AST/Attr.h"
#include "clang/AST/DeclOpenMP.h"
#include "clang/AST/OpenMPClause.h"
+#include "clang/AST/RecordLayout.h"
#include "clang/AST/Stmt.h"
#include "clang/AST/StmtOpenMP.h"
#include "clang/AST/StmtVisitor.h"
diff --git a/clang/lib/CodeGen/CGVTT.cpp b/clang/lib/CodeGen/CGVTT.cpp
index 989a07d09d50e..3b7ed00a3e484 100644
--- a/clang/lib/CodeGen/CGVTT.cpp
+++ b/clang/lib/CodeGen/CGVTT.cpp
@@ -10,8 +10,9 @@
//
//===----------------------------------------------------------------------===//
-#include "CodeGenModule.h"
#include "CGCXXABI.h"
+#include "CGVTables.h"
+#include "CodeGenModule.h"
#include "clang/AST/RecordLayout.h"
#include "clang/AST/VTTBuilder.h"
using namespace clang;
diff --git a/clang/lib/CodeGen/CGVTables.cpp b/clang/lib/CodeGen/CGVTables.cpp
index 0a1cf24fbfa56..60e0f4ab54bcf 100644
--- a/clang/lib/CodeGen/CGVTables.cpp
+++ b/clang/lib/CodeGen/CGVTables.cpp
@@ -10,6 +10,7 @@
//
//===----------------------------------------------------------------------===//
+#include "CGVTables.h"
#include "CGCXXABI.h"
#include "CGDebugInfo.h"
#include "CodeGenFunction.h"
@@ -1190,7 +1191,7 @@ CodeGenModule::getVTableLinkage(const CXXRecordDecl *RD) {
/// functions). For weak vtables, CodeGen tracks when they are needed and
/// emits them as-needed.
void CodeGenModule::EmitVTable(CXXRecordDecl *theClass) {
- VTables.GenerateClassData(theClass);
+ VTables->GenerateClassData(theClass);
}
void
@@ -1275,7 +1276,7 @@ void CodeGenModule::EmitDeferredVTables() {
for (const CXXRecordDecl *RD : DeferredVTables)
if (shouldEmitVTableAtEndOfTranslationUnit(*this, RD))
- VTables.GenerateClassData(RD);
+ VTables->GenerateClassData(RD);
else if (shouldOpportunisticallyEmitVTables())
OpportunisticVTables.push_back(RD);
@@ -1417,3 +1418,15 @@ void CodeGenModule::EmitVTableTypeMetadata(const CXXRecordDecl *RD,
VTable->setVCallVisibilityMetadata(TypeVis);
}
}
+
+ItaniumVTableContext &CodeGenModule::getItaniumVTableContext() {
+ return VTables->getItaniumVTableContext();
+}
+
+const ItaniumVTableContext &CodeGenModule::getItaniumVTableContext() const {
+ return VTables->getItaniumVTableContext();
+}
+
+MicrosoftVTableContext &CodeGenModule::getMicrosoftVTableContext() {
+ return VTables->getMicrosoftVTableContext();
+}
diff --git a/clang/lib/CodeGen/CodeGenFunction.h b/clang/lib/CodeGen/CodeGenFunction.h
index af9798b30fbcf..1bc248c46bbc3 100644
--- a/clang/lib/CodeGen/CodeGenFunction.h
+++ b/clang/lib/CodeGen/CodeGenFunction.h
@@ -20,6 +20,7 @@
#include "CodeGenPGO.h"
#include "EHScopeStack.h"
#include "VarBypassDetector.h"
+#include "clang/AST/BaseSubobject.h"
#include "clang/AST/CharUnits.h"
#include "clang/AST/CurrentSourceLocExprScope.h"
#include "clang/AST/ExprCXX.h"
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index 8f9cf965af2b9..0c1c7f6220f79 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -22,6 +22,7 @@
#include "CGOpenCLRuntime.h"
#include "CGOpenMPRuntime.h"
#include "CGOpenMPRuntimeGPU.h"
+#include "CGVTables.h"
#include "CodeGenFunction.h"
#include "CodeGenPGO.h"
#include "ConstantEmitter.h"
@@ -341,7 +342,8 @@ CodeGenModule::CodeGenModule(ASTContext &C,
: Context(C), LangOpts(C.getLangOpts()), FS(FS), HeaderSearchOpts(HSO),
PreprocessorOpts(PPO), CodeGenOpts(CGO), TheModule(M), Diags(diags),
Target(C.getTargetInfo()), ABI(createCXXABI(*this)),
- VMContext(M.getContext()), VTables(*this), StackHandler(diags),
+ VMContext(M.getContext()),
+ VTables(std::make_unique<CodeGenVTables>(*this)), StackHandler(diags),
SanitizerMD(new SanitizerMetadata(*this)),
AtomicOpts(Target.getAtomicOpts()) {
@@ -3357,7 +3359,7 @@ void CodeGenModule::EmitVTablesOpportunistically() {
assert(getVTables().isVTableExternal(RD) &&
"This queue should only contain external vtables");
if (getCXXABI().canSpeculativelyEmitVTable(RD))
- VTables.GenerateClassData(RD);
+ VTables->GenerateClassData(RD);
}
OpportunisticVTables.clear();
}
diff --git a/clang/lib/CodeGen/CodeGenModule.h b/clang/lib/CodeGen/CodeGenModule.h
index 2cf15e24180b3..261fc4ee53eb9 100644
--- a/clang/lib/CodeGen/CodeGenModule.h
+++ b/clang/lib/CodeGen/CodeGenModule.h
@@ -13,7 +13,6 @@
#ifndef LLVM_CLANG_LIB_CODEGEN_CODEGENMODULE_H
#define LLVM_CLANG_LIB_CODEGEN_CODEGENMODULE_H
-#include "CGVTables.h"
#include "CodeGenTypeCache.h"
#include "CodeGenTypes.h"
#include "SanitizerMetadata.h"
@@ -22,6 +21,7 @@
#include "clang/AST/DeclOpenMP.h"
#include "clang/AST/GlobalDecl.h"
#include "clang/AST/Mangle.h"
+#include "clang/AST/TypeOrdering.h"
#include "clang/Basic/ABI.h"
#include "clang/Basic/LangOptions.h"
#include "clang/Basic/NoSanitizeList.h"
@@ -61,6 +61,7 @@ class ASTContext;
class AtomicType;
class FunctionDecl;
class IdentifierInfo;
+class ItaniumVTableContext;
class ObjCImplementationDecl;
class ObjCEncodeExpr;
class BlockExpr;
@@ -69,10 +70,12 @@ class Decl;
class Expr;
class Stmt;
class StringLiteral;
+class MicrosoftVTableContext;
class NamedDecl;
class PointerAuthSchema;
class ValueDecl;
class VarDecl;
+class VTableLayout;
class LangOptions;
class CodeGenOptions;
class HeaderSearchOptions;
@@ -87,6 +90,7 @@ namespace CodeGen {
class CodeGenFunction;
class CodeGenTBAA;
+class CodeGenVTables;
class CGCXXABI;
class CGDebugInfo;
class CGObjCRuntime;
@@ -368,7 +372,7 @@ class CodeGenModule : public CodeGenTypeCache {
std::unique_ptr<CodeGenTypes> Types;
/// Holds information about C++ vtables.
- CodeGenVTables VTables;
+ std::unique_ptr<CodeGenVTables> VTables;
std::unique_ptr<CGObjCRuntime> ObjCRuntime;
std::unique_ptr<CGOpenCLRuntime> OpenCLRuntime;
@@ -845,19 +849,11 @@ class CodeGenModule : public CodeGenTypeCache {
CodeGenTypes &getTypes() { return *Types; }
- CodeGenVTables &getVTables() { return VTables; }
+ CodeGenVTables &getVTables() { return *VTables; }
- ItaniumVTableContext &getItaniumVTableContext() {
- return VTables.getItaniumVTableContext();
- }
-
- const ItaniumVTableContext &getItaniumVTableContext() const {
- return VTables.getItaniumVTableContext();
- }
-
- MicrosoftVTableContext &getMicrosoftVTableContext() {
- return VTables.getMicrosoftVTableContext();
- }
+ ItaniumVTableContext &getItaniumVTableContext();
+ const ItaniumVTableContext &getItaniumVTableContext() const;
+ MicrosoftVTableContext &getMicrosoftVTableContext();
CtorList &getGlobalCtors() { return GlobalCtors; }
CtorList &getGlobalDtors() { return GlobalDtors; }
diff --git a/clang/lib/CodeGen/SwiftCallingConv.cpp b/clang/lib/CodeGen/SwiftCallingConv.cpp
index 10f9f20bca313..243ca86ce3e4a 100644
--- a/clang/lib/CodeGen/SwiftCallingConv.cpp
+++ b/clang/lib/CodeGen/SwiftCallingConv.cpp
@@ -14,6 +14,7 @@
#include "ABIInfo.h"
#include "CodeGenModule.h"
#include "TargetInfo.h"
+#include "clang/AST/RecordLayout.h"
#include "clang/Basic/TargetInfo.h"
using namespace clang;
diff --git a/clang/lib/CodeGen/Targets/ARM.cpp b/clang/lib/CodeGen/Targets/ARM.cpp
index a6d9a5549355c..3c3315a7ba5ed 100644
--- a/clang/lib/CodeGen/Targets/ARM.cpp
+++ b/clang/lib/CodeGen/Targets/ARM.cpp
@@ -8,6 +8,7 @@
#include "ABIInfoImpl.h"
#include "TargetInfo.h"
+#include "clang/AST/RecordLayout.h"
using namespace clang;
using namespace clang::CodeGen;
diff --git a/clang/lib/CodeGen/Targets/LoongArch.cpp b/clang/lib/CodeGen/Targets/LoongArch.cpp
index 0f689371a60db..f43990472e735 100644
--- a/clang/lib/CodeGen/Targets/LoongArch.cpp
+++ b/clang/lib/CodeGen/Targets/LoongArch.cpp
@@ -8,6 +8,7 @@
#include "ABIInfoImpl.h"
#include "TargetInfo.h"
+#include "clang/AST/RecordLayout.h"
using namespace clang;
using namespace clang::CodeGen;
diff --git a/clang/lib/CodeGen/Targets/Mips.cpp b/clang/lib/CodeGen/Targets/Mips.cpp
index c025f7312959c..1aa87b1a3895e 100644
--- a/clang/lib/CodeGen/Targets/Mips.cpp
+++ b/clang/lib/CodeGen/Targets/Mips.cpp
@@ -8,6 +8,7 @@
#include "ABIInfoImpl.h"
#include "TargetInfo.h"
+#include "clang/AST/RecordLayout.h"
using namespace clang;
using namespace clang::CodeGen;
diff --git a/clang/lib/CodeGen/Targets/RISCV.cpp b/clang/lib/CodeGen/Targets/RISCV.cpp
index 5aa10ba41f5ed..bf578a95762ac 100644
--- a/clang/lib/CodeGen/Targets/RISCV.cpp
+++ b/clang/lib/CodeGen/Targets/RISCV.cpp
@@ -8,6 +8,7 @@
#include "ABIInfoImpl.h"
#include "TargetInfo.h"
+#include "clang/AST/RecordLayout.h"
#include "llvm/TargetParser/RISCVTargetParser.h"
using namespace clang;
diff --git a/clang/lib/CodeGen/Targets/X86.cpp b/clang/lib/CodeGen/Targets/X86.cpp
index b36a6e1396653..2d90851e3dcdd 100644
--- a/clang/lib/CodeGen/Targets/X86.cpp
+++ b/clang/lib/CodeGen/Targets/X86.cpp
@@ -8,6 +8,7 @@
#include "ABIInfoImpl.h"
#include "TargetInfo.h"
+#include "clang/AST/RecordLayout.h"
#include "clang/Basic/DiagnosticFrontend.h"
#include "llvm/ADT/SmallBitVector.h"
|
Avoid pulling in the CVTables.h header in CodeGenModules.h by putting the member behind a unique_ptr.
This had less impact than I was hoping, with only a 0.15% reduction in build time for clang. Apparently the expensive parts of CGVTables.h still get included via other pathways.