diff options
author | Tristan Gingold <tgingold@free.fr> | 2018-05-26 08:12:34 +0200 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2018-05-26 08:12:34 +0200 |
commit | 9d455c481f0fe7e762c6bee796643d4138205ef9 (patch) | |
tree | ed931ccb6a1ff6c00e68f0704c7a4a90a78af424 /src | |
parent | 56c06814817f3bd5134c34271023da400d2de1fc (diff) | |
download | ghdl-9d455c481f0fe7e762c6bee796643d4138205ef9.tar.gz ghdl-9d455c481f0fe7e762c6bee796643d4138205ef9.tar.bz2 ghdl-9d455c481f0fe7e762c6bee796643d4138205ef9.zip |
ortho_llvm: do not generate loop_stmt/indexed_element if unreachable.
Fix for #578
Diffstat (limited to 'src')
-rw-r--r-- | src/ortho/llvm/ortho_llvm.adb | 25 | ||||
-rw-r--r-- | src/ortho/llvm4-nodebug/ortho_llvm.adb | 25 |
2 files changed, 34 insertions, 16 deletions
diff --git a/src/ortho/llvm/ortho_llvm.adb b/src/ortho/llvm/ortho_llvm.adb index 3075b8bca..4c1550237 100644 --- a/src/ortho/llvm/ortho_llvm.adb +++ b/src/ortho/llvm/ortho_llvm.adb @@ -1451,11 +1451,16 @@ package body Ortho_LLVM is Idx : constant ValueRefArray (1 .. 2) := (ConstInt (Int32Type, 0, 0), Index.LLVM); + Tmp : ValueRef; begin - return O_Lnode' - (Direct => False, - LLVM => BuildGEP (Builder, Arr.LLVM, Idx, Idx'Length, Empty_Cstring), - Ltype => Arr.Ltype.Arr_El_Type); + if Unreach then + Tmp := Null_ValueRef; + else + Tmp := BuildGEP (Builder, Arr.LLVM, Idx, Idx'Length, Empty_Cstring); + end if; + return O_Lnode'(Direct => False, + LLVM => Tmp, + Ltype => Arr.Ltype.Arr_El_Type); end New_Indexed_Element; --------------- @@ -2684,10 +2689,14 @@ package body Ortho_LLVM is pragma Unreferenced (Res); begin -- FIXME: check Unreach - Label := (Bb_Entry => AppendBasicBlock (Cur_Func, Empty_Cstring), - Bb_Exit => AppendBasicBlock (Cur_Func, Empty_Cstring)); - Res := BuildBr (Builder, Label.Bb_Entry); - PositionBuilderAtEnd (Builder, Label.Bb_Entry); + if Unreach then + Label := (Null_BasicBlockRef, Null_BasicBlockRef); + else + Label := (Bb_Entry => AppendBasicBlock (Cur_Func, Empty_Cstring), + Bb_Exit => AppendBasicBlock (Cur_Func, Empty_Cstring)); + Res := BuildBr (Builder, Label.Bb_Entry); + PositionBuilderAtEnd (Builder, Label.Bb_Entry); + end if; end Start_Loop_Stmt; ---------------------- diff --git a/src/ortho/llvm4-nodebug/ortho_llvm.adb b/src/ortho/llvm4-nodebug/ortho_llvm.adb index 53f8dbe31..b8ab44bbe 100644 --- a/src/ortho/llvm4-nodebug/ortho_llvm.adb +++ b/src/ortho/llvm4-nodebug/ortho_llvm.adb @@ -1111,11 +1111,16 @@ package body Ortho_LLVM is Idx : constant ValueRefArray (1 .. 2) := (ConstInt (Int32Type, 0, 0), Index.LLVM); + Tmp : ValueRef; begin - return O_Lnode' - (Direct => False, - LLVM => BuildGEP (Builder, Arr.LLVM, Idx, Idx'Length, Empty_Cstring), - Ltype => Arr.Ltype.Arr_El_Type); + if Unreach then + Tmp := Null_ValueRef; + else + Tmp := BuildGEP (Builder, Arr.LLVM, Idx, Idx'Length, Empty_Cstring); + end if; + return O_Lnode'(Direct => False, + LLVM => Tmp, + Ltype => Arr.Ltype.Arr_El_Type); end New_Indexed_Element; --------------- @@ -2021,10 +2026,14 @@ package body Ortho_LLVM is pragma Unreferenced (Res); begin -- FIXME: check Unreach - Label := (Bb_Entry => AppendBasicBlock (Cur_Func, Empty_Cstring), - Bb_Exit => AppendBasicBlock (Cur_Func, Empty_Cstring)); - Res := BuildBr (Builder, Label.Bb_Entry); - PositionBuilderAtEnd (Builder, Label.Bb_Entry); + if Unreach then + Label := (Null_BasicBlockRef, Null_BasicBlockRef); + else + Label := (Bb_Entry => AppendBasicBlock (Cur_Func, Empty_Cstring), + Bb_Exit => AppendBasicBlock (Cur_Func, Empty_Cstring)); + Res := BuildBr (Builder, Label.Bb_Entry); + PositionBuilderAtEnd (Builder, Label.Bb_Entry); + end if; end Start_Loop_Stmt; ---------------------- |