On Thu, Aug 22, 2013 at 10:21 AM, Jan Hubicka <hubi...@ucw.cz> wrote:
>> On Thu, 22 Aug 2013, Gabriel Dos Reis wrote:
>> > >  - I would like to recall issue if we can make NEW_EXPR annotated with
>> > >    MALLOC attribute.  Without it, it is basically impossible to track
>> > >    any dynamically allocated objects in the middle-end
>> >
>> > operator new is replaceable by user program.
>>
>> But so is malloc?  As I understand, the reason why "malloc" attribute is not
>> applicable to operator new is "placement new", which returns aliased memory.
>
> placement new is optimized to nothing, so it should not affect anything here.

Yup.

> MALLOC attribute makes the assumtion that you can not get to the return value 
> of
> the function from something that you had previously (i.e. you can not have
> existing pointer to that block of memory).  So you can not really implement
> malloc in the same compilation unit you are using it.

Exactly.  The same goes for any user allocators -- many of which tend
to be inline,
delegating the hard work to an off-line function.

>
> So the existing program needs to overwrite libsup++ symbol like we do with 
> malloc?
> Of course with user defineed malloc function we should not propagate the 
> attribute,
> but I think we could have it when we end up calling the runtime.

I suspect the question is whether our current infrastructure permits
to distinguish
between declaration of 'operator new' we supply, and 'operator new' defined by
user.  The way we currently arrange for user-defined 'operator new' to take
over is that it is something that is done at linktime, (so is LTO
prepared for this?)
and ours is searched last.

>
> Honza
>>
>> Alexander

Reply via email to