Bug 59584 - [4.8/4.9/4.10 Regression]: cannot handle define_split for insn emitted for __builtin_stack_restore
[4.8/4.9/4.10 Regression]: cannot handle define_split for insn emitted for __...
Status: UNCONFIRMED
Product: gcc
Classification: Unclassified
Component: middle-end
4.8.3
: P5 normal
: 4.9.0
Assigned To: Not yet assigned to anyone
: ice-on-valid-code
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2013-12-23 13:04 UTC by Hans-Peter Nilsson
Modified: 2014-01-09 00:23 UTC (History)
1 user (show)

See Also:
Host: x86_64-unknown-linux-gnu
Target: cris-axis-elf
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Hans-Peter Nilsson 2013-12-23 13:04:38 UTC
This test previously passed, now it fails.
A patch in the revision range (last_known_working:first_known_failing) 206008:206011 exposed or caused this regression.  Since then it fails as follows:

Running /tmp/hpautotest-gcc1/gcc/gcc/testsuite/gcc.dg/dg.exp ...
...
FAIL: gcc.dg/pr50251.c (internal compiler error)
FAIL: gcc.dg/pr50251.c (test for excess errors)


In gcc.log:
Executing on host: /tmp/hpautotest-gcc1/cris-elf/gccobj/gcc/xgcc -B/tmp/hpautotest-gcc1/cris-elf/gccobj/gcc/ /tmp/hpautotest-gcc1/gcc/gcc/testsuite/gcc.dg/pr50251.c  -fno-diagnostics-show-caret -fdiagnostics-color=never   -O2 -S   -isystem /tmp/hpautotest-gcc1/cris-elf/gccobj/cris-elf/./newlib/targ-include -isystem /tmp/hpautotest-gcc1/gcc/newlib/libc/include  -o pr50251.s    (timeout = 300)
/tmp/hpautotest-gcc1/gcc/gcc/testsuite/gcc.dg/pr50251.c: In function 'main':
/tmp/hpautotest-gcc1/gcc/gcc/testsuite/gcc.dg/pr50251.c:18:1: internal compiler error: in fixup_args_size_notes, at expr.c:3978
0x698221 fixup_args_size_notes(rtx_def*, rtx_def*, int)
        /tmp/hpautotest-gcc1/gcc/gcc/expr.c:3978
0x67aef9 try_split(rtx_def*, rtx_def*, int)
        /tmp/hpautotest-gcc1/gcc/gcc/emit-rtl.c:3602
0x886e61 split_insn
        /tmp/hpautotest-gcc1/gcc/gcc/recog.c:2850
0x887104 split_all_insns()
        /tmp/hpautotest-gcc1/gcc/gcc/recog.c:2940
0x8871d2 rest_of_handle_split_after_reload
        /tmp/hpautotest-gcc1/gcc/gcc/recog.c:3889
0x8871d2 execute
        /tmp/hpautotest-gcc1/gcc/gcc/recog.c:3918
Please submit a full bug report,
with preprocessed source if appropriate.

(as the test-case is without preprocessing directives no such action necessary)

