From acffa533783d60378631c5ba4b358d2fb54cd00a Mon Sep 17 00:00:00 2001 From: Diptorup Deb Date: Tue, 28 Nov 2023 23:25:53 -0600 Subject: [PATCH 1/2] Add convergent as a supported FunctionAttribute and CallInstrAttribute. --- llvmlite/ir/instructions.py | 4 ++-- llvmlite/ir/values.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/llvmlite/ir/instructions.py b/llvmlite/ir/instructions.py index 044d43453..c6d488aae 100644 --- a/llvmlite/ir/instructions.py +++ b/llvmlite/ir/instructions.py @@ -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']) diff --git a/llvmlite/ir/values.py b/llvmlite/ir/values.py index 93431210d..3818e6f34 100644 --- a/llvmlite/ir/values.py +++ b/llvmlite/ir/values.py @@ -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', From fa1fd3398f5c3b96a1741d2e92809863cf794f26 Mon Sep 17 00:00:00 2001 From: Diptorup Deb Date: Wed, 29 Nov 2023 18:13:21 -0600 Subject: [PATCH 2/2] Add unit tests for the new convergent attribute. --- llvmlite/tests/test_ir.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/llvmlite/tests/test_ir.py b/llvmlite/tests/test_ir.py index 63a7c5f30..284129679 100644 --- a/llvmlite/tests/test_ir.py +++ b/llvmlite/tests/test_ir.py @@ -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 @@ -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") @@ -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):