[trans-mem] optimize transaction local malloc/alloca memory
Aldy Hernandez
aldyh@redhat.com
Fri Dec 4 18:15:00 GMT 2009
On Fri, Dec 04, 2009 at 08:32:13AM -0800, Richard Henderson wrote:
> 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.
I assume you're going to make me handle dereferencing of thread-private
memory with log functions or a local copy :-).
How about I make sure there are no instrumented calls whatsoever:
{ scan-tree-dump-times "ITM_WU|ITM_LU|tm_save" 1 "tmmark" }
?
> >+ 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
I thought of doing that, but decided against it because EFC_MALLOC was
set for user defined functions with the "malloc" attribute. Though, as
you pointed out to Richi, perhaps that is exactly what we want.
> >@@ -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.
Fair enough. Will do.
Aldy
More information about the Gcc-patches
mailing list