From patchwork Mon Dec 7 11:21:22 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Jambor X-Patchwork-Id: 553345 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 3DB0F1402A0 for ; Mon, 7 Dec 2015 22:21:35 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=KbMx7DEI; dkim-atps=neutral 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:subject:message-id:references:mime-version:content-type :in-reply-to; q=dns; s=default; b=vL82mCftI2JNXMEvMiCEKGxzASdPqN EcacQMhTLQkw6Qgbjdn1GkPXm+R7r73ir//fTJdEjiBWBdi84eEqz/gGWlgmkCru ePsJnlIlTdVOXIEbyGjIsNHoyVHwEYJQ449pHs1Fi5pi90M4LwF3tTktmtncOvpd SOD1YQWkSWRO0= 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:subject:message-id:references:mime-version:content-type :in-reply-to; s=default; bh=5V2J5Yg1Xyo0KvDiM4NSYk3hRK4=; b=KbMx 7DEI+6T/TCUQeTGP58YgzZFekvG8qexA4z2fP0ukGgYi9nUQcWlxhIg5Qlnj+iiR lu+hs7lvPM4BUZhfQdxXR8O6U2dBkYFYynCB7RHPfmZYr3VBVGl3uWi2hPmnq0hK Z3iVswfC55RbY+GBmHCjKoJLyEgS7c6kKH4yo3g= Received: (qmail 92829 invoked by alias); 7 Dec 2015 11:21:27 -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 92815 invoked by uid 89); 7 Dec 2015 11:21:27 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.1 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx2.suse.de Received: from mx2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (CAMELLIA256-SHA encrypted) ESMTPS; Mon, 07 Dec 2015 11:21:25 +0000 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 7337FAAC7 for ; Mon, 7 Dec 2015 11:21:22 +0000 (UTC) Date: Mon, 7 Dec 2015 12:21:22 +0100 From: Martin Jambor To: GCC Patches Subject: [hsa 4/10] Merge of HSA branch Message-ID: <20151207112122.GE24234@virgil.suse.cz> Mail-Followup-To: GCC Patches References: <20151207111758.GA24234@virgil.suse.cz> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20151207111758.GA24234@virgil.suse.cz> User-Agent: Mutt/1.5.24 (2015-08-30) X-IsSubscribed: yes Subject: Make copy_gimple_seq_and_replace_locals copy seqs in omp clauses Hi, this is https://gcc.gnu.org/ml/gcc-patches/2015-12/msg00477.html with the early return requested by Jakub. Please refer to that previous email for explanation why it is necessary. Thanks, 2015-12-03 Martin Jambor * tree-inline.c (duplicate_remap_omp_clause_seq): New function. (replace_locals_op): Duplicate gimple sequences in OMP clauses. diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index ebab189..dea23c7 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -5116,6 +5116,8 @@ mark_local_labels_stmt (gimple_stmt_iterator *gsip, return NULL_TREE; } +static gimple_seq duplicate_remap_omp_clause_seq (gimple_seq seq, + struct walk_stmt_info *wi); /* Called via walk_gimple_seq by copy_gimple_seq_and_replace_local. Using the splay_tree pointed to by ST (which is really a `splay_tree'), @@ -5160,6 +5162,35 @@ replace_locals_op (tree *tp, int *walk_subtrees, void *data) TREE_OPERAND (expr, 3) = NULL_TREE; } } + else if (TREE_CODE (expr) == OMP_CLAUSE) + { + /* Before the omplower pass completes, some OMP clauses can contain + sequences that are neither copied by gimple_seq_copy nor walked by + walk_gimple_seq. To make copy_gimple_seq_and_replace_locals work even + in those situations, we have to copy and process them explicitely. */ + + if (OMP_CLAUSE_CODE (expr) == OMP_CLAUSE_LASTPRIVATE) + { + gimple_seq seq = OMP_CLAUSE_LASTPRIVATE_GIMPLE_SEQ (expr); + seq = duplicate_remap_omp_clause_seq (seq, wi); + OMP_CLAUSE_LASTPRIVATE_GIMPLE_SEQ (expr) = seq; + } + else if (OMP_CLAUSE_CODE (expr) == OMP_CLAUSE_LINEAR) + { + gimple_seq seq = OMP_CLAUSE_LINEAR_GIMPLE_SEQ (expr); + seq = duplicate_remap_omp_clause_seq (seq, wi); + OMP_CLAUSE_LINEAR_GIMPLE_SEQ (expr) = seq; + } + else if (OMP_CLAUSE_CODE (expr) == OMP_CLAUSE_REDUCTION) + { + gimple_seq seq = OMP_CLAUSE_REDUCTION_GIMPLE_INIT (expr); + seq = duplicate_remap_omp_clause_seq (seq, wi); + OMP_CLAUSE_REDUCTION_GIMPLE_INIT (expr) = seq; + seq = OMP_CLAUSE_REDUCTION_GIMPLE_MERGE (expr); + seq = duplicate_remap_omp_clause_seq (seq, wi); + OMP_CLAUSE_REDUCTION_GIMPLE_MERGE (expr) = seq; + } + } /* Keep iterating. */ return NULL_TREE; @@ -5200,6 +5231,21 @@ replace_locals_stmt (gimple_stmt_iterator *gsip, return NULL_TREE; } +/* Create a copy of SEQ and remap all decls in it. */ + +static gimple_seq +duplicate_remap_omp_clause_seq (gimple_seq seq, struct walk_stmt_info *wi) +{ + if (!seq) + return NULL; + + /* If there are any labels in OMP sequences, they can be only referred to in + the sequence itself and therefore we can do both here. */ + walk_gimple_seq (seq, mark_local_labels_stmt, NULL, wi); + gimple_seq copy = gimple_seq_copy (seq); + walk_gimple_seq (copy, replace_locals_stmt, replace_locals_op, wi); + return copy; +} /* Copies everything in SEQ and replaces variables and labels local to current_function_decl. */