Bug 10589 - For Hitachi SH target, GCC craches when both -fomit-frame-pointer and -mdalign options are specified
Summary: For Hitachi SH target, GCC craches when both -fomit-frame-pointer and -mdalig...
Status: RESOLVED WONTFIX
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 3.2
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2003-05-01 21:46 UTC by mathieu
Modified: 2007-04-27 22:36 UTC (History)
3 users (show)

See Also:
Host: i686-pc-cygwin
Target: sh-elf
Build: i686-pc-cygwin
Known to work: 4.0.4 4.1.2 4.2.0 4.3.0
Known to fail: 3.4.6
Last reconfirmed: 2003-05-26 14:09:40


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description mathieu 2003-05-01 21:46:00 UTC
This bug happens only when both -fomit-frame-pointer and -mdalign are specified.
If only one of them is not specified, the compilation works.

Don't work:
 	sh-elf-gcc -v -save-temps -fomit-frame-pointer -ml -mdalign -c GccShBug.c
Work:
 	sh-elf-gcc -v -save-temps -fomit-frame-pointer -ml -c GccShBug.c
Work:
 	sh-elf-gcc -v -save-temps -ml -mdalign -c GccShBug.c
Work:
 	sh-elf-gcc -v -save-temps -ml -c GccShBug.c


GCC output:

$ sh-elf-gcc -v -save-temps -fomit-frame-pointer -ml -mdalign -c GccShBug.c
Reading specs from /usr/local/lib/gcc-lib/sh-elf/3.2/specs
Configured with: ../gcc-3.2/configure --target=sh-elf --prefix=/usr/local --with
out-headers --with-newlib --enable-languages=c : (reconfigured) ../gcc-3.2/confi
gure --target=sh-elf --prefix=/usr/local --without-headers --with-newlib --enabl
e-languages=c,c++
Thread model: single
gcc version 3.2
 /usr/local/lib/gcc-lib/sh-elf/3.2/cpp0.exe -lang-c -v -D__GNUC__=3 -D__GNUC_MIN
OR__=2 -D__GNUC_PATCHLEVEL__=0 -D__GXX_ABI_VERSION=102 -D__sh__ -D__ELF__ -D__sh
__ -D__ELF__ -Acpu=sh -Amachine=sh -D__NO_INLINE__ -D__STDC_HOSTED__=1 -D__sh1__
 -D__SIZE_TYPE__=unsigned int -D__PTRDIFF_TYPE__=int -D__LITTLE_ENDIAN__ GccShBu
g.c GccShBug.i
GNU CPP version 3.2 (cpplib) (Hitachi SH)
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/lib/gcc-lib/sh-elf/3.2/include
 /usr/local/sh-elf/sys-include
 /usr/local/sh-elf/include
End of search list.
 /usr/local/lib/gcc-lib/sh-elf/3.2/cc1.exe -fpreprocessed GccShBug.i -quiet -dum
pbase GccShBug.c -ml -mdalign -version -fomit-frame-pointer -o GccShBug.s
GNU CPP version 3.2 (cpplib) (Hitachi SH)
GNU C version 3.2 (sh-elf)
        compiled by GNU C version 2.95.3-5 (cygwin special).
GccShBug.c: In function `divCeil':
GccShBug.c:11: Internal compiler error in output_stack_adjust, at config/sh/sh.c
:4195
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://www.gnu.org/software/gcc/bugs.html> for instructions.

Release:
GCC 3.2

Environment:
Cygwin or GNUSH 0302

How-To-Repeat:
int divCeil(int a, int b) {
        int c;
        if (a>0) {
                if (b>0) c=a+b-1;
                else c=a;
        } else {
                if (b>0) c=a;
                else c=a+b+1;
        }
        return c/b;
}
Comment 1 mathieu 2003-05-01 21:46:00 UTC
Fix:
Simple: don't use at the same time -fomit-frame-pointer and -mdalign.
Comment 2 Dara Hazeghi 2003-05-10 12:38:21 UTC
From: Dara Hazeghi <dhazeghi@yahoo.com>
To: gcc-gnats@gcc.gnu.org, mathieu@thenesis.com
Cc:  
Subject: Re: target/10589: For Hitachi SH target, GCC craches when both -fomit-frame-pointer and -mdalign options are specified
Date: Sat, 10 May 2003 12:38:21 -0700

 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit- 
 trail&database=gcc&pr=10589
 
 Hello,
 
 this is just to confirm that this bug exists on 3.3 branch and mainline  
 as well.
 
 Dara
Comment 3 Andrew Pinski 2003-05-26 14:09:40 UTC
See Dara's comment.
Comment 4 Kazu Hirata 2003-07-15 17:02:00 UTC
Here is an even smaller testcase.

int
foo (int a, int b)
{
  return a / b;
}
Comment 5 dank 2003-09-14 17:58:15 UTC
The testcase fails neither in gcc-3.0.2 as patched here in 2001,
nor in gcc-2.95 as supplied by Montavista in 2001,
so is it fair to say this is a regression?
Comment 6 dank 2003-09-15 17:41:47 UTC
I've prepared a patch to add a testcase for this PR to the testsuite; see
http://www.kegel.com/crosstool/current/patches/gcc-3.3.1/pr10589-1-test.patch
I'll submit it to gcc-patches in a couple days if nobody squawks.
Comment 7 Kazumoto Kojima 2007-04-27 22:36:52 UTC
The testcase fails with 3.4.6, but doesn't fail with 4.0 and later
compilers.  So I'd like to close this PR as WONTFIX because 3.4 was
frozen.