Bug 83480 - ICE in create_block_for_bookkeeping, at sel-sched.c:4557
Summary: ICE in create_block_for_bookkeeping, at sel-sched.c:4557
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: debug (show other bugs)
Version: 8.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks: selective-scheduling
  Show dependency treegraph
 
Reported: 2017-12-19 08:25 UTC by Arseny Solokha
Modified: 2018-04-09 11:36 UTC (History)
5 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2017-12-19 00:00:00


Attachments
gcc8-pr83480.patch (940 bytes, patch)
2018-01-05 15:28 UTC, Jakub Jelinek
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Arseny Solokha 2017-12-19 08:25:01 UTC
gcc-8.0.0-alpha20171217 snapshot (r255766) ICEs when compiling the following snippet w/ -g -O2 (-O3, -Ofast) -fselective-scheduling2 -fsel-sched-pipelining -fgcse-sm -floop-parallelize-all -fno-tree-loop-im:

int cf, eq;

void
m8 (long long int yl, int nn)
{
  while (nn < 1)
    {
      cf = (yl / nn) >= -1;
      ++nn;
    }

  while (cf < 1)
    {
      for (eq = 0; eq < 2; eq++)
        {
        }
      ++cf;
    }
}

% powerpc-e300c3-linux-gnu-gcc-8.0.0-alpha20171217 -g -O2 -fselective-scheduling2 -fsel-sched-pipelining -fgcse-sm -floop-parallelize-all -fno-tree-loop-im -c m4vfwtte.c
during RTL pass: sched2
m4vfwtte.c: In function 'm8':
m4vfwtte.c:19:1: internal compiler error: in create_block_for_bookkeeping, at sel-sched.c:4557
 }
 ^
0xbe4c22 create_block_for_bookkeeping
	/var/tmp/portage/cross-powerpc-e300c3-linux-gnu/gcc-8.0.0_alpha20171217/work/gcc-8-20171217/gcc/sel-sched.c:4557
0xbe4c22 find_place_for_bookkeeping
	/var/tmp/portage/cross-powerpc-e300c3-linux-gnu/gcc-8.0.0_alpha20171217/work/gcc-8-20171217/gcc/sel-sched.c:4694
0xbe4c22 generate_bookkeeping_insn
	/var/tmp/portage/cross-powerpc-e300c3-linux-gnu/gcc-8.0.0_alpha20171217/work/gcc-8-20171217/gcc/sel-sched.c:4794
0xbe4c22 move_op_at_first_insn
	/var/tmp/portage/cross-powerpc-e300c3-linux-gnu/gcc-8.0.0_alpha20171217/work/gcc-8-20171217/gcc/sel-sched.c:6067
0xbe551b code_motion_path_driver
	/var/tmp/portage/cross-powerpc-e300c3-linux-gnu/gcc-8.0.0_alpha20171217/work/gcc-8-20171217/gcc/sel-sched.c:6659
0xbe5f01 code_motion_process_successors
	/var/tmp/portage/cross-powerpc-e300c3-linux-gnu/gcc-8.0.0_alpha20171217/work/gcc-8-20171217/gcc/sel-sched.c:6346
0xbe5f01 code_motion_path_driver
	/var/tmp/portage/cross-powerpc-e300c3-linux-gnu/gcc-8.0.0_alpha20171217/work/gcc-8-20171217/gcc/sel-sched.c:6612
0xbe5f01 code_motion_process_successors
	/var/tmp/portage/cross-powerpc-e300c3-linux-gnu/gcc-8.0.0_alpha20171217/work/gcc-8-20171217/gcc/sel-sched.c:6346
0xbe5f01 code_motion_path_driver
	/var/tmp/portage/cross-powerpc-e300c3-linux-gnu/gcc-8.0.0_alpha20171217/work/gcc-8-20171217/gcc/sel-sched.c:6612
0xbe6765 move_op
	/var/tmp/portage/cross-powerpc-e300c3-linux-gnu/gcc-8.0.0_alpha20171217/work/gcc-8-20171217/gcc/sel-sched.c:6704
0xbe6765 move_exprs_to_boundary
	/var/tmp/portage/cross-powerpc-e300c3-linux-gnu/gcc-8.0.0_alpha20171217/work/gcc-8-20171217/gcc/sel-sched.c:5227
