summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/include/llvm/LTO/LTOCodeGenerator.h4
-rw-r--r--llvm/lib/LTO/LTOCodeGenerator.cpp11
-rw-r--r--llvm/tools/llvm-lto/llvm-lto.cpp2
-rw-r--r--llvm/tools/lto/lto.cpp5
4 files changed, 7 insertions, 15 deletions
diff --git a/llvm/include/llvm/LTO/LTOCodeGenerator.h b/llvm/include/llvm/LTO/LTOCodeGenerator.h
index c322288a1ae..876defbdcd3 100644
--- a/llvm/include/llvm/LTO/LTOCodeGenerator.h
+++ b/llvm/include/llvm/LTO/LTOCodeGenerator.h
@@ -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;
diff --git a/llvm/lib/LTO/LTOCodeGenerator.cpp b/llvm/lib/LTO/LTOCodeGenerator.cpp
index 468ec24e3a0..b0dae74c13d 100644
--- a/llvm/lib/LTO/LTOCodeGenerator.cpp
+++ b/llvm/lib/LTO/LTOCodeGenerator.cpp
@@ -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
diff --git a/llvm/tools/llvm-lto/llvm-lto.cpp b/llvm/tools/llvm-lto/llvm-lto.cpp
index 86b95577b30..07cd9bb1eaf 100644
--- a/llvm/tools/llvm-lto/llvm-lto.cpp
+++ b/llvm/tools/llvm-lto/llvm-lto.cpp
@@ -257,7 +257,7 @@ int main(int argc, char **argv) {
unsigned BaseArg = 0;
- LTOCodeGenerator CodeGen;
+ LTOCodeGenerator CodeGen(getGlobalContext());
if (UseDiagnosticHandler)
CodeGen.setDiagnosticHandler(handleDiagnostics, nullptr);
diff --git a/llvm/tools/lto/lto.cpp b/llvm/tools/lto/lto.cpp
index ee389da2499..6058fb1197e 100644
--- a/llvm/tools/lto/lto.cpp
+++ b/llvm/tools/lto/lto.cpp
@@ -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;
};
}
OpenPOWER on IntegriCloud