https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102330

--- Comment #9 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
If you need to mark some var as addressable during omp lowering, then you need
to treat it similarly to the task shared case, so during scan phase of that
pass
do something like:
              /* Taking address of OUTER in lower_send_shared_vars
                 might need regimplification of everything that uses the
                 variable.  */
              if (!task_shared_vars)
                task_shared_vars = BITMAP_ALLOC (NULL);
              bitmap_set_bit (task_shared_vars, DECL_UID (outer));
              TREE_ADDRESSABLE (outer) = 1;
which will then make sure that the lowering phase of the pass will try to
regimplify all statements refering to such vars.  Note, this should be only
done if the var isn't already TREE_ADDRESSABLE.

We then do:

static tree
lower_omp_regimplify_p (tree *tp, int *walk_subtrees,
                        void *data)
{
  tree t = *tp;

...

  if (task_shared_vars
      && DECL_P (t)
      && bitmap_bit_p (task_shared_vars, DECL_UID (t)))
    return t;

Whether you can use the same bitmap or need to add another bitmap next to
task_shared_vars is something hard to guess without diving into it deeply.

Reply via email to