Skip to content

Commit

Permalink
[openacc, parloops] Fix SIGSEGV in oacc_entry_exit_ok_1
Browse files Browse the repository at this point in the history
When compiling the test-case with r268755, we run into a SIGSEGV in
oacc_entry_exit_ok_1 when trying to dereference a NULL red:
...
                      struct reduction_info *red;
                      red = reduction_phi (reduction_list, use_stmt);
                      tree val = PHI_RESULT (red->keep_res);
...

Fix this by handling ref == NULL.

Bootstrapped and reg-tested on x86_64.
Build and reg-tested on x86_64 with nvptx accelerator.

2019-06-16  Tom de Vries  <tdevries@suse.de>

	PR tree-optimization/89376
	* tree-parloops.c (oacc_entry_exit_ok_1): Handle red == NULL.

	* testsuite/libgomp.oacc-c-c++-common/pr89376.c: New test.

From-SVN: r272338
  • Loading branch information
vries authored and Tom de Vries committed Jun 16, 2019
1 parent a328e00 commit f45ce17
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 3 deletions.
5 changes: 5 additions & 0 deletions gcc/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2019-06-16 Tom de Vries <tdevries@suse.de>

PR tree-optimization/89376
* tree-parloops.c (oacc_entry_exit_ok_1): Handle red == NULL.

2019-06-15 Maya Rashish <coypu@sdf.org>

* doc/invoke.texi (Spec Files): Update location of the
Expand Down
6 changes: 3 additions & 3 deletions gcc/tree-parloops.c
Original file line number Diff line number Diff line change
Expand Up @@ -3052,11 +3052,11 @@ oacc_entry_exit_ok_1 (bitmap in_loop_bbs, vec<basic_block> region_bbs,
{
use_operand_p use_p;
gimple *use_stmt;
struct reduction_info *red;
single_imm_use (lhs, &use_p, &use_stmt);
if (gimple_code (use_stmt) == GIMPLE_PHI)
if (gimple_code (use_stmt) == GIMPLE_PHI
&& (red = reduction_phi (reduction_list, use_stmt)))
{
struct reduction_info *red;
red = reduction_phi (reduction_list, use_stmt);
tree val = PHI_RESULT (red->keep_res);
if (has_single_use (val))
{
Expand Down
5 changes: 5 additions & 0 deletions libgomp/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2019-06-16 Tom de Vries <tdevries@suse.de>

PR tree-optimization/89376
* testsuite/libgomp.oacc-c-c++-common/pr89376.c: New test.

2019-06-15 Tom de Vries <tdevries@suse.de>

PR tree-optimization/89713
Expand Down
15 changes: 15 additions & 0 deletions libgomp/testsuite/libgomp.oacc-c-c++-common/pr89376.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/* { dg-do run } */
/* { dg-additional-options "-fno-tree-ch -fno-tree-dce -fno-tree-vrp" } */

int
main (void)
{
int fa;

#pragma acc kernels
for (int rw = 0; rw < 1; ++rw)
fa = 0;

return 0;
}

0 comments on commit f45ce17

Please sign in to comment.