Taco H. in den Bosch
taco at heddesit.nl
Tue Sep 3 13:33:35 PDT 2013
I have some problems with gettings the X86_thiscall calling convention to
work. I am new to LLVM, so if this is the wrong place for this question
then I appologise, please tell me where to go instead.
I am generating code to call a member function of a class compiled with
Microsoft Visual C++ using the JIT compiler.
The following code is used to register the pointer to the function. as_ptr
retrieves the address of a member function pointer. Yes, this is a bit of a
hack, but it works (I have tested it in other situations).
vector<llvm::Type *> arguments;
auto get_interface_type=FunctionType::get(any, arguments, false);
Function::ExternalLinkage, "get_interface", llvm_module);
The following call generates the code for the call:
Now the problem is that the generated code does not actually seem to be
using the thiscall calling convention specified for the called function:
0011001B mov dword ptr [esp+8],eax 0011001F mov
eax,dword ptr [esp+14h] 00110023 mov dword ptr [esp+4],eax
00110027 mov dword ptr [esp],102594h 0011002E call
Zeo::InterfaceGroup::get_interface (0151B133h) 00110033 add
0x102594 is the address of the object that I am trying to call a member
function on, and should be loaded into ecx by the code, instead of stored
on the stack. The result is that the right function is called, but 'this'
and the other parameters are incorrect.
>From what I have been reading about it, this calling convention should be
implemented, so either I am doing something wrong, or there is a bug in
LLVM in general, or the JIT compiler specifically. The chance that I am
doing something wrong is probably bigger, but I do not know what.
Any tips would be greatly appreciated. By the way, I am using a 3.3 release
built with Visual Studio.
With kind regards,Taco.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the llvm-dev