[lld] r251921 - Remove a redundant boolean.

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 3 06:34:11 PST 2015


Author: rafael
Date: Tue Nov  3 08:34:11 2015
New Revision: 251921

URL: http://llvm.org/viewvc/llvm-project?rev=251921&view=rev
Log:
Remove a redundant boolean.

Modified:
    lld/trunk/ELF/OutputSections.cpp
    lld/trunk/ELF/Symbols.h
    lld/trunk/ELF/Writer.cpp

Modified: lld/trunk/ELF/OutputSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.cpp?rev=251921&r1=251920&r2=251921&view=diff
==============================================================================
--- lld/trunk/ELF/OutputSections.cpp (original)
+++ lld/trunk/ELF/OutputSections.cpp Tue Nov  3 08:34:11 2015
@@ -650,7 +650,7 @@ typename ELFFile<ELFT>::uintX_t lld::elf
     return Out<ELFT>::Bss->getVA() + cast<DefinedCommon<ELFT>>(S).OffsetInBSS;
   case SymbolBody::SharedKind: {
     auto &SS = cast<SharedSymbol<ELFT>>(S);
-    if (SS.NeedsCopy)
+    if (SS.needsCopy())
       return Out<ELFT>::Bss->getVA() + SS.OffsetInBSS;
     return 0;
   }
@@ -1005,7 +1005,7 @@ void SymbolTableSection<ELFT>::writeGlob
       OutSec = Out<ELFT>::Bss;
       break;
     case SymbolBody::SharedKind: {
-      if (cast<SharedSymbol<ELFT>>(Body)->NeedsCopy)
+      if (cast<SharedSymbol<ELFT>>(Body)->needsCopy())
         OutSec = Out<ELFT>::Bss;
       break;
     }

Modified: lld/trunk/ELF/Symbols.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Symbols.h?rev=251921&r1=251920&r2=251921&view=diff
==============================================================================
--- lld/trunk/ELF/Symbols.h (original)
+++ lld/trunk/ELF/Symbols.h Tue Nov  3 08:34:11 2015
@@ -284,8 +284,8 @@ public:
   SharedFile<ELFT> *File;
 
   // Can have offset if requires copy relocation.
-  uintX_t OffsetInBSS = 0;
-  bool NeedsCopy = false;
+  uintX_t OffsetInBSS = -1;
+  bool needsCopy() const { return OffsetInBSS != (uintX_t)-1; }
 };
 
 // This class represents a symbol defined in an archive file. It is

Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=251921&r1=251920&r2=251921&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Tue Nov  3 08:34:11 2015
@@ -201,9 +201,10 @@ void Writer<ELFT>::scanRelocs(
     bool NeedsPlt = false;
     if (Body) {
       if (auto *E = dyn_cast<SharedSymbol<ELFT>>(Body)) {
-        if (E->NeedsCopy)
+        if (E->needsCopy())
           continue;
-        E->NeedsCopy = Target->relocNeedsCopy(Type, *Body);
+        if (Target->relocNeedsCopy(Type, *Body))
+          E->OffsetInBSS = 0;
       }
       NeedsPlt = Target->relocNeedsPlt(Type, *Body);
       if (NeedsPlt) {
@@ -535,7 +536,7 @@ template <class ELFT> void Writer<ELFT>:
     if (auto *C = dyn_cast<DefinedCommon<ELFT>>(Body))
       CommonSymbols.push_back(C);
     if (auto *SC = dyn_cast<SharedSymbol<ELFT>>(Body))
-      if (SC->NeedsCopy)
+      if (SC->needsCopy())
         SharedCopySymbols.push_back(SC);
 
     if (!includeInSymtab<ELFT>(*Body))




More information about the llvm-commits mailing list