[lld] r290062 - Remove lld/Support/Memory.h.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Sun Dec 18 06:06:07 PST 2016


Author: ruiu
Date: Sun Dec 18 08:06:06 2016
New Revision: 290062

URL: http://llvm.org/viewvc/llvm-project?rev=290062&view=rev
Log:
Remove lld/Support/Memory.h.

I thought for a while about how to remove it, but it looks like we
can just copy the file for now. Of course I'm not happy about that,
but it's just less than 50 lines of code, and we already have
duplicate code in Error.h and some other places. I want to solve
them all at once later.

Differential Revision: https://reviews.llvm.org/D27819

Added:
    lld/trunk/COFF/Memory.h
      - copied, changed from r290042, lld/trunk/include/lld/Support/Memory.h
    lld/trunk/ELF/Memory.h
      - copied, changed from r290042, lld/trunk/include/lld/Support/Memory.h
Removed:
    lld/trunk/lib/Support/CMakeLists.txt
    lld/trunk/lib/Support/Memory.cpp
Modified:
    lld/trunk/COFF/CMakeLists.txt
    lld/trunk/COFF/Driver.cpp
    lld/trunk/COFF/DriverUtils.cpp
    lld/trunk/COFF/InputFiles.cpp
    lld/trunk/COFF/ModuleDef.cpp
    lld/trunk/COFF/SymbolTable.cpp
    lld/trunk/COFF/Symbols.cpp
    lld/trunk/COFF/Symbols.h
    lld/trunk/COFF/Writer.cpp
    lld/trunk/ELF/CMakeLists.txt
    lld/trunk/ELF/Driver.cpp
    lld/trunk/ELF/DriverUtils.cpp
    lld/trunk/ELF/InputFiles.cpp
    lld/trunk/ELF/InputSection.cpp
    lld/trunk/ELF/LinkerScript.cpp
    lld/trunk/ELF/OutputSections.cpp
    lld/trunk/ELF/SymbolTable.cpp
    lld/trunk/ELF/SyntheticSections.cpp
    lld/trunk/ELF/Target.cpp
    lld/trunk/ELF/Thunks.cpp
    lld/trunk/ELF/Writer.cpp
    lld/trunk/include/lld/Support/Memory.h
    lld/trunk/lib/CMakeLists.txt

