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

Richard Guenther richard.guenther@gmail.com
Fri Dec 4 17:07:00 GMT 2009


On Fri, Dec 4, 2009 at 5:47 PM, Richard Henderson <rth@redhat.com> wrote:
> On 12/04/2009 08:40 AM, Richard Guenther wrote:
>>>
>>> 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.
>
> ... So?  Isn't that exactly what we want?

I'm not sure - I didn't look at the context ;)

> Do note that unless the user *also* annotates his function for transactional
> memory, we'll enter serial-irrevocable mode.  Which for this particular test
> case including __transaction_cancel would be verboten and enforced by the
> front end.  So we can assume that the user has also done what ever needs
> doing to release the memory on transaction restart.

Well ...

"There is no need to instrument malloc/alloca memory being dereferenced
in a transaction if it can be proven that the memory was allocated
inside the transaction and cannot escape.

There is no instrumenting to do because for alloca, a transaction
restart will reset the stack pointer and we'll just reallocate again.
For malloc, a transaction restart will free the memory, and we'll also
reallocate again."

I guess it all depends on how you'd instrument malloc/alloca
(and how you identify them in that case).  Or how the transaction reset
will free the memory again.

That said, checking for ECF_MALLOC for something that isn't only
asking whether the returned pointer aliases looks fragile to me.

Richard.



More information about the Gcc-patches mailing list