Bug 11741 - internal compiler error at gcse.c:5318
Summary: internal compiler error at gcse.c:5318
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: rtl-optimization (show other bugs)
Version: 3.3.1
: P2 normal
Target Milestone: 3.3.3
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2003-07-31 09:19 UTC by rehsack
Modified: 2003-11-08 16:27 UTC (History)
2 users (show)

See Also:
Host:
Target: i?86-*-*
Build:
Known to work:
Known to fail:
Last reconfirmed: 2003-08-24 17:06:12


Attachments
preprocessed source which fails to compile (72.74 KB, text/plain)
2003-07-31 09:21 UTC, rehsack
Details
first part of created assembler source (342 bytes, text/plain)
2003-07-31 09:22 UTC, rehsack
Details

Note You need to log in before you can comment on or make changes to this bug.
Description rehsack 2003-07-31 09:19:56 UTC
When compiling freebsd-port x11/gnomelib (v1.4.2) with current system compiler,
the compiler fails unexpectly:

/bin/sh ../libtool --mode=compile cc -DHAVE_CONFIG_H -I. -I. -I.. -I.. -I./..
-DNEED_GNOMESUPPORT_H -I../support -I../suppo rt -I../intl -I../intl
-I/usr/X11R6/include -I/usr/X11R6/include/gtk12 -I/usr/local/include/glib12
-I/usr/local/include -I/ usr/X11R6/include -I/usr/X11R6/include
-I/usr/X11R6/include -I/usr/local/include -I/usr/local/include
-DGNOMELIBDIR=\""/usr /X11R6/lib"\" -DGNOMEDATADIR=\""/usr/X11R6/share/gnome"\"
-DGNOMEBINDIR=\""/usr/X11R6/bin"\" -DGNOMELOCALSTATEDIR=\""/usr/X
11R6/share/gnome"\" -DGNOMELOCALEDIR=\""/usr/X11R6/share/locale"\"
-DG_LOG_DOMAIN=\"GnomeUI\"  -I/usr/local/include -I/usr/ X11R6/include/gtk12
-I/usr/local/include/glib12 -I/usr/local/include -I/usr/X11R6/include  -v
-save-temps -O3 -fforce-addr -funroll-loops -momit-leaf-frame-pointer 
-minline-all-stringops -mmmx -msse -msse2 -mfpmath=sse -march=pentium4 -Wall
-Wun used  -c gtkcauldron.c
rm -f .libs/gtkcauldron.lo
cc -DHAVE_CONFIG_H -I. -I. -I.. -I.. -I./.. -DNEED_GNOMESUPPORT_H -I../support
-I../support -I../intl -I../intl -I/usr/X11R 6/include
-I/usr/X11R6/include/gtk12 -I/usr/local/include/glib12 -I/usr/local/include
-I/usr/X11R6/include -I/usr/X11R6/inc lude -I/usr/X11R6/include
-I/usr/local/include -I/usr/local/include -DGNOMELIBDIR=\"/usr/X11R6/lib\"
-DGNOMEDATADIR=\"/usr/ X11R6/share/gnome\" -DGNOMEBINDIR=\"/usr/X11R6/bin\"
-DGNOMELOCALSTATEDIR=\"/usr/X11R6/share/gnome\" -DGNOMELOCALEDIR=\"/us
r/X11R6/share/locale\" -DG_LOG_DOMAIN=\"GnomeUI\" -I/usr/local/include
-I/usr/X11R6/include/gtk12 -I/usr/local/include/glib 12 -I/usr/local/include
-I/usr/X11R6/include -v -save-temps -O3 -fforce-addr -funroll-loops
-momit-leaf-frame-pointer -minl ine-all-stringops -mmmx -msse -msse2
-mfpmath=sse -march=pentium4 -Wall -Wunused -c gtkcauldron.c  -fPIC -DPIC -o
.libs/gtk cauldron.lo
Using built-in specs.
Configured with: FreeBSD/i386 system compiler
Thread model: posix
gcc version 3.3.1 [FreeBSD] 20030711 (prerelease)
 /usr/libexec/cc1 -E -quiet -v -I. -I. -I.. -I.. -I./.. -I../support
