From 9fd25a1cc4665ea9dc1c52345e944e4a32f5a337 Mon Sep 17 00:00:00 2001 From: whitequark Date: Fri, 28 Aug 2015 03:03:12 -0500 Subject: [PATCH] LLVMIRGenerator: fix syscall emission. --- artiq/compiler/transforms/llvm_ir_generator.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/artiq/compiler/transforms/llvm_ir_generator.py b/artiq/compiler/transforms/llvm_ir_generator.py index 51218b294..05e3212ab 100644 --- a/artiq/compiler/transforms/llvm_ir_generator.py +++ b/artiq/compiler/transforms/llvm_ir_generator.py @@ -793,10 +793,13 @@ class LLVMIRGenerator: def _prepare_ffi_call(self, insn): llargs = [self.map(arg) for arg in insn.arguments()] - llfunty = ll.FunctionType(self.llty_of_type(insn.type, for_return=True), - [llarg.type for llarg in llargs]) - llfun = ll.Function(self.llmodule, llfunty, - insn.target_function().type.name) + llfunname = insn.target_function().type.name + llfun = self.llmodule.get_global(llfunname) + if llfun is None: + llfunty = ll.FunctionType(self.llty_of_type(insn.type, for_return=True), + [llarg.type for llarg in llargs]) + llfun = ll.Function(self.llmodule, llfunty, + insn.target_function().type.name) return llfun, list(llargs) # See session.c:{send,receive}_rpc_value and comm_generic.py:_{send,receive}_rpc_value.