Win64 calling convention

Hi,

I've encountered a problem invoking LLVM-generated x86_64 code on Windows from MSVC-compiled code. There seems to be disagreement between the two compilers over the calling convention for passing a 12 or 16 byte structure by value. e.g.

struct aggregate { int a; int b; int c; int d; };
int test(aggregate byVal) { ... }

LLVM chooses to pass byVal with a and b packed into rcx and c and d packed into rdx. MSVC (8 here) instead passes a reference to the structure in rcx. My reading of the System V ABI spec is unclear, although Microsoft already deviate in their choice of fastcall registers so perhaps it is irrelevant.

Should I file a bug for this?

Good evening, Jay.

Hi,

I've encountered a problem invoking LLVM-generated x86_64 code on
Windows from MSVC-compiled code. There seems to be disagreement between
the two compilers over the calling convention for passing a 12 or 16
byte structure by value. e.g.

struct aggregate { int a; int b; int c; int d; };
int test(aggregate byVal) { ... }

LLVM chooses to pass byVal with a and b packed into rcx and c and d
packed into rdx. MSVC (8 here) instead passes a reference to the
structure in rcx. My reading of the System V ABI spec is unclear,
although Microsoft already deviate in their choice of fastcall registers
so perhaps it is irrelevant.

I guess it might be a clang's issue.
ToT clang does not know Win64 calling conversion and it seems you saw
"amd64-like" cc.

Should I file a bug for this?

You may file one though I have patches for it.
I will post patches for clang soon.

...Takumi