Skip to content

[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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions clang/lib/CodeGen/CGBuiltin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions clang/lib/CodeGen/CGCXX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions clang/lib/CodeGen/CGCXXABI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions clang/lib/CodeGen/CGCXXABI.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class CXXDestructorDecl;
class CXXMethodDecl;
class CXXRecordDecl;
class MangleContext;
struct ReturnAdjustment;

namespace CodeGen {
class CGCallee;
Expand Down
1 change: 1 addition & 0 deletions clang/lib/CodeGen/CGCall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions clang/lib/CodeGen/CGClass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions clang/lib/CodeGen/CGDebugInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions clang/lib/CodeGen/CGExpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions clang/lib/CodeGen/CGExprAgg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions clang/lib/CodeGen/CGExprCXX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions clang/lib/CodeGen/CGNonTrivialStruct.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
1 change: 1 addition & 0 deletions clang/lib/CodeGen/CGOpenMPRuntime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions clang/lib/CodeGen/CGStmtOpenMP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 2 additions & 1 deletion clang/lib/CodeGen/CGVTT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
17 changes: 15 additions & 2 deletions clang/lib/CodeGen/CGVTables.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
//
//===----------------------------------------------------------------------===//

#include "CGVTables.h"
#include "CGCXXABI.h"
#include "CGDebugInfo.h"
#include "CodeGenFunction.h"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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();
}
1 change: 1 addition & 0 deletions clang/lib/CodeGen/CodeGenFunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 4 additions & 2 deletions clang/lib/CodeGen/CodeGenModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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()) {

Expand Down Expand Up @@ -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();
}
Expand Down
24 changes: 10 additions & 14 deletions clang/lib/CodeGen/CodeGenModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down Expand Up @@ -61,6 +61,7 @@ class ASTContext;
class AtomicType;
class FunctionDecl;
class IdentifierInfo;
class ItaniumVTableContext;
class ObjCImplementationDecl;
class ObjCEncodeExpr;
class BlockExpr;
Expand All @@ -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;
Expand All @@ -87,6 +90,7 @@ namespace CodeGen {

class CodeGenFunction;
class CodeGenTBAA;
class CodeGenVTables;
class CGCXXABI;
class CGDebugInfo;
class CGObjCRuntime;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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; }
Expand Down
1 change: 1 addition & 0 deletions clang/lib/CodeGen/SwiftCallingConv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions clang/lib/CodeGen/Targets/ARM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include "ABIInfoImpl.h"
#include "TargetInfo.h"
#include "clang/AST/RecordLayout.h"

using namespace clang;
using namespace clang::CodeGen;
Expand Down
1 change: 1 addition & 0 deletions clang/lib/CodeGen/Targets/LoongArch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include "ABIInfoImpl.h"
#include "TargetInfo.h"
#include "clang/AST/RecordLayout.h"

using namespace clang;
using namespace clang::CodeGen;
Expand Down
1 change: 1 addition & 0 deletions clang/lib/CodeGen/Targets/Mips.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include "ABIInfoImpl.h"
#include "TargetInfo.h"
#include "clang/AST/RecordLayout.h"

using namespace clang;
using namespace clang::CodeGen;
Expand Down
1 change: 1 addition & 0 deletions clang/lib/CodeGen/Targets/RISCV.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include "ABIInfoImpl.h"
#include "TargetInfo.h"
#include "clang/AST/RecordLayout.h"
#include "llvm/TargetParser/RISCVTargetParser.h"

using namespace clang;
Expand Down
1 change: 1 addition & 0 deletions clang/lib/CodeGen/Targets/X86.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
Loading