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

    <tr>
        <th>Summary</th>
        <td>
            Using Polly to build Zstd 1.5.3 leads to a crash in the Linux Kernel and htop
        </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 a couple of days I've noticed that I could not compile a Linux Kernel successfully any longer with either GCC 12.2.1 or Clang-16 (latest tested revision: 12c62a67183e1b390e625f29cb832c15eba5089c). It would just stop at the end of the module linking phase (with Clang) or abort with an error there (GCC).

```
  LD [M]  sound/usb/usx2y/snd-usb-us122l.ko
  LD [M]  sound/usb/usx2y/snd-usb-usx2y.ko
  LD [M]  sound/usb/snd-usbmidi-lib.ko
```
After a lots of experiments I found out that the issue came from compiling the system's zstd library with the following Polly flags. 

```
export CC=clang
export CXX=clang++
export CC_LD=mold
export CXX_LD=mold
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=5000000 -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-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 -funroll-loops -fno-semantic-interposition -fcf-protection=none -mharden-sls=none -fomit-frame-pointer -mprefer-vector-width=256 -flto"
export CXXFLAGS="${CFLAGS}"
export LDFLAGS="-Wl,--lto-O3,-O3,-Bsymbolic-functions,--as-needed -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=mold -Wl,-zcommon-page-size=0x200000 -Wl,-zmax-page-size=0x200000"
CCLDFLAGS="$LDFLAGS"
CXXLDFLAGS="$LDFLAGS"
export ASFLAGS="-D__AVX__=1 -D__AVX2__=1 -msse2avx -D__FMA__=1"
```
All is fine when I compile ZSTD with the following CFLAGS instead, keeping the other flags the same:

`export CFLAGS="-O3 -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 -fno-math-errno -fno-trapping-math -falign-functions=32 -funroll-loops -fno-semantic-interposition -fcf-protection=none -mharden-sls=none -fomit-frame-pointer -mprefer-vector-width=256 -flto"`

As Zstd happened to work fine with Polly before, I wonder if the recent change in https://github.com/llvm/llvm-project/commit/b4b7fa234cfaea5267449654de8297ee860f094e might have been the cause of the regression?  Pinging @Meinersbur for awareness. Sorry in advance for not being able to reduce this further.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJztV01z2zYQ_TXSBUONCIn6OOggW3XqVk48cdq6vXhAEhQRgwAHAG0rv75vSUmxmKRf02M0EkVgH4DF7tvFIrX5fnVlHRMss02tJbMFy8Xes-sBnz9JZmxQmcxZKEVg1wTSOXXiraoV8IJtlWle2M_SGamZb7JMel80Wu-ZMHumrdlJx55VKJnEA-9vLi9ZzEd8FDOsfKmF2UXxjA34QosgfWD0wJpOPimvrBlM1sBnMy5m83gxkXE6WY7ljCcFX2bpYsKzOJGpSMaLZTbgyxG7Duy5VfRjg9l8sDWD9libSZPTDum1snkD_bUyj8rsWF0KL0mHVtNWKcxFCorUutBtQBgmnUMf7aNFYy-05GC8GYzXh-dsfPi2Tca2GzZILm4GyYYxbxuTD_hV49P2-cL3-Pcmj9CDX8y5Hj3a_zIU7X808jCiUrmKtEpPY3p6r4sgiRfaBk82ky-1dKqSBs1rVtCUzDahYwYZVHnfSJaJSrLC2erAELItSf0ePq1AKs8--ZDD7qkTbt_ZlQCF1do-E_zWEnkKLXZ-xP7CstCIPAMPTDZZ67Cz7vv7Uz-_oO_5oIftBvLK6rw_7BuS9Xv0av1URcKdCd7eHAWmOhPcfXh_fXuU-eBUfSZ-d_HT5bvb348Am37MbL3vQza_3Ny-guRNdT7L-x_Wmx-2V0eIkyKXujiHrN9ury9OCGFg_DPAj-_uPnzDjK3oL01JiG_a5vJqu35zB-GA8-jdhEWVcFmJthFBIb9EFY1iUd36_KyFp1ehjf-NFO5LsXBCa6khDg7MiwpbS1PVp5foSbouf2yScW9wLgHJpUGyioioTZAgc4tsP1_Ag8xCVDtbqCBS0Drso0qZCDERaWvrSBkfPMZP-0NDGwMnJc-3gBRH8z6rPJBReDLrIUhsnfokHcQthbBqfxroH6Uie8SOgNpuf73pAUxTRaEkapCKk_4iPislkmGnZr43olLZNyFRVjbm0UMlg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