Recursive calloc() due to optimization
Sebastian Huber
sebastian.huber@embedded-brains.de
Wed Mar 25 13:07:00 GMT 2015
On 25/03/15 14:01, Marc Glisse wrote:
> On Wed, 25 Mar 2015, Sebastian Huber wrote:
>
>> Hello,
>>
>> I updated to GCC 5 and now it turns the RTEMS calloc() implementation
>> into
>>
>> Disassembly of section .text:
>>
>> 00000000 <calloc>:
>> 0: fb01 f000 mul.w r0, r1, r0
>> 4: 2101 movs r1, #1
>> 6: f7ff bffe b.w 0 <calloc>
>> a: bf00 nop
>>
>> on ARM. How can I disable this optimization? I tried
>>
>> __attribute__((__optimize__("-fno-builtin")))
>> void *calloc(
>> size_t nelem,
>> size_t elsize
>> )
>> {
>> char *cptr;
>> size_t length;
>>
>> length = nelem * elsize;
>> cptr = malloc( length );
>> if ( cptr )
>> memset( cptr, '\0', length );
>>
>> return cptr;
>> }
>>
>> but this doesn't work. It this one of the -fno-tree-* options?
>
> -fno-builtin is good, but you cannot use it in an optimize attribute.
This is quite confusing since for other optimiziations in this area it
works like that, e.g. glibc (include/libc-symbols.h):
/* Add the compiler optimization to inhibit loop transformation to library
calls. This is used to avoid recursive calls in memset and memmove
default implementations. */
#ifdef HAVE_CC_INHIBIT_LOOP_TO_LIBCALL
# define inhibit_loop_to_libcall \
__attribute__ ((__optimize__ ("-fno-tree-loop-distribute-patterns")))
#else
# define inhibit_loop_to_libcall
#endif
--
Sebastian Huber, embedded brains GmbH
Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone : +49 89 189 47 41-16
Fax : +49 89 189 47 41-09
E-Mail : sebastian.huber@embedded-brains.de
PGP : Public key available on request.
Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.
More information about the Gcc-help
mailing list