aboutsummaryrefslogtreecommitdiff
path: root/include/lld/Support/Memory.h
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2017-05-08 17:13:44 +0000
committerDimitry Andric <dim@FreeBSD.org>2017-05-08 17:13:44 +0000
commitfbe69f787ace06f44b6cb1bd3cd45ac703a16a05 (patch)
tree71baf2dfe04008283f87b4c0ae75a2268033cd62 /include/lld/Support/Memory.h
parentd803cda42997f42649910309ac18170d2d6f2214 (diff)
downloadsrc-fbe69f787ace06f44b6cb1bd3cd45ac703a16a05.tar.gz
src-fbe69f787ace06f44b6cb1bd3cd45ac703a16a05.zip
Notes
Diffstat (limited to 'include/lld/Support/Memory.h')
-rw-r--r--include/lld/Support/Memory.h63
1 files changed, 0 insertions, 63 deletions
diff --git a/include/lld/Support/Memory.h b/include/lld/Support/Memory.h
deleted file mode 100644
index 46db4a39f696..000000000000
--- a/include/lld/Support/Memory.h
+++ /dev/null
@@ -1,63 +0,0 @@
-//===- Memory.h -------------------------------------------------*- C++ -*-===//
-//
-// The LLVM Linker
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This file defines arena allocators.
-//
-// Almost all large objects, such as files, sections or symbols, are
-// used for the entire lifetime of the linker once they are created.
-// This usage characteristic makes arena allocator an attractive choice
-// where the entire linker is one arena. With an arena, newly created
-// objects belong to the arena and freed all at once when everything is done.
-// Arena allocators are efficient and easy to understand.
-// Most objects are allocated using the arena allocators defined by this file.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLD_MEMORY_H
-#define LLD_MEMORY_H
-
-#include "llvm/Support/Allocator.h"
-#include "llvm/Support/StringSaver.h"
-#include <vector>
-
-namespace lld {
-
-// Use this arena if your object doesn't have a destructor.
-extern llvm::BumpPtrAllocator BAlloc;
-extern llvm::StringSaver Saver;
-
-// These two classes are hack to keep track of all
-// SpecificBumpPtrAllocator instances.
-struct SpecificAllocBase {
- SpecificAllocBase() { Instances.push_back(this); }
- virtual ~SpecificAllocBase() = default;
- virtual void reset() = 0;
- static std::vector<SpecificAllocBase *> Instances;
-};
-
-template <class T> struct SpecificAlloc : public SpecificAllocBase {
- void reset() override { Alloc.DestroyAll(); }
- llvm::SpecificBumpPtrAllocator<T> Alloc;
-};
-
-// Use this arena if your object has a destructor.
-// Your destructor will be invoked from freeArena().
-template <typename T, typename... U> inline T *make(U &&... Args) {
- static SpecificAlloc<T> Alloc;
- return new (Alloc.Alloc.Allocate()) T(std::forward<U>(Args)...);
-}
-
-inline void freeArena() {
- for (SpecificAllocBase *Alloc : SpecificAllocBase::Instances)
- Alloc->reset();
- BAlloc.Reset();
-}
-}
-
-#endif