Bug 88347 - ICE in begin_move_insn, at sched-ebb.c:175
Summary: ICE in begin_move_insn, at sched-ebb.c:175
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: rtl-optimization (show other bugs)
Version: 9.0
: P2 normal
Target Milestone: ---
Assignee: acsawdey
URL:
Keywords: ice-on-valid-code
: 88423 (view as bug list)
Depends on:
Blocks:
 
Reported: 2018-12-04 06:24 UTC by Arseny Solokha
Modified: 2019-03-26 00:42 UTC (History)
2 users (show)

See Also:
Host:
Target: powerpc-*-linux-gnu
Build:
Known to work:
Known to fail:
Last reconfirmed: 2018-12-12 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Arseny Solokha 2018-12-04 06:24:30 UTC
gcc-9.0.0-alpha20181202 snapshot (r266729) ICEs when compiling gcc/testsuite/gcc.target/powerpc/ppc-switch-2.c w/ -mcpu=603e -O1 -fsched-stalled-insns -fsched2-use-superblocks -fschedule-insns2 -fno-dce -fno-guess-branch-probability --param max-cse-insns=4:

% powerpc-e300c3-linux-gnu-gcc-9.0.0-alpha20181202 -mcpu=603e -O1 -fsched-stalled-insns -fsched2-use-superblocks -fschedule-insns2 -fno-dce -fno-guess-branch-probability --param max-cse-insns=4 -c gcc/testsuite/gcc.target/powerpc/ppc-switch-2.c
during RTL pass: sched2                                                                                                                
gcc/testsuite/gcc.target/powerpc/ppc-switch-2.c: In function 'test_switch':
gcc/testsuite/gcc.target/powerpc/ppc-switch-2.c:32:1: internal compiler error: in begin_move_insn, at sched-ebb.c:175
   32 | }
      | ^
0x759da8 begin_move_insn
	/var/tmp/portage/cross-powerpc-e300c3-linux-gnu/gcc-9.0.0_alpha20181202/work/gcc-9-20181202/gcc/sched-ebb.c:175
0x145ec0b commit_schedule
	/var/tmp/portage/cross-powerpc-e300c3-linux-gnu/gcc-9.0.0_alpha20181202/work/gcc-9-20181202/gcc/haifa-sched.c:6228
0x1469a90 schedule_block(basic_block_def**, void*)
	/var/tmp/portage/cross-powerpc-e300c3-linux-gnu/gcc-9.0.0_alpha20181202/work/gcc-9-20181202/gcc/haifa-sched.c:7065
0x14f47e9 schedule_ebb(rtx_insn*, rtx_insn*, bool)
	/var/tmp/portage/cross-powerpc-e300c3-linux-gnu/gcc-9.0.0_alpha20181202/work/gcc-9-20181202/gcc/sched-ebb.c:537
0x14f4f64 schedule_ebbs()
	/var/tmp/portage/cross-powerpc-e300c3-linux-gnu/gcc-9.0.0_alpha20181202/work/gcc-9-20181202/gcc/sched-ebb.c:657
0xcc2eac rest_of_handle_sched2
	/var/tmp/portage/cross-powerpc-e300c3-linux-gnu/gcc-9.0.0_alpha20181202/work/gcc-9-20181202/gcc/sched-rgn.c:3738
0xcc2eac execute
	/var/tmp/portage/cross-powerpc-e300c3-linux-gnu/gcc-9.0.0_alpha20181202/work/gcc-9-20181202/gcc/sched-rgn.c:3876
Comment 1 Segher Boessenkool 2018-12-12 22:31:16 UTC
Confirmed.

We here have an unconditional branch that is not followed by a barrier:
first there is a label and a jump table, after *that* is the barrier.

Is this correct RTL?  If so,

===
diff --git a/gcc/sched-ebb.c b/gcc/sched-ebb.c
index 49ae286..566cb24 100644
--- a/gcc/sched-ebb.c
+++ b/gcc/sched-ebb.c
@@ -172,7 +172,11 @@ begin_move_insn (rtx_insn *insn, rtx_insn *last)
        if (e)
          gcc_checking_assert (NOTE_P (x) || LABEL_P (x));
        else
-         gcc_checking_assert (BARRIER_P (x));
+         {
+           if (LABEL_P (x) && JUMP_TABLE_DATA_P (NEXT_INSN (x)))
+             x = NEXT_INSN (NEXT_INSN (x));
+           gcc_checking_assert (BARRIER_P (x));
+         }
       }
 
       if (e)
===

fixes it.
Comment 2 David Malcolm 2019-01-22 18:29:27 UTC
*** Bug 88423 has been marked as a duplicate of this bug. ***
Comment 3 David Malcolm 2019-01-22 19:06:15 UTC
Segher's fix appears superior to mine; am testing it now...
Comment 4 David Malcolm 2019-01-23 14:23:21 UTC
Candidate patch: https://gcc.gnu.org/ml/gcc-patches/2019-01/msg01372.html
(though see the concerns in that thread; un-assigning myself)
Comment 5 Jeffrey A. Law 2019-03-25 23:34:08 UTC
Author: law
Date: Mon Mar 25 23:33:36 2019
New Revision: 269928

URL: https://gcc.gnu.org/viewcvs?rev=269928&root=gcc&view=rev
Log:
	PR rtl-optimization/88347
	PR rtl-optimization/88423
	* sched-deps.c (sched_analyze_insn): Take into account that for
	tablejumps the barrier appears after a label and a jump_table_data.

	* gcc.c-torture/compile/pr88347.c: New test.
	* gcc.c-torture/compile/pr88423.c: New test.

Added:
    trunk/gcc/testsuite/gcc.c-torture/compile/pr88347.c
    trunk/gcc/testsuite/gcc.c-torture/compile/pr88423.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/sched-deps.c
    trunk/gcc/testsuite/ChangeLog
Comment 6 Jeffrey A. Law 2019-03-26 00:42:42 UTC
Fixed on the trunk.