public inbox for linux-m68k@lists.linux-m68k.org
 help / color / mirror / Atom feed
From: Mikael Pettersson <mikpe@it.uu.se>
To: Thorsten Glaser <tg@mirbsd.de>
Cc: linux-kernel@vger.kernel.org, linux-m68k@vger.kernel.org
Subject: Re: aranym bug, manifests as "ida_remove called for id=13" on recent kernels
Date: Mon, 11 Oct 2010 21:05:03 +0200	[thread overview]
Message-ID: <19635.24543.793716.40892@pilspetsen.it.uu.se> (raw)
In-Reply-To: <Pine.BSM.4.64L.1010111218040.23471@herc.mirbsd.org>

Thorsten Glaser writes:
 > Mikael Pettersson dixit:
 > 
 > >It's gcc PR41302 which was fixed for gcc trunk on November 4 2009
 > >in r153890.  The patch backports easily to gcc-4.4 and solves the
 > >test case there (manual inspection using a cross).  It also backports
 > 
 > [x] send unidiff
 > 
 > I’ll include that in my gcc build and then forward it to Debian
 > once I got a working gcc, unless you want to push that to them
 > already.

This is what I have had in my repo since November last year,
but it's only been minimally tested in a cross.  Please push
if/once it passes bootstrap + regtest.

gcc/

2009-11-10  Mikael Pettersson  <mikpe@it.uu.se>

	Backport from mainline:
	2009-11-04  Maxim Kuvyrkov  <maxim@codesourcery.com>

	PR target/41302
	* config/m68k/m68k.c (m68k_reg_present_p): New static function.
	(m68k_ok_for_sibcall_p): Handle different result return locations.

gcc/testsuite/

2009-11-10  Mikael Pettersson  <mikpe@it.uu.se>

	Backport from mainline:
	2009-11-04  Carlos O'Donell  <carlos@codesourcery.com>

	PR target/41302
	* gcc.target/m68k/pr41302.c: New test.

--- gcc-4.4.2/gcc/config/m68k/m68k.c.~1~	2008-11-19 17:24:10.000000000 +0100
+++ gcc-4.4.2/gcc/config/m68k/m68k.c	2009-11-10 00:10:06.000000000 +0100
@@ -1374,6 +1374,30 @@ flags_in_68881 (void)
   return cc_status.flags & CC_IN_68881;
 }
 
+/* Return true if PARALLEL contains register REGNO.  */
+static bool
+m68k_reg_present_p (const_rtx parallel, unsigned int regno)
+{
+  int i;
+
+  if (REG_P (parallel) && REGNO (parallel) == regno)
+    return true;
+
+  if (GET_CODE (parallel) != PARALLEL)
+    return false;
+
+  for (i = 0; i < XVECLEN (parallel, 0); ++i)
+    {
+      const_rtx x;
+
+      x = XEXP (XVECEXP (parallel, 0, i), 0);
+      if (REG_P (x) && REGNO (x) == regno)
+	return true;
+    }
+
+  return false;
+}
+
 /* Implement TARGET_FUNCTION_OK_FOR_SIBCALL_P.  */
 
 static bool
@@ -1386,6 +1410,26 @@ m68k_ok_for_sibcall_p (tree decl, tree e
   if (CALL_EXPR_STATIC_CHAIN (exp))
     return false;
 
+  if (!VOID_TYPE_P (TREE_TYPE (DECL_RESULT (cfun->decl))))
+    {
+      /* Check that the return value locations are the same.  For
+	 example that we aren't returning a value from the sibling in
+	 a D0 register but then need to transfer it to a A0 register.  */
+      rtx cfun_value;
+      rtx call_value;
+
+      cfun_value = FUNCTION_VALUE (TREE_TYPE (DECL_RESULT (cfun->decl)),
+				   cfun->decl);
+      call_value = FUNCTION_VALUE (TREE_TYPE (exp), decl);
+
+      /* Check that the values are equal or that the result the callee
+	 function returns is superset of what the current function returns.  */
+      if (!(rtx_equal_p (cfun_value, call_value)
+	    || (REG_P (cfun_value)
+		&& m68k_reg_present_p (call_value, REGNO (cfun_value)))))
+	return false;
+    }
+
   kind = m68k_get_function_kind (current_function_decl);
   if (kind == m68k_fk_normal_function)
     /* We can always sibcall from a normal function, because it's
@@ -4583,6 +4627,9 @@ m68k_libcall_value (enum machine_mode mo
   return gen_rtx_REG (mode, D0_REG);
 }
 
+/* Location in which function value is returned.
+   NOTE: Due to differences in ABIs, don't call this function directly,
+   use FUNCTION_VALUE instead.  */
 rtx
 m68k_function_value (const_tree valtype, const_tree func ATTRIBUTE_UNUSED)
 {
--- gcc-4.4.2/gcc/testsuite/gcc.target/m68k/pr41302.c.~1~	1970-01-01 01:00:00.000000000 +0100
+++ gcc-4.4.2/gcc/testsuite/gcc.target/m68k/pr41302.c	2009-11-04 13:09:17.000000000 +0100
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+/* { dg-final { scan-assembler "move.l \%d0,\%a0" { target *linux* } } } */
+
+struct pts {
+  int c;
+};
+
+unsigned int bar (struct pts *a, int b);
+
+struct pts * foo (struct pts *a, int b)
+{
+  return (struct pts *) bar (a, b);
+}

  parent reply	other threads:[~2010-10-11 19:05 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-07 17:49 aranym bug, manifests as "ida_remove called for id=13" on recent kernels Al Viro
2010-10-10  9:47 ` Geert Uytterhoeven
2010-10-10 14:49   ` Al Viro
2010-10-10 20:18     ` Geert Uytterhoeven
2010-10-10 23:52       ` Al Viro
2010-10-11  2:41         ` Al Viro
2010-10-11  4:36           ` Brad Boyer
2010-10-11  4:48             ` Al Viro
2010-10-11 12:21               ` Thorsten Glaser
2010-10-11 13:10                 ` Andreas Schwab
2010-10-11 13:35                 ` Al Viro
2010-10-11 13:45                   ` Thorsten Glaser
2010-10-11 14:15                   ` Andreas Schwab
2010-10-11 14:24                     ` Al Viro
2010-10-11 22:02                       ` Al Viro
2010-11-02 15:30                       ` Geert Uytterhoeven
2010-10-11 19:05                 ` Mikael Pettersson [this message]
2010-10-11  9:27           ` Mikael Pettersson
2010-10-11 11:50             ` Mikael Pettersson
2010-10-11 12:29             ` Andreas Schwab
2010-10-11  8:39         ` Geert Uytterhoeven

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=19635.24543.793716.40892@pilspetsen.it.uu.se \
    --to=mikpe@it.uu.se \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-m68k@vger.kernel.org \
    --cc=tg@mirbsd.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox