<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Dec 12, 2016, at 9:41 PM, Sean Silva <<a href="mailto:chisophugis@gmail.com" class="">chisophugis@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><br class=""><div class="gmail_extra"><br class=""><div class="gmail_quote">On Mon, Dec 12, 2016 at 10:46 AM, Chris Bieneman <span dir="ltr" class=""><<a href="mailto:beanz@apple.com" target="_blank" class="">beanz@apple.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class="">Can we maybe wrap the globals from Memory.cpp either in a singleton pattern with access functions (preferred) or ManagedStatics?<div class=""><br class=""></div><div class="">Avoiding the static initialization cost is desirable for both libraries and tools.</div></div></blockquote><div class=""><br class=""></div><div class="">I don't think a singleton pattern really helps here. The main issue is that this is not something appropriate for an llvm-style "lib/" subdirectory (whether you put a singleton pattern around it or not). It needs to be more clearly part of COFF/ELF; I think Rui's suggestion of making this a top-level directory alongside COFF and ELF is a good way to achieve that.</div><div class=""><br class=""></div><div class="">I don't really have an issue with static initializers in a "program". </div></div></div></div></div></blockquote><div><br class=""></div><div>I do. Static initializers slow down the launch of the program and using singleton-style lazy initialization ensures that you only run the initializers if you need them. Meaning you don't run all the static initializers in the program just to print the help output. Sadly in LLVM we run a boat load of static initializers just to print help in basically everything LLVM derived.</div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><div class="">The problem with them is when they are in libraries that get linked in, but end up not being needed by the thing linking the library ("pay for what you don't use"), which is not the case here.</div></div></div></div></div></blockquote><div><br class=""></div><div>Global initializers are not "pay for what you use", they are "pay for what you link". Unless all code paths in a tool need the global value it shouldn't be a global.</div><div><br class=""></div><div>-Chris</div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><div class=""><br class=""></div><div class="">-- Sean Silva</div><div class=""> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><span class="HOEnZb"><font color="#888888" class=""><div class=""><br class=""></div><div class="">-Chris</div></font></span><div class=""><div class="h5"><div class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Dec 9, 2016, at 11:14 AM, Rui Ueyama via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org" target="_blank" class="">llvm-commits@lists.llvm.org</a>> wrote:</div><br class="m_3069360725974238290Apple-interchange-newline"><div class=""><div dir="ltr" class="">On second thought, I think we don't want to put `lld.cpp` in the top-level directory because there are people out there who don't want to link that file. That file contains `main` function. If people are using the ELF linker as a library, they want to link just `lld::elf::link` and not `main`.<div class=""><br class=""></div><div class="">I'll try to eliminate the shared variables between ELF and COFF. Will send a code review.</div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Fri, Dec 9, 2016 at 11:04 AM, Rui Ueyama <span dir="ltr" class=""><<a href="mailto:ruiu@google.com" target="_blank" class="">ruiu@google.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><span class="">On Fri, Dec 9, 2016 at 11:02 AM, Sean Silva <span dir="ltr" class=""><<a href="mailto:chisophugis@gmail.com" target="_blank" class="">chisophugis@gmail.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class=""><br class=""><div class="gmail_extra"><br class=""><div class="gmail_quote"><span class="">On Fri, Dec 9, 2016 at 10:59 AM, Sean Silva <span dir="ltr" class=""><<a href="mailto:chisophugis@gmail.com" target="_blank" class="">chisophugis@gmail.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class=""><br class=""><div class="gmail_extra"><br class=""><div class="gmail_quote"><span class="">On Fri, Dec 9, 2016 at 10:51 AM, Rui Ueyama <span dir="ltr" class=""><<a href="mailto:ruiu@google.com" target="_blank" class="">ruiu@google.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><span class="">On Thu, Dec 8, 2016 at 11:06 PM, Sean Silva <span dir="ltr" class=""><<a href="mailto:chisophugis@gmail.com" target="_blank" class="">chisophugis@gmail.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class=""><br class=""><div class="gmail_extra"><br class=""><div class="gmail_quote"><span class="">On Thu, Dec 8, 2016 at 10:00 PM, Rui Ueyama <span dir="ltr" class=""><<a href="mailto:ruiu@google.com" target="_blank" class="">ruiu@google.com</a>></span> wrote:<br class=""><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" class="">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 class=""><br class=""></div></span><div class=""><div class="">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 class=""><div class=""><br class=""></div><div class=""> </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" class=""> 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 class=""><br class=""></div></span><div class=""><div class="">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 class=""><br class=""></div><div class="">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 class=""><br class=""></div></span><div class="">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 class=""><br class=""></div><div class="">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 class=""><br class=""></div></span><div class="">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></div></div></blockquote><div class=""><br class=""></div></span><div class="">Maybe a top-level "ProgramSupport" directory?</div></div></div></div></blockquote><div class=""><br class=""></div></span><div class="">If we have many files, yes, but probably for now the top directory should suffice and probably better.</div><div class=""><div class="m_3069360725974238290m_6515402570817765344h5"><div class=""><br class=""></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><span class="m_3069360725974238290m_6515402570817765344m_4781005601113662361HOEnZb"><font color="#888888" class=""><div class=""><br class=""></div><div class="">-- Sean Silva</div></font></span><div class=""><div class="m_3069360725974238290m_6515402570817765344m_4781005601113662361h5"><div class=""> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><span class="m_3069360725974238290m_6515402570817765344m_4781005601113662361m_-675733283778548838HOEnZb"><font color="#888888" class=""><div class=""><br class=""></div><div class="">-- Sean Silva</div></font></span><div class=""><div class="m_3069360725974238290m_6515402570817765344m_4781005601113662361m_-675733283778548838h5"><div class=""> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><span class=""><div class=""><br class=""></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><div class=""><br class=""></div><div class="">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 class="">I.e. ELF would have something like:</div><div class="">```</div><div class=""><span class=""><div class="">template <typename T, typename... U> inline T *make(U &&... Args) {</div></span><div class="">  static SpecificAlloc<T> Alloc(elf::AllocatorInstances)<wbr class="">;</div><span class=""><div class="">  return new (Alloc.Alloc.Allocate()) T(std::forward<U>(Args)...);</div><div class="">}</div></span></div><div class="">```</div><div class=""><br class=""></div><div class="">And then e.g. the call to freeArena would be: `<span style="font-size:12.8px" class="">freeArena(elf::AllocatorInsta<wbr class="">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 class=""><br class=""></div></span><div class="">I don't see a benefit of doing it, although it might be a bit clear than what we are doing now.</div><div class=""><div class="m_3069360725974238290m_6515402570817765344m_4781005601113662361m_-675733283778548838m_7602586567038364975h5"><div class=""><br class=""></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><div class=""><div class="m_3069360725974238290m_6515402570817765344m_4781005601113662361m_-675733283778548838m_7602586567038364975m_4267569217605652006h5"><div class=""><br class=""></div><div class="">-- Sean Silva</div><div class=""> </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" class=""><div class=""><div class="m_3069360725974238290m_6515402570817765344m_4781005601113662361m_-675733283778548838m_7602586567038364975m_4267569217605652006m_2116982124393476706gmail-h5"><div class="gmail_extra"><br class=""><div class="gmail_quote">On Thu, Dec 8, 2016 at 9:48 PM, Sean Silva <span dir="ltr" class=""><<a href="mailto:chisophugis@gmail.com" target="_blank" class="">chisophugis@gmail.com</a>></span> wrote:<br class=""><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" class="">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_3069360725974238290m_6515402570817765344m_4781005601113662361m_-675733283778548838m_7602586567038364975m_4267569217605652006m_2116982124393476706gmail-m_-8527722654444900257m_4662250962169156980HOEnZb"><font color="#888888" class=""><div class=""><br class=""></div><div class="">-- Sean Silva</div></font></span></div><div class="m_3069360725974238290m_6515402570817765344m_4781005601113662361m_-675733283778548838m_7602586567038364975m_4267569217605652006m_2116982124393476706gmail-m_-8527722654444900257m_4662250962169156980HOEnZb"><div class="m_3069360725974238290m_6515402570817765344m_4781005601113662361m_-675733283778548838m_7602586567038364975m_4267569217605652006m_2116982124393476706gmail-m_-8527722654444900257m_4662250962169156980h5"><div class="gmail_extra"><br class=""><div class="gmail_quote">On Thu, Dec 8, 2016 at 10:31 AM, Rui Ueyama via llvm-commits <span dir="ltr" class=""><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank" class="">llvm-commits@lists.llvm.org</a>></span> wrote:<br class=""><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 class="">
Date: Thu Dec  8 12:31:13 2016<br class="">
New Revision: 289084<br class="">
<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=289084&view=rev" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-pr<wbr class="">oject?rev=289084&view=rev</a><br class="">
Log:<br class="">
Move Memory.{h,cpp} to lld/Support so that we can use them from COFF.<br class="">
<br class="">
Added:<br class="">
    lld/trunk/include/lld/Support/<br class="">
    lld/trunk/include/lld/Support/<wbr class="">Memory.h<br class="">
      - copied, changed from r289082, lld/trunk/ELF/Memory.h<br class="">
    lld/trunk/lib/Support/<br class="">
    lld/trunk/lib/Support/CMakeLis<wbr class="">ts.txt<br class="">
    lld/trunk/lib/Support/Memory.c<wbr class="">pp<br class="">
      - copied, changed from r289082, lld/trunk/ELF/Memory.cpp<br class="">
Removed:<br class="">
    lld/trunk/ELF/Memory.cpp<br class="">
    lld/trunk/ELF/Memory.h<br class="">
Modified:<br class="">
    lld/trunk/ELF/CMakeLists.txt<br class="">
    lld/trunk/ELF/Driver.cpp<br class="">
    lld/trunk/ELF/DriverUtils.cpp<br class="">
    lld/trunk/ELF/InputFiles.cpp<br class="">
    lld/trunk/ELF/InputSection.cpp<br class="">
    lld/trunk/ELF/LinkerScript.cpp<br class="">
    lld/trunk/ELF/OutputSections.c<wbr class="">pp<br class="">
    lld/trunk/ELF/SymbolTable.cpp<br class="">
    lld/trunk/ELF/SyntheticSection<wbr class="">s.cpp<br class="">
    lld/trunk/ELF/Target.cpp<br class="">
    lld/trunk/ELF/Thunks.cpp<br class="">
    lld/trunk/ELF/Writer.cpp<br class="">
    lld/trunk/lib/CMakeLists.txt<br class="">
<br class="">
Modified: lld/trunk/ELF/CMakeLists.txt<br class="">
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" class="">http://llvm.org/viewvc/llvm-pr<wbr class="">oject/lld/trunk/ELF/CMakeLists<wbr class="">.txt?rev=289084&r1=289083&r2=2<wbr class="">89084&view=diff</a><br class="">
==============================<wbr class="">==============================<wbr class="">==================<br class="">
--- lld/trunk/ELF/CMakeLists.txt (original)<br class="">
+++ lld/trunk/ELF/CMakeLists.txt Thu Dec  8 12:31:13 2016<br class="">
@@ -14,7 +14,6 @@ add_lld_library(lldELF<br class="">
   LTO.cpp<br class="">
   LinkerScript.cpp<br class="">
   MarkLive.cpp<br class="">
-  Memory.cpp<br class="">
   Mips.cpp<br class="">
   OutputSections.cpp<br class="">
   Relocations.cpp<br class="">
@@ -50,6 +49,7 @@ add_lld_library(lldELF<br class="">
   LINK_LIBS<br class="">
   lldConfig<br class="">
   lldCore<br class="">
+  lldSupport<br class="">
   ${PTHREAD_LIB}<br class="">
<br class="">
   DEPENDS<br class="">
<br class="">
Modified: lld/trunk/ELF/Driver.cpp<br class="">
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" class="">http://llvm.org/viewvc/llvm-pr<wbr class="">oject/lld/trunk/ELF/Driver.cpp<wbr class="">?rev=289084&r1=289083&r2=28908<wbr class="">4&view=diff</a><br class="">
==============================<wbr class="">==============================<wbr class="">==================<br class="">
--- lld/trunk/ELF/Driver.cpp (original)<br class="">
+++ lld/trunk/ELF/Driver.cpp Thu Dec  8 12:31:13 2016<br class="">
@@ -14,7 +14,6 @@<br class="">
 #include "InputFiles.h"<br class="">
 #include "InputSection.h"<br class="">
 #include "LinkerScript.h"<br class="">
-#include "Memory.h"<br class="">
 #include "Strings.h"<br class="">
 #include "SymbolTable.h"<br class="">
 #include "Target.h"<br class="">
@@ -22,6 +21,7 @@<br class="">
 #include "Writer.h"<br class="">
 #include "lld/Config/Version.h"<br class="">
 #include "lld/Driver/Driver.h"<br class="">
+#include "lld/Support/Memory.h"<br class="">
 #include "llvm/ADT/StringExtras.h"<br class="">
 #include "llvm/ADT/StringSwitch.h"<br class="">
 #include "llvm/Support/CommandLine.h"<br class="">
<br class="">
Modified: lld/trunk/ELF/DriverUtils.cpp<br class="">
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" class="">http://llvm.org/viewvc/llvm-pr<wbr class="">oject/lld/trunk/ELF/DriverUtil<wbr class="">s.cpp?rev=289084&r1=289083&r2=<wbr class="">289084&view=diff</a><br class="">
==============================<wbr class="">==============================<wbr class="">==================<br class="">
--- lld/trunk/ELF/DriverUtils.cpp (original)<br class="">
+++ lld/trunk/ELF/DriverUtils.cpp Thu Dec  8 12:31:13 2016<br class="">
@@ -15,10 +15,10 @@<br class="">
<br class="">
 #include "Driver.h"<br class="">
 #include "Error.h"<br class="">
-#include "Memory.h"<br class="">
 #include "ScriptParser.h"<br class="">
 #include "lld/Config/Version.h"<br class="">
 #include "lld/Core/Reproduce.h"<br class="">
+#include "lld/Support/Memory.h"<br class="">
 #include "llvm/ADT/Optional.h"<br class="">
 #include "llvm/ADT/STLExtras.h"<br class="">
 #include "llvm/ADT/Triple.h"<br class="">
<br class="">
Modified: lld/trunk/ELF/InputFiles.cpp<br class="">
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" class="">http://llvm.org/viewvc/llvm-pr<wbr class="">oject/lld/trunk/ELF/InputFiles<wbr class="">.cpp?rev=289084&r1=289083&r2=2<wbr class="">89084&view=diff</a><br class="">
==============================<wbr class="">==============================<wbr class="">==================<br class="">
--- lld/trunk/ELF/InputFiles.cpp (original)<br class="">
+++ lld/trunk/ELF/InputFiles.cpp Thu Dec  8 12:31:13 2016<br class="">
@@ -12,9 +12,9 @@<br class="">
 #include "Error.h"<br class="">
 #include "InputSection.h"<br class="">
 #include "LinkerScript.h"<br class="">
-#include "Memory.h"<br class="">
 #include "SymbolTable.h"<br class="">
 #include "Symbols.h"<br class="">
+#include "lld/Support/Memory.h"<br class="">
 #include "llvm/ADT/STLExtras.h"<br class="">
 #include "llvm/Bitcode/BitcodeReader.h"<br class="">
 #include "llvm/CodeGen/Analysis.h"<br class="">
<br class="">
Modified: lld/trunk/ELF/InputSection.cpp<br class="">
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" class="">http://llvm.org/viewvc/llvm-pr<wbr class="">oject/lld/trunk/ELF/InputSecti<wbr class="">on.cpp?rev=289084&r1=289083&r2<wbr class="">=289084&view=diff</a><br class="">
==============================<wbr class="">==============================<wbr class="">==================<br class="">
--- lld/trunk/ELF/InputSection.cpp (original)<br class="">
+++ lld/trunk/ELF/InputSection.cpp Thu Dec  8 12:31:13 2016<br class="">
@@ -13,13 +13,12 @@<br class="">
 #include "Error.h"<br class="">
 #include "InputFiles.h"<br class="">
 #include "LinkerScript.h"<br class="">
-#include "Memory.h"<br class="">
 #include "OutputSections.h"<br class="">
 #include "Relocations.h"<br class="">
 #include "SyntheticSections.h"<br class="">
 #include "Target.h"<br class="">
 #include "Thunks.h"<br class="">
-<br class="">
+#include "lld/Support/Memory.h"<br class="">
 #include "llvm/Support/Compression.h"<br class="">
 #include "llvm/Support/Endian.h"<br class="">
 #include <mutex><br class="">
<br class="">
Modified: lld/trunk/ELF/LinkerScript.cpp<br class="">
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" class="">http://llvm.org/viewvc/llvm-pr<wbr class="">oject/lld/trunk/ELF/LinkerScri<wbr class="">pt.cpp?rev=289084&r1=289083&r2<wbr class="">=289084&view=diff</a><br class="">
==============================<wbr class="">==============================<wbr class="">==================<br class="">
--- lld/trunk/ELF/LinkerScript.cpp (original)<br class="">
+++ lld/trunk/ELF/LinkerScript.cpp Thu Dec  8 12:31:13 2016<br class="">
@@ -15,7 +15,6 @@<br class="">
 #include "Config.h"<br class="">
 #include "Driver.h"<br class="">
 #include "InputSection.h"<br class="">
-#include "Memory.h"<br class="">
 #include "OutputSections.h"<br class="">
 #include "ScriptParser.h"<br class="">
 #include "Strings.h"<br class="">
@@ -24,6 +23,7 @@<br class="">
 #include "SyntheticSections.h"<br class="">
 #include "Target.h"<br class="">
 #include "Writer.h"<br class="">
+#include "lld/Support/Memory.h"<br class="">
 #include "llvm/ADT/STLExtras.h"<br class="">
 #include "llvm/ADT/SmallString.h"<br class="">
 #include "llvm/ADT/StringRef.h"<br class="">
<br class="">
Removed: lld/trunk/ELF/Memory.cpp<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Memory.cpp?rev=289083&view=auto" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-pr<wbr class="">oject/lld/trunk/ELF/Memory.cpp<wbr class="">?rev=289083&view=auto</a><br class="">
==============================<wbr class="">==============================<wbr class="">==================<br class="">
--- lld/trunk/ELF/Memory.cpp (original)<br class="">
+++ lld/trunk/ELF/Memory.cpp (removed)<br class="">
@@ -1,29 +0,0 @@<br class="">
-//===- Memory.cpp ------------------------------<wbr class="">-----------------*- C++ -*-===//<br class="">
-//<br class="">
-//                             The LLVM Linker<br class="">
-//<br class="">
-// This file is distributed under the University of Illinois Open Source<br class="">
-// License. See LICENSE.TXT for details.<br class="">
-//<br class="">
-//===------------------------<wbr class="">------------------------------<wbr class="">----------------===//<br class="">
-<br class="">
-#include "Memory.h"<br class="">
-<br class="">
-using namespace llvm;<br class="">
-using namespace lld;<br class="">
-using namespace lld::elf;<br class="">
-<br class="">
-namespace lld {<br class="">
-BumpPtrAllocator elf::BAlloc;<br class="">
-StringSaver elf::Saver{elf::BAlloc};<br class="">
-<br class="">
-SpecificAllocBase::SpecificAl<wbr class="">locBase() { Instances.push_back(this); }<br class="">
-<br class="">
-std::vector<SpecificAllocBase *> SpecificAllocBase::Instances;<br class="">
-<br class="">
-void elf::freeArena() {<br class="">
-  for (SpecificAllocBase *Alloc : SpecificAllocBase::Instances)<br class="">
-    Alloc->reset();<br class="">
-  BAlloc.Reset();<br class="">
-}<br class="">
-}<br class="">
<br class="">
Removed: lld/trunk/ELF/Memory.h<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Memory.h?rev=289083&view=auto" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-pr<wbr class="">oject/lld/trunk/ELF/Memory.h?r<wbr class="">ev=289083&view=auto</a><br class="">
==============================<wbr class="">==============================<wbr class="">==================<br class="">
--- lld/trunk/ELF/Memory.h (original)<br class="">
+++ lld/trunk/ELF/Memory.h (removed)<br class="">
@@ -1,61 +0,0 @@<br class="">
-//===- Memory.h ------------------------------<wbr class="">-------------------*- C++ -*-===//<br class="">
-//<br class="">
-//                             The LLVM Linker<br class="">
-//<br class="">
-// This file is distributed under the University of Illinois Open Source<br class="">
-// License. See LICENSE.TXT for details.<br class="">
-//<br class="">
-//===------------------------<wbr class="">------------------------------<wbr class="">----------------===//<br class="">
-//<br class="">
-// This file defines arena allocators.<br class="">
-//<br class="">
-// Almost all large objects, such as files, sections or symbols, are<br class="">
-// used for the entire lifetime of the linker once they are created.<br class="">
-// This usage characteristic makes arena allocator an attractive choice<br class="">
-// where the entire linker is one arena. With an arena, newly created<br class="">
-// objects belong to the arena and freed all at once when everything is done.<br class="">
-// Arena allocators are efficient and easy to understand.<br class="">
-// Most objects are allocated using the arena allocators defined by this file.<br class="">
-//<br class="">
-//===------------------------<wbr class="">------------------------------<wbr class="">----------------===//<br class="">
-<br class="">
-#ifndef LLD_ELF_MEMORY_H<br class="">
-#define LLD_ELF_MEMORY_H<br class="">
-<br class="">
-#include "llvm/Support/Allocator.h"<br class="">
-#include "llvm/Support/StringSaver.h"<br class="">
-#include <vector><br class="">
-<br class="">
-namespace lld {<br class="">
-namespace elf {<br class="">
-<br class="">
-// Use this arena if your object doesn't have a destructor.<br class="">
-extern llvm::BumpPtrAllocator BAlloc;<br class="">
-extern llvm::StringSaver Saver;<br class="">
-<br class="">
-// These two classes are hack to keep track of all<br class="">
-// SpecificBumpPtrAllocator instances.<br class="">
-struct SpecificAllocBase {<br class="">
-  SpecificAllocBase();<br class="">
-  virtual ~SpecificAllocBase() = default;<br class="">
-  virtual void reset() = 0;<br class="">
-  static std::vector<SpecificAllocBase *> Instances;<br class="">
-};<br class="">
-<br class="">
-template <class T> struct SpecificAlloc : public SpecificAllocBase {<br class="">
-  void reset() override { Alloc.DestroyAll(); }<br class="">
-  llvm::SpecificBumpPtrAllocator<wbr class=""><T> Alloc;<br class="">
-};<br class="">
-<br class="">
-// Use this arena if your object has a destructor.<br class="">
-// Your destructor will be invoked from freeArena().<br class="">
-template <typename T, typename... U> inline T *make(U &&... Args) {<br class="">
-  static SpecificAlloc<T> Alloc;<br class="">
-  return new (Alloc.Alloc.Allocate()) T(std::forward<U>(Args)...);<br class="">
-}<br class="">
-<br class="">
-void freeArena();<br class="">
-}<br class="">
-}<br class="">
-<br class="">
-#endif<br class="">
<br class="">
Modified: lld/trunk/ELF/OutputSections.c<wbr class="">pp<br class="">
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" class="">http://llvm.org/viewvc/llvm-pr<wbr class="">oject/lld/trunk/ELF/OutputSect<wbr class="">ions.cpp?rev=289084&r1=289083&<wbr class="">r2=289084&view=diff</a><br class="">
==============================<wbr class="">==============================<wbr class="">==================<br class="">
--- lld/trunk/ELF/OutputSections.c<wbr class="">pp (original)<br class="">
+++ lld/trunk/ELF/OutputSections.c<wbr class="">pp Thu Dec  8 12:31:13 2016<br class="">
@@ -11,12 +11,12 @@<br class="">
 #include "Config.h"<br class="">
 #include "EhFrame.h"<br class="">
 #include "LinkerScript.h"<br class="">
-#include "Memory.h"<br class="">
 #include "Strings.h"<br class="">
 #include "SymbolTable.h"<br class="">
 #include "SyntheticSections.h"<br class="">
 #include "Target.h"<br class="">
 #include "Threads.h"<br class="">
+#include "lld/Support/Memory.h"<br class="">
 #include "llvm/Support/Dwarf.h"<br class="">
 #include "llvm/Support/MD5.h"<br class="">
 #include "llvm/Support/MathExtras.h"<br class="">
<br class="">
Modified: lld/trunk/ELF/SymbolTable.cpp<br class="">
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" class="">http://llvm.org/viewvc/llvm-pr<wbr class="">oject/lld/trunk/ELF/SymbolTabl<wbr class="">e.cpp?rev=289084&r1=289083&r2=<wbr class="">289084&view=diff</a><br class="">
==============================<wbr class="">==============================<wbr class="">==================<br class="">
--- lld/trunk/ELF/SymbolTable.cpp (original)<br class="">
+++ lld/trunk/ELF/SymbolTable.cpp Thu Dec  8 12:31:13 2016<br class="">
@@ -18,8 +18,8 @@<br class="">
 #include "Config.h"<br class="">
 #include "Error.h"<br class="">
 #include "LinkerScript.h"<br class="">
-#include "Memory.h"<br class="">
 #include "Symbols.h"<br class="">
+#include "lld/Support/Memory.h"<br class="">
 #include "llvm/ADT/STLExtras.h"<br class="">
<br class="">
 using namespace llvm;<br class="">
<br class="">
Modified: lld/trunk/ELF/SyntheticSection<wbr class="">s.cpp<br class="">
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" class="">http://llvm.org/viewvc/llvm-pr<wbr class="">oject/lld/trunk/ELF/SyntheticS<wbr class="">ections.cpp?rev=289084&r1=2890<wbr class="">83&r2=289084&view=diff</a><br class="">
==============================<wbr class="">==============================<wbr class="">==================<br class="">
--- lld/trunk/ELF/SyntheticSection<wbr class="">s.cpp (original)<br class="">
+++ lld/trunk/ELF/SyntheticSection<wbr class="">s.cpp Thu Dec  8 12:31:13 2016<br class="">
@@ -19,15 +19,14 @@<br class="">
 #include "Error.h"<br class="">
 #include "InputFiles.h"<br class="">
 #include "LinkerScript.h"<br class="">
-#include "Memory.h"<br class="">
 #include "OutputSections.h"<br class="">
 #include "Strings.h"<br class="">
 #include "SymbolTable.h"<br class="">
 #include "Target.h"<br class="">
 #include "Threads.h"<br class="">
 #include "Writer.h"<br class="">
-<br class="">
 #include "lld/Config/Version.h"<br class="">
+#include "lld/Support/Memory.h"<br class="">
 #include "llvm/Support/Dwarf.h"<br class="">
 #include "llvm/Support/Endian.h"<br class="">
 #include "llvm/Support/MD5.h"<br class="">
<br class="">
Modified: lld/trunk/ELF/Target.cpp<br class="">
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" class="">http://llvm.org/viewvc/llvm-pr<wbr class="">oject/lld/trunk/ELF/Target.cpp<wbr class="">?rev=289084&r1=289083&r2=28908<wbr class="">4&view=diff</a><br class="">
==============================<wbr class="">==============================<wbr class="">==================<br class="">
--- lld/trunk/ELF/Target.cpp (original)<br class="">
+++ lld/trunk/ELF/Target.cpp Thu Dec  8 12:31:13 2016<br class="">
@@ -27,17 +27,16 @@<br class="">
 #include "Target.h"<br class="">
 #include "Error.h"<br class="">
 #include "InputFiles.h"<br class="">
-#include "Memory.h"<br class="">
 #include "OutputSections.h"<br class="">
 #include "Symbols.h"<br class="">
 #include "SyntheticSections.h"<br class="">
 #include "Thunks.h"<br class="">
 #include "Writer.h"<br class="">
-<br class="">
+#include "lld/Support/Memory.h"<br class="">
 #include "llvm/ADT/ArrayRef.h"<br class="">
 #include "llvm/Object/ELF.h"<br class="">
-#include "llvm/Support/Endian.h"<br class="">
 #include "llvm/Support/ELF.h"<br class="">
+#include "llvm/Support/Endian.h"<br class="">
<br class="">
 using namespace llvm;<br class="">
 using namespace llvm::object;<br class="">
<br class="">
Modified: lld/trunk/ELF/Thunks.cpp<br class="">
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" class="">http://llvm.org/viewvc/llvm-pr<wbr class="">oject/lld/trunk/ELF/Thunks.cpp<wbr class="">?rev=289084&r1=289083&r2=28908<wbr class="">4&view=diff</a><br class="">
==============================<wbr class="">==============================<wbr class="">==================<br class="">
--- lld/trunk/ELF/Thunks.cpp (original)<br class="">
+++ lld/trunk/ELF/Thunks.cpp Thu Dec  8 12:31:13 2016<br class="">
@@ -25,10 +25,10 @@<br class="">
 #include "Config.h"<br class="">
 #include "Error.h"<br class="">
 #include "InputSection.h"<br class="">
-#include "Memory.h"<br class="">
 #include "OutputSections.h"<br class="">
 #include "Symbols.h"<br class="">
 #include "Target.h"<br class="">
+#include "lld/Support/Memory.h"<br class="">
 #include "llvm/Support/Casting.h"<br class="">
 #include "llvm/Support/ELF.h"<br class="">
 #include "llvm/Support/Endian.h"<br class="">
<br class="">
Modified: lld/trunk/ELF/Writer.cpp<br class="">
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" class="">http://llvm.org/viewvc/llvm-pr<wbr class="">oject/lld/trunk/ELF/Writer.cpp<wbr class="">?rev=289084&r1=289083&r2=28908<wbr class="">4&view=diff</a><br class="">
==============================<wbr class="">==============================<wbr class="">==================<br class="">
--- lld/trunk/ELF/Writer.cpp (original)<br class="">
+++ lld/trunk/ELF/Writer.cpp Thu Dec  8 12:31:13 2016<br class="">
@@ -10,14 +10,13 @@<br class="">
 #include "Writer.h"<br class="">
 #include "Config.h"<br class="">
 #include "LinkerScript.h"<br class="">
-#include "Memory.h"<br class="">
 #include "OutputSections.h"<br class="">
 #include "Relocations.h"<br class="">
 #include "Strings.h"<br class="">
 #include "SymbolTable.h"<br class="">
 #include "SyntheticSections.h"<br class="">
 #include "Target.h"<br class="">
-<br class="">
+#include "lld/Support/Memory.h"<br class="">
 #include "llvm/ADT/StringMap.h"<br class="">
 #include "llvm/ADT/StringSwitch.h"<br class="">
 #include "llvm/Support/FileOutputBuffer<wbr class="">.h"<br class="">
<br class="">
Copied: lld/trunk/include/lld/Support/<wbr class="">Memory.h (from r289082, lld/trunk/ELF/Memory.h)<br class="">
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" class="">http://llvm.org/viewvc/llvm-pr<wbr class="">oject/lld/trunk/include/lld/Su<wbr class="">pport/Memory.h?p2=lld/trunk/in<wbr class="">clude/lld/Support/Memory.h&p1=<wbr class="">lld/trunk/ELF/Memory.h&r1=2890<wbr class="">82&r2=289084&rev=289084&view=d<wbr class="">iff</a><br class="">
==============================<wbr class="">==============================<wbr class="">==================<br class="">
--- lld/trunk/ELF/Memory.h (original)<br class="">
+++ lld/trunk/include/lld/Support/<wbr class="">Memory.h Thu Dec  8 12:31:13 2016<br class="">
@@ -19,15 +19,14 @@<br class="">
 //<br class="">
 //===------------------------<wbr class="">------------------------------<wbr class="">----------------===//<br class="">
<br class="">
-#ifndef LLD_ELF_MEMORY_H<br class="">
-#define LLD_ELF_MEMORY_H<br class="">
+#ifndef LLD_MEMORY_H<br class="">
+#define LLD_MEMORY_H<br class="">
<br class="">
 #include "llvm/Support/Allocator.h"<br class="">
 #include "llvm/Support/StringSaver.h"<br class="">
 #include <vector><br class="">
<br class="">
 namespace lld {<br class="">
-namespace elf {<br class="">
<br class="">
 // Use this arena if your object doesn't have a destructor.<br class="">
 extern llvm::BumpPtrAllocator BAlloc;<br class="">
@@ -56,6 +55,5 @@ template <typename T, typename... U> inl<br class="">
<br class="">
 void freeArena();<br class="">
 }<br class="">
-}<br class="">
<br class="">
 #endif<br class="">
<br class="">
Modified: lld/trunk/lib/CMakeLists.txt<br class="">
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" class="">http://llvm.org/viewvc/llvm-pr<wbr class="">oject/lld/trunk/lib/CMakeLists<wbr class="">.txt?rev=289084&r1=289083&r2=2<wbr class="">89084&view=diff</a><br class="">
==============================<wbr class="">==============================<wbr class="">==================<br class="">
--- lld/trunk/lib/CMakeLists.txt (original)<br class="">
+++ lld/trunk/lib/CMakeLists.txt Thu Dec  8 12:31:13 2016<br class="">
@@ -2,3 +2,4 @@ add_subdirectory(Config)<br class="">
 add_subdirectory(Core)<br class="">
 add_subdirectory(Driver)<br class="">
 add_subdirectory(ReaderWriter<wbr class="">)<br class="">
+add_subdirectory(Support)<br class="">
<br class="">
Added: lld/trunk/lib/Support/CMakeLis<wbr class="">ts.txt<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Support/CMakeLists.txt?rev=289084&view=auto" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-pr<wbr class="">oject/lld/trunk/lib/Support/CM<wbr class="">akeLists.txt?rev=289084&view=a<wbr class="">uto</a><br class="">
==============================<wbr class="">==============================<wbr class="">==================<br class="">
--- lld/trunk/lib/Support/CMakeLis<wbr class="">ts.txt (added)<br class="">
+++ lld/trunk/lib/Support/CMakeLis<wbr class="">ts.txt Thu Dec  8 12:31:13 2016<br class="">
@@ -0,0 +1,9 @@<br class="">
+add_lld_library(lldSupport<br class="">
+  Memory.cpp<br class="">
+<br class="">
+  ADDITIONAL_HEADER_DIRS<br class="">
+  ${LLD_INCLUDE_DIR}/lld/Support<br class="">
+<br class="">
+  LINK_LIBS<br class="">
+  LLVMSupport<br class="">
+)<br class="">
<br class="">
Copied: lld/trunk/lib/Support/Memory.c<wbr class="">pp (from r289082, lld/trunk/ELF/Memory.cpp)<br class="">
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" class="">http://llvm.org/viewvc/llvm-pr<wbr class="">oject/lld/trunk/lib/Support/Me<wbr class="">mory.cpp?p2=lld/trunk/lib/Supp<wbr class="">ort/Memory.cpp&p1=lld/trunk/EL<wbr class="">F/Memory.cpp&r1=289082&r2=2890<wbr class="">84&rev=289084&view=diff</a><br class="">
==============================<wbr class="">==============================<wbr class="">==================<br class="">
--- lld/trunk/ELF/Memory.cpp (original)<br class="">
+++ lld/trunk/lib/Support/Memory.c<wbr class="">pp Thu Dec  8 12:31:13 2016<br class="">
@@ -7,21 +7,19 @@<br class="">
 //<br class="">
 //===------------------------<wbr class="">------------------------------<wbr class="">----------------===//<br class="">
<br class="">
-#include "Memory.h"<br class="">
+#include "lld/Support/Memory.h"<br class="">
<br class="">
 using namespace llvm;<br class="">
-using namespace lld;<br class="">
-using namespace lld::elf;<br class="">
<br class="">
 namespace lld {<br class="">
-BumpPtrAllocator elf::BAlloc;<br class="">
-StringSaver elf::Saver{elf::BAlloc};<br class="">
+BumpPtrAllocator BAlloc;<br class="">
+StringSaver Saver{BAlloc};<br class="">
<br class="">
 SpecificAllocBase::SpecificAl<wbr class="">locBase() { Instances.push_back(this); }<br class="">
<br class="">
 std::vector<SpecificAllocBase *> SpecificAllocBase::Instances;<br class="">
<br class="">
-void elf::freeArena() {<br class="">
+void freeArena() {<br class="">
   for (SpecificAllocBase *Alloc : SpecificAllocBase::Instances)<br class="">
     Alloc->reset();<br class="">
   BAlloc.Reset();<br class="">
<br class="">
<br class="">
______________________________<wbr class="">_________________<br class="">
llvm-commits mailing list<br class="">
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank" class="">llvm-commits@lists.llvm.org</a><br class="">
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank" class="">http://lists.llvm.org/cgi-bin/<wbr class="">mailman/listinfo/llvm-commits</a><br class="">
</blockquote></div><br class=""></div>
</div></div></blockquote></div><br class=""></div></div></div></div>
</blockquote></div></div></div><br class=""></div></div>
</blockquote></div></div></div><br class=""></div></div>
</blockquote></div></div></div><br class=""></div></div>
</blockquote></div></div></div><br class=""></div></div>
</blockquote></div></div></div><br class=""></div></div>
</blockquote></div><br class=""></div></div>
______________________________<wbr class="">_________________<br class="">llvm-commits mailing list<br class=""><a href="mailto:llvm-commits@lists.llvm.org" target="_blank" class="">llvm-commits@lists.llvm.org</a><br class=""><a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" target="_blank" class="">http://lists.llvm.org/cgi-bin/<wbr class="">mailman/listinfo/llvm-commits</a><br class=""></div></blockquote></div><br class=""></div></div></div></div></blockquote></div><br class=""></div></div>
</div></blockquote></div><br class=""></body></html>