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

    <tr>
        <th>Summary</th>
        <td>
            [AArch64][BOLT] llvm-bolt annotateCFIState Assertion `!StateStack.empty() && "corrupt CFI stack"' failed.
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            BOLT
      </td>
    </tr>

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

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

<pre>
    BOLT version: af150272cff97c121ed4fdb76fce702fbe2f12a3 crashes on [MySQL binary](https://github.com/ilinpv/bolt-tests/raw/0403b9cfe9e9c150fb523122f9962daa1b2150f2/test/AArch64/Inputs/mysqld.zst):
`llvm-bolt mysqld -o mysqld-bolt -instrument --print-disasm -v 1 > mysqld.disasm`
```
...
BOLT-WARNING: failed to post-process indirect branches for _ZL13get_next_timePK9Time_zonePllli13interval_type/1(*2)
BOLT-WARNING: failed to post-process indirect branches for _ZN24Field_iterator_table_ref13end_of_fieldsEv/1(*2)
BOLT-WARNING: failed to post-process indirect branches for _ZN16Event_parse_data13init_intervalEP3THD
llvm-bolt: llvm-project/bolt/lib/Core/BinaryFunction.cpp:2652: void llvm::bolt::BinaryFunction::annotateCFIState(): Assertion `!StateStack.empty() && "corrupt CFI stack"' failed.
```
Presumably that was caused by incorrect remember-restore CFI sequences in the binary.

</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJysVE2PpDYQ_TXmYoFwmY_mwIGeHpJRJpNJZqRIuSADRbcTY7O26U3vr48MvdlkD7lkJSRDueoV9epVCefkWSPWJD-S_BSJ1V-MraWSerlGvRlv9fGn53d6Reuk0YQ3VEwsT6GEYZqqcmDAcMymsS-LacAyhalHmBgITgcr3AUdNZqS_Pjj7e3nZ9pLLeyN5CcCh4v3iyO8IdASaM_SX9Y-GcxMoN3zE2h7o3zs0XlHoLXiI4E2zVLeV8OEFVYDy9Opz4EzgKmqChiFYD0EKxBoQyCBtmnscCkyAu2TXtYNar65D2pMPoX7KvxD2pAiVeo6xyEl3e9pbO5vuzWW2nm7zqg9jePFSu3jUTrhZhpfKaOEP979k91MinRHvj9pkyQJSZvAafxr88vL08t3gdNJSIUj9YYuxvl4sWZA56jUo7Q4eNpboYfA5WQs7X57ZvyMvtP4p--8nPH1h-pdzth9MhpflVKScak92qtQnb8tSKBlBA4EGgjl_u_8L5C1EtXYSY9WeGM7L3qFncWJcdRjZ6ZuCg7u8frNc7Pi8Yrad4uwDrtReBGqlb77XPLjK3___kTS5u92hjTbx2LN7zj4u7AItEr2BNoHYwNHx02c7aoHL41OhmUhvIEihxB_NXLcQIJaeHOHJbz5d9RuE1obLzw-tE9v4dwICDqjjXNogyMNegC2Xb95MfyR4Lz42-5JCRQECkoABmPtunj60D5RF_wIAIHyTlvylbxeLbp1Fr26UX8Rnn4Ujg5idTjS_kalDmiBVIszzj3a2KLzxuIOjx9W1AMG8qm_4H1aQ45orPlY8UpEWLMy4-yQVyWPLnXJBU7skI4sbAQcWcaGKZ0Y4xkv8gwjWUMKecrhwA6s4jwRxVTC2JdVX7FU4EiyFGchVRLITYw9R9K5FWvGeZ6ySIkeldv2E0DQTqg_P0W23tu7nh3JUiWdd18QvPRq22mfRz8_kfy4Recn-mXMv-7TN29PtFpV_8ei2wS1H_8Q50ZAWFN3Dq41_BUAAP__ZjDRYg">