From patchwork Fri Mar 18 12:44:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 52097 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 77B673888C6B for ; Fri, 18 Mar 2022 12:44:32 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 77B673888C6B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1647607472; bh=3q6s/vG/kxXyge3SUuCvvOoDhRDLiIJmpQbvlv7aqW4=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=aaCmDO2Sz2Riv2DkL/BAZ/vBxyCrHUQfQsMOIqL980cA5HinJ2H9ydLXF7MsG1wTz rU82dS+5h37Hj10SaXqQo2ctMeI0uz0zOJp/sodhCI7bxlJZsJYow/eKJot0w+drQm fvu1kaHFzJ6FP2Vk9ttfBNMk5kk3eDnF2Ebbnys8= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id B537C388883E for ; Fri, 18 Mar 2022 12:44:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B537C388883E Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 9ACBC210EC; Fri, 18 Mar 2022 12:44:01 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 7EC9012FC5; Fri, 18 Mar 2022 12:44:01 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id Vh7jHZF+NGI5GQAAMHmgww (envelope-from ); Fri, 18 Mar 2022 12:44:01 +0000 Date: Fri, 18 Mar 2022 13:44:00 +0100 To: gcc-patches@gcc.gnu.org Subject: [PATCH][openmp] Set location for taskloop stmts Message-ID: <20220318124358.GA28424@delia.home> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-12.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Tom de Vries via Gcc-patches From: Tom de Vries Reply-To: Tom de Vries Cc: Jakub Jelinek Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Hi, The test-case included in this patch contains: ... #pragma omp taskloop simd shared(a) lastprivate(myId) ... This is translated to 3 taskloop statements in gimple, visible with -fdump-tree-gimple: ... #pragma omp taskloop private(D.2124) #pragma omp taskloop shared(a) shared(myId) private(i.0) firstprivate(a_h) #pragma omp taskloop lastprivate(myId) ... But when exposing the gimple statement locations using -fdump-tree-gimple-lineno, we find that only the first one has location information. Fix this by adding the missing location information. Tested gomp.exp on x86_64. Tested libgomp testsuite on x86_64 with nvptx accelerator. OK for trunk? Thanks, - Tom [openmp] Set location for taskloop stmts gcc/ChangeLog: 2022-03-18 Tom de Vries * gimplify.cc (gimplify_omp_for): Set taskloop location. gcc/testsuite/ChangeLog: 2022-03-18 Tom de Vries * c-c++-common/gomp/pr104968.c: New test. --- gcc/gimplify.cc | 2 ++ gcc/testsuite/c-c++-common/gomp/pr104968.c | 14 ++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/gcc/gimplify.cc b/gcc/gimplify.cc index 139a0de6100..c46589639e4 100644 --- a/gcc/gimplify.cc +++ b/gcc/gimplify.cc @@ -13178,6 +13178,7 @@ gimplify_omp_for (tree *expr_p, gimple_seq *pre_p) gfor = gimple_build_omp_for (for_body, kind, OMP_FOR_CLAUSES (orig_for_stmt), TREE_VEC_LENGTH (OMP_FOR_INIT (for_stmt)), for_pre_body); + gimple_set_location (gfor, EXPR_LOCATION (*expr_p)); if (orig_for_stmt != for_stmt) gimple_omp_for_set_combined_p (gfor, true); if (gimplify_omp_ctxp @@ -13361,6 +13362,7 @@ gimplify_omp_for (tree *expr_p, gimple_seq *pre_p) g = gimple_build_bind (NULL_TREE, gfor, NULL_TREE); g = gimple_build_omp_task (g, task_clauses, NULL_TREE, NULL_TREE, NULL_TREE, NULL_TREE, NULL_TREE); + gimple_set_location (g, EXPR_LOCATION (*expr_p)); gimple_omp_task_set_taskloop_p (g, true); g = gimple_build_bind (NULL_TREE, g, NULL_TREE); gomp_for *gforo diff --git a/gcc/testsuite/c-c++-common/gomp/pr104968.c b/gcc/testsuite/c-c++-common/gomp/pr104968.c new file mode 100644 index 00000000000..2977db2f433 --- /dev/null +++ b/gcc/testsuite/c-c++-common/gomp/pr104968.c @@ -0,0 +1,14 @@ +/* { dg-additional-options "-fdump-tree-gimple-lineno" } */ + +int +main (void) +{ + double a[10], a_h[10]; + int myId = -1; +#pragma omp target map(tofrom:a) +#pragma omp taskloop simd shared(a) lastprivate(myId) /* { dg-line here } */ + for(int i = 0 ; i < 10; i++) if (a[i] != a_h[i]) { } +} + +/* { dg-final { scan-tree-dump-times "#pragma omp taskloop" 3 "gimple" } } */ +/* { dg-final { scan-tree-dump-times "(?n)\\\[.*pr104968.c:[get-absolute-line '' here]:.*\\\] #pragma omp taskloop" 3 "gimple" } } */