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

    <tr>
        <th>Summary</th>
        <td>
            [OpenMP] Compile-time regression (>4x) from clang-13 to clang-14
        </td>
    </tr>

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

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

    <tr>
      <th>Reporter</th>
      <td>
          q-p
      </td>
    </tr>
</table>

<pre>
    I'm seeing a huge performance regression in *compile-time* (haven't checked run-time yet) since upgrading from clang-13 to clang-14.

Run-time of the compilation of one (particular) file is as follows (this file leads to a huge chain of template instantiations):
- clang-13: 77secs
- clang-13 without `-fopenmp`: 64secs
- clang-14: **360secs**
- clang-14 without -fopenmp: 50sec

(without `-fopenmp` clang-14 seems faster than 13).

Attached is the output from `-ftime-trace` for clang-13, 14, and 14 without `-fopenmp`.

Compilation options were
```sh
/opt/homebrew/opt/llvm/bin/clang++ -std=c++17 -O2 -UNDEBUG -Wall -fopenmp -fno-finite-math-only -fvisibility-inlines-hidden -fdiagnostics-color=always -ftemplate-backtrace-limit=0 -Wno-int-in-bool-context -Wno-misleading-indentation -Wno-pass-failed -fPIC file.cpp -c -ofile.o -ftime-trace
```
[time_trace_clang13.json.zip](https://github.com/llvm/llvm-project/files/8990561/time_trace_clang13.json.zip)
[time_trace_clang14_noopenmp.json.zip](https://github.com/llvm/llvm-project/files/8990562/time_trace_clang14_noopenmp.json.zip)
[time_trace_clang14.json.zip](https://github.com/llvm/llvm-project/files/8990563/time_trace_clang14.json.zip)

Is there a way to disable this pass? It doesn't seem to catch too much for our code if the pass output is anything to go by (only a few `OpenMP runtime call __kmpc_global_thread_num deduplicated. [OMP170] [-Rpass=openmp-opt]`).
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJytVdlu2zgU_Rr5haChxeuDH7I0gzx0EhQo5tGgxCuJDUVqSCqu5-vnkE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