[LLD] Have only one SpecificAllocator per type
authorReid Kleckner <rnk@google.com>
Tue, 2 Jun 2020 20:58:50 +0000 (13:58 -0700)
committerReid Kleckner <rnk@google.com>
Tue, 2 Jun 2020 21:09:09 +0000 (14:09 -0700)
commit3eb16fe4e945631988d6d302d0bc317d8c07279c
tree9e38626e4ebaf94c2ef556b3ef41f60b77dad013
parentca4bd052f68c11a95fe7ac4f115b82ea05dd1c08
[LLD] Have only one SpecificAllocator per type

Previously, the SpecificAllocator was a static local in the `make<T>`
function template. Using static locals is nice because they are only
constructed and registered if they are accessed. However, if there are
multiple calls to make<> with different constructor parameters, we would
get multiple static local variable instances. This is undesirable and
leads to extra memory allocations. I noticed there were two sources of
DefinedRegular allocations while checking heap profiles.
lld/include/lld/Common/Memory.h