A few more hints from gdb shows that gcc ties itself in a knot when splitting:
 (set (reg/f:SI 14 sp) (mem/f/c:SI (symbol_ref:SI ("p")))
into:
(gdb) call debug_rtx_range (seq, 0)
(insn 33 0 34 (set (reg/f:SI 14 sp)
        (symbol_ref:SI ("p") <var_decl 0x7ffff7eb2000 p>)) -1
     (nil))

(insn 34 33 0 (set (reg/f:SI 14 sp)
        (mem/f/c:SI (reg/f:SI 14 sp) [2 p+0 S4 A8])) -1
     (expr_list:REG_ARGS_SIZE (const_int 0 [0])
        (nil)))

(nil)

While this define_split has a bug (by matching sp, allowing to set the stack temporarily in an inconsistent state by using sp as a temporary for the symbol), I doubt that's the actual bug causing internal inconsistency within gcc.  Anyway:

(gdb) r -fpreprocessed pr50251.i -melf -quiet -dumpbase pr50251.c -auxbase-strip pr50251.s -O2 -version -fno-diagnostics-show-caret -fdiagnostics-color=never -o pr50251.s
GNU C (GCC) version 4.9.0 20131223 (experimental) [trunk revision 206176] (cris-elf)
        compiled by GNU C version 4.4.4 20100630 (Red Hat 4.4.4-10), GMP version 4.3.0, MPFR version 2.4.1, MPC version 0.8
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
GNU C (GCC) version 4.9.0 20131223 (experimental) [trunk revision 206176] (cris-elf)
        compiled by GNU C version 4.4.4 20100630 (Red Hat 4.4.4-10), GMP version 4.3.0, MPFR version 2.4.1, MPC version 0.8
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
Compiler executable checksum: cc4b37aa04284e09676146c2c3d35a20

Breakpoint 1, fancy_abort (file=0xd4f878 "/tmp/hpautotest-gcc1/gcc/gcc/expr.c", line=3978, 
    function=0xd50d50 "fixup_args_size_notes") at /tmp/hpautotest-gcc1/gcc/gcc/diagnostic.c:1182
1182    {
Missing separate debuginfos, use: debuginfo-install glibc-2.11.1-1.x86_64 libgcc-4.4.4-10.fc12.x86_64 libstdc++-4.4.4-10.fc12.x86_64
(gdb) up
#1  0x0000000000698222 in fixup_args_size_notes (prev=0x0, last=<value optimized out>, 
    end_args_size=<value optimized out>) at /tmp/hpautotest-gcc1/gcc/gcc/expr.c:3978
3978          gcc_assert (!saw_unknown);
(gdb) p prev
(gdb) p prev
$1 = (rtx_def *) 0x0
(gdb) p last
$2 = <value optimized out>
(gdb) up
#2  0x000000000067aefa in try_split (pat=<value optimized out>, trial=0x7ffff7ea47e0, last=1)
    at /tmp/hpautotest-gcc1/gcc/gcc/emit-rtl.c:3602
3602              fixup_args_size_notes (NULL_RTX, insn_last, INTVAL (XEXP (note, 0)));
(gdb) p insn_last
$3 = (rtx_def *) 0x7ffff7ea4c60
(gdb) p note
$4 = (rtx_def *) 0x7ffff7ea2df8
(gdb) pr
(expr_list:REG_ARGS_SIZE (const_int 0 [0])
    (nil))
(gdb) call debug_rtx_range ($3, 0)
(insn 34 33 0 (set (reg/f:SI 14 sp)
        (mem/f/c:SI (reg/f:SI 14 sp) [2 p+0 S4 A8])) -1
     (expr_list:REG_ARGS_SIZE (const_int 0 [0])
        (nil)))

(nil)

(gdb) bt
#0  fancy_abort (file=0xd4f878 "/tmp/hpautotest-gcc1/gcc/gcc/expr.c", line=3978, 
    function=0xd50d50 "fixup_args_size_notes") at /tmp/hpautotest-gcc1/gcc/gcc/diagnostic.c:1182
#1  0x0000000000698222 in fixup_args_size_notes (prev=0x0, last=<value optimized out>, 
    end_args_size=<value optimized out>) at /tmp/hpautotest-gcc1/gcc/gcc/expr.c:3978
#2  0x000000000067aefa in try_split (pat=<value optimized out>, trial=0x7ffff7ea47e0, last=1)
    at /tmp/hpautotest-gcc1/gcc/gcc/emit-rtl.c:3602
#3  0x0000000000886e62 in split_insn (insn=0x7ffff7ea47e0) at /tmp/hpautotest-gcc1/gcc/gcc/recog.c:2850
#4  0x0000000000887105 in split_all_insns () at /tmp/hpautotest-gcc1/gcc/gcc/recog.c:2940
#5  0x00000000008871d3 in rest_of_handle_split_after_reload (this=<value optimized out>)
    at /tmp/hpautotest-gcc1/gcc/gcc/recog.c:3889
#6  (anonymous namespace)::pass_split_after_reload::execute (this=<value optimized out>)
    at /tmp/hpautotest-gcc1/gcc/gcc/recog.c:3918
