Bug 87955 - [9 Regression] ICE in cl_target_option_print_diff at gcc/options-save.c:3803 since r265920
Summary: [9 Regression] ICE in cl_target_option_print_diff at gcc/options-save.c:3803 ...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: ipa (show other bugs)
Version: 9.0
: P3 normal
Target Milestone: 9.0
Assignee: David Malcolm
URL: https://gcc.gnu.org/ml/gcc-patches/20...
Keywords: ice-on-valid-code, patch
Depends on:
Blocks:
 
Reported: 2018-11-09 10:25 UTC by Martin Liška
Modified: 2018-12-10 13:33 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail: 9.0
Last reconfirmed: 2018-11-09 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Liška 2018-11-09 10:25:35 UTC
Following is iceing:

$ cat /tmp/ice.i
float a;
__attribute__((__target__("fpmath=387")))

void b() {
  if (a)
    __builtin_abort();
}

void c() { b(); }

$ ./xgcc -B. -O2 -fopt-info /tmp/ice.i -c
during GIMPLE pass: einline
/tmp/ice.i: In function ‘c’:
/tmp/ice.i:9:1: internal compiler error: Segmentation fault
    9 | void c() { b(); }
      | ^~~~
0xd0f73f crash_signal
	/home/marxin/Programming/gcc/gcc/toplev.c:325
0x7ffff6bc310f ???
	/usr/src/debug/glibc-2.27-6.1.x86_64/signal/../sysdeps/unix/sysv/linux/x86_64/sigaction.c:0
0x7ffff6c03d8a fputc
	/usr/src/debug/glibc-2.27-6.1.x86_64/libio/fputc.c:35
0xc29812 cl_target_option_print_diff(_IO_FILE*, int, cl_target_option*, cl_target_option*)
	/dev/shm/objdir/gcc/options-save.c:3803
0x155bf98 report_inline_failed_reason
	/home/marxin/Programming/gcc/gcc/ipa-inline.c:248
0x155c470 can_inline_edge_p
	/home/marxin/Programming/gcc/gcc/ipa-inline.c:381
0x155d386 can_early_inline_edge_p
	/home/marxin/Programming/gcc/gcc/ipa-inline.c:578
0x1563c1b early_inline_small_functions
	/home/marxin/Programming/gcc/gcc/ipa-inline.c:2690
0x1564018 early_inliner(function*)
	/home/marxin/Programming/gcc/gcc/ipa-inline.c:2803
0x1564225 execute
	/home/marxin/Programming/gcc/gcc/ipa-inline.c:2885
Comment 1 David Malcolm 2018-11-09 13:09:01 UTC
Sorry about that.  Confirmed; I'm working on a fix.
Comment 2 David Malcolm 2018-11-11 01:35:55 UTC
Candidate patch: https://gcc.gnu.org/ml/gcc-patches/2018-11/msg00834.html
Comment 3 David Malcolm 2018-11-13 16:00:28 UTC
Author: dmalcolm
Date: Tue Nov 13 15:59:57 2018
New Revision: 266079

URL: https://gcc.gnu.org/viewcvs?rev=266079&root=gcc&view=rev
Log:
Fix ICE with -fopt-info-inline (PR ipa/87955)

PR ipa/87955 reports a problem I introduced in r265920, where I converted
the guard in report_inline_failed_reason from using:
  if (dump_file)
to using
  if (dump_enabled_p ()).
without updating the calls to cl_target_option_print_diff and
cl_optimization_print_diff, which assume that dump_file is non-NULL.

The functions are auto-generated.  Rather than porting them to the dump
API, this patch applies the workaround of adding the missing checks on
dump_file before calling them.

gcc/ChangeLog:
	PR ipa/87955
	* ipa-inline.c (report_inline_failed_reason): Guard calls to
	cl_target_option_print_diff and cl_optimization_print_diff with
	if (dump_file).

gcc/testsuite/ChangeLog:
	PR ipa/87955
	* gcc.target/i386/pr87955.c: New test.


Added:
    trunk/gcc/testsuite/gcc.target/i386/pr87955.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/ipa-inline.c
    trunk/gcc/testsuite/ChangeLog
Comment 4 David Malcolm 2018-11-13 16:02:58 UTC
Should be fixed by r266079.
Comment 5 Rainer Orth 2018-11-19 13:05:04 UTC
The new testcase FAILs on 32-bit Solaris/x86, FreeBSD, and Linux:

+FAIL: gcc.target/i386/pr87955.c  (test for errors, line 10)

I suspect it needs to be restricted to target lp64?
Comment 6 Jakub Jelinek 2018-12-10 13:31:23 UTC
Author: jakub
Date: Mon Dec 10 13:30:49 2018
New Revision: 266954

URL: https://gcc.gnu.org/viewcvs?rev=266954&root=gcc&view=rev
Log:
	PR ipa/87955
	* gcc.target/i386/pr87955.c: Add -msse2 -mfpmath=sse to dg-options.

Modified:
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gcc.target/i386/pr87955.c
Comment 7 Jakub Jelinek 2018-12-10 13:33:28 UTC
Should be fixed now.