public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH, OpenMP, Fortran] PR103643: ICE in gimplify_omp_affinity
@ 2022-01-03 14:51 Chung-Lin Tang
  2022-01-03 15:09 ` Jakub Jelinek
  0 siblings, 1 reply; 2+ messages in thread
From: Chung-Lin Tang @ 2022-01-03 14:51 UTC (permalink / raw)
  To: gcc-patches, Jakub Jelinek, Tobias Burnus

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

After the PR90030 patch, which removes the universal casting of all Fortran array pointers to 'c_char*',
a Fortran descriptor based array passed into an affinity() clause now looks like:

-     #pragma omp task private(i) shared(b) affinity(*(c_char *) a.data)
+     #pragma omp task private(i) shared(b) affinity(*(integer(kind=4)[0:] * restrict) a.data)

The 'integer(kind=4)[0:]' incomplete type appears to be causing ICE during gimplify_expr() due to
is_gimple_val, fb_rvalue. The ICE appears to be fixed just by adjusting to 'is_gimple_lvalue, fb_lvalue'.
Considering the use of the affinity() clause, which should be specifying the location of a particular
object in memory, this probably makes sense.

Tested without regressions, seeking approval for trunk.

Thanks,
Chung-Lin

2022-01-03  Chung-Lin Tang  <cltang@codesourcery.com>

gcc/ChangeLog:

	PR middle-end/103643
	* gimplify.c (gimplify_omp_affinity): Adjust gimplify_expr of entire
	OMP_CLAUSE_DECL to use 'is_gimple_lvalue, fb_lvalue'

gcc/testsuite/ChangeLog:

	* gfortran.dg/gomp/pr103643.f90: New test.

[-- Attachment #2: pr103643.patch --]
[-- Type: text/plain, Size: 1058 bytes --]

diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index b118c72f62c..87cc01483dd 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -8123,7 +8123,7 @@ gimplify_omp_affinity (tree *list_p, gimple_seq *pre_p)
 	    if (error_operand_p (OMP_CLAUSE_DECL (c)))
 	      return;
 	    if (gimplify_expr (&OMP_CLAUSE_DECL (c), pre_p, NULL,
-			       is_gimple_val, fb_rvalue) == GS_ERROR)
+			       is_gimple_lvalue, fb_lvalue) == GS_ERROR)
 	      return;
 	    gimplify_and_add (OMP_CLAUSE_DECL (c), pre_p);
 	  }
diff --git a/gcc/testsuite/gfortran.dg/gomp/pr103643.f90 b/gcc/testsuite/gfortran.dg/gomp/pr103643.f90
new file mode 100644
index 00000000000..3b409f5f858
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/gomp/pr103643.f90
@@ -0,0 +1,19 @@
+! PR middle-end/103643
+! { dg-do compile }
+
+program test_task_affinity
+  implicit none
+  integer i
+  integer, allocatable :: A(:)
+
+  allocate (A(10))
+
+  !$omp target
+  !$omp task affinity(A)
+  do i = 1, 10
+     A(i) = 0
+  end do
+  !$omp end task
+  !$omp end target
+
+end program test_task_affinity

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

* Re: [PATCH, OpenMP, Fortran] PR103643: ICE in gimplify_omp_affinity
  2022-01-03 14:51 [PATCH, OpenMP, Fortran] PR103643: ICE in gimplify_omp_affinity Chung-Lin Tang
@ 2022-01-03 15:09 ` Jakub Jelinek
  0 siblings, 0 replies; 2+ messages in thread
From: Jakub Jelinek @ 2022-01-03 15:09 UTC (permalink / raw)
  To: Chung-Lin Tang; +Cc: gcc-patches, Tobias Burnus

On Mon, Jan 03, 2022 at 10:51:49PM +0800, Chung-Lin Tang wrote:
> After the PR90030 patch, which removes the universal casting of all Fortran array pointers to 'c_char*',
> a Fortran descriptor based array passed into an affinity() clause now looks like:
> 
> -     #pragma omp task private(i) shared(b) affinity(*(c_char *) a.data)
> +     #pragma omp task private(i) shared(b) affinity(*(integer(kind=4)[0:] * restrict) a.data)
> 
> The 'integer(kind=4)[0:]' incomplete type appears to be causing ICE during gimplify_expr() due to
> is_gimple_val, fb_rvalue. The ICE appears to be fixed just by adjusting to 'is_gimple_lvalue, fb_lvalue'.
> Considering the use of the affinity() clause, which should be specifying the location of a particular
> object in memory, this probably makes sense.
> 
> Tested without regressions, seeking approval for trunk.
> 
> Thanks,
> Chung-Lin
> 
> 2022-01-03  Chung-Lin Tang  <cltang@codesourcery.com>
> 
> gcc/ChangeLog:
> 
> 	PR middle-end/103643
> 	* gimplify.c (gimplify_omp_affinity): Adjust gimplify_expr of entire
> 	OMP_CLAUSE_DECL to use 'is_gimple_lvalue, fb_lvalue'
> 
> gcc/testsuite/ChangeLog:
> 
> 	* gfortran.dg/gomp/pr103643.f90: New test.

Ok, thanks.

	Jakub


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

end of thread, other threads:[~2022-01-03 15:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-03 14:51 [PATCH, OpenMP, Fortran] PR103643: ICE in gimplify_omp_affinity Chung-Lin Tang
2022-01-03 15:09 ` Jakub Jelinek

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