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

    <tr>
        <th>Summary</th>
        <td>
            Slow register allocation on arm64
        </td>
    </tr>

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

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

    <tr>
      <th>Reporter</th>
      <td>
          etang-cw
      </td>
    </tr>
</table>

<pre>
    To reproduce:
- Download [gfxreconstruct-slow.zip](https://github.com/llvm/llvm-project/files/13034364/gfxreconstruct-slow.zip) and unzip it
- Run `time clang++ -std=c++11 -O2 -arch arm64 -c generated_vulkan_replay_consumer.cpp -I include -DVK_NO_PROTOTYPES -DVK_ENABLE_BETA_EXTENSIONS -DNDEBUG -o generated_vulkan_replay_consumer.arm64.o -ftime-trace`
- View the time it took to compile
- View the time trace json file
- Do the same with `-arch x86_64`

Expected result:
Both take a similar amount of time

Actual result:
On an M1, the x86_64 build takes a bit over 1m, but the arm64 build takes over 13m

In the time trace json, each instantiation of `InitializeOutputStructPNext` takes ~23 seconds to `RunPass {"detail":"Greedy Register Allocator"}`.  In the x86 builds, the same pass takes about 1 second per instantiation.

Reproduced with both Xcode 15's clang and a copy of clang-16 from MacPorts

I realize this file is terrible from a codegen time perspective, with a massive switch statement inside a templated function that gets instantiated many times, but even so, the 13x time difference between the backends seemed worth a bug report
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUVMFu4zYQ_Rr6MpAhUZbiHHyIa2cRtGsHSbrYngyKGkncUKRAjmwnh357QSreeostil5siBzOvHnvzQjvVWsQV6xYs2IzEyN11q2QhGkTeZpVtn5bvVhwODhbjxJZfsfSDUvvEtjYk9FW1MCKdducHUprPLlRUuK1Pc3f1cCKDePLjmjw4SG_Z_y-VdSN1VzanvF7rY-Xv2Rw9htKYvy-URo94_dZnuaLvFyEV_9SgN-CMDWM5l0NoOiC7Wk0wMqU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