[LLVMdev] optimization assumes malloc return is non-null
John Regehr
regehr at cs.utah.edu
Mon Jun 23 11:29:01 PDT 2008
To say that LLVM *assumes* that malloc() succeeds or fails is misleading.
This misstatement may be the root of people's ongoing problems in
understanding this transformation and its validity.
The right way to think about it is: LLVM is supplying an alternate
implementation of malloc that happens to run at compile time, and happens
to succeed all the time. This implementation is -- as I understand the C
standard -- a perfectly legal one. It has nothing to do with the version
of malloc() found in libc except that the two implementations share a
common API.
An implementation of malloc that always fails at compile time is legal
too, but useless.
John Regehr
More information about the llvm-dev
mailing list