-I../support -I../intl -I../intl -I/usr/X11R6/include -I/usr/X11R6/include/gtk12
-I/usr/local/include/glib12 -I/usr/local/include -I/usr/X11R6/include
-I/usr/X11R6/include -I/us r/X11R6/include -I/usr/local/include
-I/usr/local/include -I/usr/local/include -I/usr/X11R6/include/gtk12
-I/usr/local/incl ude/glib12 -I/usr/local/include -I/usr/X11R6/include
-D__GNUC__=3 -D__GNUC_MINOR__=3 -D__GNUC_PATCHLEVEL__=1 -D__PIC__ -D__ pic__
-D_LONGLONG -DHAVE_CONFIG_H -DNEED_GNOMESUPPORT_H -DGNOMELIBDIR="/usr/X11R6/lib"
-DGNOMEDATADIR="/usr/X11R6/share/gno me" -DGNOMEBINDIR="/usr/X11R6/bin"
-DGNOMELOCALSTATEDIR="/usr/X11R6/share/gnome"
-DGNOMELOCALEDIR="/usr/X11R6/share/locale"  -DG_LOG_DOMAIN="GnomeUI" -DPIC
gtkcauldron.c -momit-leaf-frame-pointer -minline-all-stringops -mmmx -msse
-msse2 -mfpmath= sse -march=pentium4 -Wall -Wunused -fforce-addr -funroll-loops
-fPIC -O3 gtkcauldron.i
ignoring duplicate directory "."
ignoring duplicate directory ".."
ignoring duplicate directory ".."
ignoring duplicate directory "../support"
ignoring duplicate directory "../intl"
ignoring duplicate directory "/usr/X11R6/include"
ignoring duplicate directory "/usr/X11R6/include"
ignoring duplicate directory "/usr/X11R6/include"
ignoring duplicate directory "/usr/local/include"
ignoring duplicate directory "/usr/local/include"
ignoring duplicate directory "/usr/local/include"
ignoring duplicate directory "/usr/X11R6/include/gtk12"
ignoring duplicate directory "/usr/local/include/glib12"
ignoring duplicate directory "/usr/local/include"
ignoring duplicate directory "/usr/X11R6/include"
ignoring duplicate directory "/usr/include"
#include "..." search starts here:
#include <...> search starts here: .
 ..
 ../support
 ../intl
 /usr/X11R6/include
 /usr/X11R6/include/gtk12
 /usr/local/include/glib12
 /usr/local/include
 /usr/include
End of search list.
 /usr/libexec/cc1 -fpreprocessed gtkcauldron.i -quiet -dumpbase gtkcauldron.c
