> On Tue, Jan 24, 2017 at 05:27:26PM +0000, David Sherwood wrote: > > I have a patch to fix the following openmp issue: > > > > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79212 > > > > Writing openmp directives in a certain way in fortran programs can > > lead to the following assert: > > > > internal compiler error: in maybe_lookup_decl_in_outer_ctx, at > > omp-low.c:4134 > > 0xa941e6 maybe_lookup_decl_in_outer_ctx > > /work/davshe01/oban-work-shoji/src/gcc/gcc/omp-low.c:4134 > > 0xa9cadc scan_sharing_clauses > > /work/davshe01/oban-work-shoji/src/gcc/gcc/omp-low.c:1975 > > > > Tested: > > aarch64 - No regressions in gcc/testsuite/fortran.dg, > > gcc/testsuite/gcc.dg, gcc/testsuite/g++.dg or libgomp/testsuite > > > > Will do a full test run before submitting. > > > > Good to go? > > David Sherwood. > > > > ChangeLog: > > > > 2017-01-24 David Sherwood <david.sherw...@arm.com> > > > > PR middle-end/79212 > > This line should be intended by a single tab. > > > gcc/ > > * gimplify.c (omp_notice_variable): Add GOVD_SEEN flag to variables > > in > all contexts. > > These too. > > > gcc/testsuite/ > > * gfortran.dg/gomp/sharing-4.f90: New test. > > > > --- a/gcc/gimplify.c > +++ b/gcc/gimplify.c > @@ -7147,12 +7147,9 @@ omp_notice_variable (struct gimplify_omp_ctx > *ctx, tree decl, bool in_code) > && (TREE_CODE (TYPE_SIZE_UNIT (TREE_TYPE (TREE_TYPE > (decl)))) > != INTEGER_CST)) > { > - splay_tree_node n2; > tree t = TYPE_SIZE_UNIT (TREE_TYPE (TREE_TYPE (decl))); > gcc_assert (DECL_P (t)); > - n2 = splay_tree_lookup (ctx->variables, (splay_tree_key) t); > - if (n2) > - n2->value |= GOVD_SEEN; > + omp_notice_variable (ctx, t, true); > } > } > > As this is conditional, if the decl won't be in ctx->variables splay tree, bad > things will happen (omp_notice_variable could complain loudly, or make it > shared etc. or whatever the default is). So perhaps it should be > instead: > splay_tree_node n2; > tree t = TYPE_SIZE_UNIT (TREE_TYPE (TREE_TYPE (decl))); > gcc_assert (DECL_P (t)); > n2 = splay_tree_lookup (ctx->variables, (splay_tree_key) t); > if (n2) > omp_notice_variable (ctx, t, true); > > Ok for trunk with those changes. > > Jakub
Hi, Thanks for the reply. I made the changes you suggested and have just committed the following to trunk: Index: gcc/ChangeLog =================================================================== --- gcc/ChangeLog (revision 244921) +++ gcc/ChangeLog (working copy) @@ -1,3 +1,9 @@ +2017-01-26 David Sherwood <david.sherw...@arm.com> + + PR middle-end/79212 + * gimplify.c (omp_notice_variable): Add GOVD_SEEN flag to variables in + all contexts. + 2017-01-26 Jakub Jelinek <ja...@redhat.com> PR target/70465 Index: gcc/testsuite/gfortran.dg/gomp/sharing-4.f90 =================================================================== --- gcc/testsuite/gfortran.dg/gomp/sharing-4.f90 (revision 0) +++ gcc/testsuite/gfortran.dg/gomp/sharing-4.f90 (revision 244922) @@ -0,0 +1,24 @@ +! { dg-do compile } +! { dg-options "-fopenmp" } + +subroutine foo (v, n, r) + integer :: n + integer, intent(in) :: v(:) + integer, intent(out) :: r + integer :: i + + r = 0 + +!$omp parallel +!$omp single + + do i = 1, n +!$omp task shared (v) + r = r + v(i) +!$omp end task + enddo + +!$omp end single +!$omp end parallel + +end Index: gcc/testsuite/ChangeLog =================================================================== --- gcc/testsuite/ChangeLog (revision 244921) +++ gcc/testsuite/ChangeLog (working copy) @@ -1,3 +1,8 @@ +2017-01-26 David Sherwood <david.sherw...@arm.com> + + PR middle-end/79212 + * gfortran.dg/gomp/sharing-4.f90: New test. + 2017-01-26 Jakub Jelinek <ja...@redhat.com> PR target/70465 Index: gcc/gimplify.c =================================================================== --- gcc/gimplify.c (revision 244921) +++ gcc/gimplify.c (working copy) @@ -7152,7 +7152,7 @@ gcc_assert (DECL_P (t)); n2 = splay_tree_lookup (ctx->variables, (splay_tree_key) t); if (n2) - n2->value |= GOVD_SEEN; + omp_notice_variable (ctx, t, true); } }