static const char *getVersionString();
LTOCodeGenerator();
+ LTOCodeGenerator(std::unique_ptr<LLVMContext> Context);
~LTOCodeGenerator();
// Merge given module, return true on success.
typedef StringMap<uint8_t> StringSet;
+ void initialize();
+ std::unique_ptr<LLVMContext> OwnedContext;
LLVMContext &Context;
Linker IRLinker;
TargetMachine *TargetMach;
}
LTOCodeGenerator::LTOCodeGenerator()
- : Context(getGlobalContext()), IRLinker(new Module("ld-temp.o", Context)),
- TargetMach(nullptr), EmitDwarfDebugInfo(false),
- ScopeRestrictionsDone(false), CodeModel(LTO_CODEGEN_PIC_MODEL_DEFAULT),
- DiagHandler(nullptr), DiagContext(nullptr) {
+ : Context(getGlobalContext()), IRLinker(new Module("ld-temp.o", Context)) {
+ initialize();
+}
+
+LTOCodeGenerator::LTOCodeGenerator(std::unique_ptr<LLVMContext> Context)
+ : OwnedContext(std::move(Context)), Context(*OwnedContext),
+ IRLinker(new Module("ld-temp.o", *OwnedContext)) {
+ initialize();
+}
+
+void LTOCodeGenerator::initialize() {
+ TargetMach = nullptr;
+ EmitDwarfDebugInfo = false;
+ ScopeRestrictionsDone = false;
+ CodeModel = LTO_CODEGEN_PIC_MODEL_DEFAULT;
+ DiagHandler = nullptr;
+ DiagContext = nullptr;
+
initializeLTOPasses();
}