From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 557B23858C33; Thu, 25 Aug 2022 06:13:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 557B23858C33 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1661408000; bh=Z4GEQjzyQuyvwWXUdPh7PdscKmMP5C49vrkIX/+ty+U=; h=From:To:Subject:Date:In-Reply-To:References:From; b=YlO6uOTWTVlTxeMMzXL2/fnAsMFTl8ZQo5+CN5mSYsfZXW3IvAZ7d/wiGcLSIuOJO Qpbp9bPH2nBWCvpIuUIz3Ow1K06pCQgcA9OA03SvD6zJrTpRlx6QKiwsfd37AAGQEv 68eNok3lQSzGpHhRVy5ocx2a76EPplL/ucRqnFLs= From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/105012] [12/13 Regression] wrf from SPECCPU2017 ICEs during LTO linking since r12-7692-g8db155ddf8cec9 Date: Thu, 25 Aug 2022 06:13:19 +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 X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P4 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 12.3 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D105012 --- Comment #19 from Richard Biener --- (In reply to anlauf from comment #18) > Tentative patch, regtests cleanly but otherwise untested: >=20 > diff --git a/gcc/fortran/trans-expr.cc b/gcc/fortran/trans-expr.cc > index 850007fd2e1..0a1520e95ba 100644 > --- a/gcc/fortran/trans-expr.cc > +++ b/gcc/fortran/trans-expr.cc > @@ -6503,8 +6503,19 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * > sym, > else > { > bool add_clobber; > - add_clobber =3D fsym && fsym->attr.intent =3D=3D IN= TENT_OUT > - && !fsym->attr.allocatable && !fsym->attr.pointer > + gfc_symbol *dsym =3D fsym; > + gfc_dummy_arg *dummy; > + > + /* Use associated dummy as fallback for formal > + argument if there is no explicit interface. */ > + if (dsym =3D=3D NULL > + && (dummy =3D arg->associated_dummy) > + && dummy->intrinsicness =3D=3D > GFC_NON_INTRINSIC_DUMMY_ARG > + && dummy->u.non_intrinsic->sym) > + dsym =3D dummy->u.non_intrinsic->sym; > + > + add_clobber =3D dsym && dsym->attr.intent =3D=3D IN= TENT_OUT > + && !dsym->attr.allocatable && !dsym->attr.pointer > && e->symtree && e->symtree->n.sym > && !e->symtree->n.sym->attr.dimension > && !e->symtree->n.sym->attr.pointer >=20 > Does this fix the remaining issue? >=20 > What is the best way to write a testcase that checks that the clobber is > inserted properly? For the testcase in comment#8 you could do ! { dg-do compile } ! { dg-options "-fdump-tree-original" } module error_function integer, parameter :: r8 =3D selected_real_kind(12) ! 8 byte real contains SUBROUTINE CALERF_r8(ARG, RESULT, JINT) integer, parameter :: rk =3D r8 real(rk), intent(in) :: arg real(rk), intent(out) :: result IF (Y .LE. THRESH) THEN END IF end SUBROUTINE CALERF_r8 FUNCTION DERFC(X) integer, parameter :: rk =3D r8 ! 8 byte real real(rk), intent(in) :: X real(rk) :: DERFC CALL CALERF_r8(X, DERFC, JINT) END FUNCTION DERFC end module error_function ! { dg-final { scan-tree-dump-not "derfc =3D {CLOBBER};" } } tough a more precise test would be to use scan-tree-dump-times "CLOBBER" 1 and scan-tree-dump "__result_derfc =3D {CLOBBER};". With the bug we see __attribute__((fn spec (". r "))) real(kind=3D8) derfc (real(kind=3D8) & restrict x) { integer(kind=3D4) jint; real(kind=3D8) __result_derfc; derfc =3D {CLOBBER}; calerf_r8 ((real(kind=3D8) *) x, &__result_derfc, &jint); return __result_derfc; and corrected there should be either __result_derfc =3D {CLOBBER}; instead or the clobber not emitted (for a missed optimization only).=