From 3cce8d98f270f48f480046d439c9d4635641c24e Mon Sep 17 00:00:00 2001 From: Jan Hubicka Date: Fri, 7 Jul 2023 23:06:33 +0200 Subject: [PATCH] Dump profile_count along with relative frequency gcc/ChangeLog: * profile-count.cc (profile_count::dump): Add FUN parameter; print relative frequency. (profile_count::debug): Update. * profile-count.h (profile_count::dump): Update prototype. --- gcc/profile-count.cc | 14 ++++++++++---- gcc/profile-count.h | 4 ++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/gcc/profile-count.cc b/gcc/profile-count.cc index 16585045f8ea..6bf9700d8db6 100644 --- a/gcc/profile-count.cc +++ b/gcc/profile-count.cc @@ -87,10 +87,16 @@ const char *profile_quality_display_names[] = /* Dump THIS to BUFFER. */ void -profile_count::dump (char *buffer) const +profile_count::dump (char *buffer, struct function *fun) const { if (!initialized_p ()) sprintf (buffer, "uninitialized"); + else if (fun && initialized_p () + && fun->cfg + && ENTRY_BLOCK_PTR_FOR_FN (fun)->count.initialized_p ()) + sprintf (buffer, "%" PRId64 " (%s freq %.4f)", m_val, + profile_quality_display_names[m_quality], + to_sreal_scale (ENTRY_BLOCK_PTR_FOR_FN (fun)->count).to_double ()); else sprintf (buffer, "%" PRId64 " (%s)", m_val, profile_quality_display_names[m_quality]); @@ -99,10 +105,10 @@ profile_count::dump (char *buffer) const /* Dump THIS to F. */ void -profile_count::dump (FILE *f) const +profile_count::dump (FILE *f, struct function *fun) const { char buffer[64]; - dump (buffer); + dump (buffer, fun); fputs (buffer, f); } @@ -111,7 +117,7 @@ profile_count::dump (FILE *f) const void profile_count::debug () const { - dump (stderr); + dump (stderr, cfun); fprintf (stderr, "\n"); } diff --git a/gcc/profile-count.h b/gcc/profile-count.h index 4270793c9f6a..99416d9a4634 100644 --- a/gcc/profile-count.h +++ b/gcc/profile-count.h @@ -1281,10 +1281,10 @@ public: sreal to_sreal_scale (profile_count in, bool *known = NULL) const; /* Output THIS to F. */ - void dump (FILE *f) const; + void dump (FILE *f, struct function *fun = NULL) const; /* Output THIS to BUFFER. */ - void dump (char *buffer) const; + void dump (char *buffer, struct function *fun = NULL) const; /* Print THIS to stderr. */ void debug () const; -- 2.39.2