[lld] r259128 - Rename isTlsOptimized -> canRelaxTls.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 28 16:20:12 PST 2016


Author: ruiu
Date: Thu Jan 28 18:20:12 2016
New Revision: 259128

URL: http://llvm.org/viewvc/llvm-project?rev=259128&view=rev
Log:
Rename isTlsOptimized -> canRelaxTls.

This function is a predicate that a given relocation can be relaxed.
The previous name implied that it returns true if a given relocation
has already been optimized away.

Modified:
    lld/trunk/ELF/InputSection.cpp
    lld/trunk/ELF/OutputSections.cpp
    lld/trunk/ELF/Target.cpp
    lld/trunk/ELF/Target.h
    lld/trunk/ELF/Writer.cpp

Modified: lld/trunk/ELF/InputSection.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputSection.cpp?rev=259128&r1=259127&r2=259128&view=diff
==============================================================================
--- lld/trunk/ELF/InputSection.cpp (original)
+++ lld/trunk/ELF/InputSection.cpp Thu Jan 28 18:20:12 2016
@@ -156,7 +156,7 @@ void InputSectionBase<ELFT>::relocate(ui
     auto NextRelocs = llvm::make_range(&RI, Rels.end());
 
     if (Target->isTlsLocalDynamicReloc(Type) &&
-        !Target->isTlsOptimized(Type, nullptr)) {
+        !Target->canRelaxTls(Type, nullptr)) {
       Target->relocateOne(BufLoc, BufEnd, Type, AddrLoc,
                           Out<ELFT>::Got->getLocalTlsIndexVA() +
                               getAddend<ELFT>(RI));
@@ -168,7 +168,7 @@ void InputSectionBase<ELFT>::relocate(ui
     if (SymIndex >= SymTab->sh_info)
       Body = File->getSymbolBody(SymIndex)->repl();
 
-    if (Target->isTlsOptimized(Type, Body)) {
+    if (Target->canRelaxTls(Type, Body)) {
       uintX_t SymVA;
       if (!Body)
         SymVA = getLocalRelTarget(*File, RI, 0);
@@ -207,7 +207,7 @@ void InputSectionBase<ELFT>::relocate(ui
     }
 
     if (Target->isTlsGlobalDynamicReloc(Type) &&
-        !Target->isTlsOptimized(Type, Body)) {
+        !Target->canRelaxTls(Type, Body)) {
       Target->relocateOne(BufLoc, BufEnd, Type, AddrLoc,
                           Out<ELFT>::Got->getGlobalDynAddr(*Body) +
                               getAddend<ELFT>(RI));

Modified: lld/trunk/ELF/OutputSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.cpp?rev=259128&r1=259127&r2=259128&view=diff
==============================================================================
--- lld/trunk/ELF/OutputSections.cpp (original)
+++ lld/trunk/ELF/OutputSections.cpp Thu Jan 28 18:20:12 2016
@@ -251,7 +251,7 @@ bool RelocationSection<ELFT>::applyTlsDy
   if (!Body || !Target->isTlsGlobalDynamicReloc(Type))
     return false;
 
-  if (Target->isTlsOptimized(Type, Body)) {
+  if (Target->canRelaxTls(Type, Body)) {
     P->setSymbolAndType(Body->DynamicSymbolTableIndex,
                         Target->getTlsGotReloc(), Config->Mips64EL);
     P->r_offset = Out<ELFT>::Got->getEntryAddr(*Body);

Modified: lld/trunk/ELF/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.cpp?rev=259128&r1=259127&r2=259128&view=diff
==============================================================================
--- lld/trunk/ELF/Target.cpp (original)
+++ lld/trunk/ELF/Target.cpp Thu Jan 28 18:20:12 2016
@@ -102,7 +102,7 @@ public:
   void relocateOne(uint8_t *Loc, uint8_t *BufEnd, uint32_t Type, uint64_t P,
                    uint64_t SA, uint64_t ZA = 0,
                    uint8_t *PairedLoc = nullptr) const override;
-  bool isTlsOptimized(unsigned Type, const SymbolBody *S) const override;
+  bool canRelaxTls(unsigned Type, const SymbolBody *S) const override;
   unsigned relocateTlsOptimize(uint8_t *Loc, uint8_t *BufEnd, uint32_t Type,
                                uint64_t P, uint64_t SA,
                                const SymbolBody *S) const override;
@@ -137,7 +137,7 @@ public:
                    uint64_t SA, uint64_t ZA = 0,
                    uint8_t *PairedLoc = nullptr) const override;
   bool isRelRelative(uint32_t Type) const override;
-  bool isTlsOptimized(unsigned Type, const SymbolBody *S) const override;
+  bool canRelaxTls(unsigned Type, const SymbolBody *S) const override;
   bool isSizeReloc(uint32_t Type) const override;
   unsigned relocateTlsOptimize(uint8_t *Loc, uint8_t *BufEnd, uint32_t Type,
                                uint64_t P, uint64_t SA,
@@ -274,7 +274,7 @@ TargetInfo *createTarget() {
 
 TargetInfo::~TargetInfo() {}
 
-bool TargetInfo::isTlsOptimized(unsigned Type, const SymbolBody *S) const {
+bool TargetInfo::canRelaxTls(unsigned Type, const SymbolBody *S) const {
   return false;
 }
 
@@ -400,9 +400,9 @@ bool X86TargetInfo::needsCopyRel(uint32_
 
 bool X86TargetInfo::relocNeedsGot(uint32_t Type, const SymbolBody &S) const {
   if (S.isTls() && Type == R_386_TLS_GD)
-    return Target->isTlsOptimized(Type, &S) && canBePreempted(&S, true);
+    return Target->canRelaxTls(Type, &S) && canBePreempted(&S, true);
   if (Type == R_386_TLS_GOTIE || Type == R_386_TLS_IE)
-    return !isTlsOptimized(Type, &S);
+    return !canRelaxTls(Type, &S);
   return Type == R_386_GOT32 || relocNeedsPlt(Type, S);
 }
 
@@ -467,7 +467,7 @@ void X86TargetInfo::relocateOne(uint8_t
   }
 }
 
-bool X86TargetInfo::isTlsOptimized(unsigned Type, const SymbolBody *S) const {
+bool X86TargetInfo::canRelaxTls(unsigned Type, const SymbolBody *S) const {
   if (Config->Shared || (S && !S->isTls()))
     return false;
   return Type == R_386_TLS_LDO_32 || Type == R_386_TLS_LDM ||
@@ -672,9 +672,9 @@ bool X86_64TargetInfo::needsCopyRel(uint
 
 bool X86_64TargetInfo::relocNeedsGot(uint32_t Type, const SymbolBody &S) const {
   if (Type == R_X86_64_TLSGD)
-    return Target->isTlsOptimized(Type, &S) && canBePreempted(&S, true);
+    return Target->canRelaxTls(Type, &S) && canBePreempted(&S, true);
   if (Type == R_X86_64_GOTTPOFF)
-    return !isTlsOptimized(Type, &S);
+    return !canRelaxTls(Type, &S);
   return Type == R_X86_64_GOTPCREL || relocNeedsPlt(Type, S);
 }
 
@@ -743,8 +743,7 @@ bool X86_64TargetInfo::isSizeReloc(uint3
   return Type == R_X86_64_SIZE32 || Type == R_X86_64_SIZE64;
 }
 
-bool X86_64TargetInfo::isTlsOptimized(unsigned Type,
-                                      const SymbolBody *S) const {
+bool X86_64TargetInfo::canRelaxTls(unsigned Type, const SymbolBody *S) const {
   if (Config->Shared || (S && !S->isTls()))
     return false;
   return Type == R_X86_64_TLSGD || Type == R_X86_64_TLSLD ||

Modified: lld/trunk/ELF/Target.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.h?rev=259128&r1=259127&r2=259128&view=diff
==============================================================================
--- lld/trunk/ELF/Target.h (original)
+++ lld/trunk/ELF/Target.h Thu Jan 28 18:20:12 2016
@@ -77,7 +77,7 @@ public:
                            uint64_t P, uint64_t SA, uint64_t ZA = 0,
                            uint8_t *PairedLoc = nullptr) const = 0;
   virtual bool isGotRelative(uint32_t Type) const;
-  virtual bool isTlsOptimized(unsigned Type, const SymbolBody *S) const;
+  virtual bool canRelaxTls(unsigned Type, const SymbolBody *S) const;
   virtual bool needsCopyRel(uint32_t Type, const SymbolBody &S) const;
   virtual unsigned relocateTlsOptimize(uint8_t *Loc, uint8_t *BufEnd,
                                        uint32_t Type, uint64_t P, uint64_t SA,

Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=259128&r1=259127&r2=259128&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Thu Jan 28 18:20:12 2016
@@ -201,7 +201,7 @@ template <class ELFT, class RelT>
 static bool handleTlsRelocation(unsigned Type, SymbolBody *Body,
                                 InputSectionBase<ELFT> &C, RelT &RI) {
   if (Target->isTlsLocalDynamicReloc(Type)) {
-    if (Target->isTlsOptimized(Type, nullptr))
+    if (Target->canRelaxTls(Type, nullptr))
       return true;
     if (Out<ELFT>::Got->addCurrentModuleTlsIndex())
       Out<ELFT>::RelaDyn->addReloc({&C, &RI});
@@ -212,7 +212,7 @@ static bool handleTlsRelocation(unsigned
     return false;
 
   if (Target->isTlsGlobalDynamicReloc(Type)) {
-    bool Opt = Target->isTlsOptimized(Type, Body);
+    bool Opt = Target->canRelaxTls(Type, Body);
     if (!Opt && Out<ELFT>::Got->addDynTlsEntry(Body)) {
       Out<ELFT>::RelaDyn->addReloc({&C, &RI});
       Out<ELFT>::RelaDyn->addReloc({nullptr, nullptr});




More information about the llvm-commits mailing list