From: Jan Hubicka <hubicka@ucw.cz>
To: Jakub Jelinek <jakub@redhat.com>
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:09:17 +0100 [thread overview]
Message-ID: <ZBS63Wf9FxkfCOCE@kam.mff.cuni.cz> (raw)
In-Reply-To: <ZBMIBhJmFydWQgQf@tucnak>
>
> I have in the meantime briefly tested following.
>
> But if you want to the above way, then at least the testcase could be
> useful. Though, not sure if the above is all that is needed. Shouldn't
> set_const_flag_1 upon TREE_READONLY (node->decl) = 0; also adjust
> TREE_TYPE on the function to
> tree fntype = TREE_TYPE (node->decl);
> TREE_TYPE (node->decl)
> = build_qualified_type (fntype,
> TYPE_QUALS (fntype) & ~TYPE_QUAL_CONST);
> too (perhaps guarded on TREE_READONLY (fntype))?
>
> 2023-03-16 Jakub Jelinek <jakub@redhat.com>
>
> PR tree-optimization/106912
> gcc/
> * calls.h (ignore_const_fntype): Declare.
> * calls.cc (flags_from_decl_or_type): Ignore TYPE_READONLY
> on types if ignore_const_fntype.
> * tree-profile.cc: Include calls.h.
> (tree_profiling): Set ignore_const_fntype if profile_arc_flag
> or flag_test_coverage.
> gcc/lto/
> * lto-lang.cc (lto_post_options): Set ignore_const_fntype if
> profile_arc_flag or flag_test_coverage and not flag_auto_profile.
> gcc/testsuite/
> * gcc.dg/pr106912.c: New test.
>
> --- gcc/calls.h.jj 2023-01-02 09:32:51.252868185 +0100
> +++ gcc/calls.h 2023-03-16 12:23:51.632460586 +0100
> @@ -134,5 +134,6 @@ extern void maybe_complain_about_tail_ca
>
> extern rtx rtx_for_static_chain (const_tree, bool);
> extern bool cxx17_empty_base_field_p (const_tree);
> +extern bool ignore_const_fntype;
>
> #endif // GCC_CALLS_H
> --- gcc/calls.cc.jj 2023-02-21 11:44:48.460464845 +0100
> +++ gcc/calls.cc 2023-03-16 12:27:45.427032110 +0100
> @@ -800,6 +800,13 @@ is_tm_builtin (const_tree fndecl)
> return false;
> }
>
> +/* Set if flags_from_decl_or_type should ignore TYPE_READONLY of function
> + types. This is used when tree-profile.cc instruments const calls,
> + clears TREE_READONLY on FUNCTION_DECLs which have been instrumented, but
> + for function types or indirect calls we don't know if the callees have been
> + instrumented or not. */
> +bool ignore_const_fntype;
> +
> /* Detect flags (function attributes) from the function decl or type node. */
>
> int
> @@ -849,7 +856,7 @@ flags_from_decl_or_type (const_tree exp)
> }
> else if (TYPE_P (exp))
> {
> - if (TYPE_READONLY (exp))
> + if (TYPE_READONLY (exp) && !ignore_const_fntype)
I think we want to ignore PURE flag too: if callee modifies counters
seen by caller, we need to take that into account when optimizing it.
It is not very pretty to have global flag for prifled state, but I can't
think of scenario where this would break, so perhaps it is good way to
go?
Honza
next prev parent reply other threads:[~2023-03-17 19:09 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
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 [this message]
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=ZBS63Wf9FxkfCOCE@kam.mff.cuni.cz \
--to=hubicka@ucw.cz \
--cc=gcc-patches@gcc.gnu.org \
--cc=jakub@redhat.com \
--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).