summaryrefslogtreecommitdiff
path: root/gcc/function.c
diff options
context:
space:
mode:
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2002-04-18 19:10:11 +0000
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2002-04-18 19:10:11 +0000
commit3bfb563ae8239b543841a8a7c919f5ef6ef30799 (patch)
tree96fdec6ac3f7a61a7e94dfb6e4e7c3793655a3d3 /gcc/function.c
parent25a08c3894d2c197f57bd2af8010ee7ca262ddd1 (diff)
downloadgcc-3bfb563ae8239b543841a8a7c919f5ef6ef30799.tar.gz
PR c/6358
* function.c (assign_parms): Assign hard current_function_return_rtx register here... (expand_function_end): ...not here. * gcc.c-torture/compile/20020418-1.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@52485 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/function.c')
-rw-r--r--gcc/function.c47
1 files changed, 33 insertions, 14 deletions
diff --git a/gcc/function.c b/gcc/function.c
index 86a87ab6068..4562376ce49 100644
--- a/gcc/function.c
+++ b/gcc/function.c
@@ -5145,6 +5145,35 @@ assign_parms (fndecl)
current_function_return_rtx
= (DECL_RTL_SET_P (DECL_RESULT (fndecl))
? DECL_RTL (DECL_RESULT (fndecl)) : NULL_RTX);
+
+ /* If scalar return value was computed in a pseudo-reg, or was a named
+ return value that got dumped to the stack, copy that to the hard
+ return register. */
+ if (DECL_RTL_SET_P (DECL_RESULT (fndecl)))
+ {
+ tree decl_result = DECL_RESULT (fndecl);
+ rtx decl_rtl = DECL_RTL (decl_result);
+
+ if (REG_P (decl_rtl)
+ ? REGNO (decl_rtl) >= FIRST_PSEUDO_REGISTER
+ : DECL_REGISTER (decl_result))
+ {
+ rtx real_decl_rtl;
+
+#ifdef FUNCTION_OUTGOING_VALUE
+ real_decl_rtl = FUNCTION_OUTGOING_VALUE (TREE_TYPE (decl_result),
+ fndecl);
+#else
+ real_decl_rtl = FUNCTION_VALUE (TREE_TYPE (decl_result),
+ fndecl);
+#endif
+ REG_FUNCTION_VALUE_P (real_decl_rtl) = 1;
+ /* The delay slot scheduler assumes that current_function_return_rtx
+ holds the hard register containing the return value, not a
+ temporary pseudo. */
+ current_function_return_rtx = real_decl_rtl;
+ }
+ }
}
/* Indicate whether REGNO is an incoming argument to the current function
@@ -6958,16 +6987,11 @@ expand_function_end (filename, line, end_bindings)
? REGNO (decl_rtl) >= FIRST_PSEUDO_REGISTER
: DECL_REGISTER (decl_result))
{
- rtx real_decl_rtl;
+ rtx real_decl_rtl = current_function_return_rtx;
-#ifdef FUNCTION_OUTGOING_VALUE
- real_decl_rtl = FUNCTION_OUTGOING_VALUE (TREE_TYPE (decl_result),
- current_function_decl);
-#else
- real_decl_rtl = FUNCTION_VALUE (TREE_TYPE (decl_result),
- current_function_decl);
-#endif
- REG_FUNCTION_VALUE_P (real_decl_rtl) = 1;
+ /* This should be set in assign_parms. */
+ if (! REG_FUNCTION_VALUE_P (real_decl_rtl))
+ abort ();
/* If this is a BLKmode structure being returned in registers,
then use the mode computed in expand_return. Note that if
@@ -6995,11 +7019,6 @@ expand_function_end (filename, line, end_bindings)
int_size_in_bytes (TREE_TYPE (decl_result)));
else
emit_move_insn (real_decl_rtl, decl_rtl);
-
- /* The delay slot scheduler assumes that current_function_return_rtx
- holds the hard register containing the return value, not a
- temporary pseudo. */
- current_function_return_rtx = real_decl_rtl;
}
}