0xbe6765 schedule_expr_on_boundary
	/var/tmp/portage/cross-powerpc-e300c3-linux-gnu/gcc-8.0.0_alpha20171217/work/gcc-8-20171217/gcc/sel-sched.c:5440
0xbea7c8 fill_insns
	/var/tmp/portage/cross-powerpc-e300c3-linux-gnu/gcc-8.0.0_alpha20171217/work/gcc-8-20171217/gcc/sel-sched.c:5582
0xbec53e schedule_on_fences
	/var/tmp/portage/cross-powerpc-e300c3-linux-gnu/gcc-8.0.0_alpha20171217/work/gcc-8-20171217/gcc/sel-sched.c:7356
0xbec53e sel_sched_region_2
	/var/tmp/portage/cross-powerpc-e300c3-linux-gnu/gcc-8.0.0_alpha20171217/work/gcc-8-20171217/gcc/sel-sched.c:7494
0xbeed31 sel_sched_region_1
	/var/tmp/portage/cross-powerpc-e300c3-linux-gnu/gcc-8.0.0_alpha20171217/work/gcc-8-20171217/gcc/sel-sched.c:7536
0xbeed31 sel_sched_region(int)
	/var/tmp/portage/cross-powerpc-e300c3-linux-gnu/gcc-8.0.0_alpha20171217/work/gcc-8-20171217/gcc/sel-sched.c:7637
0xbef401 run_selective_scheduling()
	/var/tmp/portage/cross-powerpc-e300c3-linux-gnu/gcc-8.0.0_alpha20171217/work/gcc-8-20171217/gcc/sel-sched.c:7713
0xbc640d rest_of_handle_sched2
	/var/tmp/portage/cross-powerpc-e300c3-linux-gnu/gcc-8.0.0_alpha20171217/work/gcc-8-20171217/gcc/sched-rgn.c:3729
0xbc640d execute
	/var/tmp/portage/cross-powerpc-e300c3-linux-gnu/gcc-8.0.0_alpha20171217/work/gcc-8-20171217/gcc/sched-rgn.c:3873
Comment 1 Aldy Hernandez 2017-12-19 20:37:41 UTC
Confirmed on gcc110 with:

~/src/gcc/configure --disable-bootstrap --disable-multilib --enable-languages=c  --with-isl=$HOME/bld/isl-0.15/install
...
...
LD_LIBRARY_PATH=~/bld/isl-0.15/install/lib/ ./cc1 a.c -quiet -g -O2 -fselective-scheduling2 -fsel-sched-pipelining -fgcse-sm -floop-parallelize-all -fno-tree-loop-im -m32
Comment 2 Arseny Solokha 2017-12-23 05:55:54 UTC
This is not target-specific. The following snippet compiled w/ -g -O2 (-O3, -Ofast) -fselective-scheduling2 -ftree-vectorize -freorder-blocks-algorithm=simple -fnon-call-exceptions -fno-guess-branch-probability -fno-peephole2 -fno-tree-sink -fno-tree-scev-cprop reproduces the issue for x86_64:

signed char jx, dl;

