<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/62751>62751</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[BFI] unreasonable block frequency estimation
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
MatzeB
</td>
</tr>
</table>
<pre>
Reduced a case where block frequency estimation gives unreasonable numbers:
```C++
extern __attribute__((noreturn)) void abort();
volatile int effect;
void foo() {
while (true) {
if (effect) [[unlikely]] {
if (effect) {
// call a noreturn function
abort();
}
}
effect = 123456;
}
}
```
Results in:
```
$ clang -c -O1 -o /dev/null -mllvm -print-bfi test.cpp
block-frequency-info: _Z3foov
- : float = 1.0, int = 8
- : float = 2098201008.8, int = 16785608070
- : float = 1048576.0, int = 8388608
- : float = 1.0, int = 8
- : float = 2098201007.8, int = 16785608062
```
It seems we usually assign a frequency of around 4k to an infinite loop. So the 2B values are unreasonably large.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUVEuPwjYQ_jXOZZTIcV7mkMOyCGkPVaXtrRfkJGNw19jUDyj99ZVDdhe25VBk4czrmxnPQ3iv9gaxJ82aNJtMxHCwrv9FhL9xnQ12uvbvOMURJxAwCo9wOaBDGLQdP0A6_DOiGa-APqijCMoa2KszeojGofDWiEEjmHgc0HlSvRC6IfTzv6W380rYOp2Zi38FdAZ2OxGCU0MMuNsRxgnjxjoM0RnCVoSt4GzVBGKwLsziFakWhLPVIiiNoEwAlBLHcCdTE0hrbyZAuoUPcDkkE8J4cBEfZUom_oKUJOmt1tFo9YH6SpoNaTb3UOn3L5tHMQBhW8K2MAqtQcBnbiCjGdMzPir_V5oLTLf5Jh-Im28g1QZKVtVNe2f5pfj98VmM-wq9o486eFDmWekWktUwamH2kI-Q_1pCblN-E54J25qoNeRHrc9HyE9OmZAPUkFAH4rxdLohzP2Uf_VTroy0pHqB3e-VtPa8xJ1D4kltxZJXQQl7neucSP5EjdEVZ7SklBf8Xr9sO960lNOOPnNAa9507Q83Fectfebs_8bUPYmpZYvlj7eG5XoL4BGPHi4I0Ueh9RVu0wzibjCtBOFsNBPUHxAsCAPKSGVUQNDWngr4zUI4ILA1nIWO6EE4vB_fK2jh9lhkU19Nq2olMuzLltesW7GmzA59WdFOUFoKHGtOx2ZqWjrWJVZSDg1SzFTPKKtoU7asYrQpC86kkJxXYydo3ZVIaopHoXSRmqSwbp8p7yP2LeuaMtNiQO3nDcWYwQvMQsJYWliuTzb5EPee1FQrH_w3SlBBz6ttvX1LM_qwlJ6vsCw63R9COM0ba57TvQqHOBSjPRK2TfjLlZ-c_WMe8e0clSdsO0f9TwAAAP__G8GHMg">