diff --git a/artiq/compiler/transforms/llvm_ir_generator.py b/artiq/compiler/transforms/llvm_ir_generator.py index afbc6cbc9..013d2a5ea 100644 --- a/artiq/compiler/transforms/llvm_ir_generator.py +++ b/artiq/compiler/transforms/llvm_ir_generator.py @@ -1339,6 +1339,12 @@ class LLVMIRGenerator: self.llbuilder.call(self.llbuiltin("llvm.stackrestore"), [llstackptr]) 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 # T result = { diff --git a/artiq/test/coredevice/test_embedding.py b/artiq/test/coredevice/test_embedding.py index d8d85d5e0..21f0c14f2 100644 --- a/artiq/test/coredevice/test_embedding.py +++ b/artiq/test/coredevice/test_embedding.py @@ -223,6 +223,17 @@ class _RPCCalls(EnvExperiment): def builtin(self): 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): def test_args(self): @@ -239,6 +250,7 @@ class RPCCallsTest(ExperimentCase): self.assertTrue((exp.numpy_full() == numpy.full(10, 20)).all()) self.assertTrue(numpy.isnan(exp.numpy_nan()).all()) exp.builtin() + exp.async_in_try() class _Annotation(EnvExperiment):