public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-7703] [openmp] Set location for taskloop stmts
@ 2022-03-18 15:16 Tom de Vries
  0 siblings, 0 replies; only message in thread
From: Tom de Vries @ 2022-03-18 15:16 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:356e2720e9030927579024c2f060d665a0b9080f

commit r12-7703-g356e2720e9030927579024c2f060d665a0b9080f
Author: Tom de Vries <tdevries@suse.de>
Date:   Fri Mar 18 10:34:02 2022 +0100

    [openmp] Set location for taskloop stmts
    
    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.
    
    gcc/ChangeLog:
    
    2022-03-18  Tom de Vries  <tdevries@suse.de>
    
            * gimplify.cc (gimplify_omp_for): Set taskloop location.
    
    gcc/testsuite/ChangeLog:
    
    2022-03-18  Tom de Vries  <tdevries@suse.de>
    
            * c-c++-common/gomp/pr104968.c: New test.

Diff:
---
 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" } }  */


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-03-18 15:16 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-18 15:16 [gcc r12-7703] [openmp] Set location for taskloop stmts Tom de Vries

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).