diff options
| author | Chandler Carruth <chandlerc@gmail.com> | 2015-12-30 03:00:23 +0000 |
|---|---|---|
| committer | Chandler Carruth <chandlerc@gmail.com> | 2015-12-30 03:00:23 +0000 |
| commit | ff5a01a7b1f2d14035e638f5b67e982a9b9e50ac (patch) | |
| tree | ce970e6de5cf94294c37b50091ede5e116141172 /clang/lib/AST | |
| parent | 813faed9200fd145f165baf4b620ceb356865786 (diff) | |
| download | bcm5719-llvm-ff5a01a7b1f2d14035e638f5b67e982a9b9e50ac.tar.gz bcm5719-llvm-ff5a01a7b1f2d14035e638f5b67e982a9b9e50ac.zip | |
[ptr-traits] Switch from a really wasteful SmallDenseMap of
SmallVector<.., 16> (16!!!!) objects to a simple SmallVector of pairs.
This no longer de-duplicates the common function pointers used during
deallocation, but this doesn't really seem worth the complexity and
overhead of managing the map-of-vectors. Notably, there is no reason to
assume that functions have the 4-byte alignment that DenseMap relies on,
and indeed this prevents checking the alignment of the DenseMap keys
because we can't even meaningfully query the alignment of functions
using our existing alignment tools.
Generally, function pointers don't seem like a great idea for keys in
a DenseMap. =]
I chatted with Richard Smith about this a bit as well and have written
down a FIXME because this *does* waste some memory and in general seems
a very clumsy memory management strategy. He would like to see a more
fundamental fix eventually here that tries to build a better pattern.
llvm-svn: 256610
Diffstat (limited to 'clang/lib/AST')
| -rw-r--r-- | clang/lib/AST/ASTContext.cpp | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index b344b0687f2..508124a2a6e 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -760,10 +760,8 @@ ASTContext::~ASTContext() { ReleaseDeclContextMaps(); // Call all of the deallocation functions on all of their targets. - for (DeallocationMap::const_iterator I = Deallocations.begin(), - E = Deallocations.end(); I != E; ++I) - for (unsigned J = 0, N = I->second.size(); J != N; ++J) - (I->first)((I->second)[J]); + for (auto &Pair : Deallocations) + (Pair.first)(Pair.second); // ASTRecordLayout objects in ASTRecordLayouts must always be destroyed // because they can contain DenseMaps. @@ -812,7 +810,7 @@ void ASTContext::ReleaseParentMapEntries() { } void ASTContext::AddDeallocation(void (*Callback)(void*), void *Data) { - Deallocations[Callback].push_back(Data); + Deallocations.push_back({Callback, Data}); } void |

