<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/146528>146528</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Weird behavior of padding of `-target-abi experimental-mv`
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
yhx-12243
</td>
</tr>
</table>
<pre>
When compiling WebAssembly using `-target-abi experimental-mv`, the struct with padding will result in a very weird padding result: Use a lot of `i32` to waste with. For example:
`1.cpp`:
```cpp
struct Unit {};
struct A {
int x;
Unit c;
};
A foo() {
return {};
}
```
Compiling command: `clang++ 1.cpp -S -O3 --target=wasm32-unknown-unknown -Xclang -target-abi -Xclang experimental-mv`
Result `1.s`:
```wat
.file "1.cpp"
.functype _Z3foov () -> (i32, i32, i32, i32, i32)
.section .text._Z3foov,"",@
.hidden _Z3foov # -- Begin function _Z3foov
.globl _Z3foov
.type _Z3foov,@function
_Z3foov: # @_Z3foov
.functype _Z3foov () -> (i32, i32, i32, i32, i32)
.local i32
# %bb.0:
i32.const 0
local.get 0
local.get 0
local.get 0
local.get 0
# fallthrough-return
end_function
# -- End function
```
However, if I change `Unit` into `char`, the behavior is as we expected.
I think it is a bug of experimental-mv ABI.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJysVE2vqzYQ_TVmMwIRO4SwYJHcvKh3VanV0626eTIwgPuMjWwTkn9f2cC9ua8fm1ay5GTGZz7OHIZbKzqFWJLsTLJLxCfXa1M--nu8o3TPoko3j_KtRwW1HkYhhergDauTtThU8gGT9RZySGPHTYcu5pUAvI9oxIDKcRkPN3JICX0B1yNYZ6bawSxcDyNvGg-ehZRg0E7SgVDA4YbmATMK07y_WdyEneCrReAgtQPd-ryCUXJIwWmYuXUYQidw1QbwzodRImEnkoZzSHdJPY6-HLYaluON6Wmt7asSDkh-JvmFsPMCXV2nYPeWQigH981fBEy9_n3CnaDVmtAjocUH1KCbjPqcIr8817OAX94Jr_UwcNX49n21kquO0DOhZwgNQfwrxD8ziNcZEHaZuR0YjSf1XelZbTfEvwUwPA9rs_3N0EIZvyyTCezZv3I3c7e0lbRCIkkLQulCM6WbY1K1e4ze-e131mp9g5WTmLAv_rcfIn2Bf76KNZTF2gmt_E-Hd5es8Qh98en8eSH7dH3ci6ZB9SmrJwnO2AkFoSqhFWwxFlAndSU_MKv1c_lLli0ASU-b3Q-IMiD79DP8f2RA6ppLAC9BFgj2-WhWVck2meBJaq2sI2mxkhFgiRfHfzSFBlsupeuNnro-XuS8PEbVfHuiZSP8i2rgyfyDzn_SM97QhE5beIW656pDLzj_WfmPWying_J7bp6WSYU9vwltQFjgFmYMGq4dNskS-RVcL9R3EC48gWrq_Nb4QelwOr8mUVOypmAFj7Dc5dmO5YecZVFfMlqnVc1yPBbsWB-yhh-rhiHHAvO6ZU0kSprSLM3T3Y4xumMJyyjyPC_2Rx-lzck-xYELmUh5GxJtukhYO2G52x8yeowkr1DasIApVThD8HotZ5fIlB4UV1NnyT6Vwjr7EcYJJ7F8C4vynQvdvi_NZUH--2KOJiPL3rnRevXQK6HXTrh-qpJaD4RefbL1ikej_8DaEXoNJVpCr2sPt5L-GQAA__8msN8W">