struct LTOCodeGenerator {
static const char *getVersionString();
- LTOCodeGenerator();
- LTOCodeGenerator(std::unique_ptr<LLVMContext> Context);
+ LTOCodeGenerator(LLVMContext &Context);
~LTOCodeGenerator();
/// Merge given module. Return true on success.
typedef StringMap<uint8_t> StringSet;
- std::unique_ptr<LLVMContext> OwnedContext;
LLVMContext &Context;
std::unique_ptr<Module> MergedModule;
std::unique_ptr<Linker> IRLinker;
#endif
}
-LTOCodeGenerator::LTOCodeGenerator()
- : Context(getGlobalContext()),
+LTOCodeGenerator::LTOCodeGenerator(LLVMContext &Context)
+ : Context(Context),
MergedModule(new Module("ld-temp.o", Context)),
IRLinker(new Linker(*MergedModule)) {
initializeLTOPasses();
}
-LTOCodeGenerator::LTOCodeGenerator(std::unique_ptr<LLVMContext> Context)
- : OwnedContext(std::move(Context)), Context(*OwnedContext),
- MergedModule(new Module("ld-temp.o", *OwnedContext)),
- IRLinker(new Linker(*MergedModule)) {
- initializeLTOPasses();
-}
-
LTOCodeGenerator::~LTOCodeGenerator() {}
// Initialize LTO passes. Please keep this function in sync with
unsigned BaseArg = 0;
- LTOCodeGenerator CodeGen;
+ LTOCodeGenerator CodeGen(getGlobalContext());
if (UseDiagnosticHandler)
CodeGen.setDiagnosticHandler(handleDiagnostics, nullptr);
// libLTO API semantics, which require that the code generator owns the object
// file.
struct LibLTOCodeGenerator : LTOCodeGenerator {
- LibLTOCodeGenerator() {
+ LibLTOCodeGenerator() : LTOCodeGenerator(getGlobalContext()) {
setDiagnosticHandler(handleLibLTODiagnostic, nullptr); }
LibLTOCodeGenerator(std::unique_ptr<LLVMContext> Context)
- : LTOCodeGenerator(std::move(Context)) {
+ : LTOCodeGenerator(*Context), OwnedContext(std::move(Context)) {
setDiagnosticHandler(handleLibLTODiagnostic, nullptr); }
std::unique_ptr<MemoryBuffer> NativeObjectFile;
+ std::unique_ptr<LLVMContext> OwnedContext;
};
}