[lld] r289170 - COFF: Use make() in SymbolTable and Writer.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 8 18:13:12 PST 2016


Author: ruiu
Date: Thu Dec  8 20:13:12 2016
New Revision: 289170

URL: http://llvm.org/viewvc/llvm-project?rev=289170&view=rev
Log:
COFF: Use make() in SymbolTable and Writer.

Modified:
    lld/trunk/COFF/SymbolTable.cpp
    lld/trunk/COFF/SymbolTable.h
    lld/trunk/COFF/Writer.cpp

Modified: lld/trunk/COFF/SymbolTable.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/SymbolTable.cpp?rev=289170&r1=289169&r2=289170&view=diff
==============================================================================
--- lld/trunk/COFF/SymbolTable.cpp (original)
+++ lld/trunk/COFF/SymbolTable.cpp Thu Dec  8 20:13:12 2016
@@ -139,7 +139,7 @@ void SymbolTable::reportRemainingUndefin
         if (!Resolve)
           continue;
         auto *D = cast<Defined>(Imp->Body);
-        auto *S = new (Alloc) DefinedLocalImport(Name, D);
+        auto *S = make<DefinedLocalImport>(Name, D);
         LocalImportChunks.push_back(S->getChunk());
         Sym->Body = S;
         continue;
@@ -148,7 +148,7 @@ void SymbolTable::reportRemainingUndefin
     // Remaining undefined symbols are not fatal if /force is specified.
     // They are replaced with dummy defined symbols.
     if (Config->Force && Resolve)
-      Sym->Body = new (Alloc) DefinedAbsolute(Name, 0);
+      Sym->Body = make<DefinedAbsolute>(Name, 0);
     Undefs.insert(Sym->Body);
   }
   if (Undefs.empty())
@@ -223,7 +223,7 @@ Symbol *SymbolTable::insert(SymbolBody *
     New->setBackref(Sym);
     return Sym;
   }
-  Sym = new (Alloc) Symbol(New);
+  Sym = make<Symbol>(New);
   New->setBackref(Sym);
   return Sym;
 }
@@ -299,7 +299,7 @@ void SymbolTable::mangleMaybe(Undefined
 }
 
 Undefined *SymbolTable::addUndefined(StringRef Name) {
-  auto *New = new (Alloc) Undefined(Name);
+  auto *New = make<Undefined>(Name);
   addSymbol(New);
   if (auto *U = dyn_cast<Undefined>(New->repl()))
     return U;
@@ -307,13 +307,13 @@ Undefined *SymbolTable::addUndefined(Str
 }
 
 DefinedRelative *SymbolTable::addRelative(StringRef Name, uint64_t VA) {
-  auto *New = new (Alloc) DefinedRelative(Name, VA);
+  auto *New = make<DefinedRelative>(Name, VA);
   addSymbol(New);
   return New;
 }
 
 DefinedAbsolute *SymbolTable::addAbsolute(StringRef Name, uint64_t VA) {
-  auto *New = new (Alloc) DefinedAbsolute(Name, VA);
+  auto *New = make<DefinedAbsolute>(Name, VA);
   addSymbol(New);
   return New;
 }

Modified: lld/trunk/COFF/SymbolTable.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/SymbolTable.h?rev=289170&r1=289169&r2=289170&view=diff
==============================================================================
--- lld/trunk/COFF/SymbolTable.h (original)
+++ lld/trunk/COFF/SymbolTable.h Thu Dec  8 20:13:12 2016
@@ -119,7 +119,6 @@ private:
 
   std::vector<BitcodeFile *> BitcodeFiles;
   std::vector<SmallString<0>> Objs;
-  llvm::BumpPtrAllocator Alloc;
 };
 
 } // namespace coff

Modified: lld/trunk/COFF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Writer.cpp?rev=289170&r1=289169&r2=289170&view=diff
==============================================================================
--- lld/trunk/COFF/Writer.cpp (original)
+++ lld/trunk/COFF/Writer.cpp Thu Dec  8 20:13:12 2016
@@ -16,6 +16,7 @@
 #include "SymbolTable.h"
 #include "Symbols.h"
 #include "lld/Core/Parallel.h"
+#include "lld/Support/Memory.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringSwitch.h"
@@ -135,8 +136,6 @@ private:
 
   SymbolTable *Symtab;
   std::unique_ptr<FileOutputBuffer> Buffer;
-  SpecificBumpPtrAllocator<OutputSection> CAlloc;
-  SpecificBumpPtrAllocator<BaserelChunk> BAlloc;
   std::vector<OutputSection *> OutputSections;
   std::vector<char> Strtab;
   std::vector<llvm::object::coff_symbol16> OutputSymtab;
@@ -342,7 +341,7 @@ void Writer::createSections() {
     StringRef Name = getOutputSection(Pair.first);
     OutputSection *&Sec = Sections[Name];
     if (!Sec) {
-      Sec = new (CAlloc.Allocate()) OutputSection(Name);
+      Sec = make<OutputSection>(Name);
       OutputSections.push_back(Sec);
     }
     std::vector<Chunk *> &Chunks = Pair.second;
@@ -866,7 +865,7 @@ OutputSection *Writer::createSection(Str
                        .Default(0);
   if (!Perms)
     llvm_unreachable("unknown section name");
-  auto Sec = new (CAlloc.Allocate()) OutputSection(Name);
+  auto Sec = make<OutputSection>(Name);
   Sec->addPermissions(Perms);
   OutputSections.push_back(Sec);
   return Sec;
@@ -897,13 +896,11 @@ void Writer::addBaserelBlocks(OutputSect
     uint32_t P = V[J].RVA & Mask;
     if (P == Page)
       continue;
-    BaserelChunk *Buf = BAlloc.Allocate();
-    Dest->addChunk(new (Buf) BaserelChunk(Page, &V[I], &V[0] + J));
+    Dest->addChunk(make<BaserelChunk>(Page, &V[I], &V[0] + J));
     I = J;
     Page = P;
   }
   if (I == J)
     return;
-  BaserelChunk *Buf = BAlloc.Allocate();
-  Dest->addChunk(new (Buf) BaserelChunk(Page, &V[I], &V[0] + J));
+  Dest->addChunk(make<BaserelChunk>(Page, &V[I], &V[0] + J));
 }




More information about the llvm-commits mailing list