From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30639 invoked by alias); 16 Jul 2010 14:05:20 -0000 Received: (qmail 30541 invoked by uid 22791); 16 Jul 2010 14:05:19 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE X-Spam-Check-By: sourceware.org Received: from mx01.qsc.de (HELO mx01.qsc.de) (213.148.129.14) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 16 Jul 2010 14:04:46 +0000 Received: from [192.168.178.22] (port-92-204-21-198.dynamic.qsc.de [92.204.21.198]) by mx01.qsc.de (Postfix) with ESMTP id CC8773D731; Fri, 16 Jul 2010 16:04:42 +0200 (CEST) Message-ID: <4C4066F9.80902@net-b.de> Date: Fri, 16 Jul 2010 14:05:00 -0000 From: Tobias Burnus User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.10) Gecko/20100520 SUSE/3.0.5 Thunderbird/3.0.5 MIME-Version: 1.0 To: gcc patches , gfortran Subject: [Patch,Fortran] PR 44945 - Fix DECL of module variables (wrong-code "regression") Content-Type: multipart/mixed; boundary="------------020502050909040101010007" 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: 2010-07/txt/msg01359.txt.bz2 This is a multi-part message in MIME format. --------------020502050909040101010007 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-length: 1321 gfortran can produce the multiple declarations for module variables. This causes problems when inlining is done as then the alias analysis breaks. For instance, the recent patch to the string intrinsics (marking some as PURE) "caused" gfortran.dg/char_array_structure_constructor.f90 to break with -m32 on x86_64-apple-darwin10. The patch fixes this for -fwhole-file. Does anyone know why derived types were excluded? I have now added -fwhole-file to the test case to silence the error (with this patch applied), but I think the real solution it to switch to -fwhole-file by default. Build and regtested on x86-64-linux. OK for the trunk? What about 4.5? * * * RFC: Is there any compelling reason not to switch to -fwhole-file by default? I think we have slowly reached the state when there are more bugs without that option than with that option. Advantages - Fixes some wrong-code issues - Improves diagnostic - Improves (non-LTO) optimizations - More consistent codepath: The same for default, LTO and -fwhole-program Disadvantage - Some bugs, leading to wrong code I think most wrong-code issues come apparent with -fwhole-program, which allows for more optimizations - but that option implies -fwhole-file (thus there is no change). Using -flto, one sees fewer problems as this fixes some bad DECL. Tobias --------------020502050909040101010007 Content-Type: text/x-patch; name="decl.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="decl.diff" Content-length: 1640 2010-07-16 Tobias Burnus PR fortran/44945 * trans-decl.c (gfc_get_symbol_decl): Use module decl with -fwhole-file also for derived types. 2010-07-16 Tobias Burnus PR fortran/44945 * gfortran.dg/char_array_structure_constructor.f90: Add -fwhole-file as dg-option as it otherwise fails on some systems. Index: gcc/fortran/trans-decl.c =================================================================== --- gcc/fortran/trans-decl.c (revision 162255) +++ gcc/fortran/trans-decl.c (working copy) @@ -1149,11 +1149,9 @@ gfc_get_symbol_decl (gfc_symbol * sym) return sym->backend_decl; /* If use associated and whole file compilation, use the module - declaration. This is only needed for intrinsic types because - they are substituted for one another during optimization. */ + declaration. */ if (gfc_option.flag_whole_file && sym->attr.flavor == FL_VARIABLE - && sym->ts.type != BT_DERIVED && sym->attr.use_assoc && sym->module) { Index: gcc/testsuite/gfortran.dg/char_array_structure_constructor.f90 =================================================================== --- gcc/testsuite/gfortran.dg/char_array_structure_constructor.f90 (revision 162255) +++ gcc/testsuite/gfortran.dg/char_array_structure_constructor.f90 (working copy) @@ -1,4 +1,9 @@ ! { dg-do run } +! { dg-options "-O3 -fwhole-file" } +! +! PR fortran/19107 +! -fwhole-file flag added for PR fortran/44945 +! ! This test the fix of PR19107, where character array actual ! arguments in derived type constructors caused an ICE. ! It also checks that the scalar counterparts are OK. --------------020502050909040101010007--