From: Tobias Burnus <burnus@net-b.de>
To: gcc patches <gcc-patches@gcc.gnu.org>, gfortran <fortran@gcc.gnu.org>
Subject: [Patch,Fortran] PR 44945 - Fix DECL of module variables (wrong-code "regression")
Date: Fri, 16 Jul 2010 14:05:00 -0000 [thread overview]
Message-ID: <4C4066F9.80902@net-b.de> (raw)
[-- Attachment #1: Type: text/plain, Size: 1321 bytes --]
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
[-- Attachment #2: decl.diff --]
[-- Type: text/x-patch, Size: 1640 bytes --]
2010-07-16 Tobias Burnus <burnus@net-b.de>
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 <burnus@net-b.de>
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.
next reply other threads:[~2010-07-16 14:05 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-07-16 14:05 Tobias Burnus [this message]
2010-07-16 14:40 ` Paul Richard Thomas
2010-07-22 13:59 ` Tobias Burnus
2010-07-22 14:09 ` Tobias Burnus
2010-07-23 19:03 ` Paul Richard Thomas
2010-07-16 14:48 ` Jakub Jelinek
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=4C4066F9.80902@net-b.de \
--to=burnus@net-b.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).