forked from M-Labs/artiq
1
0
Fork 0

Make sure a landing pad returns {i8*} to soothe LLVM codegen.

This commit is contained in:
whitequark 2015-07-25 07:01:25 +03:00
parent ece52062f2
commit 692791f0bd
1 changed files with 12 additions and 6 deletions

View File

@ -588,9 +588,11 @@ class LLVMIRGenerator:
return llinsn return llinsn
def process_LandingPad(self, insn): 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")) 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) llexnname = self.llbuilder.load(llexnnameptr)
for target, typ in insn.clauses(): for target, typ in insn.clauses():
@ -602,11 +604,15 @@ class LLVMIRGenerator:
ir.Constant(typ.name, ir.TExceptionTypeInfo())) ir.Constant(typ.name, ir.TExceptionTypeInfo()))
lllandingpad.add_clause(ll.CatchClause(llclauseexnname)) lllandingpad.add_clause(ll.CatchClause(llclauseexnname))
llmatchingclause = self.llbuilder.icmp_unsigned('==', llexnname, llclauseexnname) if typ is None:
with self.llbuilder.if_then(llmatchingclause):
self.llbuilder.branch(self.map(target)) 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