On 30/10/2020 08:53, YaRu Wei(魏亚茹) wrote:
> Dear gcc:
> I find that disassemble the .lib file compiled with 
> gcc-arm-8.3-2019.03-x86_64-arm-eabi compilation tool chain, and found that 
> malloc is optimized to calloc. I want to know under what circumstances malloc 
> will be optimized to calloc?
> Thanks
> 

I would presume this would happen if the call to malloc were immediately
followed by a call to memset to clear the memory (or an equivalent
software coded implementation of memset were detected).  Generally,
calloc has a better idea of the memory being allocated and can optimize
the clearing step if it knows the memory is already zeroed.

R.

Reply via email to