<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/69833>69833</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Missed optimization of empty `for` loop function into just `ret`
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          Rageking8
      </td>
    </tr>
</table>

<pre>
    ```cpp
#include <unordered_map>

void foo(std::unordered_map<int, int> umap)
{
    for (const auto& i : umap) {}
}
```

```asm
foo(std::unordered_map<int, int, std::hash<int>, std::equal_to<int>, std::allocator<std::pair<int const, int> > >): # @foo(std::unordered_map<int, int, std::hash<int>, std::equal_to<int>, std::allocator<std::pair<int const, int> > >)
        add     rdi, 16
.LBB0_1:                                # =>This Inner Loop Header: Depth=1
        mov     rdi, qword ptr [rdi]
        test    rdi, rdi
        jne     .LBB0_1
 ret
```

https://godbolt.org/z/cdavsPGq5

Tested on x86-64 clang (trunk), the above function get fully optimized to just `ret` on gcc (trunk).
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzUVF1v7CYQ_TX4ZZQVC2uv_eCH_Wwr3UpVdd8jDGObBIMDeNPk11d4P7qbVm1fL7I9aObMMOeAESHoziLWJN-SfJ-JKfbO17-LDl-17cqsceqjJgU9P3IcCd0TuiGMayvNpBAI303WeYUe1fMgRsIPF8z8PTmtoHWOsDJERfiG8M0X_E7bSNgOkuEHmJKTVZci6-15AgDQOg-EldLZEEFM0RFWgAbCN9ckSPj1_pp7nVz7v2_s5hRhOHv-f5dsBzdYL0J_ifLDQwTfJmGeo_vnqDDGSRGdJ3x3c45C-zMcZpZ3slzepAzfAGEcyIr-MC3f9jANodRsvdIJvSzO4cW37ZY-LxO9_xgze74n_PC91wF-sRY9fHNuhJ9RKPSpxB7H2BO-Xz6uPbjT_dpv784rGKMHkm-TL98_4iOGeIdP5iH-YnG21-bPQY_xX45eH-MYknrsSNixc6pxJi6c7wg7fhJ2lEqcwm8_veX3Sd8xRFTgLPxRFk_FCqQRtkv_Q_STfU0isx3EHkE07oTQTlZG7Sx0GKGdjPkAN0Y96E9UEB28TCECKWhqtaCpbiflfblFpmquKl6JDOtlUa3Lkq_XedbXeZtL5LRRhZRrQVFWjVw1VdXmK16iWGe6ZpTxJWXLJWUszxdtRSkvlVjl2KLkiqwoDkKbhTGnITHPdAgT1kVVcp4Z0aAJ853EmMV3mIOEsXRF-TrlPDVTF8iKGh1i-KtK1NFg_asOIUl1pitmFVwLOIzxI1FunU-UTTowN5m0_Zso2eRN_WWzdOynZiHdQNgxLXsxT6N3LygjYce52UDYcSbzZwAAAP__13WQkg">