<div dir="ltr">Nice! De-templating classes should not only simplify code but also reduce compile time.</div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Mar 6, 2017 at 12:23 PM, Rafael Espindola 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:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: rafael<br>
Date: Mon Mar  6 14:23:56 2017<br>
New Revision: 297061<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=297061&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project?rev=297061&view=rev</a><br>
Log:<br>
Detemplate merge (input and synthetic) sections. NFC.<br>
<br>
Modified:<br>
    lld/trunk/ELF/Driver.cpp<br>
    lld/trunk/ELF/InputFiles.cpp<br>
    lld/trunk/ELF/InputSection.cpp<br>
    lld/trunk/ELF/InputSection.h<br>
    lld/trunk/ELF/MarkLive.cpp<br>
    lld/trunk/ELF/OutputSections.h<br>
    lld/trunk/ELF/<wbr>SyntheticSections.cpp<br>
    lld/trunk/ELF/<wbr>SyntheticSections.h<br>
    lld/trunk/ELF/Writer.cpp<br>
<br>
Modified: lld/trunk/ELF/Driver.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Driver.cpp?rev=297061&r1=297060&r2=297061&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/lld/trunk/ELF/Driver.<wbr>cpp?rev=297061&r1=297060&r2=<wbr>297061&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- lld/trunk/ELF/Driver.cpp (original)<br>
+++ lld/trunk/ELF/Driver.cpp Mon Mar  6 14:23:56 2017<br>
@@ -876,7 +876,7 @@ template <class ELFT> void LinkerDriver:<br>
       return;<br>
     if (Decompressor::<wbr>isCompressedELFSection(S-><wbr>Flags, S->Name))<br>
       S->uncompress<ELFT>();<br>
-    if (auto *MS = dyn_cast<MergeInputSection<<wbr>ELFT>>(S))<br>
+    if (auto *MS = dyn_cast<MergeInputSection>(S)<wbr>)<br>
       MS->splitIntoPieces();<br>
   });<br>
<br>
<br>
Modified: lld/trunk/ELF/InputFiles.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputFiles.cpp?rev=297061&r1=297060&r2=297061&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/lld/trunk/ELF/<wbr>InputFiles.cpp?rev=297061&r1=<wbr>297060&r2=297061&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- lld/trunk/ELF/InputFiles.cpp (original)<br>
+++ lld/trunk/ELF/InputFiles.cpp Mon Mar  6 14:23:56 2017<br>
@@ -381,7 +381,7 @@ elf::ObjectFile<ELFT>::<wbr>createInputSectio<br>
     if (Target->FirstRelocation)<br>
       fatal(toString(this) +<br>
             ": multiple relocation sections to one section are not supported");<br>
-    if (isa<MergeInputSection<ELFT>>(<wbr>Target))<br>
+    if (isa<MergeInputSection>(<wbr>Target))<br>
       fatal(toString(this) +<br>
             ": relocations pointing to SHF_MERGE are not supported");<br>
<br>
@@ -458,7 +458,7 @@ elf::ObjectFile<ELFT>::<wbr>createInputSectio<br>
     return make<EhInputSection<ELFT>>(<wbr>this, &Sec, Name);<br>
<br>
   if (shouldMerge(Sec))<br>
-    return make<MergeInputSection<ELFT>>(<wbr>this, &Sec, Name);<br>
+    return make<MergeInputSection>(this, &Sec, Name);<br>
   return make<InputSection>(this, &Sec, Name);<br>
 }<br>
