Hi! As the testcase shows, the sel-sched.c framework can't deal with debugging insns without causing -fcompare-debug failures, and I presume also with debug markers, with which it causes even ICEs right now.
The following patch just follows what we do for -fvar-tracking-assignments, disable it by default if -fselective-scheduling*. It isn't a complete fix, the testcase will still ICE with explicit -fselective-scheduling{,2} -gstatement-frontiers, but at least it won't ICE that often and even if the ICE is fixed, it is quite unlikely that debug marker handling would work with -fcompare-debug when other debug insns don't work with that. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2018-01-05 Jakub Jelinek <ja...@redhat.com> 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. --- gcc/toplev.c.jj 2018-01-03 10:19:54.453533845 +0100 +++ gcc/toplev.c 2018-01-05 16:20:56.130195110 +0100 @@ -1535,8 +1535,9 @@ process_options (void) flag_var_tracking_uninit = flag_var_tracking; if (flag_var_tracking_assignments == AUTODETECT_VALUE) - flag_var_tracking_assignments = flag_var_tracking - && !(flag_selective_scheduling || flag_selective_scheduling2); + flag_var_tracking_assignments + = (flag_var_tracking + && !(flag_selective_scheduling || flag_selective_scheduling2)); if (flag_var_tracking_assignments_toggle) flag_var_tracking_assignments = !flag_var_tracking_assignments; @@ -1550,8 +1551,12 @@ process_options (void) "var-tracking-assignments changes selective scheduling"); 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); + 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)); if (flag_tree_cselim == AUTODETECT_VALUE) { --- gcc/testsuite/gcc.dg/pr83480.c.jj 2018-01-05 16:24:14.444290629 +0100 +++ gcc/testsuite/gcc.dg/pr83480.c 2018-01-05 16:23:40.631274338 +0100 @@ -0,0 +1,32 @@ +/* PR debug/83480 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -g -fselective-scheduling2 -ftree-vectorize -freorder-blocks-algorithm=simple -fnon-call-exceptions -fno-guess-branch-probability -fno-peephole2 -fno-tree-sink -fno-tree-scev-cprop" } */ + +signed char a, b; + +void +foo (int x, int y) +{ + for (a = 1; a != 0; ++a) + ; + + for (;;) + { + int c; + + b %= (y != 0 && a != 0) + 1; + if (a != 0) + y = b; + + for (c = 0; c < 50; ++c) + ++x; + + if (a < 1) + { + while (x != 0) + ; + + a /= 0; /* { dg-warning "division by zero" } */ + } + } +} Jakub