[cfe-commits] r65195 - in /cfe/trunk: include/clang/Lex/MacroInfo.h lib/Lex/PPDirectives.cpp lib/Lex/Preprocessor.cpp
Chris Lattner
sabre at nondot.org
Fri Feb 20 14:46:43 PST 2009
Author: lattner
Date: Fri Feb 20 16:46:43 2009
New Revision: 65195
URL: http://llvm.org/viewvc/llvm-project?rev=65195&view=rev
Log:
switch the macroinfo argument lists from being allocated off the heap
to being allocated from the same bumpptr that the MacroInfo objects
themselves are.
This speeds up -Eonly cocoa.h pth by ~4%, fsyntax-only is barely measurable.
Modified:
cfe/trunk/include/clang/Lex/MacroInfo.h
cfe/trunk/lib/Lex/PPDirectives.cpp
cfe/trunk/lib/Lex/Preprocessor.cpp
Modified: cfe/trunk/include/clang/Lex/MacroInfo.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/MacroInfo.h?rev=65195&r1=65194&r2=65195&view=diff
==============================================================================
--- cfe/trunk/include/clang/Lex/MacroInfo.h (original)
+++ cfe/trunk/include/clang/Lex/MacroInfo.h Fri Feb 20 16:46:43 2009
@@ -16,6 +16,7 @@
#include "clang/Lex/Token.h"
#include "llvm/ADT/SmallVector.h"
+#include "llvm/Support/Allocator.h"
#include <vector>
#include <cassert>
@@ -82,15 +83,15 @@
/// FreeArgumentList - Free the argument list of the macro, restoring it to a
/// state where it can be reused for other devious purposes.
- void FreeArgumentList() {
- delete[] ArgumentList;
+ void FreeArgumentList(llvm::BumpPtrAllocator &PPAllocator) {
+ PPAllocator.Deallocate(ArgumentList);
ArgumentList = 0;
NumArguments = 0;
}
/// Destroy - destroy this MacroInfo object.
- void Destroy() {
- FreeArgumentList();
+ void Destroy(llvm::BumpPtrAllocator &PPAllocator) {
+ FreeArgumentList(PPAllocator);
this->~MacroInfo();
}
@@ -117,13 +118,14 @@
/// setArgumentList - Set the specified list of identifiers as the argument
/// list for this macro.
- void setArgumentList(IdentifierInfo* const *List, unsigned NumArgs) {
+ void setArgumentList(IdentifierInfo* const *List, unsigned NumArgs,
+ llvm::BumpPtrAllocator &PPAllocator) {
assert(ArgumentList == 0 && NumArguments == 0 &&
"Argument list already set!");
if (NumArgs == 0) return;
NumArguments = NumArgs;
- ArgumentList = new IdentifierInfo*[NumArgs];
+ ArgumentList = PPAllocator.Allocate<IdentifierInfo*>(NumArgs);
for (unsigned i = 0; i != NumArgs; ++i)
ArgumentList[i] = List[i];
}
Modified: cfe/trunk/lib/Lex/PPDirectives.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPDirectives.cpp?rev=65195&r1=65194&r2=65195&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/PPDirectives.cpp (original)
+++ cfe/trunk/lib/Lex/PPDirectives.cpp Fri Feb 20 16:46:43 2009
@@ -40,7 +40,7 @@
/// be reused for allocating new MacroInfo objects.
void Preprocessor::ReleaseMacroInfo(MacroInfo* MI) {
MICache.push_back(MI);
- MI->FreeArgumentList();
+ MI->FreeArgumentList(BP);
}
@@ -1115,7 +1115,7 @@
// Add the __VA_ARGS__ identifier as an argument.
Arguments.push_back(Ident__VA_ARGS__);
MI->setIsC99Varargs();
- MI->setArgumentList(&Arguments[0], Arguments.size());
+ MI->setArgumentList(&Arguments[0], Arguments.size(), BP);
return false;
case tok::eom: // #define X(
Diag(Tok, diag::err_pp_missing_rparen_in_macro_def);
@@ -1149,7 +1149,7 @@
Diag(Tok, diag::err_pp_expected_comma_in_arg_list);
return true;
case tok::r_paren: // #define X(A)
- MI->setArgumentList(&Arguments[0], Arguments.size());
+ MI->setArgumentList(&Arguments[0], Arguments.size(), BP);
return false;
case tok::comma: // #define X(A,
break;
@@ -1165,7 +1165,7 @@
}
MI->setIsGNUVarargs();
- MI->setArgumentList(&Arguments[0], Arguments.size());
+ MI->setArgumentList(&Arguments[0], Arguments.size(), BP);
return false;
}
}
Modified: cfe/trunk/lib/Lex/Preprocessor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Preprocessor.cpp?rev=65195&r1=65194&r2=65195&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/Preprocessor.cpp (original)
+++ cfe/trunk/lib/Lex/Preprocessor.cpp Fri Feb 20 16:46:43 2009
@@ -101,7 +101,7 @@
// will be released when the BumpPtrAllocator 'BP' object gets
// destroyed. We still need to run the dstor, however, to free
// memory alocated by MacroInfo.
- I->second->Destroy();
+ I->second->Destroy(BP);
I->first->setHasMacroDefinition(false);
}
More information about the cfe-commits
mailing list