public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Tom de Vries <Tom_deVries@mentor.com>
To: Jakub Jelinek <jakub@redhat.com>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>
Subject: [PR65637][PATCH][1/3] Fix gcc_assert in expand_omp_for_static_chunk
Date: Wed, 15 Apr 2015 13:15:00 -0000	[thread overview]
Message-ID: <552E6468.40403@mentor.com> (raw)
In-Reply-To: <552E6341.4040401@mentor.com>

[-- Attachment #1: Type: text/plain, Size: 2054 bytes --]

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<edge_var_map> *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

[-- Attachment #2: 0002-Fix-gcc_assert-in-expand_omp_for_static_chunk.patch --]
[-- Type: text/x-patch, Size: 816 bytes --]

Fix gcc_assert in expand_omp_for_static_chunk

2015-04-15  Tom de Vries  <tom@codesourcery.com>

	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


  reply	other threads:[~2015-04-15 13:15 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-15 13:10 [PR65637] Fix ssa-handling code " Tom de Vries
2015-04-15 13:15 ` Tom de Vries [this message]
2015-08-31 12:00   ` [PR65637][PATCH][3/5] Fix gcc_assert " Tom de Vries
2015-09-03  9:16     ` Jakub Jelinek
2015-04-15 13:17 ` [PR65637][PATCH][2/3] Fix inner loop phi " Tom de Vries
2015-08-31 12:03   ` [PR65637][PATCH][4/5] " Tom de Vries
2015-09-03  9:20     ` Jakub Jelinek
2015-04-15 13:23 ` [PR65637][PATCH][3/3] Handle 2 preds for fin_bb " Tom de Vries
2015-08-31 12:26   ` [PR65637][PATCH][5/5] " Tom de Vries
2015-09-03  9:40     ` Jakub Jelinek
2015-05-18 13:13 ` [PING][PR65637] Fix ssa-handling code " Tom de Vries
2015-05-18 14:19   ` Tom de Vries
2015-06-08 12:34   ` [PING^2][PR65637] " Tom de Vries
2015-08-31 11:44 ` [PR65637] " Tom de Vries
2015-08-31 11:51   ` [PATCH][1/5] Add param parloops-chunk-size Tom de Vries
2015-09-03  8:57     ` Jakub Jelinek
2015-08-31 11:55   ` [PATCH][2/5] Handle simple latch bb in expand_omp_for_static_chunk Tom de Vries
2015-09-03  9:02     ` Jakub Jelinek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=552E6468.40403@mentor.com \
    --to=tom_devries@mentor.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jakub@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).