[LLVMdev] libc malloc vs. llvm::MallocInst

TU Dresden stefan.weigert at mailbox.tu-dresden.de
Fri Jun 20 03:56:48 PDT 2008


Hello,
have a short look at the following simple c-prog:

#include <stdlib.h>


int main(int argc, char* argv[]) {

void* buf = malloc(10 * sizeof(char*));

/* do sth with buf, so that it is not "optimized away" */


return 0;

}


When you compile this using a plain llvm-gcc, the call to libc-malloc is
left inside.But compiling it with -O2 alters the call to llvm::MallocInst.

Now i would like to know, why this is done.
Is the libc-malloc still used?

There is also a pass, called RaiseAllocation (well ... at least i think so)
and i remember in previous versions (2.2)
of llvm i read a commentary inside the sourcecode that the pass should be
used with care because
llvm::MallocInst is not platform-independent. This commentary is removed in
the current version. - Why?

This is nothing serious - i am just curious to know some more details :)

Thank you in advance.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20080620/eb2f8de2/attachment.html>


More information about the llvm-dev mailing list