Make needsPlt a plain function instead of a template.

llvm-svn: 264267
diff --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp
index 79f5abb..5e00ae0 100644
--- a/lld/ELF/InputSection.cpp
+++ b/lld/ELF/InputSection.cpp
@@ -274,7 +274,7 @@
     if (Config->EMachine == EM_MIPS)
       PairedLoc = findMipsPairedReloc(Buf, &RI, Rels.end());
 
-    if (Target->needsPlt<ELFT>(Type, Body)) {
+    if (Target->needsPlt(Type, Body)) {
       SymVA = Body.getPltVA<ELFT>() + A;
     } else if (Target->needsGot(Type, Body)) {
       if (Config->EMachine == EM_MIPS)
diff --git a/lld/ELF/Symbols.cpp b/lld/ELF/Symbols.cpp
index ad33420..3ea7ceb 100644
--- a/lld/ELF/Symbols.cpp
+++ b/lld/ELF/Symbols.cpp
@@ -112,12 +112,6 @@
   return true;
 }
 
-template <class ELFT> bool SymbolBody::isGnuIfunc() const {
-  if (auto *D = dyn_cast<DefinedElf<ELFT>>(this))
-    return D->Sym.getType() == STT_GNU_IFUNC;
-  return false;
-}
-
 template <class ELFT>
 typename ELFT::uint SymbolBody::getVA(typename ELFT::uint Addend) const {
   typename ELFT::uint OutVA = getSymVA<ELFT>(*this, Addend);
@@ -279,11 +273,6 @@
 #endif
 }
 
-template bool SymbolBody::template isGnuIfunc<ELF32LE>() const;
-template bool SymbolBody::template isGnuIfunc<ELF32BE>() const;
-template bool SymbolBody::template isGnuIfunc<ELF64LE>() const;
-template bool SymbolBody::template isGnuIfunc<ELF64BE>() const;
-
 template uint32_t SymbolBody::template getVA<ELF32LE>(uint32_t) const;
 template uint32_t SymbolBody::template getVA<ELF32BE>(uint32_t) const;
 template uint64_t SymbolBody::template getVA<ELF64LE>(uint64_t) const;
diff --git a/lld/ELF/Symbols.h b/lld/ELF/Symbols.h
index d6bd0eb..c314357 100644
--- a/lld/ELF/Symbols.h
+++ b/lld/ELF/Symbols.h
@@ -74,7 +74,6 @@
   bool isLocal() const { return IsLocal; }
   bool isUsedInRegularObj() const { return IsUsedInRegularObj; }
   bool isPreemptible() const;
-  template <class ELFT> bool isGnuIfunc() const;
 
   // Returns the symbol name.
   StringRef getName() const { return Name; }
@@ -120,6 +119,7 @@
         MustBeInDynSym(false), NeedsCopyOrPltAddr(false), Name(Name) {
     IsFunc = Type == llvm::ELF::STT_FUNC;
     IsTls = Type == llvm::ELF::STT_TLS;
+    IsGnuIFunc = Type == llvm::ELF::STT_GNU_IFUNC;
     IsUsedInRegularObj = K != SharedKind && K != LazyKind;
   }
 
@@ -144,6 +144,7 @@
 
   unsigned IsTls : 1;
   unsigned IsFunc : 1;
+  unsigned IsGnuIFunc : 1;
 
 protected:
   StringRef Name;
diff --git a/lld/ELF/Target.cpp b/lld/ELF/Target.cpp
index 464738b..d079570 100644
--- a/lld/ELF/Target.cpp
+++ b/lld/ELF/Target.cpp
@@ -300,10 +300,9 @@
 
 bool TargetInfo::refersToGotEntry(uint32_t Type) const { return false; }
 
-template <class ELFT>
 TargetInfo::PltNeed TargetInfo::needsPlt(uint32_t Type,
                                          const SymbolBody &S) const {
-  if (S.isGnuIfunc<ELFT>())
+  if (S.IsGnuIFunc)
     return Plt_Explicit;
   if (S.isPreemptible() && needsPltImpl(Type))
     return Plt_Explicit;
@@ -329,9 +328,8 @@
   // that points to the real function is a dedicated got entry used by the
   // plt. That is identified by special relocation types (R_X86_64_JUMP_SLOT,
   // R_386_JMP_SLOT, etc).
-  if (auto *SS = dyn_cast<SharedSymbol<ELFT>>(&S))
-    if (!Config->Pic && SS->Sym.getType() == STT_FUNC &&
-        !refersToGotEntry(Type))
+  if (S.isShared())
+    if (!Config->Pic && S.IsFunc && !refersToGotEntry(Type))
       return Plt_Implicit;
 
   return Plt_No;
@@ -500,7 +498,7 @@
     return Target->canRelaxTls(Type, &S) && S.isPreemptible();
   if (Type == R_386_TLS_GOTIE || Type == R_386_TLS_IE)
     return !canRelaxTls(Type, &S);
-  return Type == R_386_GOT32 || needsPlt<ELF32LE>(Type, S);
+  return Type == R_386_GOT32 || needsPlt(Type, S);
 }
 
 bool X86TargetInfo::needsPltImpl(uint32_t Type) const {
@@ -757,7 +755,7 @@
     return Target->canRelaxTls(Type, &S) && S.isPreemptible();
   if (Type == R_X86_64_GOTTPOFF)
     return !canRelaxTls(Type, &S);
-  return refersToGotEntry(Type) || needsPlt<ELF64LE>(Type, S);
+  return refersToGotEntry(Type) || needsPlt(Type, S);
 }
 
 uint32_t X86_64TargetInfo::getTlsGotRel(uint32_t Type) const {
@@ -1061,7 +1059,7 @@
 }
 
 bool PPC64TargetInfo::needsGot(uint32_t Type, SymbolBody &S) const {
-  if (needsPlt<ELF64BE>(Type, S))
+  if (needsPlt(Type, S))
     return true;
 
   switch (Type) {
@@ -1334,7 +1332,7 @@
   case R_AARCH64_LD64_GOT_LO12_NC:
     return true;
   default:
-    return needsPlt<ELF64LE>(Type, S);
+    return needsPlt(Type, S);
   }
 }
 
@@ -1675,7 +1673,7 @@
 
 template <class ELFT>
 bool MipsTargetInfo<ELFT>::needsGot(uint32_t Type, SymbolBody &S) const {
-  return needsPlt<ELFT>(Type, S) || refersToGotEntry(Type);
+  return needsPlt(Type, S) || refersToGotEntry(Type);
 }
 
 template <class ELFT>
@@ -1830,14 +1828,5 @@
                                                 const SymbolBody &) const;
 template bool TargetInfo::needsCopyRel<ELF64BE>(uint32_t,
                                                 const SymbolBody &) const;
