Bug 29128 - [4.2 Regression] ICE: in move_block_after_check, at haifa-sched.c:4337
Summary: [4.2 Regression] ICE: in move_block_after_check, at haifa-sched.c:4337
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: rtl-optimization (show other bugs)
Version: 4.2.0
: P1 normal
Target Milestone: 4.2.0
Assignee: Maxim Kuvyrkov
URL:
Keywords: ice-on-valid-code
Depends on: 28489
Blocks:
  Show dependency treegraph
 
Reported: 2006-09-18 13:36 UTC by Martin Michlmayr
Modified: 2006-10-06 21:51 UTC (History)
4 users (show)

See Also:
Host:
Target: ia64-linux-gnu
Build:
Known to work: 4.0.3 4.1.1
Known to fail: 4.2.0
Last reconfirmed: 2006-09-18 14:34:50


Attachments
Patch. (964 bytes, patch)
2006-09-23 18:30 UTC, Maxim Kuvyrkov
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Michlmayr 2006-09-18 13:36:51 UTC
I get the following on ia64, but not on e.g. x86_64.

tbm@coconut0:~$ /usr/lib/gcc-snapshot/bin/gcc -c -O2 erlang-beam_emu.c
erlang-beam_emu.c: In function 'process_main':
erlang-beam_emu.c:28: internal compiler error: in move_block_after_check, at haifa-sched.c:4337
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.
For Debian GNU/Linux specific bug reporting instructions,
see <URL:file:///usr/share/doc/gcc-4.1/README.Bugs>.
tbm@coconut0:~$ /usr/lib/gcc-snapshot/bin/gcc -c -O1 erlang-beam_emu.c
tbm@coconut0:~$ gcc-4.1 -c -O2 erlang-beam_emu.c
tbm@coconut0:~$
tbm@coconut0:~$ cat erlang-beam_emu.c
typedef unsigned long Eterm;
process_main (void)
{
  register Eterm x0;
  register Eterm *reg = ((void *) 0);
  register Eterm *I = ((void *) 0);
  static void *opcodes[] = {
      &&lb_allocate_heap_zero_III,
      &&lb_allocate_init_tIy, &&lb_allocate_zero_tt
  };
lb_allocate_heap_III:{
    Eterm *next;
    goto *(next);
  }
lb_allocate_heap_zero_III:{
  }
lb_allocate_init_tIy:{
  }
lb_allocate_zero_tt:{
    Eterm *next;
    {
      Eterm *tmp_ptr = ((Eterm *) (((x0)) - 0x1));
      (*(Eterm *) (((unsigned char *) reg) + (I[(0) + 1]))) = ((tmp_ptr)[0]);
      x0 = ((tmp_ptr)[1]);
    }
    goto *(next);
  }
}
Comment 1 Martin Michlmayr 2006-09-18 13:38:26 UTC
Note that this code was affected by PR28489 and while the fix for this PR fixed the other testcases, this shows the current, new ICE.
Comment 2 Steven Bosscher 2006-09-18 14:33:33 UTC
And this is a regression because...?
Comment 3 Steven Bosscher 2006-09-18 14:34:50 UTC
Because of PR28489.  Right.
Comment 4 Steven Bosscher 2006-09-23 15:14:38 UTC
This is where we ICE:

Breakpoint 1, fancy_abort (file=0xbfb788 "../../trunk/gcc/haifa-sched.c", line=4337,
    function=0xbfc0a0 "move_block_after_check") at ../../trunk/gcc/diagnostic.c:642
642       internal_error ("in %s, at %s:%d", function, trim_filename (file), line);
(gdb) up
#1  0x0000000000a721d5 in move_block_after_check (jump=0x2aaaaaf8f180)
    at ../../trunk/gcc/haifa-sched.c:4336
4336      gcc_assert (RECOVERY_BLOCK (jump)
(gdb) l
4331      jump_bb = BLOCK_FOR_INSN (jump);
4332      jump_bb_next = jump_bb->next_bb;
4333
4334      update_bb_for_insn (jump_bb);
4335
4336      gcc_assert (RECOVERY_BLOCK (jump)
4337                  || RECOVERY_BLOCK (BB_END (jump_bb_next)));
4338
4339      unlink_block (jump_bb_next);
4340      link_block (jump_bb_next, bb);
(gdb) p debug_rtx(jump)
(jump_insn 93 121 122 7 (set (pc)
        (reg:DI 326 b6)) 330 {indirect_jump} (nil)
    (expr_list:REG_DEAD (reg:DI 326 b6)
        (nil)))
$7 = void
(gdb) p h_i_d[93].recovery_block
$8 = (basic_block) 0x0
(gdb) p debug_bb(jump_bb_next)
;; basic block 8, loop depth 0, count 0
;; prev block 7, next block 1
;; pred:
;; succ:
;; Registers live at start:  (nil)
(note 122 93 94 8 [bb 8] NOTE_INSN_BASIC_BLOCK)
(note 94 122 96 7 [bb 7] NOTE_INSN_BASIC_BLOCK)
;; Registers live at end:  (nil)
$9 = void
(gdb) 

Comment 5 Maxim Kuvyrkov 2006-09-23 18:30:45 UTC
Created attachment 12315 [details]
Patch.

That's my bug, sorry.  The attached patch has only been tested on x86_64; sadly, I'll be able to run it on ia64 not before Monday.

2006-09-23  Maxim Kuvyrkov  <mkuvyrkov@ispras.ru>

	PR rtl-optimization/29128
	* sched-ebb.c (advance_target_bb): Use correct condition to
	allow interblock movement of speculation checks.
	* sched-int.h (IS_SPEC_BRANCY_CHECK_P): New macro.

2006-09-23  Maxim Kuvyrkov  <mkuvyrkov@ispras.ru>

	PR rtl-optimization/29128
	* gcc.c-torture/compile/pr29128.c: New test.
Comment 6 Maxim Kuvyrkov 2006-10-06 21:45:30 UTC
Subject: Bug 29128

Author: mkuvyrkov
Date: Fri Oct  6 21:45:13 2006
New Revision: 117515

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=117515
Log:
2006-10-06  Maxim Kuvyrkov  <mkuvyrkov@ispras.ru>

	PR rtl-optimization/29128
	* sched-int.h (IS_SPECULATION_BRANCHY_CHECK_P): New macro.
	* sched-ebb.c (advance_target_bb): Use it to fix condition to
	allow interblock movement of speculation checks.

	* gcc.c-torture/compile/pr29128.c: New test.

Added:
    trunk/gcc/testsuite/gcc.c-torture/compile/pr29128.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/sched-ebb.c
    trunk/gcc/sched-int.h
    trunk/gcc/testsuite/ChangeLog

Comment 7 Maxim Kuvyrkov 2006-10-06 21:51:36 UTC
Fixed by the above patch.