public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Biener <rguenther@suse.de>
To: Alexandre Oliva <oliva@adacore.com>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] strub: use opt_for_fn during ipa
Date: Tue, 19 Dec 2023 09:20:07 +0100 (CET)	[thread overview]
Message-ID: <3q2snq2n-sn4n-0p60-56n5-55p9rp7sr16o@fhfr.qr> (raw)
In-Reply-To: <or4jge4zl0.fsf@lxoliva.fsfla.org>

On Tue, 19 Dec 2023, Alexandre Oliva wrote:

> On Dec 15, 2023, Richard Biener <rguenther@suse.de> wrote:
> 
> > You have to be generally careful when working within IPA
> > with function bodies without push/pop_cfun around that, several APIs
> > have variants with struct function sepcified, using the wrong one
> > will get you a NULL cfun which _some_ of them handle gracefully and
> > "wrong", all EH stuff is amongst this for example.
> 
> *nod*, I recall running into that, and finding some APIs that required
> push/pop_cfun, so since I was implementing strub so that it could be
> plugged into an existing compiler, I didn't give much thought to
> introducing alternate APIs that could.  IIRC I first hit something about
> EH, and then I had to put in push/pop_cfun.  That was very early on, so
> after that I may have used implicit-cfun APIs without getting ICEs.  I
> suppose now that strub is in pursuing push/pop_cfun avoidance could be a
> nice cleanup.

Yeah, adding API variants with explicit struct function is considered OK
when that allows to avoid push/pop_cfun.  When playing with stmts
the first thing you'll hit is update_stmt (though it's core worker,
update_stmt_operands has the arg already).  Sometimes the cfun
dependence isn't really obvious ...

> > I see you replace flag_exceptions with opt_for_fn (cfun->decl, 
> > flag_exceptions), given that's 'cfun' this replacement is a no-op
> > given 'cfun' would be NULL in IPA context unless you pushed a function.
> 
> > Looking at the 2nd hunk and the caller it seems the transform is
> > a no-op for indrect_calls but not callees, thus that hunk is OK.
> 
> Yeah, I figured that was the reason behind your recommendation, but I
> guess adding explicit uses of cfun (rather than passing a function
> around) doesn't really make things much better, except inasmuchas it
> enables a future de-cfun-ification of strub passes to be a little more
> mechanical.

Yep, we've gone through some of GCCs APIs where there was two
variants, one with and one without explicit struct function arg
and eliminating the first in favor of explicit mentioning of 'cfun'
to show where we depend on that.  That was in the context of
eventually threading parts of GCC which of course doesn't play
well with this kind of global state.

Richard.

      reply	other threads:[~2023-12-19  8:21 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-14 19:54 Alexandre Oliva
2023-12-15  7:08 ` Richard Biener
2023-12-19  3:54   ` Alexandre Oliva
2023-12-19  8:20     ` Richard Biener [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=3q2snq2n-sn4n-0p60-56n5-55p9rp7sr16o@fhfr.qr \
    --to=rguenther@suse.de \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=oliva@adacore.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).