Re: [RFC] dump_varmap in tree-ssa-structalias.c

2016-03-10 Thread Richard Biener
On Thu, 10 Mar 2016, Tom de Vries wrote:

> Hi,
> 
> I wrote attached patch to print the actual contents of the varmap variable in
> tree-ssa-structalias.c.
> 
> Does it make sense to rewrite this into a dump_varmap/debug_varmap patch?

Yes (but please not dump it by default) and I'd rather have a
split-out dump_varinfo to work with when debugging.

Richard.

> Thanks,
> - Tom
> 

-- 
Richard Biener 
SUSE LINUX GmbH, GF: Felix Imendoerffer, Jane Smithard, Graham Norton, HRB 
21284 (AG Nuernberg)


[RFC] dump_varmap in tree-ssa-structalias.c

2016-03-09 Thread Tom de Vries

Hi,

I wrote attached patch to print the actual contents of the varmap 
variable in tree-ssa-structalias.c.


Does it make sense to rewrite this into a dump_varmap/debug_varmap patch?

Thanks,
- Tom
diff --git a/gcc/tree-ssa-structalias.c b/gcc/tree-ssa-structalias.c
index de12380..9d02b14 100644
--- a/gcc/tree-ssa-structalias.c
+++ b/gcc/tree-ssa-structalias.c
@@ -7486,6 +7486,84 @@ associate_varinfo_to_alias (struct cgraph_node *node, void *data)
   return false;
 }
 
+static void
+dump_varmap (FILE *file)
+{
+  if (varmap.length () > 0)
+fprintf (file, "variables:\n");
+
+  for (unsigned int i = 0; i < varmap.length (); ++i)
+{
+  varinfo_t vi = get_varinfo (i);
+  const char *sep = "";
+
+  if (vi == NULL)
+	continue;
+
+  fprintf (file, "%u: %s\n", vi->id, vi->name);
+
+  sep = " ";
+  if (vi->is_artificial_var)
+	fprintf (file, "%sartificial", sep);
+  if (vi->is_special_var)
+	fprintf (file, "%sspecial", sep);
+  if (vi->is_unknown_size_var)
+	fprintf (file, "%sunknown-size", sep);
+  if (vi->is_full_var)
+	fprintf (file, "%sfull", sep);
+  if (vi->is_heap_var)
+	fprintf (file, "%sheap", sep);
+  if (vi->may_have_pointers)
+	fprintf (file, "%smay-have-pointers", sep);
+  if (vi->only_restrict_pointers)
+	fprintf (file, "%sonly-restrict-pointers", sep);
+  if (vi->is_restrict_var)
+	fprintf (file, "%sis-restrict-var", sep);
+  if (vi->is_global_var)
+	fprintf (file, "%sglobal", sep);
+  if (vi->is_ipa_escape_point)
+	fprintf (file, "%sipa-escape-point", sep);
+  if (vi->is_fn_info)
+	fprintf (file, "%sfn-info", sep);
+  if (vi->ruid)
+	fprintf (file, "%srestrict-uid:%u", sep, vi->ruid);
+  if (vi->next)
+	fprintf (file, "%snext:%u", sep, vi->next);
+  if (vi->head != vi->id)
+	fprintf (file, "%shead:%u", sep, vi->head);
+  if (vi->offset)
+	fprintf (file, "%soffset:" HOST_WIDE_INT_PRINT_DEC, sep, vi->offset);
+  if (vi->size != ~(unsigned HOST_WIDE_INT)0)
+	fprintf (file, "%ssize:" HOST_WIDE_INT_PRINT_DEC, sep, vi->size);
+  if (vi->fullsize != ~(unsigned HOST_WIDE_INT)0
+	  && vi->fullsize != vi->size)
+	fprintf (file, "%sfullsize:" HOST_WIDE_INT_PRINT_DEC, sep, vi->fullsize);
+  fprintf (file, "\n");
+
+  if (vi->solution && !bitmap_empty_p (vi->solution))
+	{
+	  bitmap_iterator bi;
+	  unsigned i;
+	  fprintf (file, " solution: {" );
+	  EXECUTE_IF_SET_IN_BITMAP (vi->solution, 0, i, bi)
+	fprintf (file, " %u", i);
+	  fprintf (file, " }\n" );
+	}
+  if (vi->oldsolution && !bitmap_empty_p (vi->oldsolution)
+	  && !bitmap_equal_p (vi->solution, vi->oldsolution))
+	{
+	  bitmap_iterator bi;
+	  unsigned i;
+	  fprintf (file, " oldsolution: {" );
+	  EXECUTE_IF_SET_IN_BITMAP (vi->oldsolution, 0, i, bi)
+	fprintf (file, " %u", i);
+	  fprintf (file, " }\n" );
+	}
+}
+
+  fprintf (file, "\n");
+}
+
 /* Execute the driver for IPA PTA.  */
 static unsigned int
 ipa_pta_execute (void)
@@ -7654,9 +7732,15 @@ ipa_pta_execute (void)
 	}
 }
 
+  if (dump_file && (dump_flags & TDF_DETAILS))
+dump_varmap (dump_file);
+
   /* From the constraints compute the points-to sets.  */
   solve_constraints ();
 
+  if (dump_file && (dump_flags & TDF_DETAILS))
+dump_varmap (dump_file);
+
   /* Compute the global points-to sets for ESCAPED.
  ???  Note that the computed escape set is not correct
  for the whole unit as we fail to consider graph edges to