<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/120696>120696</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
DSE removes store to an alloca that is passed to a byval parameter
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
rofirrim
</td>
</tr>
</table>
<pre>
The following IR, which I think is correct (but I admit I'm not 100% sure due to the constraints of `tail` calls though I think the `byval` makes it correct?)
```llvm
%_QMmooTtoken_t = type { [64 x i32] }
define void @_QMmooPsub(ptr nocapture %0) #0 {
%2 = alloca %_QMmooTtoken_t, i64 1, align 8
%3 = load %_QMmooTtoken_t, ptr %0, align 4
store %_QMmooTtoken_t %3, ptr %2, align 4
tail call void @foo(ptr %2)
ret void
}
declare void @foo(ptr byval(%_QMmooTtoken_t) align 4) local_unnamed_addr
```
is simplified by DSE (`opt -passes=dse`) like so:
```llvm
%_QMmooTtoken_t = type { [64 x i32] }
define void @_QMmooPsub(ptr nocapture %0) {
%2 = alloca %_QMmooTtoken_t, i64 1, align 8
tail call void @foo(ptr %2)
ret void
}
declare void @foo(ptr byval(%_QMmooTtoken_t) align 4) local_unnamed_addr
```
which I don't think preserves the original meaning because we're now passing a copy (`byval`) of an uninitialised value into `@foo` rather than the value pointed by `%0`.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzMVMtu6zYQ_RpqM4hBk5JsLbRI6hrIokAfdx-MxLHFhiIFcmTXf19Qsm8u0uy6aAECenDOzJwzD0zJnj1RK6oXUR0KnHkIsY3hZGO0Y9EFc2u_DQSn4Fy4Wn-G19-F-gmug-0HeAUerH8Hm6APMVLPINS-mxleAc1oGV6F2o3gA8NWSqEqSHMkMDMBB-CBoA8-cUTrOUE4gaglo3WiltCjcwl4CPP5I1KGiFp2twsuRiO-UwLLj_hCH4VqhHzOp5brce4y5m9Vvf32yxjCNw7v5N8YhD4A3yYCsXsBUb3UJfwFVitRHUDsDqsbQyfrCS7BGhClXF38muZOqP3EEXzoceJMS6hKCtWAUFpml0I-Q_6plkDoXOgR_pFFltPWJWzzCzp79rB_IPWCdAHN17gcf436gJYLNHFY8_lMWFX6B5z6jMvaL8J_p3sK4c5ztW8Wu0i8WGSFPnTqHUb6ArlWS-2_oNB8D68ayPq4t9l7HMm8oTHxxyquUWyCZMfJ2ZMlA90NDn_8nJtO1DJMDE8TpkRJ6INJlEHZrX0nSEHo5_-6L_51S_z_6_NYDCZ4oXZ8H9spUqJ4obQMcIj2bD06GAl93ikd9TgngisJtYsEPlwhFzLfIfRhut1L_Jj7nE04AXqYvfWWLTqbyMAF3UxgPYe8Je4kawkReaAIPKBfMljtpmA9r120-KwyjU1hWm0a3WBB7Xany3qvd_uyGFrd6W1tup5Ut6_7umqqrq92pUZd742WVWFbJVW5VUrKva5VuelUiU2DhKbr1bYkUUoa0bpN7rxNiOfCpjRTu1WyburCYUcuLbtYKU9XWG6Fyn1XxDaDnrr5nEQpnU2cPtywZUdtHoVIY8g6rxuAQ9bo3mY8IOdVvYyIWe7W0sOEEUdiisUcXTswTylPizoKdTxbHuZu04dRqOMyMevjaYrhz7xx1XFJMwl1vPO4tOrvAAAA__9WS_U1">