Bug 17675 - [Regression w.r.t. g77] Alignment constraints not honored in EQUIVALENCE
Summary: [Regression w.r.t. g77] Alignment constraints not honored in EQUIVALENCE
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.0.0
: P2 critical
Target Milestone: 4.0.0
Assignee: Paul Brook
URL:
Keywords: patch, wrong-code
: 19338 (view as bug list)
Depends on:
Blocks: 18977 19292
  Show dependency treegraph
 
Reported: 2004-09-26 06:46 UTC by Eric Botcazou
Modified: 2005-01-16 23:21 UTC (History)
4 users (show)

See Also:
Host:
Target: sparc*-*-*, ia64-*-*, alpha*-*-*
Build:
Known to work:
Known to fail:
Last reconfirmed: 2005-01-04 22:48:21


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Eric Botcazou 2004-09-26 06:46:44 UTC
We have many execution failures on SPARC for the 980628-* series of testcases:

FAIL: gfortran.dg/g77/980628-0.f  -O1  execution test
FAIL: gfortran.dg/g77/980628-0.f  -O2  execution test
FAIL: gfortran.dg/g77/980628-0.f  -O3 -fomit-frame-pointer  execution test
FAIL: gfortran.dg/g77/980628-0.f  -O3 -fomit-frame-pointer -funroll-loops 
execution test
FAIL: gfortran.dg/g77/980628-0.f  -O3 -fomit-frame-pointer -funroll-all-loops
-finline-functions  execution test
FAIL: gfortran.dg/g77/980628-0.f  -O3 -g  execution test
FAIL: gfortran.dg/g77/980628-0.f  -Os  execution test
FAIL: gfortran.dg/g77/980628-1.f  -O1  execution test
FAIL: gfortran.dg/g77/980628-1.f  -O2  execution test
FAIL: gfortran.dg/g77/980628-1.f  -O3 -fomit-frame-pointer  execution test
FAIL: gfortran.dg/g77/980628-1.f  -O3 -fomit-frame-pointer -funroll-loops 
execution test
FAIL: gfortran.dg/g77/980628-1.f  -O3 -fomit-frame-pointer -funroll-all-loops
-finline-functions  execution test
FAIL: gfortran.dg/g77/980628-1.f  -O3 -g  execution test
FAIL: gfortran.dg/g77/980628-1.f  -Os  execution test
FAIL: gfortran.dg/g77/980628-10.f  -O0  execution test
FAIL: gfortran.dg/g77/980628-10.f  -O1  execution test
FAIL: gfortran.dg/g77/980628-10.f  -O2  execution test
FAIL: gfortran.dg/g77/980628-10.f  -O3 -fomit-frame-pointer  execution test
FAIL: gfortran.dg/g77/980628-10.f  -O3 -fomit-frame-pointer -funroll-loops 
execution test
FAIL: gfortran.dg/g77/980628-10.f  -O3 -fomit-frame-pointer -funroll-all-loops
-finline-functions  execution test
FAIL: gfortran.dg/g77/980628-10.f  -O3 -g  execution test
FAIL: gfortran.dg/g77/980628-10.f  -Os  execution test
FAIL: gfortran.dg/g77/980628-2.f  -O0  execution test
FAIL: gfortran.dg/g77/980628-2.f  -O1  execution test
FAIL: gfortran.dg/g77/980628-2.f  -O2  execution test
FAIL: gfortran.dg/g77/980628-2.f  -O3 -fomit-frame-pointer  execution test
FAIL: gfortran.dg/g77/980628-2.f  -O3 -fomit-frame-pointer -funroll-loops 
execution test
FAIL: gfortran.dg/g77/980628-2.f  -O3 -fomit-frame-pointer -funroll-all-loops
-finline-functions  execution test
FAIL: gfortran.dg/g77/980628-2.f  -O3 -g  execution test
FAIL: gfortran.dg/g77/980628-2.f  -Os  execution test
FAIL: gfortran.dg/g77/980628-3.f  -O0  execution test
FAIL: gfortran.dg/g77/980628-3.f  -O1  execution test
FAIL: gfortran.dg/g77/980628-3.f  -O2  execution test
FAIL: gfortran.dg/g77/980628-3.f  -O3 -fomit-frame-pointer  execution test
FAIL: gfortran.dg/g77/980628-3.f  -O3 -fomit-frame-pointer -funroll-loops 
execution test
FAIL: gfortran.dg/g77/980628-3.f  -O3 -fomit-frame-pointer -funroll-all-loops
-finline-functions  execution test
FAIL: gfortran.dg/g77/980628-3.f  -O3 -g  execution test
FAIL: gfortran.dg/g77/980628-3.f  -Os  execution test
FAIL: gfortran.dg/g77/980628-7.f  -O1  execution test
FAIL: gfortran.dg/g77/980628-7.f  -O2  execution test
FAIL: gfortran.dg/g77/980628-7.f  -O3 -fomit-frame-pointer  execution test
FAIL: gfortran.dg/g77/980628-7.f  -O3 -fomit-frame-pointer -funroll-loops 
execution test
FAIL: gfortran.dg/g77/980628-7.f  -O3 -fomit-frame-pointer -funroll-all-loops
-finline-functions  execution test
FAIL: gfortran.dg/g77/980628-7.f  -O3 -g  execution test
FAIL: gfortran.dg/g77/980628-7.f  -Os  execution test
FAIL: gfortran.dg/g77/980628-8.f  -O1  execution test
FAIL: gfortran.dg/g77/980628-8.f  -O2  execution test
FAIL: gfortran.dg/g77/980628-8.f  -O3 -fomit-frame-pointer  execution test
FAIL: gfortran.dg/g77/980628-8.f  -O3 -fomit-frame-pointer -funroll-loops 
execution test
FAIL: gfortran.dg/g77/980628-8.f  -O3 -fomit-frame-pointer -funroll-all-loops
-finline-functions  execution test
FAIL: gfortran.dg/g77/980628-8.f  -O3 -g  execution test
FAIL: gfortran.dg/g77/980628-8.f  -Os  execution test
FAIL: gfortran.dg/g77/980628-9.f  -O0  execution test
FAIL: gfortran.dg/g77/980628-9.f  -O1  execution test
FAIL: gfortran.dg/g77/980628-9.f  -O2  execution test
FAIL: gfortran.dg/g77/980628-9.f  -O3 -fomit-frame-pointer  execution test
FAIL: gfortran.dg/g77/980628-9.f  -O3 -fomit-frame-pointer -funroll-loops 
execution test
FAIL: gfortran.dg/g77/980628-9.f  -O3 -fomit-frame-pointer -funroll-all-loops
-finline-functions  execution test
FAIL: gfortran.dg/g77/980628-9.f  -O3 -g  execution test
FAIL: gfortran.dg/g77/980628-9.f  -Os  execution test


