From d43f982a3168b554fd0745c23c59f94503c0a211 Mon Sep 17 00:00:00 2001 From: Tristan Gingold Date: Sun, 22 Mar 2015 19:04:08 +0100 Subject: ortho_llvm: handle more unreach cases. --- src/ortho/llvm/ortho_llvm.adb | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'src/ortho/llvm/ortho_llvm.adb') diff --git a/src/ortho/llvm/ortho_llvm.adb b/src/ortho/llvm/ortho_llvm.adb index a1c85db..0975698 100644 --- a/src/ortho/llvm/ortho_llvm.adb +++ b/src/ortho/llvm/ortho_llvm.adb @@ -1280,6 +1280,10 @@ package body Ortho_LLVM is is Res : ValueRef; begin + if Unreach then + return O_Enode'(LLVM => Null_ValueRef, Etype => Operand.Etype); + end if; + case Operand.Etype.Kind is when ON_Integer_Types => case Kind is @@ -1355,6 +1359,10 @@ package body Ortho_LLVM is is Res : ValueRef; begin + if Unreach then + return O_Enode'(LLVM => Null_ValueRef, Etype => Ntype); + end if; + case Left.Etype.Kind is when ON_Unsigned_Type | ON_Boolean_Type @@ -2515,7 +2523,11 @@ package body Ortho_LLVM is Res : ValueRef; Bb_Then : BasicBlockRef; begin - -- FIXME: check Unreach + if Unreach then + Block := (Bb => Null_BasicBlockRef); + return; + end if; + Bb_Then := AppendBasicBlock (Cur_Func, Empty_Cstring); Block := (Bb => AppendBasicBlock (Cur_Func, Empty_Cstring)); Res := BuildCondBr (Builder, Cond.LLVM, Bb_Then, Block.Bb); @@ -2537,6 +2549,11 @@ package body Ortho_LLVM is Bb_Next := AppendBasicBlock (Cur_Func, Empty_Cstring); Res := BuildBr (Builder, Bb_Next); else + if Block.Bb = Null_BasicBlockRef then + -- The IF statement was unreachable. Else part is also + -- unreachable. + return; + end if; Bb_Next := Null_BasicBlockRef; end if; -- cgit