[pypy-commit] pypy llvm-translation-backend: Pass more immutability hints to LLVM.

mjacob noreply at buildbot.pypy.org
Sat Feb 28 17:00:17 CET 2015


Author: Manuel Jacob <me at manueljacob.de>
Branch: llvm-translation-backend
Changeset: r76198:1b6be80b1ea6
Date: 2015-02-28 16:51 +0100
http://bitbucket.org/pypy/pypy/changeset/1b6be80b1ea6/

Log:	Pass more immutability hints to LLVM.

diff --git a/rpython/translator/llvm/genllvm.py b/rpython/translator/llvm/genllvm.py
--- a/rpython/translator/llvm/genllvm.py
+++ b/rpython/translator/llvm/genllvm.py
@@ -659,7 +659,7 @@
                     .format(self.typestr, groupname, i))
         struct_type = StructType()
         struct_type.setup('group_' + obj.name, fields, False)
-        database.f.write('{} = global {}\n'.format(
+        database.f.write('{} = constant {}\n'.format(
                 groupname, struct_type.repr_type_and_value(group)))
 
 
@@ -1216,9 +1216,13 @@
 
     def _get_element(self, result, var, *fields):
         if result.type is not LLVMVoid:
+            if var.type.lltype.TO._hints.get('immutable'):
+                metadata= ', !invariant.load !0'
+            else:
+                metadata=''
             t = self._tmp(PtrType.tmp(result.type))
             self._get_element_ptr(var, fields, t)
-            self.w('{result.V} = load {t.TV}'.format(**locals()))
+            self.w('{result.V} = load {t.TV}{metadata}'.format(**locals()))
     op_getfield = op_bare_getfield = _get_element
     op_getinteriorfield = op_bare_getinteriorfield = _get_element
     op_getarrayitem = op_bare_getarrayitem = _get_element
@@ -1835,6 +1839,7 @@
                 '}}\n'.format(raise_=get_repr(exctrans.rpyexc_raise_ptr),
                               type=get_repr(self.ovf_err[0]),
                               inst=get_repr(self.ovf_err[1])))
+        f.write('!0 = metadata !{ }\n')
 
     def gen_source(self):
         global database


More information about the pypy-commit mailing list