[LLVMdev] GetElementPtrInst Again!

Reid Spencer reid at x10sys.com
Fri Nov 21 16:11:02 PST 2003


I'm trying to set up a call to printf in stacker and have managed to
confuse myself. Perhaps you can shed some light.

I've declared printf as a function taking a pointer to SByteTy with var
args and returning SIntTy:

>  // Create a function for output (int printf(format,...))
>  std::vector<Type*> params;
>  params.push_back( PointerType::get( Type::SByteTy ) );        
>  FunctionType* printf_type = FunctionType::get( Type::IntTy, params, true );
>  ThePrintf = new Function( printf_type, GlobalValue::ExternalLinkage,
>             "printf", TheModule);
>                                                                                                                                                              

When I set up the call, I get the following from that pesky :) verifier:

Call parameter type does not match function signature!
        getelementptr [3 x sbyte]* %_str_format_, long 0                ; <[3 x sbyte]*>:0 [#uses=1]
typesbyte* sbyte *

So, in LLVM are arrays and pointers not equivalent as in "C"?

What do I have to do to turn my little str_format array into a pointer?

I tried the FunctionType with an argument of [3 x sbyte] but that led to
much worse diagnostics.

Help!  :)

Reid.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20031121/83470248/attachment.sig>


More information about the llvm-dev mailing list