[llvm] r235939 - LTO: Simplify code generator initialization
Duncan P. N. Exon Smith
dexonsmith at apple.com
Mon Apr 27 16:19:26 PDT 2015
Author: dexonsmith
Date: Mon Apr 27 18:19:26 2015
New Revision: 235939
URL: http://llvm.org/viewvc/llvm-project?rev=235939&view=rev
Log:
LTO: Simplify code generator initialization
Simplify `LTOCodeGenerator` initialization by initializing simple fields
at their definition.
Modified:
llvm/trunk/include/llvm/LTO/LTOCodeGenerator.h
llvm/trunk/lib/LTO/LTOCodeGenerator.cpp
Modified: llvm/trunk/include/llvm/LTO/LTOCodeGenerator.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/LTO/LTOCodeGenerator.h?rev=235939&r1=235938&r2=235939&view=diff
==============================================================================
--- llvm/trunk/include/llvm/LTO/LTOCodeGenerator.h (original)
+++ llvm/trunk/include/llvm/LTO/LTOCodeGenerator.h Mon Apr 27 18:19:26 2015
@@ -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
Modified: llvm/trunk/lib/LTO/LTOCodeGenerator.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/LTO/LTOCodeGenerator.cpp?rev=235939&r1=235938&r2=235939&view=diff
==============================================================================
--- llvm/trunk/lib/LTO/LTOCodeGenerator.cpp (original)
+++ llvm/trunk/lib/LTO/LTOCodeGenerator.cpp Mon Apr 27 18:19:26 2015
@@ -65,25 +65,12 @@ const char* LTOCodeGenerator::getVersion
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();
}
More information about the llvm-commits
mailing list