[PATCH] D27648: COFF: Use a bit in SymbolBody to track which symbols are written to the symbol table.

Peter Collingbourne via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Dec 11 14:25:49 PST 2016


This revision was automatically updated to reflect the committed changes.
Closed by commit rL289408: COFF: Use a bit in SymbolBody to track which symbols are written to the symbol… (authored by pcc).

Changed prior to commit:
  https://reviews.llvm.org/D27648?vs=80987&id=81036#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D27648

Files:
  lld/trunk/COFF/Symbols.h
  lld/trunk/COFF/Writer.cpp


Index: lld/trunk/COFF/Symbols.h
===================================================================
--- lld/trunk/COFF/Symbols.h
+++ lld/trunk/COFF/Symbols.h
@@ -80,7 +80,7 @@
   friend SymbolTable;
   explicit SymbolBody(Kind K, StringRef N = "")
       : SymbolKind(K), IsExternal(true), IsCOMDAT(false),
-        IsReplaceable(false), Name(N) {}
+        IsReplaceable(false), WrittenToSymtab(false), Name(N) {}
 
   const unsigned SymbolKind : 8;
   unsigned IsExternal : 1;
@@ -91,6 +91,11 @@
   // This bit is used by the \c DefinedBitcode subclass.
   unsigned IsReplaceable : 1;
 
+public:
+  // This bit is used by Writer::createSymbolAndStringTable().
+  unsigned WrittenToSymtab : 1;
+
+protected:
   StringRef Name;
 };
 
Index: lld/trunk/COFF/Writer.cpp
===================================================================
--- lld/trunk/COFF/Writer.cpp
+++ lld/trunk/COFF/Writer.cpp
@@ -533,13 +533,14 @@
     Sec->setStringTableOff(addEntryToStringTable(Name));
   }
 
-  std::set<SymbolBody *> SeenSymbols;
   for (lld::coff::ObjectFile *File : Symtab->ObjectFiles)
     for (SymbolBody *B : File->getSymbols())
       if (auto *D = dyn_cast<Defined>(B))
-        if (SeenSymbols.insert(D).second)
+        if (!D->WrittenToSymtab) {
+          D->WrittenToSymtab = true;
           if (Optional<coff_symbol16> Sym = createSymbol(D))
             OutputSymtab.push_back(*Sym);
+        }
 
   OutputSection *LastSection = OutputSections.back();
   // We position the symbol table to be adjacent to the end of the last section.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D27648.81036.patch
Type: text/x-patch
Size: 1541 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161211/a6445e87/attachment.bin>


More information about the llvm-commits mailing list