aboutsummaryrefslogtreecommitdiffstats
path: root/src/ortho
diff options
context:
space:
mode:
authorTristan Gingold <gingold@adacore.com>2015-12-18 17:17:27 +0100
committerTristan Gingold <gingold@adacore.com>2015-12-18 17:18:13 +0100
commitfee018a52616f9b257d84df05e565301f28474d3 (patch)
tree2797799ffc1cb64714c24ff4e4151b33b937f744 /src/ortho
parente8a965f0f42749f7fbcaaee966e24a55fb45d886 (diff)
downloadghdl-fee018a52616f9b257d84df05e565301f28474d3.tar.gz
ghdl-fee018a52616f9b257d84df05e565301f28474d3.tar.bz2
ghdl-fee018a52616f9b257d84df05e565301f28474d3.zip
ortho-llvm: avoid generation of unreachable code.
Diffstat (limited to 'src/ortho')
-rw-r--r--src/ortho/llvm/ortho_llvm.adb34
1 files changed, 23 insertions, 11 deletions
diff --git a/src/ortho/llvm/ortho_llvm.adb b/src/ortho/llvm/ortho_llvm.adb
index c0e59bdb2..f6e3dbefc 100644
--- a/src/ortho/llvm/ortho_llvm.adb
+++ b/src/ortho/llvm/ortho_llvm.adb
@@ -1454,9 +1454,14 @@ package body Ortho_LLVM is
Index.LLVM);
Tmp : ValueRef;
begin
- Tmp := BuildGEP (Builder, Arr.LLVM, Idx, Idx'Length, Empty_Cstring);
- Tmp := BuildBitCast
- (Builder, Tmp, PointerType (Get_LLVM_Type (Res_Type)), Empty_Cstring);
+ if Unreach then
+ Tmp := Null_ValueRef;
+ else
+ Tmp := BuildGEP (Builder, Arr.LLVM, Idx, Idx'Length, Empty_Cstring);
+ Tmp := BuildBitCast
+ (Builder, Tmp, PointerType (Get_LLVM_Type (Res_Type)),
+ Empty_Cstring);
+ end if;
return O_Lnode'(Direct => False, LLVM => Tmp, Ltype => Res_Type);
end New_Slice;
@@ -1626,10 +1631,7 @@ package body Ortho_LLVM is
function New_Address (Lvalue : O_Lnode; Atype : O_Tnode) return O_Enode is
begin
- return O_Enode'
- (LLVM => BuildBitCast (Builder, Lvalue.LLVM, Get_LLVM_Type (Atype),
- Empty_Cstring),
- Etype => Atype);
+ return New_Unchecked_Address (Lvalue, Atype);
end New_Address;
---------------------------
@@ -1639,11 +1641,15 @@ package body Ortho_LLVM is
function New_Unchecked_Address (Lvalue : O_Lnode; Atype : O_Tnode)
return O_Enode
is
+ Res : ValueRef;
begin
- return O_Enode'
- (LLVM => BuildBitCast (Builder, Lvalue.LLVM, Get_LLVM_Type (Atype),
- Empty_Cstring),
- Etype => Atype);
+ if Unreach then
+ Res := Null_ValueRef;
+ else
+ Res := BuildBitCast (Builder, Lvalue.LLVM, Get_LLVM_Type (Atype),
+ Empty_Cstring);
+ end if;
+ return O_Enode'(LLVM => Res, Etype => Atype);
end New_Unchecked_Address;
---------------
@@ -1681,6 +1687,12 @@ package body Ortho_LLVM is
function New_Obj (Obj : O_Dnode) return O_Lnode is
begin
+ if Unreach then
+ return O_Lnode'(Direct => False,
+ LLVM => Null_ValueRef,
+ Ltype => Obj.Dtype);
+ end if;
+
case Obj.Kind is
when ON_Const_Decl
| ON_Var_Decl