public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/36015]  New: [4.3/4.4 Regression] -mregparm and fn decls without arguments
@ 2008-04-22 16:10 jakub at gcc dot gnu dot org
  2008-04-22 16:16 ` [Bug target/36015] " jakub at gcc dot gnu dot org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: jakub at gcc dot gnu dot org @ 2008-04-22 16:10 UTC (permalink / raw)
  To: gcc-bugs

/* { dg-do run } */
/* { dg-options "-O0" } */
/* { dg-options "-O0 -mregparm=3" { target { { i?86-*-* x86_64-*-* } && ilp32 }
} } */

static int test ();

int
main (void)
{
  test (0, 1, 2, 3, 4, 5, 6, 7);
  return 0;
}

static int
test (int a, int b, int c, int d, int e, int f, int g, int h)
{
  if (a != 0 || b != 1 || c != 2 || d != 3
      || e != 4 || f != 5 || g != 6 || h != 7)
    __builtin_abort ();
  return 0;
}

used to work until 4.2.x (tested 3.2, 3.3, 3.4, 4.0, 4.1, 4.2) - in all cases
test was passed arguments in 3 regs by the caller and expecting them there.


-- 
           Summary: [4.3/4.4 Regression] -mregparm and fn decls without
                    arguments
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jakub at gcc dot gnu dot org
GCC target triplet: i686-linux


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36015


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

* [Bug target/36015] [4.3/4.4 Regression] -mregparm and fn decls without arguments
  2008-04-22 16:10 [Bug target/36015] New: [4.3/4.4 Regression] -mregparm and fn decls without arguments jakub at gcc dot gnu dot org
@ 2008-04-22 16:16 ` jakub at gcc dot gnu dot org
  2008-04-22 19:38 ` jakub at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu dot org @ 2008-04-22 16:16 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from jakub at gcc dot gnu dot org  2008-04-22 16:15 -------
*** Bug 36014 has been marked as a duplicate of this bug. ***


-- 

jakub at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |simon at sxw dot org dot uk


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36015


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

* [Bug target/36015] [4.3/4.4 Regression] -mregparm and fn decls without arguments
  2008-04-22 16:10 [Bug target/36015] New: [4.3/4.4 Regression] -mregparm and fn decls without arguments jakub at gcc dot gnu dot org
  2008-04-22 16:16 ` [Bug target/36015] " jakub at gcc dot gnu dot org
@ 2008-04-22 19:38 ` jakub at gcc dot gnu dot org
  2008-04-23 10:46 ` jakub at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu dot org @ 2008-04-22 19:38 UTC (permalink / raw)
  To: gcc-bugs



-- 

jakub at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |4.3.1


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36015


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

* [Bug target/36015] [4.3/4.4 Regression] -mregparm and fn decls without arguments
  2008-04-22 16:10 [Bug target/36015] New: [4.3/4.4 Regression] -mregparm and fn decls without arguments jakub at gcc dot gnu dot org
  2008-04-22 16:16 ` [Bug target/36015] " jakub at gcc dot gnu dot org
  2008-04-22 19:38 ` jakub at gcc dot gnu dot org
@ 2008-04-23 10:46 ` jakub at gcc dot gnu dot org
  2008-04-23 13:08 ` hjl dot tools at gmail dot com
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu dot org @ 2008-04-23 10:46 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from jakub at gcc dot gnu dot org  2008-04-23 10:45 -------
Caused I believe by http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=124835
likely together with http://gcc.gnu.org/ml/gcc-patches/2007-03/msg01511.html
While in 4.2 functions with fntype without TYPE_ARG_TYPES (i.e. !prototype_p)
nregs, etc. would be preserved and maybe_vaarg set to true only afterwards,
in 4.3 it is set early and the calling convention is forced to stack.

maybe_vaarg is only used in 2 places - in init_cumulative_args itself, in
!TARGET_64BIT case only, and in function_arg_64 (i.e. TARGET_64BIT case only).
If we want to restore 4.2 and earlier behavior (I think we have to), then
one fix could be e.g. only set maybe_vaarg to true for !prototype_p (fntype)
if TARGET_64BIT.
-                      ? (!prototype_p (fntype) || stdarg_p (fntype))
+                      ? ((TARGET_64BIT && !prototype_p (fntype))
+                         || stdarg_p (fntype))

As K&R fn declaration (i.e. !prototype_p) followed by stdarg_p definition or
prototype is diagnosed as an error by diagnose_arglist_conflict, I believe this
is safe.


-- 

jakub at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |hjl dot tools at gmail dot
                   |                            |com, hubicka at gcc dot gnu
                   |                            |dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36015


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

