[LLVMdev] FW: question about malloc call vs. instruction

Chris Lattner sabre at nondot.org
Wed Sep 11 13:45:01 PDT 2002

> printing out a bunch of instructions.  which reveals my new problem:  when
> i attempt a malloc in my own, it comes out like this:
>  %reg216 = call int (...)* %malloc( ulong 8 )            ; <int> [#uses=1]
> a call to malloc, not a malloc instruction.  i don't know how to get the
> information i need out of a call to malloc.

You need to #include <stdlib.h>.  Try compiling with warnings on (-Wall
-W), and you should get diagnostics for problems like this.

> when i replace 'malloc' in the code with 'alloca', i get
>  %reg107 = alloca ubyte, uint 8          ; <ubyte*> [#uses=1]
> so everything is fine for alloca.

alloca doesn't require a prototype.

> i thought if i ran the inline pass it might change a malloc call to a
> malloc instruction, but it didn't.  can you tell me what's up here?

No prototype = Not a known function...  The inlining pass shouldn't touch
malloc instructions/calls.  The malloc calls should be eliminated by a
pass "built into" the GCC frontend:


... but this only will work if there is a prototype for the function.


More information about the llvm-dev mailing list