<br>
<br>
Modified: lld/trunk/ELF/InputSection.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputSection.cpp?rev=297061&r1=297060&r2=297061&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/lld/trunk/ELF/<wbr>InputSection.cpp?rev=297061&<wbr>r1=297060&r2=297061&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- lld/trunk/ELF/InputSection.cpp (original)<br>
+++ lld/trunk/ELF/InputSection.cpp Mon Mar  6 14:23:56 2017<br>
@@ -111,7 +111,7 @@ uint64_t InputSectionBase::getOffset(<wbr>uin<br>
     // identify the start of the output .eh_frame.<br>
     return Offset;<br>
   case Merge:<br>
-    const MergeInputSection<ELFT> *MS = cast<MergeInputSection<ELFT>>(<wbr>this);<br>
+    const MergeInputSection *MS = cast<MergeInputSection>(this);<br>
     if (MS->MergeSec)<br>
       return MS->MergeSec->OutSecOff + MS->getOffset(Offset);<br>
     return MS->getOffset(Offset);<br>
@@ -121,7 +121,7 @@ uint64_t InputSectionBase::getOffset(<wbr>uin<br>
<br>
 template <class ELFT><br>
 OutputSection *InputSectionBase::<wbr>getOutputSection() const {<br>
-  if (auto *MS = dyn_cast<MergeInputSection<<wbr>ELFT>>(this))<br>
+  if (auto *MS = dyn_cast<MergeInputSection>(<wbr>this))<br>
     return MS->MergeSec ? MS->MergeSec->OutSec : nullptr;<br>
   if (auto *EH = dyn_cast<EhInputSection<ELFT>><wbr>(this))<br>
     return EH->EHSec->OutSec;<br>
@@ -660,9 +660,7 @@ static size_t findNull(ArrayRef<uint8_t><br>
<br>
 // Split SHF_STRINGS section. Such section is a sequence of<br>
 // null-terminated strings.<br>
-template <class ELFT><br>
-void MergeInputSection<ELFT>::<wbr>splitStrings(ArrayRef<uint8_t> Data,<br>
-                                           size_t EntSize) {<br>
+void MergeInputSection::<wbr>splitStrings(ArrayRef<uint8_t> Data, size_t EntSize) {<br>
   size_t Off = 0;<br>
   bool IsAlloc = this->Flags & SHF_ALLOC;<br>
   while (!Data.empty()) {<br>
@@ -679,9 +677,8 @@ void MergeInputSection<ELFT>::<wbr>splitStrin<br>
<br>
 // Split non-SHF_STRINGS section. Such section is a sequence of<br>
 // fixed size records.<br>
-template <class ELFT><br>
-void MergeInputSection<ELFT>::<wbr>splitNonStrings(ArrayRef<<wbr>uint8_t> Data,<br>
-                                              size_t EntSize) {<br>
+void MergeInputSection::<wbr>splitNonStrings(ArrayRef<<wbr>uint8_t> Data,<br>
+                                        size_t EntSize) {<br>
   size_t Size = Data.size();<br>
   assert((Size % EntSize) == 0);<br>
   bool IsAlloc = this->Flags & SHF_ALLOC;<br>
@@ -692,9 +689,9 @@ void MergeInputSection<ELFT>::<wbr>splitNonSt<br>
 }<br>
<br>
 template <class ELFT><br>
-MergeInputSection<ELFT>::<wbr>MergeInputSection(elf::<wbr>ObjectFile<ELFT> *F,<br>
-                                           const Elf_Shdr *Header,<br>
-                                           StringRef Name)<br>
+MergeInputSection::<wbr>MergeInputSection(elf::<wbr>ObjectFile<ELFT> *F,<br>
+                                     const typename ELFT::Shdr *Header,<br>
+                                     StringRef Name)<br>
     : InputSectionBase(F, Header, Name, InputSectionBase::Merge) {}<br>
<br>
 // This function is called after we obtain a complete list of input sections<br>
@@ -703,28 +700,26 @@ MergeInputSection<ELFT>::<wbr>MergeInputSecti<br>
 //<br>
 // Note that this function is called from parallel_for_each. This must be<br>
 // thread-safe (i.e. no memory allocation from the pools).<br>
-template <class ELFT> void MergeInputSection<ELFT>::<wbr>splitIntoPieces() {<br>
+void MergeInputSection::<wbr>splitIntoPieces() {<br>
   ArrayRef<uint8_t> Data = this->Data;<br>
-  uintX_t EntSize = this->Entsize;<br>
+  uint64_t EntSize = this->Entsize;<br>
   if (this->Flags & SHF_STRINGS)<br>
     splitStrings(Data, EntSize);<br>
   else<br>
     splitNonStrings(Data, EntSize);<br>
<br>
   if (Config->GcSections && (this->Flags & SHF_ALLOC))<br>
-    for (uintX_t Off : LiveOffsets)<br>
+    for (uint64_t Off : LiveOffsets)<br>
       this->getSectionPiece(Off)-><wbr>Live = true;<br>
 }<br>
<br>
-template <class ELFT><br>
-bool MergeInputSection<ELFT>::<wbr>classof(const InputSectionBase *S) {<br>
+bool MergeInputSection::classof(<wbr>const InputSectionBase *S) {<br>
   return S->kind() == InputSectionBase::Merge;<br>
 }<br>
<br>
 // Do binary search to get a section piece at a given input offset.<br>
-template <class ELFT><br>
-SectionPiece *MergeInputSection<ELFT>::<wbr>getSectionPiece(uintX_t Offset) {<br>
-  auto *This = static_cast<const MergeInputSection<ELFT> *>(this);<br>
+SectionPiece *MergeInputSection::<wbr>getSectionPiece(uint64_t Offset) {<br>
+  auto *This = static_cast<const MergeInputSection *>(this);<br>
   return const_cast<SectionPiece *>(This->getSectionPiece(<wbr>Offset));<br>
 }<br>
<br>
@@ -741,17 +736,15 @@ static It fastUpperBound(It First, It La<br>
   return Comp(Value, *First) ? First : First + 1;<br>
 }<br>
<br>
-template <class ELFT><br>
-const SectionPiece *<br>
-MergeInputSection<ELFT>::<wbr>getSectionPiece(uintX_t Offset) const {<br>
-  uintX_t Size = this->Data.size();<br>
+const SectionPiece *MergeInputSection::<wbr>getSectionPiece(uint64_t Offset) const {<br>
+  uint64_t Size = this->Data.size();<br>
   if (Offset >= Size)<br>
     fatal(toString(this) + ": entry is past the end of the section");<br>
<br>
   // Find the element this offset points to.<br>
   auto I = fastUpperBound(<br>
       Pieces.begin(), Pieces.end(), Offset,<br>
-      [](const uintX_t &A, const SectionPiece &B) { return A < B.InputOff; });<br>
+      [](const uint64_t &A, const SectionPiece &B) { return A < B.InputOff; });<br>
   --I;<br>
   return &*I;<br>
 }<br>
@@ -759,8 +752,7 @@ MergeInputSection<ELFT>::<wbr>getSectionPiece<br>
 // Returns the offset in an output section for a given input offset.<br>
 // Because contents of a mergeable section is not contiguous in output,<br>
 // it is not just an addition to a base output offset.<br>
-template <class ELFT><br>
-typename ELFT::uint MergeInputSection<ELFT>::<wbr>getOffset(uintX_t Offset) const {<br>
+uint64_t MergeInputSection::getOffset(<wbr>uint64_t Offset) const {<br>
   // Initialize OffsetMap lazily.<br>
   std::call_once(InitOffsetMap, [&] {<br>
     OffsetMap.reserve(Pieces.size(<wbr>));<br>
@@ -782,7 +774,7 @@ typename ELFT::uint MergeInputSection<EL<br>
   if (!Piece.Live)<br>
     return 0;<br>
<br>
-  uintX_t Addend = Offset - Piece.InputOff;<br>
+  uint64_t Addend = Offset - Piece.InputOff;<br>
   return Piece.OutputOff + Addend;<br>
 }<br>
<br>
@@ -814,11 +806,6 @@ template class elf::EhInputSection<ELF32<br>
 template class elf::EhInputSection<ELF64LE>;<br>
 template class elf::EhInputSection<ELF64BE>;<br>
<br>
-template class elf::MergeInputSection<<wbr>ELF32LE>;<br>
-template class elf::MergeInputSection<<wbr>ELF32BE>;<br>
-template class elf::MergeInputSection<<wbr>ELF64LE>;<br>
-template class elf::MergeInputSection<<wbr>ELF64BE>;<br>
-<br>
 template void InputSectionBase::uncompress<<wbr>ELF32LE>();<br>
 template void InputSectionBase::uncompress<<wbr>ELF32BE>();<br>
 template void InputSectionBase::uncompress<<wbr>ELF64LE>();<br>
@@ -862,3 +849,16 @@ template elf::ObjectFile<ELF32LE> *Input<br>
 template elf::ObjectFile<ELF32BE> *InputSectionBase::getFile<<wbr>ELF32BE>() const;<br>
 template elf::ObjectFile<ELF64LE> *InputSectionBase::getFile<<wbr>ELF64LE>() const;<br>
 template elf::ObjectFile<ELF64BE> *InputSectionBase::getFile<<wbr>ELF64BE>() const;<br>
+<br>
+template MergeInputSection::<wbr>MergeInputSection(elf::<wbr>ObjectFile<ELF32LE> *F,<br>
+                                              const ELF32LE::Shdr *Header,<br>
+                                              StringRef Name);<br>
+template MergeInputSection::<wbr>MergeInputSection(elf::<wbr>ObjectFile<ELF32BE> *F,<br>
+                                              const ELF32BE::Shdr *Header,<br>
+                                              StringRef Name);<br>
+template MergeInputSection::<wbr>MergeInputSection(elf::<wbr>ObjectFile<ELF64LE> *F,<br>
+                                              const ELF64LE::Shdr *Header,<br>
+                                              StringRef Name);<br>
+template MergeInputSection::<wbr>MergeInputSection(elf::<wbr>ObjectFile<ELF64BE> *F,<br>
+                                              const ELF64BE::Shdr *Header,<br>
+                                              StringRef Name);<br>
<br>
Modified: lld/trunk/ELF/InputSection.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputSection.h?rev=297061&r1=297060&r2=297061&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/lld/trunk/ELF/<wbr>InputSection.h?rev=297061&r1=<wbr>297060&r2=297061&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- lld/trunk/ELF/InputSection.h (original)<br>
+++ lld/trunk/ELF/InputSection.h Mon Mar  6 14:23:56 2017<br>
@@ -29,7 +29,7 @@ struct SectionPiece;<br>
<br>
 class DefinedRegular;<br>
 template <class ELFT> class EhFrameSection;<br>
-template <class ELFT> class MergeSyntheticSection;<br>
+class MergeSyntheticSection;<br>
 template <class ELFT> class ObjectFile;<br>
 class OutputSection;<br>
<br>
@@ -156,26 +156,23 @@ static_assert(sizeof(<wbr>SectionPiece) == 2<br>
               "SectionPiece is too big");<br>
<br>
 // This corresponds to a SHF_MERGE section of an input file.<br>
-template <class ELFT> class MergeInputSection : public InputSectionBase {<br>
-  typedef typename ELFT::uint uintX_t;<br>
-  typedef typename ELFT::Sym Elf_Sym;<br>
-  typedef typename ELFT::Shdr Elf_Shdr;<br>
-<br>
+class MergeInputSection : public InputSectionBase {<br>
 public:<br>
-  MergeInputSection(ObjectFile<<wbr>ELFT> *F, const Elf_Shdr *Header,<br>
+  template <class ELFT><br>
+  MergeInputSection(ObjectFile<<wbr>ELFT> *F, const typename ELFT::Shdr *Header,<br>
                     StringRef Name);<br>
   static bool classof(const InputSectionBase *S);<br>
   void splitIntoPieces();<br>
<br>
   // Mark the piece at a given offset live. Used by GC.<br>
-  void markLiveAt(uintX_t Offset) {<br>
+  void markLiveAt(uint64_t Offset) {<br>
     assert(this->Flags & llvm::ELF::SHF_ALLOC);<br>
     LiveOffsets.insert(Offset);<br>
   }<br>
<br>
   // Translate an offset in the input section to an offset<br>
   // in the output section.<br>
-  uintX_t getOffset(uintX_t Offset) const;<br>
+  uint64_t getOffset(uint64_t Offset) const;<br>
<br>
   // Splittable sections are handled as a sequence of data<br>
   // rather than a single large blob of data.<br>
@@ -197,13 +194,13 @@ public:<br>
   }<br>
<br>
   // Returns the SectionPiece at a given input section offset.<br>
-  SectionPiece *getSectionPiece(uintX_t Offset);<br>
-  const SectionPiece *getSectionPiece(uintX_t Offset) const;<br>
+  SectionPiece *getSectionPiece(uint64_t Offset);<br>
+  const SectionPiece *getSectionPiece(uint64_t Offset) const;<br>
<br>
   // MergeInputSections are aggregated to a synthetic input sections,<br>
   // and then added to an OutputSection. This pointer points to a<br>
   // synthetic MergeSyntheticSection which this section belongs to.<br>
-  MergeSyntheticSection<ELFT> *MergeSec = nullptr;<br>
+  MergeSyntheticSection *MergeSec = nullptr;<br>
<br>
 private:<br>
   void splitStrings(ArrayRef<uint8_t> A, size_t Size);<br>
@@ -211,10 +208,10 @@ private:<br>
<br>
   std::vector<uint32_t> Hashes;<br>
<br>
-  mutable llvm::DenseMap<uintX_t, uintX_t> OffsetMap;<br>
+  mutable llvm::DenseMap<uint64_t, uint64_t> OffsetMap;<br>
   mutable std::once_flag InitOffsetMap;<br>
<br>
-  llvm::DenseSet<uintX_t> LiveOffsets;<br>
+  llvm::DenseSet<uint64_t> LiveOffsets;<br>
 };<br>
<br>
 struct EhSectionPiece : public SectionPiece {<br>
<br>
Modified: lld/trunk/ELF/MarkLive.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/MarkLive.cpp?rev=297061&r1=297060&r2=297061&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/lld/trunk/ELF/<wbr>MarkLive.cpp?rev=297061&r1=<wbr>297060&r2=297061&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- lld/trunk/ELF/MarkLive.cpp (original)<br>
+++ lld/trunk/ELF/MarkLive.cpp Mon Mar  6 14:23:56 2017<br>
@@ -210,7 +210,7 @@ template <class ELFT> void elf::markLive<br>
     // Usually, a whole section is marked as live or dead, but in mergeable<br>
     // (splittable) sections, each piece of data has independent liveness bit.<br>
     // So we explicitly tell it which offset is in use.<br>
-    if (auto *MS = dyn_cast<MergeInputSection<<wbr>ELFT>>(R.Sec))<br>
+    if (auto *MS = dyn_cast<MergeInputSection>(R.<wbr>Sec))<br>
       MS->markLiveAt(R.Offset);<br>
<br>
     if (R.Sec->Live)<br>
<br>
Modified: lld/trunk/ELF/OutputSections.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.h?rev=297061&r1=297060&r2=297061&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/lld/trunk/ELF/<wbr>OutputSections.h?rev=297061&<wbr>r1=297060&r2=297061&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- lld/trunk/ELF/OutputSections.h (original)<br>
+++ lld/trunk/ELF/OutputSections.h Mon Mar  6 14:23:56 2017<br>
@@ -26,7 +26,7 @@ struct EhSectionPiece;<br>
 template <class ELFT> class EhInputSection;<br>
 class InputSection;<br>
 class InputSectionBase;<br>
-template <class ELFT> class MergeInputSection;<br>
+class MergeInputSection;<br>
 class OutputSection;<br>
 template <class ELFT> class ObjectFile;<br>
 template <class ELFT> class SharedFile;<br>
<br>
Modified: lld/trunk/ELF/<wbr>SyntheticSections.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SyntheticSections.cpp?rev=297061&r1=297060&r2=297061&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/lld/trunk/ELF/<wbr>SyntheticSections.cpp?rev=<wbr>297061&r1=297060&r2=297061&<wbr>view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- lld/trunk/ELF/<wbr>SyntheticSections.cpp (original)<br>
+++ lld/trunk/ELF/<wbr>SyntheticSections.cpp Mon Mar  6 14:23:56 2017<br>
@@ -110,14 +110,15 @@ static ArrayRef<uint8_t> getVersion() {<br>
 // With this feature, you can identify LLD-generated binaries easily<br>
 // by "objdump -s -j .comment <file>".<br>
 // The returned object is a mergeable string section.<br>
-template <class ELFT> MergeInputSection<ELFT> *elf::createCommentSection() {<br>
+template <class ELFT> MergeInputSection *elf::createCommentSection() {<br>
   typename ELFT::Shdr Hdr = {};<br>
   Hdr.sh_flags = SHF_MERGE | SHF_STRINGS;<br>
   Hdr.sh_type = SHT_PROGBITS;<br>
   Hdr.sh_entsize = 1;<br>
   Hdr.sh_addralign = 1;<br>
<br>
-  auto *Ret = make<MergeInputSection<ELFT>>(<wbr>/*file=*/nullptr, &Hdr, ".comment");<br>
+  auto *Ret =<br>
+      make<MergeInputSection>((<wbr>ObjectFile<ELFT> *)nullptr, &Hdr, ".comment");<br>
   Ret->Data = getVersion();<br>
   Ret->splitIntoPieces();<br>
   return Ret;<br>
@@ -2134,34 +2135,27 @@ template <class ELFT> bool VersionNeedSe<br>
   return getNeedNum() == 0;<br>
 }<br>
<br>
-template <class ELFT><br>
-MergeSyntheticSection<ELFT>::<wbr>MergeSyntheticSection(<wbr>StringRef Name,<br>
-                                                   uint32_t Type,<br>
-                                                   uint64_t Flags,<br>
-                                                   uint64_t Alignment)<br>
+MergeSyntheticSection::<wbr>MergeSyntheticSection(<wbr>StringRef Name, uint32_t Type,<br>
+                                             uint64_t Flags, uint64_t Alignment)<br>
     : SyntheticSection(Flags, Type, Alignment, Name),<br>
       Builder(StringTableBuilder::<wbr>RAW, Alignment) {}<br>
<br>
-template <class ELFT><br>
-void MergeSyntheticSection<ELFT>::<wbr>addSection(MergeInputSection<<wbr>ELFT> *MS) {<br>
+void MergeSyntheticSection::<wbr>addSection(MergeInputSection *MS) {<br>
   assert(!Finalized);<br>
   MS->MergeSec = this;<br>
   Sections.push_back(MS);<br>
 }<br>
<br>
-template <class ELFT> void MergeSyntheticSection<ELFT>::<wbr>writeTo(uint8_t *Buf) {<br>
-  Builder.write(Buf);<br>
-}<br>
+void MergeSyntheticSection::<wbr>writeTo(uint8_t *Buf) { Builder.write(Buf); }<br>
<br>
-template <class ELFT><br>
-bool MergeSyntheticSection<ELFT>::<wbr>shouldTailMerge() const {<br>
+bool MergeSyntheticSection::<wbr>shouldTailMerge() const {<br>
   return (this->Flags & SHF_STRINGS) && Config->Optimize >= 2;<br>
 }<br>
<br>
-template <class ELFT> void MergeSyntheticSection<ELFT>::<wbr>finalizeTailMerge() {<br>
+void MergeSyntheticSection::<wbr>finalizeTailMerge() {<br>
   // Add all string pieces to the string table builder to create section<br>
   // contents.<br>
-  for (MergeInputSection<ELFT> *Sec : Sections)<br>
+  for (MergeInputSection *Sec : Sections)<br>
     for (size_t I = 0, E = Sec->Pieces.size(); I != E; ++I)<br>
       if (Sec->Pieces[I].Live)<br>
         Builder.add(Sec->getData(I));<br>
@@ -2172,18 +2166,18 @@ template <class ELFT> void MergeSyntheti<br>
   // finalize() fixed tail-optimized strings, so we can now get<br>
   // offsets of strings. Get an offset for each string and save it<br>
   // to a corresponding StringPiece for easy access.<br>
-  for (MergeInputSection<ELFT> *Sec : Sections)<br>
+  for (MergeInputSection *Sec : Sections)<br>
     for (size_t I = 0, E = Sec->Pieces.size(); I != E; ++I)<br>
       if (Sec->Pieces[I].Live)<br>
         Sec->Pieces[I].OutputOff = Builder.getOffset(Sec-><wbr>getData(I));<br>
 }<br>
<br>
-template <class ELFT> void MergeSyntheticSection<ELFT>::<wbr>finalizeNoTailMerge() {<br>
+void MergeSyntheticSection::<wbr>finalizeNoTailMerge() {<br>
   // Add all string pieces to the string table builder to create section<br>
   // contents. Because we are not tail-optimizing, offsets of strings are<br>
   // fixed when they are added to the builder (string table builder contains<br>
   // a hash table from strings to offsets).<br>
-  for (MergeInputSection<ELFT> *Sec : Sections)<br>
+  for (MergeInputSection *Sec : Sections)<br>
     for (size_t I = 0, E = Sec->Pieces.size(); I != E; ++I)<br>
       if (Sec->Pieces[I].Live)<br>
         Sec->Pieces[I].OutputOff = Builder.add(Sec->getData(I));<br>
@@ -2191,7 +2185,7 @@ template <class ELFT> void MergeSyntheti<br>
   Builder.finalizeInOrder();<br>
 }<br>
<br>
-template <class ELFT> void MergeSyntheticSection<ELFT>::<wbr>finalizeContents() {<br>
+void MergeSyntheticSection::<wbr>finalizeContents() {<br>
   if (Finalized)<br>
     return;<br>
   Finalized = true;<br>
@@ -2201,9 +2195,9 @@ template <class ELFT> void MergeSyntheti<br>
     finalizeNoTailMerge();<br>
 }<br>
<br>
-template <class ELFT> size_t MergeSyntheticSection<ELFT>::<wbr>getSize() const {<br>
+size_t MergeSyntheticSection::<wbr>getSize() const {<br>
   // We should finalize string builder to know the size.<br>
-  const_cast<<wbr>MergeSyntheticSection<ELFT> *>(this)->finalizeContents();<br>
+  const_cast<<wbr>MergeSyntheticSection *>(this)->finalizeContents();<br>
   return Builder.getSize();<br>
 }<br>
<br>
@@ -2273,10 +2267,10 @@ template InputSection *elf::createCommon<br>
 template InputSection *elf::createCommonSection<<wbr>ELF64LE>();<br>
 template InputSection *elf::createCommonSection<<wbr>ELF64BE>();<br>
<br>
-template MergeInputSection<ELF32LE> *elf::createCommentSection();<br>
-template MergeInputSection<ELF32BE> *elf::createCommentSection();<br>
-template MergeInputSection<ELF64LE> *elf::createCommentSection();<br>
-template MergeInputSection<ELF64BE> *elf::createCommentSection();<br>
+template MergeInputSection *elf::createCommentSection<<wbr>ELF32LE>();<br>
+template MergeInputSection *elf::createCommentSection<<wbr>ELF32BE>();<br>
+template MergeInputSection *elf::createCommentSection<<wbr>ELF64LE>();<br>
+template MergeInputSection *elf::createCommentSection<<wbr>ELF64BE>();<br>
<br>
 template SymbolBody *elf::addSyntheticLocal<<wbr>ELF32LE>(StringRef, uint8_t,<br>
                                                      uint64_t, uint64_t,<br>
@@ -2396,11 +2390,6 @@ template class elf::VersionDefinitionSec<br>
 template class elf::VersionDefinitionSection<<wbr>ELF64LE>;<br>
 template class elf::VersionDefinitionSection<<wbr>ELF64BE>;<br>
<br>
-template class elf::MergeSyntheticSection<<wbr>ELF32LE>;<br>
-template class elf::MergeSyntheticSection<<wbr>ELF32BE>;<br>
-template class elf::MergeSyntheticSection<<wbr>ELF64LE>;<br>
-template class elf::MergeSyntheticSection<<wbr>ELF64BE>;<br>
-<br>
 template class elf::MipsRldMapSection<<wbr>ELF32LE>;<br>
 template class elf::MipsRldMapSection<<wbr>ELF32BE>;<br>
 template class elf::MipsRldMapSection<<wbr>ELF64LE>;<br>
<br>
Modified: lld/trunk/ELF/<wbr>SyntheticSections.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SyntheticSections.h?rev=297061&r1=297060&r2=297061&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/lld/trunk/ELF/<wbr>SyntheticSections.h?rev=<wbr>297061&r1=297060&r2=297061&<wbr>view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- lld/trunk/ELF/<wbr>SyntheticSections.h (original)<br>
+++ lld/trunk/ELF/<wbr>SyntheticSections.h Mon Mar  6 14:23:56 2017<br>
@@ -640,12 +640,11 @@ public:<br>
 // with different attributes in a single output sections. To do that<br>
 // we put them into MergeSyntheticSection synthetic input sections which are<br>
 // attached to regular output sections.<br>
-template <class ELFT><br>
 class MergeSyntheticSection final : public SyntheticSection {<br>
 public:<br>
   MergeSyntheticSection(<wbr>StringRef Name, uint32_t Type, uint64_t Flags,<br>
                         uint64_t Alignment);<br>
-  void addSection(MergeInputSection<<wbr>ELFT> *MS);<br>
+  void addSection(MergeInputSection *MS);<br>
   void writeTo(uint8_t *Buf) override;<br>
   void finalizeContents() override;<br>
   bool shouldTailMerge() const;<br>
@@ -657,7 +656,7 @@ private:<br>
<br>
   bool Finalized = false;<br>
   llvm::StringTableBuilder Builder;<br>
-  std::vector<MergeInputSection<<wbr>ELFT> *> Sections;<br>
+  std::vector<MergeInputSection *> Sections;<br>
 };<br>
<br>
 // .MIPS.abiflags section.<br>
@@ -751,7 +750,7 @@ private:<br>
<br>
 template <class ELFT> InputSection *createCommonSection();<br>
 InputSection *createInterpSection();<br>
-template <class ELFT> MergeInputSection<ELFT> *createCommentSection();<br>
+template <class ELFT> MergeInputSection *createCommentSection();<br>
 template <class ELFT><br>
 SymbolBody *addSyntheticLocal(StringRef Name, uint8_t Type, uint64_t Value,<br>
                               uint64_t Size, InputSectionBase *Section);<br>
<br>
Modified: lld/trunk/ELF/Writer.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=297061&r1=297060&r2=297061&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/lld/trunk/ELF/Writer.<wbr>cpp?rev=297061&r1=297060&r2=<wbr>297061&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- lld/trunk/ELF/Writer.cpp (original)<br>
+++ lld/trunk/ELF/Writer.cpp Mon Mar  6 14:23:56 2017<br>
@@ -163,9 +163,9 @@ static typename ELFT::uint getOutFlags(I<br>
 template <class ELFT> static void combineMergableSections() {<br>
   typedef typename ELFT::uint uintX_t;<br>
<br>
-  std::vector<<wbr>MergeSyntheticSection<ELFT> *> MergeSections;<br>
+  std::vector<<wbr>MergeSyntheticSection *> MergeSections;<br>
   for (InputSectionBase *&S : InputSections) {<br>
-    MergeInputSection<ELFT> *MS = dyn_cast<MergeInputSection<<wbr>ELFT>>(S);<br>
+    MergeInputSection *MS = dyn_cast<MergeInputSection>(S)<wbr>;<br>
     if (!MS)<br>
       continue;<br>
<br>
@@ -179,13 +179,13 @@ template <class ELFT> static void combin<br>
     uintX_t Alignment = std::max<uintX_t>(MS-><wbr>Alignment, MS->Entsize);<br>
<br>
     auto I =<br>
-        llvm::find_if(MergeSections, [=](MergeSyntheticSection<<wbr>ELFT> *Sec) {<br>
+        llvm::find_if(MergeSections, [=](MergeSyntheticSection *Sec) {<br>
           return Sec->Name == OutsecName && Sec->Flags == Flags &&<br>
                  Sec->Alignment == Alignment;<br>
         });<br>
     if (I == MergeSections.end()) {<br>
-      MergeSyntheticSection<ELFT> *Syn = make<MergeSyntheticSection<<wbr>ELFT>>(<br>
-          OutsecName, MS->Type, Flags, Alignment);<br>
+      MergeSyntheticSection *Syn =<br>
+          make<MergeSyntheticSection>(<wbr>OutsecName, MS->Type, Flags, Alignment);<br>
       MergeSections.push_back(Syn);<br>
       I = std::prev(MergeSections.end())<wbr>;<br>
       S = Syn;<br>
@@ -491,7 +491,7 @@ template <class ELFT> static bool includ<br>
     // Exclude symbols pointing to garbage-collected sections.<br>
     if (!D->Section->Live)<br>
       return false;<br>
-    if (auto *S = dyn_cast<MergeInputSection<<wbr>ELFT>>(D->Section))<br>
+    if (auto *S = dyn_cast<MergeInputSection>(D-<wbr>>Section))<br>
       if (!S->getSectionPiece(D->Value)<wbr>->Live)<br>
         return false;<br>
   }<br>
<br>
<br>
______________________________<wbr>_________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org">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>