diff options
author | Douglas Gregor <dgregor@apple.com> | 2010-03-29 23:34:08 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2010-03-29 23:34:08 +0000 |
commit | fe6b2d481d91140923f4541f273b253291884214 (patch) | |
tree | 5a1b459e04812ca5b5797a726a16c05dfe7298ca /lib/Basic/Diagnostic.cpp | |
parent | 74350825e370a37fb3baec78082078b28fc3c8b4 (diff) |
Optimize PartialDiagnostic's memory-allocation behavior by placing a
cache of PartialDiagnostic::Storage objects into an allocator within
the ASTContext. This eliminates a significant amount of malloc
traffic, for a 10% performance improvement in -fsyntax-only wall-clock
time with 403.gcc's combine.c.
Also, eliminate the RequireNonAbstractType hack I put in earlier,
which was but a symptom of this larger problem.
Fixes <rdar://problem/7806091>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99849 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Basic/Diagnostic.cpp')
-rw-r--r-- | lib/Basic/Diagnostic.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/Basic/Diagnostic.cpp b/lib/Basic/Diagnostic.cpp index 21a8aeae42..9b8bae3142 100644 --- a/lib/Basic/Diagnostic.cpp +++ b/lib/Basic/Diagnostic.cpp @@ -12,6 +12,7 @@ //===----------------------------------------------------------------------===// #include "clang/Basic/Diagnostic.h" +#include "clang/Basic/PartialDiagnostic.h" #include "clang/Lex/LexDiagnostic.h" #include "clang/Parse/ParseDiagnostic.h" @@ -1246,3 +1247,13 @@ StoredDiagnostic::Deserialize(FileManager &FM, SourceManager &SM, /// DiagnosticClient should be included in the number of diagnostics /// reported by Diagnostic. bool DiagnosticClient::IncludeInDiagnosticCounts() const { return true; } + +PartialDiagnostic::StorageAllocator::StorageAllocator() { + for (unsigned I = 0; I != NumCached; ++I) + FreeList[I] = Cached + I; + NumFreeListEntries = NumCached; +} + +PartialDiagnostic::StorageAllocator::~StorageAllocator() { + assert(NumFreeListEntries == NumCached && "A partial is on the lamb"); +} |