Fix GOMP/GOACC_parallel handling in find_func_clobbers
authorTom de Vries <tom@codesourcery.com>
Wed, 9 Dec 2015 10:13:35 +0000 (10:13 +0000)
committerTom de Vries <vries@gcc.gnu.org>
Wed, 9 Dec 2015 10:13:35 +0000 (10:13 +0000)
2015-12-09  Tom de Vries  <tom@codesourcery.com>

PR tree-optimization/68716
* tree-ssa-structalias.c (find_func_clobbers): Fix handling of
BUILT_IN_GOMP_PARALLEL and BUILT_IN_GOACC_PARALLEL.

* testsuite/libgomp.c/omp-nested-2.c: New test.

From-SVN: r231449

gcc/ChangeLog
gcc/tree-ssa-structalias.c
libgomp/ChangeLog
libgomp/testsuite/libgomp.c/omp-nested-2.c [new file with mode: 0644]

index aff215e889da737a87805cf0691dcff32800d0fb..82607d19ad4f5bbed46e7e76a3840019f68f2a6c 100644 (file)
@@ -1,3 +1,9 @@
+2015-12-09  Tom de Vries  <tom@codesourcery.com>
+
+       PR tree-optimization/68716
+       * tree-ssa-structalias.c (find_func_clobbers): Fix handling of
+       BUILT_IN_GOMP_PARALLEL and BUILT_IN_GOACC_PARALLEL.
+
 2015-12-09  Martin Liska  <mliska@suse.cz>
 
        * hash-traits.h (struct typed_delete_remove): New function.
index 060ff3efc1d71e7bac339fae917bfe95f7036806..15e351ebe592b8ab85c0d7dce360a5f9dfe2a64c 100644 (file)
@@ -5082,7 +5082,52 @@ find_func_clobbers (struct function *fn, gimple *origt)
            return;
          case BUILT_IN_GOMP_PARALLEL:
          case BUILT_IN_GOACC_PARALLEL:
-           return;
+           {
+             unsigned int fnpos, argpos;
+             switch (DECL_FUNCTION_CODE (decl))
+               {
+               case BUILT_IN_GOMP_PARALLEL:
+                 /* __builtin_GOMP_parallel (fn, data, num_threads, flags).  */
+                 fnpos = 0;
+                 argpos = 1;
+                 break;
+               case BUILT_IN_GOACC_PARALLEL:
+                 /* __builtin_GOACC_parallel (device, fn, mapnum, hostaddrs,
+                                              sizes, kinds, ...).  */
+                 fnpos = 1;
+                 argpos = 3;
+                 break;
+               default:
+                 gcc_unreachable ();
+               }
+
+             tree fnarg = gimple_call_arg (t, fnpos);
+             gcc_assert (TREE_CODE (fnarg) == ADDR_EXPR);
+             tree fndecl = TREE_OPERAND (fnarg, 0);
+             varinfo_t cfi = get_vi_for_tree (fndecl);
+
+             tree arg = gimple_call_arg (t, argpos);
+
+             /* Parameter passed by value is used.  */
+             lhs = get_function_part_constraint (fi, fi_uses);
+             struct constraint_expr *rhsp;
+             get_constraint_for (arg, &rhsc);
+             FOR_EACH_VEC_ELT (rhsc, j, rhsp)
+               process_constraint (new_constraint (lhs, *rhsp));
+             rhsc.truncate (0);
+
+             /* The caller clobbers what the callee does.  */
+             lhs = get_function_part_constraint (fi, fi_clobbers);
+             rhs = get_function_part_constraint (cfi, fi_clobbers);
+             process_constraint (new_constraint (lhs, rhs));
+
+             /* The caller uses what the callee does.  */
+             lhs = get_function_part_constraint (fi, fi_uses);
+             rhs = get_function_part_constraint (cfi, fi_uses);
+             process_constraint (new_constraint (lhs, rhs));
+
+             return;
+           }
          /* printf-style functions may have hooks to set pointers to
             point to somewhere into the generated string.  Leave them
             for a later exercise...  */
index cde0b5c55a3a2b260ba05d8373dc12d26294f201..1b12354a075c61b89c6ae8de10a1688d1f58a10e 100644 (file)
@@ -1,3 +1,8 @@
+2015-12-09  Tom de Vries  <tom@codesourcery.com>
+
+       PR tree-optimization/68716
+       * testsuite/libgomp.c/omp-nested-2.c: New test.
+
 2015-12-02  Thomas Schwinge  <thomas@codesourcery.com>
 
        * testsuite/libgomp.oacc-c-c++-common/host_data-2.c: Restrict to
diff --git a/libgomp/testsuite/libgomp.c/omp-nested-2.c b/libgomp/testsuite/libgomp.c/omp-nested-2.c
new file mode 100644 (file)
index 0000000..7495afb
--- /dev/null
@@ -0,0 +1,4 @@
+// { dg-do run }
+// { dg-additional-options "-fipa-pta" }
+
+#include "omp-nested-1.c"