[lld] r289084 - Move Memory.{h, cpp} to lld/Support so that we can use them from COFF.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 8 10:31:14 PST 2016
Author: ruiu
Date: Thu Dec 8 12:31:13 2016
New Revision: 289084
URL: http://llvm.org/viewvc/llvm-project?rev=289084&view=rev
Log:
Move Memory.{h,cpp} to lld/Support so that we can use them from COFF.
Added:
lld/trunk/include/lld/Support/
lld/trunk/include/lld/Support/Memory.h
- copied, changed from r289082, lld/trunk/ELF/Memory.h
lld/trunk/lib/Support/
lld/trunk/lib/Support/CMakeLists.txt
lld/trunk/lib/Support/Memory.cpp
- copied, changed from r289082, lld/trunk/ELF/Memory.cpp
Removed:
lld/trunk/ELF/Memory.cpp
lld/trunk/ELF/Memory.h
Modified:
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/lib/CMakeLists.txt
Modified: lld/trunk/ELF/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/CMakeLists.txt?rev=289084&r1=289083&r2=289084&view=diff
==============================================================================
--- lld/trunk/ELF/CMakeLists.txt (original)
+++ lld/trunk/ELF/CMakeLists.txt Thu Dec 8 12:31:13 2016
@@ -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
Modified: lld/trunk/ELF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Driver.cpp?rev=289084&r1=289083&r2=289084&view=diff
==============================================================================
--- lld/trunk/ELF/Driver.cpp (original)
+++ lld/trunk/ELF/Driver.cpp Thu Dec 8 12:31:13 2016
@@ -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"
Modified: lld/trunk/ELF/DriverUtils.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/DriverUtils.cpp?rev=289084&r1=289083&r2=289084&view=diff
==============================================================================
--- lld/trunk/ELF/DriverUtils.cpp (original)
+++ lld/trunk/ELF/DriverUtils.cpp Thu Dec 8 12:31:13 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=289084&r1=289083&r2=289084&view=diff
==============================================================================
--- lld/trunk/ELF/InputFiles.cpp (original)
+++ lld/trunk/ELF/InputFiles.cpp Thu Dec 8 12:31:13 2016
@@ -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"
Modified: lld/trunk/ELF/InputSection.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputSection.cpp?rev=289084&r1=289083&r2=289084&view=diff
==============================================================================
--- lld/trunk/ELF/InputSection.cpp (original)
+++ lld/trunk/ELF/InputSection.cpp Thu Dec 8 12:31:13 2016
@@ -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 <mutex>
Modified: lld/trunk/ELF/LinkerScript.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LinkerScript.cpp?rev=289084&r1=289083&r2=289084&view=diff
==============================================================================
--- lld/trunk/ELF/LinkerScript.cpp (original)
+++ lld/trunk/ELF/LinkerScript.cpp Thu Dec 8 12:31:13 2016
@@ -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"
Removed: lld/trunk/ELF/Memory.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Memory.cpp?rev=289083&view=auto
==============================================================================
--- lld/trunk/ELF/Memory.cpp (original)
+++ lld/trunk/ELF/Memory.cpp (removed)
@@ -1,29 +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 "Memory.h"
-
-using namespace llvm;
-using namespace lld;
-using namespace lld::elf;
-
-namespace lld {
-BumpPtrAllocator elf::BAlloc;
-StringSaver elf::Saver{elf::BAlloc};
-
-SpecificAllocBase::SpecificAllocBase() { Instances.push_back(this); }
-
-std::vector<SpecificAllocBase *> SpecificAllocBase::Instances;
-
-void elf::freeArena() {
- for (SpecificAllocBase *Alloc : SpecificAllocBase::Instances)
- Alloc->reset();
- BAlloc.Reset();
-}
-}
Removed: lld/trunk/ELF/Memory.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Memory.h?rev=289083&view=auto
==============================================================================
--- lld/trunk/ELF/Memory.h (original)
+++ lld/trunk/ELF/Memory.h (removed)
@@ -1,61 +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_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;
-extern llvm::StringSaver Saver;
-
-// These two classes are hack to keep track of all
-// SpecificBumpPtrAllocator instances.
-struct SpecificAllocBase {
- SpecificAllocBase();
- 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)...);
-}
-
-void freeArena();
-}
-}
-
-#endif
Modified: lld/trunk/ELF/OutputSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.cpp?rev=289084&r1=289083&r2=289084&view=diff
==============================================================================
--- lld/trunk/ELF/OutputSections.cpp (original)
+++ lld/trunk/ELF/OutputSections.cpp Thu Dec 8 12:31:13 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=289084&r1=289083&r2=289084&view=diff
==============================================================================
--- lld/trunk/ELF/SymbolTable.cpp (original)
+++ lld/trunk/ELF/SymbolTable.cpp Thu Dec 8 12:31:13 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=289084&r1=289083&r2=289084&view=diff
==============================================================================
--- lld/trunk/ELF/SyntheticSections.cpp (original)
+++ lld/trunk/ELF/SyntheticSections.cpp Thu Dec 8 12:31:13 2016
@@ -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"
Modified: lld/trunk/ELF/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.cpp?rev=289084&r1=289083&r2=289084&view=diff
==============================================================================
--- lld/trunk/ELF/Target.cpp (original)
+++ lld/trunk/ELF/Target.cpp Thu Dec 8 12:31:13 2016
@@ -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;
Modified: lld/trunk/ELF/Thunks.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Thunks.cpp?rev=289084&r1=289083&r2=289084&view=diff
==============================================================================
--- lld/trunk/ELF/Thunks.cpp (original)
+++ lld/trunk/ELF/Thunks.cpp Thu Dec 8 12:31:13 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=289084&r1=289083&r2=289084&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Thu Dec 8 12:31:13 2016
@@ -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"
Copied: lld/trunk/include/lld/Support/Memory.h (from r289082, lld/trunk/ELF/Memory.h)
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Support/Memory.h?p2=lld/trunk/include/lld/Support/Memory.h&p1=lld/trunk/ELF/Memory.h&r1=289082&r2=289084&rev=289084&view=diff
==============================================================================
--- lld/trunk/ELF/Memory.h (original)
+++ lld/trunk/include/lld/Support/Memory.h Thu Dec 8 12:31:13 2016
@@ -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 <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> inl
void freeArena();
}
-}
#endif
Modified: lld/trunk/lib/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/CMakeLists.txt?rev=289084&r1=289083&r2=289084&view=diff
==============================================================================
--- lld/trunk/lib/CMakeLists.txt (original)
+++ lld/trunk/lib/CMakeLists.txt Thu Dec 8 12:31:13 2016
@@ -2,3 +2,4 @@ add_subdirectory(Config)
add_subdirectory(Core)
add_subdirectory(Driver)
add_subdirectory(ReaderWriter)
+add_subdirectory(Support)
Added: lld/trunk/lib/Support/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Support/CMakeLists.txt?rev=289084&view=auto
==============================================================================
--- lld/trunk/lib/Support/CMakeLists.txt (added)
+++ lld/trunk/lib/Support/CMakeLists.txt Thu Dec 8 12:31:13 2016
@@ -0,0 +1,9 @@
+add_lld_library(lldSupport
+ Memory.cpp
+
+ ADDITIONAL_HEADER_DIRS
+ ${LLD_INCLUDE_DIR}/lld/Support
+
+ LINK_LIBS
+ LLVMSupport
+)
Copied: lld/trunk/lib/Support/Memory.cpp (from r289082, lld/trunk/ELF/Memory.cpp)
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Support/Memory.cpp?p2=lld/trunk/lib/Support/Memory.cpp&p1=lld/trunk/ELF/Memory.cpp&r1=289082&r2=289084&rev=289084&view=diff
==============================================================================
--- lld/trunk/ELF/Memory.cpp (original)
+++ lld/trunk/lib/Support/Memory.cpp Thu Dec 8 12:31:13 2016
@@ -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();
More information about the llvm-commits
mailing list