summaryrefslogtreecommitdiff
path: root/gcc/cgraphunit.c
diff options
context:
space:
mode:
authormarxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4>2014-11-07 12:32:30 +0000
committermarxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4>2014-11-07 12:32:30 +0000
commitfd43cc5994d37643c4b887558af575f9441babd9 (patch)
tree0b4d48f2d89c808ed0bbec9eb9bf0c8bf6983e09 /gcc/cgraphunit.c
parentb43b0cfd161c5e289a4c8c97aa0bd6e67446d6e3 (diff)
downloadgcc-fd43cc5994d37643c4b887558af575f9441babd9.tar.gz
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@217218 138bc75d-0d04-0410-961f-82ee72b054a4
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 d2e88474594..75d414024a7 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