public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.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	[thread overview]
Message-ID: <bug-105012-4-5MrNKiCKq8@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-105012-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #19 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to anlauf from comment #18)
> Tentative patch, regtests cleanly but otherwise untested:
> 
> 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 = fsym && fsym->attr.intent == INTENT_OUT
> -                       && !fsym->attr.allocatable && !fsym->attr.pointer
> +                     gfc_symbol *dsym = fsym;
> +                     gfc_dummy_arg *dummy;
> +
> +                     /* Use associated dummy as fallback for formal
> +                        argument if there is no explicit interface.  */
> +                     if (dsym == NULL
> +                         && (dummy = arg->associated_dummy)
> +                         && dummy->intrinsicness ==
> GFC_NON_INTRINSIC_DUMMY_ARG
> +                         && dummy->u.non_intrinsic->sym)
> +                       dsym = dummy->u.non_intrinsic->sym;
> +
> +                     add_clobber = dsym && dsym->attr.intent == INTENT_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
> 
> Does this fix the remaining issue?
> 
> 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 = selected_real_kind(12) ! 8 byte real
contains
SUBROUTINE CALERF_r8(ARG, RESULT, JINT)
   integer, parameter :: rk = 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 = 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 = {CLOBBER};" } }

tough a more precise test would be to use scan-tree-dump-times "CLOBBER" 1
and scan-tree-dump "__result_derfc = {CLOBBER};".  With the bug we see

__attribute__((fn spec (". r ")))
real(kind=8) derfc (real(kind=8) & restrict x)
{
  integer(kind=4) jint;
  real(kind=8) __result_derfc;

  derfc = {CLOBBER};
  calerf_r8 ((real(kind=8) *) x, &__result_derfc, &jint);
  return __result_derfc;

and corrected there should be either

  __result_derfc = {CLOBBER};

instead or the clobber not emitted (for a missed optimization only).

  parent reply	other threads:[~2022-08-25  6:13 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-22  8:54 [Bug lto/105012] New: [12 Regression] wrf from SPECCPU2017 ICEs during LTO linking tnfchris at gcc dot gnu.org
2022-03-22  9:36 ` [Bug lto/105012] " marxin at gcc dot gnu.org
2022-03-22 10:21 ` rguenth at gcc dot gnu.org
2022-03-22 10:23 ` rguenth at gcc dot gnu.org
2022-03-22 10:37 ` marxin at gcc dot gnu.org
2022-03-22 10:52 ` rguenth at gcc dot gnu.org
2022-03-22 10:53 ` [Bug lto/105012] [12 Regression] wrf from SPECCPU2017 ICEs during LTO linking since r12-7692-g8db155ddf8cec9 marxin at gcc dot gnu.org
2022-03-22 10:58 ` marxin at gcc dot gnu.org
2022-03-22 11:06 ` [Bug fortran/105012] " rguenth at gcc dot gnu.org
2022-03-22 11:09 ` marxin at gcc dot gnu.org
2022-03-22 11:11 ` rguenth at gcc dot gnu.org
2022-03-22 11:18 ` rguenth at gcc dot gnu.org
2022-03-22 11:20 ` rguenth at gcc dot gnu.org
2022-03-22 11:31 ` rguenth at gcc dot gnu.org
2022-03-22 13:05 ` cvs-commit at gcc dot gnu.org
2022-03-22 13:07 ` rguenth at gcc dot gnu.org
2022-05-06  8:33 ` [Bug fortran/105012] [12/13 " jakub at gcc dot gnu.org
2022-08-24 19:36 ` anlauf at gcc dot gnu.org
2022-08-24 20:34 ` anlauf at gcc dot gnu.org
2022-08-25  6:13 ` rguenth at gcc dot gnu.org [this message]
2022-08-25  6:18 ` rguenth at gcc dot gnu.org
2022-08-25 19:50 ` mikael at gcc dot gnu.org
2022-08-25 19:55 ` anlauf at gcc dot gnu.org
2022-08-25 19:57 ` anlauf at gcc dot gnu.org
2022-08-25 20:06 ` mikael at gcc dot gnu.org
2022-08-25 20:30 ` anlauf at gcc dot gnu.org
2022-08-25 20:40 ` mikael at gcc dot gnu.org
2022-08-25 20:47 ` anlauf at gcc dot gnu.org
2022-08-25 21:19 ` mikael at gcc dot gnu.org
2022-08-25 21:31 ` anlauf at gcc dot gnu.org
2022-08-28 10:27 ` mikael at gcc dot gnu.org
2022-09-02 19:04 ` mikael at gcc dot gnu.org
2022-09-25 12:48 ` cvs-commit at gcc dot gnu.org
2022-09-25 12:48 ` cvs-commit at gcc dot gnu.org
2022-10-10 20:04 ` cvs-commit at gcc dot gnu.org
2022-10-10 20:53 ` cvs-commit at gcc dot gnu.org
2022-10-12 12:34 ` cvs-commit at gcc dot gnu.org
2022-10-12 12:42 ` mikael at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-105012-4-5MrNKiCKq8@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).