diff mbox series

[og8] Don't rescan "attach" node for dereferenced struct member

Message ID 20190215184739.3cc27e70@squid.athome
State New
Headers show
Series [og8] Don't rescan "attach" node for dereferenced struct member | expand

Commit Message

Julian Brown Feb. 15, 2019, 6:47 p.m. UTC
Hi,

The following (og8 branch) patch added support for
attaching/detaching from dereferenced struct members:

https://gcc.gnu.org/ml/gcc-patches/2019-01/msg01778.html

Unfortunately I made a mistake in the portion of that patch that
inserts new alloc and firstprivate_pointer nodes for the struct base,
meaning that the node rewritten to an attach operation would be
scanned again. This is both unnecessary, and can cause problems in some
circumstances.

Tested with offloading to nvptx, no regressions and the new test passes.
I will apply (to the og8 branch) shortly.

Thanks,

Julian

ChangeLog

            gcc/
            * gimplify.c (gimplify_scan_omp_clauses): Avoid scanning
            'c' again after creating base-pointer nodes for
            dereferenced struct.

            gcc/testsuite/
            * gfortran.dg/goacc/derived-types-2.f90: New.
diff mbox series

Patch

commit e374d415801588435d62ac214e0313ffd3ef2198
Author: Julian Brown <julian@codesourcery.com>
Date:   Thu Feb 14 16:40:21 2019 -0800

    [og8] Don't rescan "attach" node for dereferenced struct member
    
            gcc/
            * gimplify.c (gimplify_scan_omp_clauses): Avoid scanning 'c' again
            after creating base-pointer nodes for dereferenced struct.
    
            gcc/testsuite/
            * gfortran.dg/goacc/derived-types-2.f90: New.

diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index 8bf11eb659e..2ff5b68e0cc 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -8289,8 +8289,6 @@  gimplify_scan_omp_clauses (tree *list_p, gimple_seq *pre_p,
 		      *list_p = c2;
 		      OMP_CLAUSE_CHAIN (c2) = c3;
 		      OMP_CLAUSE_CHAIN (c3) = c;
-		      c = c3;
-		      list_p = &OMP_CLAUSE_CHAIN (c3);
 
 		      struct_deref_set->add (decl);
 		    }
diff --git a/gcc/testsuite/gfortran.dg/goacc/derived-types-2.f90 b/gcc/testsuite/gfortran.dg/goacc/derived-types-2.f90
new file mode 100644
index 00000000000..d01583fac89
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/goacc/derived-types-2.f90
@@ -0,0 +1,14 @@ 
+module bar
+  type :: type1
+     real(8), pointer, public :: p(:) => null()
+  end type
+  type :: type2
+     class(type1), pointer :: p => null()
+  end type
+end module
+
+subroutine foo (var)
+   use bar
+   type(type2), intent(inout) :: var
+   !$acc enter data create(var%p%p)
+end subroutine