On Wed, Jul 31, 2024 at 1:21 PM Tobias Burnus <tbur...@baylibre.com> wrote: > > Hi Richard, hi all, > > Richard Biener wrote: > > Looking at pass_omp_target_link::execute I wonder iff find_link_var_op > shouldn't simply do the substitution? Aka > > This seems to work ... > > --- a/gcc/omp-offload.cc > +++ b/gcc/omp-offload.cc > @@ -2893,6 +2893,7 @@ find_link_var_op (tree *tp, int *walk_subtrees, void *) > && is_global_var (t) > && lookup_attribute ("omp declare target link", DECL_ATTRIBUTES (t))) > { > + *tp = unshare_expr (DECL_VALUE_EXPR (t)); > *walk_subtrees = 0; > return t; > } > > which then makes the stmt obviously not gimple? > > ... except that 'return t' prevents updating other value-expr in the same > stmt, but that can be fixed. > > Updated patch attached.
You can pass a walk_stmt_info wi; wi->data = NULL; to walk_gimple_stmt and set wi->data instead of using a global variable (or make wi->data point to a local variable for some more indirection). OK as-is or with cleanup as suggested above. Thanks, Richard. > Thanks for the suggestion! > > Tobias