[trans-mem] optimize transaction local malloc/alloca memory
Richard Guenther
richard.guenther@gmail.com
Fri Dec 4 16:47:00 GMT 2009
On Fri, Dec 4, 2009 at 5:32 PM, Richard Henderson <rth@redhat.com> 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.
>
>> + 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
That's not a check for malloc but just for if the function returns a
pointer to non-aliased memory. I could imagine this to trigger
falsely for user-annotated functions, so IMHO testing for the
builtins is better (where you btw miss BUILT_IN_CALLOC).
Richard.
More information about the Gcc-patches
mailing list