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 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.


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