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
> 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);
>
> instead of all the gimple stmt building. Note that points-to doesn't
> care about types at all.
Indeed, this is much cleaner. Thanks so much. Check out the updated
patch below. Everything's working.
> Btw, re-computing PTA after tm lowering should probably done
> somewhere more strathegic, dependent on where that is done.
Do you suggest another pass_tm_* spot to put the TODO_rebuild_alias?
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)
@@ -1275,6 +1275,7 @@ struct gimple_opt_pass pass_tm_mark =
0, /* todo_flags_start */
TODO_update_ssa
| TODO_verify_ssa
+ | TODO_rebuild_alias
| TODO_dump_func, /* todo_flags_finish */
}
};
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. */