public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Sandra Loosemore <sandra@codesourcery.com>
To: GCC Patches <gcc-patches@gcc.gnu.org>,
	David Ung <davidu@mips.com>,   Nigel Stephens <nigel@mips.com>,
	 Mark Mitchell <mark@codesourcery.com>,
	 richard@codesourcery.com
Subject: Re: PATCH:  mips16/nomips16 function attributes, version N
Date: Thu, 30 Aug 2007 02:02:00 -0000	[thread overview]
Message-ID: <46D5FB22.8030509@codesourcery.com> (raw)
In-Reply-To: <87wsveknrz.fsf@firetop.home>

Richard Sandiford wrote:

> I suppose I was hoping that, one day, the compiler would be in a
> "mode-agnostic" state when outside the top-level push_cfun/pop_cfun
> pair, except for explicit exceptions like TARGET_CPU_CPP_BUILTINS.
> However, that would mean deferring backend_init until the first call
> to your new hook, which would probably be even more work than what
> you've done so far.  Even then, the compiler would not be in a
> mode-agnostic state between a top-level pop_cfun and the next
> push_cfun.  I suppose that day will only come "when" (= if) all
> mode-specific data is in an easily-switchable struct.

Right.  In a perfect world, what we'd do here is just have two objects 
encapsulating all the back end state for each mode, and all we'd have to 
swap is a pointer.  But reverse-engineering that onto the existing code 
would be very nasty, and likely introduce many bugs.

> As it is, the comments you made on internal IRC suggest that this
> reinitialisation is very expensive, so I suppose it's not something
> we want to foist on normal -mips16 users for the sake of an internal
> mental model.

To give a rough idea of the magnitude of the performance hit, my 
previous version of these patches that invoked the reset hook only once 
per function ran about 20% slower in -mflip-mips16 mode than without, 
judging just by time stamps on log files from running the gcc testsuite. 
  With the new version and the hook being invoked every time cfun is 
set, that's gone up to a factor of 3.  Of course -mflip-mips16 is 
designed to be pathological; in practice, use of these attributes is 
going to be exceptional, and we should optimize for the common case instead.

As I noted in my comments about the other part of the patch, I think 
some of the places where cfun is being set to NULL are really not 
necessary (they seem to be signalling that a processing phase is done 
rather than a real function context switch), and getting rid of those 
places would speed things up.  Again, it's only a concern for things 
that aren't using the default mode.

> From the segfault you describe, it sounds like we currently assume that
> calling this hook is a no-op until the first time we pass a function
> with attributes.  (Or at least, it sounds like that rule would avoid the
> situations where things go wrong.)  If so, I think we should mention
> that in the tm.texi documentation.

Yes, I am worried about this too.  I already had to add a hack to 
prevent the hook from being invoked recursively; maybe I need to 
generalize that with something to prevent it from being invoked before 
initial initialization :-) is complete, and/or put an assertion in 
target_reinit ().  I'm going to poke around at this once I've tested the 
other changes you suggested.

-Sandra

      reply	other threads:[~2007-08-29 23:04 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-08-27 20:14 Sandra Loosemore
2007-08-28  9:02 ` Richard Sandiford
2007-08-29 19:56   ` Sandra Loosemore
2007-08-29 23:04     ` Richard Sandiford
2007-08-30  2:02       ` Sandra Loosemore [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=46D5FB22.8030509@codesourcery.com \
    --to=sandra@codesourcery.com \
    --cc=davidu@mips.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=mark@codesourcery.com \
    --cc=nigel@mips.com \
    --cc=richard@codesourcery.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).