On 5/25/21 10:47 AM, Richard Biener wrote:
On Mon, May 24, 2021 at 10:02 PM Martin Sebor via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
On 5/21/21 5:39 AM, Aldy Hernandez via Gcc-patches wrote:
This patch converts the remaining users of get_range_info and
get_ptr_nonnull to the range_query API.
No effort was made to move passes away from VR_ANTI_RANGE, or any other
use of deprecated methods. This was a straight up conversion to the new
API, nothing else.
A question about the uses of the RANGE_QUERY() and GLOBAL_RANGE_QUERY()
macros (hopefully functions): some clients in this patch call one or
the other based on whether cfun is set or null, while others call it
without such testing. That suggests that the former clients might
be making the assumption that cfun is null while the latter ones
make the opposite assumption that cfun is not null. It seems that
the code would be safer/more future-proof if it avoided making
these assumptions.
That could be done by introducing a function like this one:
range_query&
get_range_query (const function *func = cfun)
{
if (func)
return func->x_range_query;
return *get_global_range_query ();
}
This function would be easier to use since clients wouldn't have
to worry about when cfun is null.
Note that IPA passes also work on specific 'fun', not 'cfun' and
that 'cfun' stands in the way of threading GCC. So please avoid
adding new references, even more so default args.
I wonder if SSA_NAME_RANGE_INFO is then obsolete? What if
"ranger" is not enabled/available - will this effectively regress things
by not exposing SSA_NAME_RANGE_INFO (which also encodes
nonzero bits & friends)?
No, SSA_NAME_RANGE_INFO is not obsolete. The default range mechanism
when enable_ranger() has not been called is global_ranges, which is just
a range_query object that uses SSA_NAME_RANGE_INFO and SSA_NAME_PTR_INFO
under the covers. See global_range_query::range_of_expr().
This patchset just provides a generic API so all things range related
use the same interface. In the future we may obsolete
SSA_NAME_RANGE_INFO, but not before we provide all the functionality it
already provides. Note that get_nonzero_bits() is currently untouched.
However, what I will remove is global access to get_ptr_nonnull() and
get_range_info(), since their only remaining user is from the
range_query object this patchset provides.
Aldy