This is the mail archive of the gcc@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: avoiding recursive calls of calloc due to optimization


On Mon, Sep 21, 2015 at 8:17 PM, Marc Glisse <marc.glisse@inria.fr> wrote:
> On Mon, 21 Sep 2015, Daniel Gutson wrote:
>
>> This is derived from https://gcc.gnu.org/ml/gcc-help/2015-03/msg00091.html
>>
>> Currently, gcc provides an optimization that transforms a call to
>> malloc and a call to memset into a call to calloc.
>> This is fine except when it takes place within the calloc() function
>> implementation itself, causing a recursive call.
>> Two alternatives have been proposed: -fno-malloc-builtin and disable
>> optimizations in calloc().
>> I think the former is suboptimal since it affects all the code just
>> because of the implementation of one function (calloc()),
>> whereas the latter is suboptimal too since it disables the
>> optimizations in the whole function (calloc too).
>> I think of two alternatives: either make -fno-calloc-builtin to
>> disable the optimization, or make the optimization aware of the
>> function context where it is operating and prevent it to do the
>> transformation if the function is calloc().
>>
>> Please help me to find the best alternative so we can implent it.
>
>
> You may want to read this PR for more context
>
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56888#c27

Yeah, I think the proper way is to add a helper to symtab to
query whether the current function is BUILT_IN_XXX and use that
to fend of most of the "obvious" cases.

Richard.

> --
> Marc Glisse


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