diff options
author | Jakub Jelinek <jakub@redhat.com> | 2020-01-02 10:15:00 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2020-01-02 10:15:00 +0100 |
commit | 4ea5d54b3c7175de045589f994fc94ed7e59d80d (patch) | |
tree | 4472bba5f8bb5925bc2f7a9345c82197dd3b83f1 | |
parent | 2b70275ee1b0de038324280276a9edebcaa93d90 (diff) | |
download | gcc-4ea5d54b3c7175de045589f994fc94ed7e59d80d.zip gcc-4ea5d54b3c7175de045589f994fc94ed7e59d80d.tar.gz gcc-4ea5d54b3c7175de045589f994fc94ed7e59d80d.tar.bz2 |
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
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/predict.c | 5 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/c-c++-common/cold-1.c | 22 |
4 files changed, 34 insertions, 4 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 382c300..34b4976 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -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 diff --git a/gcc/predict.c b/gcc/predict.c index 6b60ff4..a134deb 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 1ccff57..e943998 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -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 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; +} |