diff options
-rw-r--r-- | lld/COFF/InputFiles.cpp | 6 | ||||
-rw-r--r-- | lld/COFF/InputFiles.h | 4 | ||||
-rw-r--r-- | lld/COFF/SymbolTable.cpp | 2 |
3 files changed, 7 insertions, 5 deletions
diff --git a/lld/COFF/InputFiles.cpp b/lld/COFF/InputFiles.cpp index 088092e8ae7..c167ceb9c57 100644 --- a/lld/COFF/InputFiles.cpp +++ b/lld/COFF/InputFiles.cpp @@ -32,6 +32,7 @@ namespace lld { namespace coff { int InputFile::NextIndex = 0; +llvm::LLVMContext BitcodeFile::Context; // Returns the last element of a path, which is supposed to be a filename. static StringRef getBasename(StringRef Path) { @@ -320,9 +321,8 @@ void BitcodeFile::parse() { // Usually parse() is thread-safe, but bitcode file is an exception. std::lock_guard<std::mutex> Lock(Mu); - ErrorOr<std::unique_ptr<LTOModule>> ModOrErr = - LTOModule::createFromBuffer(llvm::getGlobalContext(), MB.getBufferStart(), - MB.getBufferSize(), llvm::TargetOptions()); + ErrorOr<std::unique_ptr<LTOModule>> ModOrErr = LTOModule::createFromBuffer( + Context, MB.getBufferStart(), MB.getBufferSize(), llvm::TargetOptions()); error(ModOrErr, "Could not create lto module"); M = std::move(*ModOrErr); diff --git a/lld/COFF/InputFiles.h b/lld/COFF/InputFiles.h index 76a13c987e1..f3f962bafde 100644 --- a/lld/COFF/InputFiles.h +++ b/lld/COFF/InputFiles.h @@ -12,6 +12,7 @@ #include "lld/Core/LLVM.h" #include "llvm/ADT/ArrayRef.h" +#include "llvm/IR/LLVMContext.h" #include "llvm/LTO/LTOModule.h" #include "llvm/Object/Archive.h" #include "llvm/Object/COFF.h" @@ -203,9 +204,10 @@ public: static bool classof(const InputFile *F) { return F->kind() == BitcodeKind; } std::vector<SymbolBody *> &getSymbols() override { return SymbolBodies; } MachineTypes getMachineType() override; - std::unique_ptr<LTOModule> takeModule() { return std::move(M); } + static llvm::LLVMContext Context; + private: void parse() override; diff --git a/lld/COFF/SymbolTable.cpp b/lld/COFF/SymbolTable.cpp index 189c3feca73..032c2d3bb5f 100644 --- a/lld/COFF/SymbolTable.cpp +++ b/lld/COFF/SymbolTable.cpp @@ -369,7 +369,7 @@ void SymbolTable::addCombinedLTOObjects() { // Create an object file and add it to the symbol table by replacing any // DefinedBitcode symbols with the definitions in the object file. - LTOCodeGenerator CG(getGlobalContext()); + LTOCodeGenerator CG(BitcodeFile::Context); CG.setOptLevel(Config->LTOOptLevel); std::vector<ObjectFile *> Objs = createLTOObjects(&CG); |