[LLVMdev] function pointer from name?

Alexander Popolitov popolit at gmail.com
Sun May 4 13:36:32 PDT 2014


I don't know, whether this is equivalent to what debug in C++ does,
but in this snippet:

ptrvoid = G_LLVM_BUILDER.call(ptrfinder, [funcallee], 'ptrfind')
print >> stderr, ptrvoid.__str__()
ptr = G_LLVM_BUILDER.bitcast(ptrvoid, funct_type, name='cast')
print >> stderr, ptr.__str__()
res = G_LLVM_BUILDER.call
print >> stderr, res.__str__()

precisely the following gets printed to stderr

%ptrfind = call i8* @find_llvm_function(i8* %calltmp)
%cast = bitcast i8* %ptrfind to i8* (i8*)*

and then there's an error, so third line never gets printed

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