diff options
author | Mehdi Amini <mehdi.amini@apple.com> | 2016-04-14 21:59:01 +0000 |
---|---|---|
committer | Mehdi Amini <mehdi.amini@apple.com> | 2016-04-14 21:59:01 +0000 |
commit | 03b42e41bf4bdd9ab05ea4c6905bae5d19971960 (patch) | |
tree | d4249845a564b11af673299653e7c4e876d8c4f2 /llvm/lib/Target/Target.cpp | |
parent | 3d1c1deb04efe0022f11ebc18bb43d7341ba0c75 (diff) | |
download | llvm-03b42e41bf4bdd9ab05ea4c6905bae5d19971960.zip llvm-03b42e41bf4bdd9ab05ea4c6905bae5d19971960.tar.gz llvm-03b42e41bf4bdd9ab05ea4c6905bae5d19971960.tar.bz2 |
Remove every uses of getGlobalContext() in LLVM (but the C API)
At the same time, fixes InstructionsTest::CastInst unittest: yes
you can leave the IR in an invalid state and exit when you don't
destroy the context (like the global one), no longer now.
This is the first part of http://reviews.llvm.org/D19094
From: Mehdi Amini <mehdi.amini@apple.com>
llvm-svn: 266379
Diffstat (limited to 'llvm/lib/Target/Target.cpp')
-rw-r--r-- | llvm/lib/Target/Target.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/llvm/lib/Target/Target.cpp b/llvm/lib/Target/Target.cpp index c2b4393..5d1616d 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) { |