[lld] r265543 - Use a bit in SymbolBody to store CanKeepUndefined.

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 6 07:31:04 PDT 2016


Author: rafael
Date: Wed Apr  6 09:31:03 2016
New Revision: 265543

URL: http://llvm.org/viewvc/llvm-project?rev=265543&view=rev
Log:
Use a bit in SymbolBody to store CanKeepUndefined.

UndefinedElf for 64 bits goes from 72 to 64 bytes.

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

Modified: lld/trunk/ELF/Symbols.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Symbols.cpp?rev=265543&r1=265542&r2=265543&view=diff
==============================================================================
--- lld/trunk/ELF/Symbols.cpp (original)
+++ lld/trunk/ELF/Symbols.cpp Wed Apr  6 09:31:03 2016
@@ -89,15 +89,14 @@ static typename ELFT::uint getSymVA(cons
 
 SymbolBody::SymbolBody(Kind K, uint32_t NameOffset, uint8_t StOther,
                        uint8_t Type)
-    : SymbolKind(K), MustBeInDynSym(false), NeedsCopyOrPltAddr(false),
-      Type(Type), Binding(STB_LOCAL), StOther(StOther), NameOffset(NameOffset) {
+    : SymbolKind(K), Type(Type), Binding(STB_LOCAL), StOther(StOther),
+      NameOffset(NameOffset) {
   init();
 }
 
 SymbolBody::SymbolBody(Kind K, StringRef Name, uint8_t Binding, uint8_t StOther,
                        uint8_t Type)
-    : SymbolKind(K), MustBeInDynSym(false), NeedsCopyOrPltAddr(false),
-      Type(Type), Binding(Binding), StOther(StOther),
+    : SymbolKind(K), Type(Type), Binding(Binding), StOther(StOther),
       Name({Name.data(), Name.size()}) {
   assert(!isLocal());
   init();
@@ -107,6 +106,9 @@ void SymbolBody::init() {
   Kind K = kind();
   IsUsedInRegularObj = K == DefinedRegularKind || K == DefinedCommonKind ||
                        K == DefinedSyntheticKind || K == UndefinedElfKind;
+  CanKeepUndefined = false;
+  MustBeInDynSym = false;
+  NeedsCopyOrPltAddr = false;
 }
 
 // Returns true if a symbol can be replaced at load-time by a symbol
@@ -267,8 +269,9 @@ template <typename ELFT>
 UndefinedElf<ELFT>::UndefinedElf(StringRef Name, uint8_t Binding,
                                  uint8_t StOther, uint8_t Type,
                                  bool CanKeepUndefined)
-    : SymbolBody(SymbolBody::UndefinedElfKind, Name, Binding, StOther, Type),
-      CanKeepUndefined(CanKeepUndefined) {}
+    : SymbolBody(SymbolBody::UndefinedElfKind, Name, Binding, StOther, Type) {
+  this->CanKeepUndefined = CanKeepUndefined;
+}
 
 template <typename ELFT>
 UndefinedElf<ELFT>::UndefinedElf(const Elf_Sym &Sym)

Modified: lld/trunk/ELF/Symbols.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Symbols.h?rev=265543&r1=265542&r2=265543&view=diff
==============================================================================
--- lld/trunk/ELF/Symbols.h (original)
+++ lld/trunk/ELF/Symbols.h Wed Apr  6 09:31:03 2016
@@ -147,6 +147,8 @@ public:
   // symbol or if the symbol should point to its plt entry.
   unsigned NeedsCopyOrPltAddr : 1;
 
+  unsigned CanKeepUndefined : 1;
+
   // The following fields have the same meaning as the ELF symbol attributes.
   uint8_t Type;    // symbol type
   uint8_t Binding; // symbol binding
@@ -289,7 +291,6 @@ public:
 template <class ELFT> class UndefinedElf : public SymbolBody {
   typedef typename ELFT::uint uintX_t;
   typedef typename ELFT::Sym Elf_Sym;
-  bool CanKeepUndefined = false;
 
 public:
   UndefinedElf(StringRef N, const Elf_Sym &Sym);




More information about the llvm-commits mailing list