[lld] r266009 - [LTO] Switch Module to std::unique_ptr<>.

Davide Italiano via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 11 15:39:51 PDT 2016


Author: davide
Date: Mon Apr 11 17:39:51 2016
New Revision: 266009

URL: http://llvm.org/viewvc/llvm-project?rev=266009&view=rev
Log:
[LTO] Switch Module to std::unique_ptr<>.

Differential Revision:   http://reviews.llvm.org/D18994

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

Modified: lld/trunk/ELF/LTO.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LTO.cpp?rev=266009&r1=266008&r2=266009&view=diff
==============================================================================
--- lld/trunk/ELF/LTO.cpp (original)
+++ lld/trunk/ELF/LTO.cpp Mon Apr 11 17:39:51 2016
@@ -140,23 +140,23 @@ static void internalize(GlobalValue &GV)
 // and return the resulting ObjectFile.
 std::unique_ptr<InputFile> BitcodeCompiler::compile() {
   for (const auto &Name : InternalizedSyms) {
-    GlobalValue *GV = Combined.getNamedValue(Name.first());
+    GlobalValue *GV = Combined->getNamedValue(Name.first());
     assert(GV);
     internalize(*GV);
   }
 
   if (Config->SaveTemps)
-    saveBCFile(Combined, ".lto.bc");
+    saveBCFile(*Combined, ".lto.bc");
 
   std::unique_ptr<TargetMachine> TM(getTargetMachine());
-  runLTOPasses(Combined, *TM);
+  runLTOPasses(*Combined, *TM);
 
   raw_svector_ostream OS(OwningData);
   legacy::PassManager CodeGenPasses;
   if (TM->addPassesToEmitFile(CodeGenPasses, OS,
                               TargetMachine::CGFT_ObjectFile))
     fatal("failed to setup codegen");
-  CodeGenPasses.run(Combined);
+  CodeGenPasses.run(*Combined);
   MB = MemoryBuffer::getMemBuffer(OwningData,
                                   "LLD-INTERNAL-combined-lto-object", false);
   if (Config->SaveTemps)
@@ -165,7 +165,7 @@ std::unique_ptr<InputFile> BitcodeCompil
 }
 
 TargetMachine *BitcodeCompiler::getTargetMachine() {
-  StringRef TripleStr = Combined.getTargetTriple();
+  StringRef TripleStr = Combined->getTargetTriple();
   std::string Msg;
   const Target *T = TargetRegistry::lookupTarget(TripleStr, Msg);
   if (!T)

Modified: lld/trunk/ELF/LTO.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LTO.h?rev=266009&r1=266008&r2=266009&view=diff
==============================================================================
--- lld/trunk/ELF/LTO.h (original)
+++ lld/trunk/ELF/LTO.h Mon Apr 11 17:39:51 2016
@@ -39,12 +39,15 @@ public:
   void add(BitcodeFile &F);
   std::unique_ptr<InputFile> compile();
 
+  BitcodeCompiler()
+      : Combined(new llvm::Module("ld-temp.o", Context)), Mover(*Combined) {}
+
 private:
   llvm::TargetMachine *getTargetMachine();
 
   llvm::LLVMContext Context;
-  llvm::Module Combined{"ld-temp.o", Context};
-  llvm::IRMover Mover{Combined};
+  std::unique_ptr<llvm::Module> Combined;
+  llvm::IRMover Mover;
   SmallString<0> OwningData;
   std::unique_ptr<MemoryBuffer> MB;
   llvm::StringSet<> InternalizedSyms;




More information about the llvm-commits mailing list