From: Jakub Jelinek Date: Thu, 2 Jan 2020 09:15:00 +0000 (+0100) Subject: re PR ipa/93087 (Bogus `-Wsuggest-attribute=cold` on function already marked as ... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=4ea5d54b3c7175de045589f994fc94ed7e59d80d;p=gcc.git 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. From-SVN: r279829 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 382c3004d1c..34b4976819a 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2020-01-02 Jakub Jelinek + + 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 PR target/67834 diff --git a/gcc/predict.c b/gcc/predict.c index 6b60ff4a4d1..a134deb9b3f 100644 --- a/gcc/predict.c +++ b/gcc/predict.c @@ -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; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 1ccff579b4e..e943998ac6f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2020-01-02 Jakub Jelinek + + PR ipa/93087 + * c-c++-common/cold-1.c: New test. + 2020-01-01 Jerry DeLisle 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 index 00000000000..3493623e1eb --- /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; +}