summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Bitcode/Reader/BitReader.cpp5
-rw-r--r--llvm/lib/Target/CppBackend/CPPBackend.cpp3
-rw-r--r--llvm/lib/Target/Target.cpp7
3 files changed, 9 insertions, 6 deletions
diff --git a/llvm/lib/Bitcode/Reader/BitReader.cpp b/llvm/lib/Bitcode/Reader/BitReader.cpp
index 385c18a4000..9ac3cb95d08 100644
--- a/llvm/lib/Bitcode/Reader/BitReader.cpp
+++ b/llvm/lib/Bitcode/Reader/BitReader.cpp
@@ -25,14 +25,13 @@ using namespace llvm;
Optionally returns a human-readable error message via OutMessage. */
LLVMBool LLVMParseBitcode(LLVMMemoryBufferRef MemBuf, LLVMModuleRef *OutModule,
char **OutMessage) {
- return LLVMParseBitcodeInContext(wrap(&getGlobalContext()), MemBuf, OutModule,
+ return LLVMParseBitcodeInContext(LLVMGetGlobalContext(), MemBuf, OutModule,
OutMessage);
}
LLVMBool LLVMParseBitcode2(LLVMMemoryBufferRef MemBuf,
LLVMModuleRef *OutModule) {
- return LLVMParseBitcodeInContext2(wrap(&getGlobalContext()), MemBuf,
- OutModule);
+ return LLVMParseBitcodeInContext2(LLVMGetGlobalContext(), MemBuf, OutModule);
}
static void diagnosticHandler(const DiagnosticInfo &DI, void *C) {
diff --git a/llvm/lib/Target/CppBackend/CPPBackend.cpp b/llvm/lib/Target/CppBackend/CPPBackend.cpp
index a086e710d16..bc2bf155c51 100644
--- a/llvm/lib/Target/CppBackend/CPPBackend.cpp
+++ b/llvm/lib/Target/CppBackend/CPPBackend.cpp
@@ -1947,6 +1947,7 @@ void CppWriter::printProgram(const std::string& fname,
Out << "#include <llvm/Support/MathExtras.h>\n";
Out << "#include <algorithm>\n";
Out << "using namespace llvm;\n\n";
+ Out << "static LLVMContext TheContext;\n\n";
Out << "Module* " << fname << "();\n\n";
Out << "int main(int argc, char**argv) {\n";
Out << " Module* Mod = " << fname << "();\n";
@@ -1965,7 +1966,7 @@ void CppWriter::printModule(const std::string& fname,
nl(Out,1) << "// Module Construction";
nl(Out) << "Module* mod = new Module(\"";
printEscapedString(mName);
- Out << "\", getGlobalContext());";
+ Out << "\", TheContext);";
if (!TheModule->getTargetTriple().empty()) {
nl(Out) << "mod->setDataLayout(\"" << TheModule->getDataLayoutStr()
<< "\");";
diff --git a/llvm/lib/Target/Target.cpp b/llvm/lib/Target/Target.cpp
index c2b4393fe4c..5d1616d0377 100644
--- a/llvm/lib/Target/Target.cpp
+++ b/llvm/lib/Target/Target.cpp
@@ -24,6 +24,9 @@
using namespace llvm;
+// Avoid including "llvm-c/Core.h" for compile time, fwd-declare this instead.
+extern "C" LLVMContextRef LLVMGetGlobalContext(void);
+
inline TargetLibraryInfoImpl *unwrap(LLVMTargetLibraryInfoRef P) {
return reinterpret_cast<TargetLibraryInfoImpl*>(P);
}
@@ -81,11 +84,11 @@ unsigned LLVMPointerSizeForAS(LLVMTargetDataRef TD, unsigned AS) {
}
LLVMTypeRef LLVMIntPtrType(LLVMTargetDataRef TD) {
- return wrap(unwrap(TD)->getIntPtrType(getGlobalContext()));
+ return wrap(unwrap(TD)->getIntPtrType(*unwrap(LLVMGetGlobalContext())));
}
LLVMTypeRef LLVMIntPtrTypeForAS(LLVMTargetDataRef TD, unsigned AS) {
- return wrap(unwrap(TD)->getIntPtrType(getGlobalContext(), AS));
+ return wrap(unwrap(TD)->getIntPtrType(*unwrap(LLVMGetGlobalContext()), AS));
}
LLVMTypeRef LLVMIntPtrTypeInContext(LLVMContextRef C, LLVMTargetDataRef TD) {
OpenPOWER on IntegriCloud