#7  0x000000000086680a in execute_one_pass (pass=0x1171600) at /tmp/hpautotest-gcc1/gcc/gcc/passes.c:2226
#8  0x0000000000866a86 in execute_pass_list (pass=0x1171600) at /tmp/hpautotest-gcc1/gcc/gcc/passes.c:2279
#9  0x0000000000866a98 in execute_pass_list (pass=0x11714e0) at /tmp/hpautotest-gcc1/gcc/gcc/passes.c:2280
#10 0x0000000000866a98 in execute_pass_list (pass=0x11703a0) at /tmp/hpautotest-gcc1/gcc/gcc/passes.c:2280
#11 0x00000000005f3699 in expand_function (node=0x7ffff7eb5000) at /tmp/hpautotest-gcc1/gcc/gcc/cgraphunit.c:1763
#12 0x00000000005f557d in expand_all_functions () at /tmp/hpautotest-gcc1/gcc/gcc/cgraphunit.c:1897
#13 compile () at /tmp/hpautotest-gcc1/gcc/gcc/cgraphunit.c:2241
#14 0x00000000005f6c6a in finalize_compilation_unit () at /tmp/hpautotest-gcc1/gcc/gcc/cgraphunit.c:2318
#15 0x00000000004a90f3 in c_write_global_declarations () at /tmp/hpautotest-gcc1/gcc/gcc/c/c-decl.c:10400
#16 0x00000000008e560d in compile_file () at /tmp/hpautotest-gcc1/gcc/gcc/toplev.c:561
#17 0x00000000008e6826 in do_compile (argc=15, argv=0x7fffffffe028) at /tmp/hpautotest-gcc1/gcc/gcc/toplev.c:1887
#18 toplev_main (argc=15, argv=0x7fffffffe028) at /tmp/hpautotest-gcc1/gcc/gcc/toplev.c:1963
#19 0x00000037d421eb1d in __libc_start_main () from /lib64/libc.so.6
#20 0x00000000004952c9 in _start ()
(gdb) up
#3  0x0000000000886e62 in split_insn (insn=0x7ffff7ea47e0) at /tmp/hpautotest-gcc1/gcc/gcc/recog.c:2850
2850      rtx last = try_split (PATTERN (insn), insn, 1);
(gdb) p insn
$5 = (rtx_def *) 0x7ffff7ea47e0
(gdb) pr
(insn 14 13 32 2 (set (reg/f:SI 14 sp)
        (mem/f/c:SI (symbol_ref:SI ("p") <var_decl 0x7ffff7eb2000 p>) [2 p+0 S4 A8])) /tmp/hpautotest-gcc1/gcc/gcc/testsuite/gcc.dg/pr50251.c:15 37 {*movsi_internal}
     (expr_list:REG_ARGS_SIZE (const_int 0 [0])
        (nil)))
(gdb) up
#4  0x0000000000887105 in split_all_insns () at /tmp/hpautotest-gcc1/gcc/gcc/recog.c:2940
2940                      if (split_insn (insn))
(gdb) p insn
$6 = (rtx_def *) 0x7ffff7ea47e0
(failing sequence trying to call get_insns() omitted, instead using the equivalent)
(gdb) call debug_rtx_range ((&x_rtl)->emit.x_first_insn, 0)
(note 1 0 3 NOTE_INSN_DELETED)

(note 3 1 2 2 [bb 2] NOTE_INSN_BASIC_BLOCK)

(note 2 3 7 2 NOTE_INSN_FUNCTION_BEG)

(insn 7 2 8 2 (set (mem/f/c:SI (symbol_ref:SI ("p") <var_decl 0x7ffff7eb2000 p>) [2 p+0 S4 A8])
        (reg/f:SI 14 sp)) /tmp/hpautotest-gcc1/gcc/gcc/testsuite/gcc.dg/pr50251.c:13 37 {*movsi_internal}
     (nil))

(note 8 7 9 2 NOTE_INSN_DELETED)

(insn 9 8 31 2 (set (reg/f:SI 0 r0 [31])
        (symbol_ref:SI ("bar") [flags 0x41] <function_decl 0x7ffff7ea1a00 bar>)) /tmp/hpautotest-gcc1/gcc/gcc/testsuite/
gcc.dg/pr50251.c:14 37 {*movsi_internal}
     (expr_list:REG_EQUIV (symbol_ref:SI ("bar") [flags 0x41] <function_decl 0x7ffff7ea1a00 bar>)
        (nil)))

(insn 31 9 10 2 (set (reg:SI 10 r10)
        (const_int -4 [0xfffffffffffffffc])) /tmp/hpautotest-gcc1/gcc/gcc/testsuite/gcc.dg/pr50251.c:14 37 {*movsi_internal}
     (nil))

