]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Keep x_range_query NULL for global ranges.
authorAndrew MacLeod <amacleod@redhat.com>
Tue, 9 Nov 2021 14:29:23 +0000 (09:29 -0500)
committerAndrew MacLeod <amacleod@redhat.com>
Tue, 9 Nov 2021 18:27:42 +0000 (13:27 -0500)
Instead of x_range_query always pointing to an object, have it default to
NULL and return a pointer to the global query in that case.

* function.c (allocate_struct_function): Don't set x_range_query.
* function.h (get_range_query): Move to value-query.h.
* gimple-range.cc (enable_ranger): Check that query is currently NULL.
(disable_ranger): Clear function current query field.
* value-query.cc (get_global_range_query): Relocate to:
* value-query.h (get_global_range_query): Here and inline.
(get_range_query): Relocate here from function.h.

gcc/function.c
gcc/function.h
gcc/gimple-range.cc
gcc/value-query.cc
gcc/value-query.h

index af3d57b32a36785bd679ef6e35e57040c5f847ee..61b3bd036b877763133e2abdd5f6ef157085765c 100644 (file)
@@ -4873,8 +4873,6 @@ allocate_struct_function (tree fndecl, bool abstract_p)
      binding annotations among them.  */
   cfun->debug_nonbind_markers = lang_hooks.emits_begin_stmt
     && MAY_HAVE_DEBUG_MARKER_STMTS;
-
-  cfun->x_range_query = &global_ranges;
 }
 
 /* This is like allocate_struct_function, but pushes a new cfun for FNDECL
index 36003e7576a882b2d0e322bc509593dab4e0eb0f..899430833cefa8189e2179e8ad9a03490e0aea64 100644 (file)
@@ -719,15 +719,4 @@ extern const char *current_function_name (void);
 
 extern void used_types_insert (tree);
 
-/* Returns the currently active range access class.  When there is no active
-   range class, global ranges are used.  Never returns null.  */
-
-ATTRIBUTE_RETURNS_NONNULL inline range_query *
-get_range_query (const struct function *fun)
-{
-  return fun->x_range_query;
-}
-
-extern range_query *get_global_range_query ();
-
 #endif  /* GCC_FUNCTION_H */
index 87dba6e81d89c7f15745d83de485e6413367b6b9..a2b68b2bc80fa1359bc9d324da52c66c6aac8da0 100644 (file)
@@ -467,6 +467,7 @@ enable_ranger (struct function *fun)
 {
   gimple_ranger *r;
 
+  gcc_checking_assert (!fun->x_range_query);
   r = new gimple_ranger;
   fun->x_range_query = r;
 
@@ -479,7 +480,7 @@ enable_ranger (struct function *fun)
 void
 disable_ranger (struct function *fun)
 {
+  gcc_checking_assert (fun->x_range_query);
   delete fun->x_range_query;
-
-  fun->x_range_query = &global_ranges;
+  fun->x_range_query = NULL;
 }
index 17ebd86ce5f414e5f742e59eebd1d29e8527c8be..b7d9e6653b1173aca53ecef941c0533c10ec5db1 100644 (file)
@@ -435,14 +435,6 @@ gimple_range_global (tree name)
 
 global_range_query global_ranges;
 
-// Like get_range_query, but for accessing global ranges.
-
-range_query *
-get_global_range_query ()
-{
-  return &global_ranges;
-}
-
 bool
 global_range_query::range_of_expr (irange &r, tree expr, gimple *stmt)
 {
index 5161d23714b4e94f66648325f7df77a3e6b75228..38e23bb357b69586ae39dbc55760b4a94f7354ae 100644 (file)
@@ -127,6 +127,22 @@ public:
 };
 
 extern global_range_query global_ranges;
+
+inline range_query *
+get_global_range_query ()
+{
+  return &global_ranges;
+}
+
+/* Returns the currently active range access class.  When there is no active
+   range class, global ranges are used.  Never returns null.  */
+
+ATTRIBUTE_RETURNS_NONNULL inline range_query *
+get_range_query (const struct function *fun)
+{
+  return fun->x_range_query ? fun->x_range_query : &global_ranges;
+}
+
 extern value_range gimple_range_global (tree name);
 extern bool update_global_range (irange &r, tree name);