1 //===- Memory.cpp ---------------------------------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #include "lld/Common/Memory.h"
10 #include "lld/Common/CommonLinkerContext.h"
16 lld::SpecificAllocBase::getOrCreate(void *tag
, size_t size
, size_t align
,
17 SpecificAllocBase
*(&creator
)(void *)) {
18 auto &instances
= context().instances
;
19 auto &instance
= instances
[tag
];
20 if (instance
== nullptr) {
21 void *storage
= context().bAlloc
.Allocate(size
, align
);
22 instance
= creator(storage
);