This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch] Fix PR target/24445
- From: Kaz Kojima <kkojima at rr dot iij4u dot or dot jp>
- To: gcc-patches at gcc dot gnu dot org
- Date: Thu, 03 Nov 2005 22:17:19 +0900 (JST)
- Subject: [patch] Fix PR target/24445
The attached patch is to fix PR target/24445. It's tested with
bootstrap and the toplevel "make -k check" with no new failures
on i686-pc-linux-gnu and powerpc-apple-darwin7.9.0. The patch
to calls.c is approved by Ian on gcc list already:
http://gcc.gnu.org/ml/gcc/2005-11/msg00138.html
Is the testcase part OK?
Regards,
kaz
--
:ADDPATCH:
2005-11-03 Kaz Kojima <kkojima@gcc.gnu.org>
ChangeLog:
PR target/24445
* calls.c (expand_call): Copy a return value to a plain register
if needed.
testsuite/ChangeLog:
PR target/24445
* gcc.dg/pr24445.c: New test.
diff -uprN ORIG/trunk/gcc/calls.c LOCAL/trunk/gcc/calls.c
--- ORIG/trunk/gcc/calls.c 2005-10-29 06:52:11.000000000 +0900
+++ LOCAL/trunk/gcc/calls.c 2005-11-03 13:45:32.000000000 +0900
@@ -2855,6 +2855,14 @@ expand_call (tree exp, rtx target, int i
&& GET_MODE (target) == TYPE_MODE (TREE_TYPE (exp))
&& GET_MODE (target) == GET_MODE (valreg))
{
+ /* We have to copy a return value in a CLASS_LIKELY_SPILLED hard
+ reg to a plain register. */
+ if (REG_P (valreg)
+ && HARD_REGISTER_P (valreg)
+ && CLASS_LIKELY_SPILLED_P (REGNO_REG_CLASS (REGNO (valreg)))
+ && !(REG_P (target) && !HARD_REGISTER_P (target)))
+ valreg = copy_to_reg (valreg);
+
/* TARGET and VALREG cannot be equal at this point because the
latter would not have REG_FUNCTION_VALUE_P true, while the
former would if it were referring to the same register.
diff -uprN ORIG/trunk/gcc/testsuite/gcc.dg/pr24445.c LOCAL/trunk/gcc/testsuite/gcc.dg/pr24445.c
--- ORIG/trunk/gcc/testsuite/gcc.dg/pr24445.c 1970-01-01 09:00:00.000000000 +0900
+++ LOCAL/trunk/gcc/testsuite/gcc.dg/pr24445.c 2005-11-03 14:33:09.000000000 +0900
@@ -0,0 +1,9 @@
+/* { dg-do compile { target fpic } } */
+/* { dg-options "-O1 -fpic" } */
+extern int bar (void) __attribute__ ((__pure__));
+extern char *baz;
+void
+foo (void)
+{
+ baz = (char *) bar ();
+}