Move a call to getGlobalContext out of lib/LTO.

llvm-svn: 254696
This commit is contained in:
Rafael Espindola 2015-12-04 02:42:28 +00:00
parent d25663ec5d
commit b0476044d6
4 changed files with 7 additions and 15 deletions

View File

@ -62,8 +62,7 @@ namespace llvm {
struct LTOCodeGenerator {
static const char *getVersionString();
LTOCodeGenerator();
LTOCodeGenerator(std::unique_ptr<LLVMContext> Context);
LTOCodeGenerator(LLVMContext &Context);
~LTOCodeGenerator();
/// Merge given module. Return true on success.
@ -168,7 +167,6 @@ private:
typedef StringMap<uint8_t> StringSet;
std::unique_ptr<LLVMContext> OwnedContext;
LLVMContext &Context;
std::unique_ptr<Module> MergedModule;
std::unique_ptr<Linker> IRLinker;

View File

@ -64,20 +64,13 @@ const char* LTOCodeGenerator::getVersionString() {
#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

View File

@ -257,7 +257,7 @@ int main(int argc, char **argv) {
unsigned BaseArg = 0;
LTOCodeGenerator CodeGen;
LTOCodeGenerator CodeGen(getGlobalContext());
if (UseDiagnosticHandler)
CodeGen.setDiagnosticHandler(handleDiagnostics, nullptr);

View File

@ -95,13 +95,14 @@ static void handleLibLTODiagnostic(lto_codegen_diagnostic_severity_t Severity,
// 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;
};
}