It appears that the old bug mentioned in the head comment is back:

* g77 0.5.23 and previous had bugs involving too little space
* allocated for EQUIVALENCE and COMMON areas needing initial
* padding to meet alignment requirements of the system.


G95:
Program received signal SIGSEGV, Segmentation fault.
0x00010a94 in x_ (c1=0xffbefaa4, r1=@0xffbefaa5, c2=0xffbefab0,
    r2=@0xffbefab1, c3=0xffbefabc, r3=@0xffbefabd, c4=@0xffbefaa3,
    c5=@0xffbefaa1, c6=@0xffbefaa2, _c1=1, _c2=1, _c3=1, _c4=1, _c5=1, _c6=1)
    at 980628-2.f:44
44            if (r1 .ne. 1.) call abort

G77:
Breakpoint 1, x_ (c1=0xffbefaab, r1=0xffbefaac, c2=0xffbefa9b, r2=0xffbefa9c,
    c3=0xffbefa8b, r3=0xffbefa8c, c4=0xffbefa87, c5=0xffbefa86, c6=0xffbefa85,
    __g77_length_c1=1, __g77_length_c2=1, __g77_length_c3=1,
    __g77_length_c4=1, __g77_length_c5=1, __g77_length_c6=1) at 980628-2.f:44
44            if (r1 .ne. 1.) call abort

Note the discrepancy for the alignment of r1, r2 and r3.
Comment 1 Giovanni Bajo 2004-11-13 14:31:58 UTC
A regression wrt the old frontend.
Comment 2 Eric Botcazou 2004-11-16 08:36:53 UTC
This is critical on the SPARC.
Comment 3 James A. Morrison 2004-11-17 15:09:19 UTC
 I'm getting the same problems on sparc32 builds.
