Index: tree-ssa-uninit.c
===================================================================
--- tree-ssa-uninit.c	(revision 161774)
+++ tree-ssa-uninit.c	(working copy)
@@ -92,6 +92,12 @@ ssa_undefined_value_p (tree t)
   if (TREE_CODE (var) == PARM_DECL)
     return false;
 
+  /* When returning by reference the return address is actually a hidden
+     parameter.  */
+  if (TREE_CODE (SSA_NAME_VAR (t)) == RESULT_DECL
+      && DECL_BY_REFERENCE (SSA_NAME_VAR (t)))
+    return false;
+
   /* Hard register variables get their initial value from the ether.  */
   if (TREE_CODE (var) == VAR_DECL && DECL_HARD_REGISTER (var))
     return false;
Index: tree.c
===================================================================
--- tree.c	(revision 161774)
+++ tree.c	(working copy)
@@ -9750,6 +9750,7 @@ needs_to_live_in_memory (const_tree t)
   return (TREE_ADDRESSABLE (t)
 	  || is_global_var (t)
 	  || (TREE_CODE (t) == RESULT_DECL
+	      && !DECL_BY_REFERENCE (t)
 	      && aggregate_value_p (t, current_function_decl)));
 }
 
Index: tree-inline.c
===================================================================
--- tree-inline.c	(revision 161774)
+++ tree-inline.c	(working copy)
@@ -1236,7 +1237,11 @@ remap_gimple_stmt (gimple stmt, copy_bod
 	 If RETVAL is just the result decl, the result decl has
 	 already been set (e.g. a recent "foo (&result_decl, ...)");
 	 just toss the entire GIMPLE_RETURN.  */
-      if (retval && TREE_CODE (retval) != RESULT_DECL)
+      if (retval
+	  && (TREE_CODE (retval) != RESULT_DECL
+	      && (TREE_CODE (retval) != SSA_NAME
+		  || !SSA_NAME_IS_DEFAULT_DEF (retval)
+		  || TREE_CODE (SSA_NAME_VAR (retval)) != RESULT_DECL)))
         {
 	  copy = gimple_build_assign (id->retvar, retval);
 	  /* id->retvar is already substituted.  Skip it on later remapping.  */
Index: tree-ssa-structalias.c
===================================================================
--- tree-ssa-structalias.c	(revision 161774)
+++ tree-ssa-structalias.c	(working copy)
@@ -5751,7 +5751,8 @@ find_what_p_points_to (tree p)
   /* For parameters, get at the points-to set for the actual parm
      decl.  */
   if (TREE_CODE (p) == SSA_NAME
-      && TREE_CODE (SSA_NAME_VAR (p)) == PARM_DECL
+      && (TREE_CODE (SSA_NAME_VAR (p)) == PARM_DECL
+	  || TREE_CODE (SSA_NAME_VAR (p)) == RESULT_DECL)
       && SSA_NAME_IS_DEFAULT_DEF (p))
     lookup_p = SSA_NAME_VAR (p);
 
Index: tree-cfg.c
===================================================================
--- tree-cfg.c	(revision 161774)
+++ tree-cfg.c	(working copy)
@@ -3818,8 +3818,7 @@ verify_gimple_return (gimple stmt)
   if (op == NULL)
     return false;
 
-  if (!is_gimple_val (op)
-      && TREE_CODE (op) != RESULT_DECL)
+  if (!is_gimple_val (op) && TREE_CODE (op) != RESULT_DECL)
     {
       error ("invalid operand in return statement");
       debug_generic_stmt (op);
@@ -3829,7 +3828,10 @@ verify_gimple_return (gimple stmt)
   if (!useless_type_conversion_p (restype, TREE_TYPE (op))
       /* ???  With C++ we can have the situation that the result
 	 decl is a reference type while the return type is an aggregate.  */
-      && !(TREE_CODE (op) == RESULT_DECL
+      && !((TREE_CODE (op) == RESULT_DECL
+	    || (TREE_CODE (op) == SSA_NAME
+	        && SSA_NAME_IS_DEFAULT_DEF (op)
+	        && TREE_CODE (SSA_NAME_VAR (op)) == RESULT_DECL))
 	   && TREE_CODE (TREE_TYPE (op)) == REFERENCE_TYPE
 	   && useless_type_conversion_p (restype, TREE_TYPE (TREE_TYPE (op)))))
     {
