Finish making AST BumpPtrAllocation runtime configurable (based on -disable-free).
snaroff% time ../../Release-Asserts/bin/clang INPUTS/Cocoa_h.m
0.179u 0.051s 0:00.23 95.6% 0+0k 0+0io 0pf+0w
snaroff% time ../../Release-Asserts/bin/clang INPUTS/Cocoa_h.m -disable-free
0.169u 0.052s 0:00.22 95.4% 0+0k 0+0io 0pf+0w
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63153 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp
index 7cc67e0..5e22691 100644
--- a/lib/AST/ASTContext.cpp
+++ b/lib/AST/ASTContext.cpp
@@ -31,9 +31,9 @@
ASTContext::ASTContext(const LangOptions& LOpts, SourceManager &SM,
TargetInfo &t,
IdentifierTable &idents, SelectorTable &sels,
- unsigned size_reserve) :
+ bool FreeMem, unsigned size_reserve) :
CFConstantStringTypeDecl(0), ObjCFastEnumerationStateTypeDecl(0),
- SourceMgr(SM), LangOpts(LOpts), Target(t),
+ SourceMgr(SM), LangOpts(LOpts), FreeMemory(FreeMem), Target(t),
Idents(idents), Selectors(sels)
{
if (size_reserve > 0) Types.reserve(size_reserve);
@@ -1126,8 +1126,8 @@
// FunctionTypeProto objects are allocated with extra bytes after them
// for a variable size array (for parameter types) at the end of them.
FunctionTypeProto *FTP =
- (FunctionTypeProto*)Allocator.Allocate(sizeof(FunctionTypeProto) +
- NumArgs*sizeof(QualType), 8);
+ (FunctionTypeProto*)Allocate(sizeof(FunctionTypeProto) +
+ NumArgs*sizeof(QualType), 8);
new (FTP) FunctionTypeProto(ResultTy, ArgArray, NumArgs, isVariadic,
TypeQuals, Canonical);
Types.push_back(FTP);
diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp
index c8b7fc2..25317db 100644
--- a/lib/AST/Decl.cpp
+++ b/lib/AST/Decl.cpp
@@ -118,8 +118,7 @@
EnumDecl *EnumDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation L,
IdentifierInfo *Id,
EnumDecl *PrevDecl) {
- void *Mem = C.getAllocator().Allocate<EnumDecl>();
- EnumDecl *Enum = new (Mem) EnumDecl(DC, L, Id);
+ EnumDecl *Enum = new (C) EnumDecl(DC, L, Id);
C.getTypeDeclType(Enum, PrevDecl);
return Enum;
}
@@ -229,7 +228,7 @@
// Zero params -> null pointer.
if (NumParams) {
- void *Mem = C.getAllocator().Allocate<ParmVarDecl*>(NumParams);
+ void *Mem = C.Allocate(sizeof(ParmVarDecl*)*NumParams);
ParamInfo = new (Mem) ParmVarDecl*[NumParams];
memcpy(ParamInfo, NewParamInfo, sizeof(ParmVarDecl*)*NumParams);
}
diff --git a/lib/AST/DeclCXX.cpp b/lib/AST/DeclCXX.cpp
index ee242c5..39ca878 100644
--- a/lib/AST/DeclCXX.cpp
+++ b/lib/AST/DeclCXX.cpp
@@ -47,7 +47,7 @@
// FIXME: how do I pass in Size to ASTContext::new?
unsigned Size = sizeof(TemplateParameterList) + sizeof(Decl *) * NumParams;
unsigned Align = llvm::AlignOf<TemplateParameterList>::Alignment;
- void *Mem = C.getAllocator().Allocate(Size, Align);
+ void *Mem = C.Allocate(Size, Align);
return new (Mem) TemplateParameterList(Params, NumParams);
}
diff --git a/lib/AST/DeclGroup.cpp b/lib/AST/DeclGroup.cpp
index c7af7cd..e7f84e1 100644
--- a/lib/AST/DeclGroup.cpp
+++ b/lib/AST/DeclGroup.cpp
@@ -24,7 +24,7 @@
assert (numdecls > 0);
unsigned size = sizeof(DeclGroup) + sizeof(Decl*) * numdecls;
unsigned alignment = llvm::AlignOf<DeclGroup>::Alignment;
- void* mem = C.getAllocator().Allocate(size, alignment);
+ void* mem = C.Allocate(size, alignment);
new (mem) DeclGroup(numdecls, decls);
return static_cast<DeclGroup*>(mem);
}
@@ -40,7 +40,7 @@
unsigned NumDecls = (unsigned) D.ReadInt();
unsigned size = sizeof(DeclGroup) + sizeof(Decl*) * NumDecls;
unsigned alignment = llvm::AlignOf<DeclGroup>::Alignment;
- DeclGroup* DG = (DeclGroup*) C.getAllocator().Allocate(size, alignment);
+ DeclGroup* DG = (DeclGroup*) C.Allocate(size, alignment);
new (DG) DeclGroup();
DG->NumDecls = NumDecls;
D.BatchReadOwnedPtrs(NumDecls, &(*DG)[0], C);
diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp
index 63484d1..8e43f99 100644
--- a/lib/AST/Expr.cpp
+++ b/lib/AST/Expr.cpp
@@ -1387,10 +1387,9 @@
Expr **IndexExprs, unsigned NumIndexExprs,
SourceLocation ColonOrEqualLoc,
bool UsesColonSyntax, Expr *Init) {
- void *Mem = C.getAllocator().Allocate(sizeof(DesignatedInitExpr) +
- sizeof(Designator) * NumDesignators +
- sizeof(Stmt *) * (NumIndexExprs + 1),
- 8);
+ void *Mem = C.Allocate(sizeof(DesignatedInitExpr) +
+ sizeof(Designator) * NumDesignators +
+ sizeof(Stmt *) * (NumIndexExprs + 1), 8);
DesignatedInitExpr *DIE
= new (Mem) DesignatedInitExpr(C.VoidTy, NumDesignators,
ColonOrEqualLoc, UsesColonSyntax,