From patchwork Sun Jun 16 07:49:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 1116503 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-503022-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="s8owywAo"; dkim-atps=neutral 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 45RRMY2xFjz9s00 for ; Sun, 16 Jun 2019 17:49:58 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:mime-version:content-type; q=dns; s=default; b=FHIEQYGKYS4raVlKIPKvfGAYxhKMbcBJRXGHGzy+Vjpg7s3ter RjJj6LbjcjIMqvHSpaNlEKy0Jie3AvPHrJEGmWJRTpo8UTgKG5M/vmqa1V1c8aqj kbMvB3aZ96gAv8o4BMXqgL2+b2bkXyT+9AAadEdgvSaBDiDxd4zBnFkEQ= 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:date :from:to:cc:subject:message-id:mime-version:content-type; s= default; bh=4AOzd1XUaBVaM7lpLX769eSdJI4=; b=s8owywAoah0Qz0w+aCVE Qx/fB2yG9xa77F6/879lQO6iFVOBkT9QzMsqZx0XKW9GrVxSSmXKZYlmqBR1Ta+F nYwaXeOpghsS1XRYgGCP/mWe6U5DPy9RKFbdmYA0yGKIvNAHSzACJ8uAm/l7QgL2 Fmq2NBo7Rec+nqMS7y+XAP0= Received: (qmail 26108 invoked by alias); 16 Jun 2019 07:49:47 -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 26100 invoked by uid 89); 16 Jun 2019 07:49:47 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-24.5 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_NUMSUBJECT, SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: mx1.suse.de Received: from mx2.suse.de (HELO mx1.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 16 Jun 2019 07:49:46 +0000 Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 699F8AE2C; Sun, 16 Jun 2019 07:49:43 +0000 (UTC) Date: Sun, 16 Jun 2019 09:49:40 +0200 From: Tom de Vries To: gcc-patches@gcc.gnu.org Cc: Richard Biener , Thomas Schwinge Subject: [committed][openacc] Fix SIGSEGV in oacc_entry_exit_ok_1 Message-ID: <20190616074939.GA32295@delia> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) X-IsSubscribed: yes Hi, 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. Committed to trunk. Thanks, - Tom [openacc] Fix SIGSEGV in oacc_entry_exit_ok_1 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. --- gcc/tree-parloops.c | 6 +++--- libgomp/testsuite/libgomp.oacc-c-c++-common/pr89376.c | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/gcc/tree-parloops.c b/gcc/tree-parloops.c index 9de154e722f..6b8c8cd5b75 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/testsuite/libgomp.oacc-c-c++-common/pr89376.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/pr89376.c new file mode 100644 index 00000000000..7f6c83254d5 --- /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; +} +