Skip to content

Commit

Permalink
Make sure a landing pad returns {i8*} to soothe LLVM codegen.
Browse files Browse the repository at this point in the history
whitequark committed Jul 25, 2015
1 parent ece5206 commit 692791f
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions artiq/compiler/transforms/llvm_ir_generator.py
Original file line number Diff line number Diff line change
@@ -588,9 +588,11 @@ def process_Raise(self, insn):
return llinsn

def process_LandingPad(self, insn):
lllandingpad = self.llbuilder.landingpad(self.llty_of_type(insn.type),
lllandingpad = self.llbuilder.landingpad(ll.LiteralStructType([ll.IntType(8).as_pointer()]),
self.llbuiltin("__artiq_personality"))
llexnnameptr = self.llbuilder.gep(lllandingpad, [self.llindex(0), self.llindex(0)])
llrawexn = self.llbuilder.extract_value(lllandingpad, 0)
llexn = self.llbuilder.bitcast(llrawexn, self.llty_of_type(insn.type))
llexnnameptr = self.llbuilder.gep(llexn, [self.llindex(0), self.llindex(0)])
llexnname = self.llbuilder.load(llexnnameptr)

for target, typ in insn.clauses():
@@ -602,11 +604,15 @@ def process_LandingPad(self, insn):
ir.Constant(typ.name, ir.TExceptionTypeInfo()))
lllandingpad.add_clause(ll.CatchClause(llclauseexnname))

llmatchingclause = self.llbuilder.icmp_unsigned('==', llexnname, llclauseexnname)
with self.llbuilder.if_then(llmatchingclause):
if typ is None:
self.llbuilder.branch(self.map(target))
else:
llmatchingclause = self.llbuilder.icmp_unsigned('==', llexnname, llclauseexnname)
with self.llbuilder.if_then(llmatchingclause):
self.llbuilder.branch(self.map(target))

self.llbuilder.resume(lllandingpad)
if self.llbuilder.basic_block.terminator is None:
self.llbuilder.resume(lllandingpad)

return lllandingpad
return llexn

0 comments on commit 692791f

Please sign in to comment.