* [Bug fortran/48352] [4.7 Regression] segfault in fortran/frontend-passes.c
2011-03-30 6:54 [Bug fortran/48352] New: [4.7 Regression] segfault in fortran/frontend-passes.c Joost.VandeVondele at pci dot uzh.ch
@ 2011-03-30 7:59 ` burnus at gcc dot gnu.org
2011-03-30 21:06 ` tkoenig at gcc dot gnu.org
` (9 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: burnus at gcc dot gnu.org @ 2011-03-30 7:59 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48352
Tobias Burnus <burnus at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |ice-on-valid-code
CC| |burnus at gcc dot gnu.org,
| |tkoenig at gcc dot gnu.org
Target Milestone|--- |4.7.0
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug fortran/48352] [4.7 Regression] segfault in fortran/frontend-passes.c
2011-03-30 6:54 [Bug fortran/48352] New: [4.7 Regression] segfault in fortran/frontend-passes.c Joost.VandeVondele at pci dot uzh.ch
2011-03-30 7:59 ` [Bug fortran/48352] " burnus at gcc dot gnu.org
@ 2011-03-30 21:06 ` tkoenig at gcc dot gnu.org
2011-03-31 7:26 ` jvdelisle at gcc dot gnu.org
` (8 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: tkoenig at gcc dot gnu.org @ 2011-03-30 21:06 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48352
Thomas Koenig <tkoenig at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2011.03.30 20:43:03
Ever Confirmed|0 |1
--- Comment #1 from Thomas Koenig <tkoenig at gcc dot gnu.org> 2011-03-30 20:43:03 UTC ---
Really strange.
gdb shows
Program received signal SIGSEGV, Segmentation fault.
gfc_expr_walker (e=0x18, exprfn=0x597fc0 <cfe_expr_0>, data=0x0)
at ../../trunk/gcc/fortran/frontend-passes.c:752
752 while (*e)
(gdb) up
#1 0x00000000005984ec in gfc_code_walker (c=0x1452b30, codefn=0x597330
<cfe_code>,
exprfn=0x597fc0 <cfe_expr_0>, data=0x0) at
../../trunk/gcc/fortran/frontend-passes.c:1050
1050 WALK_SUBEXPR ((*c)->ext.omp_clauses->chunk_size);
(gdb) p (*c)->op
$1 = EXEC_ASSIGN
(gdb) p (*c)->ext.omp_clauses
$2 = (gfc_omp_clauses *) 0x0
Why are we in the section dealing with OMP stuff when handling an EXEC_ASSIGN?
We should not get there at all.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug fortran/48352] [4.7 Regression] segfault in fortran/frontend-passes.c
2011-03-30 6:54 [Bug fortran/48352] New: [4.7 Regression] segfault in fortran/frontend-passes.c Joost.VandeVondele at pci dot uzh.ch
2011-03-30 7:59 ` [Bug fortran/48352] " burnus at gcc dot gnu.org
2011-03-30 21:06 ` tkoenig at gcc dot gnu.org
@ 2011-03-31 7:26 ` jvdelisle at gcc dot gnu.org
2011-03-31 13:05 ` jvdelisle at gcc dot gnu.org
` (7 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: jvdelisle at gcc dot gnu.org @ 2011-03-31 7:26 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48352
Jerry DeLisle <jvdelisle at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jvdelisle at gcc dot
| |gnu.org
--- Comment #2 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> 2011-03-31 04:56:02 UTC ---
This fixes it.
Index: gcc/fortran/frontend-passes.c
===================================================================
--- gcc/fortran/frontend-passes.c (revision 171769)
+++ gcc/fortran/frontend-passes.c (working copy)
@@ -334,6 +334,8 @@ cfe_code (gfc_code **c, int *walk_subtrees ATTRIBU
static void
optimize_namespace (gfc_namespace *ns)
{
+ if (!ns->code)
+ return;
current_ns = ns;
Regression tested.
trim_optimize_2.f90 fails but I do not know if this is because the patterns are
changed or this patch is just disabling the optimizations.
Also moving the check down a little bit still works, as follows.
Index: gcc/fortran/frontend-passes.c
===================================================================
--- gcc/fortran/frontend-passes.c (revision 171769)
+++ gcc/fortran/frontend-passes.c (working copy)
@@ -334,11 +334,14 @@ cfe_code (gfc_code **c, int *walk_subtrees ATTRIBU
static void
optimize_namespace (gfc_namespace *ns)
{
-
current_ns = ns;
gfc_code_walker (&ns->code, cfe_code, cfe_expr_0, NULL);
+
gfc_code_walker (&ns->code, optimize_code, optimize_expr, NULL);
+
+ if (!ns->code)
+ return;
for (ns = ns->contained; ns; ns = ns->sibling)
optimize_namespace (ns);
I think somewhere while walking the code, the code pointer is getting bashed or
for this test case, it really is null.
Hope this at least gives some hints.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug fortran/48352] [4.7 Regression] segfault in fortran/frontend-passes.c
2011-03-30 6:54 [Bug fortran/48352] New: [4.7 Regression] segfault in fortran/frontend-passes.c Joost.VandeVondele at pci dot uzh.ch
` (2 preceding siblings ...)
2011-03-31 7:26 ` jvdelisle at gcc dot gnu.org
@ 2011-03-31 13:05 ` jvdelisle at gcc dot gnu.org
2011-03-31 13:32 ` burnus at gcc dot gnu.org
` (6 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: jvdelisle at gcc dot gnu.org @ 2011-03-31 13:05 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48352
--- Comment #3 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> 2011-03-31 12:54:26 UTC ---
The regression is caused by r171207.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug fortran/48352] [4.7 Regression] segfault in fortran/frontend-passes.c
2011-03-30 6:54 [Bug fortran/48352] New: [4.7 Regression] segfault in fortran/frontend-passes.c Joost.VandeVondele at pci dot uzh.ch
` (3 preceding siblings ...)
2011-03-31 13:05 ` jvdelisle at gcc dot gnu.org
@ 2011-03-31 13:32 ` burnus at gcc dot gnu.org
2011-03-31 13:50 ` Joost.VandeVondele at pci dot uzh.ch
` (5 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: burnus at gcc dot gnu.org @ 2011-03-31 13:32 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48352
--- Comment #4 from Tobias Burnus <burnus at gcc dot gnu.org> 2011-03-31 13:05:29 UTC ---
(In reply to comment #3)
> The regression is caused by r171207.
That's http://gcc.gnu.org/ml/gcc-cvs/2011-03/msg00630.html
Author: tkoenig
Date: Mon Mar 21 07:14:42 2011
New Revision: 171207
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=171207
Log:
2010-03-21 Thomas Koenig
PR fortran/22572
[...]
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug fortran/48352] [4.7 Regression] segfault in fortran/frontend-passes.c
2011-03-30 6:54 [Bug fortran/48352] New: [4.7 Regression] segfault in fortran/frontend-passes.c Joost.VandeVondele at pci dot uzh.ch
` (4 preceding siblings ...)
2011-03-31 13:32 ` burnus at gcc dot gnu.org
@ 2011-03-31 13:50 ` Joost.VandeVondele at pci dot uzh.ch
2011-03-31 15:26 ` jvdelisle at gcc dot gnu.org
` (4 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Joost.VandeVondele at pci dot uzh.ch @ 2011-03-31 13:50 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48352
--- Comment #5 from Joost VandeVondele <Joost.VandeVondele at pci dot uzh.ch> 2011-03-31 13:25:27 UTC ---
reduced:
INTEGER, DIMENSION(:), POINTER :: a
DO I=1,MIN(SIZE(a),SIZE(a))
ENDDO
END
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug fortran/48352] [4.7 Regression] segfault in fortran/frontend-passes.c
2011-03-30 6:54 [Bug fortran/48352] New: [4.7 Regression] segfault in fortran/frontend-passes.c Joost.VandeVondele at pci dot uzh.ch
` (5 preceding siblings ...)
2011-03-31 13:50 ` Joost.VandeVondele at pci dot uzh.ch
@ 2011-03-31 15:26 ` jvdelisle at gcc dot gnu.org
2011-03-31 18:53 ` tkoenig at gcc dot gnu.org
` (3 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: jvdelisle at gcc dot gnu.org @ 2011-03-31 15:26 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48352
--- Comment #6 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> 2011-03-31 15:01:31 UTC ---
I am a little suspicious of this:
static int count_arglist;
+/* Pointer to an array of gfc_expr ** we operate on, plus its size
+ and counter. */
+
+static gfc_expr ***expr_array;
+static int expr_size, expr_count;
It could be getting walked on or optimized away by the optimizers. Is there
another way to do this that is less indirect or relies less on static.
Just seems too tricky. I do not have time to go further with this.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug fortran/48352] [4.7 Regression] segfault in fortran/frontend-passes.c
2011-03-30 6:54 [Bug fortran/48352] New: [4.7 Regression] segfault in fortran/frontend-passes.c Joost.VandeVondele at pci dot uzh.ch
` (6 preceding siblings ...)
2011-03-31 15:26 ` jvdelisle at gcc dot gnu.org
@ 2011-03-31 18:53 ` tkoenig at gcc dot gnu.org
2011-04-01 6:18 ` Joost.VandeVondele at pci dot uzh.ch
` (2 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: tkoenig at gcc dot gnu.org @ 2011-03-31 18:53 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48352
Thomas Koenig <tkoenig at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
AssignedTo|unassigned at gcc dot |tkoenig at gcc dot gnu.org
|gnu.org |
--- Comment #7 from Thomas Koenig <tkoenig at gcc dot gnu.org> 2011-03-31 18:31:22 UTC ---
(In reply to comment #5)
> reduced:
>
> INTEGER, DIMENSION(:), POINTER :: a
> DO I=1,MIN(SIZE(a),SIZE(a))
> ENDDO
> END
Thanks, Joost.
Slightly more reduced test case (from the point of
stepping through the code):
interface
pure integer function f()
end function f
end interface
DO I=1,min(f(),f())
ENDDO
END
Somehow, the insertion of the statement with the extra variable doesn't
work for DO loops.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug fortran/48352] [4.7 Regression] segfault in fortran/frontend-passes.c
2011-03-30 6:54 [Bug fortran/48352] New: [4.7 Regression] segfault in fortran/frontend-passes.c Joost.VandeVondele at pci dot uzh.ch
` (7 preceding siblings ...)
2011-03-31 18:53 ` tkoenig at gcc dot gnu.org
@ 2011-04-01 6:18 ` Joost.VandeVondele at pci dot uzh.ch
2011-04-01 19:31 ` tkoenig at gcc dot gnu.org
2011-04-01 19:32 ` tkoenig at gcc dot gnu.org
10 siblings, 0 replies; 12+ messages in thread
From: Joost.VandeVondele at pci dot uzh.ch @ 2011-04-01 6:18 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48352
--- Comment #8 from Joost VandeVondele <Joost.VandeVondele at pci dot uzh.ch> 2011-04-01 06:17:51 UTC ---
BTW, from this experience, it would be great to have the frontend optimizations
being protected by a switch (-f(no-)frontend-optimizations or similar) which
can default to true at -O1 and higher.
First, this would provide an easy workaround for this kind of bugs.
Second, this would make sense in combination with LTO, where in principle one
could compile in the first pass with -O0, and only at link time with -Ox (this
makes sense from a compile time point of view). However, for this to generate
good code, the first pass should be -O0 -ffrontend-optimizations, otherwise the
middle end would have no chance.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug fortran/48352] [4.7 Regression] segfault in fortran/frontend-passes.c
2011-03-30 6:54 [Bug fortran/48352] New: [4.7 Regression] segfault in fortran/frontend-passes.c Joost.VandeVondele at pci dot uzh.ch
` (8 preceding siblings ...)
2011-04-01 6:18 ` Joost.VandeVondele at pci dot uzh.ch
@ 2011-04-01 19:31 ` tkoenig at gcc dot gnu.org
2011-04-01 19:32 ` tkoenig at gcc dot gnu.org
10 siblings, 0 replies; 12+ messages in thread
From: tkoenig at gcc dot gnu.org @ 2011-04-01 19:31 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48352
--- Comment #9 from Thomas Koenig <tkoenig at gcc dot gnu.org> 2011-04-01 19:31:27 UTC ---
Author: tkoenig
Date: Fri Apr 1 19:31:23 2011
New Revision: 171849
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=171849
Log:
2011-04-01 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-04-01 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/48352
* gfortran.dg/function_optimize_3.f90: New test.
Added:
trunk/gcc/testsuite/gfortran.dg/function_optimize_3.f90
Modified:
trunk/gcc/fortran/ChangeLog
trunk/gcc/fortran/frontend-passes.c
trunk/gcc/testsuite/ChangeLog
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug fortran/48352] [4.7 Regression] segfault in fortran/frontend-passes.c
2011-03-30 6:54 [Bug fortran/48352] New: [4.7 Regression] segfault in fortran/frontend-passes.c Joost.VandeVondele at pci dot uzh.ch
` (9 preceding siblings ...)
2011-04-01 19:31 ` tkoenig at gcc dot gnu.org
@ 2011-04-01 19:32 ` tkoenig at gcc dot gnu.org
10 siblings, 0 replies; 12+ messages in thread
From: tkoenig at gcc dot gnu.org @ 2011-04-01 19:32 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48352
Thomas Koenig <tkoenig at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
--- Comment #10 from Thomas Koenig <tkoenig at gcc dot gnu.org> 2011-04-01 19:32:35 UTC ---
Fixed, closing.
^ permalink raw reply [flat|nested] 12+ messages in thread