* [Bug target/36015] [4.3/4.4 Regression] -mregparm and fn decls without arguments
  2008-04-22 16:10 [Bug target/36015] New: [4.3/4.4 Regression] -mregparm and fn decls without arguments jakub at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2008-04-23 10:46 ` jakub at gcc dot gnu dot org
@ 2008-04-23 13:08 ` hjl dot tools at gmail dot com
  2008-04-23 13:30 ` jakub at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: hjl dot tools at gmail dot com @ 2008-04-23 13:08 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from hjl dot tools at gmail dot com  2008-04-23 13:07 -------
(In reply to comment #2)
> Caused I believe by http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=124835
> likely together with http://gcc.gnu.org/ml/gcc-patches/2007-03/msg01511.html
> While in 4.2 functions with fntype without TYPE_ARG_TYPES (i.e. !prototype_p)
> nregs, etc. would be preserved and maybe_vaarg set to true only afterwards,
> in 4.3 it is set early and the calling convention is forced to stack.
> 
> maybe_vaarg is only used in 2 places - in init_cumulative_args itself, in
> !TARGET_64BIT case only, and in function_arg_64 (i.e. TARGET_64BIT case only).
> If we want to restore 4.2 and earlier behavior (I think we have to), then
> one fix could be e.g. only set maybe_vaarg to true for !prototype_p (fntype)
> if TARGET_64BIT.
> -                      ? (!prototype_p (fntype) || stdarg_p (fntype))
> +                      ? ((TARGET_64BIT && !prototype_p (fntype))
> +                         || stdarg_p (fntype))
> 
> As K&R fn declaration (i.e. !prototype_p) followed by stdarg_p definition or
> prototype is diagnosed as an error by diagnose_arglist_conflict, I believe this
> is safe.
> 

Can you give it a try on both Linux/ia32 and Linux/x86-64?


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36015


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

* [Bug target/36015] [4.3/4.4 Regression] -mregparm and fn decls without arguments
  2008-04-22 16:10 [Bug target/36015] New: [4.3/4.4 Regression] -mregparm and fn decls without arguments jakub at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2008-04-23 13:08 ` hjl dot tools at gmail dot com
@ 2008-04-23 13:30 ` jakub at gcc dot gnu dot org
  2008-04-23 14:00 ` jakub at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu dot org @ 2008-04-23 13:30 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from jakub at gcc dot gnu dot org  2008-04-23 13:29 -------
