[lld] r280226 - Delete DefinedBitcode.

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 31 05:30:35 PDT 2016


Author: rafael
Date: Wed Aug 31 07:30:34 2016
New Revision: 280226

URL: http://llvm.org/viewvc/llvm-project?rev=280226&view=rev
Log:
Delete DefinedBitcode.

Given that we almost always want to handle it as DefinedRegular, just
use DefinedRegular.

Modified:
    lld/trunk/ELF/LTO.cpp
    lld/trunk/ELF/OutputSections.cpp
    lld/trunk/ELF/SymbolTable.cpp
    lld/trunk/ELF/Symbols.cpp
    lld/trunk/ELF/Symbols.h

Modified: lld/trunk/ELF/LTO.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LTO.cpp?rev=280226&r1=280225&r2=280226&view=diff
==============================================================================
--- lld/trunk/ELF/LTO.cpp (original)
+++ lld/trunk/ELF/LTO.cpp Wed Aug 31 07:30:34 2016
@@ -201,8 +201,10 @@ void BitcodeCompiler::add(BitcodeFile &F
       handleUndefinedAsmRefs(Sym, GV, AsmUndefinedRefs);
       continue;
     }
-    auto *B = dyn_cast<DefinedBitcode>(S->body());
-    if (!B || B->file() != &F)
+    SymbolBody *B = S->body();
+    if (B->kind() != SymbolBody::DefinedRegularKind)
+      continue;
+    if (B->File != &F)
       continue;
 
     // We collect the set of symbols we want to internalize here

Modified: lld/trunk/ELF/OutputSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.cpp?rev=280226&r1=280225&r2=280226&view=diff
==============================================================================
--- lld/trunk/ELF/OutputSections.cpp (original)
+++ lld/trunk/ELF/OutputSections.cpp Wed Aug 31 07:30:34 2016
@@ -1474,8 +1474,6 @@ SymbolTableSection<ELFT>::getOutputSecti
   case SymbolBody::LazyArchiveKind:
   case SymbolBody::LazyObjectKind:
     break;
-  case SymbolBody::DefinedBitcodeKind:
-    llvm_unreachable("should have been replaced");
   }
   return nullptr;
 }

Modified: lld/trunk/ELF/SymbolTable.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SymbolTable.cpp?rev=280226&r1=280225&r2=280226&view=diff
==============================================================================
--- lld/trunk/ELF/SymbolTable.cpp (original)
+++ lld/trunk/ELF/SymbolTable.cpp Wed Aug 31 07:30:34 2016
@@ -471,7 +471,7 @@ Symbol *SymbolTable<ELFT>::addBitcode(St
              /*IsUsedInRegularObj*/ false, F);
   int Cmp = compareDefinedNonCommon<ELFT>(S, WasInserted, Binding);
   if (Cmp > 0)
-    replaceBody<DefinedBitcode>(S, Name, StOther, Type, F);
+    replaceBody<DefinedRegular<ELFT>>(S, Name, StOther, Type, F);
   else if (Cmp == 0)
     reportDuplicate(S->body(), F);
   return S;

Modified: lld/trunk/ELF/Symbols.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Symbols.cpp?rev=280226&r1=280225&r2=280226&view=diff
==============================================================================
--- lld/trunk/ELF/Symbols.cpp (original)
+++ lld/trunk/ELF/Symbols.cpp Wed Aug 31 07:30:34 2016
@@ -81,8 +81,6 @@ static typename ELFT::uint getSymVA(cons
   case SymbolBody::LazyObjectKind:
     assert(Body.symbol()->IsUsedInRegularObj && "lazy symbol reached writer");
     return 0;
-  case SymbolBody::DefinedBitcodeKind:
-    llvm_unreachable("should have been replaced");
   }
   llvm_unreachable("invalid symbol kind");
 }
@@ -192,16 +190,6 @@ Defined::Defined(Kind K, StringRef Name,
 Defined::Defined(Kind K, uint32_t NameOffset, uint8_t StOther, uint8_t Type)
     : SymbolBody(K, NameOffset, StOther, Type) {}
 
-DefinedBitcode::DefinedBitcode(StringRef Name, uint8_t StOther, uint8_t Type,
-                               BitcodeFile *F)
-    : Defined(DefinedBitcodeKind, Name, StOther, Type) {
-  this->File = F;
-}
-
-bool DefinedBitcode::classof(const SymbolBody *S) {
-  return S->kind() == DefinedBitcodeKind;
-}
-
 Undefined::Undefined(StringRef Name, uint8_t StOther, uint8_t Type,
                      InputFile *File)
     : SymbolBody(SymbolBody::UndefinedKind, Name, StOther, Type) {

Modified: lld/trunk/ELF/Symbols.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Symbols.h?rev=280226&r1=280225&r2=280226&view=diff
==============================================================================
--- lld/trunk/ELF/Symbols.h (original)
+++ lld/trunk/ELF/Symbols.h Wed Aug 31 07:30:34 2016
@@ -45,7 +45,6 @@ public:
     DefinedRegularKind = DefinedFirst,
     SharedKind,
     DefinedCommonKind,
-    DefinedBitcodeKind,
     DefinedSyntheticKind,
     DefinedLast = DefinedSyntheticKind,
     UndefinedKind,
@@ -159,14 +158,6 @@ public:
   static bool classof(const SymbolBody *S) { return S->isDefined(); }
 };
 
-// The defined symbol in LLVM bitcode files.
-class DefinedBitcode : public Defined {
-public:
-  DefinedBitcode(StringRef Name, uint8_t StOther, uint8_t Type, BitcodeFile *F);
-  static bool classof(const SymbolBody *S);
-  BitcodeFile *file() { return (BitcodeFile *)this->File; }
-};
-
 template <class ELFT> class DefinedCommon : public Defined {
 public:
   DefinedCommon(StringRef N, uint64_t Size, uint64_t Alignment, uint8_t StOther,
@@ -217,6 +208,12 @@ public:
                 llvm::ELF::STT_NOTYPE),
         Value(0), Size(0), Section(NullInputSection) {}
 
+  DefinedRegular(StringRef Name, uint8_t StOther, uint8_t Type, BitcodeFile *F)
+      : Defined(SymbolBody::DefinedRegularKind, Name, StOther, Type), Value(0),
+        Size(0), Section(NullInputSection) {
+    this->File = F;
+  }
+
   static bool classof(const SymbolBody *S) {
     return S->kind() == SymbolBody::DefinedRegularKind;
   }
@@ -439,11 +436,11 @@ struct Symbol {
   // large and aligned enough to store any derived class of SymbolBody. We
   // assume that the size and alignment of ELF64LE symbols is sufficient for any
   // ELFT, and we verify this with the static_asserts in replaceBody.
-  llvm::AlignedCharArrayUnion<
-      DefinedBitcode, DefinedCommon<llvm::object::ELF64LE>,
-      DefinedRegular<llvm::object::ELF64LE>,
-      DefinedSynthetic<llvm::object::ELF64LE>, Undefined,
-      SharedSymbol<llvm::object::ELF64LE>, LazyArchive, LazyObject>
+  llvm::AlignedCharArrayUnion<DefinedCommon<llvm::object::ELF64LE>,
+                              DefinedRegular<llvm::object::ELF64LE>,
+                              DefinedSynthetic<llvm::object::ELF64LE>,
+                              Undefined, SharedSymbol<llvm::object::ELF64LE>,
+                              LazyArchive, LazyObject>
       Body;
 
   SymbolBody *body() { return reinterpret_cast<SymbolBody *>(Body.buffer); }




More information about the llvm-commits mailing list