[LLVMdev] How to cast an integer array to an integer pointer? (user question)

Eli Friedman eli.friedman at gmail.com
Wed May 5 18:41:08 PDT 2010


On Wed, May 5, 2010 at 4:05 PM, Yuri <yuri at tsoft.com> wrote:
> I am new to LLVM and couldn't find any llvm-user list, so I am posting
> my user question here, sorry.

This is the right mailing list for user questions.

> I am trying to create a simple "puts" call accepting the static string,
> with the code below.
> The last line (CallInst::Create) fails with an assert: "Calling a
> function with a bad signature!"
> Because the type of function is void(u8*) and the argument supplied is:
> getelementptr inbounds [4 x i8]* @0, i32 0
> How to convert the pointer to the array to u8* ? I tried BitCastInst but
> it inserts an explicit bitcast. I don't think this is right.

I think you're misunderstanding how the getelementptr instruction
works; see http://llvm.org/docs/GetElementPtr.html , and try adding a
call to "gepi->getType()->dump()".

-Eli



More information about the llvm-dev mailing list