Move Memory.{h,cpp} to lld/Support so that we can use them from COFF.
authorRui Ueyama <ruiu@google.com>
Thu, 8 Dec 2016 18:31:13 +0000 (18:31 +0000)
committerRui Ueyama <ruiu@google.com>
Thu, 8 Dec 2016 18:31:13 +0000 (18:31 +0000)
llvm-svn: 289084

16 files changed:
lld/ELF/CMakeLists.txt
lld/ELF/Driver.cpp
lld/ELF/DriverUtils.cpp
lld/ELF/InputFiles.cpp
lld/ELF/InputSection.cpp
lld/ELF/LinkerScript.cpp
lld/ELF/OutputSections.cpp
lld/ELF/SymbolTable.cpp
lld/ELF/SyntheticSections.cpp
lld/ELF/Target.cpp
lld/ELF/Thunks.cpp
lld/ELF/Writer.cpp
lld/include/lld/Support/Memory.h [moved from lld/ELF/Memory.h with 96% similarity]
lld/lib/CMakeLists.txt
lld/lib/Support/CMakeLists.txt [new file with mode: 0644]
lld/lib/Support/Memory.cpp [moved from lld/ELF/Memory.cpp with 79% similarity]

index 39cf8ec..9780e1e 100644 (file)
@@ -14,7 +14,6 @@ add_lld_library(lldELF
   LTO.cpp
   LinkerScript.cpp
   MarkLive.cpp
-  Memory.cpp
   Mips.cpp
   OutputSections.cpp
   Relocations.cpp
@@ -50,6 +49,7 @@ add_lld_library(lldELF
   LINK_LIBS
   lldConfig
   lldCore
+  lldSupport
   ${PTHREAD_LIB}
 
   DEPENDS
index 2095e73..a2c96b8 100644 (file)
@@ -14,7 +14,6 @@
 #include "InputFiles.h"
 #include "InputSection.h"
 #include "LinkerScript.h"
-#include "Memory.h"
 #include "Strings.h"
 #include "SymbolTable.h"
 #include "Target.h"
@@ -22,6 +21,7 @@
 #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"
index 6a270a6..179dfd3 100644 (file)
 
 #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"
index 06a19f5..37ebfa7 100644 (file)
@@ -12,9 +12,9 @@
 #include "Error.h"
 #include "InputSection.h"
 #include "LinkerScript.h"
-#include "Memory.h"
 #include "SymbolTable.h"
 #include "Symbols.h"
+#include "lld/Support/Memory.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/Bitcode/BitcodeReader.h"
 #include "llvm/CodeGen/Analysis.h"
index f11b7b7..975882e 100644 (file)
 #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>
index 50ce955..1a19f55 100644 (file)
@@ -15,7 +15,6 @@
 #include "Config.h"
 #include "Driver.h"
 #include "InputSection.h"
-#include "Memory.h"
 #include "OutputSections.h"
 #include "ScriptParser.h"
 #include "Strings.h"
@@ -24,6 +23,7 @@
 #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"
index cfb8ac9..f8daa57 100644 (file)
 #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"
index 078fbb3..25e435d 100644 (file)
@@ -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;
index d69100a..e833251 100644 (file)
 #include "Error.h"
 #include "InputFiles.h"
 #include "LinkerScript.h"
-#include "Memory.h"
 #include "OutputSections.h"
 #include "Strings.h"
 #include "SymbolTable.h"
 #include "Target.h"
 #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"
index 73fab27..aa88736 100644 (file)
 #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/Endian.h"
 #include "llvm/Support/ELF.h"
+#include "llvm/Support/Endian.h"
 
 using namespace llvm;
 using namespace llvm::object;
index 34b630a..e7a1efe 100644 (file)
 #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"
index be9be49..c63b883 100644 (file)
 #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"
similarity index 96%
rename from lld/ELF/Memory.h
rename to lld/include/lld/Support/Memory.h
index 9479fd0..1ed5ec9 100644 (file)
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef LLD_ELF_MEMORY_H
-#define LLD_ELF_MEMORY_H
+#ifndef LLD_MEMORY_H
+#define LLD_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;
@@ -56,6 +55,5 @@ template <typename T, typename... U> inline T *make(U &&... Args) {
 
 void freeArena();
 }
-}
 
 #endif
index 699f5e9..acd5322 100644 (file)
@@ -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 (file)
index 0000000..18dccdb
--- /dev/null
@@ -0,0 +1,9 @@
+add_lld_library(lldSupport
+  Memory.cpp
+
+  ADDITIONAL_HEADER_DIRS
+  ${LLD_INCLUDE_DIR}/lld/Support
+
+  LINK_LIBS
+  LLVMSupport
+)
similarity index 79%
rename from lld/ELF/Memory.cpp
rename to lld/lib/Support/Memory.cpp
index 7771317..9bdcdcc 100644 (file)
@@ -7,21 +7,19 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "Memory.h"
+#include "lld/Support/Memory.h"
 
 using namespace llvm;
-using namespace lld;
-using namespace lld::elf;
 
 namespace lld {
-BumpPtrAllocator elf::BAlloc;
-StringSaver elf::Saver{elf::BAlloc};
+BumpPtrAllocator BAlloc;
+StringSaver Saver{BAlloc};
 
 SpecificAllocBase::SpecificAllocBase() { Instances.push_back(this); }
 
 std::vector<SpecificAllocBase *> SpecificAllocBase::Instances;
 
-void elf::freeArena() {
+void freeArena() {
   for (SpecificAllocBase *Alloc : SpecificAllocBase::Instances)
     Alloc->reset();
   BAlloc.Reset();