LTO: Simplify code generator initialization
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>
Mon, 27 Apr 2015 23:19:26 +0000 (23:19 +0000)
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>
Mon, 27 Apr 2015 23:19:26 +0000 (23:19 +0000)
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
lib/LTO/LTOCodeGenerator.cpp

index ff3b71a1a0e91ffee662739c65c57a3083601c93..88156304344620cce8a114b90813ec2c2c1a3d24 100644 (file)
@@ -155,15 +155,14 @@ private:
 
   typedef StringMap<uint8_t> StringSet;
 
-  void initialize();
   void destroyMergedModule();
   std::unique_ptr<LLVMContext> 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<MemoryBuffer> 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
index 16718d7ce647b9f88707371e4c27b869e459faec..6a19849e668483c6cf70fd09d71b9ae545a06ac4 100644 (file)
@@ -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<LLVMContext> 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();
 }