<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/95152>95152</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[MemCpyOpt] Call slot optimization doesn't respect writeonly
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
aeubanks
</td>
</tr>
</table>
<pre>
```
$ cat /tmp/a.ll
declare void @g(ptr)
define void @f(ptr dead_on_unwind noalias writable writeonly sret(i64) align 8 %0) {
%a = alloca i64
call void @g(ptr %a)
call void @llvm.memcpy(ptr align 8 %0, ptr align 8 %a, i64 8, i1 false)
ret void
}
$ opt -p memcpyopt -S /tmp/a.ll
declare void @g(ptr)
define void @f(ptr dead_on_unwind noalias writable writeonly sret(i64) align 8 %0) {
%a = alloca i64, align 8
call void @g(ptr %0)
ret void
}
```
If `@g` is not `writeonly` in regards to the `ptr` param, we may end up reading from `%0` in `@g` which is marked `writeonly`.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzUVE2PmzAQ_TXmMtrImO8Dh91EkXqoeugPWA14AHeNjWyzUfrrKxO66Uaqeq4UBfvNm3njxxj0Xo2GqGXFCytOCa5hsq5FWjs0bz7prLy2rOT7j58Yf2Yihx4DMHEO88LEGQ9a30KSeo2O4N0qCSznIxP1EhwTzZ66swZl7qThRgJJKF-teV3NRRkJxqJW6OHiVMBO07Yga_QVvKPARK3KnIkGUKvRQA1MFDzuWfVy04EIIbDsBKi17RFixh7qUevHPjf-R7OfKVq_z4eZ5n657uTPukd4wDBiqsyh3hYpDKg93as7Clvx3ZnqdHfXLgGeFripbZvv_6vb4vg741_G87s1f_XmYRC3_y8DRCTWKjkoD8aGiHwcYIMNOBrRSQ_BQpgoMqJXJYcFHc6x0QvBjFcgI2FdwBFKZUYYnJ03hdjirdQfepdJ9VNUndG9kXwUPiSyzWSTNZhQm1ZpnYqqSetkaktssprqgnPBRS5R5rKus4HSpquwwD5RbQzwMk3TKi_S6kA5ZUPKy6wQdVWWA8s5zaj0YRtN68ZEeb9S2xRpIRKNHWm_3WshDF1gCzIh4jV3bcx56tbRx9FWPvh7laCC3j4IX2k-LtdvS2DFCY7xtXltQ5xONaufGJQ1IC15w0QVwJFfqA_3wUlWp9sphMWz7JmJMxPnUYVp7Q69nZk4R8H98bQ4-4P6wMR5a9Mzcb4d470VvwIAAP__KRRi6w">