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

    <tr>
        <th>Summary</th>
        <td>
            [dsymutil] Extremely slow generate dSYM files after the commit D158124 
        </td>
    </tr>

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

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

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

<pre>
    We have found that <img width="1963" alt="image" src="https://github.com/llvm/llvm-project/assets/1595163/5f331899-7ced-40d1-a9d4-51afc1e96a34">, the time for dsymutil to generate dSYM files in our project has increased from 10 minutes to 45 minutes. Upon inspecting the logs, we noticed an unusually high number of warnings related to "could not find object file symbol for symbol".

This commit was made to support a new feature in Xcode 15, adding support for mergeable libraries. While debugging the LLVM source code, we discovered that the increased time consumption is due to a key code change. If the MachODebugMapParser::switchToNewDebugMapObject method encounters a branch where the object cannot be loaded, it simply returns without calling the resetParserState method. This leads to an excessive execution of unnecessary logic in the subsequent handleStabSymbolTableEntry method, while the CurrentObjectAddresses still holds the information of the previous object, and the current object has already moved on to the next one. Before the D158124 commit, entering the MachODebugMapParser::switchToNewDebugMapObject method would directly invoke the resetParserState method. This way, if a branch occurs where the object cannot be loaded, the guard statement in the handleStabSymbolTableEntry method would return early, avoiding the execution of subsequent unnecessary logic.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJycVc2O4zYTfBr50hhDoqyxffBhdr0GPmDn2wAzySbHFtmSmKVIhz_W6O2DpixMggTIJhf_kFR1dVWpiSHo3hKdiuZD0Zw3mOLg_Ek66yaym9ap-fSVYMAbQeeSVRAHjFDUH_XYw6RVHIr6XAhRHR_rQghAE5cFPWJPvBK8XFaGGK-hqJ8KcSnEpddxSO1WurEQF2Nu69fD1btfScZCXDAEiqEQl6o5NhXjX5qurqvD8fiwl6QedqWqHvCodg9NhZ2s6Pi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