Modified: lld/trunk/COFF/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/CMakeLists.txt?rev=290062&r1=290061&r2=290062&view=diff
==============================================================================
--- lld/trunk/COFF/CMakeLists.txt (original)
+++ lld/trunk/COFF/CMakeLists.txt Sun Dec 18 08:06:06 2016
@@ -40,7 +40,6 @@ add_lld_library(lldCOFF
 
   LINK_LIBS
   lldCore
-  lldSupport
   ${PTHREAD_LIB}
 
   DEPENDS

Modified: lld/trunk/COFF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Driver.cpp?rev=290062&r1=290061&r2=290062&view=diff
==============================================================================
--- lld/trunk/COFF/Driver.cpp (original)
+++ lld/trunk/COFF/Driver.cpp Sun Dec 18 08:06:06 2016
@@ -11,11 +11,11 @@
 #include "Config.h"
 #include "Error.h"
 #include "InputFiles.h"
+#include "Memory.h"
 #include "SymbolTable.h"
 #include "Symbols.h"
 #include "Writer.h"
 #include "lld/Driver/Driver.h"
-#include "lld/Support/Memory.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/LibDriver/LibDriver.h"
@@ -50,6 +50,10 @@ namespace coff {
 Configuration *Config;
 LinkerDriver *Driver;
 
+BumpPtrAllocator BAlloc;
+StringSaver Saver{BAlloc};
+std::vector<SpecificAllocBase *> SpecificAllocBase::Instances;
+
 bool link(ArrayRef<const char *> Args) {
   Config = make<Configuration>();
   Driver = make<LinkerDriver>();

Modified: lld/trunk/COFF/DriverUtils.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/DriverUtils.cpp?rev=290062&r1=290061&r2=290062&view=diff
==============================================================================
--- lld/trunk/COFF/DriverUtils.cpp (original)
+++ lld/trunk/COFF/DriverUtils.cpp Sun Dec 18 08:06:06 2016
@@ -16,8 +16,8 @@
 #include "Config.h"
 #include "Driver.h"
 #include "Error.h"
+#include "Memory.h"
 #include "Symbols.h"
-#include "lld/Support/Memory.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/Object/COFF.h"

Modified: lld/trunk/COFF/InputFiles.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/InputFiles.cpp?rev=290062&r1=290061&r2=290062&view=diff
==============================================================================
--- lld/trunk/COFF/InputFiles.cpp (original)
+++ lld/trunk/COFF/InputFiles.cpp Sun Dec 18 08:06:06 2016
@@ -7,14 +7,15 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "InputFiles.h"
 #include "Chunks.h"
 #include "Config.h"
 #include "Driver.h"
 #include "Error.h"
-#include "InputFiles.h"
+#include "Memory.h"
 #include "SymbolTable.h"
 #include "Symbols.h"
-#include "lld/Support/Memory.h"
+#include "llvm-c/lto.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/Triple.h"
 #include "llvm/ADT/Twine.h"
@@ -29,7 +30,6 @@
 #include "llvm/Support/ErrorOr.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Target/TargetOptions.h"
-#include "llvm-c/lto.h"
 #include <cstring>
 #include <system_error>
 #include <utility>

Copied: lld/trunk/COFF/Memory.h (from r290042, lld/trunk/include/lld/Support/Memory.h)
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Memory.h?p2=lld/trunk/COFF/Memory.h&p1=lld/trunk/include/lld/Support/Memory.h&r1=290042&r2=290062&rev=290062&view=diff
==============================================================================
--- lld/trunk/include/lld/Support/Memory.h (original)
+++ lld/trunk/COFF/Memory.h Sun Dec 18 08:06:06 2016
@@ -7,35 +7,25 @@
 //
 //===----------------------------------------------------------------------===//
 //
-// 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.
+// See ELF/Memory.h
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef LLD_MEMORY_H
-#define LLD_MEMORY_H
+#ifndef LLD_COFF_MEMORY_H
+#define LLD_COFF_MEMORY_H
 
 #include "llvm/Support/Allocator.h"
 #include "llvm/Support/StringSaver.h"
 #include <vector>
 
 namespace lld {
+namespace coff {
 
-// 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();
+  SpecificAllocBase() { Instances.push_back(this); }
   virtual ~SpecificAllocBase() = default;
   virtual void reset() = 0;
   static std::vector<SpecificAllocBase *> Instances;
@@ -46,14 +36,17 @@ template <class T> struct SpecificAlloc
   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) {
+template <typename T, typename... U> T *make(U &&... Args) {
   static SpecificAlloc<T> Alloc;
   return new (Alloc.Alloc.Allocate()) T(std::forward<U>(Args)...);
 }
 
-void freeArena();
+inline void freeArena() {
+  for (SpecificAllocBase *Alloc : SpecificAllocBase::Instances)
+    Alloc->reset();
+  BAlloc.Reset();
+}
+}
 }
 
 #endif

Modified: lld/trunk/COFF/ModuleDef.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/ModuleDef.cpp?rev=290062&r1=290061&r2=290062&view=diff
==============================================================================
--- lld/trunk/COFF/ModuleDef.cpp (original)
+++ lld/trunk/COFF/ModuleDef.cpp Sun Dec 18 08:06:06 2016
@@ -18,7 +18,7 @@
 
 #include "Config.h"
 #include "Error.h"
-#include "lld/Support/Memory.h"
+#include "Memory.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/Support/StringSaver.h"

Modified: lld/trunk/COFF/SymbolTable.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/SymbolTable.cpp?rev=290062&r1=290061&r2=290062&view=diff
==============================================================================
--- lld/trunk/COFF/SymbolTable.cpp (original)
+++ lld/trunk/COFF/SymbolTable.cpp Sun Dec 18 08:06:06 2016
@@ -11,8 +11,8 @@
 #include "Config.h"
 #include "Driver.h"
 #include "Error.h"
+#include "Memory.h"
 #include "Symbols.h"
-#include "lld/Support/Memory.h"
 #include "llvm/IR/LLVMContext.h"
 #include "llvm/LTO/legacy/LTOCodeGenerator.h"
 #include "llvm/Support/Debug.h"

Modified: lld/trunk/COFF/Symbols.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Symbols.cpp?rev=290062&r1=290061&r2=290062&view=diff
==============================================================================
--- lld/trunk/COFF/Symbols.cpp (original)
+++ lld/trunk/COFF/Symbols.cpp Sun Dec 18 08:06:06 2016
@@ -10,8 +10,8 @@
 #include "Symbols.h"
 #include "Error.h"
 #include "InputFiles.h"
+#include "Memory.h"
 #include "Strings.h"
-#include "lld/Support/Memory.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/raw_ostream.h"

Modified: lld/trunk/COFF/Symbols.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Symbols.h?rev=290062&r1=290061&r2=290062&view=diff
==============================================================================
--- lld/trunk/COFF/Symbols.h (original)
+++ lld/trunk/COFF/Symbols.h Sun Dec 18 08:06:06 2016
@@ -12,8 +12,8 @@
 
 #include "Chunks.h"
 #include "Config.h"
+#include "Memory.h"
 #include "lld/Core/LLVM.h"
-#include "lld/Support/Memory.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/Object/Archive.h"
 #include "llvm/Object/COFF.h"

Modified: lld/trunk/COFF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Writer.cpp?rev=290062&r1=290061&r2=290062&view=diff
==============================================================================
--- lld/trunk/COFF/Writer.cpp (original)
+++ lld/trunk/COFF/Writer.cpp Sun Dec 18 08:06:06 2016
@@ -12,11 +12,11 @@
 #include "DLL.h"
 #include "Error.h"
 #include "InputFiles.h"
+#include "Memory.h"
 #include "PDB.h"
 #include "SymbolTable.h"
 #include "Symbols.h"
 #include "lld/Core/Parallel.h"
-#include "lld/Support/Memory.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringSwitch.h"

Modified: lld/trunk/ELF/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/CMakeLists.txt?rev=290062&r1=290061&r2=290062&view=diff
==============================================================================
--- lld/trunk/ELF/CMakeLists.txt (original)
+++ lld/trunk/ELF/CMakeLists.txt Sun Dec 18 08:06:06 2016
@@ -53,7 +53,6 @@ add_lld_library(lldELF
   LINK_LIBS
   lldConfig
   lldCore
-  lldSupport
   ${PTHREAD_LIB}
 
   DEPENDS

Modified: lld/trunk/ELF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Driver.cpp?rev=290062&r1=290061&r2=290062&view=diff
==============================================================================
--- lld/trunk/ELF/Driver.cpp (original)
+++ lld/trunk/ELF/Driver.cpp Sun Dec 18 08:06:06 2016
@@ -14,6 +14,7 @@
 #include "InputFiles.h"
 #include "InputSection.h"
 #include "LinkerScript.h"
+#include "Memory.h"
 #include "Strings.h"
 #include "SymbolTable.h"
 #include "Target.h"
@@ -21,7 +22,6 @@
 #include "Writer.h"
 #include "lld/Config/Version.h"
 #include "lld/Driver/Driver.h"
-#include "lld/Support/Memory.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/Support/CommandLine.h"
@@ -42,6 +42,10 @@ using namespace lld::elf;
 Configuration *elf::Config;
 LinkerDriver *elf::Driver;
 
+BumpPtrAllocator elf::BAlloc;
+StringSaver elf::Saver{BAlloc};
+std::vector<SpecificAllocBase *> elf::SpecificAllocBase::Instances;
+
 bool elf::link(ArrayRef<const char *> Args, bool CanExitEarly,
                raw_ostream &Error) {
   ErrorCount = 0;

Modified: lld/trunk/ELF/DriverUtils.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/DriverUtils.cpp?rev=290062&r1=290061&r2=290062&view=diff
==============================================================================
--- lld/trunk/ELF/DriverUtils.cpp (original)
+++ lld/trunk/ELF/DriverUtils.cpp Sun Dec 18 08:06:06 2016
@@ -15,10 +15,10 @@
 
 #include "Driver.h"
 #include "Error.h"
+#include "Memory.h"
 #include "ScriptParser.h"
 #include "lld/Config/Version.h"
 #include "lld/Core/Reproduce.h"
-#include "lld/Support/Memory.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/Triple.h"

Modified: lld/trunk/ELF/InputFiles.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputFiles.cpp?rev=290062&r1=290061&r2=290062&view=diff
==============================================================================
--- lld/trunk/ELF/InputFiles.cpp (original)
+++ lld/trunk/ELF/InputFiles.cpp Sun Dec 18 08:06:06 2016
@@ -12,10 +12,10 @@
 #include "Error.h"
 #include "InputSection.h"
 #include "LinkerScript.h"
+#include "Memory.h"
 #include "SymbolTable.h"
 #include "Symbols.h"
 #include "SyntheticSections.h"
-#include "lld/Support/Memory.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/Bitcode/BitcodeReader.h"
 #include "llvm/CodeGen/Analysis.h"

Modified: lld/trunk/ELF/InputSection.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputSection.cpp?rev=290062&r1=290061&r2=290062&view=diff
==============================================================================
--- lld/trunk/ELF/InputSection.cpp (original)
+++ lld/trunk/ELF/InputSection.cpp Sun Dec 18 08:06:06 2016
@@ -13,12 +13,12 @@
 #include "Error.h"
 #include "InputFiles.h"
 #include "LinkerScript.h"
+#include "Memory.h"
 #include "OutputSections.h"
 #include "Relocations.h"
 #include "SyntheticSections.h"
 #include "Target.h"
 #include "Thunks.h"
-#include "lld/Support/Memory.h"
 #include "llvm/Support/Compression.h"
 #include "llvm/Support/Endian.h"
 #include <mutex>

Modified: lld/trunk/ELF/LinkerScript.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LinkerScript.cpp?rev=290062&r1=290061&r2=290062&view=diff
==============================================================================
--- lld/trunk/ELF/LinkerScript.cpp (original)
+++ lld/trunk/ELF/LinkerScript.cpp Sun Dec 18 08:06:06 2016
@@ -15,6 +15,7 @@
 #include "Config.h"
 #include "Driver.h"
 #include "InputSection.h"
+#include "Memory.h"
 #include "OutputSections.h"
 #include "ScriptParser.h"
 #include "Strings.h"
@@ -23,7 +24,6 @@
 #include "SyntheticSections.h"
 #include "Target.h"
 #include "Writer.h"
-#include "lld/Support/Memory.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/StringRef.h"

Copied: lld/trunk/ELF/Memory.h (from r290042, lld/trunk/include/lld/Support/Memory.h)
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Memory.h?p2=lld/trunk/ELF/Memory.h&p1=lld/trunk/include/lld/Support/Memory.h&r1=290042&r2=290062&rev=290062&view=diff
==============================================================================
--- lld/trunk/include/lld/Support/Memory.h (original)
+++ lld/trunk/ELF/Memory.h Sun Dec 18 08:06:06 2016
@@ -17,16 +17,19 @@
 // Arena allocators are efficient and easy to understand.
 // Most objects are allocated using the arena allocators defined by this file.
 //
+// If you edit this file, please edit COFF/Memory.h too.
+//
 //===----------------------------------------------------------------------===//
 
-#ifndef LLD_MEMORY_H
-#define LLD_MEMORY_H
+#ifndef LLD_ELF_MEMORY_H
+#define LLD_ELF_MEMORY_H
 
 #include "llvm/Support/Allocator.h"
 #include "llvm/Support/StringSaver.h"
 #include <vector>
 
 namespace lld {
+namespace elf {
 
 // Use this arena if your object doesn't have a destructor.
 extern llvm::BumpPtrAllocator BAlloc;
@@ -35,7 +38,7 @@ extern llvm::StringSaver Saver;
 // These two classes are hack to keep track of all
 // SpecificBumpPtrAllocator instances.
 struct SpecificAllocBase {
-  SpecificAllocBase();
+  SpecificAllocBase() { Instances.push_back(this); }
   virtual ~SpecificAllocBase() = default;
   virtual void reset() = 0;
   static std::vector<SpecificAllocBase *> Instances;
@@ -48,12 +51,17 @@ template <class T> struct SpecificAlloc
 
 // 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) {
+template <typename T, typename... U> T *make(U &&... Args) {
   static SpecificAlloc<T> Alloc;
   return new (Alloc.Alloc.Allocate()) T(std::forward<U>(Args)...);
 }
 
-void freeArena();
+inline void freeArena() {
+  for (SpecificAllocBase *Alloc : SpecificAllocBase::Instances)
+    Alloc->reset();
+  BAlloc.Reset();
+}
+}
 }
 
 #endif

Modified: lld/trunk/ELF/OutputSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.cpp?rev=290062&r1=290061&r2=290062&view=diff
==============================================================================
--- lld/trunk/ELF/OutputSections.cpp (original)
+++ lld/trunk/ELF/OutputSections.cpp Sun Dec 18 08:06:06 2016
@@ -11,12 +11,12 @@
 #include "Config.h"
 #include "EhFrame.h"
 #include "LinkerScript.h"
+#include "Memory.h"
 #include "Strings.h"
 #include "SymbolTable.h"
 #include "SyntheticSections.h"
 #include "Target.h"
 #include "Threads.h"
-#include "lld/Support/Memory.h"
 #include "llvm/Support/Dwarf.h"
 #include "llvm/Support/MD5.h"
 #include "llvm/Support/MathExtras.h"

Modified: lld/trunk/ELF/SymbolTable.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SymbolTable.cpp?rev=290062&r1=290061&r2=290062&view=diff
==============================================================================
--- lld/trunk/ELF/SymbolTable.cpp (original)
+++ lld/trunk/ELF/SymbolTable.cpp Sun Dec 18 08:06:06 2016
@@ -18,8 +18,8 @@
 #include "Config.h"
 #include "Error.h"
 #include "LinkerScript.h"
+#include "Memory.h"
 #include "Symbols.h"
-#include "lld/Support/Memory.h"
 #include "llvm/ADT/STLExtras.h"
 
 using namespace llvm;

Modified: lld/trunk/ELF/SyntheticSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SyntheticSections.cpp?rev=290062&r1=290061&r2=290062&view=diff
==============================================================================
--- lld/trunk/ELF/SyntheticSections.cpp (original)
+++ lld/trunk/ELF/SyntheticSections.cpp Sun Dec 18 08:06:06 2016
@@ -19,6 +19,7 @@
 #include "Error.h"
 #include "InputFiles.h"
 #include "LinkerScript.h"
+#include "Memory.h"
 #include "OutputSections.h"
 #include "Strings.h"
 #include "SymbolTable.h"
@@ -26,7 +27,6 @@
 #include "Threads.h"
 #include "Writer.h"
 #include "lld/Config/Version.h"
-#include "lld/Support/Memory.h"
 #include "llvm/Support/Dwarf.h"
 #include "llvm/Support/Endian.h"
 #include "llvm/Support/MD5.h"

Modified: lld/trunk/ELF/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.cpp?rev=290062&r1=290061&r2=290062&view=diff
==============================================================================
--- lld/trunk/ELF/Target.cpp (original)
+++ lld/trunk/ELF/Target.cpp Sun Dec 18 08:06:06 2016
@@ -27,12 +27,12 @@
 #include "Target.h"
 #include "Error.h"
 #include "InputFiles.h"
+#include "Memory.h"
 #include "OutputSections.h"
 #include "Symbols.h"
 #include "SyntheticSections.h"
 #include "Thunks.h"
 #include "Writer.h"
-#include "lld/Support/Memory.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/Object/ELF.h"
 #include "llvm/Support/ELF.h"

Modified: lld/trunk/ELF/Thunks.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Thunks.cpp?rev=290062&r1=290061&r2=290062&view=diff
==============================================================================
--- lld/trunk/ELF/Thunks.cpp (original)
+++ lld/trunk/ELF/Thunks.cpp Sun Dec 18 08:06:06 2016
@@ -25,10 +25,10 @@
 #include "Config.h"
 #include "Error.h"
 #include "InputSection.h"
+#include "Memory.h"
 #include "OutputSections.h"
 #include "Symbols.h"
 #include "Target.h"
-#include "lld/Support/Memory.h"
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/ELF.h"
 #include "llvm/Support/Endian.h"

Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=290062&r1=290061&r2=290062&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Sun Dec 18 08:06:06 2016
@@ -10,13 +10,13 @@
 #include "Writer.h"
 #include "Config.h"
 #include "LinkerScript.h"
+#include "Memory.h"
 #include "OutputSections.h"
 #include "Relocations.h"
 #include "Strings.h"
 #include "SymbolTable.h"
 #include "SyntheticSections.h"
 #include "Target.h"
-#include "lld/Support/Memory.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/Support/FileOutputBuffer.h"

Modified: lld/trunk/include/lld/Support/Memory.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Support/Memory.h?rev=290062&r1=290061&r2=290062&view=diff
==============================================================================
--- lld/trunk/include/lld/Support/Memory.h (original)
+++ lld/trunk/include/lld/Support/Memory.h Sun Dec 18 08:06:06 2016
@@ -35,7 +35,7 @@ extern llvm::StringSaver Saver;
 // These two classes are hack to keep track of all
 // SpecificBumpPtrAllocator instances.
 struct SpecificAllocBase {
-  SpecificAllocBase();
+  SpecificAllocBase() { Instances.push_back(this); }
   virtual ~SpecificAllocBase() = default;
   virtual void reset() = 0;
   static std::vector<SpecificAllocBase *> Instances;
@@ -53,7 +53,11 @@ template <typename T, typename... U> inl
   return new (Alloc.Alloc.Allocate()) T(std::forward<U>(Args)...);
 }
 
-void freeArena();
+inline void freeArena() {
+  for (SpecificAllocBase *Alloc : SpecificAllocBase::Instances)
+    Alloc->reset();
+  BAlloc.Reset();
+}
 }
 
 #endif

Modified: lld/trunk/lib/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/CMakeLists.txt?rev=290062&r1=290061&r2=290062&view=diff
==============================================================================
--- lld/trunk/lib/CMakeLists.txt (original)
+++ lld/trunk/lib/CMakeLists.txt Sun Dec 18 08:06:06 2016
@@ -2,4 +2,3 @@ add_subdirectory(Config)
 add_subdirectory(Core)
 add_subdirectory(Driver)
 add_subdirectory(ReaderWriter)
-add_subdirectory(Support)

Removed: lld/trunk/lib/Support/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Support/CMakeLists.txt?rev=290061&view=auto
==============================================================================
--- lld/trunk/lib/Support/CMakeLists.txt (original)
+++ lld/trunk/lib/Support/CMakeLists.txt (removed)
@@ -1,9 +0,0 @@
-add_lld_library(lldSupport
-  Memory.cpp
-
-  ADDITIONAL_HEADER_DIRS
-  ${LLD_INCLUDE_DIR}/lld/Support
-
-  LINK_LIBS
-  LLVMSupport
-)

Removed: lld/trunk/lib/Support/Memory.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Support/Memory.cpp?rev=290061&view=auto
==============================================================================
--- lld/trunk/lib/Support/Memory.cpp (original)
+++ lld/trunk/lib/Support/Memory.cpp (removed)
@@ -1,27 +0,0 @@
-//===- 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();
-}
-}




More information about the llvm-commits mailing list