[LLVMdev] optimization assumes malloc return is non-null

Duncan Sands baldrick at free.fr
Wed May 14 07:31:05 PDT 2008


Hi,

> The substitution of malloc() is predicated on the assumption that the
> compiler knows the implementation of malloc(), and the argument for that
> seems to rest in part on the specification of the Standard C Library.
> 
> But I am not aware of any requirement that compliant C code must be
> linked with the Standard C Library. If this requirement does not exist,
> then no portion of the C library specification can be used to justify a
> compile-time optimization unless we have some sort of compilation model
> information that tells us the C library can be assumed.
> 
> Is there a requirement somewhere in the C *Language* Specification that
> ties all of this together in the required way?

this is what -ffreestanding is for.  More generally, don't run SimplifyLibcalls
if you are not going to link with the standard C library.

Ciao,

Duncan.



More information about the llvm-dev mailing list