From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 10D3F385702E; Mon, 29 Mar 2021 16:08:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 10D3F385702E From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/99816] fortran do loop line table issue Date: Mon, 29 Mar 2021 16:08:16 +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: 11.0 X-Bugzilla-Keywords: wrong-debug X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: keywords cf_reconfirmed_on everconfirmed bug_status 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: Mon, 29 Mar 2021 16:08:17 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D99816 Richard Biener changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |wrong-debug Last reconfirmed| |2021-03-29 Ever confirmed|0 |1 Status|UNCONFIRMED |NEW --- Comment #1 from Richard Biener --- The IL from the frontend is (with line numbers): __attribute__((fn spec (". w w "))) void sub (real(kind=3D4)[0:D.3943] * restrict a, integer(kind=3D4) & restri= ct n) [t.f90:1:16] { integer(kind=3D8) ubound.0; integer(kind=3D8) size.1; integer(kind=3D4) i; integer(kind=3D8) D.3943; bitsizetype D.3944; sizetype D.3945; [t.f90:1:18] ubound.0 =3D [t.f90:1:18] (integer(kind=3D8)) [t.f90:1:18] *= n; [t.f90:1:18] size.1 =3D [t.f90:1:18] NON_LVALUE_EXPR ; [t.f90:1:18] size.1 =3D [t.f90:1:18] MAX_EXPR ; [t.f90:1:18] D.3943 =3D [t.f90:1:16] size.1 + -1; [t.f90:1:18] D.3944 =3D (bitsizetype) (sizetype) NON_LVALUE_EXPR = * 32; [t.f90:1:18] D.3945 =3D (sizetype) NON_LVALUE_EXPR * 4; [t.f90:3:22] { integer(kind=3D4) D.3938; [t.f90:3:22] D.3938 =3D [t.f90:3:22] *n; [t.f90:3:17] i =3D 1; [t.f90:3:17] while (1) { [t.f90:5:34] { logical(kind=3D4) D.3941; [t.f90:3:17] D.3941 =3D [t.f90:3:17] i > D.3938; [t.f90:3:17] if (D.3941) [t.f90:3:17] goto L.2; [t.f90:4:15] [t.f90:4:15] ([t.f90:4:15] *a)[[t.f90:4:15] (integer(kind=3D8)) i + -1] =3D (real(kind=3D4)) i; [t.f90:4:15] __label_000100:; [t.f90:5:34] L.1:; [t.f90:3:17] i =3D [t.f90:3:17] i + 1; } } [t.f90:5:34] L.2:; } [t.f90:6:13] return; } where we have two labels / empty stmts with line number 5, one inside and one outside of the loop. Note the actual "continue" is the end of the while loop. gimplification turns this into [t.f90:3:22] { integer(kind=3D4) D.3938; [t.f90:3:22] D.3938 =3D [t.f90:3:22] *n; [t.f90:3:17] i =3D 1; : [t.f90:5:34] { logical(kind=3D4) D.3941; [t.f90:3:17] D.3941 =3D i > D.3938; [t.f90:3:17] if (D.3941 !=3D 0) goto L.2; else goto ; : [t.f90:4:15] _5 =3D (integer(kind=3D8)) i; [t.f90:4:15] _6 =3D _5 + -1; [t.f90:4:15] _7 =3D (real(kind=3D4)) i; [t.f90:4:15] [t.f90:4:15] [t.f90:4:15] (*a)[_6] =3D _7; [t.f90:4:15] __label_000100: [t.f90:5:34] L.1: [t.f90:3:17] i =3D i + 1; } [t.f90:3:17] goto ; [t.f90:5:34] L.2: } note how the while (1) backwards jump gets line number 3. How the Fortran frontend uses LOOP_EXPR but does control flow by itself makes it difficult to deal with this.=