diff --git a/include/llvm/LLVMContext.h b/include/llvm/LLVMContext.h index 01c64a81e04..1d95502bcd6 100644 --- a/include/llvm/LLVMContext.h +++ b/include/llvm/LLVMContext.h @@ -197,6 +197,9 @@ public: VectorType* getVectorTypeTruncatedElement(const VectorType* VTy); }; +/// FOR BACKWARDS COMPATIBILITY - Returns a global context. +LLVMContext* getGlobalContext(); + } #endif diff --git a/lib/VMCore/LLVMContext.cpp b/lib/VMCore/LLVMContext.cpp index e0fe6ab7929..09c7fcc8cf1 100644 --- a/lib/VMCore/LLVMContext.cpp +++ b/lib/VMCore/LLVMContext.cpp @@ -15,10 +15,17 @@ #include "llvm/LLVMContext.h" #include "llvm/Constants.h" #include "llvm/DerivedTypes.h" +#include "llvm/Support/ManagedStatic.h" #include "LLVMContextImpl.h" using namespace llvm; +static ManagedStatic GlobalContext; + +LLVMContext* getGlobalContext() { + return &*GlobalContext; +} + LLVMContext::LLVMContext() : pImpl(new LLVMContextImpl()) { } LLVMContext::~LLVMContext() { delete pImpl; }