<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/91380>91380</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
AllocaInst::getAllocationSize/AllocaInst::getAllocationSizeInBits should check for overflow
</td>
</tr>
<tr>
<th>Labels</th>
<td>
good first issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
efriedma-quic
</td>
</tr>
</table>
<pre>
Currently, the code just blindly multiplies the size, and can therefore return a nonsense result. (The behavior isn't really defined in the overflow case, but reasoning based on the overflowed computation is likely to lead to weird results.)
https://github.com/llvm/llvm-project/blob/7115ed0fff027b65fa76fdfae215ed1382ed1473/llvm/lib/Transforms/Utils/InlineFunction.cpp#L2622 has code to compute the allocation size while conservatively checking for overflow; we should use similar logic, then make the inliner call getAllocationSize(). Maybe use the multiply-with-overflow helper from CheckedArithmetic.h instead of writing out that code.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUU82O4zYMfhr5Qoxhy0kcH3zIzCLAAO2p2weQLcrijiylEpUgffpCTnbaAQoUvZgA8Znk9yOVEi0ecRT7V7H_VqnMNsQRTSTUq3r5I9NcTUHfx7ccI3p2dyHfgC3CHDTCj5wYJkdeuzus2TFdHGHaAIn-xAJWXsOsfOlFNCEiROQcPSjwwSf0qXRSdlwDCHn8bhEmtOpKIQIlL2TPEFE5dweNhjxqoG0chCtG48INZpW2XVPeoCl48gtMKqGG8BWLGuawXjIrpuCBEjj6QHcHDuBQ6VJvSFE_j0q1kINovonm9Pha5ksS3UnIs5DnhdjmqZ7DKuTZuevP8nKJ4QfOLOR5cmES8ty37R51Y4xpZD8d9kb1B6ONQln6bXeUqNtd3_1jDpX_vkflkwlxTUKef2dypb57Rx7P2c-FRT1fLkJ2v8iDlGBVepjD4ckUNwGUc2F-kC7WwM2SKzb6hPGqmK5FhNni_FG0MyF-Sia6V7ghJBuy05BT8XYlpyK4sND8TISHVX08VtF2XYRZOQcL8ulz9W9bKI5CDjXAr-o-4Tav_PSMz_3lRmxfPq216C4YwcSwwlu5DvUpEtsVmebaAvnExbZg4BaJy-0hM7BVvMlQV3rs9NANqsKx7dt92wyy6So7DqYx_R7bnWwPykyT1Ni3h4M84mE4tk1X0SgbuWv2Td8ObSe7ejjibteaZu6nqW97JXYNropcXQyrQ1wqSinjOLTdsamcmtCl7WlJuYSgwVBMDBtGSFkeXBy3sEx5SWLXOEqc_h7GxA7Hh3jvPnEJXXf6Fz3P_4l596_E6aeFm8tfLK5ydOP_TvbGpMRxI_xXAAAA__-lz3ma">