Skip to content

Commit

Permalink
Merge pull request #649 from sklam/misc/0.35.0rc3
Browse files Browse the repository at this point in the history
Preparing 0.35.0rc3
  • Loading branch information
sklam committed Nov 13, 2020
2 parents 5202760 + 9e87d1f commit 10a4928
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGE_LOG
Expand Up @@ -21,6 +21,7 @@ Pull requests:
* PR #641: fix llvmdev build number
* PR #642: pin to correct version of llvmdev
* PR #644: Fix refprune fanout_raise case getting stuck on large graphs
* PR #647: Add support for general attrs on call and loop-rotate pass

Authors:

Expand Down
6 changes: 6 additions & 0 deletions ffi/passmanagers.cpp
Expand Up @@ -161,4 +161,10 @@ LLVMPY_AddBasicAliasAnalysisPass(LLVMPassManagerRef PM)
LLVMAddBasicAliasAnalysisPass(PM);
}

API_EXPORT(void)
LLVMPY_LLVMAddLoopRotatePass(LLVMPassManagerRef PM)
{
LLVMAddLoopRotatePass(PM);
}

} // end extern "C"
4 changes: 4 additions & 0 deletions llvmlite/binding/passmanagers.py
Expand Up @@ -141,6 +141,10 @@ def add_basic_alias_analysis_pass(self):
"""See http://llvm.org/docs/AliasAnalysis.html#the-basicaa-pass."""
ffi.lib.LLVMPY_AddBasicAliasAnalysisPass(self)

def add_loop_rotate_pass(self):
"""http://llvm.org/docs/Passes.html#loop-rotate-rotate-loops."""
ffi.lib.LLVMPY_LLVMAddLoopRotatePass(self)

# Non-standard LLVM passes

def add_refprune_pass(self, subpasses_flags=RefPruneSubpasses.ALL,
Expand Down
6 changes: 4 additions & 2 deletions llvmlite/ir/builder.py
Expand Up @@ -851,13 +851,15 @@ def resume(self, landingpad):

# Call APIs

def call(self, fn, args, name='', cconv=None, tail=False, fastmath=()):
def call(self, fn, args, name='', cconv=None, tail=False, fastmath=(),
attrs=()):
"""
Call function *fn* with *args*:
name = fn(args...)
"""
inst = instructions.CallInstr(self.block, fn, args, name=name,
cconv=cconv, tail=tail, fastmath=fastmath)
cconv=cconv, tail=tail, fastmath=fastmath,
attrs=attrs)
self._insert(inst)
return inst

Expand Down
7 changes: 4 additions & 3 deletions llvmlite/ir/instructions.py
Expand Up @@ -52,7 +52,8 @@ def __repr__(self):


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


class FastMathFlags(AttributeSet):
Expand All @@ -62,13 +63,13 @@ class FastMathFlags(AttributeSet):

class CallInstr(Instruction):
def __init__(self, parent, func, args, name='', cconv=None, tail=False,
fastmath=()):
fastmath=(), attrs=()):
self.cconv = (func.calling_convention
if cconv is None and isinstance(func, Function)
else cconv)
self.tail = tail
self.fastmath = FastMathFlags(fastmath)
self.attributes = CallInstrAttributes()
self.attributes = CallInstrAttributes(attrs)

# Fix and validate arguments
args = list(args)
Expand Down
1 change: 1 addition & 0 deletions llvmlite/tests/test_binding.py
Expand Up @@ -1290,6 +1290,7 @@ def test_populate(self):
pm.add_sroa_pass()
pm.add_type_based_alias_analysis_pass()
pm.add_basic_alias_analysis_pass()
pm.add_loop_rotate_pass()


class TestDylib(BaseTest):
Expand Down
9 changes: 8 additions & 1 deletion llvmlite/tests/test_ir.py
Expand Up @@ -1141,6 +1141,10 @@ def test_call(self):
res_f_readonly.attributes.add('readonly')
builder.call(f, (a, b), 'res_fast', fastmath='fast')
builder.call(f, (a, b), 'res_nnan_ninf', fastmath=('nnan', 'ninf'))
builder.call(f, (a, b), 'res_noinline', attrs='noinline')
builder.call(f, (a, b), 'res_alwaysinline', attrs='alwaysinline')
builder.call(f, (a, b), 'res_noinline_ro', attrs=('noinline',
'readonly'))
self.check_block(block, """\
my_block:
%"res_f" = call float @"f"(i32 %".1", i32 %".2")
Expand All @@ -1150,7 +1154,10 @@ def test_call(self):
%"res_f_readonly" = call float @"f"(i32 %".1", i32 %".2") readonly
%"res_fast" = call fast float @"f"(i32 %".1", i32 %".2")
%"res_nnan_ninf" = call ninf nnan float @"f"(i32 %".1", i32 %".2")
""")
%"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
""") # noqa E501

def test_call_metadata(self):
"""
Expand Down

0 comments on commit 10a4928

Please sign in to comment.