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

    <tr>
        <th>Summary</th>
        <td>
            LLVM/Clang got super slow when it got compiled with Polly
        </td>
    </tr>

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

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

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

<pre>
    For about a week or so, I've noticed a huge slowdown in compilation speed of LLVM/Clang when my build got compiled with the following flags (my CPU = Haswell):

```
export CC=clang
export CXX=clang++
export CC_LD=lld
export CXX_LD=lld
export AR=llvm-ar
export NM=llvm-nm
export STRIP=llvm-strip
export OBJCOPY=llvm-objcopy
export OBJDUMP=llvm-objdump
export READELF=llvm-readelf
export RANLIB=llvm-ranlib
export HOSTCC=clang
export HOSTCXX=clang++
export HOSTAR=llvm-ar
export CFLAGS="-O3 -march=native -mllvm -polly -mllvm -polly-position=early -mllvm -polly-parallel=true -fopenmp -fopenmp-version=50 -mllvm -polly-dependences-computeout=0 -mllvm -polly-detect-profitability-min-per-loop-insts=40 -mllvm -polly-tiling=true -mllvm -polly-prevect-width=256 -mllvm -polly-vectorizer=stripmine -mllvm -polly-omp-backend=LLVM -mllvm -polly-num-threads=36 -mllvm -polly-scheduling=dynamic -mllvm -polly-scheduling-chunksize=1 -mllvm -polly-ast-use-context -mllvm -polly-invariant-load-hoisting -mllvm -polly-loopfusion-greedy -mllvm -polly-run-inliner -mllvm -polly-run-dce -mllvm -polly-enable-delicm=true -mllvm -extra-vectorizer-passes -mllvm -enable-cond-stores-vec -mllvm -slp-vectorize-hor-store -mllvm -enable-loopinterchange -mllvm -enable-loop-distribute -mllvm -enable-unroll-and-jam -mllvm -enable-loop-flatten -mllvm -interleave-small-loop-scalar-reduction -mllvm -unroll-runtime-multi-exit -mllvm -aggressive-ext-opt -fno-math-errno -fno-trapping-math -falign-functions=32 -fno-semantic-interposition -fcf-protection=none -mharden-sls=none -fomit-frame-pointer -flto"
export CXXFLAGS="${CFLAGS}"
export LDFLAGS="-Wl,--lto-O3,-O3,-Bsymbolic-functions,--as-needed -Wl,-mllvm,-march=native -mllvm -extra-vectorizer-passes -mllvm -enable-cond-stores-vec -mllvm -slp-vectorize-hor-store -mllvm -enable-loopinterchange -mllvm -enable-loop-distribute -mllvm -enable-unroll-and-jam -mllvm -enable-loop-flatten -mllvm -interleave-small-loop-scalar-reduction -mllvm -unroll-runtime-multi-exit -mllvm -aggressive-ext-opt -flto -fuse-ld=lld"
export ASFLAGS="-D__AVX__=1 -D__AVX2__=1 -msse2avx -D__FMA__=1"
```

Here is my build configuration: 
[PKGBUILD.txt](https://github.com/llvm/llvm-project/files/9307767/PKGBUILD.txt)

If I delete all Polly-related flags in CFLAGS, the compilation speed of the produced binaries goes back to normal. Using FullLTO is intentional here, but the slowdown was reported to me also when using ThinLTO. The mentioned Polly-flags used to work just fine before.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJztVk1v4zYQ_TXyhaAhy_HXwQd_rHfTOptgk2zTU0BJlMWEIgWSsuP--j5KtmNrkwJFrwUMWdS8GQ5n3gwn1ul-utKGsFhXjjCy4_yVYG11EC3IdRCNtpwo7UTCU4jzasOJlXqX6p0iQpFEF6WQzAmtiC05QDoj6_XPmyBaLSRTG7LLuSLFnsSVkCnZaHfQAXQnXE5czkmmJWwKoDPJNpYE0Rgai7tHEvSX5BuzOy5lEE2C_iwIl0F4fA7Dw69e8rdSG0cWCyglfu_Lz09Pp-_R3P8ulZ7XS8ilTNtaHwtmP-qP24IycyH4fnMUqOJCcP_w4_ruKLPOiPJCfDv_bXF79-cRoOOXRJf7NmT5eHN3Bkmr4tLKjy-z5Zf16ggxnKVcZpeQ2ff19fyEYEqK-ALw7fb-4ZMg1qJ_DKRHfBqbxWo9-3oPYRBF9LZPaMFMkmOtwCAQjRZei9ASfNhfrvC0wtMM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