Message ID | 7afb203c-bf08-713f-069a-44ff3d1e1a12@redhat.com |
---|---|
State | New |
Headers | show |
Series | [RFA] Don't use wi->info to pass gimple location to array warning callbacks in tree-vrp.c | expand |
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); >
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);