[LLVMdev] malloc vs malloc

Jon Harrop jon at ffconsultancy.com
Tue Dec 23 09:14:08 PST 2008


I discovered that LLVM's malloc only allows a 32-bit size argument, so you 
cannot use it to allocate huge blocks on 64-bit machines. So I considered 
replacing all of my uses of LLVM's malloc instruction with calls to the libc 
malloc function instead. That got me wondering why LLVM even has its own 
malloc intrinsic anyway...

Am I correct in assuming that LLVM's malloc intrinsic exists so that some 
optimization passes can rewrite it, e.g. replacing heap allocation with stack 
allocation when no part of the allocated value escapes scope? So replacing 
all of my uses of LLVM's malloc with libc's malloc might hamper LLVM's 
optimizations and degrade performance?

-- 
Dr Jon Harrop, Flying Frog Consultancy Ltd.
http://www.ffconsultancy.com/?e



More information about the llvm-dev mailing list