<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/63874>63874</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Clang: ABI incompatibility with MSVC on i686-windows for struct containing overaligned type
</td>
</tr>
<tr>
<th>Labels</th>
<td>
llvm:codegen,
ABI,
platform:win32
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
rnk
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
erikdesjardins
</td>
</tr>
</table>
<pre>
Somewhat related to #63257.
In https://reviews.llvm.org/D72114, a special case was added to pass overaligned arguments indirectly, to match MSVC. However, it doesn't quite match MSVC behavior. MSVC seems to apply the special case transitively, if any field of the struct contains an overaligned type, whereas Clang only applies the special case when the toplevel struct itself is overaligned.
For example, for the following struct definitions:
```c
__declspec(align(8))
struct Align
{
uint64_t a;
uint64_t b;
};
struct Wrap1Align
{
struct Align a;
uint32_t b;
};
struct Wrap2Align {
struct Wrap1Align a;
uint8_t b;
};
```
MSVC passes all three indirectly, whereas Clang only passes `Align` indirectly.
Demo: https://godbolt.org/z/766G9zx53
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyMVEFvqzgQ_jXmMmoEdiBw4JA2ym4Pe3rS7rEyMIR5z9isPYSX9-tXQNombVd6kgX2eOb77M8zo0Ogk0UsRfoopPT2h5BSpIdIj9w5X6KnHw2G79o3ZENUueZSfnM9Tp1m8Gg0YwPsQEiVKZnuNiI-iHi_fp8tdMxDEGov5FHIo8cz4RQ2xpz7jfMnIY-HnUySrZBPoCEMWJM2UOuAMOkAumlW-EGHAO6MXpv5uA1ofxp7tByAbEMeazaXGYQd9JrrDv769vfTBv50E57RzzvE0DgMVsgdw78jMd54QoWdPpPzm3UZEPswg-lhMBfgDu8Px17bQExnXGmpBW0v0BKaBly7BrAfa4baWdZkA2h7dwO-DDiHTh161AGejLYncNZcFlLC8Jl26tAuVnaDwTOaVxLigKYFuhPp7i2OzgP-1P1gFtbW-QWodca4iezpFanBliwxObs82w2CyOJ11Ov65aXB2sznEzJfKIXMcyGLeSweV8j9srdi7B7XCYxkOdu-MGihXm0A7-bqzSx2h_f5Le4_Xg_Jl-C3xF8QKPn7BHIF-YT9Tv4FQf7_-K8i3tItKTenOAbQxgB3HvFDYn-RJtcIkcWrCFl8E3P3-AfsnVD7D9V4ck3lDF8L8ZeQx12W_VH8-pmqqClVU6hCR1gmWV6oLM0LFXVlUqlUZlWTFTtZaFQqL6o4a6VCjWmW1hGVMpYq3iVbGSd5ojZFnWZpWrR5vE10km_FNsZek3lrAhGFMGKZqXy3jYyu0IRrN5o9hNrXrsET2rkxySch5f7x-W0-GM2t87PbRFbJa_fy5Rz7UI2nILaxocDvTSdiYoPlIuQsyv7xGcjWrh80U0WG-AIT8bUxOAuU5dnDRLZxU1gK576y5-L5WNjR6E35QW3ibqw2teuFPC43W38Pg3ffsWYhj4sQQcjjosV_AQAA__9C2cQT">