(insn 10 31 11 2 (set (reg:SI 10 r10)
        (plus:SI (reg:SI 10 r10)
            (reg/f:SI 8 r8))) /tmp/hpautotest-gcc1/gcc/gcc/testsuite/gcc.dg/pr50251.c:14 74 {*addsi3_non_v32}
     (expr_list:REG_EQUAL (plus:SI (reg/f:SI 8 r8)
            (const_int -4 [0xfffffffffffffffc]))
        (nil)))

(call_insn 11 10 12 2 (parallel [
            (call (mem:QI (reg/f:SI 0 r0 [31]) [0 bar S1 A8])
                (const_int 0 [0]))
            (clobber (reg:SI 16 srp))
        ]) /tmp/hpautotest-gcc1/gcc/gcc/testsuite/gcc.dg/pr50251.c:14 220 {*expanded_call_non_v32}
     (nil)
    (expr_list:REG_UNUSED (use (reg:SI 10 r10))
        (nil)))

(insn 12 11 13 2 (clobber (mem:BLK (scratch) [0  A8])) /tmp/hpautotest-gcc1/gcc/gcc/testsuite/gcc.dg/pr50251.c:15 -1
     (nil))

(insn 13 12 14 2 (clobber (mem:BLK (reg/f:SI 14 sp) [0  A8])) /tmp/hpautotest-gcc1/gcc/gcc/testsuite/gcc.dg/pr50251.c:15 -1
     (nil))

(insn 14 13 32 2 (set (reg/f:SI 14 sp)
        (mem/f/c:SI (symbol_ref:SI ("p") <var_decl 0x7ffff7eb2000 p>) [2 p+0 S4 A8])) /tmp/hpautotest-gcc1/gcc/gcc/testsuite/gcc.dg/pr50251.c:15 37 {*movsi_internal}
     (expr_list:REG_ARGS_SIZE (const_int 0 [0])
        (nil)))

(insn 32 14 17 2 (set (reg:SI 10 r10)
        (const_int -4 [0xfffffffffffffffc])) /tmp/hpautotest-gcc1/gcc/gcc/testsuite/gcc.dg/pr50251.c:16 37 {*movsi_internal}
     (nil))

(insn 17 32 18 2 (set (reg:SI 10 r10)
        (plus:SI (reg:SI 10 r10)
            (reg/f:SI 8 r8))) /tmp/hpautotest-gcc1/gcc/gcc/testsuite/gcc.dg/pr50251.c:16 74 {*addsi3_non_v32}
     (expr_list:REG_EQUAL (plus:SI (reg/f:SI 8 r8)
            (const_int -4 [0xfffffffffffffffc]))
        (nil)))

(call_insn 18 17 23 2 (parallel [
            (call (mem:QI (reg/f:SI 0 r0 [31]) [0 bar S1 A8])
                (const_int 0 [0]))
            (clobber (reg:SI 16 srp))
        ]) /tmp/hpautotest-gcc1/gcc/gcc/testsuite/gcc.dg/pr50251.c:16 220 {*expanded_call_non_v32}
     (nil)
    (expr_list:REG_UNUSED (use (reg:SI 10 r10))
        (nil)))

(insn 23 18 26 2 (set (reg/i:SI 10 r10)
        (const_int 0 [0])) /tmp/hpautotest-gcc1/gcc/gcc/testsuite/gcc.dg/pr50251.c:18 37 {*movsi_internal}
     (nil))

(insn 26 23 29 2 (use (reg/i:SI 10 r10)) /tmp/hpautotest-gcc1/gcc/gcc/testsuite/gcc.dg/pr50251.c:18 -1
     (nil))

(note 29 26 0 NOTE_INSN_DELETED)

(nil) 

(gdb) 


