From: Jakub Jelinek <jakub@redhat.com>
To: Jan Hubicka <hubicka@ucw.cz>
Cc: Richard Biener <rguenther@suse.de>, gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] tree-optimization/106912 - IPA profile and pure/const
Date: Fri, 17 Mar 2023 20:54:38 +0100 [thread overview]
Message-ID: <ZBTFfqUQ+wluuWE/@tucnak> (raw)
In-Reply-To: <ZBTCMrFx87T38eQR@kam.mff.cuni.cz>
On Fri, Mar 17, 2023 at 08:40:34PM +0100, Jan Hubicka wrote:
> > + /* Drop the const attribute from the call type (the pure
> > + attribute is not available on types). */
> > + tree fntype = gimple_call_fntype (call);
> > + if (fntype && TYPE_READONLY (fntype))
> > + gimple_call_set_fntype
> > + (call, build_qualified_type (fntype, (TYPE_QUALS (fntype)
> > + & ~TYPE_QUAL_CONST)));
>
> Sorry, now I am bit confused on why Jakub's fix did not need similar
> fixup. The flag is only set during the profiling stage and thus I would
> expect it to still run into the problem that VOPs are missing.
> Is it only becuase we do not sanity check?
My patch started from this point ignoring all TYPE_READONLY bits on
all FUNCTION_TYPE/METHOD_TYPEs, while Richi's patch instead makes it
explicit in the IL, TYPE_READONLY is honored as before but it shouldn't
show up in any of the gimple_call_fntype types unless it is a direct
call to a const function for which we don't have a body.
In either case, vops are added on the update_stmt a few lines later.
> Here is a testcase that shows the problem:
>
> include <math.h>
> float c;
>
> __attribute__ ((const))
> float
> instrument(float v)
> {
> return sin (v);
> }
> __attribute__ ((no_profile_instrument_function,const,noinline))
> float noinstrument (float v)
> {
> return instrument (v);
> }
>
> m()
> {
> c+=instrument(c);
> if (!__builtin_expect (c,1))
> {
> c+=noinstrument (c);
> }
> c+=instrument(c);
> }
> main()
> {
> m();
> }
>
> Compiling
> gcc -O0 t.c -fprofile-arcs -fno-early-inlining --coverage -lm -ftest-coverage -S ; gcc t.s -ftest-coverage -lm -fprofile-arcs
> makes gcov to report 3 executions on instrument while with -O3 it is 2.
>
> This is because the noinstrument has const flag that is not cleared and
> it becoames essentially non-const because it calls instrument that gets
> intrumented and partially inlined.
I thought tree-profile.cc right now clears const on all const functions
with body, or is that
!(!node->clone_of || node->decl != node->clone_of->decl)
restricting it to instrumented functions only?
Jakub
next prev parent reply other threads:[~2023-03-17 19:54 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-25 7:59 Richard Biener
2022-11-25 10:05 ` Jan Hubicka
2022-11-25 12:05 ` Richard Biener
2022-11-25 12:11 ` Jan Hubicka
2022-11-25 13:05 ` Richard Biener
2022-11-25 13:18 ` Jan Hubicka
2022-11-25 20:26 ` Richard Biener
2023-03-16 11:21 ` Jakub Jelinek
2023-03-16 12:05 ` Richard Biener
2023-03-16 12:13 ` Jakub Jelinek
2023-03-16 12:22 ` Richard Biener
2023-03-16 14:11 ` Richard Biener
2023-03-16 14:27 ` Jakub Jelinek
2023-03-17 19:40 ` Jan Hubicka
2023-03-17 19:54 ` Jakub Jelinek [this message]
2023-03-20 8:33 ` Richard Biener
2023-03-24 10:25 ` Richard Biener
2023-03-24 11:49 ` Jan Hubicka
2023-03-24 13:05 ` Jan Hubicka
2023-03-24 13:07 ` Richard Biener
2023-03-24 13:18 ` Jan Hubicka
2023-03-17 19:09 ` Jan Hubicka
2023-03-17 19:27 ` Jakub Jelinek
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=ZBTFfqUQ+wluuWE/@tucnak \
--to=jakub@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=hubicka@ucw.cz \
--cc=rguenther@suse.de \
/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).