diff mbox

[trans-mem] handle memset (PR/47492)

Message ID 4D499D90.2090301@redhat.com
State New
Headers show

Commit Message

Aldy Hernandez Feb. 2, 2011, 6:08 p.m. UTC
> Patrick's test case at the end of this thread can be handled
> with a separate one liner.

Well, I don't know about a one liner unless I'm missing something, but 
here goes...

I set the bits for TM memcpy/memmove as well, btw.

As always, thanks Patrick for keeping us honest :).

OK for branch?
* trans-mem.c (expand_call_tm): Annotate BUILT_IN_TM_* calls.
	(find_tm_replacement_function): Add comment.

Comments

Richard Henderson Feb. 3, 2011, 4:28 p.m. UTC | #1
On 02/02/2011 10:08 AM, Aldy Hernandez wrote:
> 	* trans-mem.c (expand_call_tm): Annotate BUILT_IN_TM_* calls.
> 	(find_tm_replacement_function): Add comment.

Ok.


r~
diff mbox

Patch

Index: testsuite/gcc.dg/tm/memset-2.c
===================================================================
--- testsuite/gcc.dg/tm/memset-2.c	(revision 0)
+++ testsuite/gcc.dg/tm/memset-2.c	(revision 0)
@@ -0,0 +1,17 @@ 
+/* { dg-do compile } */
+/* { dg-options "-fgnu-tm -fdump-tree-tmlower" } */
+
+char array[4];
+
+void *memset(void *s, int c, __SIZE_TYPE__);
+
+int main()
+{
+  __transaction [[atomic]] {
+    memset(array, 'b', sizeof(4));
+  }
+  return 0;
+}
+
+/* { dg-final { scan-tree-dump-times "GTMA_HAVE_STORE" 1 "tmlower" } } */
+/* { dg-final { cleanup-tree-dump "tmlower" } } */
Index: trans-mem.c
===================================================================
--- trans-mem.c	(revision 169535)
+++ trans-mem.c	(working copy)
@@ -478,6 +478,8 @@  find_tm_replacement_function (tree fndec
 
   /* ??? We may well want TM versions of most of the common <string.h>
      functions.  For now, we've already these two defined.  */
+  /* Adjust expand_call_tm() attributes as necessary for the cases
+     handled here:  */
   if (DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL)
     switch (DECL_FUNCTION_CODE (fndecl))
       {
@@ -2179,10 +2181,17 @@  expand_call_tm (struct tm_region *region
   struct cgraph_node *node;
   bool retval = false;
 
+  fn_decl = gimple_call_fndecl (stmt);
+
+  if (fn_decl == built_in_decls[BUILT_IN_TM_MEMCPY]
+      || fn_decl == built_in_decls[BUILT_IN_TM_MEMMOVE])
+    transaction_subcode_ior (region, GTMA_HAVE_STORE | GTMA_HAVE_LOAD);
+  if (fn_decl == built_in_decls[BUILT_IN_TM_MEMSET])
+    transaction_subcode_ior (region, GTMA_HAVE_STORE);
+
   if (is_tm_pure_call (stmt))
     return false;
 
-  fn_decl = gimple_call_fndecl (stmt);
   if (fn_decl)
     retval = is_tm_ending_fndecl (fn_decl);
   if (!retval)