aboutsummaryrefslogtreecommitdiff
path: root/gcc/cgraphunit.c
diff options
context:
space:
mode:
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