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

            Bug ID: 128176
           Summary: [14/15/16/17 Regression] Fortran multi-level mapping
                    with pointer attachment
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Keywords: openmp, wrong-code
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: burnus at gcc dot gnu.org
                CC: sandra at gcc dot gnu.org
  Target Milestone: ---

Created attachment 65964
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=65964&action=edit
test case, compile with -fopenmp and look at the dump and/or run with
offloading enabled

The program was working with GCC 13 but since GCC 14, there are two issues:

* The FE no longer maps ‘map(to:*n->p) but only ‘alloc’s space for the pointer
'p' in n%p
* The ME changes the ‘map(to: *n)’ to ‘map(alloc: *n)’

Kudos to Sandra for finding this issue.

* * *

Regarding the first issue:

For 'map(to:n), map(to:n%p), map(to:n%p%p)', the original dump is (since GCC
14):

- map(to:*n) map(alloc:n [pointer assign, bias: 0])  (looks ok)
- map(alloc:n->p [len: 8])  (okay but as '*n' is mapped should be a noop)
- (missing: map(to *n->p [len: 16]))
- map(to:*n->p->p [len: 16]) map(attach_detach:n->p->p [bias: 0])  (looks OK)

Note that this regressed between gfortran-13 and gfortran-14 (same as
mainline); GCC 13's original dump was:

- map(to:*n) map(alloc:n [pointer assign, bias: 0]) (same)
- map(to:*n->p [len: 16]) map(always_pointer:n->p [pointer assign, bias: 0])
(here ok, wrong in GCC 14+)
- map(to:*n->p->p [len: 16]) map(always_pointer:n->p->p [pointer assign, bias:
0]) (ok; ptr attach way changed in GCC 13→14)

* * *

When lowering the current (gcc 14 to gcc 17 mainline) code, the FE issue
obviously remains - but a new issue shows up. Namely, -fdump-tree-gimple code
is:

The gimple lowering turns the mainline version into:

- map(struct:*n->p [len: 1]) map(alloc:n->p [len: 8]) This one is wrong
- map(to:*n->p->p [len: 16])  This is fine, attachment happens in (4)
- map(alloc:*n [len: 16]) map(alloc:n [pointer assign, bias: 0])  This one maps
all of 'n', which looks fine – except that '*n' is only 'alloc' and no longer
'to' !
- map(attach: n->p->p [bias: 0]) map(attach: n->p [bias: 0]) looks fine

Namely, the map type in the third map clause changed from 'to' to 'alloc'!

Reply via email to