forked from M-Labs/artiq
1
0
Fork 0

compiler: handle async RPC as last statement in try block.

Fixes #1107.
This commit is contained in:
whitequark 2018-08-07 07:06:53 +00:00
parent 7bd7b6592a
commit 93af5d2a03
2 changed files with 18 additions and 0 deletions

View File

@ -1339,6 +1339,12 @@ class LLVMIRGenerator:
self.llbuilder.call(self.llbuiltin("llvm.stackrestore"), [llstackptr]) self.llbuilder.call(self.llbuiltin("llvm.stackrestore"), [llstackptr])
if fun_type.async: if fun_type.async:
# If this RPC is called using an `invoke` ARTIQ IR instruction, there will be
# no other instructions in this basic block. Since this RPC is async, it cannot
# possibly raise an exception, so add an explicit jump to the normal successor.
if llunwindblock:
self.llbuilder.branch(llnormalblock)
return ll.Undefined return ll.Undefined
# T result = { # T result = {

View File

@ -223,6 +223,17 @@ class _RPCCalls(EnvExperiment):
def builtin(self): def builtin(self):
sleep(1.0) sleep(1.0)
@rpc(flags={"async"})
def async_rpc(self):
pass
@kernel
def async_in_try(self):
try:
self.async_rpc()
except ValueError:
pass
class RPCCallsTest(ExperimentCase): class RPCCallsTest(ExperimentCase):
def test_args(self): def test_args(self):
@ -239,6 +250,7 @@ class RPCCallsTest(ExperimentCase):
self.assertTrue((exp.numpy_full() == numpy.full(10, 20)).all()) self.assertTrue((exp.numpy_full() == numpy.full(10, 20)).all())
self.assertTrue(numpy.isnan(exp.numpy_nan()).all()) self.assertTrue(numpy.isnan(exp.numpy_nan()).all())
exp.builtin() exp.builtin()
exp.async_in_try()
class _Annotation(EnvExperiment): class _Annotation(EnvExperiment):