From: Thomas Koenig <tkoenig@netcologne.de>
To: "fortran@gcc.gnu.org" <fortran@gcc.gnu.org>,
gcc-patches <gcc-patches@gcc.gnu.org>
Subject: [patch, fortran] Fix PR 48352 - regression with ICE with front end optimization
Date: Thu, 31 Mar 2011 20:37:00 -0000 [thread overview]
Message-ID: <4D94E40A.2060306@netcologne.de> (raw)
[-- Attachment #1: Type: text/plain, Size: 1006 bytes --]
Hello world,
the attached patch fixes a 4.7 regression, PR 48352, where a function
elimination in the expressions for a DO loop caused an ICE. The ICE was
caused by interaction of the expression walker with insertion of a
statement for a DO loop.
Many thanks to Joost for finding the bug and reducing the test case.
To fix the regression, I have disabled this particular optimization for
expressions within the loop control.
I'd like to overhaul the way that statements are inserted during front
end optimization, later. This is needed for functions returning arrays
with bounds not known at compile-time anyway.
Regression-tested. OK for trunk?
Thomas
2011-03-31 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/48352
* frontend-passes (cfe_register_funcs): Don't
register functions if they appear as iterators in DO loops.
2011-03-31 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/48352
* gfortran.dg/function_optimize_3.f90: New test.
[-- Attachment #2: pr48352.diff --]
[-- Type: text/x-patch, Size: 519 bytes --]
Index: frontend-passes.c
===================================================================
--- frontend-passes.c (Revision 171793)
+++ frontend-passes.c (Arbeitskopie)
@@ -137,6 +137,13 @@ static int
cfe_register_funcs (gfc_expr **e, int *walk_subtrees ATTRIBUTE_UNUSED,
void *data ATTRIBUTE_UNUSED)
{
+
+ /* FIXME - there is a bug in the insertion code for DO loops. Bail
+ out here. */
+
+ if ((*current_code)->op == EXEC_DO)
+ return 0;
+
if ((*e)->expr_type != EXPR_FUNCTION)
return 0;
[-- Attachment #3: function_optimize_3.f90 --]
[-- Type: text/plain, Size: 259 bytes --]
! { dg-do compile }
! { dg-options "-O" }
! PR 48352 - variable elimination in a DO loop caused segfaults.
! Test case contributed by Joost VandeVondele
program main
INTEGER, DIMENSION(:), POINTER :: a
DO I=1,MIN(SIZE(a),SIZE(a))
ENDDO
END program main
next reply other threads:[~2011-03-31 20:29 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-31 20:37 Thomas Koenig [this message]
2011-04-01 0:41 ` Jerry DeLisle
2011-04-01 19:38 ` Thomas Koenig
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=4D94E40A.2060306@netcologne.de \
--to=tkoenig@netcologne.de \
--cc=fortran@gcc.gnu.org \
--cc=gcc-patches@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).