public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: Aldy Hernandez <aldyh@redhat.com>,
	       Richard Sandiford <rdsandiford@googlemail.com>
Cc: gcc-patches <gcc-patches@gcc.gnu.org>
Subject: Re: PR target/52555: attribute optimize is overriding command line options
Date: Tue, 12 Feb 2013 14:05:00 -0000	[thread overview]
Message-ID: <20130212140503.GD4385@tucnak.redhat.com> (raw)
In-Reply-To: <51198989.7090803@redhat.com>

On Mon, Feb 11, 2013 at 06:15:05PM -0600, Aldy Hernandez wrote:
> How does this look?

Looks good to me.

> Jakub, what's this you mention in the PR about caching
> __optimize__((3))?  You also mention I shouldn't compare against
> this_target_optabs, but default_target_optabs.  But what if
> this_target_optabs has changed?  (See patch).

The reason for that is that this_target_optabs could at that point be
simply whatever optabs used the last parsed function.
this_target_optabs changes only either because of optimize attribute
(not sure if MIPS as the only switchable target? supports that), or
because of mips_set_mips16_mode.  I think invoke_set_current_function_hook
invokes the target hook after the code you've changed, so I'd say it should
work fine even on MIPS.  CCing Richard for that anyway.
> 
> Tested on x86-64 Linux.  It would be nice if someone with access to
> a SWITCHABLE_TARGET platform (mips) could also test this.

A few nits below.  I'm not sure about the behavior of multiple optimize
attributes either, let's try it and see how it is handled right now
(ignoring optabs).

> @@ -6184,6 +6184,41 @@ init_optabs (void)
>    targetm.init_libfuncs ();
>  }
>  
> +/* Recompute the optabs.  If they have changed, save the new set of
> +   optabs in the optimization node OPTNODE.  */
> +
> +void
> +save_optabs_if_changed (tree optnode)
> +{
> +  struct target_optabs *save_target_optabs = this_target_optabs;
> +  struct target_optabs *tmp_target_optabs = XNEW (struct target_optabs);
> +
> +  /* Generate a new set of optabs into tmp_target_optabs.  */
> +  memset (tmp_target_optabs, 0, sizeof (struct target_optabs));

I think you should just use XCNEW and drop the memset.

> +  this_target_optabs = tmp_target_optabs;
> +  init_all_optabs ();
> +  this_target_optabs = save_target_optabs;
> +
> +  /* If the optabs changed, record it in the node.  */
> +  if (memcmp (tmp_target_optabs, this_target_optabs,
> +	      sizeof (struct target_optabs)))
> +    {
> +      /* ?? An existing entry in TREE_OPTIMIZATION_OPTABS indicates
> +	 multiple ((optimize)) attributes for the same function.  Is
> +	 this even valid?  For now, just clobber the existing entry
> +	 with the new optabs.  */
> +      if (TREE_OPTIMIZATION_OPTABS (optnode))
> +	free (TREE_OPTIMIZATION_OPTABS (optnode));
> +
> +      TREE_OPTIMIZATION_OPTABS (optnode) = tmp_target_optabs;
> +    }
> +  else
> +    {
> +      TREE_OPTIMIZATION_OPTABS (optnode) = NULL;
> +      free (tmp_target_optabs);

Shouldn't this (and above) be XDELETE to match the allocation style?

	Jakub

  reply	other threads:[~2013-02-12 14:05 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-12  0:15 Aldy Hernandez
2013-02-12 14:05 ` Jakub Jelinek [this message]
2013-02-12 15:58   ` Aldy Hernandez
2013-02-12 16:16     ` Jakub Jelinek
2013-02-12 16:30   ` Richard Sandiford
2013-02-12 17:28     ` Aldy Hernandez
2013-02-12 17:48       ` Richard Sandiford
2013-02-12 17:46         ` Richard Sandiford
2013-02-13 17:39         ` Aldy Hernandez
2013-02-13 17:58           ` Richard Sandiford
2013-02-13 18:08             ` Aldy Hernandez
2013-02-13 19:54               ` Jakub Jelinek
2013-02-15 17:23                 ` Aldy Hernandez
2013-02-15 17:35                   ` Jakub Jelinek
2013-02-15 17:52                     ` Aldy Hernandez
2013-02-16 11:20                   ` Richard Sandiford
2013-02-18 18:51                     ` Aldy Hernandez
2013-02-18 23:05                       ` Jakub Jelinek
2013-02-21 23:03                         ` Steve Ellcey
2013-02-22  0:10                           ` Aldy Hernandez
2013-02-22 10:03                           ` Jakub Jelinek
2013-02-22 17:32                             ` Steve Ellcey
2013-02-22 18:17                               ` Jakub Jelinek
2013-02-22 19:49                                 ` Richard Sandiford
2013-03-01 23:37                             ` Steve Ellcey

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=20130212140503.GD4385@tucnak.redhat.com \
    --to=jakub@redhat.com \
    --cc=aldyh@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=rdsandiford@googlemail.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).