Fix some improper debug dump in clone materialization

Message ID BYAPR01MB461688302896E162D1BE0324F78A0@BYAPR01MB4616.prod.exchangelabs.com
State New
Headers show
Series
  • Fix some improper debug dump in clone materialization
Related show

Commit Message

Kees Cook via Gcc-patches June 1, 2020, 9:08 a.m.
Clone materialization might produce some improper debug output as:

Original--

cloning foo/271 to foo.constprop/334
   replace map: 0 -> xxx1->yyy
    m_always_copy_start: 1
    IPA adjusted parameters: foo (...)
{
...
}

And a better output could be:

cloning foo/271 to foo.constprop/334
    replace map: 0 -> xxx, 1->yyy         /* separate 1 with xxx,  */
    m_always_copy_start: 1                   /* Align with replace map */
    IPA adjusted parameters:                /* If no adjusted parameter, start a new line or omit this line */
foo (...)
{
...
}

Feng
---
2020-06-01  Feng Xue  <fxue@os.amperecomputing.com>

gcc/
	* cgraphclones.c (materialize_all_clones): Adjust replace map dump.
	* ipa-param-manipulation.c (ipa_dump_adjusted_parameters): Do not
	dump infomation if there is no adjusted parameter.
	* (ipa_param_adjustments::dump): Adjust prefix spaces for dump string.
---
 gcc/cgraphclones.c           | 6 +++---
 gcc/ipa-param-manipulation.c | 5 ++++-
 2 files changed, 7 insertions(+), 4 deletions(-)

--

Comments

Martin Jambor June 1, 2020, 11:22 a.m. | #1
Hi Feng,

On Mon, Jun 01 2020, Feng Xue OS wrote:
> Clone materialization might produce some improper debug output as:

>

> Original--

>

> cloning foo/271 to foo.constprop/334

>    replace map: 0 -> xxx1->yyy

>     m_always_copy_start: 1

>     IPA adjusted parameters: foo (...)

> {

> ...

> }

>

> And a better output could be:

>

> cloning foo/271 to foo.constprop/334

>     replace map: 0 -> xxx, 1->yyy         /* separate 1 with xxx,  */

>     m_always_copy_start: 1                   /* Align with replace map */

>     IPA adjusted parameters:                /* If no adjusted parameter, start a new line or omit this line */

> foo (...)

> {

> ...

> }

>

> Feng

> ---

> 2020-06-01  Feng Xue  <fxue@os.amperecomputing.com>

>

> gcc/

> 	* cgraphclones.c (materialize_all_clones): Adjust replace map dump.

> 	* ipa-param-manipulation.c (ipa_dump_adjusted_parameters): Do not

> 	dump infomation if there is no adjusted parameter.

> 	* (ipa_param_adjustments::dump): Adjust prefix spaces for dump string.


This is OK, thank you.

Martin

Patch

diff --git a/gcc/cgraphclones.c b/gcc/cgraphclones.c
index e4f1c1d4b5e..db61c218297 100644
--- a/gcc/cgraphclones.c
+++ b/gcc/cgraphclones.c
@@ -1160,15 +1160,15 @@  symbol_table::materialize_all_clones (void)
 		      if (node->clone.tree_map)
 		        {
 			  unsigned int i;
-			  fprintf (symtab->dump_file, "   replace map: ");
+			  fprintf (symtab->dump_file, "    replace map:");
 			  for (i = 0;
 			       i < vec_safe_length (node->clone.tree_map);
 			       i++)
 			    {
 			      ipa_replace_map *replace_info;
 			      replace_info = (*node->clone.tree_map)[i];
-			      fprintf (symtab->dump_file, "%i -> ",
-				       (*node->clone.tree_map)[i]->parm_num);
+			      fprintf (symtab->dump_file, "%s %i -> ",
+				       i ? "," : "", replace_info->parm_num);
 			      print_generic_expr (symtab->dump_file,
 						  replace_info->new_tree);
 			    }
diff --git a/gcc/ipa-param-manipulation.c b/gcc/ipa-param-manipulation.c
index 978916057f0..2cc4bc79dc1 100644
--- a/gcc/ipa-param-manipulation.c
+++ b/gcc/ipa-param-manipulation.c
@@ -111,6 +111,9 @@  ipa_dump_adjusted_parameters (FILE *f,
   unsigned i, len = vec_safe_length (adj_params);
   bool first = true;
 
+  if (!len)
+    return;
+
   fprintf (f, "    IPA adjusted parameters: ");
   for (i = 0; i < len; i++)
     {
@@ -899,7 +902,7 @@  ipa_param_adjustments::dump (FILE *f)
   fprintf (f, "    m_always_copy_start: %i\n", m_always_copy_start);
   ipa_dump_adjusted_parameters (f, m_adj_params);
   if (m_skip_return)
-    fprintf (f, "     Will SKIP return.\n");
+    fprintf (f, "    Will SKIP return.\n");
 }
 
 /* Dump information contained in the object in textual form to stderr.  */