Clang i386-pc-win32 struct return-by-value doesn't match MSVC

Hi everyone. It looks like, when targeting msvc x86-32 (triple
i?86-pc-win32), Clang still returns all structs by hidden pointer,
although MSVC returns structs sized {8,4,3,2,1} bytes in registers as
documented at Argument Passing and Naming Conventions | Microsoft Docs .
A simple test case:

Yes, a bug. Please file at , or if you're interested
you can try writing a patch yourself. The relevant code is
lib/CodeGen/TargetInfo.cpp in clang.


Filed . Thanks for the quick reply.


Note that pc-win32 currently uses the Itanium ABI. To properly test
this you need to pass "-Xclang -cxx-abi -Xclang microsoft".

I would like to switch pc-win32 over to using the microsoft ABI by
default, even though it is not complete, as the code that it currently
generates is mostly useless. However, I do know of one person that
uses the current behavior with thunks to convert the ABI over ;/.

- Michael Spencer

I attached some patches for Clang and LLVM to the issue I submitted:

Do these changes need to be predicated on the -cxx-abi setting?


No; -cxx-abi is only supposed to affect C++specific features, like
mangling and typeinfo.

Please submit patches to llvm-commits/cfe-commits with testcases.