From 41d384c50571635a2dbbbb9d297f12ce91fb5797 Mon Sep 17 00:00:00 2001 From: vries Date: Sun, 16 Jun 2019 07:47:15 +0000 Subject: [PATCH] [openacc, parloops] Fix SIGSEGV in oacc_entry_exit_ok_1 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 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@272338 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 5 +++++ gcc/tree-parloops.c | 6 +++--- libgomp/ChangeLog | 5 +++++ .../testsuite/libgomp.oacc-c-c++-common/pr89376.c | 15 +++++++++++++++ 4 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 libgomp/testsuite/libgomp.oacc-c-c++-common/pr89376.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 516ef410ef02..c5b213e1ae80 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2019-06-16 Tom de Vries + + PR tree-optimization/89376 + * tree-parloops.c (oacc_entry_exit_ok_1): Handle red == NULL. + 2019-06-15 Maya Rashish * doc/invoke.texi (Spec Files): Update location of the diff --git a/gcc/tree-parloops.c b/gcc/tree-parloops.c index 9de154e722f9..6b8c8cd5b759 100644 --- a/gcc/tree-parloops.c +++ b/gcc/tree-parloops.c @@ -3052,11 +3052,11 @@ oacc_entry_exit_ok_1 (bitmap in_loop_bbs, vec 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)) { diff --git a/libgomp/ChangeLog b/libgomp/ChangeLog index 131a415cb48e..827bab2d8961 100644 --- a/libgomp/ChangeLog +++ b/libgomp/ChangeLog @@ -1,3 +1,8 @@ +2019-06-16 Tom de Vries + + PR tree-optimization/89376 + * testsuite/libgomp.oacc-c-c++-common/pr89376.c: New test. + 2019-06-15 Tom de Vries PR tree-optimization/89713 diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/pr89376.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/pr89376.c new file mode 100644 index 000000000000..7f6c83254d54 --- /dev/null +++ b/libgomp/testsuite/libgomp.oacc-c-c++-common/pr89376.c @@ -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; +} + -- 2.39.2