On Fri, Feb 10, 2023 at 1:02 AM Andrew MacLeod via Gcc-patches <gcc-patches@gcc.gnu.org> wrote: > > I was about to ping on this, and then found it in my drafts.. Doh! > > > get_range_global() can invoke tree.cc::nonnull_arg_p() if the item being > queried is a pointer and a parameter. This routine assumes the context > is CFUN, and this is not always true.
Can you share the backtrace where the context is different and cfun not NULL? I'm curious .. > This patch simply adds a function context to the get_range_global query, > and defaults it to cfun. If the context passed in is anything different > than cfun, then it simply chooses not to invoke nonnull_arg_p(). > > The check_assume function now directly calls gimple_range_global with > the correct function context instead of indirectly calling it through > the global_range_query->range_of_expr () method. Thats all it should > have been doing in the first place really since its always an ssa name. > > Bootstraps on x86_64-pc-linux-gnu with no regressions. OK for trunk? OK. Note that in the end nonnull_arg_p should get a struct function argument as well, and its flag_delete_null_pointer_checks then need to become opt_for_fn (fn->decl, flag_delete_null_pointer_checks). I'll also note that for functions with many arguments nonnull_arg_p is quite expensive and nonnull_arg_p on a PARM_DECL default-def should be reflected on its range by a pass and we shouldn't re-query this in any on-demand called function. Richard. > Andrew > >