From: Richard Guenther Date: Mon, 30 May 2011 13:12:23 +0000 (+0000) Subject: re PR middle-end/49210 (verify_gimple fails building ada/einfo.o at -O3) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=42b05b6e884f5b14c3433f12593fe6accae5becf;p=gcc.git re PR middle-end/49210 (verify_gimple fails building ada/einfo.o at -O3) 2011-05-30 Richard Guenther PR tree-optimization/49210 * ipa-split.c (split_function): Care for the case where the call result is not trivially convertible to the result holding variable. * gnat.dg/boolean_subtype2.adb: New testcase. * gnat.dg/boolean_subtype2.ads: Likewise. * gnat.dg/boolean_subtype2_pkg.ads: Likewise. From-SVN: r174435 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index e1d9f65508d..ed73069b297 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2011-05-30 Richard Guenther + + PR tree-optimization/49210 + * ipa-split.c (split_function): Care for the case where the + call result is not trivially convertible to the result holding + variable. + 2011-05-30 Richard Guenther PR tree-optimization/49218 diff --git a/gcc/ipa-split.c b/gcc/ipa-split.c index 9579d41f18b..2e672874024 100644 --- a/gcc/ipa-split.c +++ b/gcc/ipa-split.c @@ -1196,11 +1196,31 @@ split_function (struct split_point *split_point) } } if (DECL_BY_REFERENCE (DECL_RESULT (current_function_decl))) - gimple_call_set_lhs (call, build_simple_mem_ref (retval)); + { + gimple_call_set_lhs (call, build_simple_mem_ref (retval)); + gsi_insert_after (&gsi, call, GSI_NEW_STMT); + } else - gimple_call_set_lhs (call, retval); + { + tree restype; + restype = TREE_TYPE (DECL_RESULT (current_function_decl)); + gsi_insert_after (&gsi, call, GSI_NEW_STMT); + if (!useless_type_conversion_p (TREE_TYPE (retval), restype)) + { + gimple cpy; + tree tem = create_tmp_reg (restype, NULL); + tem = make_ssa_name (tem, call); + cpy = gimple_build_assign_with_ops (NOP_EXPR, retval, + tem, NULL_TREE); + gsi_insert_after (&gsi, cpy, GSI_NEW_STMT); + retval = tem; + } + gimple_call_set_lhs (call, retval); + update_stmt (call); + } } - gsi_insert_after (&gsi, call, GSI_NEW_STMT); + else + gsi_insert_after (&gsi, call, GSI_NEW_STMT); } /* We don't use return block (there is either no return in function or multiple of them). So create new basic block with return statement. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index cca41493dab..d7df19bda9a 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2011-05-30 Richard Guenther + + PR tree-optimization/49210 + * gnat.dg/boolean_subtype2.adb: New testcase. + * gnat.dg/boolean_subtype2.ads: Likewise. + * gnat.dg/boolean_subtype2_pkg.ads: Likewise. + 2011-05-30 Jakub Jelinek PR c++/49223 diff --git a/gcc/testsuite/gnat.dg/boolean_subtype2.adb b/gcc/testsuite/gnat.dg/boolean_subtype2.adb new file mode 100644 index 00000000000..d5c17ce2199 --- /dev/null +++ b/gcc/testsuite/gnat.dg/boolean_subtype2.adb @@ -0,0 +1,40 @@ +-- { dg-do compile } +-- { dg-options "-O3 -gnata" } + +package body Boolean_Subtype2 is + + function Component_Type (Id : Entity_Id) return Entity_Id is + begin + pragma Assert (Is_String_Type (Id)); + return Node20 (Id); + end; + + function First_Index (Id : Entity_Id) return Node_Id is + begin + pragma Assert (Is_String_Type (Id)); + return Node20 (Id); + end ; + + function Is_Character_Type (Id : Entity_Id) return B is + begin + return Flag63 (Id); + end; + + function Number_Dimensions (Id : Entity_Id) return Positive is + N : Integer := 0; + T : Node_Id := First_Index (Id); + begin + if Present (T) then + N := N + 1; + end if; + return N; + end; + + function Is_String_Type (Id : Entity_Id) return B is + begin + return (Id /= 0 + and then Number_Dimensions (Id) = 1 + and then Is_Character_Type (Component_Type (Id))); + end; + +end Boolean_Subtype2; diff --git a/gcc/testsuite/gnat.dg/boolean_subtype2.ads b/gcc/testsuite/gnat.dg/boolean_subtype2.ads new file mode 100644 index 00000000000..82e192b1dc4 --- /dev/null +++ b/gcc/testsuite/gnat.dg/boolean_subtype2.ads @@ -0,0 +1,9 @@ +with Boolean_Subtype2_Pkg; use Boolean_Subtype2_Pkg; + +package Boolean_Subtype2 is + + subtype B is Boolean; + + function Is_String_Type (Id : Entity_Id) return B; + +end Boolean_Subtype2; diff --git a/gcc/testsuite/gnat.dg/boolean_subtype2_pkg.ads b/gcc/testsuite/gnat.dg/boolean_subtype2_pkg.ads new file mode 100644 index 00000000000..3c2f610e01f --- /dev/null +++ b/gcc/testsuite/gnat.dg/boolean_subtype2_pkg.ads @@ -0,0 +1,10 @@ +package Boolean_Subtype2_Pkg is + + type Node_Id is range 0 .. 099_999_999; + subtype Entity_Id is Node_Id; + + function Node20 (N : Node_Id) return Node_Id; + function Flag63 (N : Node_Id) return Boolean; + function Present (N : Node_Id) return Boolean; + +end Boolean_Subtype2_Pkg;