From patchwork Wed Apr 15 13:15:20 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 461519 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 94241140134 for ; Wed, 15 Apr 2015 23:15:38 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass reason="1024-bit key; unprotected key" header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=KDjNs2gJ; dkim-adsp=none (unprotected policy); dkim-atps=neutral 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:references :in-reply-to:content-type; q=dns; s=default; b=OFqaOj3LcRYZTL6V1 swyzWo8RXgDh9ywp/HS2wZ7NHYdRpaps2yGyw9rId2oigyV1Cs2eNHkXduDNTGLi zhCaVlj6ppH+SoudPkUDL4t7N6oa8HpEUeYy8QcZf1fbuRTGHLaRoOrNhynA6XKR wupuyiopr+KkMXbp+8TZQcjSp4= 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:references :in-reply-to:content-type; s=default; bh=CL0FBZg8y2VfT33rLDFkNrW zDLM=; b=KDjNs2gJlCiZIE+RUep2a4q0qgHzg5eDCINa8+qg5DCWJkMPiQBEn1C ZfE8zcNGsUw7MdllGIR5cDaRAkd0fYs2OP1ebUrjs8hxM/3mJAg3svegZgFgNIlT 7NlPyZG0VxBxGL1YSpstijdMesm1LFEas+ypQAaclt5mUE44/Qm0= Received: (qmail 83057 invoked by alias); 15 Apr 2015 13:15:30 -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 83046 invoked by uid 89); 15 Apr 2015 13:15:29 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 15 Apr 2015 13:15:28 +0000 Received: from nat-ies.mentorg.com ([192.94.31.2] helo=SVR-IES-FEM-01.mgc.mentorg.com) by relay1.mentorg.com with esmtp id 1YiNA4-0004jx-JA from Tom_deVries@mentor.com ; Wed, 15 Apr 2015 06:15:24 -0700 Received: from [127.0.0.1] (137.202.0.76) by SVR-IES-FEM-01.mgc.mentorg.com (137.202.0.104) with Microsoft SMTP Server id 14.3.224.2; Wed, 15 Apr 2015 14:15:23 +0100 Message-ID: <552E6468.40403@mentor.com> Date: Wed, 15 Apr 2015 15:15:20 +0200 From: Tom de Vries User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-Version: 1.0 To: Jakub Jelinek CC: GCC Patches Subject: [PR65637][PATCH][1/3] Fix gcc_assert in expand_omp_for_static_chunk References: <552E6341.4040401@mentor.com> In-Reply-To: <552E6341.4040401@mentor.com> On 15-04-15 15:10, Tom de Vries wrote: > Hi, > > This patch series fixes PR65637. > > Currently, ssa-handling code in expand_omp_for_static_chunk is dead and not > exercised by testing. > > Ssa-handling code in omp-low.c is only triggered by pass_parallelize_loops, and > that pass doesn't specify a chunk size on the GIMPLE_OMP_FOR it constructs, so > that only exercises the expand_omp_for_static_nochunk path. > > Using the attached trigger patch, we excercise the ssa-handling code in > expand_omp_for_static_chunk. The following patch series fixes the problems in > the ssa-handling code that we encounter. > > 1. Fix gcc_assert in expand_omp_for_static_chunk > 2. Fix inner loop phi in expand_omp_for_static_chunk > 3. Handle 2 preds for fin_bb in expand_omp_for_static_chunk > > The patch series has been bootstrapped and reg-tested on x86_64 together with > attached trigger patch. > > I'll post the patches from the patch series individually, in response to this > email. > This patch fixes a segfault in an gcc_assert in expand_omp_for_static_chunk while compiling autopar/pr46099.c. When compiling f1 from autopar/pr46099.c using expand_omp_for_static_chunk, we redirect the edge (trip_update_bb -> fin_bb) to point to iter_part_bb: ... redirect_edge_and_branch (single_succ_edge (trip_update_bb), iter_part_bb); ... And fin_bb is an empty block without any phis, so during the redirect we don't store any entries in the edge_var_map: ... (gdb) call debug_bb (fin_bb) ;; basic block 18, loop depth 0, count 0, freq 0, maybe hot ;; prev block 21, next block 16, flags: (NEW) ;; pred: 21 [100.0%] (FALLTHRU) ;; 19 (FALSE_VALUE) ;; succ: 16 [100.0%] (FALLTHRU) ... Consequently, head will be NULL. ... vec *head = redirect_edge_var_map_vector (re); ... And because head is NULL, this assert causes a segfault: ... gcc_assert (gsi_end_p (psi) && i == head->length ()); ... This patch fixes that, by handling the case that head is NULL in the assert. OK for trunk? Thanks, - Tom Fix gcc_assert in expand_omp_for_static_chunk 2015-04-15 Tom de Vries PR tree-optimization/65637 * omp-low.c (expand_omp_for_static_chunk): Fix gcc_assert for the case that head is NULL. --- gcc/omp-low.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/omp-low.c b/gcc/omp-low.c index 80bddf0..f7b9d11 100644 --- a/gcc/omp-low.c +++ b/gcc/omp-low.c @@ -7274,7 +7274,7 @@ expand_omp_for_static_chunk (struct omp_region *region, locus = redirect_edge_var_map_location (vm); add_phi_arg (nphi, redirect_edge_var_map_def (vm), re, locus); } - gcc_assert (gsi_end_p (psi) && i == head->length ()); + gcc_assert (gsi_end_p (psi) && (head == NULL || i == head->length ())); redirect_edge_var_map_clear (re); while (1) { -- 1.9.1