public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Fortran: Add location info to OpenMP tree nodes
@ 2022-03-26  2:03 Sandra Loosemore
  2022-03-26  7:04 ` Jakub Jelinek
  2022-04-05  4:12 ` Sandra Loosemore
  0 siblings, 2 replies; 4+ messages in thread
From: Sandra Loosemore @ 2022-03-26  2:03 UTC (permalink / raw)
  To: fortran; +Cc: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 730 bytes --]

I've got another patch forthcoming (stage 1 material) that adds some new 
diagnostics for non-rectangular loops during gimplification of OMP 
nodes.  When I was working on that, I discovered that the Fortran front 
end wasn't attaching location information to the tree nodes 
corresponding to the various OMP directives, so the new errors weren't 
coming out with location info either.  I went through trans-openmp.cc 
and fixed all the places where make_node was being called to explicitly 
set the location.

I don't have a test case specifically for this change, but my test cases 
for the new diagnostics in the non-rectangular loops patch do exercise 
it.  Is this OK for trunk now, or for stage 1 when we get there?

-Sandra

[-- Attachment #2: omp-location.patch --]
[-- Type: text/x-patch, Size: 4971 bytes --]

commit 4c745003d0b39d0e92032b62421df4920753783a
Author: Sandra Loosemore <sandra@codesourcery.com>
Date:   Thu Mar 24 21:02:34 2022 -0700

    Fortran: Add location info to OpenMP tree nodes
    
    	 gcc/fortran/
    	 * trans-openmp.cc (gfc_trans_omp_critical): Set location on OMP
    	 tree node.
    	 (gfc_trans_omp_do): Likewise.
    	 (gfc_trans_omp_masked): Likewise.
    	 (gfc_trans_omp_do_simd): Likewise.
    	 (gfc_trans_omp_scope): Likewise.
    	 (gfc_trans_omp_taskgroup): Likewise.
    	 (gfc_trans_omp_taskwait): Likewise.
    	 (gfc_trans_omp_distribute): Likewise.
    	 (gfc_trans_omp_taskloop): Likewise.
    	 (gfc_trans_omp_master_masked_taskloop): Likewise.

diff --git a/gcc/fortran/trans-openmp.cc b/gcc/fortran/trans-openmp.cc
index 25dde82..ba3ff71 100644
--- a/gcc/fortran/trans-openmp.cc
+++ b/gcc/fortran/trans-openmp.cc
@@ -5012,6 +5012,7 @@ gfc_trans_omp_critical (gfc_code *code)
     name = get_identifier (code->ext.omp_clauses->critical_name);
   gfc_start_block (&block);
   stmt = make_node (OMP_CRITICAL);
+  SET_EXPR_LOCATION (stmt, gfc_get_location (&code->loc));
   TREE_TYPE (stmt) = void_type_node;
   OMP_CRITICAL_BODY (stmt) = gfc_trans_code (code->block->next);
   OMP_CRITICAL_NAME (stmt) = name;
@@ -5044,6 +5045,7 @@ gfc_trans_omp_do (gfc_code *code, gfc_exec_op op, stmtblock_t *pblock,
   unsigned ix;
   vec<tree, va_heap, vl_embed> *saved_doacross_steps = doacross_steps;
   gfc_expr_list *tile = do_clauses ? do_clauses->tile_list : clauses->tile_list;
+  gfc_code *orig_code = code;
 
   /* Both collapsed and tiled loops are lowered the same way.  In
      OpenACC, those clauses are not compatible, so prioritize the tile
@@ -5398,6 +5400,7 @@ gfc_trans_omp_do (gfc_code *code, gfc_exec_op op, stmtblock_t *pblock,
     default: gcc_unreachable ();
     }
 
+  SET_EXPR_LOCATION (stmt, gfc_get_location (&orig_code->loc));
   TREE_TYPE (stmt) = void_type_node;
   OMP_FOR_BODY (stmt) = gfc_finish_block (&body);
   OMP_FOR_CLAUSES (stmt) = omp_clauses;
@@ -5670,6 +5673,7 @@ gfc_trans_omp_masked (gfc_code *code, gfc_omp_clauses *clauses)
   gfc_start_block (&block);
   tree omp_clauses = gfc_trans_omp_clauses (&block, clauses, code->loc);
   tree stmt = make_node (OMP_MASKED);
+  SET_EXPR_LOCATION (stmt, gfc_get_location (&code->loc));
   TREE_TYPE (stmt) = void_type_node;
   OMP_MASKED_BODY (stmt) = body;
   OMP_MASKED_CLAUSES (stmt) = omp_clauses;
@@ -6444,6 +6448,7 @@ gfc_trans_omp_do_simd (gfc_code *code, stmtblock_t *pblock,
   if (flag_openmp)
     {
       stmt = make_node (OMP_FOR);
+      SET_EXPR_LOCATION (stmt, gfc_get_location (&code->loc));
       TREE_TYPE (stmt) = void_type_node;
       OMP_FOR_BODY (stmt) = body;
       OMP_FOR_CLAUSES (stmt) = omp_do_clauses;
@@ -6616,6 +6621,7 @@ gfc_trans_omp_scope (gfc_code *code)
   tree omp_clauses = gfc_trans_omp_clauses (&block, code->ext.omp_clauses,
 					    code->loc);
   tree stmt = make_node (OMP_SCOPE);
+  SET_EXPR_LOCATION (stmt, gfc_get_location (&code->loc));
   TREE_TYPE (stmt) = void_type_node;
   OMP_SCOPE_BODY (stmt) = body;
   OMP_SCOPE_CLAUSES (stmt) = omp_clauses;
@@ -6691,6 +6697,7 @@ gfc_trans_omp_taskgroup (gfc_code *code)
   gfc_start_block (&block);
   tree body = gfc_trans_code (code->block->next);
   tree stmt = make_node (OMP_TASKGROUP);
+  SET_EXPR_LOCATION (stmt, gfc_get_location (&code->loc));
   TREE_TYPE (stmt) = void_type_node;
   OMP_TASKGROUP_BODY (stmt) = body;
   OMP_TASKGROUP_CLAUSES (stmt) = gfc_trans_omp_clauses (&block,
@@ -6711,6 +6718,7 @@ gfc_trans_omp_taskwait (gfc_code *code)
   stmtblock_t block;
   gfc_start_block (&block);
   tree stmt = make_node (OMP_TASK);
+  SET_EXPR_LOCATION (stmt, gfc_get_location (&code->loc));
   TREE_TYPE (stmt) = void_type_node;
   OMP_TASK_BODY (stmt) = NULL_TREE;
   OMP_TASK_CLAUSES (stmt) = gfc_trans_omp_clauses (&block,
@@ -6788,6 +6796,7 @@ gfc_trans_omp_distribute (gfc_code *code, gfc_omp_clauses *clausesa)
   if (flag_openmp)
     {
       tree distribute = make_node (OMP_DISTRIBUTE);
+      SET_EXPR_LOCATION (distribute, gfc_get_location (&code->loc));
       TREE_TYPE (distribute) = void_type_node;
       OMP_FOR_BODY (distribute) = stmt;
       OMP_FOR_CLAUSES (distribute) = omp_clauses;
@@ -7008,6 +7017,7 @@ gfc_trans_omp_taskloop (gfc_code *code, gfc_exec_op op)
   if (flag_openmp)
     {
       tree taskloop = make_node (OMP_TASKLOOP);
+      SET_EXPR_LOCATION (taskloop, gfc_get_location (&code->loc));
       TREE_TYPE (taskloop) = void_type_node;
       OMP_FOR_BODY (taskloop) = stmt;
       OMP_FOR_CLAUSES (taskloop) = omp_clauses;
@@ -7053,6 +7063,7 @@ gfc_trans_omp_master_masked_taskloop (gfc_code *code, gfc_exec_op op)
 					    &clausesa[GFC_OMP_SPLIT_MASKED],
 					    code->loc);
       tree msk = make_node (OMP_MASKED);
+      SET_EXPR_LOCATION (msk, gfc_get_location (&code->loc));
       TREE_TYPE (msk) = void_type_node;
       OMP_MASKED_BODY (msk) = stmt;
       OMP_MASKED_CLAUSES (msk) = clauses;

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Fortran: Add location info to OpenMP tree nodes
  2022-03-26  2:03 [PATCH] Fortran: Add location info to OpenMP tree nodes Sandra Loosemore
@ 2022-03-26  7:04 ` Jakub Jelinek
  2022-04-05  4:12 ` Sandra Loosemore
  1 sibling, 0 replies; 4+ messages in thread
From: Jakub Jelinek @ 2022-03-26  7:04 UTC (permalink / raw)
  To: Sandra Loosemore; +Cc: fortran, gcc-patches

On Fri, Mar 25, 2022 at 08:03:09PM -0600, Sandra Loosemore wrote:
> I've got another patch forthcoming (stage 1 material) that adds some new
> diagnostics for non-rectangular loops during gimplification of OMP nodes.
> When I was working on that, I discovered that the Fortran front end wasn't
> attaching location information to the tree nodes corresponding to the
> various OMP directives, so the new errors weren't coming out with location
> info either.  I went through trans-openmp.cc and fixed all the places where
> make_node was being called to explicitly set the location.
> 
> I don't have a test case specifically for this change, but my test cases for
> the new diagnostics in the non-rectangular loops patch do exercise it.  Is
> this OK for trunk now, or for stage 1 when we get there?

Ok for GCC 13.

> commit 4c745003d0b39d0e92032b62421df4920753783a
> Author: Sandra Loosemore <sandra@codesourcery.com>
> Date:   Thu Mar 24 21:02:34 2022 -0700
> 
>     Fortran: Add location info to OpenMP tree nodes
>     
>     	 gcc/fortran/
>     	 * trans-openmp.cc (gfc_trans_omp_critical): Set location on OMP
>     	 tree node.
>     	 (gfc_trans_omp_do): Likewise.
>     	 (gfc_trans_omp_masked): Likewise.
>     	 (gfc_trans_omp_do_simd): Likewise.
>     	 (gfc_trans_omp_scope): Likewise.
>     	 (gfc_trans_omp_taskgroup): Likewise.
>     	 (gfc_trans_omp_taskwait): Likewise.
>     	 (gfc_trans_omp_distribute): Likewise.
>     	 (gfc_trans_omp_taskloop): Likewise.
>     	 (gfc_trans_omp_master_masked_taskloop): Likewise.

	Jakub


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Fortran: Add location info to OpenMP tree nodes
  2022-03-26  2:03 [PATCH] Fortran: Add location info to OpenMP tree nodes Sandra Loosemore
  2022-03-26  7:04 ` Jakub Jelinek
@ 2022-04-05  4:12 ` Sandra Loosemore
  2022-04-05  6:27   ` Richard Biener
  1 sibling, 1 reply; 4+ messages in thread
From: Sandra Loosemore @ 2022-04-05  4:12 UTC (permalink / raw)
  To: fortran; +Cc: gcc-patches

On 3/25/22 20:03, Sandra Loosemore wrote:
> I've got another patch forthcoming (stage 1 material) that adds some new 
> diagnostics for non-rectangular loops during gimplification of OMP 
> nodes.  When I was working on that, I discovered that the Fortran front 
> end wasn't attaching location information to the tree nodes 
> corresponding to the various OMP directives, so the new errors weren't 
> coming out with location info either.  I went through trans-openmp.cc 
> and fixed all the places where make_node was being called to explicitly 
> set the location.
> 
> I don't have a test case specifically for this change, but my test cases 
> for the new diagnostics in the non-rectangular loops patch do exercise 
> it.  Is this OK for trunk now, or for stage 1 when we get there?

Ping!  Even a quick review and "this isn't suitable for GCC 12" answer 
would be helpful.

https://gcc.gnu.org/pipermail/fortran/2022-March/057706.html

The definitely-stage-1 patch that exercises this is here:

https://gcc.gnu.org/pipermail/fortran/2022-March/057707.html

-Sandra

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Fortran: Add location info to OpenMP tree nodes
  2022-04-05  4:12 ` Sandra Loosemore
@ 2022-04-05  6:27   ` Richard Biener
  0 siblings, 0 replies; 4+ messages in thread
From: Richard Biener @ 2022-04-05  6:27 UTC (permalink / raw)
  To: Sandra Loosemore; +Cc: fortran, gcc-patches

On Tue, Apr 5, 2022 at 6:12 AM Sandra Loosemore <sandra@codesourcery.com> wrote:
>
> On 3/25/22 20:03, Sandra Loosemore wrote:
> > I've got another patch forthcoming (stage 1 material) that adds some new
> > diagnostics for non-rectangular loops during gimplification of OMP
> > nodes.  When I was working on that, I discovered that the Fortran front
> > end wasn't attaching location information to the tree nodes
> > corresponding to the various OMP directives, so the new errors weren't
> > coming out with location info either.  I went through trans-openmp.cc
> > and fixed all the places where make_node was being called to explicitly
> > set the location.
> >
> > I don't have a test case specifically for this change, but my test cases
> > for the new diagnostics in the non-rectangular loops patch do exercise
> > it.  Is this OK for trunk now, or for stage 1 when we get there?
>
> Ping!  Even a quick review and "this isn't suitable for GCC 12" answer
> would be helpful.
>
> https://gcc.gnu.org/pipermail/fortran/2022-March/057706.html

OK if nobody objects in 24h.

Richard.

> The definitely-stage-1 patch that exercises this is here:
>
> https://gcc.gnu.org/pipermail/fortran/2022-March/057707.html
>
> -Sandra

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-04-05 10:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-26  2:03 [PATCH] Fortran: Add location info to OpenMP tree nodes Sandra Loosemore
2022-03-26  7:04 ` Jakub Jelinek
2022-04-05  4:12 ` Sandra Loosemore
2022-04-05  6:27   ` Richard Biener

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).