diff options
Diffstat (limited to 'lld/lib')
-rw-r--r-- | lld/lib/CMakeLists.txt | 1 | ||||
-rw-r--r-- | lld/lib/Support/CMakeLists.txt | 9 | ||||
-rw-r--r-- | lld/lib/Support/Memory.cpp | 27 |
3 files changed, 37 insertions, 0 deletions
diff --git a/lld/lib/CMakeLists.txt b/lld/lib/CMakeLists.txt index 699f5e93f8a..acd5322302f 100644 --- a/lld/lib/CMakeLists.txt +++ b/lld/lib/CMakeLists.txt @@ -2,3 +2,4 @@ add_subdirectory(Config) add_subdirectory(Core) add_subdirectory(Driver) add_subdirectory(ReaderWriter) +add_subdirectory(Support) diff --git a/lld/lib/Support/CMakeLists.txt b/lld/lib/Support/CMakeLists.txt new file mode 100644 index 00000000000..18dccdbc50c --- /dev/null +++ b/lld/lib/Support/CMakeLists.txt @@ -0,0 +1,9 @@ +add_lld_library(lldSupport + Memory.cpp + + ADDITIONAL_HEADER_DIRS + ${LLD_INCLUDE_DIR}/lld/Support + + LINK_LIBS + LLVMSupport +) diff --git a/lld/lib/Support/Memory.cpp b/lld/lib/Support/Memory.cpp new file mode 100644 index 00000000000..9bdcdcc8fdb --- /dev/null +++ b/lld/lib/Support/Memory.cpp @@ -0,0 +1,27 @@ +//===- Memory.cpp -----------------------------------------------*- C++ -*-===// +// +// The LLVM Linker +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "lld/Support/Memory.h" + +using namespace llvm; + +namespace lld { +BumpPtrAllocator BAlloc; +StringSaver Saver{BAlloc}; + +SpecificAllocBase::SpecificAllocBase() { Instances.push_back(this); } + +std::vector<SpecificAllocBase *> SpecificAllocBase::Instances; + +void freeArena() { + for (SpecificAllocBase *Alloc : SpecificAllocBase::Instances) + Alloc->reset(); + BAlloc.Reset(); +} +} |