From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 49653 invoked by alias); 7 Oct 2016 12:21:41 -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 49639 invoked by uid 89); 7 Oct 2016 12:21:41 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.6 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:2375 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 07 Oct 2016 12:21:40 +0000 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1867CC050938; Fri, 7 Oct 2016 12:21:39 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-116-44.ams2.redhat.com [10.36.116.44]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u97CLach005053 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 7 Oct 2016 08:21:38 -0400 Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id u97CLYol031975; Fri, 7 Oct 2016 14:21:35 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id u97CLWeB031974; Fri, 7 Oct 2016 14:21:32 +0200 Date: Fri, 07 Oct 2016 12:21:00 -0000 From: Jakub Jelinek To: Nathan Sidwell , Thomas Schwinge , James Norris Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] Untested #pragma acc declare fix Message-ID: <20161007122132.GG7282@tucnak.redhat.com> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) X-IsSubscribed: yes X-SW-Source: 2016-10/txt/msg00479.txt.bz2 Hi! During review of Martin's -fsanitize-use-after-scope patch, I've noticed what I believe is a bug in #pragma acc declare support. In particular, the oacc_declare_returns has been added next to the CLOBBER additions, but the clobbers are guarded with many conditions, e.g. aren't emitted with -fstack-reuse=none and many other conditions. I believe the additions to that data structure aren't guarded by these conditions, it is just for VAR_DECLs that aren't is_global_var and have current_function_decl context. I haven't tested this patch (can bootstrap/regtest it), but don't have time to try to write a testcase for all the cases where the conditions matter. 2016-10-07 Jakub Jelinek * gimplify.c (gimplify_bind_expr): Handle oacc_declare_returns even for -fstack-reuse=none, or for volatile vars etc. --- gcc/gimplify.c.jj 2016-09-26 12:06:46.000000000 +0200 +++ gcc/gimplify.c 2016-10-07 14:11:09.299624104 +0200 @@ -1192,21 +1192,24 @@ gimplify_bind_expr (tree *expr_p, gimple { if (TREE_CODE (t) == VAR_DECL && !is_global_var (t) - && DECL_CONTEXT (t) == current_function_decl - && !DECL_HARD_REGISTER (t) - && !TREE_THIS_VOLATILE (t) - && !DECL_HAS_VALUE_EXPR_P (t) - /* Only care for variables that have to be in memory. Others - will be rewritten into SSA names, hence moved to the top-level. */ - && !is_gimple_reg (t) - && flag_stack_reuse != SR_NONE) + && DECL_CONTEXT (t) == current_function_decl) { - tree clobber = build_constructor (TREE_TYPE (t), NULL); - gimple *clobber_stmt; - TREE_THIS_VOLATILE (clobber) = 1; - clobber_stmt = gimple_build_assign (t, clobber); - gimple_set_location (clobber_stmt, end_locus); - gimplify_seq_add_stmt (&cleanup, clobber_stmt); + if (!DECL_HARD_REGISTER (t) + && !TREE_THIS_VOLATILE (t) + && !DECL_HAS_VALUE_EXPR_P (t) + /* Only care for variables that have to be in memory. Others + will be rewritten into SSA names, hence moved to the + top-level. */ + && !is_gimple_reg (t) + && flag_stack_reuse != SR_NONE) + { + tree clobber = build_constructor (TREE_TYPE (t), NULL); + gimple *clobber_stmt; + TREE_THIS_VOLATILE (clobber) = 1; + clobber_stmt = gimple_build_assign (t, clobber); + gimple_set_location (clobber_stmt, end_locus); + gimplify_seq_add_stmt (&cleanup, clobber_stmt); + } if (flag_openacc && oacc_declare_returns != NULL) { Jakub