* [RFA][PATCH] Don't use wi->info to pass gimple location to array warning callbacks in tree-vrp.c
@ 2017-10-25 18:45 Jeff Law
2017-10-26 9:34 ` Richard Biener
0 siblings, 1 reply; 2+ messages in thread
From: Jeff Law @ 2017-10-25 18:45 UTC (permalink / raw)
To: gcc-patches
[-- Attachment #1: Type: text/plain, Size: 1072 bytes --]
The array dereference warnings in tree-vrp.c use the gimple walkers to
dig down into gimple statements looking for array accesses. I wasn't
keen to convert all the clients of the gimple walkers to C++ classes at
this time.
And the gimple walkers have a mechanism by which we could pass around a
class instance -- they've got an opaque pointer (wi->info).
THe pointer is already in use to hold a gimple location. So I initially
thought I'd have to instead have it point to a structure that would hold
the gimple location and a class instance.
However, we can get to the gimple location via other means -- we can
just extract it from the gimple statement which is a first class entity
within the wi structure. That's all this patch does.
That frees up the opaque pointer and in a future patch I can just shove
the vr_values class instance into it.
Bootstrapped and regression tested on x86_64.
OK for the trunk?
Jeff
ps. Now to figure out a strategy for vrp_valueize, which are the last
callbacks that need fixing to allow encapsulation of the vr_values bits.
[-- Attachment #2: P3 --]
[-- Type: text/plain, Size: 867 bytes --]
* tree-vrp.c (check_all_array_refs): Do not use wi->info to smuggle
gimple statement locations.
(check_array_bounds): Corresponding changes. Get the statement's
location directly from wi->stmt.
diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c
index 2bc485c..9defbce 100644
--- a/gcc/tree-vrp.c
+++ b/gcc/tree-vrp.c
@@ -6837,10 +6837,7 @@ check_array_bounds (tree *tp, int *walk_subtree, void *data)
if (EXPR_HAS_LOCATION (t))
location = EXPR_LOCATION (t);
else
- {
- location_t *locp = (location_t *) wi->info;
- location = *locp;
- }
+ location = gimple_location (wi->stmt);
*walk_subtree = TRUE;
@@ -6887,9 +6884,6 @@ check_all_array_refs (void)
memset (&wi, 0, sizeof (wi));
- location_t loc = gimple_location (stmt);
- wi.info = &loc;
-
walk_gimple_op (gsi_stmt (si),
check_array_bounds,
&wi);
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [RFA][PATCH] Don't use wi->info to pass gimple location to array warning callbacks in tree-vrp.c
2017-10-25 18:45 [RFA][PATCH] Don't use wi->info to pass gimple location to array warning callbacks in tree-vrp.c Jeff Law
@ 2017-10-26 9:34 ` Richard Biener
0 siblings, 0 replies; 2+ messages in thread
From: Richard Biener @ 2017-10-26 9:34 UTC (permalink / raw)
To: Jeff Law; +Cc: gcc-patches
On Wed, Oct 25, 2017 at 7:30 PM, Jeff Law <law@redhat.com> wrote:
>
> The array dereference warnings in tree-vrp.c use the gimple walkers to
> dig down into gimple statements looking for array accesses. I wasn't
> keen to convert all the clients of the gimple walkers to C++ classes at
> this time.
>
> And the gimple walkers have a mechanism by which we could pass around a
> class instance -- they've got an opaque pointer (wi->info).
>
> THe pointer is already in use to hold a gimple location. So I initially
> thought I'd have to instead have it point to a structure that would hold
> the gimple location and a class instance.
>
> However, we can get to the gimple location via other means -- we can
> just extract it from the gimple statement which is a first class entity
> within the wi structure. That's all this patch does.
>
>
> That frees up the opaque pointer and in a future patch I can just shove
> the vr_values class instance into it.
>
> Bootstrapped and regression tested on x86_64.
>
> OK for the trunk?
OK. The user probably was introduced before the stmt field in
walk_stmt_info.
Thanks,
Richard.
> Jeff
>
> ps. Now to figure out a strategy for vrp_valueize, which are the last
> callbacks that need fixing to allow encapsulation of the vr_values bits.
>
>
> * tree-vrp.c (check_all_array_refs): Do not use wi->info to smuggle
> gimple statement locations.
> (check_array_bounds): Corresponding changes. Get the statement's
> location directly from wi->stmt.
>
>
> diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c
> index 2bc485c..9defbce 100644
> --- a/gcc/tree-vrp.c
> +++ b/gcc/tree-vrp.c
> @@ -6837,10 +6837,7 @@ check_array_bounds (tree *tp, int *walk_subtree, void *data)
> if (EXPR_HAS_LOCATION (t))
> location = EXPR_LOCATION (t);
> else
> - {
> - location_t *locp = (location_t *) wi->info;
> - location = *locp;
> - }
> + location = gimple_location (wi->stmt);
>
> *walk_subtree = TRUE;
>
> @@ -6887,9 +6884,6 @@ check_all_array_refs (void)
>
> memset (&wi, 0, sizeof (wi));
>
> - location_t loc = gimple_location (stmt);
> - wi.info = &loc;
> -
> walk_gimple_op (gsi_stmt (si),
> check_array_bounds,
> &wi);
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-10-26 9:29 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-25 18:45 [RFA][PATCH] Don't use wi->info to pass gimple location to array warning callbacks in tree-vrp.c Jeff Law
2017-10-26 9:34 ` Richard Biener
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).