[LLVMdev] Passing structures by value on Windows
lost
lostfreeman at gmail.com
Thu Jun 3 04:14:52 PDT 2010
Hello, LLVM team!
I faced a problem with passing structures by value on Windows (both
x86 and x64). I tried to write simple { i32 i32 } Vector2D addition
using IR builder (signature is Vector2D add(Vector2D a, Vector2D b)).
x86 version worked fine, but on x64 function returned incorrect value.
Some research showed, that { i16 i16 } addition also fails on x86, so
I guess the problem is in passing structures as values.
On x64 VC++ passes two { i32 i32 } structs in RCX and RDX respectively
and reads result from RAX, but it seems LLVM reads parameters from
ECX, EDX (first vector) and R8D, R9D (second vector).
Currently, I can't figure out how to dump IR, but there is a link with
disassembly shown by Visual Studio for generated functions:
comparing { i32 i32 } add on 32-bit and 64-bit (first one works):
http://pastebin.com/ijjCNWKJ
Best regards,
Milovanov Victor.
More information about the llvm-dev
mailing list