1. Apr 26, 2024
    • Bill Wendling's avatar
      [Clang] Handle structs with inner structs and no fields (#89126) · 504a17cc
      Bill Wendling authored
      A struct that declares an inner struct, but no fields, won't have a
      field count. So getting the offset of the inner struct fails. This
      happens in both C and C++:
      
        struct foo {
          struct bar {
            int Quantizermatrix[];
          };
        };
      
      Here 'struct foo' has no fields.
      
      Closes: https://github.com/llvm/llvm-project/issues/88931
      504a17cc
    • Björn Pettersson's avatar
      [DAGCombiner] Fix miscompile bug in combineShiftOfShiftedLogic (#89616) · 78b99c73
      Björn Pettersson authored
      Ensure that the sum of the shift amounts does not overflow the
      shift amount type when combining shifts in combineShiftOfShiftedLogic.
      
      Solves a miscompile bug found when testing the C23 BitInt feature.
      
      Targets like X86 that only use an i8 for shift amounts after
      legalization seems to be extra susceptible for bugs like this as it
      isn't legal to shift more than 255 steps.
      
      (cherry picked from commit f9b419b7)
      78b99c73
    • Bjorn Pettersson's avatar
      [DAGCombiner] Pre-commit test case for miscompile bug in combineShiftOfShiftedLogic · 1aa91720
      Bjorn Pettersson authored
      DAGCombiner is trying to fold shl over binops, and in the process
      combining it with another shl. However it needs to be more careful
      to ensure that the sum of the shift counts fits in the type used
      for the shift amount.
      For example, X86 is using i8 as shift amount type. So we need to
      make sure that the sum of the shift amounts isn't greater than 255.
      
      Fix will be applied in a later commit. This only pre-commits the
      test case to show that we currently get the wrong result.
      
      Bug was found when testing the C23 BitInt feature.
      
      (cherry picked from commit 5fd9bbde)
      1aa91720
  2. Apr 25, 2024
  3. Apr 24, 2024
  4. Apr 23, 2024
  5. Apr 17, 2024
    • Tom Stellard's avatar
      [CMake][Release] Disable PGO (#88465) (#89000) · e6c32898
      Tom Stellard authored
      Running the test-release.sh script with PGO enabled causes build errors
      like:
      
      ld.lld: error: Function Import: link error: linking module flags
      'ProfileSummary': IDs have conflicting values
      
      I believe this a build system bug due to the PGO profile data being
      generated unconditionally. If you run `ninja check-all` and then `ninja
      install` like we do in test-release.sh, then the profile data is
      regenerated during `ninja install` and some of the clang tools which are
      not test dependencies get build during the ninja install step with
      different profile data. When these tools link against the LLVM
      libraries, like libSupport, we end up with these errors.
      
      (cherry picked from commit 0d2bb7f0)
      e6c32898
    • Cinhi Young's avatar
      [MIPS] Fix the opcode of max.fmt and mina.fmt (#85609) · 028e425f
      Cinhi Young authored
      - The opcode of the mina.fmt and max.fmt is documented wrong, the
        object code compiled from the same assembly with LLVM behaves
        differently than one compiled with GCC and Binutils.
      - Modify the opcodes to match Binutils. The actual opcodes are as
      follows:
      
        {5,3} | bits {2,0} of func
                 |    ...   | 100  | 101    | 110   | 111
        -----+-----+-----+-----+-----+-----
         010  |   ...   |  min  | mina | max  | maxa
      
      (cherry picked from commit 8b859c6e)
      028e425f
    • Giuliano Belinassi's avatar
      Fix override keyword being print to the left side · e3c832b3
      Giuliano Belinassi authored
      
      
      Previously, the `override` keyword in C++ was being print in the left
      side of a method decl, which is unsupported by C++ standard. This commit
      fixes that by setting the `CanPrintOnLeft` field to 0, forcing it to be
      print on the right side of the decl.
      
      Signed-off-by: default avatarGiuliano Belinassi <gbelinassi@suse.de>
      e3c832b3
    • Nikita Popov's avatar
      Revert "[Mips] Fix missing sign extension in expansion of sub-word atomic max (#77072)" · 1deeee3f
      Nikita Popov authored
      These changes caused correctness regressions observed in Rust,
      see
      https://github.com/llvm/llvm-project/pull/77072#issuecomment-2049009507.
      
      This reverts commit 0e501dbd.
      This reverts commit fbb27d16.
      1deeee3f
    • Martin Storsjö's avatar
      [LLD] [COFF] Don't add pseudo relocs for dangling references (#88487) · 995539ce
      Martin Storsjö authored
      When doing GC, we normally won't have dangling references, because such
      a reference would keep the other section alive, keeping it from being
      eliminated.
      
      However, references within DWARF sections are ignored for the purposes
      of GC (because otherwise, they would essentially keep everything alive,
      defeating the point of the GC), see
      c579a5b1 for more context.
      
      Therefore, dangling relocations against discarded symbols are ignored
      within DWARF sections (see maybeReportRelocationToDiscarded in
      Chunks.cpp). Consequently, we also shouldn't create any pseudo
      relocations for these cases, as we run into a null pointer dereference
      when trying to generate the pseudo relocation info for it.
      
      This fixes the downstream bug
      https://github.com/mstorsjo/llvm-mingw/issues/418, fixing crashes on
      combinations with -ffunction-sections, -fdata-sections,
      -Wl,--gc-sections and debug info.
      
      (cherry picked from commit 9c970d5e)
      995539ce
    • Louis Dionne's avatar
      [libc++] Fix -Wgnu-include-next in stddef.h (#88214) · db67e6fb
      Louis Dionne authored
      As reported in #86843, we must have #pragma GCC system_header before we
      use #include_next, otherwise the compiler may not understand that we're
      in a system header and may issue a diagnostic for our usage of
      
      (cherry picked from commit 3c4b673a)
      db67e6fb
    • XChy's avatar
      [SelectionDAG] Prevent combination on inconsistent type in `combineCarryDiamond` (#84888) · 647fbc71
      XChy authored
      Fixes #84831
      When matching carry pattern with `getAsCarry`, it may produce different
      type of carryout. This patch checks such case and does early exit.
      
      I'm new to DAG, any suggestion is appreciated.
      
      (cherry picked from commit cb4453dc)
      647fbc71
  6. Apr 16, 2024
    • Cyrill Leutwiler's avatar
      [RISCV] Support rv{32, 64}e in the compiler builtins (#88252) · eaae766a
      Cyrill Leutwiler authored
      Register spills (save/restore) in RISC-V embedded work differently
      because there are less registers and different stack alignment.
      
      [GCC equivalent
      ](https://github.com/gcc-mirror/gcc/blob/master/libgcc/config/riscv/save-restore.S#L298C16-L336
      
      )
      
      Follow up from #76777.
      
      ---------
      
      Signed-off-by: default avatarxermicus <cyrill@parity.io>
      (cherry picked from commit bd32aaa8)
      eaae766a
    • Tom Stellard's avatar
      github-upload-release.py: Fix bug preventing release creation (#84571) · c24b41d7
      Tom Stellard authored
      After aa020024 we started passing the
      user name to the create_release function and this was being interpreted
      as the git tag.
      
      (cherry picked from commit 0b9ce71a)
      c24b41d7
    • Alexandre Ganea's avatar
      [Codegen][X86] Fix /HOTPATCH with clang-cl and inline asm (#87639) · c837970d
      Alexandre Ganea authored
      This fixes an edge case where functions starting with inline assembly
      would assert while trying to lower that inline asm instruction.
      
      After this PR, for now we always add a no-op (xchgw in this case) without
      considering the size of the next inline asm instruction. We might want
      to revisit this in the future.
      
      This fixes Unreal Engine 5.3.2 compilation with clang-cl and /HOTPATCH.
      
      Should close https://github.com/llvm/llvm-project/issues/56234
      
      (cherry picked from commit ec1af63d)
      c837970d
    • Yingwei Zheng's avatar
      [InstSimplify] Make sure the simplified value doesn't generate poison in... · d0ddcce2
      Yingwei Zheng authored
      [InstSimplify] Make sure the simplified value doesn't generate poison in threadBinOpOverSelect (#87075)
      
      Alive2: https://alive2.llvm.org/ce/z/y_Jmdn
      Fix https://github.com/llvm/llvm-project/issues/87042.
      
      (cherry picked from commit 3197f9d8)
      d0ddcce2
    • Daniel Paoliello's avatar
      Prepend all library intrinsics with `#` when building for Arm64EC (#87542) · 4056cc29
      Daniel Paoliello authored
      While attempting to build some Rust code, I was getting linker errors
      due to missing functions that are implemented in `compiler-rt`. Turns
      out that when `compiler-rt` is built for Arm64EC, all its function names
      are mangled with the leading `#`.
      
      This change removes the hard-coded list of library-implemented
      intrinsics to mangle for Arm64EC, and instead assumes that they all must
      be mangled.
      4056cc29
    • Alexey Bataev's avatar
      [SLP]Fix a crash if the argument of call was affected by minbitwidth analysis. · 6e071cf3
      Alexey Bataev authored
      Need to support proper type conversion for function arguments to avoid
      compiler crash.
      6e071cf3
    • Brian Cain's avatar
      [libcxx] coerce formatter precision to int (#87738) · d89da2ac
      Brian Cain authored
      __precision_ is declared as an int32_t which on some hexagon platforms
      is defined as a long.
      
      This change fixes errors like the ones below:
      
      In file included from
      /local/mnt/workspace/hex/llvm-project/libcxx/test/libcxx/diagnostics/format.nodiscard_extensions.compile.pass.cpp:19:
      In file included from
      /local/mnt/workspace/hex/obj_runtimes_hex88_qurt_v75_ON_ON_shared/include/c++/v1/format:202:
      In file included from
      /local/mnt/workspace/hex/obj_runtimes_hex88_qurt_v75_ON_ON_shared/include/c++/v1/__format/format_functions.h:29:
      
      /local/mnt/workspace/hex/obj_runtimes_hex88_qurt_v75_ON_ON_shared/include/c++/v1/__format/formatter_floating_point.h:700:17:
      error: no matching function for call to 'max'
      700 | int __p = std::max(1, (__specs.__has_precision() ?
      __specs.__precision_ : 6));
                |                 ^~~~~~~~
      
      /local/mnt/workspace/hex/obj_runtimes_hex88_qurt_v75_ON_ON_shared/include/c++/v1/__format/formatter_floating_point.h:771:25:
      note: in instantiation of function template specialization
      'std::__formatter::__format_floating_point<float, char,
      std::format_context>' requested here
      771 | return __formatter::__format_floating_point(__value, __ctx,
      __parser_.__get_parsed_std_specifications(__ctx));
                |                         ^
      
      /local/mnt/workspace/hex/obj_runtimes_hex88_qurt_v75_ON_ON_shared/include/c++/v1/__format/format_functions.h:284:42:
      note: in instantiation of function template specialization
      'std::__formatter_floating_point<char>::format<float,
      std::format_context>' requested here
      284 | __ctx.advance_to(__formatter.format(__arg, __ctx));
                |                                          ^
      
      /local/mnt/workspace/hex/obj_runtimes_hex88_qurt_v75_ON_ON_shared/include/c++/v1/__format/format_functions.h:429:15:
      note: in instantiation of function template specialization
      'std::__vformat_to<std::back_insert_iterator<std::string>, char,
      std::back_insert_iterator<std::__format::__output_buffer<char>>>'
      requested here
      429 | return std::__vformat_to(std::move(__out_it), __fmt, __args);
                |               ^
      
      /local/mnt/workspace/hex/obj_runtimes_hex88_qurt_v75_ON_ON_shared/include/c++/v1/__format/format_functions.h:462:8:
      note: in instantiation of function template specialization
      'std::vformat_to<std::back_insert_iterator<std::string>>' requested here
            462 |   std::vformat_to(std::back_inserter(__res), __fmt, __args);
                |        ^
      
      /local/mnt/workspace/hex/llvm-project/libcxx/test/libcxx/diagnostics/format.nodiscard_extensions.compile.pass.cpp:29:8:
      note: in instantiation of function template specialization
      'std::vformat<void>' requested here
             29 |   std::vformat("", std::make_format_args());
                |        ^
      
      /local/mnt/workspace/hex/obj_runtimes_hex88_qurt_v75_ON_ON_shared/include/c++/v1/__algorithm/max.h:35:1:
      note: candidate template ignored: deduced conflicting types for
      parameter '_Tp' ('int' vs. 'int32_t' (aka 'long'))
      35 | max(_LIBCPP_LIFETIMEBOUND const _Tp& __a, _LIBCPP_LIFETIMEBOUND
      const _Tp& __b) {
                | ^
      
      /local/mnt/workspace/hex/obj_runtimes_hex88_qurt_v75_ON_ON_shared/include/c++/v1/__algorithm/max.h:43:1:
      note: candidate template ignored: could not match
      'initializer_list<_Tp>' against 'int'
             43 | max(initializer_list<_Tp> __t, _Compare __comp) {
                | ^
      
      /local/mnt/workspace/hex/obj_runtimes_hex88_qurt_v75_ON_ON_shared/include/c++/v1/__algorithm/max.h:48:86:
      note: candidate function template not viable: requires single argument
      '__t', but 2 arguments were provided
      48 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI
      _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp max(initializer_list<_Tp> __t) {
      | ^ ~~~~~~~~~~~~~~~~~~~~~~~~~
      
      /local/mnt/workspace/hex/obj_runtimes_hex88_qurt_v75_ON_ON_shared/include/c++/v1/__algorithm/max.h:29:1:
      note: candidate function template not viable: requires 3 arguments, but
      2 were provided
      29 | max(_LIBCPP_LIFETIMEBOUND const _Tp& __a, _LIBCPP_LIFETIMEBOUND
      const _Tp& __b, _Compare __comp) {
      | ^
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      
      (cherry picked from commit e1830f58)
      d89da2ac
  7. Apr 11, 2024
  8. Apr 03, 2024
  9. Apr 02, 2024
    • Fangrui Song's avatar
      [tsan] Refine fstat{,64} interceptors (#86625) · f249092e
      Fangrui Song authored
      In glibc versions before 2.33. `libc_nonshared.a` defines
      `__fxstat/__fxstat64` but there is no `fstat/fstat64`. glibc 2.33 added
      `fstat/fstat64` and obsoleted `__fxstat/__fxstat64`. Ports added after
      2.33 do not provide `__fxstat/__fxstat64`, so our `fstat/fstat64`
      interceptors using `__fxstat/__fxstat64` interceptors would lead to
      runtime failures on such ports (LoongArch and certain RISC-V ports).
      
      Similar to https://reviews.llvm.org/D118423, refine the conditions that
      we define fstat{,64} interceptors. `fstat` is supported by musl/*BSD
      while `fstat64` is glibc only.
      
      (cherry picked from commit d5224b73)
      f249092e