From patchwork Tue Jul 17 10:58:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 944883 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-481716-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="tH/Gxqu5"; 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 41VHMf5xm4z9rxs for ; Tue, 17 Jul 2018 20:58:53 +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:subject:message-id:reply-to:mime-version:content-type; q=dns; s=default; b=m6d6ONpuPgO3TGGqLRt5tqLpBlPf0PacSJKyHolkLBP qRAHPIY9Y3PAUpPUBO1nhvx7iz4/TiebLyh8oqsZD4bNQ1KIAR/Bd8R9gOVnT+MB Gj9L+yA7kj7xDpbvvwRmpDGKO8khw1lI/HKHBS02N5Sn/HUFi+dyGKY0PMRTDLt0 = 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:reply-to:mime-version:content-type; s=default; bh=S3QqYBDr/Pwv4ysGF7tZA8pU8zQ=; b=tH/Gxqu53KUe5dV7r gJ7tIBnt7Lga3EiBBtaEhRKKgcGHpI+otqHEZI4hYcDLlqLCIHON+GIarxbAvTVI UfUgsDHMyxNXnIzh3+o5IzaWoMgp+bPuT+nEGl/DlKF5iXkcsR4nzx3aYH8CQJZY Vjb0I3IDULvPtlUB8d6vv5Qi8A= Received: (qmail 47079 invoked by alias); 17 Jul 2018 10:58:46 -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 47070 invoked by uid 89); 17 Jul 2018 10:58:45 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-11.9 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=VLA, vla 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; Tue, 17 Jul 2018 10:58:44 +0000 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2474E30832E8 for ; Tue, 17 Jul 2018 10:58:43 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-117-71.ams2.redhat.com [10.36.117.71]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B8E325D6B5 for ; Tue, 17 Jul 2018 10:58:42 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id w6HAweAQ000494 for ; Tue, 17 Jul 2018 12:58:41 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id w6HAweCJ000493 for gcc-patches@gcc.gnu.org; Tue, 17 Jul 2018 12:58:40 +0200 Date: Tue, 17 Jul 2018 12:58:40 +0200 From: Jakub Jelinek To: gcc-patches@gcc.gnu.org Subject: [committed] Fix OpenMP taskloop lowering (PR middle-end/86542) Message-ID: <20180717105840.GK7166@tucnak> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.9.2 (2017-12-15) X-IsSubscribed: yes Hi! Another bug I've ran into while working on OpenMP 5.0 range for support. For collapse(2) and higher taskloops, if there is any clause that needs a cpyfn callback (e.g. firstprivate with non-POD, or VLA), we wouldn't be copying over the temporaries needed for collapsed loop; without cpyfn the default memcpy that copies the passed in data to the task arg area handles that already. Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, committed to trunk, queued for backports. 2018-07-17 Jakub Jelinek PR middle-end/86542 * omp-low.c (create_task_copyfn): Copy over also fields corresponding to _looptemp_ clauses, other than the first two. * testsuite/libgomp.c++/pr86542.C: New test. Jakub --- gcc/omp-low.c.jj 2018-06-22 19:17:12.219437746 +0200 +++ gcc/omp-low.c 2018-07-17 10:18:02.551015945 +0200 @@ -7026,6 +7026,7 @@ create_task_copyfn (gomp_task *task_stmt splay_tree_node n; struct omp_taskcopy_context tcctx; location_t loc = gimple_location (task_stmt); + size_t looptempno = 0; child_fn = gimple_omp_task_copy_fn (task_stmt); child_cfun = DECL_STRUCT_FUNCTION (child_fn); @@ -7139,6 +7140,15 @@ create_task_copyfn (gomp_task *task_stmt t = build2 (MODIFY_EXPR, TREE_TYPE (dst), dst, src); append_to_statement_list (t, &list); break; + case OMP_CLAUSE__LOOPTEMP_: + /* Fields for first two _looptemp_ clauses are initialized by + GOMP_taskloop*, the rest are handled like firstprivate. */ + if (looptempno < 2) + { + looptempno++; + break; + } + /* FALLTHRU */ case OMP_CLAUSE_FIRSTPRIVATE: decl = OMP_CLAUSE_DECL (c); if (is_variable_sized (decl)) @@ -7164,7 +7174,10 @@ create_task_copyfn (gomp_task *task_stmt src = decl; dst = build_simple_mem_ref_loc (loc, arg); dst = omp_build_component_ref (dst, f); - t = lang_hooks.decls.omp_clause_copy_ctor (c, dst, src); + if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE__LOOPTEMP_) + t = build2 (MODIFY_EXPR, TREE_TYPE (dst), dst, src); + else + t = lang_hooks.decls.omp_clause_copy_ctor (c, dst, src); append_to_statement_list (t, &list); break; case OMP_CLAUSE_PRIVATE: --- libgomp/testsuite/libgomp.c++/pr86542.C.jj 2018-07-17 10:20:02.214127004 +0200 +++ libgomp/testsuite/libgomp.c++/pr86542.C 2018-07-17 10:19:39.207105565 +0200 @@ -0,0 +1,37 @@ +// PR middle-end/86542 + +struct S { int s; S (); ~S (); S (const S &); }; +S s; + +S::S () +{ +} + +S::~S () +{ +} + +S::S (const S &x) +{ + s = x.s; +} + +__attribute__((noipa)) void +foo (int i, int j, int k, S s) +{ + if (i != 0 || j != 0 || k != 0 || s.s != 12) + __builtin_abort (); +} + +int +main () +{ + volatile int inc = 16, jnc = 16, knc = 16; + s.s = 12; + #pragma omp taskloop collapse (3) firstprivate (s) + for (int i = 0; i < 16; i += inc) + for (int j = 0; j < 16; j += jnc) + for (int k = 0; k < 16; k += knc) + foo (i, j, k, s); + return 0; +}