From 0b69e488e64ad8a698cd7bff502fa4511161dd6b Mon Sep 17 00:00:00 2001 From: whitequark Date: Thu, 31 Dec 2015 19:53:28 +0800 Subject: [PATCH] transforms.llvm_ir_generator: compare exn typeinfo using strcmp. This is necessary to correctly catch exceptions from RPCs. --- artiq/compiler/transforms/llvm_ir_generator.py | 7 ++++++- artiq/runtime/ksupport.c | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/artiq/compiler/transforms/llvm_ir_generator.py b/artiq/compiler/transforms/llvm_ir_generator.py index d021e2869..68670ac62 100644 --- a/artiq/compiler/transforms/llvm_ir_generator.py +++ b/artiq/compiler/transforms/llvm_ir_generator.py @@ -364,6 +364,8 @@ class LLVMIRGenerator: llty = ll.FunctionType(llvoid, [self.llty_of_type(builtins.TException())]) elif name == "__artiq_reraise": llty = ll.FunctionType(llvoid, []) + elif name == "strcmp": + llty = ll.FunctionType(lli32, [llptr, llptr]) elif name == "send_rpc": llty = ll.FunctionType(llvoid, [lli32, llptr], var_arg=True) @@ -1159,7 +1161,10 @@ class LLVMIRGenerator: if typ is None: self.llbuilder.branch(self.map(target)) else: - llmatchingclause = self.llbuilder.icmp_unsigned('==', llexnname, llclauseexnname) + llexnmatch = self.llbuilder.call(self.llbuiltin("strcmp"), + [llexnname, llclauseexnname]) + llmatchingclause = self.llbuilder.icmp_unsigned('==', + llexnmatch, ll.Constant(lli32, 0)) with self.llbuilder.if_then(llmatchingclause): self.llbuilder.branch(self.map(target)) diff --git a/artiq/runtime/ksupport.c b/artiq/runtime/ksupport.c index 3da82f76f..fdf40fb32 100644 --- a/artiq/runtime/ksupport.c +++ b/artiq/runtime/ksupport.c @@ -92,6 +92,7 @@ static const struct symbol runtime_exports[] = { {"__artiq_personality", &__artiq_personality}, {"__artiq_raise", &__artiq_raise}, {"__artiq_reraise", &__artiq_reraise}, + {"strcmp", &strcmp}, {"abort", &ksupport_abort}, /* proxified syscalls */