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

    <tr>
        <th>Summary</th>
        <td>
            [clang][AST] clang::Type::isSpecificBuiltinType slows down compilation
        </td>
    </tr>

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

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

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

<pre>
    I've profiled a clang release build (from main 39191c45771564b8a0930d71b4c229147cf839db) compiling sqlite3 (from llvm-test-suite/CTMark) on Windows and `clang::Type::isSpecificBuiltinType` consumes a relatively large portion of compilation time/samples. If we could speed up the function itself or optimize/reduce the usages, we could improve the compilation time of sqlite3 and potentially many other projects.
The following profile shows that `isSpecificBuiltinType` consumes more than 2% of all samples:
![image](https://github.com/llvm/llvm-project/assets/26170289/ca5e0481-88b6-4012-8453-9c793e2acb66)
The line `if (const BuiltinType *BT = getAs<BuiltinType>()) {` seems to consume more than half of the samples.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUlE-PszYQxj-NuYwSwdj88YFDsmmk99DTRurZmAHcGptis1H66Suz2W7US_ueEjR4_Dy_eQYVghkdUcvKMysvmdri5NdWW5rJhbsKgdas8_2j_cGw_iBYVj8YSz0o0Fa5EVaypAJBtxnbA8NmWP0MszIOuCxkoUVZ10VZia5RueR5Xxed0IiyELUeGi77jqEE7efFWONGCH9aE4n_08raj_kQKcRD2Ewkhte3269q_SOd8g5-M6739wDK9cCqfBfF-Inx0-2x0Oc_E94X0mYw-rwZG43bS1UO2ruwzRRAJR8qmg-yD7BqHQkWv0bjHfjhKU7tj9HMSUNQ82IpHOHHAHcC7TfbQ1iIetgWiBPBsDm9nzAxkB3Ar-CXaGbzVzq_Ur9p2l_cghopMHz7bmTmZfUfn-V_X54EfTFKphcfyUWjrH3ArNwDfJxoTYP6nXQMR5ZfWH66JUXeWn9PjJ9ThDAldHFSMbH7b0yzX5Mo5QAZlkmJshaeLBLr_S6GBSvPZlYjsfLCsJliXPYyXhleRxOnrTtqPzO8puk-fw5PyQyvKXcxMLxiVdQ5NpLhVauSctEUh6bpqoPICzw0ouQHqWvJCZXuqoqh_LZrjaPd1pCylDxEeDEGDE_nGzB-gZHiKTD-9mqb_8KwSf1QAqvPCUMgmgNE_8XjBcek0oSHfWBf0cj6lveSS5VRW1SS11wIgdnUiiGnBlVXDZUuB6y5aHin6kIiVb0WOjMt5shzmfNcihrxWAstm74aCLuub_KGiZxmZewxcTv6dcxMCBu1VYnIM6s6smFfaURHd9iLDDFt-NrurLttDEzk1oQYvrtEE-3-Lfhco_LCyvPp_cbKC_z_xYJgU6p6f3ev4c221bY_nYRdekrCbu3vAAAA__9E0omg">