transforms.llvm_ir_generator: fix reraise inside EH block.

This commit is contained in:
whitequark 2015-12-10 23:02:32 +08:00
parent 3ec9b677b2
commit c660028abf
1 changed files with 8 additions and 9 deletions

View File

@ -1093,30 +1093,29 @@ class LLVMIRGenerator:
def process_Unreachable(self, insn): def process_Unreachable(self, insn):
return self.llbuilder.unreachable() return self.llbuilder.unreachable()
def process_Raise(self, insn): def _gen_raise(self, insn, func, args):
llexn = self.map(insn.value())
if insn.exception_target() is not None: if insn.exception_target() is not None:
llnormalblock = self.llfunction.append_basic_block("unreachable") llnormalblock = self.llfunction.append_basic_block("unreachable")
llnormalblock.terminator = ll.Unreachable(llnormalblock) llnormalblock.terminator = ll.Unreachable(llnormalblock)
llnormalblock.instructions.append(llnormalblock.terminator) llnormalblock.instructions.append(llnormalblock.terminator)
llunwindblock = self.map(insn.exception_target()) llunwindblock = self.map(insn.exception_target())
llinsn = self.llbuilder.invoke(self.llbuiltin("__artiq_raise"), [llexn], llinsn = self.llbuilder.invoke(func, args,
llnormalblock, llunwindblock, llnormalblock, llunwindblock,
name=insn.name) name=insn.name)
else: else:
llinsn = self.llbuilder.call(self.llbuiltin("__artiq_raise"), [llexn], llinsn = self.llbuilder.call(func, args,
name=insn.name) name=insn.name)
self.llbuilder.unreachable() self.llbuilder.unreachable()
llinsn.attributes.add('noreturn') llinsn.attributes.add('noreturn')
return llinsn return llinsn
def process_Raise(self, insn):
llexn = self.map(insn.value())
return self._gen_raise(insn, self.llbuiltin("__artiq_raise"), [llexn])
def process_Reraise(self, insn): def process_Reraise(self, insn):
llinsn = self.llbuilder.call(self.llbuiltin("__artiq_reraise"), [], return self._gen_raise(insn, self.llbuiltin("__artiq_reraise"), [])
name=insn.name)
llinsn.attributes.add('noreturn')
self.llbuilder.unreachable()
return llinsn
def process_LandingPad(self, insn): def process_LandingPad(self, insn):
# Layout on return from landing pad: {%_Unwind_Exception*, %Exception*} # Layout on return from landing pad: {%_Unwind_Exception*, %Exception*}