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

    <tr>
        <th>Summary</th>
        <td>
            Please backport fd1da784ac64 to 14.x ([compiler-rt] [scudo] Use -mcrc32 on x86 when available)
        </td>
    </tr>

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

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

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

<pre>
    Please backport fd1da784ac644492f8ca40064baf3ef360352f55 to 14.x branch:

```
ommit fd1da784ac644492f8ca40064baf3ef360352f55 (HEAD -> main, origin/main)
Author: Michał Górny <mgorny@moritz.systems>
Date:   2022-03-31 09:55:25 +0200

    [compiler-rt] [scudo] Use -mcrc32 on x86 when available
    
    Update the hardware CRC32 logic in scudo to support using `-mcrc32`
    instead of `-msse4.2`.  The CRC32 intrinsics use the former flag
    in the newer compiler versions, e.g. in clang since 12fa608af44a.
    With these versions of clang, passing `-msse4.2` is insufficient
    to enable the instructions and causes build failures when `-march` does
    not enable CRC32 implicitly:
    
        /var/tmp/portage/sys-libs/compiler-rt-sanitizers-14.0.0/work/compiler-rt/lib/scudo/scudo_crc32.cpp:20:10: error: always_inline function '_mm_crc32_u32' requires target feature 'crc32', but would be inlined into function 'computeHardwareCRC32' that is compiled without support for 'crc32'
          return CRC32_INTRINSIC(Crc, Data);
                 ^
        /var/tmp/portage/sys-libs/compiler-rt-sanitizers-14.0.0/work/compiler-rt/lib/scudo/scudo_crc32.h:27:27: note: expanded from macro 'CRC32_INTRINSIC'
        #  define CRC32_INTRINSIC FIRST_32_SECOND_64(_mm_crc32_u32, _mm_crc32_u64)
                                  ^
        /var/tmp/portage/sys-libs/compiler-rt-sanitizers-14.0.0/work/compiler-rt/lib/scudo/../sanitizer_common/sanitizer_platform.h:132:36: note: expanded from macro 'FIRST_32_SECOND_64'
        #  define FIRST_32_SECOND_64(a, b) (a)
                                           ^
        1 error generated.
    
    For backwards compatibility, use `-mcrc32` when available and fall back
    to `-msse4.2`.  The `<smmintrin.h>` header remains in use as it still
    works and is compatible with GCC, while clang's `<crc32intrin.h>`
    is not.
    
    Use __builtin_ia32*() rather than _mm_crc32*() when using `-mcrc32`
    to preserve compatibility with GCC.  _mm_crc32*() are aliases
    to __builtin_ia32*() in both compilers but GCC requires `-msse4.2`
    for the former, while both use `-mcrc32` for the latter.
    
    Originally reported in https://bugs.gentoo.org/835870.
    
    Differential Revision: https://reviews.llvm.org/D122789
```
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzNVkuTmzgQ_jX4ojIF4mE4-DCDx8kcNtmaTGqPLgHCaCMQK4lxnF-_3cKPYeKksrWH3SqXLEHzdffXL5WqPq5_l5wZTkpWfRmUtqSpw5qtsphVaRzHOW2yisVBkMYlayLeRGkQJbRJEmIVCWP_Kyk166vWi-68YOMF5zUNTj93VF0n_gG0R7P3D3cbsvSiB9Ix0Xu0IEqLPe6204N8Qr4bbas0aCe_iaplXpF4GSXvvCLy7iPdH4kXFd1ewc6Lgw4w7DffHI3lnQHwCWPDLEcEQmhA6TKIllFIghweJQksFA26D2gQvPYQpImX3FeqG4Tkeqmtl2zwianGWuH-M9C67CpdRZSonnzNUnJoeU_YCxOSlZK_ArrsPg81WENsy0nLdH1gmpPiqQAIqfaiIqInTgHSb8bBhWw0ot8TIPuk7UI7AooenGU1Uc0kYQyPfRTxCXluz-CitxokRWUAbVLfKN1xTRrJ9q_R3LueH-DV2XfywrURqjcYJu7vfRSrJAOjwLKKk5A2LA0y1sQx869gfwjbIhwoPCOgme5LhBqYuXp2sZsIg06NTSMqwXt7xQNKeI_EOhvRcT1W1sGyviYVA9cMKUcha9JADEYNRxcSp4FpSGPArxU3V9Be2TPqiapukKDZyuMl5-chdCe6fWEaVtsNsGKY2J7DDnJvKUUJVG1fpc7SsF5Y8Q1YWEJRBX4A7w9Kf5m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