Skip to content

Commit 692791f

Browse files
author
whitequark
committedJul 25, 2015
Make sure a landing pad returns {i8*} to soothe LLVM codegen.
1 parent ece5206 commit 692791f

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed
 

Diff for: ‎artiq/compiler/transforms/llvm_ir_generator.py

+12-6
Original file line numberDiff line numberDiff line change
@@ -588,9 +588,11 @@ def process_Raise(self, insn):
588588
return llinsn
589589

590590
def process_LandingPad(self, insn):
591-
lllandingpad = self.llbuilder.landingpad(self.llty_of_type(insn.type),
591+
lllandingpad = self.llbuilder.landingpad(ll.LiteralStructType([ll.IntType(8).as_pointer()]),
592592
self.llbuiltin("__artiq_personality"))
593-
llexnnameptr = self.llbuilder.gep(lllandingpad, [self.llindex(0), self.llindex(0)])
593+
llrawexn = self.llbuilder.extract_value(lllandingpad, 0)
594+
llexn = self.llbuilder.bitcast(llrawexn, self.llty_of_type(insn.type))
595+
llexnnameptr = self.llbuilder.gep(llexn, [self.llindex(0), self.llindex(0)])
594596
llexnname = self.llbuilder.load(llexnnameptr)
595597

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

605-
llmatchingclause = self.llbuilder.icmp_unsigned('==', llexnname, llclauseexnname)
606-
with self.llbuilder.if_then(llmatchingclause):
607+
if typ is None:
607608
self.llbuilder.branch(self.map(target))
609+
else:
610+
llmatchingclause = self.llbuilder.icmp_unsigned('==', llexnname, llclauseexnname)
611+
with self.llbuilder.if_then(llmatchingclause):
612+
self.llbuilder.branch(self.map(target))
608613

609-
self.llbuilder.resume(lllandingpad)
614+
if self.llbuilder.basic_block.terminator is None:
615+
self.llbuilder.resume(lllandingpad)
610616

611-
return lllandingpad
617+
return llexn
612618

0 commit comments

Comments
 (0)