Fix: if-else branch should terminate automatically. Insert unreachable to if.end block if necessary.
This commit is contained in:
parent
d55bb95d4d
commit
562e3c1e46
1 changed files with 4 additions and 0 deletions
|
|
@ -97,11 +97,15 @@ class _IfElse(object):
|
||||||
self._to_close.append(self.parent.builder.basic_block)
|
self._to_close.append(self.parent.builder.basic_block)
|
||||||
bbend = self.parent.function.append_basic_block('if.end')
|
bbend = self.parent.function.append_basic_block('if.end')
|
||||||
builder = self.parent.builder
|
builder = self.parent.builder
|
||||||
|
closed_count = 0
|
||||||
for bb in self._to_close:
|
for bb in self._to_close:
|
||||||
if not _is_block_terminated(bb):
|
if not _is_block_terminated(bb):
|
||||||
with _change_block_temporarily(builder, bb):
|
with _change_block_temporarily(builder, bb):
|
||||||
builder.branch(bbend)
|
builder.branch(bbend)
|
||||||
|
closed_count += 1
|
||||||
builder.position_at_end(bbend)
|
builder.position_at_end(bbend)
|
||||||
|
if not closed_count:
|
||||||
|
self.parent.unreachable()
|
||||||
|
|
||||||
class _Loop(object):
|
class _Loop(object):
|
||||||
'''while...do loop.
|
'''while...do loop.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue