On 11/13/18 3:12 AM, Richard Biener wrote:
On Mon, Nov 12, 2018 at 10:50 AM Aldy Hernandez <al...@redhat.com> wrote:
I have rebased my value_range dumping patch after your value_range_base
changes.
I know you are not a fan of the gimple-pretty-print.c chunk, but I still
think having one set of dumping code is preferable to catering to
possible GC corruption while debugging. If you're strongly opposed (as,
I'm putting my foot down), I can remove it as well as the relevant
pretty_printer stuff.
I'd say we do not want to change the gimple-pretty-print.c stuff also because
we'll miss the leading #. I'd rather see a simple wide-int-range class
wrapping the interesting bits up. I guess I'll come up with one then ;)
Ok. Removed.
The patch looks bigger than it is because I moved all the dump routines
into one place.
OK?
p.s. After your changes, perhaps get_range_info(const_tree, value_range
&) should take a value_range_base instead?
Yes, I missed that and am now testing this change.
Thanks.
Btw, the patch needs updating again (sorry). If you leave out the
gimple-pretty-print.c stuff there's no requirement to use the pretty-printer
API, right?
No need to apologize for contributing code :). Thanks. And yes,
there's no need for the pretty-printer bits.
I've also removed the value_range*::dump() versions with no arguments,
as now we have an overloaded debug() for use from the debugger.
Testing attached patch.
Aldy
gcc/
* tree-vrp.c (value_range_base::dump): Dump type.
Do not use INF nomenclature for 1-bit types.
(dump_value_range): Group all variants to common dumping code.
(debug): New overloaded functions for value_ranges.
(value_range_base::dump): Remove no argument version.
(value_range::dump): Same.
gcc/testsuite/
* gcc.dg/tree-ssa/pr64130.c: Adjust for new value_range pretty
printer.
* gcc.dg/tree-ssa/vrp92.c: Same.
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr64130.c b/gcc/testsuite/gcc.dg/tree-ssa/pr64130.c
index e068765e2fc..28ffbb76da8 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/pr64130.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr64130.c
@@ -15,6 +15,6 @@ int funsigned2 (uint32_t a)
return (-1 * 0x1ffffffffL) / a == 0;
}
-/* { dg-final { scan-tree-dump ": \\\[2, 8589934591\\\]" "evrp" } } */
-/* { dg-final { scan-tree-dump ": \\\[-8589934591, -2\\\]" "evrp" } } */
+/* { dg-final { scan-tree-dump "int \\\[2, 8589934591\\\]" "evrp" } } */
+/* { dg-final { scan-tree-dump "int \\\[-8589934591, -2\\\]" "evrp" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/vrp92.c b/gcc/testsuite/gcc.dg/tree-ssa/vrp92.c
index 5a2dbf0108a..66d74e9b5e9 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/vrp92.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/vrp92.c
@@ -18,5 +18,5 @@ int foo (int i, int j)
return j;
}
-/* { dg-final { scan-tree-dump "res_.: \\\[1, 1\\\]" "vrp1" } } */
+/* { dg-final { scan-tree-dump "res_.: int \\\[1, 1\\\]" "vrp1" } } */
/* { dg-final { scan-tree-dump-not "Threaded" "vrp1" } } */
diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c
index 27bc1769f11..f498386e8eb 100644
--- a/gcc/tree-vrp.c
+++ b/gcc/tree-vrp.c
@@ -365,8 +365,6 @@ value_range_base::type () const
return TREE_TYPE (min ());
}
-/* Dump value range to FILE. */
-
void
value_range_base::dump (FILE *file) const
{
@@ -374,21 +372,26 @@ value_range_base::dump (FILE *file) const
fprintf (file, "UNDEFINED");
else if (m_kind == VR_RANGE || m_kind == VR_ANTI_RANGE)
{
- tree type = TREE_TYPE (min ());
+ tree ttype = type ();
+
+ print_generic_expr (file, ttype);
+ fprintf (file, " ");
fprintf (file, "%s[", (m_kind == VR_ANTI_RANGE) ? "~" : "");
- if (INTEGRAL_TYPE_P (type)
- && !TYPE_UNSIGNED (type)
- && vrp_val_is_min (min ()))
+ if (INTEGRAL_TYPE_P (ttype)
+ && !TYPE_UNSIGNED (ttype)
+ && vrp_val_is_min (min ())
+ && TYPE_PRECISION (ttype) != 1)
fprintf (file, "-INF");
else
print_generic_expr (file, min ());
fprintf (file, ", ");
- if (INTEGRAL_TYPE_P (type)
- && vrp_val_is_max (max ()))
+ if (INTEGRAL_TYPE_P (ttype)
+ && vrp_val_is_max (max ())
+ && TYPE_PRECISION (ttype) != 1)
fprintf (file, "+INF");
else
print_generic_expr (file, max ());
@@ -398,7 +401,7 @@ value_range_base::dump (FILE *file) const
else if (varying_p ())
fprintf (file, "VARYING");
else
- fprintf (file, "INVALID RANGE");
+ gcc_unreachable ();
}
void
@@ -425,17 +428,45 @@ value_range::dump (FILE *file) const
}
void
-value_range_base::dump () const
+dump_value_range (FILE *file, const value_range *vr)
{
- dump_value_range (stderr, this);
- fprintf (stderr, "\n");
+ if (!vr)
+ fprintf (file, "[]");
+ else
+ vr->dump (file);
}
void
-value_range::dump () const
+dump_value_range (FILE *file, const value_range_base *vr)
+{
+ if (!vr)
+ fprintf (file, "[]");
+ else
+ vr->dump (file);
+}
+
+DEBUG_FUNCTION void
+debug (const value_range_base *vr)
+{
+ dump_value_range (stderr, vr);
+}
+
+DEBUG_FUNCTION void
+debug (const value_range_base &vr)
+{
+ dump_value_range (stderr, &vr);
+}
+
+DEBUG_FUNCTION void
+debug (const value_range *vr)
+{
+ dump_value_range (stderr, vr);
+}
+
+DEBUG_FUNCTION void
+debug (const value_range &vr)
{
- dump_value_range (stderr, this);
- fprintf (stderr, "\n");
+ dump_value_range (stderr, &vr);
}
/* Return true if the SSA name NAME is live on the edge E. */
@@ -2165,43 +2196,6 @@ extract_range_from_unary_expr (value_range_base *vr,
return;
}
-/* Debugging dumps. */
-
-void
-dump_value_range (FILE *file, const value_range *vr)
-{
- if (!vr)
- fprintf (file, "[]");
- else
- vr->dump (file);
-}
-
-void
-dump_value_range (FILE *file, const value_range_base *vr)
-{
- if (!vr)
- fprintf (file, "[]");
- else
- vr->dump (file);
-}
-
-/* Dump value range VR to stderr. */
-
-DEBUG_FUNCTION void
-debug_value_range (const value_range_base *vr)
-{
- dump_value_range (stderr, vr);
-}
-
-/* Dump value range VR to stderr. */
-
-DEBUG_FUNCTION void
-debug_value_range (const value_range *vr)
-{
- dump_value_range (stderr, vr);
-}
-
-
/* Given a COND_EXPR COND of the form 'V OP W', and an SSA name V,
create a new SSA name N and return the assertion assignment
'N = ASSERT_EXPR <V, V OP W>'. */
diff --git a/gcc/tree-vrp.h b/gcc/tree-vrp.h
index 348fa4f0e7b..287860399c4 100644
--- a/gcc/tree-vrp.h
+++ b/gcc/tree-vrp.h
@@ -71,9 +71,7 @@ public:
void set_and_canonicalize (enum value_range_kind, tree, tree);
bool zero_p () const;
bool singleton_p (tree *result = NULL) const;
-
void dump (FILE *) const;
- void dump () const;
protected:
void check ();
@@ -139,7 +137,6 @@ class GTY((user)) value_range : public value_range_base
void deep_copy (const value_range *);
void set_and_canonicalize (enum value_range_kind, tree, tree, bitmap = NULL);
void dump (FILE *) const;
- void dump () const;
private:
/* Deep-copies bitmap argument. */