Hello community,
here is the log from the commit of package python-llvmlite for openSUSE:Factory checked in at 2018-12-03 10:12:23
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-llvmlite (Old)
and /work/SRC/openSUSE:Factory/.python-llvmlite.new.19453 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-llvmlite"
Mon Dec 3 10:12:23 2018 rev:9 rq:653424 version:0.26.0
Changes:
--------
--- /work/SRC/openSUSE:Factory/python-llvmlite/python-llvmlite.changes 2018-10-11 11:58:27.721793909 +0200
+++ /work/SRC/openSUSE:Factory/.python-llvmlite.new.19453/python-llvmlite.changes 2018-12-03 10:12:34.759587440 +0100
@@ -1,0 +2,20 @@
+Sat Dec 1 18:33:44 UTC 2018 - Arun Persaud
+
+- update to version 0.26.0:
+ * The primary new features in this release is support for generation
+ of Intel JIT events, which makes profiling of JIT compiled code in
+ Intel VTune possible. This release also contains some minor build
+ improvements for ARMv7, and some small fixes.
+ * LLVM 7 support was originally slated for this release, but had to
+ be delayed after some issues arose in testing. LLVM 6 is still
+ required for llvmlite.
+ * PR #409: Use native cmake on armv7l
+ * PR #407: Throttle thread count for llvm build on armv7l.
+ * PR #403: Add shutdown detection to ObjectRef __del__ method.
+ * PR #400: conda recipe: add make as build dep
+ * PR #399: Add get_element_offset to TargetData
+ * PR #398: Fix gep method call on Constant objects
+ * PR #395: Fix typo in irbuilder documentation
+ * PR #394: Enable IntelJIT events for LLVM for VTune support
+
+-------------------------------------------------------------------
Old:
----
llvmlite-0.25.0.tar.gz
New:
----
llvmlite-0.26.0.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ python-llvmlite.spec ++++++
--- /var/tmp/diff_new_pack.56h5WV/_old 2018-12-03 10:12:35.283586954 +0100
+++ /var/tmp/diff_new_pack.56h5WV/_new 2018-12-03 10:12:35.287586950 +0100
@@ -18,7 +18,7 @@
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
Name: python-llvmlite
-Version: 0.25.0
+Version: 0.26.0
Release: 0
Summary: Lightweight wrapper around basic LLVM functionality
License: BSD-2-Clause
++++++ llvmlite-0.25.0.tar.gz -> llvmlite-0.26.0.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/llvmlite-0.25.0/PKG-INFO new/llvmlite-0.26.0/PKG-INFO
--- old/llvmlite-0.25.0/PKG-INFO 2018-09-21 21:32:23.000000000 +0200
+++ new/llvmlite-0.26.0/PKG-INFO 2018-11-28 15:59:12.000000000 +0100
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: llvmlite
-Version: 0.25.0
+Version: 0.26.0
Summary: lightweight wrapper around basic LLVM functionality
Home-page: http://llvmlite.pydata.org
Author: Continuum Analytics, Inc.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/llvmlite-0.25.0/ffi/core.cpp new/llvmlite-0.26.0/ffi/core.cpp
--- old/llvmlite-0.25.0/ffi/core.cpp 2018-09-21 21:31:30.000000000 +0200
+++ new/llvmlite-0.26.0/ffi/core.cpp 2018-11-28 15:58:46.000000000 +0100
@@ -29,6 +29,16 @@
return LLVMGetGlobalContext();
}
+API_EXPORT(LLVMContextRef)
+LLVMPY_ContextCreate() {
+ return LLVMContextCreate();
+}
+
+API_EXPORT(void)
+LLVMPY_ContextDispose(LLVMContextRef context) {
+ return LLVMContextDispose(context);
+}
+
API_EXPORT(void)
LLVMPY_SetCommandLine(const char *name, const char *option)
{
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/llvmlite-0.25.0/ffi/core.h new/llvmlite-0.26.0/ffi/core.h
--- old/llvmlite-0.25.0/ffi/core.h 2018-09-21 21:31:30.000000000 +0200
+++ new/llvmlite-0.26.0/ffi/core.h 2018-11-28 15:58:46.000000000 +0100
@@ -30,6 +30,9 @@
API_EXPORT(LLVMContextRef)
LLVMPY_GetGlobalContext();
+API_EXPORT(LLVMContextRef)
+LLVMPY_ContextCreate();
+
} /* end extern "C" */
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/llvmlite-0.25.0/ffi/executionengine.cpp new/llvmlite-0.26.0/ffi/executionengine.cpp
--- old/llvmlite-0.25.0/ffi/executionengine.cpp 2018-09-21 21:31:30.000000000 +0200
+++ new/llvmlite-0.26.0/ffi/executionengine.cpp 2018-11-28 15:58:46.000000000 +0100
@@ -153,15 +153,24 @@
API_EXPORT(bool)
LLVMPY_EnableJITEvents(LLVMExecutionEngineRef EE)
{
+ llvm::JITEventListener *listener;
+ bool result = false;
+
#ifdef __linux__
- llvm::JITEventListener *listener = llvm::JITEventListener::createOProfileJITEventListener();
+ listener = llvm::JITEventListener::createOProfileJITEventListener();
// if listener is null, then LLVM was not compiled for OProfile JIT events.
if (listener) {
llvm::unwrap(EE)->RegisterJITEventListener(listener);
- return true;
+ result = true;
}
#endif
- return false;
+ listener = llvm::JITEventListener::createIntelJITEventListener();
+ // if listener is null, then LLVM was not compiled for Intel JIT events.
+ if (listener) {
+ llvm::unwrap(EE)->RegisterJITEventListener(listener);
+ result = true;
+ }
+ return result;
}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/llvmlite-0.25.0/ffi/module.cpp new/llvmlite-0.26.0/ffi/module.cpp
--- old/llvmlite-0.25.0/ffi/module.cpp 2018-09-21 21:31:30.000000000 +0200
+++ new/llvmlite-0.26.0/ffi/module.cpp 2018-11-28 15:58:46.000000000 +0100
@@ -3,6 +3,7 @@
#include "llvm-c/Core.h"
#include "llvm-c/Analysis.h"
#include "llvm/IR/Module.h"
+#include "llvm/IR/TypeFinder.h"
#include "core.h"
@@ -35,6 +36,26 @@
struct OpaqueFunctionsIterator;
typedef OpaqueFunctionsIterator* LLVMFunctionsIteratorRef;
+/* module types iterator */
+class TypesIterator {
+private:
+ llvm::TypeFinder finder;
+ using const_iterator = llvm::TypeFinder::const_iterator;
+ const_iterator cur;
+public:
+ TypesIterator(llvm::Module& m, bool namedOnly) : finder(llvm::TypeFinder()) {
+ finder.run(m, namedOnly);
+ cur = finder.begin();
+ }
+ const llvm::Type* next() {
+ if (cur != finder.end()) {
+ return *cur++;
+ }
+ return nullptr;
+ }
+};
+
+typedef TypesIterator* LLVMTypesIteratorRef;
//
// Local helper functions
@@ -62,6 +83,16 @@
return reinterpret_cast(GI);
}
+static LLVMTypesIteratorRef
+wrap(TypesIterator* TyI) {
+ return reinterpret_cast<LLVMTypesIteratorRef>(TyI);
+}
+
+static TypesIterator*
+unwrap(LLVMTypesIteratorRef TyI) {
+ return reinterpret_cast(TyI);
+}
+
} // end namespace llvm
@@ -119,6 +150,13 @@
return wrap(unwrap(M)->getGlobalVariable(Name));
}
+API_EXPORT(LLVMTypeRef)
+LLVMPY_GetNamedStructType(LLVMModuleRef M,
+ const char *Name)
+{
+ return LLVMGetTypeByName(M, Name);
+}
+
API_EXPORT(int)
LLVMPY_VerifyModule(LLVMModuleRef M, char **OutMsg)
@@ -177,6 +215,14 @@
mod->end()));
}
+API_EXPORT(LLVMTypesIteratorRef)
+LLVMPY_ModuleTypesIter(LLVMModuleRef M)
+{
+ llvm::Module* mod = llvm::unwrap(M);
+ auto* iter = new TypesIterator(*mod, false);
+ return llvm::wrap(iter);
+}
+
/*
These functions return NULL if we are at the end
@@ -205,6 +251,12 @@
}
}
+API_EXPORT(LLVMTypeRef)
+LLVMPY_TypesIterNext(LLVMTypesIteratorRef TyI)
+{
+ return llvm::wrap(llvm::unwrap(TyI)->next());
+}
+
API_EXPORT(void)
LLVMPY_DisposeGlobalsIter(LLVMGlobalsIteratorRef GI)
{
@@ -217,6 +269,14 @@
delete llvm::unwrap(GI);
}
+API_EXPORT(void)
+LLVMPY_DisposeTypesIter(LLVMTypesIteratorRef TyI)
+{
+ delete llvm::unwrap(TyI);
+}
+
+
+
API_EXPORT(LLVMModuleRef)
LLVMPY_CloneModule(LLVMModuleRef M)
{
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/llvmlite-0.25.0/ffi/targets.cpp new/llvmlite-0.26.0/ffi/targets.cpp
--- old/llvmlite-0.25.0/ffi/targets.cpp 2018-09-21 21:31:30.000000000 +0200
+++ new/llvmlite-0.26.0/ffi/targets.cpp 2018-11-28 15:58:46.000000000 +0100
@@ -119,6 +119,15 @@
}
API_EXPORT(long long)
+LLVMPY_OffsetOfElement(LLVMTargetDataRef TD, LLVMTypeRef Ty, int Element)
+{
+ llvm::Type *tp = llvm::unwrap(Ty);
+ if (!tp->isStructTy())
+ return -1;
+ return (long long) LLVMOffsetOfElement(TD, Ty, Element);
+}
+
+API_EXPORT(long long)
LLVMPY_ABISizeOfElementType(LLVMTargetDataRef TD, LLVMTypeRef Ty)
{
llvm::Type *tp = llvm::unwrap(Ty);
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/llvmlite-0.25.0/llvmlite/_version.py new/llvmlite-0.26.0/llvmlite/_version.py
--- old/llvmlite-0.25.0/llvmlite/_version.py 2018-09-21 21:32:23.000000000 +0200
+++ new/llvmlite-0.26.0/llvmlite/_version.py 2018-11-28 15:59:12.000000000 +0100
@@ -4,8 +4,8 @@
# unpacked source archive. Distribution tarballs contain a pre-generated copy
# of this file.
-version_version = '0.25.0'
-version_full = '9af98a608a49278dbc4ce5dc743152f2341b6a87'
+version_version = '0.26.0'
+version_full = 'f63f7b0b67bfc159a9cc4e6a9728c67f8c690825'
def get_versions(default={}, verbose=False):
return {'version': version_version, 'full': version_full}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/llvmlite-0.25.0/llvmlite/binding/__init__.py new/llvmlite-0.26.0/llvmlite/binding/__init__.py
--- old/llvmlite-0.25.0/llvmlite/binding/__init__.py 2018-09-21 21:31:30.000000000 +0200
+++ new/llvmlite-0.26.0/llvmlite/binding/__init__.py 2018-11-28 15:58:46.000000000 +0100
@@ -15,3 +15,4 @@
from .value import *
from .analysis import *
from .object_file import *
+from .context import *
\ No newline at end of file
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/llvmlite-0.25.0/llvmlite/binding/context.py new/llvmlite-0.26.0/llvmlite/binding/context.py
--- old/llvmlite-0.25.0/llvmlite/binding/context.py 1970-01-01 01:00:00.000000000 +0100
+++ new/llvmlite-0.26.0/llvmlite/binding/context.py 2018-11-28 15:58:46.000000000 +0100
@@ -0,0 +1,30 @@
+from __future__ import print_function, absolute_import
+
+from . import ffi
+
+
+def create_context():
+ return ContextRef(ffi.lib.LLVMPY_ContextCreate())
+
+
+def get_global_context():
+ return GlobalContextRef(ffi.lib.LLVMPY_GetGlobalContext())
+
+
+class ContextRef(ffi.ObjectRef):
+ def __init__(self, context_ptr):
+ super(ContextRef, self).__init__(context_ptr)
+
+ def _dispose(self):
+ ffi.lib.LLVMPY_ContextDispose(self)
+
+class GlobalContextRef(ContextRef):
+ def _dispose(self):
+ pass
+
+
+ffi.lib.LLVMPY_GetGlobalContext.restype = ffi.LLVMContextRef
+
+ffi.lib.LLVMPY_ContextCreate.restype = ffi.LLVMContextRef
+
+ffi.lib.LLVMPY_ContextDispose.argtypes = [ffi.LLVMContextRef]
\ No newline at end of file
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/llvmlite-0.25.0/llvmlite/binding/ffi.py new/llvmlite-0.26.0/llvmlite/binding/ffi.py
--- old/llvmlite-0.25.0/llvmlite/binding/ffi.py 2018-09-21 21:31:30.000000000 +0200
+++ new/llvmlite-0.26.0/llvmlite/binding/ffi.py 2018-11-28 15:58:46.000000000 +0100
@@ -26,6 +26,7 @@
LLVMMemoryBufferRef = _make_opaque_ref("LLVMMemoryBuffer")
LLVMGlobalsIterator = _make_opaque_ref("LLVMGlobalsIterator")
LLVMFunctionsIterator = _make_opaque_ref("LLVMFunctionsIterator")
+LLVMTypesIterator = _make_opaque_ref("LLVMTypesIterator")
LLVMObjectCacheRef = _make_opaque_ref("LLVMObjectCache")
LLVMObjectFileRef = _make_opaque_ref("LLVMObjectFile")
LLVMSectionIteratorRef = _make_opaque_ref("LLVMSectionIterator")
@@ -164,7 +165,8 @@
# Avoid errors trying to rely on globals and modules at interpreter
# shutdown.
if not _is_shutting_down():
- self.close()
+ if self.close is not None:
+ self.close()
def __str__(self):
if self._ptr is None:
@@ -238,13 +240,20 @@
def __exit__(self, exc_type, exc_val, exc_tb):
self.close()
- def __del__(self):
- if self.close is not None:
- self.close()
+ def __del__(self, _is_shutting_down=_is_shutting_down):
+ if not _is_shutting_down():
+ if self.close is not None:
+ self.close()
def __bool__(self):
return bool(self._ptr)
+ def __eq__(self, other):
+ if not hasattr(other, "_ptr"):
+ return False
+ return ctypes.addressof(self._ptr[0]) == \
+ ctypes.addressof(other._ptr[0])
+
__nonzero__ = __bool__
# XXX useful?
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/llvmlite-0.25.0/llvmlite/binding/module.py new/llvmlite-0.26.0/llvmlite/binding/module.py
--- old/llvmlite-0.25.0/llvmlite/binding/module.py 2018-09-21 21:31:30.000000000 +0200
+++ new/llvmlite-0.26.0/llvmlite/binding/module.py 2018-11-28 15:58:46.000000000 +0100
@@ -5,36 +5,43 @@
from . import ffi
from .linker import link_modules
from .common import _decode_string, _encode_string
-from .value import ValueRef
+from .value import ValueRef, TypeRef
+from .context import get_global_context
-def parse_assembly(llvmir):
+def parse_assembly(llvmir, context=None):
"""
Create Module from a LLVM IR string
"""
- context = ffi.lib.LLVMPY_GetGlobalContext()
+ if context is None:
+ context = get_global_context()
llvmir = _encode_string(llvmir)
strbuf = c_char_p(llvmir)
with ffi.OutputString() as errmsg:
- mod = ModuleRef(ffi.lib.LLVMPY_ParseAssembly(context, strbuf, errmsg))
+ mod = ModuleRef(
+ ffi.lib.LLVMPY_ParseAssembly(context, strbuf, errmsg),
+ context)
if errmsg:
mod.close()
raise RuntimeError("LLVM IR parsing error\n{0}".format(errmsg))
return mod
-def parse_bitcode(bitcode):
+def parse_bitcode(bitcode, context=None):
"""
Create Module from a LLVM *bitcode* (a bytes object).
"""
- context = ffi.lib.LLVMPY_GetGlobalContext()
+ if context is None:
+ context = get_global_context()
buf = c_char_p(bitcode)
bufsize = len(bitcode)
with ffi.OutputString() as errmsg:
- mod = ModuleRef(ffi.lib.LLVMPY_ParseBitcode(context, buf, bufsize, errmsg))
+ mod = ModuleRef(ffi.lib.LLVMPY_ParseBitcode(
+ context, buf, bufsize, errmsg), context)
if errmsg:
mod.close()
- raise RuntimeError("LLVM bitcode parsing error\n{0}".format(errmsg))
+ raise RuntimeError(
+ "LLVM bitcode parsing error\n{0}".format(errmsg))
return mod
@@ -43,6 +50,10 @@
A reference to a LLVM module.
"""
+ def __init__(self, module_ptr, context):
+ super(ModuleRef, self).__init__(module_ptr)
+ self._context = context
+
def __str__(self):
with ffi.OutputString() as outstr:
ffi.lib.LLVMPY_PrintModuleToString(self, outstr)
@@ -86,6 +97,16 @@
raise NameError(name)
return ValueRef(p, module=self)
+ def get_struct_type(self, name):
+ """
+ Get a TypeRef pointing to a structure type named *name*.
+ NameError is raised if the struct type isn't found.
+ """
+ p = ffi.lib.LLVMPY_GetNamedStructType(self, _encode_string(name))
+ if not p:
+ raise NameError(name)
+ return TypeRef(p)
+
def verify(self):
"""
Verify the module IR's correctness. RuntimeError is raised on error.
@@ -168,8 +189,17 @@
it = ffi.lib.LLVMPY_ModuleFunctionsIter(self)
return _FunctionsIterator(it, module=self)
+ @property
+ def struct_types(self):
+ """
+ Return an iterator over the struct types defined in
+ the module. The iterator will yield a TypeRef.
+ """
+ it = ffi.lib.LLVMPY_ModuleTypesIter(self)
+ return _TypesIterator(it, module=self)
+
def clone(self):
- return ModuleRef(ffi.lib.LLVMPY_CloneModule(self))
+ return ModuleRef(ffi.lib.LLVMPY_CloneModule(self), self._context)
class _Iterator(ffi.ObjectRef):
@@ -210,6 +240,24 @@
return ffi.lib.LLVMPY_FunctionsIterNext(self)
+class _TypesIterator(_Iterator):
+
+ def _dispose(self):
+ self._capi.LLVMPY_DisposeTypesIter(self)
+
+ def __next__(self):
+ vp = self._next()
+ if vp:
+ return TypeRef(vp)
+ else:
+ raise StopIteration
+
+ def _next(self):
+ return ffi.lib.LLVMPY_TypesIterNext(self)
+
+ next = __next__
+
+
# =============================================================================
# Set function FFI
@@ -223,8 +271,6 @@
POINTER(c_char_p)]
ffi.lib.LLVMPY_ParseBitcode.restype = ffi.LLVMModuleRef
-ffi.lib.LLVMPY_GetGlobalContext.restype = ffi.LLVMContextRef
-
ffi.lib.LLVMPY_DisposeModule.argtypes = [ffi.LLVMModuleRef]
ffi.lib.LLVMPY_PrintModuleToString.argtypes = [ffi.LLVMModuleRef,
@@ -250,6 +296,9 @@
ffi.lib.LLVMPY_GetNamedGlobalVariable.argtypes = [ffi.LLVMModuleRef, c_char_p]
ffi.lib.LLVMPY_GetNamedGlobalVariable.restype = ffi.LLVMValueRef
+ffi.lib.LLVMPY_GetNamedStructType.argtypes = [ffi.LLVMModuleRef, c_char_p]
+ffi.lib.LLVMPY_GetNamedStructType.restype = ffi.LLVMTypeRef
+
ffi.lib.LLVMPY_ModuleGlobalsIter.argtypes = [ffi.LLVMModuleRef]
ffi.lib.LLVMPY_ModuleGlobalsIter.restype = ffi.LLVMGlobalsIterator
@@ -261,11 +310,19 @@
ffi.lib.LLVMPY_ModuleFunctionsIter.argtypes = [ffi.LLVMModuleRef]
ffi.lib.LLVMPY_ModuleFunctionsIter.restype = ffi.LLVMFunctionsIterator
+ffi.lib.LLVMPY_ModuleTypesIter.argtypes = [ffi.LLVMModuleRef]
+ffi.lib.LLVMPY_ModuleTypesIter.restype = ffi.LLVMTypesIterator
+
ffi.lib.LLVMPY_DisposeFunctionsIter.argtypes = [ffi.LLVMFunctionsIterator]
+ffi.lib.LLVMPY_DisposeTypesIter.argtypes = [ffi.LLVMTypesIterator]
+
ffi.lib.LLVMPY_FunctionsIterNext.argtypes = [ffi.LLVMFunctionsIterator]
ffi.lib.LLVMPY_FunctionsIterNext.restype = ffi.LLVMValueRef
+ffi.lib.LLVMPY_TypesIterNext.argtypes = [ffi.LLVMTypesIterator]
+ffi.lib.LLVMPY_TypesIterNext.restype = ffi.LLVMTypeRef
+
ffi.lib.LLVMPY_CloneModule.argtypes = [ffi.LLVMModuleRef]
ffi.lib.LLVMPY_CloneModule.restype = ffi.LLVMModuleRef
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/llvmlite-0.25.0/llvmlite/binding/targets.py new/llvmlite-0.26.0/llvmlite/binding/targets.py
--- old/llvmlite-0.25.0/llvmlite/binding/targets.py 2018-09-21 21:31:30.000000000 +0200
+++ new/llvmlite-0.26.0/llvmlite/binding/targets.py 2018-11-28 15:58:46.000000000 +0100
@@ -133,6 +133,18 @@
"""
return ffi.lib.LLVMPY_ABISizeOfType(self, ty)
+ def get_element_offset(self, ty, position):
+ """
+ Get byte offset of type's ty element at the given position
+ """
+
+ offset = ffi.lib.LLVMPY_OffsetOfElement(self, ty, position)
+ if offset == -1:
+ raise ValueError("Could not determined offset of {}th "
+ "element of the type '{}'. Is it a struct type?".format(
+ position, str(ty)))
+ return offset
+
def get_pointee_abi_size(self, ty):
"""
Get ABI size of pointee type of LLVM pointer type *ty*.
@@ -343,6 +355,11 @@
ffi.LLVMTypeRef]
ffi.lib.LLVMPY_ABISizeOfType.restype = c_longlong
+ffi.lib.LLVMPY_OffsetOfElement.argtypes = [ffi.LLVMTargetDataRef,
+ ffi.LLVMTypeRef,
+ c_int]
+ffi.lib.LLVMPY_OffsetOfElement.restype = c_longlong
+
ffi.lib.LLVMPY_ABISizeOfElementType.argtypes = [ffi.LLVMTargetDataRef,
ffi.LLVMTypeRef]
ffi.lib.LLVMPY_ABISizeOfElementType.restype = c_longlong
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/llvmlite-0.25.0/llvmlite/ir/values.py new/llvmlite-0.26.0/llvmlite/ir/values.py
--- old/llvmlite-0.25.0/llvmlite/ir/values.py 2018-09-21 21:31:30.000000000 +0200
+++ new/llvmlite-0.26.0/llvmlite/ir/values.py 2018-11-28 15:58:46.000000000 +0100
@@ -161,6 +161,12 @@
tys = [el.type for el in elems]
return cls(types.LiteralStructType(tys), elems)
+ @property
+ def addrspace(self):
+ if not isinstance(self.type, types.PointerType):
+ raise TypeError("Only pointer constant have address spaces")
+ return self.type.addrspace
+
def __eq__(self, other):
if isinstance(other, Constant):
return str(self) == str(other)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/llvmlite-0.25.0/llvmlite/tests/test_binding.py new/llvmlite-0.26.0/llvmlite/tests/test_binding.py
--- old/llvmlite-0.25.0/llvmlite/tests/test_binding.py 2018-09-21 21:31:30.000000000 +0200
+++ new/llvmlite-0.26.0/llvmlite/tests/test_binding.py 2018-11-28 15:58:46.000000000 +0100
@@ -174,9 +174,9 @@
# This will probably put any existing garbage in gc.garbage again
del self.old_garbage
- def module(self, asm=asm_sum):
+ def module(self, asm=asm_sum, context=None):
asm = asm.format(triple=llvm.get_default_triple())
- mod = llvm.parse_assembly(asm)
+ mod = llvm.parse_assembly(asm, context)
return mod
def glob(self, name='glob', mod=None):
@@ -244,6 +244,11 @@
self.assertIn("parsing error", s)
self.assertIn("invalid operand type", s)
+ def test_global_context(self):
+ gcontext1 = llvm.context.get_global_context()
+ gcontext2 = llvm.context.get_global_context()
+ assert gcontext1 == gcontext2
+
def test_dylib_symbols(self):
llvm.add_symbol("__xyzzy", 1234)
llvm.add_symbol("__xyzzy", 5678)
@@ -418,6 +423,18 @@
del mod
str(fn.module)
+ def test_get_struct_type(self):
+ mod = self.module()
+ st_ty = mod.get_struct_type("struct.glob_type")
+ self.assertEquals(st_ty.name, "struct.glob_type")
+ # also match struct names of form "%struct.glob_type.{some_index}"
+ self.assertIsNotNone(re.match(
+ r'%struct\.glob_type(\.[\d]+)? = type { i64, \[2 x i64\] }',
+ str(st_ty)))
+
+ with self.assertRaises(NameError):
+ mod.get_struct_type("struct.doesnt_exist")
+
def test_get_global_variable(self):
mod = self.module()
gv = mod.get_global_variable("glob")
@@ -447,6 +464,19 @@
funcs = list(it)
self.assertEqual(len(funcs), 1)
self.assertEqual(funcs[0].name, "sum")
+
+ def test_structs(self):
+ mod = self.module()
+ it = mod.struct_types
+ del mod
+ structs = list(it)
+ self.assertEqual(len(structs), 1)
+ self.assertIsNotNone(re.match(r'struct\.glob_type(\.[\d]+)?',
+ structs[0].name))
+ self.assertIsNotNone(re.match(
+ r'%struct\.glob_type(\.[\d]+)? = type { i64, \[2 x i64\] }',
+ str(structs[0])))
+
def test_link_in(self):
dest = self.module()
src = self.module(asm_mul)
@@ -494,12 +524,15 @@
self.assertIn("Invalid bitcode signature", str(cm.exception))
def test_bitcode_roundtrip(self):
- bc = self.module(asm=asm_mul).as_bitcode()
- mod = llvm.parse_bitcode(bc)
+ # create a new context to avoid struct renaming
+ context1 = llvm.create_context()
+ bc = self.module(context=context1).as_bitcode()
+ context2 = llvm.create_context()
+ mod = llvm.parse_bitcode(bc, context2)
self.assertEqual(mod.as_bitcode(), bc)
- mod.get_function("mul")
- mod.get_global_variable("mul_glob")
+ mod.get_function("sum")
+ mod.get_global_variable("glob")
def test_cloning(self):
m = self.module()
@@ -806,7 +839,7 @@
self.assertEqual(tp.name, "")
st = mod.get_global_variable("glob_struct")
self.assertIsNotNone(re.match(r"struct\.glob_type(\.[\d]+)?",
- st.type.element_type.name))
+ st.type.element_type.name))
def test_type_printing_variable(self):
mod = self.module()
@@ -824,7 +857,7 @@
st = mod.get_global_variable("glob_struct")
self.assertTrue(st.type.is_pointer)
self.assertIsNotNone(re.match(r'%struct\.glob_type(\.[\d]+)?\*',
- str(st.type)))
+ str(st.type)))
self.assertIsNotNone(re.match(
r"%struct\.glob_type(\.[\d]+)? = type { i64, \[2 x i64\] }",
str(st.type.element_type)))
@@ -891,6 +924,26 @@
glob = self.glob()
self.assertEqual(td.get_abi_size(glob.type), 8)
+ def test_get_pointee_abi_size(self):
+ td = self.target_data()
+
+ glob = self.glob()
+ self.assertEqual(td.get_pointee_abi_size(glob.type), 4)
+
+ glob = self.glob("glob_struct")
+ self.assertEqual(td.get_pointee_abi_size(glob.type), 24)
+
+ def test_get_struct_element_offset(self):
+ td = self.target_data()
+ glob = self.glob("glob_struct")
+
+ with self.assertRaises(ValueError):
+ td.get_element_offset(glob.type, 0)
+
+ struct_type = glob.type.element_type
+ self.assertEqual(td.get_element_offset(struct_type, 0), 0)
+ self.assertEqual(td.get_element_offset(struct_type, 1), 8)
+
class TestTargetMachine(BaseTest):
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/llvmlite-0.25.0/llvmlite/tests/test_ir.py new/llvmlite-0.26.0/llvmlite/tests/test_ir.py
--- old/llvmlite-0.25.0/llvmlite/tests/test_ir.py 2018-09-21 21:31:30.000000000 +0200
+++ new/llvmlite-0.26.0/llvmlite/tests/test_ir.py 2018-11-28 15:58:46.000000000 +0100
@@ -1908,6 +1908,17 @@
'getelementptr ({float, i1}, {float, i1}* @"myconstant", i32 0, i32 1)')
self.assertEqual(c.type, ir.PointerType(int1))
+ const = ir.Constant(tp, None)
+ with self.assertRaises(TypeError):
+ c_wrong = const.gep([ir.Constant(int32, 0)])
+
+ const_ptr = ir.Constant(tp.as_pointer(), None)
+ c2 = const_ptr.gep([ir.Constant(int32, 0)])
+ self.assertEqual(str(c2),
+ 'getelementptr ({float, i1}, {float, i1}* null, i32 0)')
+ self.assertEqual(c.type, ir.PointerType(int1))
+
+
def test_gep_addrspace_globalvar(self):
m = self.module()
tp = ir.LiteralStructType((flt, int1))