On Fri, Feb 16, 2024 at 04:15:05PM +0100, Tobias Burnus wrote: > I have no idea whether that would - nor whether that would be > the way forward. - Thoughts?
Don't have time to dive through this now in detail, just want to point out why we ignore DECL_VALUE_EXPR on the magic var during gimplification for the parallel case - gimplify_var_or_parm_decl has /* When within an OMP context, notice uses of variables. */ if (gimplify_omp_ctxp && omp_notice_variable (gimplify_omp_ctxp, decl, true)) return GS_ALL_DONE; /* If the decl is an alias for another expression, substitute it now. */ if (DECL_HAS_VALUE_EXPR_P (decl)) { *expr_p = unshare_expr (DECL_VALUE_EXPR (decl)); return GS_OK; } return GS_ALL_DONE; and the trick is to make sure omp_notice_variable returns true if it is undesirable to expand the DECL_VALUE_EXPR of decl at that point. And whether omp_notice_variable returns true or false depends on lang_hooks.decls.omp_disregard_value_expr langhook. And that one has if (VAR_P (decl) && DECL_HAS_VALUE_EXPR_P (decl) && DECL_ARTIFICIAL (decl) && DECL_LANG_SPECIFIC (decl) && DECL_OMP_PRIVATIZED_MEMBER (decl)) return true; to deal with this. Jakub