Hi! On 2022-03-01T17:46:20+0100, I wrote: > On 2022-01-13T10:54:16+0100, I wrote: >> On 2019-05-08T14:51:57+0100, Julian Brown wrote: >>> - The "addressable" bit is set during the kernels conversion pass for >>> variables that have "create" (alloc) clauses created for them in the >>> synthesised outer data region (instead of in the front-end, etc., >>> where it can't be done accurately). Such variables actually have >>> their address taken during transformations made in a later pass >>> (omp-low, I think), but there's a phase-ordering problem that means >>> the flag should be set earlier. >> >> The actual issue is a bit different, but yes, there is a problem. >> The related ICE has also been reported as >> "ICE in lower_omp_target, at omp-low.c:12287". (And I'm confused why we >> didn't run into that with the OpenACC 'kernels' decomposition >> originally.) I've pushed to master branch >> commit 9b32c1669aad5459dd053424f9967011348add83 >> "OpenACC 'kernels' decomposition: Mark variables used in synthesized data >> clauses as addressable [PR100280]" >> --- a/gcc/omp-oacc-kernels-decompose.cc >> +++ b/gcc/omp-oacc-kernels-decompose.cc >> @@ -793,7 +793,8 @@ make_data_region_try_statement (location_t loc, gimple *body) >> >> /* If INNER_BIND_VARS holds variables, build an OpenACC data region with >> location LOC containing BODY and having 'create (var)' clauses for each >> - variable. If INNER_CLEANUP is present, add a try-finally statement with >> + variable (as a side effect, such variables also get TREE_ADDRESSABLE set). >> + If INNER_CLEANUP is present, add a try-finally statement with >> this cleanup code in the finally block. Return the new data region, or >> the original BODY if no data region was needed. */ >> >> @@ -842,6 +843,9 @@ maybe_build_inner_data_region (location_t loc, gimple *body, >> inner_data_clauses = new_clause; >> >> prev_mapped_var = v; >> + >> + /* See . */ >> + TREE_ADDRESSABLE (v) = 1; >> } >> } > > So, that's too simple. ;-) [...] > We're after gimplification, and must not just set 'TREE_ADDRESSABLE', > because that may easily violate GIMPLE invariants, leading to ICEs later. > There are a few open PRs, which my following changes are addressing. To > make "late" 'TREE_ADDRESSABLE' work, we have a precedent in OpenMP's > 'gcc/omp-low.cc:task_shared_vars' handling, as Jakub had pointed to in > discussion of . > I'm thus proposing to generalize 'gcc/omp-low.cc:task_shared_vars' into > 'make_addressable_vars', plus new 'OMP_CLAUSE_MAP_DECL_MAKE_ADDRESSABLE' > that we then may use instead of the 'TREE_ADDRESSABLE (v) = 1;' quoted > above (plus one or two additional ones to be introduced in later > patches), and wire that up in 'gcc/omp-low.cc:scan_sharing_clauses', for > 'OMP_CLAUSE_MAP': set 'TREE_ADDRESSABLE' and put into > 'make_addressable_vars' for later fix-up. Pushed to master branch commit 8935589b496f755e08cadf26d8ceddf0dd6e0968 "OMP lowering: Regimplify 'OMP_CLAUSE_MAP_DECL_MAKE_ADDRESSABLE' DECLs [PR100280, PR104132, PR104133]", see attached. Grüße Thomas ----------------- Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955