public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH Commitred] Fix PR target/48767
@ 2011-04-26 22:44 Kaz Kojima
  2011-04-26 22:57 ` Joseph S. Myers
  0 siblings, 1 reply; 5+ messages in thread
From: Kaz Kojima @ 2011-04-26 22:44 UTC (permalink / raw)
  To: gcc-patches

Hi,

The attached target specific patch is to fix PR target/48767.
In the problematic case, sh.c:sh_gimplify_va_arg_expr calls
targetm.calls.must_pass_in_stack with void type as its 2nd
argument which is unexpected by the callee.  The patch is
tested on sh4-unknown-linux-gnu with no new failures.
Applied on trunk.

Regards,
	kaz
--
2011-04-26  Kaz Kojima  <kkojima@gcc.gnu.org>

	PR target/48767
	* config/sh/sh.c (sh_gimplify_va_arg_expr): Don't call
	targetm.calls.must_pass_in_stack for void type.

--- ORIG/trunk/gcc/config/sh/sh.c	2011-04-23 09:43:19.000000000 +0900
+++ trunk/gcc/config/sh/sh.c	2011-04-26 10:40:25.000000000 +0900
@@ -8062,9 +8062,14 @@ sh_gimplify_va_arg_expr (tree valist, tr
   HOST_WIDE_INT size, rsize;
   tree tmp, pptr_type_node;
   tree addr, lab_over = NULL, result = NULL;
-  int pass_by_ref = targetm.calls.must_pass_in_stack (TYPE_MODE (type), type);
+  bool pass_by_ref;
   tree eff_type;
 
+  if (!VOID_TYPE_P (type))
+    pass_by_ref = targetm.calls.must_pass_in_stack (TYPE_MODE (type), type);
+  else
+    pass_by_ref = false;
+
   if (pass_by_ref)
     type = build_pointer_type (type);
 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH Commitred] Fix PR target/48767
  2011-04-26 22:44 [PATCH Commitred] Fix PR target/48767 Kaz Kojima
@ 2011-04-26 22:57 ` Joseph S. Myers
  2011-04-26 23:42   ` Kaz Kojima
  0 siblings, 1 reply; 5+ messages in thread
From: Joseph S. Myers @ 2011-04-26 22:57 UTC (permalink / raw)
  To: Kaz Kojima; +Cc: gcc-patches

I think you should add a testcase to gcc.c-torture/compile, unless there 
is already one that this patch fixes.

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH Commitred] Fix PR target/48767
  2011-04-26 22:57 ` Joseph S. Myers
@ 2011-04-26 23:42   ` Kaz Kojima
  2011-04-27 12:44     ` Joseph S. Myers
  0 siblings, 1 reply; 5+ messages in thread
From: Kaz Kojima @ 2011-04-26 23:42 UTC (permalink / raw)
  To: joseph; +Cc: gcc-patches

"Joseph S. Myers" <joseph@codesourcery.com> wrote:
> I think you should add a testcase to gcc.c-torture/compile, unless there 
> is already one that this patch fixes.

Ah, indeed.  How about the attached testcase?
BTW, is it valid C?

Regards,
	kaz
--
--- ORIG/trunk/gcc/testsuite/gcc.c-torture/compile/pr48767.c	1970-01-01 09:00:00.000000000 +0900
+++ trunk/gcc/testsuite/gcc.c-torture/compile/pr48767.c	2011-04-27 07:54:05.000000000 +0900
@@ -0,0 +1,9 @@
+/* PR target/48767 */
+/* { dg-do compile } */
+/* { dg-options "" } */
+
+void
+foo (__builtin_va_list ap)
+{
+  __builtin_va_arg (ap, void);
+}


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH Commitred] Fix PR target/48767
  2011-04-26 23:42   ` Kaz Kojima
@ 2011-04-27 12:44     ` Joseph S. Myers
  2011-04-27 13:18       ` Kaz Kojima
  0 siblings, 1 reply; 5+ messages in thread
From: Joseph S. Myers @ 2011-04-27 12:44 UTC (permalink / raw)
  To: Kaz Kojima; +Cc: gcc-patches

On Wed, 27 Apr 2011, Kaz Kojima wrote:

> "Joseph S. Myers" <joseph@codesourcery.com> wrote:
> > I think you should add a testcase to gcc.c-torture/compile, unless there 
> > is already one that this patch fixes.
> 
> Ah, indeed.  How about the attached testcase?

Yes, that testcase looks like what I had in mind, but you don't need the 
dg-* directives (the defaults in gcc.c-torture/compile should be fine).

> BTW, is it valid C?

I think this should be considered the same as passing a type such as 
"short" that can never be the promoted argument type: undefined behavior 
at runtime if the call is executed.

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH Commitred] Fix PR target/48767
  2011-04-27 12:44     ` Joseph S. Myers
@ 2011-04-27 13:18       ` Kaz Kojima
  0 siblings, 0 replies; 5+ messages in thread
From: Kaz Kojima @ 2011-04-27 13:18 UTC (permalink / raw)
  To: joseph; +Cc: gcc-patches

"Joseph S. Myers" <joseph@codesourcery.com> wrote:
> Yes, that testcase looks like what I had in mind, but you don't need the 
> dg-* directives (the defaults in gcc.c-torture/compile should be fine).
> 
>> BTW, is it valid C?
> 
> I think this should be considered the same as passing a type such as 
> "short" that can never be the promoted argument type: undefined behavior 
> at runtime if the call is executed.

Thanks for the explanation.  I've committed the testcase below
on trunk.

Regards,
	kaz
--
2011-04-27  Kaz Kojima  <kkojima@gcc.gnu.org>

	PR target/48767
	* gcc.c-torture/compile/pr48767.c: New test.

diff -uprN ORIG/trunk/gcc/testsuite/gcc.c-torture/compile/pr48767.c  trunk/gcc/testsuite/gcc.c-torture/compile/pr48767.c
--- ORIG/trunk/gcc/testsuite/gcc.c-torture/compile/pr48767.c	1970-01-01 09:00:00.000000000 +0900
+++ trunk/gcc/testsuite/gcc.c-torture/compile/pr48767.c	2011-04-27 19:28:47.000000000 +0900
@@ -0,0 +1,7 @@
+/* PR target/48767 */
+
+void
+foo (__builtin_va_list ap)
+{
+  __builtin_va_arg (ap, void);
+}

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-04-27 10:49 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-26 22:44 [PATCH Commitred] Fix PR target/48767 Kaz Kojima
2011-04-26 22:57 ` Joseph S. Myers
2011-04-26 23:42   ` Kaz Kojima
2011-04-27 12:44     ` Joseph S. Myers
2011-04-27 13:18       ` Kaz Kojima

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).