-momit-leaf-frame-pointer -minline-all-string ops -mmmx -msse -msse2
-mfpmath=sse -march=pentium4 -auxbase-strip .libs/gtkcauldron.lo -O3 -Wall
-Wunused -version -fforce -addr -funroll-loops -fPIC -o gtkcauldron.s
GNU C version 3.3.1 [FreeBSD] 20030711 (prerelease) (i386-undermydesk-freebsd)
        compiled by GNU C version 3.3.1 [FreeBSD] 20030711 (prerelease).
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
gtkcauldron.c: In function `convert_label_with_ampersand':
gtkcauldron.c:457: internal compiler error: in pre_insert_copy_insn, at gcse.c:5318
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.
gmake[1]: *** [gtkcauldron.lo] Error 1
Comment 1 rehsack 2003-07-31 09:21:46 UTC
Created attachment 4532 [details]
preprocessed source which fails to compile
Comment 2 rehsack 2003-07-31 09:22:51 UTC
Created attachment 4533 [details]
first part of created assembler source
Comment 3 Andrew Pinski 2003-07-31 14:00:50 UTC
I can confirm this on the mainline (20030730) but I have reduced this yet (it happens at -O2 also):
gcc pr11741.c -O2 -fforce-addr -funroll-loops -momit-leaf-frame-pointer -minline-all-
stringops -mmmx -msse -msse2 -mfpmath=sse -march=pentium4
Comment 4 Dara Hazeghi 2003-08-24 16:57:15 UTC
On mainline, only -O2 -minline-all-stringops -march=pentium4 is needed to cause it to ICE.
Comment 5 Andrew Pinski 2003-08-24 17:06:11 UTC
Here is the reduced sources:
char* g_strdup (const char *str);

char *convert_label_with_ampersand (const char * _label, int * accelerator_key, int * underbar_pos)
{
    char *p;
    char *label = g_strdup (_label);
    for (p = label;; p++) {
        if (!*p)
            break;
        if (!p[1])
            break;
        if (*p == '&') {
            memcpy (p, p + 1, strlen (p));
            if (*p == '&')
                continue;
            *underbar_pos = (unsigned long) p - (unsigned long) label;
            *accelerator_key = *p;
            return label;
        }
    }
    return label;
}
Comment 6 Dara Hazeghi 2003-08-24 17:15:39 UTC
Slightly more reduced. Bug happens on Linux too, so expanding target summary.

char* g_strdup (const char *str);
void *memcpy(void * , const void * , unsigned int);
unsigned int strlen(const char *);

void convert_label_with_ampersand (const char * _label)
{
    char *p;
    char *label = g_strdup (_label);
    for (p = label;; p++) {
        if (*p == '&') {
            memcpy (p, p + 1, strlen (p));
            if (*p == '&')
			  continue;
        }
    }
}
Comment 7 Andrew Pinski 2003-08-24 17:22:11 UTC
Even more reduced:
char* g_strdup (const char *str);

char *convert_label_with_ampersand (const char * _label)
{
    char *p;
    char *label = g_strdup (_label);
    for (p = label;; p++) {
            memcpy (p, p + 1, strlen (p));
       }
    return label;
}
Comment 8 Kazu Hirata 2003-09-02 10:38:22 UTC
Even more reduced:

void
foo (char *p)
{
  for (;;)
    {
      memcpy (p, p + 1, strlen (p));
      p++;
    }
}
Comment 9 Andreas Jaeger 2003-09-02 11:17:02 UTC
Subject: Re:  internal compiler error at gcse.c:5318

"kazu at cs dot umass dot edu" <gcc-bugzilla@gcc.gnu.org> writes:

> Even more reduced:
>
> void
> foo (char *p)
> {
>   for (;;)
>     {
>       memcpy (p, p + 1, strlen (p));
>       p++;
>     }
> }

This is not valid ISO C since the regions might overlap,

Andreas
Comment 10 GCC Commits 2003-09-26 18:23:39 UTC
Subject: Bug 11741

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	sayle@gcc.gnu.org	2003-09-26 18:23:33

Modified files:
	gcc            : ChangeLog gcse.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/gcc.dg: 20030926-1.c 

Log message:
	PR optimization/11741
	* gcse.c (pre_insert_copy_insn): Tweak the logic for finding the
	appropriate set to match that in hash_scan_insn.  Fall back to
	the original copy method, if we can't validate changing insn.
	(pre_delete): Only delete instructions that have a single_set,
	instead of aborting when we encounter an PARALLEL insn with more
	then one SET.
	
	* gcc.dg/20030926-1.c: New test case.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.1184&r2=2.1185
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/gcse.c.diff?cvsroot=gcc&r1=1.274&r2=1.275
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.3081&r2=1.3082
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/20030926-1.c.diff?cvsroot=gcc&r1=NONE&r2=1.1

Comment 11 Andrew Pinski 2003-09-27 20:25:39 UTC
Fixed.
Comment 12 GCC Commits 2003-11-08 15:24:36 UTC
Subject: Bug 11741

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-3_3-branch
Changes by:	sayle@gcc.gnu.org	2003-11-08 15:24:33

Modified files:
	gcc            : ChangeLog gcse.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/gcc.dg: 20030926-1.c 20031108-1.c 

Log message:
	Backport from mainline
	PR optimization/10467
	PR optimization/11741
	* gcse.c (pre_insert_copy_insn): Tweak the logic for finding the
	appropriate set to match the code in hash_scan_insn.
	
	* gcc.dg/20030926-1.c: New test case.
	* gcc.dg/20031108-1.c: New test case.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.16114.2.801&r2=1.16114.2.802
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/gcse.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.223.2.7&r2=1.223.2.8
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.2261.2.314&r2=1.2261.2.315
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/20030926-1.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=NONE&r2=1.1.12.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/20031108-1.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=NONE&r2=1.1.2.1