From patchwork Mon Nov 9 16:31:58 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kyrylo Tkachov X-Patchwork-Id: 56261 Delivered-To: patch@linaro.org Received: by 10.112.155.196 with SMTP id vy4csp275557lbb; Mon, 9 Nov 2015 08:32:30 -0800 (PST) X-Received: by 10.50.6.36 with SMTP id x4mr20109109igx.61.1447086750461; Mon, 09 Nov 2015 08:32:30 -0800 (PST) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id qh9si11146004igb.88.2015.11.09.08.32.29 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Nov 2015 08:32:30 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-return-413299-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; spf=pass (google.com: domain of gcc-patches-return-413299-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-413299-patch=linaro.org@gcc.gnu.org; dkim=pass header.i=@gcc.gnu.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:content-type; q=dns; s=default; b=pnEwshkOSM+hHzHq47BKuwNCuCb9ZthqIxZZEZA6pFu 3SYoikNo+dS1OluB1WQwKHQIy5u0thL0WT76nkwlO8IgBEM5RvP4/gTbYRF9d93I Fq4Gt6UiVrnGE9if2J/wxrnpVpXv2O2eqpfX4wjtUrPuCayJDz83w/o9UNvMfyHw = DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:content-type; s=default; bh=NJSXBBSH8KYF3kxnvoMIXe0Zjbk=; b=BfUccKUUR6HHEqK5V Fz0Qn5z8Gmf97R0kCHrZVHQoDR8paN0fvjlB19v7rqPk0nZXSZ8mEwLUYgUyGICY 2+3ODO3VMzymiY7EHcFNisuBkpt/q3Sl8GgpXlQIiQFMZxkARyMtDBkxwo81AMm+ gewL2S5mRRui3NmtWV98gex6kg= Received: (qmail 89989 invoked by alias); 9 Nov 2015 16:32:08 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 89879 invoked by uid 89); 9 Nov 2015 16:32:07 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL, BAYES_00, SPF_PASS autolearn=ham version=3.3.2 X-HELO: eu-smtp-delivery-143.mimecast.com Received: from eu-smtp-delivery-143.mimecast.com (HELO eu-smtp-delivery-143.mimecast.com) (146.101.78.143) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 09 Nov 2015 16:32:05 +0000 Received: from cam-owa2.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.140]) by eu-smtp-1.mimecast.com with ESMTP id uk-mta-15-7mXwFS_DSXadFJKcjNyWrg-1; Mon, 09 Nov 2015 16:31:59 +0000 Received: from [10.2.206.200] ([10.1.2.79]) by cam-owa2.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Mon, 9 Nov 2015 16:31:58 +0000 Message-ID: <5640CA7E.8080007@arm.com> Date: Mon, 09 Nov 2015 16:31:58 +0000 From: Kyrill Tkachov User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 MIME-Version: 1.0 To: GCC Patches CC: Vladimir Makarov Subject: [PATCH][haifa-sched] PR rtl-optimization/68236: Exit early from autoprefetcher lookahead if not in haifa sched X-MC-Unique: 7mXwFS_DSXadFJKcjNyWrg-1 X-IsSubscribed: yes 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 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 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 (); }