From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 5A59C3858429; Thu, 10 Mar 2022 15:13:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5A59C3858429 From: "burnus at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/104696] [OpenMP] Implicit mapping breaks struct mapping Date: Thu, 10 Mar 2022 15:13:18 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: missed-optimization, openmp, wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: burnus at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 12.0 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Mar 2022 15:13:18 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D104696 --- Comment #4 from Tobias Burnus --- (In reply to Chung-Lin Tang from comment #3) > The problem, at a low-level, is that the Fortran FE is using always_point= er, > while C/C++ front-ends generate attach_detach (and turns in attach after > gimplify). Actually, if one modifies the C testcase, as alluded in previous comment 2,= one runs into the same issue. Namely, for: ------------ test.c-------------- struct s { int d; }; struct s2 { struct s r[5], q, arr[1024][1024]; }; int main () { struct s2 x; #pragma omp target map(tofrom: x.q.d) x.q.d =3D 2; #pragma omp target map(tofrom: x.r[1].d) *.r[1].d =3D 3; __builtin_printf("%d, %d\n", x.q.d, x.r[1].d); return 0; } ------------ test.c-------------- The expect result is 'struct: x' + 'tofrom: x.r[1].d' - and as 'struct:x' exists, no implicit mapping of 'x' happens. That happens for 'x.q.d': map(struct:x [len: 1]) map(tofrom:x.q.d [len: 4]) but not for 'x.r[1].d': map(tofrom:x [len: 4194328][implicit]) map(tofrom:x.r[1].d [len: 4]) Thus the code which constructs 'struct: x' has trouble for 'component ref + array ref + component ref'.=