Re: [PATCH, PR68716] Fix GOMP/GOACC_parallel handling in find_func_clobbers

2015-12-09 Thread Jakub Jelinek
On Wed, Dec 09, 2015 at 11:01:31AM +0100, Tom de Vries wrote:
>   PR tree-optimization/68716
>   * tree-ssa-structalias.c (find_func_clobbers): Fix handling of
>   BUILT_IN_GOMP_PARALLEL and BUILT_IN_GOMP_PARALLEL.

Pasto in ChangeLog entry?

Jakub


Re: [PATCH, PR68716] Fix GOMP/GOACC_parallel handling in find_func_clobbers

2015-12-09 Thread Tom de Vries

On 09/12/15 11:03, Jakub Jelinek wrote:

On Wed, Dec 09, 2015 at 11:01:31AM +0100, Tom de Vries wrote:

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


Pasto in ChangeLog entry?



Indeed, thanks for noticing.

- Tom

Fix GOMP/GOACC_parallel handling in find_func_clobbers

2015-12-08  Tom de Vries  

	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.

---
 gcc/tree-ssa-structalias.c | 47 +-
 libgomp/testsuite/libgomp.c/omp-nested-2.c |  4 +++
 2 files changed, 50 insertions(+), 1 deletion(-)

diff --git a/gcc/tree-ssa-structalias.c b/gcc/tree-ssa-structalias.c
index 060ff3e..15e351e 100644
--- a/gcc/tree-ssa-structalias.c
+++ b/gcc/tree-ssa-structalias.c
@@ -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, );
+	  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...  */
diff --git a/libgomp/testsuite/libgomp.c/omp-nested-2.c b/libgomp/testsuite/libgomp.c/omp-nested-2.c
new file mode 100644
index 000..7495afb
--- /dev/null
+++ b/libgomp/testsuite/libgomp.c/omp-nested-2.c
@@ -0,0 +1,4 @@
+// { dg-do run }
+// { dg-additional-options "-fipa-pta" }
+
+#include "omp-nested-1.c"


Re: [PATCH, PR68716] Fix GOMP/GOACC_parallel handling in find_func_clobbers

2015-12-09 Thread Richard Biener
On Wed, 9 Dec 2015, Jakub Jelinek wrote:

> On Wed, Dec 09, 2015 at 11:01:31AM +0100, Tom de Vries wrote:
> > PR tree-optimization/68716
> > * tree-ssa-structalias.c (find_func_clobbers): Fix handling of
> > BUILT_IN_GOMP_PARALLEL and BUILT_IN_GOMP_PARALLEL.
> 
> Pasto in ChangeLog entry?

Ok with that fixed.

Richard.