void
m9 (int zk, int f9)
{
  for (jx = 1; jx != 0; ++jx)
    {
    }

  for (;;)
    {
      int wj;

      dl %= (f9 != 0 && jx != 0) + 1;
      if (jx != 0)
        f9 = dl;

      for (wj = 0; wj < 50; ++wj)
        ++zk;

      if (jx < 1)
        {
          while (zk != 0)
            {
            }

          jx /= 0;
        }
    }
}
Comment 3 Arseny Solokha 2017-12-25 03:27:32 UTC
Likely a duplicate of PR80463.
Comment 4 Jakub Jelinek 2018-01-02 14:08:34 UTC
Started with r255607 (at least the #c2 testcase).
Comment 5 Jakub Jelinek 2018-01-02 14:29:45 UTC
The ICE goes away with -gno-statement-frontiers, perhaps if sel-sched is unfixable we should disable statement frontiers in addition to var-tracking-assignments that we already disable for sel-sched.
Comment 6 Alexandre Oliva 2018-01-05 14:56:11 UTC
It seems like sel-sched really can't deal with debug insns; I agree it makes sense to disable all sorts of debug insns when sel-sched is selected/enabled.
Comment 7 Jakub Jelinek 2018-01-05 15:19:38 UTC
Apparently we only disable -fvar-tracking-assignments by default if sel-sched, not disable it unconditionally.
So, while we could and should change:
  if (debug_nonbind_markers_p == AUTODETECT_VALUE)
    debug_nonbind_markers_p = optimize && debug_info_level >= DINFO_LEVEL_NORMAL
      && (write_symbols == DWARF2_DEBUG || write_symbols == VMS_AND_DWARF2_DEBUG);
to
  if (debug_nonbind_markers_p == AUTODETECT_VALUE)
    debug_nonbind_markers_p
      = (optimize
         && debug_info_level >= DINFO_LEVEL_NORMAL
         && (write_symbols == DWARF2_DEBUG
             || write_symbols == VMS_AND_DWARF2_DEBUG)
         && !(flag_selective_scheduling || flag_selective_scheduling2));
the testcase would still ICE with -gstatement-frontiers.
Comment 8 Jakub Jelinek 2018-01-05 15:28:06 UTC
Created attachment 43045 [details]
gcc8-pr83480.patch

In any case, I think this patch is a small step towards the right direction.
Comment 9 Alexandre Oliva 2018-01-05 18:21:35 UTC
didn't we print a warning if we found VTA and sel-sched enabled at the same time, too?  I guess that might be useful in this case as well.  (thanks for taking care of this!)
Comment 10 Jakub Jelinek 2018-01-06 07:49:05 UTC
Author: jakub
Date: Sat Jan  6 07:48:31 2018
New Revision: 256309

URL: https://gcc.gnu.org/viewcvs?rev=256309&root=gcc&view=rev
Log:
	PR debug/83480
	* toplev.c (process_options): Don't enable debug_nonbind_markers_p
	by default if flag_selective_schedling{,2}.  Formatting fixes.

	* gcc.dg/pr83480.c: New test.

Added:
    trunk/gcc/testsuite/gcc.dg/pr83480.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/toplev.c
Comment 11 Jakub Jelinek 2018-01-06 07:50:12 UTC
Not fully fixed yet, the testcase still ICEs with:
-O2 -g -gstatement-frontiers -fselective-scheduling2 -fsel-sched-pipelining -fgcse-sm -floop-parallelize-all -fno-tree-loop-im
Comment 12 Andrey Belevantsev 2018-01-30 11:00:28 UTC
(In reply to Jakub Jelinek from comment #11)
> Not fully fixed yet, the testcase still ICEs with:
> -O2 -g -gstatement-frontiers -fselective-scheduling2 -fsel-sched-pipelining
> -fgcse-sm -floop-parallelize-all -fno-tree-loop-im

I couldn't make testcase from #c2 to ICE with those, so I've checked out the reported rev. 255766 and reproduced the ICE from that comment.  That one is fixed with the same patch as for PR 80463 #c3 and PR 83972.
Comment 13 Richard Biener 2018-03-27 09:41:51 UTC
It's no longer a regression now since -gstatement-frontiers is new and now required to trigger the ICE.
Comment 14 Andrey Belevantsev 2018-04-09 10:20:23 UTC
Author: abel
Date: Mon Apr  9 10:19:50 2018
New Revision: 259231

URL: https://gcc.gnu.org/viewcvs?rev=259231&root=gcc&view=rev
Log:
       PR rtl-optimization/80463
       PR rtl-optimization/83972
       PR rtl-optimization/83480

       * sel-sched-ir.c (has_dependence_note_mem_dep): Take into account the
       correct producer for the insn.
       (tidy_control_flow): Fixup seqnos in case of debug insns.

       * gcc.dg/pr80463.c: New test.
       * g++.dg/pr80463.C: Likewise.
       * gcc.dg/pr83972.c: Likewise.


Added:
    trunk/gcc/testsuite/g++.dg/pr80463.C
    trunk/gcc/testsuite/gcc.dg/pr80463.c
    trunk/gcc/testsuite/gcc.dg/pr83972.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/sel-sched-ir.c
    trunk/gcc/testsuite/ChangeLog
Comment 15 Andrey Belevantsev 2018-04-09 11:36:32 UTC
Fixed on trunk.