aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAldy Hernandez <aldyh@redhat.com>2019-11-25 10:55:26 +0000
committerAldy Hernandez <aldyh@redhat.com>2019-11-25 10:55:26 +0000
commitfe4f19722b8db0ef902f156cb5a85f3db534329b (patch)
tree131f64842e8982b74eb0ae75fd415453607099ed
parent89adad43a3e8dc57b60af7bda9a074ed7304ff4b (diff)
Gather statistics on how many sub-ranges are used in widest_irangeranger
throughout the compilation unit. git-svn-id: https://gcc.gnu.org/svn/gcc/branches/ranger@278677 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/toplev.c1
-rw-r--r--gcc/value-range.cc35
-rw-r--r--gcc/value-range.h8
3 files changed, 44 insertions, 0 deletions
diff --git a/gcc/toplev.c b/gcc/toplev.c
index d4583bac66c..cb335e97e3f 100644
--- a/gcc/toplev.c
+++ b/gcc/toplev.c
@@ -2112,6 +2112,7 @@ dump_memory_report (const char *header)
dump_ggc_loc_statistics ();
dump_alias_stats (stderr);
dump_pta_stats (stderr);
+ dump_value_range_stats (stderr);
}
/* Clean up: close opened files, etc. */
diff --git a/gcc/value-range.cc b/gcc/value-range.cc
index e6abf639511..e99b68a2c45 100644
--- a/gcc/value-range.cc
+++ b/gcc/value-range.cc
@@ -256,6 +256,8 @@ widest_irange::widest_irange (const irange &other)
widest_irange::~widest_irange ()
{
+ if (CHECKING_P)
+ stats_register_use ();
if (m_blob)
free (m_blob);
}
@@ -309,6 +311,39 @@ widest_irange::invert ()
resize_if_needed (size);
irange::invert ();
}
+
+int widest_irange::stats_used_buckets[11];
+
+void
+widest_irange::stats_register_use (void)
+{
+ int n = num_pairs ();
+ if (n < 10)
+ stats_used_buckets[n]++;
+ else
+ stats_used_buckets[10]++;
+}
+
+void
+widest_irange::stats_dump (FILE *file)
+{
+ fprintf (file, "\nwidest_irange stats:\n");
+ for (int i = 0; i < 11; ++i)
+ {
+ if (stats_used_buckets[i] == 0)
+ continue;
+ if (i < 10)
+ fprintf (file, "%2d sub-ranges: %d\n", i, stats_used_buckets[i]);
+ else
+ fprintf (file, "10+ sub-ranges: %d\n", stats_used_buckets[i]);
+ }
+}
+
+void
+dump_value_range_stats (FILE *file)
+{
+ widest_irange::stats_dump (file);
+}
void
vrange::set_undefined ()
diff --git a/gcc/value-range.h b/gcc/value-range.h
index 8d0d796c3b6..8cc71b16005 100644
--- a/gcc/value-range.h
+++ b/gcc/value-range.h
@@ -180,11 +180,18 @@ public:
virtual void union_ (const vrange &);
virtual void invert ();
+#if CHECKING_P
+ static void stats_dump (FILE *);
+#endif
private:
static const unsigned m_sub_ranges_in_local_storage = 5;
void init_widest_irange ();
void resize_if_needed (unsigned);
+ // Memory usage stats.
+ void stats_register_use (void);
+ static int stats_used_buckets[11];
+
tree *m_blob;
tree m_ranges[m_sub_ranges_in_local_storage*2];
};
@@ -197,6 +204,7 @@ extern bool range_has_numeric_bounds_p (const irange *);
extern bool ranges_from_anti_range (const value_range *,
value_range *, value_range *);
extern void dump_value_range (FILE *, const vrange *);
+extern void dump_value_range_stats (FILE *);
extern bool vrp_val_is_min (const_tree);
extern bool vrp_val_is_max (const_tree);
extern tree vrp_val_min (const_tree);