Bug 27381 - [4.2 Regression] ice on valid code with -O
Summary: [4.2 Regression] ice on valid code with -O
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 4.2.0
: P3 blocker
Target Milestone: 4.2.0
Assignee: Andrew Macleod
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2006-05-02 11:16 UTC by David Binderman
Modified: 2006-05-04 04:53 UTC (History)
5 users (show)

See Also:
Host:
Target: i686-pc-linux-gnu
Build:
Known to work: 4.1.0
Known to fail:
Last reconfirmed: 2006-05-02 15:38:29


Attachments
C source code (27.83 KB, application/octet-stream)
2006-05-02 11:19 UTC, David Binderman
Details
proposed patch (630 bytes, patch)
2006-05-02 15:40 UTC, Andrew Macleod
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description David Binderman 2006-05-02 11:16:54 UTC
I just tried to compile Suse package gnome-print-0.37-18 with a recent
GNU C compiler version 4.2 snapshot 20060429. 

The compiler snapshot said

if gcc -DHAVE_CONFIG_H -I. -I. -I.. -I.. -I.. -I/usr/include/freetype2 -I/opt/gnome/include/gnome-1.0 -DNEED_GNOMESUPPORT_H -I/opt/gnome/lib64/gnome-libs/include -I/opt/gnome/include -I/opt/gnome/include/gtk-1.2 -I/opt/gnome/include/glib-1.2 -I/opt/gnome/lib64/glib/include -I/usr/X11R6/include -I/opt/gnome/include/gdk-pixbuf-1.0 -I/usr/include/gnome-xml                       -DGNOMELOCALEDIR=\""/opt/gnome/share/locale"\" -DBINDIR=\""/opt/gnome/bin"\" -DDATADIR=\""/opt/gnome/share"\" -DSYSCONFDIR=\""/etc/opt/gnome"\" -DLIBDIR=\""/opt/gnome/lib64"\" -DFONTMAPDIR_STATIC=\""/opt/gnome/share/gnome/fonts"\" -DFONTMAPDIR_DYNAMIC=\""/etc/opt/gnome/gnome/fonts"\" -DVERSION=\""0.37"\"  -O2 -g -fmessage-length=0 -D_FORTIFY_SOURCE=2 -MT gf-fontmap.o -MD -MP -MF ".deps/gf-fontmap.Tpo" -c -o gf-fontmap.o gf-fontmap.c; \
then mv -f ".deps/gf-fontmap.Tpo" ".deps/gf-fontmap.Po"; else rm -f ".deps/gf-fontmap.Tpo"; exit 1;
fi
gf-fontmap.c: In function 'gf_fontmap_load_file':
gf-fontmap.c:257: internal compiler error: in propagate_rhs_into_lhs, at tree-ssa-dom.c:2307
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.

Preprocessed source code attached.  Flag -O2 required.
Comment 1 David Binderman 2006-05-02 11:19:16 UTC
Created attachment 11357 [details]
C source code
Comment 2 Richard Biener 2006-05-02 11:39:50 UTC
Reducing.
Comment 3 Richard Biener 2006-05-02 12:26:37 UTC
Confirmed.  Reduced testcase:

typedef char gchar;
typedef unsigned char xmlChar;
typedef struct _xmlNode xmlNode;
typedef xmlNode *xmlNodePtr;
struct _xmlNode {
    struct _xmlNode *next;
    struct _xmlNode *childs;
};
typedef struct _GFFileEntry GFFileEntry;
struct _GFFileEntry {
    gchar *path;
};
gf_fm_load_font_2_0_truetype (xmlNodePtr node)
{
    xmlNodePtr child;
    GFFileEntry ttf;
    ttf.path = ((void *)0);
    for (child = node->childs;
	 child != ((void *)0);
	 child = child->next) {
	xmlChar *type, *xmlpath;
	if (type
	    && !__builtin_strcmp (type, "ttf")
	    && !ttf.path) {
	    if (xmlpath) {
		ttf.path = g_strdup (xmlpath);
	    }
	}
	if (type) free((type));
	if (ttf.path) break;
    }
}
Comment 4 Richard Biener 2006-05-02 12:37:01 UTC
Caused by

Author: amacleod
Date: Fri Apr 28 20:39:18 2006
New Revision: 113356

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=113356
Log:

The condition the assert was flawed.

2006-04-28  Andrew MacLeod  <amacleod@redhat.com>

	* tree-ssa-dom.c (propagate_rhs_into_lhs): Fix assert clause.


Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/tree-ssa-dom.c
Comment 5 Andrew Macleod 2006-05-02 15:38:29 UTC
The assert condition is not flawed.  It has exposed a second bug with the old immuse iterator scheme that was also hidden by the old algorithm work around Jeff had implemented.

When iterating over the immediate uses, and deleting a stmt (such as a conditional) causes an edge to be removed, PHI nodes have an argument deleted.   

when we remove PHI arguments, we move the last phi argument to whatever position we actually deleted, and reduce the argument count.  When arguments are moved, they were simply being delinked and then linked back into the use chain. 

In this particular example, the argument being moved was another occurence of the ssa_name being iterated over, and by delinking it and linking it back in, it was moved back to the beginning of the immuse list. This caused it to be missed during the iteration pahse, and rightfully triggered the assert.

The fix is to simply keep the same linked position when the argument is moved instead of removing it from the list and linking it back in.

Patch is currently being tested.

Andrew
Comment 6 Andrew Macleod 2006-05-02 15:40:52 UTC
Created attachment 11361 [details]
proposed patch

This is the patch undergoing testing.
Comment 7 Andrew Macleod 2006-05-03 17:13:40 UTC
Subject: Bug 27381

Author: amacleod
Date: Wed May  3 17:13:37 2006
New Revision: 113499

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=113499
Log:


2006-05-02  Andrew MacLeod  <amacleod@redhat.com>

        PR tree-optimization/27381
	* tree-phinodes.c (remove_phi_arg_num): When moving a phi argument, 
	maintain the same immediate_use links.
	* tree-ssa-operands.c (dump_immediate_uses_for): Show iteration marker 
	node rather than segfaulting.


Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/tree-phinodes.c
    trunk/gcc/tree-ssa-operands.c

Comment 8 Andrew Pinski 2006-05-04 04:53:13 UTC
Fixed.