aboutsummaryrefslogtreecommitdiff
path: root/gcc/cgraphunit.c
diff options
context:
space:
mode:
authorMartin Liska <mliska@suse.cz>2014-11-07 13:32:30 +0100
committerMartin Liska <marxin@gcc.gnu.org>2014-11-07 12:32:30 +0000
commit8c14c817f30b966f509636b96d4e5586261a258b (patch)
tree0b4d48f2d89c808ed0bbec9eb9bf0c8bf6983e09 /gcc/cgraphunit.c
parent8c00ba08c614069a590c673fe20afe9a5f1f55fe (diff)
downloadgcc-8c14c817f30b966f509636b96d4e5586261a258b.zip
gcc-8c14c817f30b966f509636b96d4e5586261a258b.tar.gz
gcc-8c14c817f30b966f509636b96d4e5586261a258b.tar.bz2
re PR tree-optimization/63595 (Segmentation faults inside kernel)
PR ipa/63595 * g++.dg/ipa/pr63595.C: New test. * cgraphunit.c (cgraph_node::expand_thunk): DECL_BY_REFERENCE is correctly handled for thunks created by IPA ICF. From-SVN: r217218
Diffstat (limited to 'gcc/cgraphunit.c')
-rw-r--r--gcc/cgraphunit.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c
index d2e8847..75d4140 100644
--- a/gcc/cgraphunit.c
+++ b/gcc/cgraphunit.c
@@ -1555,7 +1555,15 @@ cgraph_node::expand_thunk (bool output_asm_thunks, bool force_gimple_thunk)
if (!VOID_TYPE_P (restype))
{
if (DECL_BY_REFERENCE (resdecl))
- restmp = gimple_fold_indirect_ref (resdecl);
+ {
+ restmp = gimple_fold_indirect_ref (resdecl);
+ if (!restmp)
+ restmp = build2 (MEM_REF,
+ TREE_TYPE (TREE_TYPE (DECL_RESULT (alias))),
+ resdecl,
+ build_int_cst (TREE_TYPE
+ (DECL_RESULT (alias)), 0));
+ }
else if (!is_gimple_reg_type (restype))
{
restmp = resdecl;
@@ -1651,7 +1659,11 @@ cgraph_node::expand_thunk (bool output_asm_thunks, bool force_gimple_thunk)
gimple_call_set_tail (call, true);
/* Build return value. */
- ret = gimple_build_return (restmp);
+ if (!DECL_BY_REFERENCE (resdecl))
+ ret = gimple_build_return (restmp);
+ else
+ ret = gimple_build_return (resdecl);
+
gsi_insert_after (&bsi, ret, GSI_NEW_STMT);
}
else