From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24469 invoked by alias); 31 Mar 2011 20:29:08 -0000 Received: (qmail 24455 invoked by uid 22791); 31 Mar 2011 20:29:07 -0000 X-SWARE-Spam-Status: No, hits=-1.6 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from cc-smtpout1.netcologne.de (HELO cc-smtpout1.netcologne.de) (89.1.8.211) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 31 Mar 2011 20:29:02 +0000 Received: from cc-smtpin1.netcologne.de (cc-smtpin1.netcologne.de [89.1.8.201]) by cc-smtpout1.netcologne.de (Postfix) with ESMTP id A2445121A0; Thu, 31 Mar 2011 22:29:00 +0200 (CEST) Received: from [192.168.0.197] (xdsl-87-79-195-86.netcologne.de [87.79.195.86]) by cc-smtpin1.netcologne.de (Postfix) with ESMTPSA id 8B44B11E8B; Thu, 31 Mar 2011 22:28:59 +0200 (CEST) Message-ID: <4D94E40A.2060306@netcologne.de> Date: Thu, 31 Mar 2011 20:37:00 -0000 From: Thomas Koenig User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; de; rv:1.9.2.14) Gecko/20110221 SUSE/3.1.8 Thunderbird/3.1.8 MIME-Version: 1.0 To: "fortran@gcc.gnu.org" , gcc-patches Subject: [patch, fortran] Fix PR 48352 - regression with ICE with front end optimization Content-Type: multipart/mixed; boundary="------------010301020708060109010406" Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2011-03/txt/msg02279.txt.bz2 This is a multi-part message in MIME format. --------------010301020708060109010406 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit Content-length: 1006 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 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 PR fortran/48352 * gfortran.dg/function_optimize_3.f90: New test. --------------010301020708060109010406 Content-Type: text/x-patch; name="pr48352.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="pr48352.diff" Content-length: 519 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; --------------010301020708060109010406 Content-Type: text/plain; name="function_optimize_3.f90" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="function_optimize_3.f90" Content-length: 259 ! { 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 --------------010301020708060109010406--