From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 5DBDB3858423; Tue, 14 Dec 2021 18:34:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5DBDB3858423 From: "hubicka at kam dot mff.cuni.cz" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/103662] TBAA problem in Fortran FE triggering in gfortran.dg/unlimited_polymorphic_3.f03 Date: Tue, 14 Dec 2021 18:34:20 +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: alias X-Bugzilla-Severity: normal X-Bugzilla-Who: hubicka at kam dot mff.cuni.cz 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: --- 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: Tue, 14 Dec 2021 18:34:20 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D103662 --- Comment #4 from hubicka at kam dot mff.cuni.cz --- > Can you explain in simple words why adding >=20 > if (ptr1%k .ne. 42) print * >=20 > before the line >=20 > if (ptr1%k .ne. 42) STOP 2 >=20 > makes the test succeed, but adding it after that one the test fails? > Or adding >=20 > print *, ptr1%k >=20 > near the end of subroutine foo? I am not sure why it depends whether it is before or after the stop. Perhaps we thread the conditionals and optimize out print in some cases? However the reason why print matters is because print call confuses the simplistic escape analysis done in modref. It now understand the fact that calling an unknown function where all arguments are constant is safe and can not make function local parameters escaped. However it punt on calling anything with parameter. Before the patch the same testcase fails if you replace STOP 2 by anything that terminate program w/o calling function. For example by division by zero. I have patch to use PTA escape analysis in modref but it hits other problem with fortran FE and openMP - GOMP_parallel makes parameters escape even if Fortran FE produces fnspec delcaring them nonescape...=