llvm.org GIT mirror llvm / c6a202e
Move a call to getGlobalContext out of lib/LTO. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@254696 91177308-0d34-0410-b5e6-96231b3b80d8 Rafael Espindola 3 years ago
4 changed file(s) with 7 addition(s) and 15 deletion(s). Raw diff Collapse all Expand all
6161 struct LTOCodeGenerator {
6262 static const char *getVersionString();
6363
64 LTOCodeGenerator();
65 LTOCodeGenerator(std::unique_ptr Context);
64 LTOCodeGenerator(LLVMContext &Context);
6665 ~LTOCodeGenerator();
6766
6867 /// Merge given module. Return true on success.
167166
168167 typedef StringMap StringSet;
169168
170 std::unique_ptr OwnedContext;
171169 LLVMContext &Context;
172170 std::unique_ptr MergedModule;
173171 std::unique_ptr IRLinker;
6363 #endif
6464 }
6565
66 LTOCodeGenerator::LTOCodeGenerator()
67 : Context(getGlobalContext()),
66 LTOCodeGenerator::LTOCodeGenerator(LLVMContext &Context)
67 : Context(Context),
6868 MergedModule(new Module("ld-temp.o", Context)),
69 IRLinker(new Linker(*MergedModule)) {
70 initializeLTOPasses();
71 }
72
73 LTOCodeGenerator::LTOCodeGenerator(std::unique_ptr Context)
74 : OwnedContext(std::move(Context)), Context(*OwnedContext),
75 MergedModule(new Module("ld-temp.o", *OwnedContext)),
7669 IRLinker(new Linker(*MergedModule)) {
7770 initializeLTOPasses();
7871 }
256256
257257 unsigned BaseArg = 0;
258258
259 LTOCodeGenerator CodeGen;
259 LTOCodeGenerator CodeGen(getGlobalContext());
260260
261261 if (UseDiagnosticHandler)
262262 CodeGen.setDiagnosticHandler(handleDiagnostics, nullptr);
9494 // libLTO API semantics, which require that the code generator owns the object
9595 // file.
9696 struct LibLTOCodeGenerator : LTOCodeGenerator {
97 LibLTOCodeGenerator() {
97 LibLTOCodeGenerator() : LTOCodeGenerator(getGlobalContext()) {
9898 setDiagnosticHandler(handleLibLTODiagnostic, nullptr); }
9999 LibLTOCodeGenerator(std::unique_ptr Context)
100 : LTOCodeGenerator(std::move(Context)) {
100 : LTOCodeGenerator(*Context), OwnedContext(std::move(Context)) {
101101 setDiagnosticHandler(handleLibLTODiagnostic, nullptr); }
102102
103103 std::unique_ptr NativeObjectFile;
104 std::unique_ptr OwnedContext;
104105 };
105106
106107 }