<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/88361>88361</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[SPGO] The most frequent transition becomes unreachable
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
Nechda
</td>
</tr>
</table>
<pre>
According to the current implementation of the SampleProfileLoader, we are unable to correctly handle this case:
Assume that `Weight` becomes larger or equal to `std::numeric_limits<uint32_t>::max()`. After the first if statement, we set it equal to `std::numeric_limits<uint32_t>::max()` regardless of the condition.
https://github.com/llvm/llvm-project/blob/1aceee7bb6c4423da73f71aff2004493bdf620d1/llvm/lib/Transforms/IPO/SampleProfile.cpp#L1710-L1723
Later, we add `+1` to the `Weight` and cast it to `uint32_t`, which becomes 0. Therefore, the most frequent edge is marked as unreachable.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysU01vnDwQ_jXmYgX5A5blwGGTvLyqtGoiJVKP0WCPwa3BG9s0zb-vTL42vVXqBaQZ5mGej4EY7bggdqS-JPV1AWuafOi-opo0FIPXz91BKR-0XUaaPE0TUrWGgEuidj45nHFJkKxfqDdb9w5y-TZ4Yx0ePWgMRFzRJ6QQkK4LDA4zkvIhoErumU6w6FybbKQKIhJ5IOyasNfnIcZ1zm1IlOzYN7TjlMiO0QGVnzFSB2HEQH2g-LiCy-Bkx2LSGUgelnXGYNWDs7NNkcir1S5JiodE5H8vX8zwi4g9ES3ZsZIeTMKwUTE2xEStoTFB2pi-MomYqE3_4nc04AhBO4zxTUDlF22zouW5ClNKp5jnRU9EP9o0rUOp_ExE79zPt9fFKfjvqBIR_eD8QETPQSFiMww7VVVCamikaTgYIxirqlYO2uwE0_wMx-a5-wBLND7MkYj-y-0NEf0nZ0t1OhEhj7zh7OLIGyHPtz1C-rBd6ywQEZc8E34N0ScnYdHZ-U3UFznfRcuDV_Rpsmp6N5yV9H7CgMYHzN2MN_uYqAn4uOZooh6R2khnCD9QU4h0XQKCmnL6ykJ3UreyhQI73nCxF5y3bTF1jZGKyZrDABxQ1HuOrRHVUFVSQmOgsJ1gomIV56yRbd2WxnA91NzsERXoGknFcAbryixm6cNY2BhX7PZ7ueOFgwFd3G5NiAWf6NYkQuTTC93m4LCOkVTM2ZjiB0qyyW1Henf7_w2pr7MAf3BO2bEtOO9CnZEu1uC6vw7Rtl9OwLb_7wAAAP__wYdZtw">