Skip to content

Commit 1bace61

Browse files
committed
Revert some of the visitors in codegen to test the performance impact
1 parent a832fd0 commit 1bace61

File tree

3 files changed

+29
-27
lines changed

3 files changed

+29
-27
lines changed

clang/lib/CodeGen/CGDebugInfo.cpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@
2525
#include "clang/AST/DeclFriend.h"
2626
#include "clang/AST/DeclObjC.h"
2727
#include "clang/AST/DeclTemplate.h"
28-
#include "clang/AST/DynamicRecursiveASTVisitor.h"
2928
#include "clang/AST/Expr.h"
3029
#include "clang/AST/RecordLayout.h"
30+
#include "clang/AST/RecursiveASTVisitor.h"
3131
#include "clang/AST/VTableBuilder.h"
3232
#include "clang/Basic/CodeGenOptions.h"
3333
#include "clang/Basic/SourceManager.h"
@@ -5697,9 +5697,10 @@ static bool ReferencesAnonymousEntity(ArrayRef<TemplateArgument> Args) {
56975697
case TemplateArgument::Pack:
56985698
return ReferencesAnonymousEntity(TA.getPackAsArray());
56995699
case TemplateArgument::Type: {
5700-
struct ReferencesAnonymous : DynamicRecursiveASTVisitor {
5700+
struct ReferencesAnonymous
5701+
: public RecursiveASTVisitor<ReferencesAnonymous> {
57015702
bool RefAnon = false;
5702-
bool VisitRecordType(RecordType *RT) override {
5703+
bool VisitRecordType(RecordType *RT) {
57035704
if (ReferencesAnonymousEntity(RT)) {
57045705
RefAnon = true;
57055706
return false;
@@ -5720,17 +5721,17 @@ static bool ReferencesAnonymousEntity(ArrayRef<TemplateArgument> Args) {
57205721
});
57215722
}
57225723
namespace {
5723-
struct ReconstitutableType : DynamicRecursiveASTVisitor {
5724+
struct ReconstitutableType : public RecursiveASTVisitor<ReconstitutableType> {
57245725
bool Reconstitutable = true;
5725-
bool VisitVectorType(VectorType *FT) override {
5726+
bool VisitVectorType(VectorType *FT) {
57265727
Reconstitutable = false;
57275728
return false;
57285729
}
5729-
bool VisitAtomicType(AtomicType *FT) override {
5730+
bool VisitAtomicType(AtomicType *FT) {
57305731
Reconstitutable = false;
57315732
return false;
57325733
}
5733-
bool VisitType(Type *T) override {
5734+
bool VisitType(Type *T) {
57345735
// _BitInt(N) isn't reconstitutable because the bit width isn't encoded in
57355736
// the DWARF, only the byte width.
57365737
if (T->isBitIntType()) {
@@ -5739,7 +5740,7 @@ struct ReconstitutableType : DynamicRecursiveASTVisitor {
57395740
}
57405741
return true;
57415742
}
5742-
bool TraverseEnumType(EnumType *ET, bool = false) override {
5743+
bool TraverseEnumType(EnumType *ET, bool = false) {
57435744
// Unnamed enums can't be reconstituted due to a lack of column info we
57445745
// produce in the DWARF, so we can't get Clang's full name back.
57455746
if (const auto *ED = dyn_cast<EnumDecl>(ET->getOriginalDecl())) {
@@ -5754,13 +5755,13 @@ struct ReconstitutableType : DynamicRecursiveASTVisitor {
57545755
}
57555756
return true;
57565757
}
5757-
bool VisitFunctionProtoType(FunctionProtoType *FT) override {
5758+
bool VisitFunctionProtoType(FunctionProtoType *FT) {
57585759
// noexcept is not encoded in DWARF, so the reversi
57595760
Reconstitutable &= !isNoexceptExceptionSpec(FT->getExceptionSpecType());
57605761
Reconstitutable &= !FT->getNoReturnAttr();
57615762
return Reconstitutable;
57625763
}
5763-
bool VisitRecordType(RecordType *RT) override {
5764+
bool VisitRecordType(RecordType *RT, bool = false) {
57645765
if (ReferencesAnonymousEntity(RT)) {
57655766
Reconstitutable = false;
57665767
return false;

clang/lib/CodeGen/CodeGenModule.cpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@
3434
#include "clang/AST/DeclCXX.h"
3535
#include "clang/AST/DeclObjC.h"
3636
#include "clang/AST/DeclTemplate.h"
37-
#include "clang/AST/DynamicRecursiveASTVisitor.h"
3837
#include "clang/AST/Mangle.h"
38+
#include "clang/AST/RecursiveASTVisitor.h"
3939
#include "clang/AST/StmtVisitor.h"
4040
#include "clang/Basic/Builtins.h"
4141
#include "clang/Basic/CodeGenOptions.h"
@@ -4266,12 +4266,13 @@ namespace {
42664266
};
42674267

42684268
// Make sure we're not referencing non-imported vars or functions.
4269-
struct DLLImportFunctionVisitor : DynamicRecursiveASTVisitor {
4269+
struct DLLImportFunctionVisitor
4270+
: public RecursiveASTVisitor<DLLImportFunctionVisitor> {
42704271
bool SafeToInline = true;
42714272

4272-
DLLImportFunctionVisitor() { ShouldVisitImplicitCode = true; }
4273+
bool shouldVisitImplicitCode() const { return true; }
42734274

4274-
bool VisitVarDecl(VarDecl *VD) override {
4275+
bool VisitVarDecl(VarDecl *VD) {
42754276
if (VD->getTLSKind()) {
42764277
// A thread-local variable cannot be imported.
42774278
SafeToInline = false;
@@ -4285,13 +4286,13 @@ namespace {
42854286
return SafeToInline;
42864287
}
42874288

4288-
bool VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *E) override {
4289+
bool VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *E) {
42894290
if (const auto *D = E->getTemporary()->getDestructor())
42904291
SafeToInline = D->hasAttr<DLLImportAttr>();
42914292
return SafeToInline;
42924293
}
42934294

4294-
bool VisitDeclRefExpr(DeclRefExpr *E) override {
4295+
bool VisitDeclRefExpr(DeclRefExpr *E) {
42954296
ValueDecl *VD = E->getDecl();
42964297
if (isa<FunctionDecl>(VD))
42974298
SafeToInline = VD->hasAttr<DLLImportAttr>();
@@ -4300,12 +4301,12 @@ namespace {
43004301
return SafeToInline;
43014302
}
43024303

4303-
bool VisitCXXConstructExpr(CXXConstructExpr *E) override {
4304+
bool VisitCXXConstructExpr(CXXConstructExpr *E) {
43044305
SafeToInline = E->getConstructor()->hasAttr<DLLImportAttr>();
43054306
return SafeToInline;
43064307
}
43074308

4308-
bool VisitCXXMemberCallExpr(CXXMemberCallExpr *E) override {
4309+
bool VisitCXXMemberCallExpr(CXXMemberCallExpr *E) {
43094310
CXXMethodDecl *M = E->getMethodDecl();
43104311
if (!M) {
43114312
// Call through a pointer to member function. This is safe to inline.
@@ -4316,12 +4317,12 @@ namespace {
43164317
return SafeToInline;
43174318
}
43184319

4319-
bool VisitCXXDeleteExpr(CXXDeleteExpr *E) override {
4320+
bool VisitCXXDeleteExpr(CXXDeleteExpr *E) {
43204321
SafeToInline = E->getOperatorDelete()->hasAttr<DLLImportAttr>();
43214322
return SafeToInline;
43224323
}
43234324

4324-
bool VisitCXXNewExpr(CXXNewExpr *E) override {
4325+
bool VisitCXXNewExpr(CXXNewExpr *E) {
43254326
SafeToInline = E->getOperatorNew()->hasAttr<DLLImportAttr>();
43264327
return SafeToInline;
43274328
}

clang/lib/CodeGen/ObjectFilePCHContainerWriter.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
#include "CodeGenModule.h"
1212
#include "clang/AST/ASTContext.h"
1313
#include "clang/AST/DeclObjC.h"
14-
#include "clang/AST/DynamicRecursiveASTVisitor.h"
1514
#include "clang/AST/Expr.h"
15+
#include "clang/AST/RecursiveASTVisitor.h"
1616
#include "clang/Basic/CodeGenOptions.h"
1717
#include "clang/Basic/Diagnostic.h"
1818
#include "clang/Basic/TargetInfo.h"
@@ -56,7 +56,7 @@ class PCHContainerGenerator : public ASTConsumer {
5656
std::shared_ptr<PCHBuffer> Buffer;
5757

5858
/// Visit every type and emit debug info for it.
59-
struct DebugTypeVisitor : DynamicRecursiveASTVisitor {
59+
struct DebugTypeVisitor : public RecursiveASTVisitor<DebugTypeVisitor> {
6060
clang::CodeGen::CGDebugInfo &DI;
6161
ASTContext &Ctx;
6262
DebugTypeVisitor(clang::CodeGen::CGDebugInfo &DI, ASTContext &Ctx)
@@ -67,13 +67,13 @@ class PCHContainerGenerator : public ASTConsumer {
6767
return !Ty->isDependentType() && !Ty->isUndeducedType();
6868
}
6969

70-
bool VisitImportDecl(ImportDecl *D) override {
70+
bool VisitImportDecl(ImportDecl *D) {
7171
if (!D->getImportedOwningModule())
7272
DI.EmitImportDecl(*D);
7373
return true;
7474
}
7575

76-
bool VisitTypeDecl(TypeDecl *D) override {
76+
bool VisitTypeDecl(TypeDecl *D) {
7777
// TagDecls may be deferred until after all decls have been merged and we
7878
// know the complete type. Pure forward declarations will be skipped, but
7979
// they don't need to be emitted into the module anyway.
@@ -90,14 +90,14 @@ class PCHContainerGenerator : public ASTConsumer {
9090
return true;
9191
}
9292

93-
bool VisitObjCInterfaceDecl(ObjCInterfaceDecl *D) override {
93+
bool VisitObjCInterfaceDecl(ObjCInterfaceDecl *D) {
9494
QualType QualTy(D->getTypeForDecl(), 0);
9595
if (!QualTy.isNull() && CanRepresent(QualTy.getTypePtr()))
9696
DI.getOrCreateStandaloneType(QualTy, D->getLocation());
9797
return true;
9898
}
9999

100-
bool VisitFunctionDecl(FunctionDecl *D) override {
100+
bool VisitFunctionDecl(FunctionDecl *D) {
101101
// Skip deduction guides.
102102
if (isa<CXXDeductionGuideDecl>(D))
103103
return true;
@@ -118,7 +118,7 @@ class PCHContainerGenerator : public ASTConsumer {
118118
return true;
119119
}
120120

121-
bool VisitObjCMethodDecl(ObjCMethodDecl *D) override {
121+
bool VisitObjCMethodDecl(ObjCMethodDecl *D) {
122122
if (!D->getClassInterface())
123123
return true;
124124

0 commit comments

Comments
 (0)