Bug 60155 - ICE: in get_pressure_class_and_nregs at gcse.c:3438
Summary: ICE: in get_pressure_class_and_nregs at gcse.c:3438
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: rtl-optimization (show other bugs)
Version: 4.8.2
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
: 54737 (view as bug list)
Depends on:
Blocks:
 
Reported: 2014-02-12 02:14 UTC by John David Anglin
Modified: 2014-04-04 22:30 UTC (History)
4 users (show)

See Also:
Host: hppa-unknown-linux-gnu
Target: hppa-unknown-linux-gnu
Build: hppa-unknown-linux-gnu
Known to work:
Known to fail:
Last reconfirmed:


Attachments
Preprocessed source (89.41 KB, text/plain)
2014-02-12 02:14 UTC, John David Anglin
Details
Patch (386 bytes, patch)
2014-02-14 20:06 UTC, John David Anglin
Details | Diff
gcse.c.d.1.txt (754 bytes, text/plain)
2014-03-03 00:57 UTC, dave.anglin
Details
gcse.c.d.7.txt (1.03 KB, text/plain)
2014-03-09 20:36 UTC, dave.anglin
Details

Note You need to log in before you can comment on or make changes to this bug.
Description John David Anglin 2014-02-12 02:14:36 UTC
Created attachment 32112 [details]
Preprocessed source

The following ICE occurs building openssh -6.5p1:

gcc -g -O2 -Wall -Wpointer-arith -Wuninitialized -Wsign-compare -Wformat-security -Wsizeof-pointer-memaccess -Wno-pointer-sign -Wno-unused-result -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -ftrapv -fno-builtin-memset -D_FORTIFY_SOURCE=2 -g -O2 -Wformat -Werror=format-security -DLOGIN_PROGRAM=\"/bin/login\" -DLOGIN_NO_ENDOPT -DSSH_EXTRAVERSION=\"Debian-2\"  -I. -I..  -I/usr/include/editline     -DSSHDIR=\"/etc/ssh\" -D_PATH_SSH_PROGRAM=\"/usr/bin/ssh\" -D_PATH_SSH_ASKPASS_DEFAUL
T=\"/usr/bin/ssh-askpass\" -D_PATH_SFTP_SERVER=\"/usr/lib/openssh/sftp-server\" 
-D_PATH_SSH_KEY_SIGN=\"/usr/lib/openssh/ssh-keysign\" -D_PATH_SSH_PKCS11_HELPER=\"/usr/lib/openssh/ssh-pkcs11-helper\" -D_PATH_SSH_PIDDIR=\"/var/run\" -D_PATH_P
RIVSEP_CHROOT_DIR=\"/var/run/sshd\" -DHAVE_CONFIG_H -c ../ssh-keygen.c
../ssh-keygen.c: In function ‘do_fingerprint’:
../ssh-keygen.c:887:1: internal compiler error: in get_pressure_class_and_nregs,
 at gcse.c:3438
 }
 ^Please submit a full bug report,
Comment 1 John David Anglin 2014-02-12 13:15:44 UTC
With 4.6 and 4.7 compilers, this appears as:

gcc-4.6 -g -O2 -Wall -Wpointer-arith -Wuninitialized -Wsign-compare -Wformat-security -Wno-pointer-sign -Wno-unused-result -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -ftrapv -fno-builtin-memset -D_FORTIFY_SOURCE=2 -g -O2 -Wformat -Werror=format-security -DLOGIN_PROGRAM=\"/bin/login\" -DLOGIN_NO_ENDOPT -DSSH_EXTRAVERSION=\"Debian-2\"  -I. -I..  -I/usr/include/editline     -DSSHDIR=\"/etc/ssh\" -D_PATH_SSH_PROGRAM=\"/usr/bin/ssh\" -D_PATH_SSH_ASKPASS_DEFAULT=\"/usr/bin/ssh-askpass\" -D_PATH_SFTP_SERVER=\"/usr/lib/openssh/sftp-server\" -D_PATH_SSH_KEY_SIGN=\"/usr/lib/openssh/ssh-keysign\" -D_PATH_SSH_PKCS11_HELPER=\"/usr/lib/openssh/ssh-pkcs11-helper\" -D_PATH_SSH_PIDDIR=\"/var/run\" -D_PATH_PRIVSEP_CHROOT_DIR=\"/var/run/sshd\" -DHAVE_CONFIG_H -c ../ssh-keygen.c
../ssh-keygen.c: In function ‘do_fingerprint’:
../ssh-keygen.c:887:1: internal compiler error: in hoist_code, at gcse.c:4631
Comment 2 John David Anglin 2014-02-13 00:02:43 UTC
Breakpoint 1, get_pressure_class_and_nregs (insn=0xfab51d98, nregs=0xfaf028c0)
    at ../../gcc/gcc/gcse.c:3459
