LTO: Simplify ownership of LTOCodeGenerator::TargetMach.
authorPeter Collingbourne <peter@pcc.me.uk>
Fri, 21 Aug 2015 04:45:57 +0000 (04:45 +0000)
committerPeter Collingbourne <peter@pcc.me.uk>
Fri, 21 Aug 2015 04:45:57 +0000 (04:45 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@245671 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/LTO/LTOCodeGenerator.h
lib/LTO/LTOCodeGenerator.cpp

index 695de5aa9946adde64efe4eafc270a78debe4c91..a7ccbceda4136e1a4fffb9522f87d4eb3b7d9a00 100644 (file)
@@ -159,7 +159,7 @@ private:
   std::unique_ptr<LLVMContext> OwnedContext;
   LLVMContext &Context;
   Linker IRLinker;
-  TargetMachine *TargetMach = nullptr;
+  std::unique_ptr<TargetMachine> TargetMach;
   bool EmitDwarfDebugInfo = false;
   bool ScopeRestrictionsDone = false;
   lto_codegen_model CodeModel = LTO_CODEGEN_PIC_MODEL_DEFAULT;
index fdf3f3a2b891ffda37da1b499f167d6897414c89..6203000c2ec39ea9935195eb70ab0e70e04c5077 100644 (file)
@@ -86,9 +86,6 @@ void LTOCodeGenerator::destroyMergedModule() {
 
 LTOCodeGenerator::~LTOCodeGenerator() {
   destroyMergedModule();
-
-  delete TargetMach;
-  TargetMach = nullptr;
 }
 
 // Initialize LTO passes. Please keep this funciton in sync with
@@ -352,9 +349,9 @@ bool LTOCodeGenerator::determineTarget(std::string &errMsg) {
     break;
   }
 
-  TargetMach = march->createTargetMachine(TripleStr, MCpu, FeatureStr, Options,
-                                          RelocModel, CodeModel::Default,
-                                          CGOptLevel);
+  TargetMach.reset(march->createTargetMachine(TripleStr, MCpu, FeatureStr,
+                                              Options, RelocModel,
+                                              CodeModel::Default, CGOptLevel));
   return true;
 }