From: Rui Ueyama Date: Thu, 8 Dec 2016 18:31:13 +0000 (+0000) Subject: Move Memory.{h,cpp} to lld/Support so that we can use them from COFF. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=520d9169e6302be3a3e74e67a61ea07b03b18370;p=platform%2Fupstream%2Fllvm.git Move Memory.{h,cpp} to lld/Support so that we can use them from COFF. llvm-svn: 289084 --- diff --git a/lld/ELF/CMakeLists.txt b/lld/ELF/CMakeLists.txt index 39cf8ec..9780e1e 100644 --- a/lld/ELF/CMakeLists.txt +++ b/lld/ELF/CMakeLists.txt @@ -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 diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp index 2095e73..a2c96b8 100644 --- a/lld/ELF/Driver.cpp +++ b/lld/ELF/Driver.cpp @@ -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" diff --git a/lld/ELF/DriverUtils.cpp b/lld/ELF/DriverUtils.cpp index 6a270a6..179dfd3 100644 --- a/lld/ELF/DriverUtils.cpp +++ b/lld/ELF/DriverUtils.cpp @@ -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" diff --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp index 06a19f5..37ebfa7 100644 --- a/lld/ELF/InputFiles.cpp +++ b/lld/ELF/InputFiles.cpp @@ -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" diff --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp index f11b7b7..975882e 100644 --- a/lld/ELF/InputSection.cpp +++ b/lld/ELF/InputSection.cpp @@ -13,13 +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 diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp index 50ce955..1a19f55 100644 --- a/lld/ELF/LinkerScript.cpp +++ b/lld/ELF/LinkerScript.cpp @@ -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" diff --git a/lld/ELF/OutputSections.cpp b/lld/ELF/OutputSections.cpp index cfb8ac9..f8daa57 100644 --- a/lld/ELF/OutputSections.cpp +++ b/lld/ELF/OutputSections.cpp @@ -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" diff --git a/lld/ELF/SymbolTable.cpp b/lld/ELF/SymbolTable.cpp index 078fbb3..25e435d 100644 --- a/lld/ELF/SymbolTable.cpp +++ b/lld/ELF/SymbolTable.cpp @@ -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; diff --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp index d69100a..e833251 100644 --- a/lld/ELF/SyntheticSections.cpp +++ b/lld/ELF/SyntheticSections.cpp @@ -19,15 +19,14 @@ #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" diff --git a/lld/ELF/Target.cpp b/lld/ELF/Target.cpp index 73fab27..aa88736 100644 --- a/lld/ELF/Target.cpp +++ b/lld/ELF/Target.cpp @@ -27,17 +27,16 @@ #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; diff --git a/lld/ELF/Thunks.cpp b/lld/ELF/Thunks.cpp index 34b630a..e7a1efe 100644 --- a/lld/ELF/Thunks.cpp +++ b/lld/ELF/Thunks.cpp @@ -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" diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp index be9be49..c63b883 100644 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -10,14 +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" diff --git a/lld/ELF/Memory.h b/lld/include/lld/Support/Memory.h similarity index 96% rename from lld/ELF/Memory.h rename to lld/include/lld/Support/Memory.h index 9479fd0..1ed5ec9 100644 --- a/lld/ELF/Memory.h +++ b/lld/include/lld/Support/Memory.h @@ -19,15 +19,14 @@ // //===----------------------------------------------------------------------===// -#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 namespace lld { -namespace elf { // Use this arena if your object doesn't have a destructor. extern llvm::BumpPtrAllocator BAlloc; @@ -56,6 +55,5 @@ template inline T *make(U &&... Args) { void freeArena(); } -} #endif diff --git a/lld/lib/CMakeLists.txt b/lld/lib/CMakeLists.txt index 699f5e9..acd5322 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 0000000..18dccdb --- /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/ELF/Memory.cpp b/lld/lib/Support/Memory.cpp similarity index 79% rename from lld/ELF/Memory.cpp rename to lld/lib/Support/Memory.cpp index 7771317..9bdcdcc 100644 --- a/lld/ELF/Memory.cpp +++ b/lld/lib/Support/Memory.cpp @@ -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::Instances; -void elf::freeArena() { +void freeArena() { for (SpecificAllocBase *Alloc : SpecificAllocBase::Instances) Alloc->reset(); BAlloc.Reset();