re PR ipa/93087 (Bogus `-Wsuggest-attribute=cold` on function already marked as ...
authorJakub Jelinek <jakub@redhat.com>
Thu, 2 Jan 2020 09:15:00 +0000 (10:15 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Thu, 2 Jan 2020 09:15:00 +0000 (10:15 +0100)
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.

From-SVN: r279829

gcc/ChangeLog
gcc/predict.c
gcc/testsuite/ChangeLog
gcc/testsuite/c-c++-common/cold-1.c [new file with mode: 0644]

index 382c3004d1c413324fd36f3186cfb5018c31e475..34b4976819aa5b25de2f2b75a056f71fd7ab1c9c 100644 (file)
@@ -1,3 +1,9 @@
+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-01  John David Anglin  <danglin@gcc.gnu.org>
 
        PR target/67834
index 6b60ff4a4d18c27c440fd10a1fd00e54e81bfc21..a134deb9b3f57b0ab785ce995d6cbe59d7f6f4b9 100644 (file)
@@ -3937,10 +3937,7 @@ compute_function_frequency (void)
       int flags = flags_from_decl_or_type (current_function_decl);
       if (lookup_attribute ("cold", DECL_ATTRIBUTES (current_function_decl))
          != NULL)
-       {
-          node->frequency = NODE_FREQUENCY_UNLIKELY_EXECUTED;
-         warn_function_cold (current_function_decl);
-       }
+       node->frequency = NODE_FREQUENCY_UNLIKELY_EXECUTED;
       else if (lookup_attribute ("hot", DECL_ATTRIBUTES (current_function_decl))
               != NULL)
         node->frequency = NODE_FREQUENCY_HOT;
index 1ccff579b4ed936728bbef7736ae7d680a39f5ed..e943998ac6f98df88ea806732c4932bb30e55b9a 100644 (file)
@@ -1,3 +1,8 @@
+2020-01-02  Jakub Jelinek  <jakub@redhat.com>
+
+       PR ipa/93087
+       * c-c++-common/cold-1.c: New test.
+
 2020-01-01  Jerry DeLisle  <jvdelisle@gcc.gnu.org>
 
        PR libfortran/90374
diff --git a/gcc/testsuite/c-c++-common/cold-1.c b/gcc/testsuite/c-c++-common/cold-1.c
new file mode 100644 (file)
index 0000000..3493623
--- /dev/null
@@ -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;
+}