-
-template TargetInfo::PltNeed
-TargetInfo::needsPlt<ELF32LE>(uint32_t, const SymbolBody &) const;
-template TargetInfo::PltNeed
-TargetInfo::needsPlt<ELF32BE>(uint32_t, const SymbolBody &) const;
-template TargetInfo::PltNeed
-TargetInfo::needsPlt<ELF64LE>(uint32_t, const SymbolBody &) const;
-template TargetInfo::PltNeed
-TargetInfo::needsPlt<ELF64BE>(uint32_t, const SymbolBody &) const;
 }
 }
diff --git a/lld/ELF/Target.h b/lld/ELF/Target.h
index 60388f7..75c2ea2 100644
--- a/lld/ELF/Target.h
+++ b/lld/ELF/Target.h
@@ -59,7 +59,6 @@
   virtual bool refersToGotEntry(uint32_t Type) const;
 
   enum PltNeed { Plt_No, Plt_Explicit, Plt_Implicit };
-  template <class ELFT>
   PltNeed needsPlt(uint32_t Type, const SymbolBody &S) const;
 
   virtual void relocateOne(uint8_t *Loc, uint8_t *BufEnd, uint32_t Type,
diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
index f0177af..2048a8e 100644
--- a/lld/ELF/Writer.cpp
+++ b/lld/ELF/Writer.cpp
@@ -359,7 +359,7 @@
     // An STT_GNU_IFUNC symbol always uses a PLT entry, and all references
     // to the symbol go through the PLT. This is true even for a local
     // symbol, although local symbols normally do not require PLT entries.
-    if (Body.isGnuIfunc<ELFT>()) {
+    if (Body.IsGnuIFunc) {
       if (Body.isInPlt())
         continue;
       Out<ELFT>::Plt->addEntry(Body);
@@ -379,7 +379,7 @@
 
     // If a relocation needs PLT, we create a PLT and a GOT slot
     // for the symbol.
-    TargetInfo::PltNeed NeedPlt = Target->needsPlt<ELFT>(Type, Body);
+    TargetInfo::PltNeed NeedPlt = Target->needsPlt(Type, Body);
     if (NeedPlt) {
       if (NeedPlt == TargetInfo::Plt_Implicit)
         Body.NeedsCopyOrPltAddr = true;