[LLVMdev] direct calls to inttoptr constants

Mark Shannon marks at dcs.gla.ac.uk
Thu Feb 12 07:01:32 PST 2009


Tobias,
I've looked into this a bit more.
You are right.
The confusion arose as I have two versions of my compiler:
The ahead-of-time compiler uses symbolic info and does the right thing.
The JIT compiler uses runtime addresses (in effect integers) and
when I examined the code in the debugger I found that LLVM produces 
indirect calls, like this:
mov    $0x8153c8c,%eax
call   *%eax

Sadly, however, I have no idea how to fix this :(
but I will try and investigate.

Do you have any ideas yet?

Mark.

Tobias wrote:
> Hello Mark,
> 
> I've followed your advice and changed the IR to:
> %0 = call i32 inttoptr (i32 12345678 to i32 (i32)*)(i32 0) nounwind
> the call is still indirect.
> 
> IMHO llc does not call it directly because the address is neither
> a globalvalue (JIT) nor a external symbol.
> That's why it uses a fallback mechanism to call it indirectly
> assuming the address is not constant and is calculated at runtime.
> 
> tobias
> 
> Mark wrote:
>> I'm doing something similar (I use LLVM as part of my JIT compiler) and
>> if I remember correctly, LLVM does the correct thing.
>>
>> I think you need to try changing the i64 value to an i32 value.
>> If that doesn't work you could also try replacing the tail call with a 
>> normal call.
>>
>>
>> Mark.
> 
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
> 




More information about the llvm-dev mailing list