Author of (all) suspect commits in revision range CC:ed.
Comment 1 Jakub Jelinek 2013-12-23 13:09:21 UTC
Are you sure it didn't fail before r205026 as well, because what my patch did was essentially restore the old behavior unless strictly necessary (then it would keep the r205026+ behavior).
Comment 2 Hans-Peter Nilsson 2013-12-23 14:26:14 UTC
(In reply to Jakub Jelinek from comment #1)
> Are you sure it didn't fail before r205026 as well, because what my patch
> did was essentially restore the old behavior unless strictly necessary (then
> it would keep the r205026+ behavior).

Sounds like you have a good grip on the circumstances. :)
There was no reason to check for earlier failure ranges, but it certainly failed before and with r205023, started passing with r205046 up until as noted.
So, I guess this will be a low-priority PR, particularly as it uses an odd builtin-construct very unlikely to be seen in user code - not to mention it will also be hidden behind a target-specific fix.
Comment 3 Jakub Jelinek 2013-12-23 18:39:26 UTC
So is this actually a regression then (I mean, has it worked in 4.8 or 4.7 etc.)?
Comment 4 Hans-Peter Nilsson 2013-12-23 22:19:18 UTC
(In reply to Jakub Jelinek from comment #3)
> So is this actually a regression then (I mean, has it worked in 4.8 or 4.7
> etc.)?

That's not the definition.  At one point it work on trunk (4.9) thus it's a regression.
Comment 5 Hans-Peter Nilsson 2013-12-23 22:19:38 UTC
The actual bug causing the ICE is that the combination of expr.c:find_args_size_adjust and expr.c:fixup_args_size_notes\
 can't handle a define_split matching for the stack-adjustment assignment instruction emitted by __builtin_stack_restor\
e.

I'm going to mark my commit for the CRIS port with this PR number (since it fixes the regression per se), but it will j\
ust remove the define_split part happening for the CRIS port; the bug is still there so the PR should not be closed.
Though, I'll change the title.
Comment 6 Hans-Peter Nilsson 2013-12-23 22:33:54 UTC
Author: hp
Date: Mon Dec 23 22:33:52 2013
New Revision: 206187

URL: http://gcc.gnu.org/viewcvs?rev=206187&root=gcc&view=rev
Log:
	PR middle-end/59584
	* config/cris/predicates.md (cris_nonsp_register_operand):
	New define_predicate.
	* config/cris/cris.md: Replace register_operand with
	cris_nonsp_register_operand for destinations in all
	define_splits where a register is set more than once.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/cris/cris.md
    trunk/gcc/config/cris/predicates.md
Comment 7 Hans-Peter Nilsson 2014-01-08 00:53:04 UTC
With the latest backports by Jakub (206335:206398], it regressed on the 4.8 branch.
Comment 8 Jakub Jelinek 2014-01-08 10:25:22 UTC
I still think this is not the correct definition of regression, I believe regression is regressing against released compiler version.  If somebody commits a wrong change that magically fixes something and has to be reverted the next day, the magically fixed issue doesn't all of sudden become a regression because of that.  Not to mention that Richard's change has not been a fix for that, just unrelated change that made the problem in the cris port latent.
Comment 9 Hans-Peter Nilsson 2014-01-08 14:12:26 UTC
(In reply to Jakub Jelinek from comment #8)
> I still think this is not the correct definition of regression, I believe
> regression is regressing against released compiler version.  If somebody
> commits a wrong change that magically fixes something and has to be reverted
> the next day, the magically fixed issue doesn't all of sudden become a
> regression because of that.

Your suggestion to split up that definition would require *separate* definitions, markings and other related complications.  Let's take that to the list if you insist.

> Not to mention that Richard's change has not
> been a fix for that, just unrelated change that made the problem in the cris
> port latent.

I see, on 2013-12-04, r205685:205709 for the 4.8 branch.
Comment 10 Hans-Peter Nilsson 2014-01-09 00:23:25 UTC
Author: hp
Date: Thu Jan  9 00:23:22 2014
New Revision: 206453

URL: http://gcc.gnu.org/viewcvs?rev=206453&root=gcc&view=rev
Log:
	Backport from mainline
	2013-12-23  Hans-Peter Nilsson  <hp@axis.com>

	PR middle-end/59584
	* config/cris/predicates.md (cris_nonsp_register_operand):
	New define_predicate.
	* config/cris/cris.md: Replace register_operand with
	cris_nonsp_register_operand for destinations in all
	define_splits where a register is set more than once.

Modified:
    branches/gcc-4_8-branch/gcc/ChangeLog
    branches/gcc-4_8-branch/gcc/config/cris/cris.md
    branches/gcc-4_8-branch/gcc/config/cris/predicates.md