This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [trans-mem] make alias oracle understand TM read/writes
- From: Aldy Hernandez <aldyh at redhat dot com>
- To: Richard Guenther <rguenther at suse dot de>
- Cc: Richard Henderson <rth at redhat dot com>, Daniel Berlin <dberlin at dberlin dot org>, gcc-patches at gcc dot gnu dot org
- Date: Tue, 1 Sep 2009 10:20:01 -0400
- Subject: Re: [trans-mem] make alias oracle understand TM read/writes
- References: <20090831152210.GA24694@redhat.com> <alpine.LNX.2.00.0908311725450.28140@zhemvz.fhfr.qr> <20090831203402.GA615@redhat.com> <4aca3dc20908311355r6b680e26h820e5815357cc47c@mail.gmail.com> <alpine.LNX.2.00.0908312328460.28140@zhemvz.fhfr.qr> <4A9C44A2.5020403@redhat.com> <alpine.LNX.2.00.0908312348300.28140@zhemvz.fhfr.qr> <4A9C4F07.7050603@redhat.com> <alpine.LNX.2.00.0909011010540.28140@zhemvz.fhfr.qr>
> > It does occur to me that having the TM builtins in the
> > table is still useful. If the user writes their own
> > TM wrapper functions, they're allowed to use the whole
> > library interface directly. So while it seems like we
> > would not need to add them to the table for compiler
> > generated code, these builtins could still appear in
> > user code directly.
>
> If that is the case then yes, the patch is still useful (without
> the PTA recomputation).
So, is the patch approved? I think it's safe to say you (Richard G) can
approve it and rth won't have any issues. Otherwise I can take the
blame.
I just want to get onto a trunk->TM merge.
Patch below. No changes, just for reference.
Aldy
* tree-ssa-alias.c (ref_maybe_used_by_call_p_1): Handle TM builtins.
(call_may_clobber_ref_p_1): Same.
* tree-ssa-structalias.c (find_func_aliases): Same.
Fix function comment to reflect reality.
Index: testsuite/gcc.dg/tm/alias-1.c
===================================================================
--- testsuite/gcc.dg/tm/alias-1.c (revision 0)
+++ testsuite/gcc.dg/tm/alias-1.c (revision 0)
@@ -0,0 +1,19 @@
+/* { dg-do compile } */
+/* { dg-options "-fgnu-tm -fdump-tree-tmmark -O" } */
+
+struct mystruct_type {
+ int *ptr;
+} *mystruct;
+
+int *someptr;
+
+void f(void)
+{
+ __tm_atomic {
+ mystruct->ptr = someptr;
+ }
+}
+
+/* { dg-final { scan-tree-dump-times "mystruct = \{ ESCAPED" 1 "tmmark" } } */
+/* { dg-final { scan-tree-dump-times "someptr = same as mystruct" 1 "tmmark" } } */
+/* { dg-final { cleanup-tree-dump "tmmark" } } */
Index: tree-ssa-alias.c
===================================================================
--- tree-ssa-alias.c (revision 151124)
+++ tree-ssa-alias.c (working copy)
@@ -886,8 +886,8 @@ ref_maybe_used_by_call_p_1 (gimple call,
&& DECL_BUILT_IN_CLASS (callee) == BUILT_IN_NORMAL)
switch (DECL_FUNCTION_CODE (callee))
{
- /* All the following functions clobber memory pointed to by
- their first argument. */
+ /* All the following functions read memory pointed to by
+ their second argument. */
case BUILT_IN_STRCPY:
case BUILT_IN_STRNCPY:
case BUILT_IN_BCOPY:
@@ -898,10 +898,22 @@ ref_maybe_used_by_call_p_1 (gimple call,
case BUILT_IN_STPNCPY:
case BUILT_IN_STRCAT:
case BUILT_IN_STRNCAT:
+ case BUILT_IN_TM_MEMCPY:
+ case BUILT_IN_TM_MEMMOVE:
{
tree src = gimple_call_arg (call, 1);
return ptr_deref_may_alias_ref_p (src, ref);
}
+ /* The following functions read memory pointed to by their
+ first argument. */
+ case BUILT_IN_TM_LOAD_1:
+ case BUILT_IN_TM_LOAD_2:
+ case BUILT_IN_TM_LOAD_4:
+ case BUILT_IN_TM_LOAD_8:
+ case BUILT_IN_TM_LOAD_FLOAT:
+ case BUILT_IN_TM_LOAD_DOUBLE:
+ case BUILT_IN_TM_LOAD_LDOUBLE:
+ return ptr_deref_may_alias_ref_p (gimple_call_arg (call, 0), ref);
/* The following builtins do not read from memory. */
case BUILT_IN_FREE:
case BUILT_IN_MEMSET:
@@ -1106,6 +1118,15 @@ call_may_clobber_ref_p_1 (gimple call, a
case BUILT_IN_STPNCPY:
case BUILT_IN_STRCAT:
case BUILT_IN_STRNCAT:
+ case BUILT_IN_TM_STORE_1:
+ case BUILT_IN_TM_STORE_2:
+ case BUILT_IN_TM_STORE_4:
+ case BUILT_IN_TM_STORE_8:
+ case BUILT_IN_TM_STORE_FLOAT:
+ case BUILT_IN_TM_STORE_DOUBLE:
+ case BUILT_IN_TM_STORE_LDOUBLE:
+ case BUILT_IN_TM_MEMCPY:
+ case BUILT_IN_TM_MEMMOVE:
{
tree dest = gimple_call_arg (call, 0);
return ptr_deref_may_alias_ref_p_1 (dest, ref);
Index: trans-mem.c
===================================================================
--- trans-mem.c (revision 151125)
+++ trans-mem.c (working copy)
@@ -1255,7 +1255,7 @@ execute_tm_mark (void)
VEC_free (basic_block, heap, queue);
- return 0;
+ return TODO_rebuild_alias;
}
struct gimple_opt_pass pass_tm_mark =
Index: tree-ssa-structalias.c
===================================================================
--- tree-ssa-structalias.c (revision 151124)
+++ tree-ssa-structalias.c (working copy)
@@ -3589,13 +3589,11 @@ handle_pure_call (gimple stmt, VEC(ce_s,
/* Walk statement T setting up aliasing constraints according to the
references found in T. This function is the main part of the
- constraint builder. AI points to auxiliary alias information used
- when building alias sets and computing alias grouping heuristics. */
+ constraint builder. */
static void
-find_func_aliases (gimple origt)
+find_func_aliases (gimple t)
{
- gimple t = origt;
VEC(ce_s, heap) *lhsc = NULL;
VEC(ce_s, heap) *rhsc = NULL;
struct constraint_expr *c;
@@ -3668,6 +3666,8 @@ find_func_aliases (gimple origt)
case BUILT_IN_STPNCPY:
case BUILT_IN_STRCAT:
case BUILT_IN_STRNCAT:
+ case BUILT_IN_TM_MEMCPY:
+ case BUILT_IN_TM_MEMMOVE:
{
tree res = gimple_call_lhs (t);
tree dest = gimple_call_arg (t, 0);
@@ -3728,6 +3728,44 @@ find_func_aliases (gimple origt)
VEC_free (ce_s, heap, lhsc);
return;
}
+ case BUILT_IN_TM_STORE_1:
+ case BUILT_IN_TM_STORE_2:
+ case BUILT_IN_TM_STORE_4:
+ case BUILT_IN_TM_STORE_8:
+ case BUILT_IN_TM_STORE_FLOAT:
+ case BUILT_IN_TM_STORE_DOUBLE:
+ case BUILT_IN_TM_STORE_LDOUBLE:
+ {
+ tree addr = gimple_call_arg (t, 0);
+ tree src = gimple_call_arg (t, 1);
+
+ get_constraint_for (addr, &lhsc);
+ do_deref (&lhsc);
+ get_constraint_for (src, &rhsc);
+ process_all_all_constraints (lhsc, rhsc);
+ VEC_free (ce_s, heap, lhsc);
+ VEC_free (ce_s, heap, rhsc);
+ return;
+ }
+ case BUILT_IN_TM_LOAD_1:
+ case BUILT_IN_TM_LOAD_2:
+ case BUILT_IN_TM_LOAD_4:
+ case BUILT_IN_TM_LOAD_8:
+ case BUILT_IN_TM_LOAD_FLOAT:
+ case BUILT_IN_TM_LOAD_DOUBLE:
+ case BUILT_IN_TM_LOAD_LDOUBLE:
+ {
+ tree dest = gimple_call_lhs (t);
+ tree addr = gimple_call_arg (t, 0);
+
+ get_constraint_for (dest, &lhsc);
+ get_constraint_for (addr, &rhsc);
+ do_deref (&rhsc);
+ process_all_all_constraints (lhsc, rhsc);
+ VEC_free (ce_s, heap, lhsc);
+ VEC_free (ce_s, heap, rhsc);
+ return;
+ }
/* All the following functions do not return pointers, do not
modify the points-to sets of memory reachable from their
arguments and do not add to the ESCAPED solution. */