diff options
author | Andrew MacLeod <amacleod@redhat.com> | 2023-02-06 13:07:01 -0500 |
---|---|---|
committer | Andrew MacLeod <amacleod@redhat.com> | 2023-02-10 09:46:33 -0500 |
commit | 99f3ad2e5b117ee79a6dcf97288261e2fa32ab4c (patch) | |
tree | 831646b70330811f9ed4355be0e3316c7eab73fd /gcc/value-query.cc | |
parent | edfc4402504fd512ba469219e2ed637f2921a1c2 (diff) | |
download | gcc-99f3ad2e5b117ee79a6dcf97288261e2fa32ab4c.zip gcc-99f3ad2e5b117ee79a6dcf97288261e2fa32ab4c.tar.gz gcc-99f3ad2e5b117ee79a6dcf97288261e2fa32ab4c.tar.bz2 |
Add function context for querying global ranges.
When processing arguments for assume functions, call get_global_range
directly and utilize a function context pointer to avoid any assumptions
about using cfun.
PR tree-optimization/108520
gcc/
* gimple-range-infer.cc (check_assume_func): Invoke
gimple_range_global directly instead using global_range_query.
* value-query.cc (get_range_global): Add function context and
avoid calling nonnull_arg_p if not cfun.
(gimple_range_global): Add function context pointer.
* value-query.h (imple_range_global): Add function context.
gcc/testsuite/
* g++.dg/pr108520.C: New.
Diffstat (limited to 'gcc/value-query.cc')
-rw-r--r-- | gcc/value-query.cc | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/gcc/value-query.cc b/gcc/value-query.cc index 5345bb4..f936e87 100644 --- a/gcc/value-query.cc +++ b/gcc/value-query.cc @@ -312,7 +312,7 @@ get_ssa_name_ptr_info_nonnull (const_tree name) // return VARYING. static void -get_range_global (vrange &r, tree name) +get_range_global (vrange &r, tree name, struct function *fun = cfun) { tree type = TREE_TYPE (name); @@ -327,7 +327,7 @@ get_range_global (vrange &r, tree name) // anti-ranges for pointers. Note that this is only valid with // default definitions of PARM_DECLs. if (POINTER_TYPE_P (type) - && ((cfun && nonnull_arg_p (sym)) + && ((cfun && fun == cfun && nonnull_arg_p (sym)) || get_ssa_name_ptr_info_nonnull (name))) r.set_nonzero (type); else if (!POINTER_TYPE_P (type)) @@ -378,15 +378,15 @@ get_range_global (vrange &r, tree name) // https://gcc.gnu.org/pipermail/gcc-patches/2021-June/571709.html void -gimple_range_global (vrange &r, tree name) +gimple_range_global (vrange &r, tree name, struct function *fun) { tree type = TREE_TYPE (name); gcc_checking_assert (TREE_CODE (name) == SSA_NAME); - if (SSA_NAME_IS_DEFAULT_DEF (name) || (cfun && cfun->after_inlining) + if (SSA_NAME_IS_DEFAULT_DEF (name) || (fun && fun->after_inlining) || is_a<gphi *> (SSA_NAME_DEF_STMT (name))) { - get_range_global (r, name); + get_range_global (r, name, fun); return; } r.set_varying (type); |