From 41b016e569802fa3effe8a25fb84dd00f647d112 Mon Sep 17 00:00:00 2001 From: Mehdi Amini Date: Thu, 14 Apr 2016 21:59:18 +0000 Subject: [PATCH] Nuke getGlobalContext() from LLVM (but the C API) The only use for getGlobalContext() is in the C API. Let's just move the static global here and nuke the C++ API. Differential Revision: http://reviews.llvm.org/D19094 From: Mehdi Amini git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266380 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/LLVMContext.h | 4 ---- lib/IR/Core.cpp | 8 ++++---- lib/IR/LLVMContext.cpp | 6 ------ 3 files changed, 4 insertions(+), 14 deletions(-) diff --git a/include/llvm/IR/LLVMContext.h b/include/llvm/IR/LLVMContext.h index 415c1fea915..e4533446399 100644 --- a/include/llvm/IR/LLVMContext.h +++ b/include/llvm/IR/LLVMContext.h @@ -235,10 +235,6 @@ private: friend class Module; }; -/// getGlobalContext - Returns a global context. This is for LLVM clients that -/// only care about operating on a single thread. -extern LLVMContext &getGlobalContext(); - // Create wrappers for C Binding types (see CBindingWrapping.h). DEFINE_SIMPLE_CONVERSION_FUNCTIONS(LLVMContext, LLVMContextRef) diff --git a/lib/IR/Core.cpp b/lib/IR/Core.cpp index 1b4ad203969..43a25838369 100644 --- a/lib/IR/Core.cpp +++ b/lib/IR/Core.cpp @@ -73,13 +73,13 @@ void LLVMDisposeMessage(char *Message) { /*===-- Operations on contexts --------------------------------------------===*/ +static ManagedStatic GlobalContext; + LLVMContextRef LLVMContextCreate() { return wrap(new LLVMContext()); } -LLVMContextRef LLVMGetGlobalContext() { - return wrap(&getGlobalContext()); -} +LLVMContextRef LLVMGetGlobalContext() { return wrap(&*GlobalContext); } void LLVMContextSetDiagnosticHandler(LLVMContextRef C, LLVMDiagnosticHandler Handler, @@ -155,7 +155,7 @@ LLVMDiagnosticSeverity LLVMGetDiagInfoSeverity(LLVMDiagnosticInfoRef DI) { /*===-- Operations on modules ---------------------------------------------===*/ LLVMModuleRef LLVMModuleCreateWithName(const char *ModuleID) { - return wrap(new Module(ModuleID, getGlobalContext())); + return wrap(new Module(ModuleID, *GlobalContext)); } LLVMModuleRef LLVMModuleCreateWithNameInContext(const char *ModuleID, diff --git a/lib/IR/LLVMContext.cpp b/lib/IR/LLVMContext.cpp index 673a8c19074..0e8d3e826aa 100644 --- a/lib/IR/LLVMContext.cpp +++ b/lib/IR/LLVMContext.cpp @@ -25,12 +25,6 @@ #include using namespace llvm; -static ManagedStatic GlobalContext; - -LLVMContext& llvm::getGlobalContext() { - return *GlobalContext; -} - LLVMContext::LLVMContext() : pImpl(new LLVMContextImpl(*this)) { // Create the fixed metadata kinds. This is done in the same order as the // MD_* enum values so that they correspond.