3459	  gcc_assert (set != NULL_RTX);
(gdb) p debug_rtx (insn)
(insn 212 211 213 18 (parallel [
            (set (reg/v:SI 114 [ num ])
                (plus:SI (reg/v:SI 114 [ num ])
                    (const_int 1 [0x1])))
            (trap_if (ne (plus:DI (sign_extend:DI (reg/v:SI 114 [ num ]))
                        (sign_extend:DI (const_int 1 [0x1])))
                    (sign_extend:DI (plus:SI (reg/v:SI 114 [ num ])
                            (const_int 1 [0x1]))))
                (const_int 0 [0]))
        ]) ../ssh-keygen.c:830 113 {addvsi3}
     (nil))
$1 = void
Comment 3 John David Anglin 2014-02-13 00:07:40 UTC
Function compiles without "-ftrapv".
Comment 4 John David Anglin 2014-02-14 20:06:38 UTC
Created attachment 32140 [details]
Patch

The attach patch fixes the ICE but maybe we should always check
if the INSN might trap.  Also, what about floating point exceptions?
Comment 5 John David Anglin 2014-02-19 15:27:56 UTC
*** Bug 54737 has been marked as a duplicate of this bug. ***
Comment 6 Jeffrey A. Law 2014-02-25 06:36:43 UTC
Well, given that gcse merely moves evaluations to other blocks where evaluation of the expression is always anticipated, there's no inherent reason why we can't gcse something that might trap.

It really feels like this is papering over the real problem, namely that get_pressure_class_and_nregs simply doesn't handle things that are passed through hash_scan_set, in particular cases where there's a single set inside a PARALLEL.
Comment 7 dave.anglin 2014-02-26 01:46:13 UTC
On 25-Feb-14, at 1:36 AM, law at redhat dot com wrote:

> It really feels like this is papering over the real problem, namely  
> that
> get_pressure_class_and_nregs simply doesn't handle things that are  
> passed
> through hash_scan_set, in particular cases where there's a single  
> set inside a
> PARALLEL.

Could we use something like single_set_for_csa, but also check for  
TRAP_IF?

Dave
--
John David Anglin	dave.anglin@bell.net
Comment 8 Jeffrey A. Law 2014-02-26 03:41:28 UTC
Rather than special case TRAP_IF, I think we just need to walk through the pattern.  If we find no assignments or > 1 assignment, then we assert.

note_stores, or walking similar to hash_scan_insn where we keep track of whether or not we've seen a set should be sufficient, I'd think.
Comment 9 dave.anglin 2014-03-03 00:57:08 UTC
Created attachment 32246 [details]
gcse.c.d.1.txt

Something like this?

--
John David Anglin	dave.anglin@bell.net
Comment 10 John David Anglin 2014-03-04 01:01:58 UTC
Bah, doesn't fix bug:

dave@mx3210:~/gnu/gcc/objdir$ gcc/xgcc -Bgcc/ -g -O2 -Wall -Wpointer-arith -Wuninitialized -Wsign-compare -Wformat-security -Wsizeof-pointer-memaccess -Wno-pointer-sign -Wno-unused-result -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -ftrapv -fno-builtin-memset -D_FORTIFY_SOURCE=2 -g -O2 -Wformat -Werror=format-security -fpreprocessed ../ssh-keygen.i
../ssh-keygen.c: In function ‘do_fingerprint’:
../ssh-keygen.c:887:1: internal compiler error: in hoist_code, at gcse.c:3378
0x5bf083 hoist_code
	../../gcc/gcc/gcse.c:3378
0x5c00bf one_code_hoisting_pass
	../../gcc/gcc/gcse.c:3651
0x5c15f3 execute_rtl_hoist
	../../gcc/gcc/gcse.c:4171
0x5c17ef execute
	../../gcc/gcc/gcse.c:4244
Comment 11 dave.anglin 2014-03-09 20:36:37 UTC
Created attachment 32319 [details]
gcse.c.d.7.txt

On 3-Mar-14, at 8:01 PM, danglin at gcc dot gnu.org wrote:

> Bah, doesn't fix bug:

Attached new patch which seems to fix bug.  Testing.

--
John David Anglin	dave.anglin@bell.net
Comment 12 Jeffrey A. Law 2014-04-04 15:26:02 UTC
Dave, 

The updated patch looks good.  Please post it to gcc-patches for archival purposes with a note that I approved it in BZ before installing the patch.

Thanks,
jeff
Comment 13 John David Anglin 2014-04-04 22:26:23 UTC
Author: danglin
Date: Fri Apr  4 22:25:51 2014
New Revision: 209134

URL: http://gcc.gnu.org/viewcvs?rev=209134&root=gcc&view=rev
Log:
	PR rtl-optimization/60155
	* gcse.c (record_set_data): New function.
	(single_set_gcse): New function.
	(gcse_emit_move_after): Use single_set_gcse instead of single_set.
	(hoist_code): Likewise.
	(get_pressure_class_and_nregs): Likewise.


Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/gcse.c
Comment 14 John David Anglin 2014-04-04 22:30:42 UTC
Fixed on trunk.