Skip to content

Commit

Permalink
transforms.llvm_ir_generator: compare exn typeinfo using strcmp.
Browse files Browse the repository at this point in the history
This is necessary to correctly catch exceptions from RPCs.
whitequark committed Dec 31, 2015
1 parent 9ed6b54 commit 0b69e48
Showing 2 changed files with 7 additions and 1 deletion.
7 changes: 6 additions & 1 deletion artiq/compiler/transforms/llvm_ir_generator.py
Original file line number Diff line number Diff line change
@@ -364,6 +364,8 @@ def llbuiltin(self, name):
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 @@ def process_LandingPad(self, insn):
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))

1 change: 1 addition & 0 deletions artiq/runtime/ksupport.c
Original file line number Diff line number Diff line change
@@ -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 */

0 comments on commit 0b69e48

Please sign in to comment.