Skip to content

Commit

Permalink
Merge pull request #1019 from diptorupd/add_convergent_attribute
Browse files Browse the repository at this point in the history
Add convergent as a supported FunctionAttribute and CallInstrAttribute.
  • Loading branch information
sklam authored Dec 7, 2023
2 parents 53488e9 + fa1fd33 commit e70590f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions llvmlite/ir/instructions.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ def __repr__(self):


class CallInstrAttributes(AttributeSet):
_known = frozenset(['noreturn', 'nounwind', 'readonly', 'readnone',
'noinline', 'alwaysinline'])
_known = frozenset(['convergent', 'noreturn', 'nounwind', 'readonly',
'readnone', 'noinline', 'alwaysinline'])


TailMarkerOptions = frozenset(['tail', 'musttail', 'notail'])
Expand Down
2 changes: 1 addition & 1 deletion llvmlite/ir/values.py
Original file line number Diff line number Diff line change
Expand Up @@ -878,7 +878,7 @@ def _to_list(self, typ):

class FunctionAttributes(AttributeSet):
_known = frozenset([
'argmemonly', 'alwaysinline', 'builtin', 'cold',
'argmemonly', 'alwaysinline', 'builtin', 'cold', 'convergent',
'inaccessiblememonly', 'inaccessiblemem_or_argmemonly', 'inlinehint',
'jumptable', 'minsize', 'naked', 'nobuiltin', 'noduplicate',
'noimplicitfloat', 'noinline', 'nonlazybind', 'norecurse',
Expand Down
6 changes: 5 additions & 1 deletion llvmlite/tests/test_ir.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,15 @@ def test_declare_attributes(self):
func = self.function()
func.attributes.add("optsize")
func.attributes.add("alwaysinline")
func.attributes.add("convergent")
func.attributes.alignstack = 16
tp_pers = ir.FunctionType(int8, (), var_arg=True)
pers = ir.Function(self.module(), tp_pers, '__gxx_personality_v0')
func.attributes.personality = pers
asm = self.descr(func).strip()
self.assertEqual(asm,
("declare %s alwaysinline optsize alignstack(16) "
("declare %s alwaysinline convergent optsize "
"alignstack(16) "
"personality i8 (...)* @\"__gxx_personality_v0\"") %
self.proto)
# Check pickling
Expand Down Expand Up @@ -1322,6 +1324,7 @@ def test_call(self):
builder.call(f, (a, b), 'res_alwaysinline', attrs='alwaysinline')
builder.call(f, (a, b), 'res_noinline_ro', attrs=('noinline',
'readonly'))
builder.call(f, (a, b), 'res_convergent', attrs='convergent')
self.check_block(block, """\
my_block:
%"res_f" = call float @"f"(i32 %".1", i32 %".2")
Expand All @@ -1334,6 +1337,7 @@ def test_call(self):
%"res_noinline" = call float @"f"(i32 %".1", i32 %".2") noinline
%"res_alwaysinline" = call float @"f"(i32 %".1", i32 %".2") alwaysinline
%"res_noinline_ro" = call float @"f"(i32 %".1", i32 %".2") noinline readonly
%"res_convergent" = call float @"f"(i32 %".1", i32 %".2") convergent
""") # noqa E501

def test_call_metadata(self):
Expand Down

0 comments on commit e70590f

Please sign in to comment.