public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-6865] predict: Don't emit -Wsuggest-attribute=cold warning for functions which already have that attribute Date: Sun, 26 Mar 2023 18:15:57 +0000 (GMT) [thread overview] Message-ID: <20230326181557.EADCA3858C00@sourceware.org> (raw) https://gcc.gnu.org/g:7eca91d4781bb3df941f25c30b971dac66ba1b3d commit r13-6865-g7eca91d4781bb3df941f25c30b971dac66ba1b3d Author: Jakub Jelinek <jakub@redhat.com> Date: Sun Mar 26 20:15:05 2023 +0200 predict: Don't emit -Wsuggest-attribute=cold warning for functions which already have that attribute [PR105685] In the following testcase, we predict baz to have cold entry regardless of the user supplied attribute (as it call unconditionally a cold function), but still issue a -Wsuggest-attribute=cold warning despite it having that attribute already. The following patch avoids that. 2023-03-26 Jakub Jelinek <jakub@redhat.com> PR ipa/105685 * predict.cc (compute_function_frequency): Don't call warn_function_cold if function already has cold attribute. * c-c++-common/cold-2.c: New test. Diff: --- gcc/predict.cc | 4 +++- gcc/testsuite/c-c++-common/cold-2.c | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/gcc/predict.cc b/gcc/predict.cc index 851117e5fac..a0dc409648f 100644 --- a/gcc/predict.cc +++ b/gcc/predict.cc @@ -4033,7 +4033,9 @@ compute_function_frequency (void) } node->frequency = NODE_FREQUENCY_UNLIKELY_EXECUTED; - warn_function_cold (current_function_decl); + if (lookup_attribute ("cold", DECL_ATTRIBUTES (current_function_decl)) + == NULL) + warn_function_cold (current_function_decl); if (ENTRY_BLOCK_PTR_FOR_FN (cfun)->count.ipa() == profile_count::zero ()) return; FOR_EACH_BB_FN (bb, cfun) diff --git a/gcc/testsuite/c-c++-common/cold-2.c b/gcc/testsuite/c-c++-common/cold-2.c new file mode 100644 index 00000000000..7f78496fb82 --- /dev/null +++ b/gcc/testsuite/c-c++-common/cold-2.c @@ -0,0 +1,19 @@ +/* PR ipa/105685 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wsuggest-attribute=cold" } */ + +extern void foo (char *, char const *, int); + +__attribute__((cold)) char * +bar (int x) +{ + static char b[42]; + foo (b, "foo", x); + return b; +} + +__attribute__((cold)) char * +baz (int x) /* { dg-bogus "function might be candidate for attribute 'cold'" } */ +{ + return bar (x); +}
reply other threads:[~2023-03-26 18:15 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20230326181557.EADCA3858C00@sourceware.org \ --to=jakub@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /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: linkBe 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).