[lld] r264770 - Make BitcodeCompiler::compile a non-template function. NFC.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 29 12:08:46 PDT 2016


Author: ruiu
Date: Tue Mar 29 14:08:46 2016
New Revision: 264770

URL: http://llvm.org/viewvc/llvm-project?rev=264770&view=rev
Log:
Make BitcodeCompiler::compile a non-template function. NFC.

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

Modified: lld/trunk/ELF/LTO.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LTO.cpp?rev=264770&r1=264769&r2=264770&view=diff
==============================================================================
--- lld/trunk/ELF/LTO.cpp (original)
+++ lld/trunk/ELF/LTO.cpp Tue Mar 29 14:08:46 2016
@@ -124,8 +124,7 @@ static void internalize(GlobalValue &GV)
 
 // Merge all the bitcode files we have seen, codegen the result
 // and return the resulting ObjectFile.
-template <class ELFT>
-std::unique_ptr<elf::ObjectFile<ELFT>> BitcodeCompiler::compile() {
+std::unique_ptr<InputFile> BitcodeCompiler::compile() {
   for (const auto &Name : InternalizedSyms) {
     GlobalValue *GV = Combined.getNamedValue(Name.first());
     assert(GV);
@@ -148,10 +147,7 @@ std::unique_ptr<elf::ObjectFile<ELFT>> B
                                   "LLD-INTERNAL-combined-lto-object", false);
   if (Config->SaveTemps)
     saveLtoObjectFile(MB->getBuffer());
-
-  std::unique_ptr<InputFile> IF = createObjectFile(*MB);
-  auto *OF = cast<ObjectFile<ELFT>>(IF.release());
-  return std::unique_ptr<ObjectFile<ELFT>>(OF);
+  return createObjectFile(*MB);
 }
 
 TargetMachine *BitcodeCompiler::getTargetMachine() {
@@ -164,8 +160,3 @@ TargetMachine *BitcodeCompiler::getTarge
   Reloc::Model R = Config->Pic ? Reloc::PIC_ : Reloc::Static;
   return T->createTargetMachine(TripleStr, "", "", Options, R);
 }
-
-template std::unique_ptr<elf::ObjectFile<ELF32LE>> BitcodeCompiler::compile();
-template std::unique_ptr<elf::ObjectFile<ELF32BE>> BitcodeCompiler::compile();
-template std::unique_ptr<elf::ObjectFile<ELF64LE>> BitcodeCompiler::compile();
-template std::unique_ptr<elf::ObjectFile<ELF64BE>> BitcodeCompiler::compile();

Modified: lld/trunk/ELF/LTO.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LTO.h?rev=264770&r1=264769&r2=264770&view=diff
==============================================================================
--- lld/trunk/ELF/LTO.h (original)
+++ lld/trunk/ELF/LTO.h Tue Mar 29 14:08:46 2016
@@ -32,12 +32,12 @@ namespace lld {
 namespace elf {
 
 class BitcodeFile;
-template <class ELFT> class ObjectFile;
+class InputFile;
 
 class BitcodeCompiler {
 public:
   void add(BitcodeFile &F);
-  template <class ELFT> std::unique_ptr<ObjectFile<ELFT>> compile();
+  std::unique_ptr<InputFile> compile();
 
 private:
   llvm::TargetMachine *getTargetMachine();

Modified: lld/trunk/ELF/SymbolTable.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SymbolTable.cpp?rev=264770&r1=264769&r2=264770&view=diff
==============================================================================
--- lld/trunk/ELF/SymbolTable.cpp (original)
+++ lld/trunk/ELF/SymbolTable.cpp Tue Mar 29 14:08:46 2016
@@ -101,7 +101,8 @@ template <class ELFT> void SymbolTable<E
   Lto.reset(new BitcodeCompiler);
   for (const std::unique_ptr<BitcodeFile> &F : BitcodeFiles)
     Lto->add(*F);
-  std::unique_ptr<ObjectFile<ELFT>> Obj = Lto->compile<ELFT>();
+  std::unique_ptr<InputFile> IF = Lto->compile();
+  ObjectFile<ELFT> *Obj = cast<ObjectFile<ELFT>>(IF.release());
 
   // Replace bitcode symbols.
   llvm::DenseSet<StringRef> DummyGroups;
@@ -113,7 +114,7 @@ template <class ELFT> void SymbolTable<E
       continue;
     Sym->Body = Body;
   }
-  ObjectFiles.push_back(std::move(Obj));
+  ObjectFiles.emplace_back(Obj);
 }
 
 // Add an undefined symbol.




More information about the llvm-commits mailing list