public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Uros Bizjak <ubizjak@gmail.com>
To: "H.J. Lu" <hjl.tools@gmail.com>
Cc: "gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH v2] x86: Issue error for return/argument only with function body
Date: Fri, 19 Mar 2021 13:20:59 +0100	[thread overview]
Message-ID: <CAFULd4Z7wYxzq+D9wNOT13CESeDyNQq6_UaQHceb5v3Zf2mKfg@mail.gmail.com> (raw)
In-Reply-To: <CAMe9rOrAo7Vci1Ld-R7z6F5=XamMpC8=YJTR80uFL+DxhFO4Pg@mail.gmail.com>

On Fri, Mar 19, 2021 at 1:11 PM H.J. Lu <hjl.tools@gmail.com> wrote:
>
> On Fri, Mar 19, 2021 at 1:39 AM Uros Bizjak <ubizjak@gmail.com> wrote:
> >
> > On Thu, Mar 18, 2021 at 11:44 PM H.J. Lu <hjl.tools@gmail.com> wrote:
> > >
> > > If we never generate function body, we shouldn't issue errors for return
> > > nor argument.  Add init_cumulative_args_called to i386 machine_function
> > > to avoid issuing errors for return and argument without function body.
> > >
> > > gcc/
> > >
> > >         PR target/99652
> > >         * config/i386/i386.c (init_cumulative_args): Set
> > >         init_cumulative_args_called to true.
> > >         (construct_container): Issue error for return and argument only
> > >         if init_cumulative_args_called is true.
> > >         * config/i386/i386.h (machine_function): Add
> > >         init_cumulative_args_called.
> > >
> > > gcc/testsuite/
> > >
> > >         PR target/99652
> > >         * gcc.dg/torture/pr99652-1.c: New test.
> > >         * gcc.dg/torture/pr99652-2.c: Likewise.
> > >         * gcc.target/i386/pr57655.c: Adjusted.
> > >         * gcc.target/i386/pr59794-6.c: Likewise.
> > >         * gcc.target/i386/pr70738-1.c: Likewise.
> > >         * gcc.target/i386/pr96744-1.c: Likewise.
> > > ---
> > >  gcc/config/i386/i386.c                    | 26 ++++++++++++++---------
> > >  gcc/config/i386/i386.h                    |  3 +++
> > >  gcc/testsuite/gcc.dg/torture/pr99652-1.c  |  8 +++++++
> > >  gcc/testsuite/gcc.dg/torture/pr99652-2.c  |  8 +++++++
> > >  gcc/testsuite/gcc.target/i386/pr57655.c   |  4 ++--
> > >  gcc/testsuite/gcc.target/i386/pr59794-6.c |  4 ++--
> > >  gcc/testsuite/gcc.target/i386/pr70738-1.c |  4 ++--
> > >  gcc/testsuite/gcc.target/i386/pr96744-1.c |  4 ++--
> > >  8 files changed, 43 insertions(+), 18 deletions(-)
> > >  create mode 100644 gcc/testsuite/gcc.dg/torture/pr99652-1.c
> > >  create mode 100644 gcc/testsuite/gcc.dg/torture/pr99652-2.c
> > >
> > > diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
> > > index 540d4f44517..4a0b8c73bef 100644
> > > --- a/gcc/config/i386/i386.c
> > > +++ b/gcc/config/i386/i386.c
> > > @@ -1705,6 +1705,8 @@ init_cumulative_args (CUMULATIVE_ARGS *cum,  /* Argument info to initialize */
> > >    struct cgraph_node *local_info_node = NULL;
> > >    struct cgraph_node *target = NULL;
> > >
> > > +  cfun->machine->init_cumulative_args_called = true;
> > > +
> > >    memset (cum, 0, sizeof (*cum));
> > >
> > >    if (fndecl)
> > > @@ -2534,18 +2536,21 @@ construct_container (machine_mode mode, machine_mode orig_mode,
> > >       some less clueful developer tries to use floating-point anyway.  */
> > >    if (needed_sseregs && !TARGET_SSE)
> > >      {
> > > -      if (in_return)
> > > +      if (cfun->machine->init_cumulative_args_called)
> >
> > Please make this an early return, with appropriate comment.
>
> Done.
>
> > >         {
> > > -         if (!issued_sse_ret_error)
> > > +         if (in_return)
> > >             {
> > > -             error ("SSE register return with SSE disabled");
> > > -             issued_sse_ret_error = true;
> > > +             if (!issued_sse_ret_error)
> > > +               {
> > > +                 error ("SSE register return with SSE disabled");
> > > +                 issued_sse_ret_error = true;
> > > +               }
> > > +           }
> > > +         else if (!issued_sse_arg_error)
> > > +           {
> > > +             error ("SSE register argument with SSE disabled");
> > > +             issued_sse_arg_error = true;
> > >             }
> > > -       }
> > > -      else if (!issued_sse_arg_error)
> > > -       {
> > > -         error ("SSE register argument with SSE disabled");
> > > -         issued_sse_arg_error = true;
> > >         }
> > >        return NULL;
> > >      }
> > > @@ -2558,7 +2563,8 @@ construct_container (machine_mode mode, machine_mode orig_mode,
> > >           || regclass[i] == X86_64_X87UP_CLASS
> > >           || regclass[i] == X86_64_COMPLEX_X87_CLASS)
> > >         {
> > > -         if (!issued_x87_ret_error)
> > > +         if (cfun->machine->init_cumulative_args_called
> > > +             && !issued_x87_ret_error)
> >
> > Also, early return.
>
> Done.
>
> > >             {
> > >               error ("x87 register return with x87 disabled");
> > >               issued_x87_ret_error = true;
> > > diff --git a/gcc/config/i386/i386.h b/gcc/config/i386/i386.h
> > > index 48749104b24..ad908c010b3 100644
> > > --- a/gcc/config/i386/i386.h
> > > +++ b/gcc/config/i386/i386.h
> > > @@ -2945,6 +2945,9 @@ struct GTY(()) machine_function {
> > >       function.  */
> > >    BOOL_BITFIELD has_explicit_vzeroupper : 1;
> > >
> > > +  /* If true if init_cumulative_args has been called.  */
> > > +  BOOL_BITFIELD init_cumulative_args_called: 1;
> >
> > I think that we should follow aarch64 lead and name it silent_p. The
> > comment also suits our needs.
> >
> >   bool silent_p;        /* True if we should act silently, rather than
> >                    raise an error for invalid calls.  */
> >
>
> Done.
>
> Here is the v2 patch.  OK for master?

   BOOL_BITFIELD has_explicit_vzeroupper : 1;

+  /* If true if we should act silently, rather than raise an error for

True if we should ...

+     invalid calls.  */
+  BOOL_BITFIELD silent_p : 1;
+

OK with the above comment fix.

Thanks,
Uros.

      reply	other threads:[~2021-03-19 12:21 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-18 22:44 [PATCH] " H.J. Lu
2021-03-19  8:39 ` Uros Bizjak
2021-03-19 12:10   ` [PATCH v2] " H.J. Lu
2021-03-19 12:20     ` Uros Bizjak [this message]

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=CAFULd4Z7wYxzq+D9wNOT13CESeDyNQq6_UaQHceb5v3Zf2mKfg@mail.gmail.com \
    --to=ubizjak@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=hjl.tools@gmail.com \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).