1. Apr 25, 2022
  2. Apr 22, 2022
  3. Apr 19, 2022
    • serge-sans-paille's avatar
      [Clang][Fortify] drop inline decls when redeclared · 0fbe8607
      serge-sans-paille authored
      When an inline builtin declaration is shadowed by an actual declaration, we must
      reference the actual declaration, even if it's not the last, following GCC
      behavior.
      
      This fixes #54715
      
      Differential Revision: https://reviews.llvm.org/D123308
      
      (cherry picked from commit 301e0d91)
      0fbe8607
    • David Spickett's avatar
      Reland "[llvm][AArch64] Insert "bti j" after call to setjmp" · 571c7d8f
      David Spickett authored
      Cherry-picked from c3b98194
      which was originally reviewed as https://reviews.llvm.org/D121707.
      
      This reverts commit edb7ba71.
      
      This changes BLR_BTI to take variable_ops meaning that we can accept
      a register or a label. The pattern still expects one argument so we'll
      never get more than one. Then later we can check the type of the operand
      to choose BL or BLR to emit.
      
      (this is what BLR_RVMARKER does but I missed this detail of it first time around)
      
      Also require NoSLSBLRMitigation which I missed in the first version.
      571c7d8f
    • Jeremy Morse's avatar
      [DebugInfo][InstrRef] Avoid a crash from mixed variable location modes · 0f56ce0f
      Jeremy Morse authored
      Variable locations now come in two modes, instruction referencing and
      DBG_VALUE. At -O0 we pick DBG_VALUE to allow fast construction of variable
      information. Unfortunately, SelectionDAG edits the optimisation level in
      the presence of opt-bisect-limit, meaning different passes have different
      views of what variable location mode we should use. That causes assertions
      when they're mixed.
      
      This patch plumbs through a boolean in SelectionDAG from start to
      instruction emission, so that we don't rely on the current optimisation
      level for correctness.
      
      Differential Revision: https://reviews.llvm.org/D123033
      
      (cherry picked from commit fb6596f1)
      0f56ce0f
    • Eli Friedman's avatar
      Force GHashCell to be 8-byte-aligned. · e8f03f20
      Eli Friedman authored
      Otherwise, with recent versions of libstdc++, clang can't tell that the
      atomic operations are properly aligned, and generates calls to
      libatomic.  (Actually, because of the use of reinterpret_cast, it wasn't
      guaranteed to be aligned, but I think it ended up being aligned in
      practice.)
      
      Fixes https://github.com/llvm/llvm-project/issues/54790 , the part where
      LLVM failed to build.
      
      Differential Revision: https://reviews.llvm.org/D123872
      
      (cherry picked from commit 13fc1781)
      e8f03f20
    • Carlo Marcelo Arenas Belón's avatar
      [compiler-rt] Implement __clear_cache on FreeBSD/powerpc · 09fba23d
      Carlo Marcelo Arenas Belón authored
      dd917342 (Add clear_cache implementation for ppc64. Fix buffer to
      meet ppc64 alignment., 2017-07-28), adds an implementation for
      __builtin___clear_cache on powerpc64, which was promptly ammended to
      also be used with big endian mode in f67036b6 (This ppc64 implementation
      of clear_cache works for both big and little endian., 2017-08-02)
      
      clang will use this implementation for it's builtin on FreeBSD and result
      in an abort() in the cases where 32-bit generation was requested (ex in
      macppc or when the big endian powerpc64 build was done with "-m32") and as
      reported[1] recently with pcre2, but there is no reason why the same code
      couldn't be used in those cases, so use instead the more generic identifier
      for the PowerPC architecture.
      
      While at it, update the comment to reflect that POWER8/9 have a 128 byte
      wide cache line and so the code could instead use 64 byte windows instead
      but that possible optimization has been punted for now.
      
      [1] https://github.com/PhilipHazel/pcre2/issues/92
      
      Reviewed By: jhibbits, #powerpc, MaskRay
      
      Differential Revision: https://reviews.llvm.org/D122640
      
      (cherry picked from commit 81f5c627)
      09fba23d
    • Nemanja Ivanovic's avatar
      [PowerPC] Allow absolute expressions in relocations · 33504b3b
      Nemanja Ivanovic authored
      The Linux kernel build uses absolute expressions suffixed with @lo/@ha
      relocations. This currently doesn't work for DS/DQ form instructions and
      there is no reason for it not to. It also works with GAS.
      This patch allows this as long as the value is a multiple of 4/16
      for DS/DQ form.
      
      Differential revision: https://reviews.llvm.org/D115419
      
      (cherry picked from commit 2aaba44b)
      33504b3b
  4. Apr 15, 2022
  5. Apr 12, 2022
    • Martin Storsjö's avatar
      [AArch64] Fix the upper limit for folded address offsets for COFF · c6205397
      Martin Storsjö authored
      In COFF, the immediates in IMAGE_REL_ARM64_PAGEBASE_REL21 relocations
      are limited to 21 bit signed, i.e. the offset has to be less than
      (1 << 20). The previous limit did intend to cover for this case, but
      had missed that the 21 bit field was signed.
      
      This fixes issue https://github.com/llvm/llvm-project/issues/54753.
      
      Differential Revision: https://reviews.llvm.org/D123160
      
      (cherry picked from commit 8d7a17b7)
      c6205397
    • Michał Górny's avatar
      [compiler-rt] [scudo] Use -mcrc32 on x86 when available · 6697c5bc
      Michał Górny authored
      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 12fa608a.
      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
      
      (cherry picked from commit fd1da784)
      6697c5bc
    • Ties Stuij's avatar
      [AARCH64] ssbs should be enabled by default for cortex-x1, cortex-x1c, cortex-a77 · 8475349b
      Ties Stuij authored
      Reviewed By: amilendra
      
      Differential Revision: https://reviews.llvm.org/D121206
      8475349b
  6. Apr 11, 2022
  7. Apr 07, 2022
    • Simon Pilgrim's avatar
      [X86] lowerV8I16Shuffle - use explicit SmallVector<SDValue, 4> width to avoid... · ec13fed5
      Simon Pilgrim authored
      [X86] lowerV8I16Shuffle - use explicit SmallVector<SDValue, 4> width to avoid MSVC AVX alignment bug
      
      As discussed on Issue #54645 - building llc with /AVX can result in incorrectly aligned structs
      
      (cherry picked from commit cb5c4a59)
      ec13fed5
    • Vassil Vassilev's avatar
      [clang-repl] Add an accessor to our underlying execution engine · aaf0c921
      Vassil Vassilev authored
      This patch will allow better incremental adoption of these changes in downstream
      cling and other users which want to experiment by customizing the execution
      engine.
      
      (cherry picked from commit 788e0f7f)
      aaf0c921
    • Philippe Valembois's avatar
      [AArch64] Use correct calling convention for each vararg · d150523f
      Philippe Valembois authored
      While checking is tail call optimization is possible, the calling
      convention applied to fixed arguments is not the correct one.
      This implies for DarwinPCS that all arguments of a vararg function will
      go to the stack although fixed ones can go in registers.
      
      This prevents non-virtual thunks to be tail optimized although they are
      marked as musttail.
      
      Differential Revision: https://reviews.llvm.org/D120622
      
      (cherry picked from commit 26cd2584)
      d150523f
    • Fraser Cormack's avatar
      [SelectionDAG] Don't create illegally-typed nodes while constant folding · fd98b0f1
      Fraser Cormack authored
      This patch fixes a (seemingly very rare) crash during vector constant
      folding introduced in D113300.
      
      Normally, during legalization, if we create an illegally-typed node during
      a failed attempt at constant folding it's cleaned up before being
      visited, due to it having no uses.
      
      If, however, an illegally-typed node is created during one round of
      legalization and isn't cleaned up, it's possible for a second round of
      legalization to create new illegally-typed nodes which add extra uses to
      the old illegal nodes. This means that we can end up visiting the old
      nodes before they're known to be dead, at which point we crash.
      
      I'm not happy about this fix. Creating illegal types at all seems like a
      bad idea, but we all-too-often rely on illegal constants being
      successfully folded and being fixed up afterwards. However, we can't
      rely on constant folding actually happening, and we don't have a
      foolproof way of peering into the future.
      
      Perhaps the correct fix is to revisit the node-iteration order during
      legalization, ensuring we visit all uses of nodes before the nodes
      themselves. Or alternatively we could try and clean up dead nodes
      immediately after failing constant folding.
      
      Reviewed By: RKSimon
      
      Differential Revision: https://reviews.llvm.org/D122382
      
      (cherry picked from commit 43a91a84)
      fd98b0f1
    • Fangrui Song's avatar
      [AArch64] Allow .variant_pcs before the symbol is registered · d53e2603
      Fangrui Song authored
      glibc sysdeps/aarch64/tst-vpcs-mod.S has something like:
      ```
      .variant_pcs    vpcs_call
      .global vpcs_call
      ```
      
      This is supported by GNU as but leads to an error in MC. Use getOrCreateSymbol
      to support a not-yet-registered symbol: call `registerSymbol` to ensure the
      symbol exists even if there is no binding directive/label, to match GNU as.
      
      While here, improve tests to check (1) a local symbol can get
      STO_AARCH64_VARIANT_PCS (2) undefined .variant_pcs (3) an alias does not
      inherit STO_AARCH64_VARIANT_PCS.
      
      Reviewed By: efriedma
      
      Differential Revision: https://reviews.llvm.org/D122507
      
      (cherry picked from commit cfbd5c8e)
      d53e2603
    • Fraser Cormack's avatar
      [VectorCombine] Insert addrspacecast when crossing address space boundaries · 67a29046
      Fraser Cormack authored
      We can not bitcast pointers across different address spaces. This was
      previously fixed in D89577 but then in D93229 an enhancement was added
      which peeks further through the ponter operand, opening up the
      possibility that address-space violations could be introduced.
      
      Instead of bailing as the previous fix did, simply insert an
      addrspacecast cast instruction.
      
      Reviewed By: lebedev.ri
      
      Differential Revision: https://reviews.llvm.org/D121787
      
      (cherry picked from commit 2e44b787)
      67a29046
  8. Apr 06, 2022