From ae51ba7ea122ba10d8ee93a282fff7f7c47bca76 Mon Sep 17 00:00:00 2001 From: "Duncan P. N. Exon Smith" Date: Mon, 27 Apr 2015 23:19:26 +0000 Subject: [PATCH] LTO: Simplify code generator initialization Simplify `LTOCodeGenerator` initialization by initializing simple fields at their definition. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@235939 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/LTO/LTOCodeGenerator.h | 19 +++++++++---------- lib/LTO/LTOCodeGenerator.cpp | 17 ++--------------- 2 files changed, 11 insertions(+), 25 deletions(-) diff --git a/include/llvm/LTO/LTOCodeGenerator.h b/include/llvm/LTO/LTOCodeGenerator.h index ff3b71a1a0e..88156304344 100644 --- a/include/llvm/LTO/LTOCodeGenerator.h +++ b/include/llvm/LTO/LTOCodeGenerator.h @@ -155,15 +155,14 @@ private: typedef StringMap StringSet; - void initialize(); void destroyMergedModule(); std::unique_ptr OwnedContext; LLVMContext &Context; Linker IRLinker; - TargetMachine *TargetMach; - bool EmitDwarfDebugInfo; - bool ScopeRestrictionsDone; - lto_codegen_model CodeModel; + TargetMachine *TargetMach = nullptr; + bool EmitDwarfDebugInfo = false; + bool ScopeRestrictionsDone = false; + lto_codegen_model CodeModel = LTO_CODEGEN_PIC_MODEL_DEFAULT; StringSet MustPreserveSymbols; StringSet AsmUndefinedRefs; std::unique_ptr NativeObjectFile; @@ -172,11 +171,11 @@ private: std::string MAttr; std::string NativeObjectPath; TargetOptions Options; - unsigned OptLevel; - lto_diagnostic_handler_t DiagHandler; - void *DiagContext; - LTOModule *OwnedModule; - bool ShouldInternalize; + unsigned OptLevel = 2; + lto_diagnostic_handler_t DiagHandler = nullptr; + void *DiagContext = nullptr; + LTOModule *OwnedModule = nullptr; + bool ShouldInternalize = true; }; } #endif diff --git a/lib/LTO/LTOCodeGenerator.cpp b/lib/LTO/LTOCodeGenerator.cpp index 16718d7ce64..6a19849e668 100644 --- a/lib/LTO/LTOCodeGenerator.cpp +++ b/lib/LTO/LTOCodeGenerator.cpp @@ -65,25 +65,12 @@ const char* LTOCodeGenerator::getVersionString() { LTOCodeGenerator::LTOCodeGenerator() : Context(getGlobalContext()), IRLinker(new Module("ld-temp.o", Context)) { - initialize(); + initializeLTOPasses(); } LTOCodeGenerator::LTOCodeGenerator(std::unique_ptr Context) : OwnedContext(std::move(Context)), Context(*OwnedContext), - IRLinker(new Module("ld-temp.o", *OwnedContext)), OptLevel(2) { - initialize(); -} - -void LTOCodeGenerator::initialize() { - TargetMach = nullptr; - EmitDwarfDebugInfo = false; - ScopeRestrictionsDone = false; - CodeModel = LTO_CODEGEN_PIC_MODEL_DEFAULT; - DiagHandler = nullptr; - DiagContext = nullptr; - OwnedModule = nullptr; - ShouldInternalize = true; - + IRLinker(new Module("ld-temp.o", *OwnedContext)) { initializeLTOPasses(); } -- 2.34.1