[llvm] r254696 - Move a call to getGlobalContext out of lib/LTO.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 3 18:42:29 PST 2015
Author: rafael
Date: Thu Dec 3 20:42:28 2015
New Revision: 254696
URL: http://llvm.org/viewvc/llvm-project?rev=254696&view=rev
Log:
Move a call to getGlobalContext out of lib/LTO.
Modified:
llvm/trunk/include/llvm/LTO/LTOCodeGenerator.h
llvm/trunk/lib/LTO/LTOCodeGenerator.cpp
llvm/trunk/tools/llvm-lto/llvm-lto.cpp
llvm/trunk/tools/lto/lto.cpp
Modified: llvm/trunk/include/llvm/LTO/LTOCodeGenerator.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/LTO/LTOCodeGenerator.h?rev=254696&r1=254695&r2=254696&view=diff
==============================================================================
--- llvm/trunk/include/llvm/LTO/LTOCodeGenerator.h (original)
+++ llvm/trunk/include/llvm/LTO/LTOCodeGenerator.h Thu Dec 3 20:42:28 2015
@@ -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;
Modified: llvm/trunk/lib/LTO/LTOCodeGenerator.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/LTO/LTOCodeGenerator.cpp?rev=254696&r1=254695&r2=254696&view=diff
==============================================================================
--- llvm/trunk/lib/LTO/LTOCodeGenerator.cpp (original)
+++ llvm/trunk/lib/LTO/LTOCodeGenerator.cpp Thu Dec 3 20:42:28 2015
@@ -64,19 +64,12 @@ const char* LTOCodeGenerator::getVersion
#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() {}
Modified: llvm/trunk/tools/llvm-lto/llvm-lto.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-lto/llvm-lto.cpp?rev=254696&r1=254695&r2=254696&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-lto/llvm-lto.cpp (original)
+++ llvm/trunk/tools/llvm-lto/llvm-lto.cpp Thu Dec 3 20:42:28 2015
@@ -257,7 +257,7 @@ int main(int argc, char **argv) {
unsigned BaseArg = 0;
- LTOCodeGenerator CodeGen;
+ LTOCodeGenerator CodeGen(getGlobalContext());
if (UseDiagnosticHandler)
CodeGen.setDiagnosticHandler(handleDiagnostics, nullptr);
Modified: llvm/trunk/tools/lto/lto.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto/lto.cpp?rev=254696&r1=254695&r2=254696&view=diff
==============================================================================
--- llvm/trunk/tools/lto/lto.cpp (original)
+++ llvm/trunk/tools/lto/lto.cpp Thu Dec 3 20:42:28 2015
@@ -95,13 +95,14 @@ static void handleLibLTODiagnostic(lto_c
// 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;
};
}
More information about the llvm-commits
mailing list