public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/vendors/ibm/heads/gcc-9)] re PR ipa/93087 (Bogus `-Wsuggest-attribute=cold` on function already marked as `__attribute__((cold
@ 2020-02-04 21:14 Peter Bergner
  0 siblings, 0 replies; only message in thread
From: Peter Bergner @ 2020-02-04 21:14 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:7bf1518f84d5e676dd5f4335783eaf7b742961a5

commit 7bf1518f84d5e676dd5f4335783eaf7b742961a5
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Wed Jan 22 17:48:05 2020 +0100

    re PR ipa/93087 (Bogus `-Wsuggest-attribute=cold` on function already marked as `__attribute__((cold))`)
    
    	PR ipa/93087
    	* predict.c (compute_function_frequency): Don't call
    	warn_function_cold on functions that already have cold attribute.
    
    	* c-c++-common/cold-1.c: New test.

Diff:
---
 gcc/ChangeLog                       |  9 +++++++++
 gcc/predict.c                       | 12 +++++++-----
 gcc/testsuite/ChangeLog             |  8 ++++++++
 gcc/testsuite/c-c++-common/cold-1.c | 22 ++++++++++++++++++++++
 4 files changed, 46 insertions(+), 5 deletions(-)

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index d3131229..d95b6af 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,12 @@
+2020-01-22  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from mainline
+	2020-01-02  Jakub Jelinek  <jakub@redhat.com>
+
+	PR ipa/93087
+	* predict.c (compute_function_frequency): Don't call
+	warn_function_cold on functions that already have cold attribute.
+
 2020-01-20  Richard Biener  <rguenther@suse.de>
 
 	Backport from mainline
diff --git a/gcc/predict.c b/gcc/predict.c
index 60a19d7..eaab47f 100644
--- a/gcc/predict.c
+++ b/gcc/predict.c
@@ -3937,12 +3937,14 @@ compute_function_frequency (void)
   if (profile_status_for_fn (cfun) != PROFILE_READ)
     {
       int flags = flags_from_decl_or_type (current_function_decl);
-      if ((ENTRY_BLOCK_PTR_FOR_FN (cfun)->count.ipa_p ()
-	   && ENTRY_BLOCK_PTR_FOR_FN (cfun)->count.ipa() == profile_count::zero ())
-	  || lookup_attribute ("cold", DECL_ATTRIBUTES (current_function_decl))
-	     != NULL)
+      if (lookup_attribute ("cold", DECL_ATTRIBUTES (current_function_decl))
+	  != NULL)
+	node->frequency = NODE_FREQUENCY_UNLIKELY_EXECUTED;
+      else if (ENTRY_BLOCK_PTR_FOR_FN (cfun)->count.ipa_p ()
+	       && (ENTRY_BLOCK_PTR_FOR_FN (cfun)->count.ipa ()
+		   == profile_count::zero ()))
 	{
-          node->frequency = NODE_FREQUENCY_UNLIKELY_EXECUTED;
+	  node->frequency = NODE_FREQUENCY_UNLIKELY_EXECUTED;
 	  warn_function_cold (current_function_decl);
 	}
       else if (lookup_attribute ("hot", DECL_ATTRIBUTES (current_function_decl))
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index c306cf6..cd4f7f4 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,6 +1,14 @@
 2020-01-22  Jakub Jelinek  <jakub@redhat.com>
 
 	Backported from mainline
+	2020-01-02  Jakub Jelinek  <jakub@redhat.com>
+
+	PR ipa/93087
+	* c-c++-common/cold-1.c: New test.
+
+2020-01-22  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from mainline
 	2019-12-26  Jakub Jelinek  <jakub@redhat.com>
 
 	PR c++/92438
diff --git a/gcc/testsuite/c-c++-common/cold-1.c b/gcc/testsuite/c-c++-common/cold-1.c
new file mode 100644
index 0000000..3493623
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/cold-1.c
@@ -0,0 +1,22 @@
+/* PR ipa/93087 */
+/* { dg-do compile { target nonpic } } */
+/* { dg-options "-O1 -Wsuggest-attribute=cold" } */
+
+extern void *getdata (void);
+extern int set_error (char const *message) __attribute__((cold));
+
+__attribute__((cold)) int
+set_nomem (void)	/* { dg-bogus "function might be candidate for attribute 'cold'" } */
+{
+  return set_error ("Allocation failed");
+}
+
+void *
+getdata_or_set_error (void)
+{
+  void *result;
+  result = getdata ();
+  if (!result)
+    set_nomem ();
+  return result;
+}


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-02-04 21:14 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-04 21:14 [gcc(refs/vendors/ibm/heads/gcc-9)] re PR ipa/93087 (Bogus `-Wsuggest-attribute=cold` on function already marked as `__attribute__((cold Peter Bergner

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).