[LLVMdev] function pointer from name?

Tim Northover t.p.northover at gmail.com
Sun May 4 11:12:42 PDT 2014


Hi,

> define i8* @bar(i8* %x) {
> entry:
>   %0 = alloca [4 x i8], align 1
>   store [4 x i8] c"foo\00", [4 x i8]* %0, align 1
>   %calltmp = call i8* @intern([4 x i8]* %0)
>   %ptrfind = call i8* @find_llvm_function(i8* %calltmp)
>   %cast = bitcast i8* %ptrfind to i8* (i8*)*
>   %calltmp1 = call i8* %cast(i8* %x)
>   ret i8* %calltmp1
> }
>
> except last two lines (with %calltmp1 and ret) do not actually get
> generated, because generation of call instruction fails with
> error 'argument is neither a function nor a function pointer'

Since this function works when put into a text file and run through
llc manually (& opt & ....), it looks like the problem is that you're
not creating the IR you think you are.

What gets output when you call "dump" on the callee parameter to
CreateCall (or whatever the python version you're using is)?

> Also, there is some possibility, that I got the guts of @find_llvm_function
> wrong, however, in that case I'd expect, that code would still be generated,
> and problems would manifestate only at runtime.

Agreed.

Cheers.

Tim.



More information about the llvm-dev mailing list