diff mbox series

[COMMITTED] Replace ad-hoc value_range dumpers with irange::dump.

Message ID 20230426114752.336928-2-aldyh@redhat.com
State New
Headers show
Series [COMMITTED] Replace ad-hoc value_range dumpers with irange::dump. | expand

Commit Message

Aldy Hernandez April 26, 2023, 11:47 a.m. UTC
This causes a regression in gcc.c-torture/unsorted/dump-noaddr.c.

The test is asserting that two dumps are identical, but they are not
because irange dumps the type which varies between runs:

               <          VR  [irange] void (*<T3dc>) (int) [1, +INF]
               >          VR  [irange] void (*<T3da>) (int) [1, +INF]

I have changed the pretty printer for irange types to pass TDF_NOUID,
thus avoiding this problem.

gcc/ChangeLog:

	* ipa-prop.cc (ipa_print_node_jump_functions_for_edge): Use
	vrange::dump instead of ad-hoc dumper.
	* tree-ssa-strlen.cc (dump_strlen_info): Same.
	* value-range-pretty-print.cc (visit): Pass TDF_NOUID to
	dump_generic_node.
---
 gcc/ipa-prop.cc                 |  9 ++------
 gcc/tree-ssa-strlen.cc          | 40 +++++----------------------------
 gcc/value-range-pretty-print.cc |  2 +-
 3 files changed, 9 insertions(+), 42 deletions(-)
diff mbox series

Patch

diff --git a/gcc/ipa-prop.cc b/gcc/ipa-prop.cc
index 1a8ff7ebb95..c6d4585aed1 100644
--- a/gcc/ipa-prop.cc
+++ b/gcc/ipa-prop.cc
@@ -437,13 +437,8 @@  ipa_print_node_jump_functions_for_edge (FILE *f, struct cgraph_edge *cs)
 
       if (jump_func->m_vr)
 	{
-	  fprintf (f, "         VR  ");
-	  fprintf (f, "%s[",
-		   (jump_func->m_vr->kind () == VR_ANTI_RANGE) ? "~" : "");
-	  print_decs (wi::to_wide (jump_func->m_vr->min ()), f);
-	  fprintf (f, ", ");
-	  print_decs (wi::to_wide (jump_func->m_vr->max ()), f);
-	  fprintf (f, "]\n");
+	  jump_func->m_vr->dump (f);
+	  fprintf (f, "\n");
 	}
       else
 	fprintf (f, "         Unknown VR\n");
diff --git a/gcc/tree-ssa-strlen.cc b/gcc/tree-ssa-strlen.cc
index 1d79034594b..dcc9e9e14ab 100644
--- a/gcc/tree-ssa-strlen.cc
+++ b/gcc/tree-ssa-strlen.cc
@@ -981,42 +981,14 @@  dump_strlen_info (FILE *fp, gimple *stmt, range_query *rvals)
 		  print_generic_expr (fp, si->nonzero_chars);
 		  if (TREE_CODE (si->nonzero_chars) == SSA_NAME)
 		    {
-		      value_range_kind rng = VR_UNDEFINED;
-		      wide_int min, max;
+		      value_range vr;
 		      if (rvals)
-			{
-			  value_range vr;
-			  rvals->range_of_expr (vr, si->nonzero_chars,
-						si->stmt);
-			  rng = vr.kind ();
-			  if (range_int_cst_p (&vr))
-			    {
-			      min = wi::to_wide (vr.min ());
-			      max = wi::to_wide (vr.max ());
-			    }
-			  else
-			    rng = VR_UNDEFINED;
-			}
+			rvals->range_of_expr (vr, si->nonzero_chars,
+					      si->stmt);
 		      else
-			{
-			  value_range vr;
-			  get_range_query (cfun)
-			    ->range_of_expr (vr, si->nonzero_chars);
-			  rng = vr.kind ();
-			  if (!vr.undefined_p ())
-			    {
-			      min = wi::to_wide (vr.min ());
-			      max = wi::to_wide (vr.max ());
-			    }
-			}
-
-		      if (rng == VR_RANGE || rng == VR_ANTI_RANGE)
-			{
-			  fprintf (fp, " %s[%llu, %llu]",
-				   rng == VR_RANGE ? "" : "~",
-				   (long long) min.to_uhwi (),
-				   (long long) max.to_uhwi ());
-			}
+			get_range_query (cfun)->range_of_expr (vr,
+							si->nonzero_chars);
+		      vr.dump (fp);
 		    }
 		}
 
diff --git a/gcc/value-range-pretty-print.cc b/gcc/value-range-pretty-print.cc
index a11c5a621f8..8d47d8087e8 100644
--- a/gcc/value-range-pretty-print.cc
+++ b/gcc/value-range-pretty-print.cc
@@ -56,7 +56,7 @@  vrange_printer::visit (const irange &r) const
       pp_string (pp, "UNDEFINED");
       return;
     }
-  dump_generic_node (pp, r.type (), 0, TDF_NONE, false);
+  dump_generic_node (pp, r.type (), 0, TDF_NONE | TDF_NOUID, false);
   pp_character (pp, ' ');
   if (r.varying_p ())
     {