Comment 4 Christian Joensson 2004-11-30 18:25:45 UTC
well, I get a few too, see http://gcc.gnu.org/ml/gcc-testresults/2004-
11/msg01283.html and http://gcc.gnu.org/ml/gcc-testresults/2004-
11/msg01296.html
Comment 5 James A. Morrison 2004-12-17 20:42:43 UTC
I haven't tested this yet, but perhaps something as simple as
Index: trans-common.c
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/fortran/trans-common.c,v
retrieving revision 1.18
diff -u -p -r1.18 trans-common.c
--- trans-common.c      16 Sep 2004 16:00:43 -0000      1.18
+++ trans-common.c      17 Dec 2004 20:41:48 -0000
@@ -269,6 +269,9 @@ build_equiv_decl (tree union_type, bool
   TREE_ADDRESSABLE (decl) = 1;
   TREE_USED (decl) = 1;

+  DECL_ALIGN (decl) = BIGGEST_ALIGNMENT;
+  DECL_USER_ALIGN (decl) = 0;
+
   /* The source location has been lost, and doesn't really matter.
      We need to set it to something though.  */
   gfc_set_decl_location (decl, &gfc_current_locus);

 Would fix the problem.
Comment 6 James A. Morrison 2004-12-19 18:09:10 UTC
 Sorry for the noise.  That patch doesn't do anything.
Comment 7 Andrew Pinski 2004-12-21 00:39:51 UTC
Patch here: <http://gcc.gnu.org/ml/gcc-patches/2004-12/msg01605.html>.
Comment 8 Paul Brook 2005-01-04 22:48:21 UTC
I don't think that patch is sufficient. I'm about halfway to a fix.
I don't think the behaviour should be conditional on STRICT_ALIGNMENT.
Either enforce alignment, or annotate things properly so that the backend
generates unaligned loads. g77 enforces alignment.
Comment 9 Andrew Pinski 2005-01-08 21:43:03 UTC
*** Bug 19338 has been marked as a duplicate of this bug. ***
Comment 10 GCC Commits 2005-01-09 22:57:59 UTC
Subject: Bug 17675

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	pbrook@gcc.gnu.org	2005-01-09 22:57:45

Modified files:
	gcc/fortran    : ChangeLog trans-common.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/gfortran.dg: common_2.f90 common_3.f90 

Log message:
	2005-01-09  Paul Brook  <paul@codesourcery.com>
	
	PR fortran/17675
	* trans-common.c (current_common, current_offset): Remove.
	(create_common): Add head argument.
	(align_segment): New function.
	(apply_segment_offset): New function.
	(translate_common): Merge code from new_segment.  Handle alignment.
	(new_segment): Remove.
	(finish_equivalences): Ensure proper alignment.
	testsuite/
	* gfortran.dg/common_2.f90: New file.
	* gfortran.dg/common_3.f90: New file.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fortran/ChangeLog.diff?cvsroot=gcc&r1=1.288&r2=1.289
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fortran/trans-common.c.diff?cvsroot=gcc&r1=1.18&r2=1.19
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.4874&r2=1.4875
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gfortran.dg/common_2.f90.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gfortran.dg/common_3.f90.diff?cvsroot=gcc&r1=NONE&r2=1.1

Comment 11 Paul Brook 2005-01-09 22:59:32 UTC
Should be fixed now.
Comment 12 Eric Botcazou 2005-01-09 23:16:31 UTC
> Should be fixed now.

Unfortunately not all of them:

FAIL: gfortran.dg/g77/980628-10.f  -O0  execution test
FAIL: gfortran.dg/g77/980628-10.f  -O1  execution test
FAIL: gfortran.dg/g77/980628-10.f  -O2  execution test
FAIL: gfortran.dg/g77/980628-10.f  -O3 -fomit-frame-pointer  execution test
FAIL: gfortran.dg/g77/980628-10.f  -O3 -fomit-frame-pointer -funroll-loops 
execution test
FAIL: gfortran.dg/g77/980628-10.f  -O3 -fomit-frame-pointer -funroll-all-loops
-finline-functions  execution test
FAIL: gfortran.dg/g77/980628-10.f  -O3 -g  execution test
FAIL: gfortran.dg/g77/980628-10.f  -Os  execution test
FAIL: gfortran.dg/g77/980628-7.f  -O0  execution test
FAIL: gfortran.dg/g77/980628-7.f  -O1  execution test
FAIL: gfortran.dg/g77/980628-7.f  -O2  execution test
FAIL: gfortran.dg/g77/980628-7.f  -O3 -fomit-frame-pointer  execution test
FAIL: gfortran.dg/g77/980628-7.f  -O3 -fomit-frame-pointer -funroll-loops 
execution test
FAIL: gfortran.dg/g77/980628-7.f  -O3 -fomit-frame-pointer -funroll-all-loops
-finline-functions  execution test
FAIL: gfortran.dg/g77/980628-7.f  -O3 -g  execution test
FAIL: gfortran.dg/g77/980628-7.f  -Os  execution test
FAIL: gfortran.dg/g77/980628-8.f  -O0  execution test
FAIL: gfortran.dg/g77/980628-8.f  -O1  execution test
FAIL: gfortran.dg/g77/980628-8.f  -O2  execution test
FAIL: gfortran.dg/g77/980628-8.f  -O3 -fomit-frame-pointer  execution test
FAIL: gfortran.dg/g77/980628-8.f  -O3 -fomit-frame-pointer -funroll-loops 
execution test
FAIL: gfortran.dg/g77/980628-8.f  -O3 -fomit-frame-pointer -funroll-all-loops
-finline-functions  execution test
FAIL: gfortran.dg/g77/980628-8.f  -O3 -g  execution test
FAIL: gfortran.dg/g77/980628-8.f  -Os  execution test
FAIL: gfortran.dg/g77/980628-9.f  -O0  execution test
FAIL: gfortran.dg/g77/980628-9.f  -O1  execution test
FAIL: gfortran.dg/g77/980628-9.f  -O2  execution test
FAIL: gfortran.dg/g77/980628-9.f  -O3 -fomit-frame-pointer  execution test
FAIL: gfortran.dg/g77/980628-9.f  -O3 -fomit-frame-pointer -funroll-loops 
execution test
FAIL: gfortran.dg/g77/980628-9.f  -O3 -fomit-frame-pointer -funroll-all-loops
-finline-functions  execution test
FAIL: gfortran.dg/g77/980628-9.f  -O3 -g  execution test
FAIL: gfortran.dg/g77/980628-9.f  -Os  execution test
FAIL: gfortran.dg/g77/980701-1.f  -O0  execution test
FAIL: gfortran.dg/g77/980701-1.f  -O1  execution test
FAIL: gfortran.dg/g77/980701-1.f  -O2  execution test
FAIL: gfortran.dg/g77/980701-1.f  -O3 -fomit-frame-pointer  execution test
FAIL: gfortran.dg/g77/980701-1.f  -O3 -fomit-frame-pointer -funroll-loops 
execution test
FAIL: gfortran.dg/g77/980701-1.f  -O3 -fomit-frame-pointer -funroll-all-loops
-finline-functions  execution test
FAIL: gfortran.dg/g77/980701-1.f  -O3 -g  execution test
FAIL: gfortran.dg/g77/980701-1.f  -Os  execution test

Note that Steve's patch fixes all of them.
Comment 13 GCC Commits 2005-01-16 12:06:02 UTC
Subject: Bug 17675

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	pbrook@gcc.gnu.org	2005-01-16 12:05:54

Modified files:
	gcc/fortran    : ChangeLog trans-common.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/gfortran.dg: common_4.f90 

Log message:
	2004-01-16  Paul Brook  <paul@codesourcery.com>
	
	PR fortran/17675
	* trans-common.c (translate_common): Remove duplicate function call.
	(finish_equivalences): Preserve alignment when biasing offsets.
	testsuite/
	* gfortran.dg/common_4.f90: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fortran/ChangeLog.diff?cvsroot=gcc&r1=1.293&r2=1.294
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fortran/trans-common.c.diff?cvsroot=gcc&r1=1.20&r2=1.21
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.4893&r2=1.4894
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gfortran.dg/common_4.f90.diff?cvsroot=gcc&r1=NONE&r2=1.1

Comment 14 Eric Botcazou 2005-01-16 15:47:26 UTC
> 	PR fortran/17675
> 	* trans-common.c (translate_common): Remove duplicate function call.
> 	(finish_equivalences): Preserve alignment when biasing offsets.
> 	testsuite/
> 	* gfortran.dg/common_4.f90: New test.

You got them all on both SPARC 32-bit and 64-bit.  Thanks!
Comment 15 Andrew Pinski 2005-01-16 16:08:36 UTC
This is now fixed right?
Comment 16 dave 2005-01-16 16:13:40 UTC
Subject: Re:  [Regression w.r.t. g77] Alignment constraints

> ------- Additional Comments From pinskia at gcc dot gnu dot org  2005-01-16
> 16:08 -------
> This is now fixed right?

Should know in a couple of hours.  I have builds going on
hppa2.0w-hp-hpux11.11 and hppa64-hp-hpux11.11.

Dave
Comment 17 dave 2005-01-16 23:17:49 UTC
Subject: Re:  [Regression w.r.t. g77] Alignment constraints

> > ------- Additional Comments From pinskia at gcc dot gnu dot org  2005-01-16
> > 16:08 -------
> > This is now fixed right?
> 
> Should know in a couple of hours.  I have builds going on
> hppa2.0w-hp-hpux11.11 and hppa64-hp-hpux11.11.

Yes.

Dave
Comment 18 Paul Brook 2005-01-16 23:21:01 UTC
Fixed.