<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/113134>113134</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Inefficient codegen in builder pattern with existed copyable base value
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
CrazyboyQCD
</td>
</tr>
</table>
<pre>
In a builder pattern code, when building with existed copyable base value, codegen isn't efficient like partial copy.
This can be reproduced on both argument value and constant value.
Full copy and patial copy:
C version: https://godbolt.org/z/z3fWsKhqE
Rust version: https://godbolt.org/z/MeGf8E5Gd
Existed value and non existed value:
C version: https://godbolt.org/z/9z3x3Kv5c
Rust version: https://godbolt.org/z/vWEaEfd3e
Real use case examaple in rust: https://godbolt.org/z/MGseG3W14
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJycU8tu2zAQ_BrqsoghkpIfBx5cxzKCoIcGBXImxZXEliZVPpw4X19IdpOgPbTNQRJA7uzMjnZkjKZ3iILUn0h9W8icBh_ELsiXs_LnL7vbQnl9FncOJKhsrMYAo0wJg4PWayRsB08DusulcT08mTQAPpuYUEPrx7NUFkHJiHCSNs-ICdmjAxMdYasE2HWmNegSWPMdYZQhGWln9IKUt6Tcfh1MhFY6UAgBx-B1blGDd6B8GkCGPh8n_EwB0k3ULib56-ja5vJusr00nwtH-UpG-BYuJTs4YYjGu-loSGmMhG8Jawhreq-Vt2nhQ09Y8zI9vHuM98OP_QX7kGP6H_hnPHTrfX3Q7zXurw6-DeS8e_X14iTffkDs5oU_8_tT3X5M7OlxL_ed5vhe7ANKCzkitNNvxmd5lKNFMA5CjumfPDhEPPBHWhVacL3hG1mgoCu2qcuy2pTFIKSqaLdcUl0zveyWFFdrVCvVdhQVXa03hRGsZBUtGS3X1ZqWC6x5va7ZquvoUrOSkarEozR2Ye3pOHEXJsaMglJOeVVYqdDGOQmMOXyC-ZYwNgUjiAl0o3IfSVVaE1N8a5NMsiju3Nsavy64-yM1f8tHkYMVv9ll0pDVovVHwpqJ9fq5GYP_hm0irJm1RsKa6zAnwX4GAAD__1eQQiU">