<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Fri, Nov 3, 2017 at 12:47 PM, Rafael Espíndola <span dir="ltr"><<a href="mailto:rafael.espindola@gmail.com" target="_blank">rafael.espindola@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">This also caused a performance regression.<br>
<br>
r316848 helped bring some of the performance back, but not to parity.<br>
<br>
316879  and 316880 got us back the previous perf on scylla, but they<br>
seem to be an independent improvement, so we probably still have this<br>
regression.<br>
<br>
The area has been further changed, so it is really hard to revert this<br>
now. Can you try to semantically revert it (and benchmark it)?<br>
<br>
*Please*, in the future do not commit such a big series of patches in<br>
quick sequence. We are now stuck with regressions that are hard to<br>
fix.<br></blockquote><div><br></div><div>As I wrote in the previous mail, I'll do. Sorry for your inconvenience. I don't necessarily think that post-commit review is bad, particularly when a delay of pre-commit review is relatively high, but I'll keep it easily revertiable and I'll explain what I did in a commit message when I do it.</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Cheers,<br>
Rafael<br>
<br>
<br>
<br>
On 28 October 2017 at 13:15, Rui Ueyama via llvm-commits<br>
<div class="HOEnZb"><div class="h5"><<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a>> wrote:<br>
> Author: ruiu<br>
> Date: Sat Oct 28 13:15:56 2017<br>
> New Revision: 316841<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=316841&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project?rev=316841&view=rev</a><br>
> Log:<br>
> Pass symbol attributes instead of ElfSym to Shared symbol ctor.<br>
><br>
> This change allows us to use less templates for Shared symbol and<br>
> the functions that deals with shared symbols.<br>
><br>
> Modified:<br>
>     lld/trunk/ELF/InputFiles.cpp<br>
>     lld/trunk/ELF/InputFiles.h<br>
>     lld/trunk/ELF/MapFile.cpp<br>
>     lld/trunk/ELF/MapFile.h<br>
>     lld/trunk/ELF/Relocations.cpp<br>
>     lld/trunk/ELF/SymbolTable.cpp<br>
>     lld/trunk/ELF/SymbolTable.h<br>
>     lld/trunk/ELF/Symbols.cpp<br>
>     lld/trunk/ELF/Symbols.h<br>
>     lld/trunk/ELF/<wbr>SyntheticSections.cpp<br>
>     lld/trunk/ELF/Writer.cpp<br>
><br>
> Modified: lld/trunk/ELF/InputFiles.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputFiles.cpp?rev=316841&r1=316840&r2=316841&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/lld/trunk/ELF/<wbr>InputFiles.cpp?rev=316841&r1=<wbr>316840&r2=316841&view=diff</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- lld/trunk/ELF/InputFiles.cpp (original)<br>
> +++ lld/trunk/ELF/InputFiles.cpp Sat Oct 28 13:15:56 2017<br>
> @@ -514,11 +514,9 @@ template <class ELFT> void ObjFile<ELFT><br>
>  }<br>
><br>
>  template <class ELFT><br>
> -InputSectionBase *ObjFile<ELFT>::getSection(<wbr>const Elf_Sym &Sym) const {<br>
> -  uint32_t Index = this->getSectionIndex(Sym);<br>
> +InputSectionBase *ObjFile<ELFT>::getSection(<wbr>uint32_t Index) const {<br>
>    if (Index == 0)<br>
>      return nullptr;<br>
> -<br>
>    if (Index >= this->Sections.size())<br>
>      fatal(toString(this) + ": invalid section index: " + Twine(Index));<br>
><br>
> @@ -533,7 +531,7 @@ InputSectionBase *ObjFile<ELFT>::getSect<br>
>  template <class ELFT><br>
>  SymbolBody *ObjFile<ELFT>::<wbr>createSymbolBody(const Elf_Sym *Sym) {<br>
>    int Binding = Sym->getBinding();<br>
> -  InputSectionBase *Sec = getSection(*Sym);<br>
> +  InputSectionBase *Sec = getSection(this-><wbr>getSectionIndex(*Sym));<br>
><br>
>    uint8_t StOther = Sym->st_other;<br>
>    uint8_t Type = Sym->getType();<br>
> @@ -629,14 +627,6 @@ SharedFile<ELFT>::SharedFile(<wbr>MemoryBuffe<br>
>      : ELFFileBase<ELFT>(Base::<wbr>SharedKind, M), SoName(DefaultSoName),<br>
>        AsNeeded(Config->AsNeeded) {}<br>
><br>
> -template <class ELFT><br>
> -const typename ELFT::Shdr *<br>
> -SharedFile<ELFT>::getSection(<wbr>const Elf_Sym &Sym) const {<br>
> -  return check(<br>
> -      this->getObj().getSection(&<wbr>Sym, this->ELFSyms, this->SymtabSHNDX),<br>
> -      toString(this));<br>
> -}<br>
> -<br>
>  // Partially parse the shared object file so that we can call<br>
>  // getSoName on this object.<br>
>  template <class ELFT> void SharedFile<ELFT>::parseSoName(<wbr>) {<br>
> @@ -735,6 +725,10 @@ template <class ELFT> void SharedFile<EL<br>
>    const Elf_Versym *Versym = nullptr;<br>
>    std::vector<const Elf_Verdef *> Verdefs = parseVerdefs(Versym);<br>
><br>
> +  ArrayRef<Elf_Shdr> Sections =<br>
> +      check(this->getObj().sections(<wbr>), toString(this));<br>
> +<br>
> +  // Add symbols to the symbol table.<br>
>    Elf_Sym_Range Syms = this->getGlobalELFSyms();<br>
>    for (const Elf_Sym &Sym : Syms) {<br>
>      unsigned VersymIndex = 0;<br>
> @@ -765,15 +759,25 @@ template <class ELFT> void SharedFile<EL<br>
>        V = Verdefs[VersymIndex];<br>
>      }<br>
><br>
> +    // We do not usually care about alignments of data in shared object<br>
> +    // files because the loader takes care of it. However, if we promote a<br>
> +    // DSO symbol to point to .bss due to copy relocation, we need to keep<br>
> +    // the original alignment requirements. We infer it here.<br>
> +    uint32_t Alignment = 1 << countTrailingZeros((uint64_t)<wbr>Sym.st_value);<br>
> +    if (0 < Sym.st_shndx && Sym.st_shndx < Sections.size()) {<br>
> +      uint32_t SecAlign = Sections[Sym.st_shndx].sh_<wbr>addralign;<br>
> +      Alignment = std::min(Alignment, SecAlign);<br>
> +    }<br>
> +<br>
>      if (!Hidden)<br>
> -      Symtab->addShared(Name, this, Sym, V);<br>
> +      Symtab->addShared(Name, this, Sym, Alignment, V);<br>
><br>
>      // Also add the symbol with the versioned name to handle undefined symbols<br>
>      // with explicit versions.<br>
>      if (V) {<br>
>        StringRef VerName = this->StringTable.data() + V->getAux()->vda_name;<br>
>        Name = Saver.save(Name + "@" + VerName);<br>
> -      Symtab->addShared(Name, this, Sym, V);<br>
> +      Symtab->addShared(Name, this, Sym, Alignment, V);<br>
>      }<br>
>    }<br>
>  }<br>
><br>
> Modified: lld/trunk/ELF/InputFiles.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputFiles.h?rev=316841&r1=316840&r2=316841&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/lld/trunk/ELF/<wbr>InputFiles.h?rev=316841&r1=<wbr>316840&r2=316841&view=diff</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- lld/trunk/ELF/InputFiles.h (original)<br>
> +++ lld/trunk/ELF/InputFiles.h Sat Oct 28 13:15:56 2017<br>
> @@ -167,7 +167,7 @@ public:<br>
>    ObjFile(MemoryBufferRef M, StringRef ArchiveName);<br>
>    void parse(llvm::DenseSet<llvm::<wbr>CachedHashStringRef> &ComdatGroups);<br>
><br>
> -  InputSectionBase *getSection(const Elf_Sym &Sym) const;<br>
> +  InputSectionBase *getSection(uint32_t Index) const;<br>
><br>
>    SymbolBody &getSymbolBody(uint32_t SymbolIndex) const {<br>
>      if (SymbolIndex >= this->Symbols.size())<br>
> @@ -294,7 +294,6 @@ template <class ELFT> class SharedFile :<br>
>  public:<br>
>    std::string SoName;<br>
><br>
> -  const Elf_Shdr *getSection(const Elf_Sym &Sym) const;<br>
>    llvm::ArrayRef<StringRef> getUndefinedSymbols() { return Undefs; }<br>
><br>
>    static bool classof(const InputFile *F) {<br>
><br>
> Modified: lld/trunk/ELF/MapFile.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/MapFile.cpp?rev=316841&r1=316840&r2=316841&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/lld/trunk/ELF/MapFile.<wbr>cpp?rev=316841&r1=316840&r2=<wbr>316841&view=diff</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- lld/trunk/ELF/MapFile.cpp (original)<br>
> +++ lld/trunk/ELF/MapFile.cpp Sat Oct 28 13:15:56 2017<br>
> @@ -49,7 +49,7 @@ static void writeHeader(raw_ostream &OS,<br>
>  static std::string indent(int Depth) { return std::string(Depth * 8, ' '); }<br>
><br>
>  // Returns a list of all symbols that we want to print out.<br>
> -template <class ELFT> static std::vector<Defined *> getSymbols() {<br>
> +static std::vector<Defined *> getSymbols() {<br>
>    std::vector<Defined *> V;<br>
>    for (InputFile *File : ObjectFiles) {<br>
>      for (SymbolBody *B : File->getSymbols()) {<br>
> @@ -90,13 +90,12 @@ static SymbolMapTy getSectionSyms(ArrayR<br>
>  // Construct a map from symbols to their stringified representations.<br>
>  // Demangling symbols (which is what toString() does) is slow, so<br>
>  // we do that in batch using parallel-for.<br>
> -template <class ELFT><br>
>  static DenseMap<Defined *, std::string><br>
>  getSymbolStrings(ArrayRef<<wbr>Defined *> Syms) {<br>
>    std::vector<std::string> Str(Syms.size());<br>
>    parallelForEachN(0, Syms.size(), [&](size_t I) {<br>
>      raw_string_ostream OS(Str[I]);<br>
> -    writeHeader(OS, Syms[I]->getVA(), Syms[I]->template getSize<ELFT>(), 0);<br>
> +    writeHeader(OS, Syms[I]->getVA(), Syms[I]->getSize(), 0);<br>
>      OS << indent(2) << toString(*Syms[I]);<br>
>    });<br>
><br>
> @@ -106,7 +105,7 @@ getSymbolStrings(ArrayRef<<wbr>Defined *> Sym<br>
>    return Ret;<br>
>  }<br>
><br>
> -template <class ELFT> void elf::writeMapFile() {<br>
> +void elf::writeMapFile() {<br>
>    if (Config->MapFile.empty())<br>
>      return;<br>
><br>
> @@ -119,12 +118,12 @@ template <class ELFT> void elf::writeMap<br>
>    }<br>
><br>
>    // Collect symbol info that we want to print out.<br>
> -  std::vector<Defined *> Syms = getSymbols<ELFT>();<br>
> +  std::vector<Defined *> Syms = getSymbols();<br>
>    SymbolMapTy SectionSyms = getSectionSyms(Syms);<br>
> -  DenseMap<Defined *, std::string> SymStr = getSymbolStrings<ELFT>(Syms);<br>
> +  DenseMap<Defined *, std::string> SymStr = getSymbolStrings(Syms);<br>
><br>
>    // Print out the header line.<br>
> -  int W = ELFT::Is64Bits ? 16 : 8;<br>
> +  int W = Config->Is64 ? 16 : 8;<br>
>    OS << left_justify("Address", W) << ' ' << left_justify("Size", W)<br>
>       << " Align Out     In      Symbol\n";<br>
><br>
> @@ -148,8 +147,3 @@ template <class ELFT> void elf::writeMap<br>
>      }<br>
>    }<br>
>  }<br>
> -<br>
> -template void elf::writeMapFile<ELF32LE>();<br>
> -template void elf::writeMapFile<ELF32BE>();<br>
> -template void elf::writeMapFile<ELF64LE>();<br>
> -template void elf::writeMapFile<ELF64BE>();<br>
><br>
> Modified: lld/trunk/ELF/MapFile.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/MapFile.h?rev=316841&r1=316840&r2=316841&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/lld/trunk/ELF/MapFile.<wbr>h?rev=316841&r1=316840&r2=<wbr>316841&view=diff</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- lld/trunk/ELF/MapFile.h (original)<br>
> +++ lld/trunk/ELF/MapFile.h Sat Oct 28 13:15:56 2017<br>
> @@ -10,12 +10,9 @@<br>
>  #ifndef LLD_ELF_MAPFILE_H<br>
>  #define LLD_ELF_MAPFILE_H<br>
><br>
> -#include <llvm/ADT/ArrayRef.h><br>
> -<br>
>  namespace lld {<br>
>  namespace elf {<br>
> -class OutputSection;<br>
> -template <class ELFT> void writeMapFile();<br>
> +void writeMapFile();<br>
>  } // namespace elf<br>
>  } // namespace lld<br>
><br>
><br>
> Modified: lld/trunk/ELF/Relocations.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Relocations.cpp?rev=316841&r1=316840&r2=316841&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/lld/trunk/ELF/<wbr>Relocations.cpp?rev=316841&r1=<wbr>316840&r2=316841&view=diff</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- lld/trunk/ELF/Relocations.cpp (original)<br>
> +++ lld/trunk/ELF/Relocations.cpp Sat Oct 28 13:15:56 2017<br>
> @@ -445,14 +445,13 @@ static RelExpr fromPlt(RelExpr Expr) {<br>
>  // Returns true if a given shared symbol is in a read-only segment in a DSO.<br>
>  template <class ELFT> static bool isReadOnly(SharedSymbol *SS) {<br>
>    typedef typename ELFT::Phdr Elf_Phdr;<br>
> -  uint64_t Value = SS->getValue<ELFT>();<br>
><br>
>    // Determine if the symbol is read-only by scanning the DSO's program headers.<br>
>    const SharedFile<ELFT> *File = SS->getFile<ELFT>();<br>
>    for (const Elf_Phdr &Phdr : check(File->getObj().program_<wbr>headers()))<br>
>      if ((Phdr.p_type == ELF::PT_LOAD || Phdr.p_type == ELF::PT_GNU_RELRO) &&<br>
> -        !(Phdr.p_flags & ELF::PF_W) && Value >= Phdr.p_vaddr &&<br>
> -        Value < Phdr.p_vaddr + Phdr.p_memsz)<br>
> +        !(Phdr.p_flags & ELF::PF_W) && SS->Value >= Phdr.p_vaddr &&<br>
> +        SS->Value < Phdr.p_vaddr + Phdr.p_memsz)<br>
>        return true;<br>
>    return false;<br>
>  }<br>
> @@ -467,12 +466,10 @@ static std::vector<SharedSymbol *> getSy<br>
>    typedef typename ELFT::Sym Elf_Sym;<br>
><br>
>    SharedFile<ELFT> *File = SS->getFile<ELFT>();<br>
> -  uint64_t Shndx = SS->getShndx<ELFT>();<br>
> -  uint64_t Value = SS->getValue<ELFT>();<br>
><br>
>    std::vector<SharedSymbol *> Ret;<br>
>    for (const Elf_Sym &S : File->getGlobalELFSyms()) {<br>
> -    if (S.st_shndx != Shndx || S.st_value != Value)<br>
> +    if (S.st_shndx != SS->Shndx || S.st_value != SS->Value)<br>
>        continue;<br>
>      StringRef Name = check(S.getName(File-><wbr>getStringTable()));<br>
>      SymbolBody *Sym = Symtab->find(Name);<br>
> @@ -526,7 +523,7 @@ static std::vector<SharedSymbol *> getSy<br>
>  // define an accessor getV().<br>
>  template <class ELFT> static void addCopyRelSymbol(SharedSymbol *SS) {<br>
>    // Copy relocation against zero-sized symbol doesn't make sense.<br>
> -  uint64_t SymSize = SS->template getSize<ELFT>();<br>
> +  uint64_t SymSize = SS->getSize();<br>
>    if (SymSize == 0)<br>
>      fatal("cannot create a copy relocation for symbol " + toString(*SS));<br>
><br>
> @@ -534,7 +531,7 @@ template <class ELFT> static void addCop<br>
>    // memory protection by reserving space in the .<a href="http://bss.rel.ro" rel="noreferrer" target="_blank">bss.rel.ro</a> section.<br>
>    bool IsReadOnly = isReadOnly<ELFT>(SS);<br>
>    BssSection *Sec = make<BssSection>(IsReadOnly ? ".<a href="http://bss.rel.ro" rel="noreferrer" target="_blank">bss.rel.ro</a>" : ".bss",<br>
> -                                     SymSize, SS->getAlignment<ELFT>());<br>
> +                                     SymSize, SS->Alignment);<br>
>    if (IsReadOnly)<br>
>      InX::BssRelRo->getParent()-><wbr>addSection(Sec);<br>
>    else<br>
> @@ -1014,7 +1011,7 @@ static void scanRelocs(InputSectionBase<br>
><br>
>      // The size is not going to change, so we fold it in here.<br>
>      if (Expr == R_SIZE)<br>
> -      Addend += Body.getSize<ELFT>();<br>
> +      Addend += Body.getSize();<br>
><br>
>      // If the produced value is a constant, we just remember to write it<br>
>      // when outputting this section. We also have to do it if the format<br>
><br>
> Modified: lld/trunk/ELF/SymbolTable.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SymbolTable.cpp?rev=316841&r1=316840&r2=316841&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/lld/trunk/ELF/<wbr>SymbolTable.cpp?rev=316841&r1=<wbr>316840&r2=316841&view=diff</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- lld/trunk/ELF/SymbolTable.cpp (original)<br>
> +++ lld/trunk/ELF/SymbolTable.cpp Sat Oct 28 13:15:56 2017<br>
> @@ -498,7 +498,7 @@ Symbol *SymbolTable::addRegular(<wbr>StringRe<br>
><br>
>  template <typename ELFT><br>
>  void SymbolTable::addShared(<wbr>StringRef Name, SharedFile<ELFT> *File,<br>
> -                            const typename ELFT::Sym &Sym,<br>
> +                            const typename ELFT::Sym &Sym, uint32_t Alignment,<br>
>                              const typename ELFT::Verdef *Verdef) {<br>
>    // DSO symbols do not affect visibility in the output, so we pass STV_DEFAULT<br>
>    // as the visibility, which will leave the visibility in the symbol table<br>
> @@ -516,8 +516,9 @@ void SymbolTable::addShared(<wbr>StringRef Na<br>
>    // in the same DSO.<br>
>    if (WasInserted || ((Body->isUndefined() || Body->isLazy()) &&<br>
>                        Body->getVisibility() == STV_DEFAULT)) {<br>
> -    replaceBody<SharedSymbol>(S, File, Name, Sym.st_other, Sym.getType(), &Sym,<br>
> -                              Verdef);<br>
> +    replaceBody<SharedSymbol>(S, File, Name, Sym.st_other, Sym.getType(),<br>
> +                              Sym.st_value, Sym.st_size, Alignment,<br>
> +                              Sym.st_shndx, Verdef);<br>
>      if (!S->isWeak())<br>
>        File->IsUsed = true;<br>
>    }<br>
> @@ -881,15 +882,19 @@ template void SymbolTable::addLazyObject<br>
><br>
>  template void SymbolTable::addShared<<wbr>ELF32LE>(StringRef, SharedFile<ELF32LE> *,<br>
>                                                const typename ELF32LE::Sym &,<br>
> +                                              uint32_t Alignment,<br>
>                                                const typename ELF32LE::Verdef *);<br>
>  template void SymbolTable::addShared<<wbr>ELF32BE>(StringRef, SharedFile<ELF32BE> *,<br>
>                                                const typename ELF32BE::Sym &,<br>
> +                                              uint32_t Alignment,<br>
>                                                const typename ELF32BE::Verdef *);<br>
>  template void SymbolTable::addShared<<wbr>ELF64LE>(StringRef, SharedFile<ELF64LE> *,<br>
>                                                const typename ELF64LE::Sym &,<br>
> +                                              uint32_t Alignment,<br>
>                                                const typename ELF64LE::Verdef *);<br>
>  template void SymbolTable::addShared<<wbr>ELF64BE>(StringRef, SharedFile<ELF64BE> *,<br>
>                                                const typename ELF64BE::Sym &,<br>
> +                                              uint32_t Alignment,<br>
>                                                const typename ELF64BE::Verdef *);<br>
><br>
>  template void SymbolTable::fetchIfLazy<<wbr>ELF32LE>(StringRef);<br>
><br>
> Modified: lld/trunk/ELF/SymbolTable.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SymbolTable.h?rev=316841&r1=316840&r2=316841&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/lld/trunk/ELF/<wbr>SymbolTable.h?rev=316841&r1=<wbr>316840&r2=316841&view=diff</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- lld/trunk/ELF/SymbolTable.h (original)<br>
> +++ lld/trunk/ELF/SymbolTable.h Sat Oct 28 13:15:56 2017<br>
> @@ -60,7 +60,7 @@ public:<br>
><br>
>    template <class ELFT><br>
>    void addShared(StringRef Name, SharedFile<ELFT> *F,<br>
> -                 const typename ELFT::Sym &Sym,<br>
> +                 const typename ELFT::Sym &Sym, uint32_t Alignment,<br>
>                   const typename ELFT::Verdef *Verdef);<br>
><br>
>    template <class ELFT><br>
><br>
> Modified: lld/trunk/ELF/Symbols.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Symbols.cpp?rev=316841&r1=316840&r2=316841&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/lld/trunk/ELF/Symbols.<wbr>cpp?rev=316841&r1=316840&r2=<wbr>316841&view=diff</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- lld/trunk/ELF/Symbols.cpp (original)<br>
> +++ lld/trunk/ELF/Symbols.cpp Sat Oct 28 13:15:56 2017<br>
> @@ -174,13 +174,13 @@ uint64_t SymbolBody::getPltVA() const {<br>
>           PltIndex * Target->PltEntrySize;<br>
>  }<br>
><br>
> -template <class ELFT> typename ELFT::uint SymbolBody::getSize() const {<br>
> +uint64_t SymbolBody::getSize() const {<br>
>    if (const auto *C = dyn_cast<DefinedCommon>(this))<br>
>      return C->Size;<br>
>    if (const auto *DR = dyn_cast<DefinedRegular>(this)<wbr>)<br>
>      return DR->Size;<br>
>    if (const auto *S = dyn_cast<SharedSymbol>(this))<br>
> -    return S->getSize<ELFT>();<br>
> +    return S->Size;<br>
>    return 0;<br>
>  }<br>
><br>
> @@ -261,17 +261,6 @@ template <class ELFT> bool DefinedRegula<br>
>           (Hdr->e_flags & EF_MIPS_PIC);<br>
>  }<br>
><br>
> -// If a shared symbol is referred via a copy relocation, its alignment<br>
> -// becomes part of the ABI. This function returns a symbol alignment.<br>
> -// Because symbols don't have alignment attributes, we need to infer that.<br>
> -template <class ELFT> uint32_t SharedSymbol::getAlignment() const {<br>
> -  SharedFile<ELFT> *File = getFile<ELFT>();<br>
> -  uint32_t SecAlign = File->getSection(getSym<ELFT>(<wbr>))->sh_addralign;<br>
> -  uint64_t SymValue = getSym<ELFT>().st_value;<br>
> -  uint32_t SymAlign = uint32_t(1) << countTrailingZeros(SymValue);<br>
> -  return std::min(SecAlign, SymAlign);<br>
> -}<br>
> -<br>
>  InputFile *Lazy::fetch() {<br>
>    if (auto *S = dyn_cast<LazyArchive>(this))<br>
>      return S->fetch();<br>
> @@ -346,17 +335,7 @@ std::string lld::toString(const SymbolBo<br>
>    return B.getName();<br>
>  }<br>
><br>
> -template uint32_t SymbolBody::template getSize<ELF32LE>() const;<br>
> -template uint32_t SymbolBody::template getSize<ELF32BE>() const;<br>
> -template uint64_t SymbolBody::template getSize<ELF64LE>() const;<br>
> -template uint64_t SymbolBody::template getSize<ELF64BE>() const;<br>
> -<br>
>  template bool DefinedRegular::template isMipsPIC<ELF32LE>() const;<br>
>  template bool DefinedRegular::template isMipsPIC<ELF32BE>() const;<br>
>  template bool DefinedRegular::template isMipsPIC<ELF64LE>() const;<br>
>  template bool DefinedRegular::template isMipsPIC<ELF64BE>() const;<br>
> -<br>
> -template uint32_t SharedSymbol::template getAlignment<ELF32LE>() const;<br>
> -template uint32_t SharedSymbol::template getAlignment<ELF32BE>() const;<br>
> -template uint32_t SharedSymbol::template getAlignment<ELF64LE>() const;<br>
> -template uint32_t SharedSymbol::template getAlignment<ELF64BE>() const;<br>
><br>
> Modified: lld/trunk/ELF/Symbols.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Symbols.h?rev=316841&r1=316840&r2=316841&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/lld/trunk/ELF/Symbols.<wbr>h?rev=316841&r1=316840&r2=<wbr>316841&view=diff</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- lld/trunk/ELF/Symbols.h (original)<br>
> +++ lld/trunk/ELF/Symbols.h Sat Oct 28 13:15:56 2017<br>
> @@ -93,7 +93,7 @@ public:<br>
>    uint64_t getGotPltOffset() const;<br>
>    uint64_t getGotPltVA() const;<br>
>    uint64_t getPltVA() const;<br>
> -  template <class ELFT> typename ELFT::uint getSize() const;<br>
> +  uint64_t getSize() const;<br>
>    OutputSection *getOutputSection() const;<br>
><br>
>    uint32_t DynsymIndex = 0;<br>
> @@ -218,10 +218,12 @@ class SharedSymbol : public Defined {<br>
>  public:<br>
>    static bool classof(const SymbolBody *S) { return S->kind() == SharedKind; }<br>
><br>
> -  SharedSymbol(StringRef Name, uint8_t StOther, uint8_t Type,<br>
> -               const void *ElfSym, const void *Verdef)<br>
> +  SharedSymbol(StringRef Name, uint8_t StOther, uint8_t Type, uint64_t Value,<br>
> +               uint64_t Size, uint32_t Alignment, uint64_t Shndx,<br>
> +               const void *Verdef)<br>
>        : Defined(SharedKind, Name, /*IsLocal=*/false, StOther, Type),<br>
> -        Verdef(Verdef), ElfSym(ElfSym) {<br>
> +        Verdef(Verdef), Value(Value), Size(Size), Shndx(Shndx),<br>
> +        Alignment(Alignment) {<br>
>      // GNU ifunc is a mechanism to allow user-supplied functions to<br>
>      // resolve PLT slot values at load-time. This is contrary to the<br>
>      // regualr symbol resolution scheme in which symbols are resolved just<br>
> @@ -246,18 +248,6 @@ public:<br>
>      return cast<SharedFile<ELFT>>(<wbr>SymbolBody::getFile());<br>
>    }<br>
><br>
> -  template <class ELFT> uint64_t getShndx() const {<br>
> -    return getSym<ELFT>().st_shndx;<br>
> -  }<br>
> -<br>
> -  template <class ELFT> uint64_t getValue() const {<br>
> -    return getSym<ELFT>().st_value;<br>
> -  }<br>
> -<br>
> -  template <class ELFT> uint64_t getSize() const {<br>
> -    return getSym<ELFT>().st_size;<br>
> -  }<br>
> -<br>
>    template <class ELFT> uint32_t getAlignment() const;<br>
><br>
>    // This field is a pointer to the symbol's version definition.<br>
> @@ -266,12 +256,10 @@ public:<br>
>    // If not null, there is a copy relocation to this section.<br>
>    InputSection *CopyRelSec = nullptr;<br>
><br>
> -private:<br>
> -  template <class ELFT> const typename ELFT::Sym &getSym() const {<br>
> -    return *(const typename ELFT::Sym *)ElfSym;<br>
> -  }<br>
> -<br>
> -  const void *ElfSym;<br>
> +  uint64_t Value; // st_value<br>
> +  uint64_t Size;  // st_size<br>
> +  uint64_t Shndx; // st_shndx<br>
> +  uint32_t Alignment;<br>
>  };<br>
><br>
>  // This represents a symbol that is not yet in the link, but we know where to<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=316841&r1=316840&r2=316841&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/lld/trunk/ELF/<wbr>SyntheticSections.cpp?rev=<wbr>316841&r1=316840&r2=316841&<wbr>view=diff</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- lld/trunk/ELF/<wbr>SyntheticSections.cpp (original)<br>
> +++ lld/trunk/ELF/<wbr>SyntheticSections.cpp Sat Oct 28 13:15:56 2017<br>
> @@ -82,7 +82,7 @@ template <class ELFT> void elf::createCo<br>
>      // don't have to care about DefinedCommon symbols beyond this point.<br>
>      replaceBody<DefinedRegular>(S, Sym->getFile(), Sym->getName(),<br>
>                                  static_cast<bool>(Sym-><wbr>isLocal()), Sym->StOther,<br>
> -                                Sym->Type, 0, Sym->getSize<ELFT>(), Section);<br>
> +                                Sym->Type, 0, Sym->getSize(), Section);<br>
>    }<br>
>  }<br>
><br>
> @@ -1615,7 +1615,7 @@ template <class ELFT> void SymbolTableSe<br>
>      if (ESym->st_shndx == SHN_UNDEF)<br>
>        ESym->st_size = 0;<br>
>      else<br>
> -      ESym->st_size = Body->getSize<ELFT>();<br>
> +      ESym->st_size = Body->getSize();<br>
><br>
>      // st_value is usually an address of a symbol, but that has a<br>
>      // special meaining for uninstantiated common symbols (this can<br>
><br>
> Modified: lld/trunk/ELF/Writer.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=316841&r1=316840&r2=316841&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/lld/trunk/ELF/Writer.<wbr>cpp?rev=316841&r1=316840&r2=<wbr>316841&view=diff</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- lld/trunk/ELF/Writer.cpp (original)<br>
> +++ lld/trunk/ELF/Writer.cpp Sat Oct 28 13:15:56 2017<br>
> @@ -248,7 +248,7 @@ template <class ELFT> void Writer<ELFT>:<br>
>      return;<br>
><br>
>    // Handle -Map option.<br>
> -  writeMapFile<ELFT>();<br>
> +  writeMapFile();<br>
>    if (errorCount())<br>
>      return;<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>
</div></div></blockquote></div><br></div></div>