[LLVMdev] function pointer from name?

Alexander Popolitov popolit at gmail.com
Mon May 5 06:27:05 PDT 2014


Ok, after all, it seems to be totally llvmpy issue, since python types 
of %ptrfind and %cast
are StructType. Error message is also generated by llvmpy's python code, 
not any C library it uses.

On 05/04/2014 08:12 PM, Tim Northover wrote:
> 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