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: calloc = malloc + memset


On Tue, Jul 15, 2014 at 2:33 PM, Bernd Schmidt <bernds_cb1@t-online.de> wrote:
> On 02/28/2014 11:48 PM, Marc Glisse wrote:
>>
>> /* Optimize
>> +   ptr = malloc (n);
>> +   memset (ptr, 0, n);
>> +   into
>> +   ptr = calloc (n);
>> +   gsi_p is known to point to a call to __builtin_memset.  */
>
>
> Is there anything in here to prevent us making an infinite loop if the above
> pattern occurs in a function called "calloc"?

Nothing.  See how I ended up doing

2014-05-06  Richard Biener  <rguenther@suse.de>

        * c-opts.c (c_common_post_options): For -freestanding,
        -fno-hosted and -fno-builtin disable pattern recognition
        if not enabled explicitely.

to avoid sth like this for memset/memcpy/memmove recognition.

Richard.

>
> Bernd
>


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