From bbd1bae29c33b55ac449730b3b9eaaa44de3f3e8 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Fri, 6 Feb 2015 21:47:20 +0100 Subject: [PATCH] re PR ipa/64896 (ICE in get_address_mode, at rtlanal.c:5442) PR ipa/64896 * cgraphunit.c (cgraph_node::expand_thunk): If restype is not is_gimple_reg_type nor the thunk_fndecl returns aggregate_value_p, set restmp to a temporary variable instead of resdecl. * g++.dg/ipa/pr64896.C: New test. From-SVN: r220489 --- gcc/ChangeLog | 8 ++++++++ gcc/cgraphunit.c | 13 +++++++++---- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/ipa/pr64896.C | 29 +++++++++++++++++++++++++++++ 4 files changed, 51 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/g++.dg/ipa/pr64896.C diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 9af837b4c5d..035baa52e80 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2015-02-06 Jakub Jelinek + + PR ipa/64896 + * cgraphunit.c (cgraph_node::expand_thunk): If + restype is not is_gimple_reg_type nor the thunk_fndecl + returns aggregate_value_p, set restmp to a temporary variable + instead of resdecl. + 2015-02-06 Vladimir Makarov * lra.c (lra_emit_add): Fix a typo in using disp instead of base. diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c index a2650f724c1..35b244e4b81 100644 --- a/gcc/cgraphunit.c +++ b/gcc/cgraphunit.c @@ -1609,11 +1609,16 @@ cgraph_node::expand_thunk (bool output_asm_thunks, bool force_gimple_thunk) } else if (!is_gimple_reg_type (restype)) { - restmp = resdecl; + if (aggregate_value_p (resdecl, TREE_TYPE (thunk_fndecl))) + { + restmp = resdecl; - if (TREE_CODE (restmp) == VAR_DECL) - add_local_decl (cfun, restmp); - BLOCK_VARS (DECL_INITIAL (current_function_decl)) = restmp; + if (TREE_CODE (restmp) == VAR_DECL) + add_local_decl (cfun, restmp); + BLOCK_VARS (DECL_INITIAL (current_function_decl)) = restmp; + } + else + restmp = create_tmp_var (restype, "retval"); } else restmp = create_tmp_reg (restype, "retval"); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e3e54449232..8855d27ff38 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-02-06 Jakub Jelinek + + PR ipa/64896 + * g++.dg/ipa/pr64896.C: New test. + 2015-02-06 Michael Meissner PR target/64205 diff --git a/gcc/testsuite/g++.dg/ipa/pr64896.C b/gcc/testsuite/g++.dg/ipa/pr64896.C new file mode 100644 index 00000000000..0a78220be8a --- /dev/null +++ b/gcc/testsuite/g++.dg/ipa/pr64896.C @@ -0,0 +1,29 @@ +// PR ipa/64896 +// { dg-do compile } +// { dg-options "-O2" } + +struct A { int a, b; }; +struct B { A c; int d; }; +struct C { virtual B fn1 () const; }; +struct D { B fn2 () const; int fn3 () const; C *fn4 () const; }; + +int +D::fn3 () const +{ + fn4 ()->fn1 (); +} + +B +D::fn2 () const +{ + return B (); +} + +class F : C +{ + B + fn1 () const + { + return B (); + } +}; -- 2.30.2