From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25493 invoked by alias); 31 Aug 2015 11:55:56 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 25477 invoked by uid 89); 31 Aug 2015 11:55:55 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 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; Mon, 31 Aug 2015 11:55:54 +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 1ZWNgl-0004kx-9B from Tom_deVries@mentor.com ; Mon, 31 Aug 2015 04:55:51 -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; Mon, 31 Aug 2015 12:55:49 +0100 Message-ID: <55E440BC.7020703@mentor.com> Date: Mon, 31 Aug 2015 12:00:00 -0000 From: Tom de Vries User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.8.0 MIME-Version: 1.0 To: Jakub Jelinek CC: GCC Patches Subject: [PR65637][PATCH][3/5] Fix gcc_assert in expand_omp_for_static_chunk References: <552E6341.4040401@mentor.com> <552E6468.40403@mentor.com> In-Reply-To: <552E6468.40403@mentor.com> Content-Type: multipart/mixed; boundary="------------080307040707040906060502" X-SW-Source: 2015-08/txt/msg01872.txt.bz2 --------------080307040707040906060502 Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit Content-length: 1401 [ Was: Re: [PR65637][PATCH][1/3] Fix gcc_assert in expand_omp_for_static_chunk ] On 15/04/15 15:15, Tom de Vries wrote: > On 15-04-15 15:10, Tom de Vries wrote: >> Hi, >> >> This patch series fixes PR65637. >> > 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. > This updated patch includes a test-case. OK for trunk? Thanks, - Tom --------------080307040707040906060502 Content-Type: text/x-patch; name="0003-Fix-gcc_assert-in-expand_omp_for_static_chunk.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="0003-Fix-gcc_assert-in-expand_omp_for_static_chunk.patch" Content-length: 2499 Fix gcc_assert in expand_omp_for_static_chunk 2015-08-31 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.dg/autopar/pr46099-chunk-size.c: New test. --- gcc/ChangeLog | 6 +++ gcc/omp-low.c | 2 +- gcc/testsuite/gcc.dg/autopar/pr46099-chunk-size.c | 47 +++++++++++++++++++++++ 3 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/autopar/pr46099-chunk-size.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index a0123b1..5a273ba 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2015-05-18 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. + 2015-08-31 Tom de Vries * tree-ssa-loop-manip.c (find_uses_to_rename_use) diff --git a/gcc/omp-low.c b/gcc/omp-low.c index c3dfc51..4e732ae 100644 --- a/gcc/omp-low.c +++ b/gcc/omp-low.c @@ -7326,7 +7326,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) { diff --git a/gcc/testsuite/gcc.dg/autopar/pr46099-chunk-size.c b/gcc/testsuite/gcc.dg/autopar/pr46099-chunk-size.c new file mode 100644 index 0000000..709841a --- /dev/null +++ b/gcc/testsuite/gcc.dg/autopar/pr46099-chunk-size.c @@ -0,0 +1,47 @@ +/* PR tree-optimization/46099. */ +/* { dg-do compile } */ +/* { dg-options "-ftree-parallelize-loops=2 -fcompare-debug -O --param parloops-chunk-size=100" } */ + +static inline void +bar (int *i) +{ + int j = *i; +} + +void baz (int *, int *, int *); + +void +f1 (int n) +{ + int i; + for (i = 0; i < n; i++) + bar (&i); +} + +void +f2 (int n) +{ + int i; + int a[10000], b[10000], c[10000]; + baz (a, b, c); + for (i = 0; i < n; i++) + { + void *p = c; + a[i] = b[i] + c[i]; + } + baz (a, b, c); +} + +void +f3 (int n) +{ + int i; + int a[10000], b[10000], c[10000]; + baz (a, b, c); + for (i = 0; i < n; i++) + { + a[i] = b[i] + c[i]; + void *p = c; + } + baz (a, b, c); +} -- 1.9.1 --------------080307040707040906060502--