<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Dec 9, 2016 at 10:51 AM, Rui Ueyama <span dir="ltr"><<a href="mailto:ruiu@google.com" target="_blank">ruiu@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span class="">On Thu, Dec 8, 2016 at 11:06 PM, Sean Silva <span dir="ltr"><<a href="mailto:chisophugis@gmail.com" target="_blank">chisophugis@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote"><span>On Thu, Dec 8, 2016 at 10:00 PM, Rui Ueyama <span dir="ltr"><<a href="mailto:ruiu@google.com" target="_blank">ruiu@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">LLD ELF can be used as a library, but it is as a whole a single monolithic linker. So is COFF linker. I put this file and make it a "library" to share code between ports, but no one except the two will use it.</div></blockquote><div><br></div></span><div><div>Code in the typical include,lib LLVM arrangement is expected to have certain library-like guarantees. It is really confusing to all LLVM developers to have this kind of mutable globals in there.</div></div><span><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"> I'm fine to retract this and instead copy-n-paste this code for now, but we need to fix the directory and library structure to match the reality. It is silly if we cannot code between COFF and ELF.</div></blockquote><div><br></div></span><div><div>While I agree that we want to be able to share *code* between COFF and ELF, I really really don't like for them to share mutable global state through a "library". Like I said, the entire justification for using globals was that LLD was a "program" and not a "library". If we want to share the code we need to do it in a way that clearly marks it as "not a library" (perhaps through directory naming and organization choices).</div></div><div><br></div><div>I think that rearranging the directory structure or something might be able to help, but overall we need more discussion among the LLD developers before resorting to sharing mutable globals between COFF and ELF.. Putting random mutable state in shared code is a recipe for disaster. We need to be careful.</div></div></div></div></blockquote><div><br></div></span><div>The common code is not really a library, and the concern of sharing state is a hypothesis that doesn't take the reality into account. At the end of COFF linker, we always exit, so you can only use it as a non-return function. On the other hand, sharing code apparently benefit us.</div><div><br></div><div>So the problem is the LLD's directory structure. It's organized like LLVM or Clang, but it should be organized more like other tools in `tools` directory. We probably should put `lld.cpp` file, which contains the main function, on the top-level directory instead of `tools/lld` inside LLD. Other files that are shared between COFF and ELF should also be put into the top directory.</div></div></div></div></blockquote><div><br></div><div>That makes sense to me. To be clear, the main thing I'm opposed to is making something that seems like it is a "library" (in the LLVM sense) which actually is not.</div><div><br></div><div>-- Sean Silva</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span class=""><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><br></div><div>At least for the moment, full copy-paste should not be necessary. All that should be needed is a special `make` function that passes a pointer/reference to a program-specific global to the constructor of the static object.</div><div>I.e. ELF would have something like:</div><div>```</div><div><span><div>template <typename T, typename... U> inline T *make(U &&... Args) {</div></span><div> static SpecificAlloc<T> Alloc(elf::AllocatorInstances)<wbr>;</div><span><div> return new (Alloc.Alloc.Allocate()) T(std::forward<U>(Args)...);</div><div>}</div></span></div><div>```</div><div><br></div><div>And then e.g. the call to freeArena would be: `<span style="font-size:12.8px">freeArena(elf::AllocatorInsta<wbr>nces)`. (also freeArena is a poor name for this function; it does not free an arena; it iterates over a list of arena allocators freeing them individually; maybe freeArenaAllocators?)</span></div></div></div></div></blockquote><div><br></div></span><div>I don't see a benefit of doing it, although it might be a bit clear than what we are doing now.</div><div><div class="h5"><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><div class="m_4267569217605652006h5"><div><br></div><div>-- Sean Silva</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><div class="m_4267569217605652006m_2116982124393476706gmail-h5"><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Dec 8, 2016 at 9:48 PM, Sean Silva <span dir="ltr"><<a href="mailto:chisophugis@gmail.com" target="_blank">chisophugis@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Please revert this for now. The use of globals in LLD has been acceptable on the premise that these variables are in the "LLD is a program, not a library" part of LLD. Putting globals in a library is another matter and should not be done lightly.<span class="m_4267569217605652006m_2116982124393476706gmail-m_-8527722654444900257m_4662250962169156980HOEnZb"><font color="#888888"><div><br></div><div>-- Sean Silva</div></font></span></div><div class="m_4267569217605652006m_2116982124393476706gmail-m_-8527722654444900257m_4662250962169156980HOEnZb"><div class="m_4267569217605652006m_2116982124393476706gmail-m_-8527722654444900257m_4662250962169156980h5"><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Dec 8, 2016 at 10:31 AM, Rui Ueyama via llvm-commits <span dir="ltr"><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Author: ruiu<br>
Date: Thu Dec 8 12:31:13 2016<br>
New Revision: 289084<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=289084&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject?rev=289084&view=rev</a><br>
Log:<br>
Move Memory.{h,cpp} to lld/Support so that we can use them from COFF.<br>
<br>
Added:<br>
lld/trunk/include/lld/Support/<br>
lld/trunk/include/lld/Support/<wbr>Memory.h<br>
- copied, changed from r289082, lld/trunk/ELF/Memory.h<br>
lld/trunk/lib/Support/<br>
lld/trunk/lib/Support/CMakeLis<wbr>ts.txt<br>
lld/trunk/lib/Support/Memory.c<wbr>pp<br>
- copied, changed from r289082, lld/trunk/ELF/Memory.cpp<br>
Removed:<br>
lld/trunk/ELF/Memory.cpp<br>
lld/trunk/ELF/Memory.h<br>
Modified:<br>
lld/trunk/ELF/CMakeLists.txt<br>
lld/trunk/ELF/Driver.cpp<br>
lld/trunk/ELF/DriverUtils.cpp<br>
lld/trunk/ELF/InputFiles.cpp<br>
lld/trunk/ELF/InputSection.cpp<br>
lld/trunk/ELF/LinkerScript.cpp<br>
lld/trunk/ELF/OutputSections.c<wbr>pp<br>
lld/trunk/ELF/SymbolTable.cpp<br>
lld/trunk/ELF/SyntheticSection<wbr>s.cpp<br>
lld/trunk/ELF/Target.cpp<br>
lld/trunk/ELF/Thunks.cpp<br>
lld/trunk/ELF/Writer.cpp<br>
lld/trunk/lib/CMakeLists.txt<br>
<br>
Modified: lld/trunk/ELF/CMakeLists.txt<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/CMakeLists.txt?rev=289084&r1=289083&r2=289084&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/lld/trunk/ELF/CMakeLists<wbr>.txt?rev=289084&r1=289083&r2=2<wbr>89084&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- lld/trunk/ELF/CMakeLists.txt (original)<br>
+++ lld/trunk/ELF/CMakeLists.txt Thu Dec 8 12:31:13 2016<br>
@@ -14,7 +14,6 @@ add_lld_library(lldELF<br>
LTO.cpp<br>
LinkerScript.cpp<br>
MarkLive.cpp<br>
- Memory.cpp<br>
Mips.cpp<br>
OutputSections.cpp<br>
Relocations.cpp<br>
@@ -50,6 +49,7 @@ add_lld_library(lldELF<br>
LINK_LIBS<br>
lldConfig<br>
lldCore<br>
+ lldSupport<br>
${PTHREAD_LIB}<br>
<br>
DEPENDS<br>
<br>
Modified: lld/trunk/ELF/Driver.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Driver.cpp?rev=289084&r1=289083&r2=289084&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/lld/trunk/ELF/Driver.cpp<wbr>?rev=289084&r1=289083&r2=28908<wbr>4&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- lld/trunk/ELF/Driver.cpp (original)<br>
+++ lld/trunk/ELF/Driver.cpp Thu Dec 8 12:31:13 2016<br>
@@ -14,7 +14,6 @@<br>
#include "InputFiles.h"<br>
#include "InputSection.h"<br>
#include "LinkerScript.h"<br>
-#include "Memory.h"<br>
#include "Strings.h"<br>
#include "SymbolTable.h"<br>
#include "Target.h"<br>
@@ -22,6 +21,7 @@<br>
#include "Writer.h"<br>
#include "lld/Config/Version.h"<br>
#include "lld/Driver/Driver.h"<br>
+#include "lld/Support/Memory.h"<br>
#include "llvm/ADT/StringExtras.h"<br>
#include "llvm/ADT/StringSwitch.h"<br>
#include "llvm/Support/CommandLine.h"<br>
<br>
Modified: lld/trunk/ELF/DriverUtils.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/DriverUtils.cpp?rev=289084&r1=289083&r2=289084&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/lld/trunk/ELF/DriverUtil<wbr>s.cpp?rev=289084&r1=289083&r2=<wbr>289084&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- lld/trunk/ELF/DriverUtils.cpp (original)<br>
+++ lld/trunk/ELF/DriverUtils.cpp Thu Dec 8 12:31:13 2016<br>
@@ -15,10 +15,10 @@<br>
<br>
#include "Driver.h"<br>
#include "Error.h"<br>
-#include "Memory.h"<br>
#include "ScriptParser.h"<br>
#include "lld/Config/Version.h"<br>
#include "lld/Core/Reproduce.h"<br>
+#include "lld/Support/Memory.h"<br>
#include "llvm/ADT/Optional.h"<br>
#include "llvm/ADT/STLExtras.h"<br>
#include "llvm/ADT/Triple.h"<br>
<br>
Modified: lld/trunk/ELF/InputFiles.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputFiles.cpp?rev=289084&r1=289083&r2=289084&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/lld/trunk/ELF/InputFiles<wbr>.cpp?rev=289084&r1=289083&r2=2<wbr>89084&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- lld/trunk/ELF/InputFiles.cpp (original)<br>
+++ lld/trunk/ELF/InputFiles.cpp Thu Dec 8 12:31:13 2016<br>
@@ -12,9 +12,9 @@<br>
#include "Error.h"<br>
#include "InputSection.h"<br>
#include "LinkerScript.h"<br>
-#include "Memory.h"<br>
#include "SymbolTable.h"<br>
#include "Symbols.h"<br>
+#include "lld/Support/Memory.h"<br>
#include "llvm/ADT/STLExtras.h"<br>
#include "llvm/Bitcode/BitcodeReader.h"<br>
#include "llvm/CodeGen/Analysis.h"<br>
<br>
Modified: lld/trunk/ELF/InputSection.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputSection.cpp?rev=289084&r1=289083&r2=289084&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/lld/trunk/ELF/InputSecti<wbr>on.cpp?rev=289084&r1=289083&r2<wbr>=289084&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- lld/trunk/ELF/InputSection.cpp (original)<br>
+++ lld/trunk/ELF/InputSection.cpp Thu Dec 8 12:31:13 2016<br>
@@ -13,13 +13,12 @@<br>
#include "Error.h"<br>
#include "InputFiles.h"<br>
#include "LinkerScript.h"<br>
-#include "Memory.h"<br>
#include "OutputSections.h"<br>
#include "Relocations.h"<br>
#include "SyntheticSections.h"<br>
#include "Target.h"<br>
#include "Thunks.h"<br>
-<br>
+#include "lld/Support/Memory.h"<br>
#include "llvm/Support/Compression.h"<br>
#include "llvm/Support/Endian.h"<br>
#include <mutex><br>
<br>
Modified: lld/trunk/ELF/LinkerScript.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LinkerScript.cpp?rev=289084&r1=289083&r2=289084&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/lld/trunk/ELF/LinkerScri<wbr>pt.cpp?rev=289084&r1=289083&r2<wbr>=289084&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- lld/trunk/ELF/LinkerScript.cpp (original)<br>
+++ lld/trunk/ELF/LinkerScript.cpp Thu Dec 8 12:31:13 2016<br>
@@ -15,7 +15,6 @@<br>
#include "Config.h"<br>
#include "Driver.h"<br>
#include "InputSection.h"<br>
-#include "Memory.h"<br>
#include "OutputSections.h"<br>
#include "ScriptParser.h"<br>
#include "Strings.h"<br>
@@ -24,6 +23,7 @@<br>
#include "SyntheticSections.h"<br>
#include "Target.h"<br>
#include "Writer.h"<br>
+#include "lld/Support/Memory.h"<br>
#include "llvm/ADT/STLExtras.h"<br>
#include "llvm/ADT/SmallString.h"<br>
#include "llvm/ADT/StringRef.h"<br>
<br>
Removed: lld/trunk/ELF/Memory.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Memory.cpp?rev=289083&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/lld/trunk/ELF/Memory.cpp<wbr>?rev=289083&view=auto</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- lld/trunk/ELF/Memory.cpp (original)<br>
+++ lld/trunk/ELF/Memory.cpp (removed)<br>
@@ -1,29 +0,0 @@<br>
-//===- Memory.cpp ------------------------------<wbr>-----------------*- C++ -*-===//<br>
-//<br>
-// The LLVM Linker<br>
-//<br>
-// This file is distributed under the University of Illinois Open Source<br>
-// License. See LICENSE.TXT for details.<br>
-//<br>
-//===------------------------<wbr>------------------------------<wbr>----------------===//<br>
-<br>
-#include "Memory.h"<br>
-<br>
-using namespace llvm;<br>
-using namespace lld;<br>
-using namespace lld::elf;<br>
-<br>
-namespace lld {<br>
-BumpPtrAllocator elf::BAlloc;<br>
-StringSaver elf::Saver{elf::BAlloc};<br>
-<br>
-SpecificAllocBase::SpecificAl<wbr>locBase() { Instances.push_back(this); }<br>
-<br>
-std::vector<SpecificAllocBase *> SpecificAllocBase::Instances;<br>
-<br>
-void elf::freeArena() {<br>
- for (SpecificAllocBase *Alloc : SpecificAllocBase::Instances)<br>
- Alloc->reset();<br>
- BAlloc.Reset();<br>
-}<br>
-}<br>
<br>
Removed: lld/trunk/ELF/Memory.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Memory.h?rev=289083&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/lld/trunk/ELF/Memory.h?r<wbr>ev=289083&view=auto</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- lld/trunk/ELF/Memory.h (original)<br>
+++ lld/trunk/ELF/Memory.h (removed)<br>
@@ -1,61 +0,0 @@<br>
-//===- Memory.h ------------------------------<wbr>-------------------*- C++ -*-===//<br>
-//<br>
-// The LLVM Linker<br>
-//<br>
-// This file is distributed under the University of Illinois Open Source<br>
-// License. See LICENSE.TXT for details.<br>
-//<br>
-//===------------------------<wbr>------------------------------<wbr>----------------===//<br>
-//<br>
-// This file defines arena allocators.<br>
-//<br>
-// Almost all large objects, such as files, sections or symbols, are<br>
-// used for the entire lifetime of the linker once they are created.<br>
-// This usage characteristic makes arena allocator an attractive choice<br>
-// where the entire linker is one arena. With an arena, newly created<br>
-// objects belong to the arena and freed all at once when everything is done.<br>
-// Arena allocators are efficient and easy to understand.<br>
-// Most objects are allocated using the arena allocators defined by this file.<br>
-//<br>
-//===------------------------<wbr>------------------------------<wbr>----------------===//<br>
-<br>
-#ifndef LLD_ELF_MEMORY_H<br>
-#define LLD_ELF_MEMORY_H<br>
-<br>
-#include "llvm/Support/Allocator.h"<br>
-#include "llvm/Support/StringSaver.h"<br>
-#include <vector><br>
-<br>
-namespace lld {<br>
-namespace elf {<br>
-<br>
-// Use this arena if your object doesn't have a destructor.<br>
-extern llvm::BumpPtrAllocator BAlloc;<br>
-extern llvm::StringSaver Saver;<br>
-<br>
-// These two classes are hack to keep track of all<br>
-// SpecificBumpPtrAllocator instances.<br>
-struct SpecificAllocBase {<br>
- SpecificAllocBase();<br>
- virtual ~SpecificAllocBase() = default;<br>
- virtual void reset() = 0;<br>
- static std::vector<SpecificAllocBase *> Instances;<br>
-};<br>
-<br>
-template <class T> struct SpecificAlloc : public SpecificAllocBase {<br>
- void reset() override { Alloc.DestroyAll(); }<br>
- llvm::SpecificBumpPtrAllocator<wbr><T> Alloc;<br>
-};<br>
-<br>
-// Use this arena if your object has a destructor.<br>
-// Your destructor will be invoked from freeArena().<br>
-template <typename T, typename... U> inline T *make(U &&... Args) {<br>
- static SpecificAlloc<T> Alloc;<br>
- return new (Alloc.Alloc.Allocate()) T(std::forward<U>(Args)...);<br>
-}<br>
-<br>
-void freeArena();<br>
-}<br>
-}<br>
-<br>
-#endif<br>
<br>
Modified: lld/trunk/ELF/OutputSections.c<wbr>pp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.cpp?rev=289084&r1=289083&r2=289084&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/lld/trunk/ELF/OutputSect<wbr>ions.cpp?rev=289084&r1=289083&<wbr>r2=289084&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- lld/trunk/ELF/OutputSections.c<wbr>pp (original)<br>
+++ lld/trunk/ELF/OutputSections.c<wbr>pp Thu Dec 8 12:31:13 2016<br>
@@ -11,12 +11,12 @@<br>
#include "Config.h"<br>
#include "EhFrame.h"<br>
#include "LinkerScript.h"<br>
-#include "Memory.h"<br>
#include "Strings.h"<br>
#include "SymbolTable.h"<br>
#include "SyntheticSections.h"<br>
#include "Target.h"<br>
#include "Threads.h"<br>
+#include "lld/Support/Memory.h"<br>
#include "llvm/Support/Dwarf.h"<br>
#include "llvm/Support/MD5.h"<br>
#include "llvm/Support/MathExtras.h"<br>
<br>
Modified: lld/trunk/ELF/SymbolTable.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SymbolTable.cpp?rev=289084&r1=289083&r2=289084&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/lld/trunk/ELF/SymbolTabl<wbr>e.cpp?rev=289084&r1=289083&r2=<wbr>289084&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- lld/trunk/ELF/SymbolTable.cpp (original)<br>
+++ lld/trunk/ELF/SymbolTable.cpp Thu Dec 8 12:31:13 2016<br>
@@ -18,8 +18,8 @@<br>
#include "Config.h"<br>
#include "Error.h"<br>
#include "LinkerScript.h"<br>
-#include "Memory.h"<br>
#include "Symbols.h"<br>
+#include "lld/Support/Memory.h"<br>
#include "llvm/ADT/STLExtras.h"<br>
<br>
using namespace llvm;<br>
<br>
Modified: lld/trunk/ELF/SyntheticSection<wbr>s.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SyntheticSections.cpp?rev=289084&r1=289083&r2=289084&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/lld/trunk/ELF/SyntheticS<wbr>ections.cpp?rev=289084&r1=2890<wbr>83&r2=289084&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- lld/trunk/ELF/SyntheticSection<wbr>s.cpp (original)<br>
+++ lld/trunk/ELF/SyntheticSection<wbr>s.cpp Thu Dec 8 12:31:13 2016<br>
@@ -19,15 +19,14 @@<br>
#include "Error.h"<br>
#include "InputFiles.h"<br>
#include "LinkerScript.h"<br>
-#include "Memory.h"<br>
#include "OutputSections.h"<br>
#include "Strings.h"<br>
#include "SymbolTable.h"<br>
#include "Target.h"<br>
#include "Threads.h"<br>
#include "Writer.h"<br>
-<br>
#include "lld/Config/Version.h"<br>
+#include "lld/Support/Memory.h"<br>
#include "llvm/Support/Dwarf.h"<br>
#include "llvm/Support/Endian.h"<br>
#include "llvm/Support/MD5.h"<br>
<br>
Modified: lld/trunk/ELF/Target.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.cpp?rev=289084&r1=289083&r2=289084&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/lld/trunk/ELF/Target.cpp<wbr>?rev=289084&r1=289083&r2=28908<wbr>4&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- lld/trunk/ELF/Target.cpp (original)<br>
+++ lld/trunk/ELF/Target.cpp Thu Dec 8 12:31:13 2016<br>
@@ -27,17 +27,16 @@<br>
#include "Target.h"<br>
#include "Error.h"<br>
#include "InputFiles.h"<br>
-#include "Memory.h"<br>
#include "OutputSections.h"<br>
#include "Symbols.h"<br>
#include "SyntheticSections.h"<br>
#include "Thunks.h"<br>
#include "Writer.h"<br>
-<br>
+#include "lld/Support/Memory.h"<br>
#include "llvm/ADT/ArrayRef.h"<br>
#include "llvm/Object/ELF.h"<br>
-#include "llvm/Support/Endian.h"<br>
#include "llvm/Support/ELF.h"<br>
+#include "llvm/Support/Endian.h"<br>
<br>
using namespace llvm;<br>
using namespace llvm::object;<br>
<br>
Modified: lld/trunk/ELF/Thunks.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Thunks.cpp?rev=289084&r1=289083&r2=289084&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/lld/trunk/ELF/Thunks.cpp<wbr>?rev=289084&r1=289083&r2=28908<wbr>4&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- lld/trunk/ELF/Thunks.cpp (original)<br>
+++ lld/trunk/ELF/Thunks.cpp Thu Dec 8 12:31:13 2016<br>
@@ -25,10 +25,10 @@<br>
#include "Config.h"<br>
#include "Error.h"<br>
#include "InputSection.h"<br>
-#include "Memory.h"<br>
#include "OutputSections.h"<br>
#include "Symbols.h"<br>
#include "Target.h"<br>
+#include "lld/Support/Memory.h"<br>
#include "llvm/Support/Casting.h"<br>
#include "llvm/Support/ELF.h"<br>
#include "llvm/Support/Endian.h"<br>
<br>
Modified: lld/trunk/ELF/Writer.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=289084&r1=289083&r2=289084&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/lld/trunk/ELF/Writer.cpp<wbr>?rev=289084&r1=289083&r2=28908<wbr>4&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- lld/trunk/ELF/Writer.cpp (original)<br>
+++ lld/trunk/ELF/Writer.cpp Thu Dec 8 12:31:13 2016<br>
@@ -10,14 +10,13 @@<br>
#include "Writer.h"<br>
#include "Config.h"<br>
#include "LinkerScript.h"<br>
-#include "Memory.h"<br>
#include "OutputSections.h"<br>
#include "Relocations.h"<br>
#include "Strings.h"<br>
#include "SymbolTable.h"<br>
#include "SyntheticSections.h"<br>
#include "Target.h"<br>
-<br>
+#include "lld/Support/Memory.h"<br>
#include "llvm/ADT/StringMap.h"<br>
#include "llvm/ADT/StringSwitch.h"<br>
#include "llvm/Support/FileOutputBuffer<wbr>.h"<br>
<br>
Copied: lld/trunk/include/lld/Support/<wbr>Memory.h (from r289082, lld/trunk/ELF/Memory.h)<br>
URL: <a href="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" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/lld/trunk/include/lld/Su<wbr>pport/Memory.h?p2=lld/trunk/in<wbr>clude/lld/Support/Memory.h&p1=<wbr>lld/trunk/ELF/Memory.h&r1=2890<wbr>82&r2=289084&rev=289084&view=d<wbr>iff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- lld/trunk/ELF/Memory.h (original)<br>
+++ lld/trunk/include/lld/Support/<wbr>Memory.h Thu Dec 8 12:31:13 2016<br>
@@ -19,15 +19,14 @@<br>
//<br>
//===------------------------<wbr>------------------------------<wbr>----------------===//<br>
<br>
-#ifndef LLD_ELF_MEMORY_H<br>
-#define LLD_ELF_MEMORY_H<br>
+#ifndef LLD_MEMORY_H<br>
+#define LLD_MEMORY_H<br>
<br>
#include "llvm/Support/Allocator.h"<br>
#include "llvm/Support/StringSaver.h"<br>
#include <vector><br>
<br>
namespace lld {<br>
-namespace elf {<br>
<br>
// Use this arena if your object doesn't have a destructor.<br>
extern llvm::BumpPtrAllocator BAlloc;<br>
@@ -56,6 +55,5 @@ template <typename T, typename... U> inl<br>
<br>
void freeArena();<br>
}<br>
-}<br>
<br>
#endif<br>
<br>
Modified: lld/trunk/lib/CMakeLists.txt<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/lib/CMakeLists.txt?rev=289084&r1=289083&r2=289084&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/lld/trunk/lib/CMakeLists<wbr>.txt?rev=289084&r1=289083&r2=2<wbr>89084&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- lld/trunk/lib/CMakeLists.txt (original)<br>
+++ lld/trunk/lib/CMakeLists.txt Thu Dec 8 12:31:13 2016<br>
@@ -2,3 +2,4 @@ add_subdirectory(Config)<br>
add_subdirectory(Core)<br>
add_subdirectory(Driver)<br>
add_subdirectory(ReaderWriter<wbr>)<br>
+add_subdirectory(Support)<br>
<br>
Added: lld/trunk/lib/Support/CMakeLis<wbr>ts.txt<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Support/CMakeLists.txt?rev=289084&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/lld/trunk/lib/Support/CM<wbr>akeLists.txt?rev=289084&view=a<wbr>uto</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- lld/trunk/lib/Support/CMakeLis<wbr>ts.txt (added)<br>
+++ lld/trunk/lib/Support/CMakeLis<wbr>ts.txt Thu Dec 8 12:31:13 2016<br>
@@ -0,0 +1,9 @@<br>
+add_lld_library(lldSupport<br>
+ Memory.cpp<br>
+<br>
+ ADDITIONAL_HEADER_DIRS<br>
+ ${LLD_INCLUDE_DIR}/lld/Support<br>
+<br>
+ LINK_LIBS<br>
+ LLVMSupport<br>
+)<br>
<br>
Copied: lld/trunk/lib/Support/Memory.c<wbr>pp (from r289082, lld/trunk/ELF/Memory.cpp)<br>
URL: <a href="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" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/lld/trunk/lib/Support/Me<wbr>mory.cpp?p2=lld/trunk/lib/Supp<wbr>ort/Memory.cpp&p1=lld/trunk/EL<wbr>F/Memory.cpp&r1=289082&r2=2890<wbr>84&rev=289084&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- lld/trunk/ELF/Memory.cpp (original)<br>
+++ lld/trunk/lib/Support/Memory.c<wbr>pp Thu Dec 8 12:31:13 2016<br>
@@ -7,21 +7,19 @@<br>
//<br>
//===------------------------<wbr>------------------------------<wbr>----------------===//<br>
<br>
-#include "Memory.h"<br>
+#include "lld/Support/Memory.h"<br>
<br>
using namespace llvm;<br>
-using namespace lld;<br>
-using namespace lld::elf;<br>
<br>
namespace lld {<br>
-BumpPtrAllocator elf::BAlloc;<br>
-StringSaver elf::Saver{elf::BAlloc};<br>
+BumpPtrAllocator BAlloc;<br>
+StringSaver Saver{BAlloc};<br>
<br>
SpecificAllocBase::SpecificAl<wbr>locBase() { Instances.push_back(this); }<br>
<br>
std::vector<SpecificAllocBase *> SpecificAllocBase::Instances;<br>
<br>
-void elf::freeArena() {<br>
+void freeArena() {<br>
for (SpecificAllocBase *Alloc : SpecificAllocBase::Instances)<br>
Alloc->reset();<br>
BAlloc.Reset();<br>
<br>
<br>
______________________________<wbr>_________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div></div></div></div>
</blockquote></div></div></div><br></div></div>
</blockquote></div></div></div><br></div></div>
</blockquote></div><br></div></div>