+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
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))
+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
--- /dev/null
+/* 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;
+}