This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: C PATCH to kill c_save_expr or towards delayed folding for the C FE
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Joseph Myers <joseph at codesourcery dot com>
- Cc: Marek Polacek <polacek at redhat dot com>, GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Sat, 13 May 2017 08:59:42 +0200
- Subject: Re: C PATCH to kill c_save_expr or towards delayed folding for the C FE
- Authentication-results: sourceware.org; auth=none
- Authentication-results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com
- Authentication-results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=jakub at redhat dot com
- Dkim-filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 13FFEC049D5C
- Dmarc-filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 13FFEC049D5C
- References: <20170512193726.GL4910@redhat.com> <alpine.DEB.2.20.1705122018060.28149@digraph.polyomino.org.uk>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Fri, May 12, 2017 at 08:28:38PM +0000, Joseph Myers wrote:
> On Fri, 12 May 2017, Marek Polacek wrote:
>
> > In the effort of reducing early folding, we should avoid calling c_fully_fold
> > blithely, except when needed for e.g. initializers. This is a teeny tiny step
>
> Note there are several reasons for early folding in the C front end: at
> least (a) cases where logically needed (initializers and other places
> where constants are needed), (b) because warnings need a folded
> expression, (c) when the expression will go somewhere c_fully_fold does
> not recurse inside. Also (d) convert, at least, folds regardless of
> whether it's actually necessary.
The C++ FE has here a folding cache. For (a) I think one usually just
performs that once (to fold e.g. the initializer), for (b) one might want
to fold many times, when wanting to test for some warning and then finally
when folding everything (which is where a cache can help, the first time you
fold something for a warning or when folding everything if never fold
something for a warning you cache the result and then just look it up).
(c) we should fix, (d) too, or convert to (b) kind of tests - fold something
in a test to see which path should be taken, but then actually defer
folding till later.
Jakub