Hi all, In this PR there are tons of ICEs throughout the aarch64 testsuite when compiled with -fselective-scheduling -fselective-scheduling2 --param=sched-autopref-queue-depth=10. Admittedly that's a rare combination as we don't use selective scheduling by default on aarch64. The problem is that after my patch to enable auto-prefetcher modelling in the scheduler for aarch64 we now call into autopref_multipass_dfa_lookahead_guard from the aarch64 backend hook. However, autopref_multipass_dfa_lookahead_guard only makes sense when doing normal scheduling, the necessary structs are not setup properly otherwise. So we end up trying to access the insn_queue, which is either NULL, or contains garbage because it has not been properly initialised from earlier.
The solution in this patch is to exit early from autopref_multipass_dfa_lookahead_guard if insn_queue is NULL. I'm using insn_queue as an indication that we entered from haifa-sched because I couldn't see any other variable that keeps track of which scheduling approach we're using. Also, I needed a hunk to reset insn_queue to NULL in haifa_sched_finish so that if we run selective scheduling after a round of normal haifa scheduling (for example after sched fusion on aarch64) we don't end up accessing bogus memory locations from insn_queue. With this patch a testsuite with -fselective-scheduling/-fselective-scheduling2/--param=sched-autopref-queue-depth=10 runs sanely rather than ICE'ing in almost every test. Bootstrapped and tested in a normal configuration on arm, aarch64 and x86_64 too. Ok for trunk? Thanks, Kyrill 2015-11-09 Kyrylo Tkachov <kyrylo.tkac...@arm.com> PR rtl-optimization/68236 * haifa-sched.c (autopref_multipass_dfa_lookahead_guard): Return 0 if insn_queue doesn't exist. (haifa_sched_finish): Reset insn_queue to NULL.
commit f7995307c6f66bd4be3895f6cd7e5d14d30b7fe2 Author: Kyrylo Tkachov <kyrylo.tkac...@arm.com> Date: Fri Nov 6 14:39:38 2015 +0000 [haifa-sched] PR rtl-optimization/68236: Exit early from autoprefetcher lookahead if not in haifa sched diff --git a/gcc/haifa-sched.c b/gcc/haifa-sched.c index caadc11..a926f4d 100644 --- a/gcc/haifa-sched.c +++ b/gcc/haifa-sched.c @@ -5806,7 +5806,10 @@ autopref_multipass_dfa_lookahead_guard (rtx_insn *insn1, int ready_index) { int r = 0; - if (PARAM_VALUE (PARAM_SCHED_AUTOPREF_QUEUE_DEPTH) <= 0) + /* Exit early if the param forbids this or if we're not entering here through + normal haifa scheduling. This can happen if selective scheduling is + explicitly enabled. */ + if (!insn_queue || PARAM_VALUE (PARAM_SCHED_AUTOPREF_QUEUE_DEPTH) <= 0) return 0; if (sched_verbose >= 2 && ready_index == 0) @@ -7483,6 +7486,7 @@ haifa_sched_finish (void) sched_deps_finish (); sched_finish_luids (); current_sched_info = NULL; + insn_queue = NULL; sched_finish (); }