83d59e05b2
Move all variables at file-scope or function-static-scope into a hosting structure (lld::CommonLinkerContext) that lives at lldMain()-scope. Drivers will inherit from this structure and add their own global state, in the same way as for the existing COFFLinkerContext. See discussion in https://lists.llvm.org/pipermail/llvm-dev/2021-June/151184.html The previous landf860fe3622
caused issues in https://lab.llvm.org/buildbot/#/builders/123/builds/8383, fixed by22ee510dac
. Differential Revision: https://reviews.llvm.org/D108850
26 lines
884 B
C++
26 lines
884 B
C++
//===- Memory.cpp ---------------------------------------------------------===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "lld/Common/Memory.h"
|
|
#include "lld/Common/CommonLinkerContext.h"
|
|
|
|
using namespace llvm;
|
|
using namespace lld;
|
|
|
|
SpecificAllocBase *
|
|
lld::SpecificAllocBase::getOrCreate(void *tag, size_t size, size_t align,
|
|
SpecificAllocBase *(&creator)(void *)) {
|
|
auto &instances = context().instances;
|
|
auto &instance = instances[tag];
|
|
if (instance == nullptr) {
|
|
void *storage = context().bAlloc.Allocate(size, align);
|
|
instance = creator(storage);
|
|
}
|
|
return instance;
|
|
}
|