* [PATCH] IPA ICF: enhance dump output
@ 2019-06-04 14:39 Martin Liška
2019-06-05 22:12 ` Jeff Law
0 siblings, 1 reply; 4+ messages in thread
From: Martin Liška @ 2019-06-04 14:39 UTC (permalink / raw)
To: gcc-patches; +Cc: Jan Hubicka
[-- Attachment #1: Type: text/plain, Size: 738 bytes --]
Hi.
The patch is about simplification of dump output. Plus it prints
also a file in which the dump message was emitted.
Patch can bootstrap on x86_64-linux-gnu and survives regression tests.
Ready to be installed?
Thanks,
Martin
gcc/ChangeLog:
2019-06-04 Martin Liska <mliska@suse.cz>
* ipa-icf-gimple.h (dump_message_1): Remove.
(dump_message): Likewise.
(return_false_with_message_1): Print also file.
(return_false_with_msg): Likewise.
(return_with_result): Likewise.
(return_with_debug): Likewise.
* ipa-icf.c (sem_function::equals_private): Remove call
to dump_message.
---
gcc/ipa-icf-gimple.h | 31 +++++++++++--------------------
gcc/ipa-icf.c | 2 --
2 files changed, 11 insertions(+), 22 deletions(-)
[-- Attachment #2: 0001-IPA-ICF-enhance-dump-output.patch --]
[-- Type: text/x-patch, Size: 3162 bytes --]
diff --git a/gcc/ipa-icf-gimple.h b/gcc/ipa-icf-gimple.h
index 51aadced9ea..351bddfb2f6 100644
--- a/gcc/ipa-icf-gimple.h
+++ b/gcc/ipa-icf-gimple.h
@@ -36,34 +36,22 @@ along with GCC; see the file COPYING3. If not see
#define FPRINTF_SPACES(file, space_count, format, ...) \
fprintf (file, "%*s" format, space_count, " ", ##__VA_ARGS__);
-/* Prints a MESSAGE to dump_file if exists. FUNC is name of function and
- LINE is location in the source file. */
-
-static inline void
-dump_message_1 (const char *message, const char *func, unsigned int line)
-{
- if (dump_file && (dump_flags & TDF_DETAILS))
- fprintf (dump_file, " debug message: %s (%s:%u)\n", message, func, line);
-}
-
-/* Prints a MESSAGE to dump_file if exists. */
-#define dump_message(message) dump_message_1 (message, __func__, __LINE__)
-
/* Logs a MESSAGE to dump_file if exists and returns false. FUNC is name
of function and LINE is location in the source file. */
static inline bool
-return_false_with_message_1 (const char *message, const char *func,
- unsigned int line)
+return_false_with_message_1 (const char *message, const char *filename,
+ const char *func, unsigned int line)
{
if (dump_file && (dump_flags & TDF_DETAILS))
- fprintf (dump_file, " false returned: '%s' (%s:%u)\n", message, func, line);
+ fprintf (dump_file, " false returned: '%s' in %s at %s:%u\n", message, func,
+ filename, line);
return false;
}
/* Logs a MESSAGE to dump_file if exists and returns false. */
#define return_false_with_msg(message) \
- return_false_with_message_1 (message, __func__, __LINE__)
+ return_false_with_message_1 (message, __FILE__, __func__, __LINE__)
/* Return false and log that false value is returned. */
#define return_false() return_false_with_msg ("")
@@ -72,16 +60,19 @@ return_false_with_message_1 (const char *message, const char *func,
is location in the source file. */
static inline bool
-return_with_result (bool result, const char *func, unsigned int line)
+return_with_result (bool result, const char *filename,
+ const char *func, unsigned int line)
{
if (!result && dump_file && (dump_flags & TDF_DETAILS))
- fprintf (dump_file, " false returned: (%s:%u)\n", func, line);
+ fprintf (dump_file, " false returned: '' in %s at %s:%u\n", func,
+ filename, line);
return result;
}
/* Logs return value if RESULT is false. */
-#define return_with_debug(result) return_with_result (result, __func__, __LINE__)
+#define return_with_debug(result) return_with_result \
+ (result, __FILE__, __func__, __LINE__)
/* Verbose logging function logging statements S1 and S2 of a CODE.
FUNC is name of function and LINE is location in the source file. */
diff --git a/gcc/ipa-icf.c b/gcc/ipa-icf.c
index 19b45b35c9a..dbfd3640126 100644
--- a/gcc/ipa-icf.c
+++ b/gcc/ipa-icf.c
@@ -883,8 +883,6 @@ sem_function::equals_private (sem_item *item)
if(!m_checker->compare_bb (bb_sorted[i], m_compared_func->bb_sorted[i]))
return return_false();
- dump_message ("All BBs are equal\n");
-
auto_vec <int> bb_dict;
/* Basic block edges check. */
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] IPA ICF: enhance dump output
2019-06-04 14:39 [PATCH] IPA ICF: enhance dump output Martin Liška
@ 2019-06-05 22:12 ` Jeff Law
2019-06-07 12:41 ` IPA ICF: enhance dump about items in a non-singular class Martin Liška
0 siblings, 1 reply; 4+ messages in thread
From: Jeff Law @ 2019-06-05 22:12 UTC (permalink / raw)
To: Martin Liška, gcc-patches; +Cc: Jan Hubicka
On 6/4/19 8:38 AM, Martin Liška wrote:
> Hi.
>
> The patch is about simplification of dump output. Plus it prints
> also a file in which the dump message was emitted.
>
> Patch can bootstrap on x86_64-linux-gnu and survives regression tests.
>
> Ready to be installed?
> Thanks,
> Martin
>
> gcc/ChangeLog:
>
> 2019-06-04 Martin Liska <mliska@suse.cz>
>
> * ipa-icf-gimple.h (dump_message_1): Remove.
> (dump_message): Likewise.
> (return_false_with_message_1): Print also file.
> (return_false_with_msg): Likewise.
> (return_with_result): Likewise.
> (return_with_debug): Likewise.
> * ipa-icf.c (sem_function::equals_private): Remove call
> to dump_message.
OK.
jeff
^ permalink raw reply [flat|nested] 4+ messages in thread
* IPA ICF: enhance dump about items in a non-singular class.
2019-06-05 22:12 ` Jeff Law
@ 2019-06-07 12:41 ` Martin Liška
2019-06-07 13:01 ` Jan Hubicka
0 siblings, 1 reply; 4+ messages in thread
From: Martin Liška @ 2019-06-07 12:41 UTC (permalink / raw)
To: Jeff Law, gcc-patches; +Cc: Jan Hubicka
[-- Attachment #1: Type: text/plain, Size: 147 bytes --]
Hi.
There's one more similar patch.
Patch can bootstrap on x86_64-linux-gnu and survives regression tests.
Ready to be installed?
Thanks,
Martin
[-- Attachment #2: 0001-IPA-ICF-enhance-dump-about-items-in-a-non-singular-c.patch --]
[-- Type: text/x-patch, Size: 3782 bytes --]
From 466a951d51064a4b339b1332c1723e77e3170150 Mon Sep 17 00:00:00 2001
From: Martin Liska <mliska@suse.cz>
Date: Thu, 6 Jun 2019 14:37:45 +0200
Subject: [PATCH] IPA ICF: enhance dump about items in a non-singular class.
gcc/ChangeLog:
2019-06-06 Martin Liska <mliska@suse.cz>
* ipa-icf.c (sem_item_optimizer::parse_nonsingleton_classes):
Update coding style.
(sem_item_optimizer::dump_cong_classes):
Print how many items are in a non-singular class. Improve
coding style.
gcc/testsuite/ChangeLog:
2019-06-07 Martin Liska <mliska@suse.cz>
* gcc.dg/ipa/pr68035.c: Update scanned pattern.
---
gcc/ipa-icf.c | 34 +++++++++++++++---------------
gcc/testsuite/gcc.dg/ipa/pr68035.c | 2 +-
2 files changed, 18 insertions(+), 18 deletions(-)
diff --git a/gcc/ipa-icf.c b/gcc/ipa-icf.c
index 6307407935f..7c486eda758 100644
--- a/gcc/ipa-icf.c
+++ b/gcc/ipa-icf.c
@@ -2744,20 +2744,20 @@ sem_item_optimizer::build_graph (void)
void
sem_item_optimizer::parse_nonsingleton_classes (void)
{
- unsigned int init_called_count = 0;
+ unsigned int counter = 0;
for (unsigned i = 0; i < m_items.length (); i++)
if (m_items[i]->cls->members.length () > 1)
{
m_items[i]->init ();
- init_called_count++;
+ ++counter;
}
if (dump_file)
- fprintf (dump_file, "Init called for %u items (%.2f%%).\n",
- init_called_count,
- m_items.length () ? 100.0f * init_called_count / m_items.length ()
- : 0.0f);
+ {
+ float f = m_items.length () ? 100.0f * counter / m_items.length () : 0.0f;
+ fprintf (dump_file, "Init called for %u items (%.2f%%).\n", counter, f);
+ }
}
/* Equality function for semantic items is used to subdivide existing
@@ -3274,13 +3274,9 @@ sem_item_optimizer::dump_cong_classes (void)
if (!dump_file)
return;
- fprintf (dump_file,
- "Congruence classes: %u (unique hash values: %lu), with total: "
- "%u items\n", m_classes_count,
- (unsigned long) m_classes.elements (), m_items.length ());
-
/* Histogram calculation. */
unsigned int max_index = 0;
+ unsigned int single_element_classes = 0;
unsigned int* histogram = XCNEWVEC (unsigned int, m_items.length () + 1);
for (hash_table<congruence_class_hash>::iterator it = m_classes.begin ();
@@ -3292,21 +3288,25 @@ sem_item_optimizer::dump_cong_classes (void)
if (c > max_index)
max_index = c;
+
+ if (c == 1)
+ ++single_element_classes;
}
+ fprintf (dump_file,
+ "Congruence classes: %lu with total: %u items (in a non-singular "
+ "class: %u)\n", (unsigned long) m_classes.elements (),
+ m_items.length (), m_items.length () - single_element_classes);
fprintf (dump_file,
"Class size histogram [num of members]: number of classe number "
"of classess\n");
-
for (unsigned int i = 0; i <= max_index; i++)
if (histogram[i])
- fprintf (dump_file, "[%u]: %u classes\n", i, histogram[i]);
-
- fprintf (dump_file, "\n\n");
+ fprintf (dump_file, "%6u: %6u\n", i, histogram[i]);
if (dump_flags & TDF_DETAILS)
- for (hash_table<congruence_class_hash>::iterator it = m_classes.begin ();
- it != m_classes.end (); ++it)
+ for (hash_table<congruence_class_hash>::iterator it = m_classes.begin ();
+ it != m_classes.end (); ++it)
{
fprintf (dump_file, " group: with %u classes:\n",
(*it)->classes.length ());
diff --git a/gcc/testsuite/gcc.dg/ipa/pr68035.c b/gcc/testsuite/gcc.dg/ipa/pr68035.c
index a8cb77971f6..f6adad9f24d 100644
--- a/gcc/testsuite/gcc.dg/ipa/pr68035.c
+++ b/gcc/testsuite/gcc.dg/ipa/pr68035.c
@@ -105,4 +105,4 @@ list_49,
};
-/* { dg-final { scan-ipa-dump "unique hash values: 51" "icf" } } */
+/* { dg-final { scan-ipa-dump "Congruence classes: 51" "icf" } } */
--
2.21.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: IPA ICF: enhance dump about items in a non-singular class.
2019-06-07 12:41 ` IPA ICF: enhance dump about items in a non-singular class Martin Liška
@ 2019-06-07 13:01 ` Jan Hubicka
0 siblings, 0 replies; 4+ messages in thread
From: Jan Hubicka @ 2019-06-07 13:01 UTC (permalink / raw)
To: Martin Liška; +Cc: Jeff Law, gcc-patches
> Hi.
>
> There's one more similar patch.
> Patch can bootstrap on x86_64-linux-gnu and survives regression tests.
>
> Ready to be installed?
OK,
thanks!
Honza
> Thanks,
> Martin
> From 466a951d51064a4b339b1332c1723e77e3170150 Mon Sep 17 00:00:00 2001
> From: Martin Liska <mliska@suse.cz>
> Date: Thu, 6 Jun 2019 14:37:45 +0200
> Subject: [PATCH] IPA ICF: enhance dump about items in a non-singular class.
>
> gcc/ChangeLog:
>
> 2019-06-06 Martin Liska <mliska@suse.cz>
>
> * ipa-icf.c (sem_item_optimizer::parse_nonsingleton_classes):
> Update coding style.
> (sem_item_optimizer::dump_cong_classes):
> Print how many items are in a non-singular class. Improve
> coding style.
>
> gcc/testsuite/ChangeLog:
>
> 2019-06-07 Martin Liska <mliska@suse.cz>
>
> * gcc.dg/ipa/pr68035.c: Update scanned pattern.
> ---
> gcc/ipa-icf.c | 34 +++++++++++++++---------------
> gcc/testsuite/gcc.dg/ipa/pr68035.c | 2 +-
> 2 files changed, 18 insertions(+), 18 deletions(-)
>
> diff --git a/gcc/ipa-icf.c b/gcc/ipa-icf.c
> index 6307407935f..7c486eda758 100644
> --- a/gcc/ipa-icf.c
> +++ b/gcc/ipa-icf.c
> @@ -2744,20 +2744,20 @@ sem_item_optimizer::build_graph (void)
> void
> sem_item_optimizer::parse_nonsingleton_classes (void)
> {
> - unsigned int init_called_count = 0;
> + unsigned int counter = 0;
>
> for (unsigned i = 0; i < m_items.length (); i++)
> if (m_items[i]->cls->members.length () > 1)
> {
> m_items[i]->init ();
> - init_called_count++;
> + ++counter;
> }
>
> if (dump_file)
> - fprintf (dump_file, "Init called for %u items (%.2f%%).\n",
> - init_called_count,
> - m_items.length () ? 100.0f * init_called_count / m_items.length ()
> - : 0.0f);
> + {
> + float f = m_items.length () ? 100.0f * counter / m_items.length () : 0.0f;
> + fprintf (dump_file, "Init called for %u items (%.2f%%).\n", counter, f);
> + }
> }
>
> /* Equality function for semantic items is used to subdivide existing
> @@ -3274,13 +3274,9 @@ sem_item_optimizer::dump_cong_classes (void)
> if (!dump_file)
> return;
>
> - fprintf (dump_file,
> - "Congruence classes: %u (unique hash values: %lu), with total: "
> - "%u items\n", m_classes_count,
> - (unsigned long) m_classes.elements (), m_items.length ());
> -
> /* Histogram calculation. */
> unsigned int max_index = 0;
> + unsigned int single_element_classes = 0;
> unsigned int* histogram = XCNEWVEC (unsigned int, m_items.length () + 1);
>
> for (hash_table<congruence_class_hash>::iterator it = m_classes.begin ();
> @@ -3292,21 +3288,25 @@ sem_item_optimizer::dump_cong_classes (void)
>
> if (c > max_index)
> max_index = c;
> +
> + if (c == 1)
> + ++single_element_classes;
> }
>
> + fprintf (dump_file,
> + "Congruence classes: %lu with total: %u items (in a non-singular "
> + "class: %u)\n", (unsigned long) m_classes.elements (),
> + m_items.length (), m_items.length () - single_element_classes);
> fprintf (dump_file,
> "Class size histogram [num of members]: number of classe number "
> "of classess\n");
> -
> for (unsigned int i = 0; i <= max_index; i++)
> if (histogram[i])
> - fprintf (dump_file, "[%u]: %u classes\n", i, histogram[i]);
> -
> - fprintf (dump_file, "\n\n");
> + fprintf (dump_file, "%6u: %6u\n", i, histogram[i]);
>
> if (dump_flags & TDF_DETAILS)
> - for (hash_table<congruence_class_hash>::iterator it = m_classes.begin ();
> - it != m_classes.end (); ++it)
> + for (hash_table<congruence_class_hash>::iterator it = m_classes.begin ();
> + it != m_classes.end (); ++it)
> {
> fprintf (dump_file, " group: with %u classes:\n",
> (*it)->classes.length ());
> diff --git a/gcc/testsuite/gcc.dg/ipa/pr68035.c b/gcc/testsuite/gcc.dg/ipa/pr68035.c
> index a8cb77971f6..f6adad9f24d 100644
> --- a/gcc/testsuite/gcc.dg/ipa/pr68035.c
> +++ b/gcc/testsuite/gcc.dg/ipa/pr68035.c
> @@ -105,4 +105,4 @@ list_49,
> };
>
>
> -/* { dg-final { scan-ipa-dump "unique hash values: 51" "icf" } } */
> +/* { dg-final { scan-ipa-dump "Congruence classes: 51" "icf" } } */
> --
> 2.21.0
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-06-07 13:01 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-04 14:39 [PATCH] IPA ICF: enhance dump output Martin Liška
2019-06-05 22:12 ` Jeff Law
2019-06-07 12:41 ` IPA ICF: enhance dump about items in a non-singular class Martin Liška
2019-06-07 13:01 ` Jan Hubicka
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).