public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: David Malcolm <dmalcolm@redhat.com>
To: Jeff Law <law@redhat.com>
Cc: Richard Biener <richard.guenther@gmail.com>,
	       Mikhail Maltsev	 <maltsevm@gmail.com>,
	       gcc-patches <gcc-patches@gnu.org>
Subject: Re: [PATCH 2/2] Get rid of global state accesses in dominance.c
Date: Fri, 14 Aug 2015 20:24:00 -0000	[thread overview]
Message-ID: <1439583118.21752.121.camel@surprise> (raw)
In-Reply-To: <55CE3288.5000806@redhat.com>

On Fri, 2015-08-14 at 12:25 -0600, Jeff Law wrote:
> On 08/14/2015 02:02 AM, Richard Biener wrote:
> > On Fri, Aug 14, 2015 at 3:04 AM, Mikhail Maltsev <maltsevm@gmail.com> wrote:
> >> The second part removes all global state accesses (i.e. accesses to cfun and
> >> it's members) from dominance.c. This requires to change lots of code, but I hope
> >> that this is a step in right direction (if my understanding of ongoing
> >> re-architecture w.r.t. to global state is correct).
> >>
> >> For now this second part lacks a changelog entry, but it's very "mechanical". I
> >> will, of course, write it if the patch gets approved.
> >
> > So the last time I did similar refactoring I wondered if we can somehow avoid
> > the "noise" in non-IPA passes.  Ideas I came up with are
> >
> >   a)  Inherit gimple/rtl pass classes from a class which is initialized with the
> >        function the pass operates on and provides methods like
> >
> >      bool dom_info_available_p (..) { return dom_info_available_p (fn, ...); }
> >
> >       thus wraps APIs working on a specific function.
> >
> >   b)  Do sth similar but make it work with overloads and clever (no idea what!)
> >      C++ that disables them if this_fn cannot be looked up
> >
> >      template <disable-me-if-this_fn-cannot_be_lookedup-at-instantiation-place>
> >      bool dom_info_available_p (..., struct function *fn = this_fn);
> >
> > all of the above would of course require that passes make all their
> > implementation
> > be methods of their pass class.  So even more refactoring.
> >
> > Note that we do not have any IPA pass which accesses dominators, so the
> > implicit 'cfun' use was ok.  The cases I refactored were those where we had
> > to push/pop_cfun () in IPA passes (which can be expensive) because it
> > used APIs with implicit cfun.
> >
> > Overall I'm not sure we want all APIs using 'cfun' to be refactored.
> > It is after
> > all useless noise to callers if all callers are effectively using 'cfun'.
> And since the main driver for eliminating global state is David's work 
> on the JIT, perhaps see if any of this helps David in a noticeable way 
> before giving it a yea/nea.

The JIT guards all access to GCC's state in a big mutex ("jit_mutex", in
gcc/jit/jit-playback.c).

For example, this includes everything to do with GC and GTY, since
there's implicitly a single set of GC roots and the GC code isn't thread
safe.

So in theory this patch might reduce the amount of things that need to
be guarded by the mutex, but sadly the mountain of work there is so
large that I'm not sure how helpful it is.  (sigh)

I've been tackling things on an as-needed basis - for example, the
recent timevar global-state removal was motivated by wanting to expose a
profiling API to jit client code.

So if there are other benefits beyond merely eliminating accesses to
globals, then maybe it's good.  Does the code become simpler, more easy
to understand?  Does it eliminate the need to change "cfun" (IIRC that
can be expensive).

For example, the jit has some rather ugly code to purge global state
after each in-process invocation.  If that can be simplified or made
less ugly, that's good.

Hope this is constructive.
Dave

  reply	other threads:[~2015-08-14 20:12 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-14  1:05 [PATCH 1/2] C++-ify dominance.c Mikhail Maltsev
2015-08-14  1:25 ` [PATCH 2/2] Get rid of global state accesses in dominance.c Mikhail Maltsev
2015-08-14  8:17   ` Richard Biener
2015-08-14 18:28     ` Jeff Law
2015-08-14 20:24       ` David Malcolm [this message]
2015-08-15  6:13     ` Mikhail Maltsev
2015-08-18 10:13       ` Richard Biener
2015-08-14  7:54 ` [PATCH 1/2] C++-ify dominance.c Richard Biener
2015-08-14 17:26   ` Jeff Law
2015-08-15  6:05   ` Mikhail Maltsev
2015-08-18 19:23     ` Jeff Law
2015-08-22  7:01       ` Mikhail Maltsev
2015-08-14 18:25 ` Jeff Law
2015-08-15  7:59   ` Richard Biener

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=1439583118.21752.121.camel@surprise \
    --to=dmalcolm@redhat.com \
    --cc=gcc-patches@gnu.org \
    --cc=law@redhat.com \
    --cc=maltsevm@gmail.com \
    --cc=richard.guenther@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).