Do not use llvm::getGlobalContext().
authorRui Ueyama <ruiu@google.com>
Thu, 14 Apr 2016 21:41:44 +0000 (21:41 +0000)
committerRui Ueyama <ruiu@google.com>
Thu, 14 Apr 2016 21:41:44 +0000 (21:41 +0000)
llvm-svn: 266375

lld/COFF/InputFiles.cpp
lld/COFF/InputFiles.h
lld/COFF/SymbolTable.cpp

index 088092e..c167ceb 100644 (file)
@@ -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);
 
index 76a13c9..f3f962b 100644 (file)
@@ -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;
 
index 189c3fe..032c2d3 100644 (file)
@@ -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);