I've instead regtested:
--- gcc/config/i386/i386.c.jj   2008-04-01 13:34:27.000000000 +0200
+++ gcc/config/i386/i386.c      2008-04-23 13:38:14.000000000 +0200
@@ -3501,7 +3501,7 @@ init_cumulative_args (CUMULATIVE_ARGS *c
     {
       /* If there are variable arguments, then we won't pass anything
          in registers in 32-bit mode. */
-      if (cum->maybe_vaarg) 
+      if (stdarg_p (fntype))
        {
          cum->nregs = 0;
          cum->sse_nregs = 0;

patch (on i686 only, as this is !TARGET_64BIT hunk of code).
IMHO it best matches what 4.2 and earlier did.  Here is the 4.2 code:
  cum->maybe_vaarg = false;
...
  /* Determine if this function has variable arguments.  This is
     indicated by the last argument being 'void_type_mode' if there
     are no variable arguments.  If there are variable arguments, then
     we won't pass anything in registers in 32-bit mode. */

  if (cum->nregs || cum->mmx_nregs || cum->sse_nregs)
    {
      for (param = (fntype) ? TYPE_ARG_TYPES (fntype) : 0;
           param != 0; param = next_param)
        {
          next_param = TREE_CHAIN (param);
          if (next_param == 0 && TREE_VALUE (param) != void_type_node)
            {
              if (!TARGET_64BIT)
                {
                  cum->nregs = 0;
                  cum->sse_nregs = 0;
                  cum->mmx_nregs = 0;
                  cum->warn_sse = 0; 
                  cum->warn_mmx = 0; 
                  cum->fastcall = 0; 
                  cum->float_in_sse = 0;
                }
              cum->maybe_vaarg = true;
            }
        }
    }
  if ((!fntype && !libname)
      || (fntype && !TYPE_ARG_TYPES (fntype)))
    cum->maybe_vaarg = true;

The param/next_param testing IMHO is stdarg_p test, so cum->nregs etc. are
cleared only if !TARGET_64BIT && stdarg_p (fntype).  maybe_vaarg is set if
stdarg_p (fntype), or for fntype && !prototype_p (fntype), or for !fntype &&
!libname.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36015


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

* [Bug target/36015] [4.3/4.4 Regression] -mregparm and fn decls without arguments
  2008-04-22 16:10 [Bug target/36015] New: [4.3/4.4 Regression] -mregparm and fn decls without arguments jakub at gcc dot gnu dot org
                   ` (4 preceding siblings ...)
  2008-04-23 13:30 ` jakub at gcc dot gnu dot org
@ 2008-04-23 14:00 ` jakub at gcc dot gnu dot org
  2008-04-24  7:01 ` jakub at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu dot org @ 2008-04-23 14:00 UTC (permalink / raw)
  To: gcc-bugs



-- 

jakub at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |jakub at gcc dot gnu dot org
                   |dot org                     |
             Status|UNCONFIRMED                 |ASSIGNED
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2008-04-23 13:59:59
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36015


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

* [Bug target/36015] [4.3/4.4 Regression] -mregparm and fn decls without arguments
  2008-04-22 16:10 [Bug target/36015] New: [4.3/4.4 Regression] -mregparm and fn decls without arguments jakub at gcc dot gnu dot org
                   ` (5 preceding siblings ...)
  2008-04-23 14:00 ` jakub at gcc dot gnu dot org
@ 2008-04-24  7:01 ` jakub at gcc dot gnu dot org
  2008-04-24  7:05 ` jakub at gcc dot gnu dot org
  2008-04-24  7:08 ` jakub at gcc dot gnu dot org
  8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu dot org @ 2008-04-24  7:01 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from jakub at gcc dot gnu dot org  2008-04-24 07:00 -------
Subject: Bug 36015

Author: jakub
Date: Thu Apr 24 06:59:55 2008
New Revision: 134621

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=134621
Log:
        PR target/36015
        * config/i386/i386.c (init_cumulative_args): Don't pass anything
        in registers for -m32 only if stdarg_p (fntype).

        * gcc.dg/pr36015.c: New test.

Added:
    trunk/gcc/testsuite/gcc.dg/pr36015.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/i386/i386.c
    trunk/gcc/testsuite/ChangeLog


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36015


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

* [Bug target/36015] [4.3/4.4 Regression] -mregparm and fn decls without arguments
  2008-04-22 16:10 [Bug target/36015] New: [4.3/4.4 Regression] -mregparm and fn decls without arguments jakub at gcc dot gnu dot org
                   ` (6 preceding siblings ...)
  2008-04-24  7:01 ` jakub at gcc dot gnu dot org
@ 2008-04-24  7:05 ` jakub at gcc dot gnu dot org
  2008-04-24  7:08 ` jakub at gcc dot gnu dot org
  8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu dot org @ 2008-04-24  7:05 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from jakub at gcc dot gnu dot org  2008-04-24 07:04 -------
Subject: Bug 36015

Author: jakub
Date: Thu Apr 24 07:03:38 2008
New Revision: 134622

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=134622
Log:
        PR target/36015
        * config/i386/i386.c (init_cumulative_args): Don't pass anything
        in registers for -m32 only if stdarg_p (fntype).

        * gcc.dg/pr36015.c: New test.

Added:
    branches/gcc-4_3-branch/gcc/testsuite/gcc.dg/pr36015.c
Modified:
    branches/gcc-4_3-branch/gcc/ChangeLog
    branches/gcc-4_3-branch/gcc/config/i386/i386.c
    branches/gcc-4_3-branch/gcc/testsuite/ChangeLog


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36015


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

* [Bug target/36015] [4.3/4.4 Regression] -mregparm and fn decls without arguments
  2008-04-22 16:10 [Bug target/36015] New: [4.3/4.4 Regression] -mregparm and fn decls without arguments jakub at gcc dot gnu dot org
                   ` (7 preceding siblings ...)
  2008-04-24  7:05 ` jakub at gcc dot gnu dot org
@ 2008-04-24  7:08 ` jakub at gcc dot gnu dot org
  8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu dot org @ 2008-04-24  7:08 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from jakub at gcc dot gnu dot org  2008-04-24 07:07 -------
Fixed.


-- 

jakub at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36015


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

end of thread, other threads:[~2008-04-24  7:08 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-04-22 16:10 [Bug target/36015] New: [4.3/4.4 Regression] -mregparm and fn decls without arguments jakub at gcc dot gnu dot org
2008-04-22 16:16 ` [Bug target/36015] " jakub at gcc dot gnu dot org
2008-04-22 19:38 ` jakub at gcc dot gnu dot org
2008-04-23 10:46 ` jakub at gcc dot gnu dot org
2008-04-23 13:08 ` hjl dot tools at gmail dot com
2008-04-23 13:30 ` jakub at gcc dot gnu dot org
2008-04-23 14:00 ` jakub at gcc dot gnu dot org
2008-04-24  7:01 ` jakub at gcc dot gnu dot org
2008-04-24  7:05 ` jakub at gcc dot gnu dot org
2008-04-24  7:08 ` jakub at gcc dot gnu dot org

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).