This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [trans-mem] optimize transaction local malloc/alloca memory


On 12/04/2009 06:26 AM, Aldy Hernandez wrote:
+  p = malloc (sizeof (*p) * 100);
+
+  __transaction {
+    /* Instrument store, since memory pointed to by P is not
+       transaction local.  */
+    p[5] = 123;
+
+    if (something())
+      __transaction_cancel;
+  }
+  return p[5];
+}
+
+/* { dg-final { scan-tree-dump-times "ITM_WU" 1 "tmmark" } } */

Not the best test case to add, since P is thread-private. You could instrument this with either a log function or a local copy.


+ if (stmt&& is_gimple_call (stmt))

Formatting.


+      if (DECL_BUILT_IN_CLASS (fn) == BUILT_IN_NORMAL
+	&&  (DECL_FUNCTION_CODE (fn) == BUILT_IN_MALLOC
+	      || DECL_FUNCTION_CODE (fn) == BUILT_IN_ALLOCA))

gimple_call_flags (stmt) & ECF_MALLOC


@@ -1149,6 +1219,8 @@ requires_barrier (basic_block entry_bloc
    switch (TREE_CODE (x))
      {
      case INDIRECT_REF:
+      if (transaction_local_dynamic_memory_p (entry_block, TREE_OPERAND (x, 0)))
+	return false;

You're going to do the whole walking and analysis thing for every memory reference? I could imagine it'd be a lot better to cache this data so that in the next statement, which might well also use the same base SSA_NAME, doesn't have to re-do the analysis.



r~



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]