From 22df81e0874c538c89bf7c182c15fab559b350d0 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Fri, 21 Aug 2015 04:45:57 +0000 Subject: [PATCH] LTO: Simplify ownership of LTOCodeGenerator::TargetMach. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@245671 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/LTO/LTOCodeGenerator.h | 2 +- lib/LTO/LTOCodeGenerator.cpp | 9 +++------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/include/llvm/LTO/LTOCodeGenerator.h b/include/llvm/LTO/LTOCodeGenerator.h index 695de5aa994..a7ccbceda41 100644 --- a/include/llvm/LTO/LTOCodeGenerator.h +++ b/include/llvm/LTO/LTOCodeGenerator.h @@ -159,7 +159,7 @@ private: std::unique_ptr OwnedContext; LLVMContext &Context; Linker IRLinker; - TargetMachine *TargetMach = nullptr; + std::unique_ptr TargetMach; bool EmitDwarfDebugInfo = false; bool ScopeRestrictionsDone = false; lto_codegen_model CodeModel = LTO_CODEGEN_PIC_MODEL_DEFAULT; diff --git a/lib/LTO/LTOCodeGenerator.cpp b/lib/LTO/LTOCodeGenerator.cpp index fdf3f3a2b89..6203000c2ec 100644 --- a/lib/LTO/LTOCodeGenerator.cpp +++ b/lib/LTO/LTOCodeGenerator.cpp @@ -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; } -- 2.34.1