platform/upstream/llvm.git
2 years ago[DAG] Ensure Legal BUILD_VECTOR elements types in shuffle->And combine
David Green [Mon, 8 Aug 2022 08:47:55 +0000 (09:47 +0100)]
[DAG] Ensure Legal BUILD_VECTOR elements types in shuffle->And combine

D129150 added a combine from shuffles to And that creates a BUILD_VECTOR
of constant elements. We need to ensure that the elements are of a legal
type, to prevent asserts during lowering.

Fixes #56970.

Differential Revision: https://reviews.llvm.org/D131350

(cherry picked from commit 061e0189a3dab6b1831a80d489ff1b15ad93aafb)

2 years ago[ARM] Regenerate vector_store.ll tests. NFC
David Green [Sun, 7 Aug 2022 11:46:28 +0000 (12:46 +0100)]
[ARM] Regenerate vector_store.ll tests. NFC

(cherry picked from commit f8d976171f2a1b7bf9268929f77904973edb0378)

2 years ago[scudo] Try to fix standalone build on armv7
Diana Picus [Fri, 5 Aug 2022 08:54:32 +0000 (10:54 +0200)]
[scudo] Try to fix standalone build on armv7

When linking scudo standalone on armv7, it can't find symbols related to
unwinding (e.g. __aeabi_unwind_cpp_pr0). This is because it is passing
--unwindlib=none. This patch hacks around the issue by adding
COMPILER_RT_UNWINDER_LINK_LIBS to the link line.

I don't know anything about scudo, so I'm not sure what the original
intention was.

See also https://github.com/llvm/llvm-project/issues/56900

Differential Revision: https://reviews.llvm.org/D131250

(cherry picked from commit 8342ea6eac85bd20c56be0ab71b4ebbccd134c67)

2 years ago[SPIR-V] Disable opaque pointers in relese 15
Tom Stellard [Mon, 8 Aug 2022 23:11:54 +0000 (23:11 +0000)]
[SPIR-V] Disable opaque pointers in relese 15

As discussed on RFC mapping into SPIR-V requires pointer being preserved in some cases: https://discourse.llvm.org/t/rfc-better-support-for-typed-pointers-in-an-opaque-pointer-world/63339/23?u=anastasiastulova

As the work is still unfinished the best approach is to continue using pointer types.

Note that this change is only planned to be committed in release 15 branch.

This fixing PR56660.

Reviewed By: jcranmer-intel

Differential Revision: https://reviews.llvm.org/D130766

2 years ago[ELF] Support --package-metadata
Alex Brachet [Mon, 8 Aug 2022 21:31:58 +0000 (21:31 +0000)]
[ELF] Support --package-metadata

This was recently introduced in GNU linkers and it makes sense for
ld.lld to have the same support. This implementation omits checking if
the input string is valid json to reduce size bloat.

Differential Revision: https://reviews.llvm.org/D131439

(cherry picked from commit dbd04b853b680b0a383e5f58edf3643364f67bdf)

2 years ago[OpenMP] Only include CMAKE_DL_LIBS on unix platforms
Martin Storsjö [Mon, 1 Aug 2022 08:50:44 +0000 (11:50 +0300)]
[OpenMP] Only include CMAKE_DL_LIBS on unix platforms

CMAKE_DL_LIBS is documented as "Name of library containing dlopen
and dlclose".

On Windows platforms, there's no system provided dlopen/dlclose, but
it can be argued that if you really intend to call dlopen/dlclose,
you're going to be using a third party compat library like
https://github.com/dlfcn-win32/dlfcn-win32, and CMAKE_DL_LIBS should
expand to its name.

This has been argued upstream in CMake in
https://gitlab.kitware.com/cmake/cmake/-/issues/17600 and
https://gitlab.kitware.com/cmake/cmake/-/merge_requests/1642, that
CMAKE_DL_LIBS should expand to "dl" on mingw platforms.

The merge request wasn't merged though, as it caused some amount of
breakage, but in practice, Fedora still carries a custom CMake patch
with the same effect.

Thus, this patch fixes cross compiling OpenMP for mingw targets
on Fedora with their custom-patched CMake.

Differential Revision: https://reviews.llvm.org/D130892

(cherry picked from commit 7f24fd26a8abaef2fa4561aa399adde81d9c563a)

2 years ago[OpenMP][libomp] Detect if test compiler has omp.h
Jonathan Peyton [Mon, 1 Aug 2022 18:43:18 +0000 (13:43 -0500)]
[OpenMP][libomp] Detect if test compiler has omp.h

omp50_taskdep_depobj.c relies on the test compiler's omp.h file.
If the test compiler does not have an omp.h file, then use the one
within the build tree.

Fixes: https://github.com/llvm/llvm-project/issues/56820
Differential Revision: https://reviews.llvm.org/D131000

(cherry picked from commit 9cf6511bff97007401238f6cff6bf80cb9af04a5)

2 years ago[DAGCombiner] Extend visitAND to include EXTRACT_SUBVECTOR
David Sherwood [Fri, 29 Jul 2022 15:31:18 +0000 (16:31 +0100)]
[DAGCombiner] Extend visitAND to include EXTRACT_SUBVECTOR

Eliminate an AND by redefining an anyext|sext|zext.

     (and (extract_subvector (anyext|sext|zext v) _) iN_mask)
  => (extract_subvector (zeroext_iN v))

Differential Revision: https://reviews.llvm.org/D130782

(cherry picked from commit 41119a0f520d07a438f7434f17ce63cc3a942d1b)

2 years ago[AArch64][DAGCombine] Add performBuildVectorCombine 'extract_elt ~> anyext'
David Sherwood [Fri, 29 Jul 2022 08:32:08 +0000 (09:32 +0100)]
[AArch64][DAGCombine] Add performBuildVectorCombine 'extract_elt ~> anyext'

A build vector of two extracted elements is equivalent to an extract
subvector where the inner vector is any-extended to the
extract_vector_elt VT, because extract_vector_elt has the effect of an
any-extend.

  (build_vector (extract_elt_i16_to_i32 vec Idx+0) (extract_elt_i16_to_i32 vec Idx+1))
  => (extract_subvector (anyext_i16_to_i32 vec) Idx)

Depends on D130697

Differential Revision: https://reviews.llvm.org/D130698

(cherry picked from commit 487fa6f8c3af87232f7ff9484568be7782f7f8b2)

2 years ago[NFC][AArch64] Precommit vector-fcvt tests
David Sherwood [Fri, 29 Jul 2022 08:01:35 +0000 (09:01 +0100)]
[NFC][AArch64] Precommit vector-fcvt tests

Add tests which show code quality of uitofp and sitofp.

Differential Revision: https://reviews.llvm.org/D130697

(cherry picked from commit 6953e754c7a887b22c56ce7b0526506e4aa86e7f)

2 years ago[OpenMP] Fix warnings about unused expressions when OMPT_LOOP_DISPATCH is a no-op...
Martin Storsjö [Tue, 2 Aug 2022 08:15:02 +0000 (11:15 +0300)]
[OpenMP] Fix warnings about unused expressions when OMPT_LOOP_DISPATCH is a no-op. NFC.

This fixes warnings like these:

../runtime/src/kmp_dispatch.cpp:2159:24: warning: left operand of comma operator has no effect [-Wunused-value]
    OMPT_LOOP_DISPATCH(*p_lb, *p_ub, pr->u.p.st, status);
                       ^~~~~
../runtime/src/kmp_dispatch.cpp:2159:31: warning: left operand of comma operator has no effect [-Wunused-value]
    OMPT_LOOP_DISPATCH(*p_lb, *p_ub, pr->u.p.st, status);
                              ^~~~~
../runtime/src/kmp_dispatch.cpp:2159:46: warning: left operand of comma operator has no effect [-Wunused-value]
    OMPT_LOOP_DISPATCH(*p_lb, *p_ub, pr->u.p.st, status);
                                     ~~~~~~~ ^~
../runtime/src/kmp_dispatch.cpp:2159:50: warning: expression result unused [-Wunused-value]
    OMPT_LOOP_DISPATCH(*p_lb, *p_ub, pr->u.p.st, status);
                                                 ^~~~~~

(cherry picked from commit 3f25ad335b4ef882cd4e336f9d9ac1606220f572)

2 years ago[CodeGen] Fixed undeclared MISchedCutoff in case of NDEBUG and LLVM_ENABLE_ABI_BREAKI...
Dmitry Vassiliev [Sat, 30 Jul 2022 16:24:50 +0000 (18:24 +0200)]
[CodeGen] Fixed undeclared MISchedCutoff in case of NDEBUG and LLVM_ENABLE_ABI_BREAKING_CHECKS

This patch fixes the error llvm/lib/CodeGen/MachineScheduler.cpp(755): error C2065: 'MISchedCutoff': undeclared identifier in case of NDEBUG and LLVM_ENABLE_ABI_BREAKING_CHECKS.
Note MISchedCutoff is declared under #ifndef NDEBUG.

Reviewed By: RKSimon

Differential Revision: https://reviews.llvm.org/D130425

(cherry picked from commit adc387460d85a371d111bcd3e08fdc8d4f26ddd5)

2 years agoWrap `llvm_unreachable` macro in do-while loop
Stefan Gränitz [Thu, 4 Aug 2022 11:58:26 +0000 (13:58 +0200)]
Wrap `llvm_unreachable` macro in do-while loop

Macros that expand into multiple terms can cause interesting preprocessor hickups depending
on the context they are used in. https://github.com/llvm/llvm-project/issues/56867 reported
a miscompilation of `llvm_unreachable(msg)` inside a `LLVM_DEBUG({ ... })` block. We were
able to fix it by wrapping the expansion in a `do {} while(false)`.

Differential Revision: https://reviews.llvm.org/D131337

(cherry picked from commit 7a66fe1075cfc7568554aeea9c40997dfb581979)

2 years ago[lld-macho] Support EH frame pointer encodings that use sdata4
Jez Ng [Mon, 1 Aug 2022 00:16:08 +0000 (20:16 -0400)]
[lld-macho] Support EH frame pointer encodings that use sdata4

Previously we only supporting using the system pointer size (aka the
`absptr` encoding) because `llvm-mc`'s CFI directives always generate EH
frames with that encoding. But libffi uses 4-byte-encoded, hand-rolled
EH frames, so this patch adds support for it.

Fixes #56576.

Reviewed By: #lld-macho, oontvoo

Differential Revision: https://reviews.llvm.org/D130804

(cherry picked from commit 6c9f6812523a706c11a12e6cb4119b0cf67bbb21)

2 years ago[libc++] Allow enabling assertions when back-deploying
Louis Dionne [Thu, 4 Aug 2022 19:25:48 +0000 (15:25 -0400)]
[libc++] Allow enabling assertions when back-deploying

When back-deploying to older platforms, we can still provide assertions,
but we might not be able to provide a great implementation for the verbose
handler. Instead, we can just call ::abort().

Differential Revision: https://reviews.llvm.org/D131199

(cherry picked from commit e36f9e13bca41223bd6af7e49bf020e58a676e9d)

2 years ago[libc++][ranges][NFC] Mark the completed Ranges papers and issues as done.
Konstantin Varlamov [Fri, 5 Aug 2022 21:02:50 +0000 (14:02 -0700)]
[libc++][ranges][NFC] Mark the completed Ranges papers and issues as done.

The newly-completed papers:
- P0896R4 ("The One Ranges Proposal");
- P1243R4 ("Rangify New Algorithms");
- P1252R2 ("Ranges Design Cleanup");
- P1716R3 ("Range Comparison Algorithms Are Over-Constrained");
- P1871R1 ("Concept traits should be named after concepts");
- P2106R0 ("Alternative wording for GB315 and GB316").

Differential Revision: https://reviews.llvm.org/D131234

(cherry picked from commit 3fa291fa925dad4bae215fbcbc64db5ce66f0d9f)

2 years ago[libc++][ranges][NFC] Make sure all implemented algorithms are enabled in "robust...
Konstantin Varlamov [Fri, 5 Aug 2022 21:01:46 +0000 (14:01 -0700)]
[libc++][ranges][NFC] Make sure all implemented algorithms are enabled in "robust" tests.

Also fix `std::find_first_of` (which accidentally copied the predicate
in the implementation).

Differential Revision: https://reviews.llvm.org/D131235

(cherry picked from commit 8ac015caf627a0db89540950d6343e955ba9500b)

2 years ago[libc++] Clarify comment in CI pipeline definition
Louis Dionne [Thu, 4 Aug 2022 18:06:31 +0000 (14:06 -0400)]
[libc++] Clarify comment in CI pipeline definition

This partially reverts commit 7d855bb8e133. The comments were actually
not outdated, they were simply unclear.

(cherry picked from commit cf08452e918e04c5a95b6dce11a977b317ac4476)

2 years ago[libc++][NFC] Remove outdated comment in CI pipeline definition
Louis Dionne [Thu, 4 Aug 2022 18:03:16 +0000 (14:03 -0400)]
[libc++][NFC] Remove outdated comment in CI pipeline definition

(cherry picked from commit 7d855bb8e133720ac1555dc189d9f41e7a50ea93)

2 years ago[libc++] Fix a hard error in `contiguous_iterator<NoOperatorArrowIter>`.
Konstantin Varlamov [Thu, 4 Aug 2022 17:57:58 +0000 (10:57 -0700)]
[libc++] Fix a hard error in `contiguous_iterator<NoOperatorArrowIter>`.

Evaluating `contiguous_iterator` on an iterator that satisfies all the
constraints except the `to_address` constraint and doesn't have
`operator->` defined results in a hard error. This is because
instantiating `to_address` ends up instantiating templates
dependent on the given type which might lead to a hard error even
in a SFINAE context.

Differential Revision: https://reviews.llvm.org/D130835

(cherry picked from commit 52d4c5016c4f8eca6abe84f658fc5f358bdfd2d0)

2 years ago[libc++][ranges] Implement `ranges::is_permutation`
Nikolas Klauser [Thu, 4 Aug 2022 17:54:13 +0000 (10:54 -0700)]
[libc++][ranges] Implement `ranges::is_permutation`

Co-authored-by: Konstantin Varlamov <varconst@apple.com>
Differential Revision: https://reviews.llvm.org/D127194

(cherry picked from commit 4038c859e58c12e997041927a87e880f2f3ef883)

2 years ago[libc++][NFC] Remove rebase artifact
Igor Zhukov [Thu, 4 Aug 2022 15:50:51 +0000 (22:50 +0700)]
[libc++][NFC] Remove rebase artifact

I found it in this commit: https://github.com/llvm/llvm-project/commit/a203acb9dd7227323d6161431225189d49917744

Reviewed By: Mordante

Differential Revision: https://reviews.llvm.org/D131163

(cherry picked from commit 1915c1c01e6c84a1fda5a313f85e2a3dbccd7ce0)

2 years ago[libc++][ranges] Implement `ranges::clamp`
Nikolas Klauser [Wed, 3 Aug 2022 23:30:50 +0000 (16:30 -0700)]
[libc++][ranges] Implement `ranges::clamp`

Differential Revision: https://reviews.llvm.org/D126193

(cherry picked from commit a203acb9dd7227323d6161431225189d49917744)

2 years ago[libc++][ranges] Implement `ranges::rotate`.
Konstantin Varlamov [Wed, 3 Aug 2022 23:04:14 +0000 (16:04 -0700)]
[libc++][ranges] Implement `ranges::rotate`.

Also fix `ranges::stable_sort` and `ranges::inplace_merge` to support
proxy iterators now that their internal implementations can correctly
dispatch `rotate`.

Differential Revision: https://reviews.llvm.org/D130758

(cherry picked from commit 36c746ca2d5b325a7ac64135c1ff8774c06ab34c)

2 years ago[libc++] Mark -fexperimental-library test as unsupported on another AppleClang
Louis Dionne [Wed, 3 Aug 2022 16:23:53 +0000 (12:23 -0400)]
[libc++] Mark -fexperimental-library test as unsupported on another AppleClang

(cherry picked from commit 144cea2ce9b9536acaf2a7513b9fdccfd3880db9)

2 years ago[LLD][COFF] Ignore DEBUG_S_XFGHASH_TYPE/VIRTUAL
Tobias Hieta [Mon, 8 Aug 2022 13:53:15 +0000 (15:53 +0200)]
[LLD][COFF] Ignore DEBUG_S_XFGHASH_TYPE/VIRTUAL

These are new debug types that ships with the latest
Windows SDK and would warn and finally fail lld-link.

The symbols seems to be related to Microsoft's XFG
which is their version of CFG. We can't handle any of
this yet, so for now we can just ignore these types
so that lld doesn't fail with a new version of Windows
SDK.

Fixes: #56285
Reviewed By: rnk

Differential Revision: https://reviews.llvm.org/D129378

(cherry picked from commit 576375a2d670a7b1bd84b53b0187605a5f4ea0c8)

2 years agoRevert "[compiler-rt][CMake] Enable TF intrinsics on powerpc32 Linux"
Nikita Popov [Tue, 2 Aug 2022 13:34:42 +0000 (15:34 +0200)]
Revert "[compiler-rt][CMake] Enable TF intrinsics on powerpc32 Linux"

As mentioned in https://reviews.llvm.org/D121379#3690593, this
change broke the build of compiler-rt targeting powerpc using GCC.
The 32-bit powerpc target is not supposed to emit 128-bit libcalls
-- if it does, then that's a backend bug and needs to be fixed there.

This reverts commit 8f24a56a3a9363f353c8da318d97491a6818781d.

Differential Revision: https://reviews.llvm.org/D130988

(cherry picked from commit 542977d43841820614a32823c33415042430e230)

2 years ago[ELF][AArch64] Fix potentially corrupted section content for PAC
Fangrui Song [Sat, 6 Aug 2022 01:24:53 +0000 (18:24 -0700)]
[ELF][AArch64] Fix potentially corrupted section content for PAC

D74537 introduced a bug: if `(config->andFeatures & GNU_PROPERTY_AARCH64_FEATURE_1_PAC) != 0`
with -z pac-plt unspecified, we incorrectly use AArch64BtiPac, whose writePlt will make
out-of-bounds write after the .plt section. This is often benign because the
output section after .plt will usually overwrite the content.

This is very difficult to test without D131247 (Parallelize writes of different OutputSections).

(cherry picked from commit d7cbfcf36ace575ec90434624279dd3ebce78c47)

2 years ago[ELF] Keep only getTarget() call. NFC
Fangrui Song [Sat, 6 Aug 2022 01:20:23 +0000 (18:20 -0700)]
[ELF] Keep only getTarget() call. NFC

The place from D61712 seems unneeded now. We can just use the place added by
D62609 (support AArch64 BTI/PAC).

(cherry picked from commit e89d6d2ac527f973c43563373dfdeb9e4c3bbcc5)

2 years ago[ELF][PPC64] Fix potentially corrupted section content with empty .got
Fangrui Song [Fri, 5 Aug 2022 22:22:57 +0000 (15:22 -0700)]
[ELF][PPC64] Fix potentially corrupted section content with empty .got

D91426 makes .got possibly empty while needed. If .got and .data have the same
address, and .got's content is written after .data, the first word of .data will
be corrupted.

The bug is not testable without D131247.

(cherry picked from commit 28d05d672300e51f53c73fe9a4bd053e73844247)

2 years ago[ELF] mergeCmp: work around irreflexivity bug
Fangrui Song [Sat, 6 Aug 2022 00:08:37 +0000 (17:08 -0700)]
[ELF] mergeCmp: work around irreflexivity bug

Some tests (e.g. aarch64-feature-pac.s) segfault in libstdc++ _GLIBCXX_DEBUG
builds (enabled by LLVM_ENABLE_EXPENSIVE_CHECKS).

dyn_cast<ThunkSection> is incorrectly true for any SyntheticSection. std::merge
transitively calls mergeCmp(x, x) (due to __glibcxx_requires_irreflexive_pred)
and will segfault in `ta->getTargetInputSection()`. The dyn_cast<ThunkSection>
issue should be eventually fixed properly, bug `a != b` is robust enough for now.

(cherry picked from commit abd9807590fc10eb92eb22aea7b50dbf08db7e9d)

2 years ago[Sanitizer][Darwin] Support OS versions before DRIVERKIT
Keith Smiley [Fri, 5 Aug 2022 20:26:24 +0000 (13:26 -0700)]
[Sanitizer][Darwin] Support OS versions before DRIVERKIT

Fixes https://github.com/llvm/llvm-project/issues/56960

Differential Revision: https://reviews.llvm.org/D131288

(cherry picked from commit 9ec4ddd224f400e2ec309fa513904525c059cc1e)

2 years ago[clangd] Change the url for clang-tidy check documentation
Nathan James [Fri, 5 Aug 2022 07:42:51 +0000 (08:42 +0100)]
[clangd] Change the url for clang-tidy check documentation

In https://github.com/llvm/llvm-project/commit/6e566bc5523f743bc34a7e26f050f1f2b4d699a8, The directory structure of the documentation for clang-tidy checks was changed, however clangd wasn't updated.
Now all the links generated will point to old dead pages.
This updated clangd to use the new page structure.

Reviewed By: sammccall, kadircet

Differential Revision: https://reviews.llvm.org/D128379

(cherry picked from commit 4c106c93eb68f8f9f201202677cd31e326c16823)

2 years ago[ConstProp] Don't fallthorugh for poison constants on vctp and active_lane_mask.
David Green [Fri, 5 Aug 2022 10:19:37 +0000 (11:19 +0100)]
[ConstProp] Don't fallthorugh for poison constants on vctp and active_lane_mask.

Given a poison constant as input, the dyn_cast to a ConstantInt would
fail so we would fall through to the generic code that attempts to fold
each element of the input vectors. The inputs to these intrinsics are
not vectors though, leading to a compile time crash. Instead bail out
properly for poison values by returning nullptr. This doesn't try to
define what poison means for these intrinsics.

Fixes #56945

(cherry picked from commit b2de84633a0a262b894e7cf87d29b167787aa2d6)

2 years ago[ORC] Actually propagate memory unmapping errors on Windows
Martin Storsjö [Wed, 3 Aug 2022 08:04:51 +0000 (11:04 +0300)]
[ORC] Actually propagate memory unmapping errors on Windows

This fixes warnings like these:

    ../lib/ExecutionEngine/Orc/MemoryMapper.cpp:364:9: warning: ignoring return value of function declared with 'warn_unused_result' attribute [-Wunused-result]
            joinErrors(std::move(Err),
            ^~~~~~~~~~ ~~~~~~~~~~~~~~~

Differential Revision: https://reviews.llvm.org/D131056

(cherry picked from commit 46bc1b5689e417d870c57a8d16044a55549673fa)

2 years ago[ORC] Fix a warning about an unused variable on Windows. NFC.
Martin Storsjö [Wed, 3 Aug 2022 08:04:27 +0000 (11:04 +0300)]
[ORC] Fix a warning about an unused variable on Windows. NFC.

Differential Revision: https://reviews.llvm.org/D131055

(cherry picked from commit 46196db4d305267a5d53ee642debaf408b0821a9)

2 years ago[MLIR] Fix checks for native arch
Nikita Popov [Wed, 3 Aug 2022 13:28:49 +0000 (15:28 +0200)]
[MLIR] Fix checks for native arch

Using if (TARGET ${LLVM_NATIVE_ARCH}) only works if MLIR is built
together with LLVM, but not for standalone builds of MLIR. The
correct way to check this is
if (${LLVM_NATIVE_ARCH} IN_LIST LLVM_TARGETS_TO_BUILD), as the
LLVM build system exports LLVM_TARGETS_TO_BUILD.

To avoid repeating the same check many times, add a
MLIR_ENABLE_EXECUTION_ENGINE variable.

Differential Revision: https://reviews.llvm.org/D131071

(cherry picked from commit 57a9bccec7dea036dbfa1a78f1ec5e73ecf7a33c)

2 years ago[ORC] Ensure that llvm_orc_registerJITLoaderGDBAllocAction is linked into tools.
Lang Hames [Thu, 4 Aug 2022 00:42:17 +0000 (17:42 -0700)]
[ORC] Ensure that llvm_orc_registerJITLoaderGDBAllocAction is linked into tools.

Add a reference to llvm_orc_registerJITLoaderGDBAllocAction from the
linkComponents function in the lli, llvm-jitlink, and llvm-jitlink-executor
tools. This ensures that llvm_orc_registerJITLoaderGDBAllocAction is not
dead-stripped in optimized builds, which may cause failures in these tools.

The llvm_orc_registerJITLoaderGDBAllocAction function was originally added with
MachO debugging support in 69be352a1961a, but that patch failed to update the
linkComponents functions.

http://llvm.org/PR56817
(cherry picked from commit b5f76d83ff8b57b2a6e4897beb388837803643da)

2 years ago[Orc] Disable use of shared memory on Android
Anubhab Ghosh [Sat, 30 Jul 2022 01:13:05 +0000 (06:43 +0530)]
[Orc] Disable use of shared memory on Android

shm_open and shm_unlink are not available on Android. This commit
disables SharedMemoryMapper on Android until a better solution is
available.

https://android.googlesource.com/platform/bionic/+/refs/heads/master/docs/status.md
https://github.com/llvm/llvm-project/issues/56812

Differential Revision: https://reviews.llvm.org/D130814

(cherry picked from commit ac3cb4ecd0c6ed03c135945d27bbe197d80cba4e)

2 years ago[PowerPC] Change long to int64_t (which is always 64 bit or 8 bytes )
Umesh Kalappa [Wed, 27 Jul 2022 16:32:41 +0000 (09:32 -0700)]
[PowerPC] Change long to int64_t (which is always 64 bit or 8 bytes )

We can't guarantee the long always 64 bits like WINDOWS or LLP64 data
model (rare but we should consider).

So use int64_t from inttypes.h and safe in this case.

Fixes https://github.com/llvm/llvm-project/issues/55911 .

(cherry picked from commit f38ea84a9f32058f3c2813b6f29b840c59de118c)

2 years ago[C++20] [Modules] Handle initializer for Header Units
Chuanqi Xu [Tue, 2 Aug 2022 02:26:07 +0000 (10:26 +0800)]
[C++20] [Modules] Handle initializer for Header Units

Previously when we add module initializer, we forget to handle header
units. This results that we couldn't compile a Hello World Example with
Header Units. This patch tries to fix this.

Reviewed By: iains

Differential Revision: https://reviews.llvm.org/D130871

(cherry picked from commit 6d10733d445506c02ebec9faa54658431857bb49)

2 years ago[C++20] [Modules] Merge same concept decls in global module fragment
Chuanqi Xu [Fri, 29 Jul 2022 02:44:30 +0000 (10:44 +0800)]
[C++20] [Modules] Merge same concept decls in global module fragment

According to [basic.def.odr]p14, the same redeclarations in different TU
but not attached to a named module are allowed. But we didn't take care
of concept decl for this condition. This patch tries to fix this
problem.

Reviewed By: ilya-biryukov

Differention Revision: https://reviews.llvm.org/D130614

(cherry picked from commit 4d9251bd780d20eebbcb124608b36a69787d5575)

2 years ago[Sema] Return primary merged decl as canonical for concepts
Ilya Biryukov [Wed, 27 Jul 2022 10:11:42 +0000 (12:11 +0200)]
[Sema] Return primary merged decl as canonical for concepts

Otherwise we get invalid results for ODR checks. See changed test for an
example: despite the fact that we merge the first concept, its **uses**
were considered different by `Profile`, leading to redefinition errors.

After this change, canonical decl for a concept can come from a
different module and may not be visible. This behavior looks suspicious,
but does not break any tests. We might want to add a mechanism to make
the canonical concept declaration visible if we find code that relies on
this invariant.

Additionally make sure we always merge with the canonical declaration to
avoid chains of merged concepts being reported as redefinitions. An
example was added to the test.

Also change the order of includes in the test. Importing a moduralized
header before its textual part causes the include guard macro to be
exported and the corresponding `#include` becomes a no-op.

Reviewed By: ChuanqiXu

Differential Revision: https://reviews.llvm.org/D130585

(cherry picked from commit 42f87bb62d0719848842da60d2a8180b9e4d7c52)

2 years ago[Libomptarget] Deinitialize AMDGPU global state more intentionally
Joseph Huber [Tue, 2 Aug 2022 18:52:47 +0000 (14:52 -0400)]
[Libomptarget] Deinitialize AMDGPU global state more intentionally

A previous patch made the destruction of the HSA plugin more
deterministic. However, there were still other global values that are not
handled this way. When attempting to call a destructor kernel, the
device would have already been uninitialized and we could not find the
appropriate kernel to call. This is because they were stored in global
containers that had their destructors called already. Merges this global
state into the rest of the info state by putting those global values
inside of the global pointer already allocated and deallocated by the
constructor and destructor. This should allow the AMDGPU plugin to
correctly identify the destructors if we were to run them.

Reviewed By: JonChesterfield

Differential Revision: https://reviews.llvm.org/D131011

(cherry picked from commit 2b7203a35972e98b8521f92d2791043dc539ae88)

2 years ago[openmp][amdgpu] Tear down amdgpu plugin accurately
Jon Chesterfield [Thu, 28 Jul 2022 19:00:01 +0000 (20:00 +0100)]
[openmp][amdgpu] Tear down amdgpu plugin accurately

Moves DeviceInfo global to heap to accurately control lifetime.
Moves calls from libomptarget to deinit_plugin later, plugins need to stay
alive until very shortly before libomptarget is destructed.

Leaving the deinit_plugin calls where initially inserted hits use after
free from the dynamic_module.c offloading test (verified with valgrind
 that the new location is sound with respect to this)

Reviewed By: tianshilei1992

Differential Revision: https://reviews.llvm.org/D130714

(cherry picked from commit ed0f21811544320f829124efbb6a38ee12eb9155)

2 years ago[amdgpu][openmp][nfc] Restore stb_local on DeviceInfo symbol
Jon Chesterfield [Thu, 28 Jul 2022 15:49:36 +0000 (16:49 +0100)]
[amdgpu][openmp][nfc] Restore stb_local on DeviceInfo symbol

(cherry picked from commit c214cb6a689581c1b7f3b702b5da6d68de6eaf3f)

2 years ago[openmp][amdgpu] Move global DeviceInfo behind call syntax prior to using D130712
Jon Chesterfield [Thu, 28 Jul 2022 15:32:56 +0000 (16:32 +0100)]
[openmp][amdgpu] Move global DeviceInfo behind call syntax prior to using D130712

(cherry picked from commit 75aa52106452a1d15ca487af7b408a812012e133)

2 years ago[openmp] Introduce optional plugin init/deinit functions
Jon Chesterfield [Thu, 28 Jul 2022 15:21:36 +0000 (16:21 +0100)]
[openmp] Introduce optional plugin init/deinit functions

Will allow plugins to migrate away from using global variables to
manage lifetime, which will fix a segfault discovered in relation to D127432

Reviewed By: jhuber6

Differential Revision: https://reviews.llvm.org/D130712

(cherry picked from commit 1f9d3974e444f95ddb600a6964ed14ded559e89c)

2 years ago[mlir] Fix Analysis/Presburger/Utils.cpp compilation with GCC 11
Rainer Orth [Wed, 3 Aug 2022 09:48:44 +0000 (11:48 +0200)]
[mlir] Fix Analysis/Presburger/Utils.cpp compilation with GCC 11

As reported in Issue #56850, mlir/lib/Analysis/Presburger/Utils.cpp doesn't
compile on Solaris 11.4/SPARC with the bundled GCC 11, as seen when testing
LLVM 15.0.0 rc1:

  /var/llvm/reltest/llvm-15.0.0-rc1/rc1/llvm-project/mlir/include/mlir/Analysis/Presburger/MPInt.h:260:47:
error: inlining failed in call to ‘always_inline’ ‘int64_t
mlir::presburger::int64FromMPInt(const mlir::presburger::MPInt&)’: indirect
function call with a yet undetermined callee

This patch hacks around this and allowed the build to finish.

Tested on `sparcv9-sun-solaris2.11`.

Differential Revision: https://reviews.llvm.org/D131060

(cherry picked from commit 75747e6e11aed9ed75d27527e9262cedb2e3f887)

2 years ago[C++2b] [Modules] Handle HaveModules with C++2b
Chuanqi Xu [Mon, 1 Aug 2022 08:02:27 +0000 (16:02 +0800)]
[C++2b] [Modules] Handle HaveModules with C++2b

Closing https://github.com/llvm/llvm-project/issues/56803. The root
cause for this bug is that we lack a good method to detect the language
mdoe when parsing the command line. There is a FIXME too. Dut to we lack
a good solution now, keep the workaround.

(cherry picked from commit 834a878367f549c58313200ce2c3a0da1a29d842)

2 years agoRevert "[X86][DAGISel] Don't widen shuffle element with AVX512"
Florian Hahn [Thu, 28 Jul 2022 14:26:42 +0000 (15:26 +0100)]
Revert "[X86][DAGISel] Don't widen shuffle element with AVX512"

This reverts commit 5fb41342105700949c81f68aefc85d9c46e9a1a6.

This patch is causing crashes when building llvm-test-suite when
optimizing for CPUs with AVX512.

Reproducer crashing with llc:

    target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
    target triple = "x86_64-apple-macosx"

    define i32 @test(<32 x i32> %0) #0 {
    entry:
      %1 = mul <32 x i32> %0, <i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1>
      %2 = tail call i32 @llvm.vector.reduce.add.v32i32(<32 x i32> %1)
      ret i32 %2
    }

    ; Function Attrs: nocallback nofree nosync nounwind readnone willreturn
    declare i32 @llvm.vector.reduce.add.v32i32(<32 x i32>) #1

    attributes #0 = { "min-legal-vector-width"="0" "target-cpu"="skylake-avx512" }
    attributes #1 = { nocallback nofree nosync nounwind readnone willreturn }

(cherry picked from commit f912bab111add1275fcaf5f24e4d3654127972d0)

2 years ago[LLD] [MachO] Fix GCC build warnings
Martin Storsjö [Tue, 2 Aug 2022 07:29:01 +0000 (10:29 +0300)]
[LLD] [MachO] Fix GCC build warnings

This fixes the following warnings produced by GCC 9:

    ../tools/lld/MachO/Arch/ARM64.cpp: In member function ‘void {anonymous}::OptimizationHintContext::applyAdrpLdr(const lld::macho::OptimizationHint&)’:
    ../tools/lld/MachO/Arch/ARM64.cpp:448:18: warning: comparison of integer expressions of different signedness: ‘int64_t’ {aka ‘long int’} and ‘uint64_t’ {aka ‘long unsigned int’} [-Wsign-compare]
      448 |   if (ldr.offset != (rel1->referentVA & 0xfff))
          |       ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ../tools/lld/MachO/UnwindInfoSection.cpp: In function ‘bool canFoldEncoding(compact_unwind_encoding_t)’:
    ../tools/lld/MachO/UnwindInfoSection.cpp:404:44: warning: comparison between ‘enum<unnamed>’ and ‘enum<unnamed>’ [-Wenum-compare]
      404 |   static_assert(UNWIND_X86_64_MODE_MASK == UNWIND_X86_MODE_MASK, "");
          |                                            ^~~~~~~~~~~~~~~~~~~~
    ../tools/lld/MachO/UnwindInfoSection.cpp:405:49: warning: comparison between ‘enum<unnamed>’ and ‘enum<unnamed>’ [-Wenum-compare]
      405 |   static_assert(UNWIND_X86_64_MODE_STACK_IND == UNWIND_X86_MODE_STACK_IND, "");
          |                                                 ^~~~~~~~~~~~~~~~~~~~~~~~~

Differential Revision: https://reviews.llvm.org/D130970

(cherry picked from commit 59c6f418fa3c5d6f5c8b75ebd817be8113de7931)

2 years ago[lldb] Silence a GCC warning about missing returns after a fully covered switch....
Martin Storsjö [Tue, 2 Aug 2022 07:28:12 +0000 (10:28 +0300)]
[lldb] Silence a GCC warning about missing returns after a fully covered switch. NFC.

(cherry picked from commit b7c5683fac3de2f3349d57b9e133ac53204b1148)

2 years ago[RISCV] Prevent infinite loop after D129980.
Craig Topper [Wed, 3 Aug 2022 22:19:03 +0000 (15:19 -0700)]
[RISCV] Prevent infinite loop after D129980.

D129980 converts (seteq (i64 (and X, 0xffffffff)), C1) into
(seteq (i64 (sext_inreg X, i32)), C1). If bit 31 of X is 0, it
will be turned back into an 'and' by SimplifyDemandedBits which
can cause an infinite loop.

To prevent this, check if bit 31 is 0 with computeKnownBits before
doing the transformation.

Fixes PR56905.

Reviewed By: reames

Differential Revision: https://reviews.llvm.org/D131113

(cherry picked from commit 53d560b22f5b5d91ae5296f030e0ca75a5d2c625)

2 years ago[RISCV][NFC] Use defined variable instead some code.
wanglian [Tue, 2 Aug 2022 07:59:27 +0000 (15:59 +0800)]
[RISCV][NFC] Use defined variable instead some code.

Reviewed By: asb

Differential Revision: https://reviews.llvm.org/D130687

(cherry picked from commit e208bab55fb11a69931a02dec8583a8ec5f94bbf)

2 years ago[libc++] Simplify how we define the linker script for libc++
Louis Dionne [Wed, 3 Aug 2022 00:30:28 +0000 (20:30 -0400)]
[libc++] Simplify how we define the linker script for libc++

Trying to be generic didn't work properly because we had to special-case
some interface libraries that we didn't want in the linker script. Instead,
only look at the ABI and the unwinding libraries explicitly.

This should solve the issue reported by @dim in [1].

[1]: https://discourse.llvm.org/t/15-0-0-rc1-has-been-tagged/64174/22

Differential Revision: https://reviews.llvm.org/D131037

(cherry picked from commit b7fb8563974d83f9eb8191fdfbebfd04147a2cbd)

2 years ago[libc++] More documentation improvements about running tests
Louis Dionne [Wed, 3 Aug 2022 13:24:54 +0000 (09:24 -0400)]
[libc++] More documentation improvements about running tests

(cherry picked from commit 3d5d44269c933849068c073f356002940f85bce4)

2 years ago[libc++][ranges] Implement `ranges::{prev, next}_permutation`.
Nikolas Klauser [Wed, 3 Aug 2022 05:40:13 +0000 (22:40 -0700)]
[libc++][ranges] Implement `ranges::{prev, next}_permutation`.

Co-authored-by: Konstantin Varlamov <varconst@apple.com>
Differential Revision: https://reviews.llvm.org/D129859

(cherry picked from commit 68264b649461206dc095e672eacf8a003e0b9e49)

2 years ago[libc++][test] Replace `_LIBCPP_STD_VER` with `TEST_STD_VER`
cpplearner [Tue, 2 Aug 2022 10:38:17 +0000 (18:38 +0800)]
[libc++][test] Replace `_LIBCPP_STD_VER` with `TEST_STD_VER`

Differential Revision: https://reviews.llvm.org/D130979

(cherry picked from commit 8a78b72289c5b1cb2ea2f0794d5bb9836b0895d8)

2 years ago[libc++][ranges] Implement `ranges::sample`.
Konstantin Varlamov [Wed, 3 Aug 2022 05:33:12 +0000 (22:33 -0700)]
[libc++][ranges] Implement `ranges::sample`.

Differential Revision: https://reviews.llvm.org/D130865

(cherry picked from commit 6bdb64223473585f783572c9fbf0673b4b324a35)

2 years ago[libc++][ranges] Implement `ranges::replace_copy{,_if}`.
Nikolas Klauser [Wed, 3 Aug 2022 05:25:00 +0000 (22:25 -0700)]
[libc++][ranges] Implement `ranges::replace_copy{,_if}`.

Co-authored-by: Konstantin Varlamov <varconst@apple.com>
Differential Revision: https://reviews.llvm.org/D129806

(cherry picked from commit 93172c1c2b10066628c85c9ff78eb882222fb304)

2 years ago[libc++][ranges] Fix the return value of `{copy,move}_backward`.
Konstantin Varlamov [Wed, 3 Aug 2022 05:22:49 +0000 (22:22 -0700)]
[libc++][ranges] Fix the return value of `{copy,move}_backward`.

The return value for both of these algorithms is specified as
```
`{last, result - N}` for the overloads in namespace `ranges`.
```
But the current implementation instead returns `{first, result - N}`.

Also add both algorithms to the relevant "robust" tests.

Differential Revision: https://reviews.llvm.org/D130968

(cherry picked from commit f537a01d3989d37aafc050a92c74e69d35381f8c)

2 years ago[libc++][ranges] Implement `ranges::remove_copy{, _if}`.
Nikolas Klauser [Wed, 3 Aug 2022 05:13:59 +0000 (22:13 -0700)]
[libc++][ranges] Implement `ranges::remove_copy{, _if}`.

Co-authored-by: Hui Xie <hui.xie1990@gmail.com>
Differential Revision: https://reviews.llvm.org/D130599

(cherry picked from commit 760d2b462c04537d119d76d3cc37d2cb53774a05)

2 years ago[libc++][test] Propagate host environment to libc++ test suite
Michał Górny [Wed, 3 Aug 2022 01:52:25 +0000 (21:52 -0400)]
[libc++][test] Propagate host environment to libc++ test suite

Propagate the complete host environment to the tests run via the new
testconfig. This ensures that all envvars needed e.g. for the compiler
to work correctly are present. This mimics the behavior explicitly
implemented in the legacy config.

https://github.com/llvm/llvm-project/issues/56816

Differential Revision: https://reviews.llvm.org/D130843

(cherry picked from commit 39d4e169d35b59a39ad2fcfe1a568ba979079d83)

2 years ago[libc++][NFC] Don't rely on `<algorithm>` transitively including `<memory>` in tests
Igor Zhukov [Wed, 3 Aug 2022 00:45:28 +0000 (20:45 -0400)]
[libc++][NFC] Don't rely on `<algorithm>` transitively including `<memory>` in tests

Found by @cpplearner (https://github.com/microsoft/STL/pull/2976#discussion_r935440806)

Differential Revision: https://reviews.llvm.org/D130997

(cherry picked from commit 495519e5f8232d144ed26e9c18dbcbac6a5f25eb)

2 years ago[libc++] Fix warning C4244 in std/numerics/rand/rand.dist/rand.dist.samp/rand.dist...
Igor Zhukov [Wed, 3 Aug 2022 00:42:05 +0000 (20:42 -0400)]
[libc++] Fix warning C4244 in std/numerics/rand/rand.dist/rand.dist.samp/rand.dist.samp.discrete/eval.pass.cpp

frederick-vs-ja noticed that https://github.com/microsoft/STL/pull/2976#issuecomment-1201926893
while we are working on updating LLVM submodule for MS STL:

    [...]\std\numerics\rand\rand.dist\rand.dist.samp\rand.dist.samp.discrete\eval.pass.cpp(33): error C2220: the following warning is treated as an error
    [...]\std\numerics\rand\rand.dist\rand.dist.samp\rand.dist.samp.discrete\eval.pass.cpp(287): note: see reference to function template instantiation 'void tests<__int64>(void)' being compiled
    [...]\std\numerics\rand\rand.dist\rand.dist.samp\rand.dist.samp.discrete\eval.pass.cpp(33): warning C4244: 'argument': conversion from '__int64' to 'const unsigned int', possible loss of data

Differential Revision: https://reviews.llvm.org/D130963

(cherry picked from commit db0ac307c9df26d26a629552aec0a78f1b492dfd)

2 years ago[libc++] Update documentation on testing libc++
Louis Dionne [Tue, 2 Aug 2022 20:15:55 +0000 (16:15 -0400)]
[libc++] Update documentation on testing libc++

(cherry picked from commit ce6aff8d13894bdb6ec492858a66e8f8ab42c33b)

2 years ago[libcxx][test] Test code should inspect `TEST_STD_VER`, not `_LIBCPP_STD_VER`.
Casey Carter [Tue, 2 Aug 2022 19:03:25 +0000 (12:03 -0700)]
[libcxx][test] Test code should inspect `TEST_STD_VER`, not `_LIBCPP_STD_VER`.

(cherry picked from commit a1a30dc933b928a7a8277d5b5f7bd25670e68884)

2 years ago[libc++][format] Enables feature-test macro.
Mark de Wever [Fri, 29 Jul 2022 18:35:43 +0000 (20:35 +0200)]
[libc++][format] Enables feature-test macro.

The macro is only enabled when the Clang is used with
-fexperimental-library.

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D130792

(cherry picked from commit 679169b7dd74c6f9161353f07e716ec25e80d1b8)

2 years ago[libc++][doc] Updates status documents.
Mark de Wever [Tue, 26 Jul 2022 17:37:06 +0000 (19:37 +0200)]
[libc++][doc] Updates status documents.

Adds the papers and LWG issues voted in during the July 2022 plenary.

Note the updating of the project based statuses is left to the active
contributors of these projects.

Reviewed By: #libc, huixie90, philnik

Differential Revision: https://reviews.llvm.org/D130595

(cherry picked from commit 759efa763abf0b9299683e8cf3ec161c0c97f13d)

2 years ago[clang][llvm][doc] Add more information for the ABI change in FP16
Phoebe Wang [Thu, 4 Aug 2022 14:27:00 +0000 (22:27 +0800)]
[clang][llvm][doc] Add more information for the ABI change in FP16

Differential Revision: https://reviews.llvm.org/D131172

2 years agoReleaseNotes: add lld/ELF notes
Fangrui Song [Wed, 3 Aug 2022 17:23:54 +0000 (10:23 -0700)]
ReleaseNotes: add lld/ELF notes

For the release/15.x branch.

Differential Revision: https://reviews.llvm.org/D130961

2 years ago[lldb] [doc] Add release notes for a few noteworthy changes for Windows in 15.x
Martin Storsjö [Wed, 3 Aug 2022 09:08:32 +0000 (12:08 +0300)]
[lldb] [doc] Add release notes for a few noteworthy changes for Windows in 15.x

2 years ago[LLD] [doc] Add release notes for MinGW changes for 15.x
Martin Storsjö [Wed, 3 Aug 2022 09:07:48 +0000 (12:07 +0300)]
[LLD] [doc] Add release notes for MinGW changes for 15.x

2 years ago[CodeGen][inlineasm] assume the flag output of inline asm is boolean value
Yuanfang Chen [Fri, 29 Jul 2022 21:50:40 +0000 (14:50 -0700)]
[CodeGen][inlineasm] assume the flag output of inline asm is boolean value

GCC inline asm document says that
"... the general rule is that the output variable must be a scalar
integer, and the value is boolean."

Commit e5c37958f901cc9bec50624dbee85d40143e4bca lowers flag output of
inline asm on X86 with setcc, hence it is guaranteed that the flag
is of boolean value. Clang does not support ARM inline asm flag output
yet so nothing need to be worried about ARM.

See "Flag Output" section at
https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html#OutputOperands

Fixes https://github.com/llvm/llvm-project/issues/56568

Reviewed By: nikic

Differential Revision: https://reviews.llvm.org/D129954

(cherry picked from commit 92c1bc61586c9d6c7bf0c36b1005fe00b4f48cc0)

2 years ago[libc++][ranges][NFC] Fix a few links on the Ranges status page.
Konstantin Varlamov [Tue, 2 Aug 2022 03:43:28 +0000 (20:43 -0700)]
[libc++][ranges][NFC] Fix a few links on the Ranges status page.

(cherry picked from commit c64c3d31c42869c258ad174d9a754279ef4aa07d)

2 years ago[libc++][ranges] Implement `std::ranges::partial_sort_copy`.
Konstantin Varlamov [Sat, 30 Jul 2022 09:42:05 +0000 (02:42 -0700)]
[libc++][ranges] Implement `std::ranges::partial_sort_copy`.

Differential Revision: https://reviews.llvm.org/D130532

(cherry picked from commit db7d7959787ed68f037e2a6e5a70bb0d8c17ab27)

2 years ago[libc++] Fix reverse_iterator::iterator_concept
Nikolas Klauser [Sun, 24 Jul 2022 14:46:57 +0000 (16:46 +0200)]
[libc++] Fix reverse_iterator::iterator_concept

Fixes https://github.com/llvm/llvm-project/issues/56504

Reviewed By: ldionne, Mordante, huixie90, #libc

Spies: libcxx-commits, hewillk

Differential Revision: https://reviews.llvm.org/D129794

(cherry picked from commit 7912b1f8e7c845a97411cbfc176db56861cdf116)

2 years ago[libc++] Rename __libcpp_assertion_handler to __libcpp_verbose_abort
Louis Dionne [Mon, 25 Jul 2022 17:43:47 +0000 (13:43 -0400)]
[libc++] Rename __libcpp_assertion_handler to __libcpp_verbose_abort

With the goal of reusing that handler to do other things besides
handling assertions (such as terminating when an exception is thrown
under -fno-exceptions), the name `__libcpp_assertion_handler` doesn't
really make sense anymore.

Furthermore, I didn't want to use the name `__libcpp_abort_handler`,
since that would give the impression that the handler is called
whenever `std::abort()` is called, which is not the case at all.

Differential Revision: https://reviews.llvm.org/D130562

(cherry picked from commit 507125af3d0b953cb56bce2e5b8000249fe1ef53)

2 years ago[libc++][ranges] implement `std::ranges::unique{_copy}`
Hui Xie [Sat, 23 Jul 2022 00:44:25 +0000 (01:44 +0100)]
[libc++][ranges] implement `std::ranges::unique{_copy}`

implement `std::ranges::unique` and `std::ranges::unique_copy`

Differential Revision: https://reviews.llvm.org/D130404

(cherry picked from commit 72f57e3a30d597346feec74cf626796b0055680f)

2 years ago[libc++] Properly log crashes with the assertion handler on older Androids
Louis Dionne [Thu, 28 Jul 2022 14:25:30 +0000 (10:25 -0400)]
[libc++] Properly log crashes with the assertion handler on older Androids

This reintroduces the same workaround we have in libc++abi for older
Androids based on https://reviews.llvm.org/D130507#inline-1255914.

Differential Revision: https://reviews.llvm.org/D130708

(cherry picked from commit 1422a9689d7907a4561da7b906ec392840d9e635)

2 years ago[libc++] Make `_IterOps::__iter_move` more similar to `std::ranges::iter_move`.
Konstantin Varlamov [Thu, 28 Jul 2022 09:06:44 +0000 (02:06 -0700)]
[libc++] Make `_IterOps::__iter_move` more similar to `std::ranges::iter_move`.

Avoid relying on `iterator_traits` and instead deduce the return type of
dereferencing the iterator. Additionally, add a static check to reject
iterators with incorrect `iterator_traits` at compile time.

Differential Revision: https://reviews.llvm.org/D130538

(cherry picked from commit b3afea1ce0bd3c9293edae67c1839318eecdd7bf)

2 years ago[libc++] Fix merge-conflict in .clang-format
Nikolas Klauser [Thu, 28 Jul 2022 08:32:02 +0000 (10:32 +0200)]
[libc++] Fix merge-conflict in .clang-format

(cherry picked from commit d5a3cc1d88d888e38633eb55e2afadb4cf788000)

2 years ago[libc++] Fix unwrapping ranges with different iterators and sentinels
Nikolas Klauser [Wed, 27 Jul 2022 21:52:45 +0000 (23:52 +0200)]
[libc++] Fix unwrapping ranges with different iterators and sentinels

Reviewed By: ldionne, huixie90, #libc

Spies: arichardson, sstefan1, libcxx-commits, mgorny

Differential Revision: https://reviews.llvm.org/D129040

(cherry picked from commit e01b4fe956dd038fed71cf3c552d3383905d022a)

2 years ago[libc++][ranges] implement `std::ranges::inplace_merge`
Hui Xie [Wed, 27 Jul 2022 12:20:16 +0000 (13:20 +0100)]
[libc++][ranges] implement `std::ranges::inplace_merge`

Differential Revision: https://reviews.llvm.org/D130627

(cherry picked from commit 8a61749f767e9af773051fc4f6dc99276fe189e3)

2 years ago[openmp] [test] Fix prepending config.library_dir to LD_LIBRARY_PATH
Michał Górny [Sat, 30 Jul 2022 18:53:02 +0000 (20:53 +0200)]
[openmp] [test] Fix prepending config.library_dir to LD_LIBRARY_PATH

Fix the LD_LIBRARY_PATH prepending order to make sure that
config.library_path ends up before any potentially-system directories
(e.g. config.hwloc_library_dir).  This makes sure that we are testing
against the just-built openmp libraries rather than the version that is
already installed.

Also rename the function to `prepend_*` to make it clearer what it
actually does.

https://github.com/llvm/llvm-project/issues/56821
Differential Revision: https://reviews.llvm.org/D130825

(cherry picked from commit eb4612ca239bffbf1612e0bce442043e716bb9f5)

2 years ago[libcxx] [test] Cover i386 & sparc64 in string.capacity test
Michał Górny [Sun, 31 Jul 2022 11:02:57 +0000 (13:02 +0200)]
[libcxx] [test] Cover i386 & sparc64 in string.capacity test

Differential Revision: https://reviews.llvm.org/D130837

(cherry picked from commit 09cf95bd3ec24c77a854a0e0d9431a6d4ba460bc)

2 years agoworkflows: Fix typo from 2d3d0f50ceb938c155a7283e684f28190d24d6ba
Tom Stellard [Tue, 2 Aug 2022 09:02:15 +0000 (02:02 -0700)]
workflows: Fix typo from 2d3d0f50ceb938c155a7283e684f28190d24d6ba

(cherry picked from commit be3587ae9ab2289179eea0bf6b241d796524062a)

2 years ago[DAG] matchRotateSub - ensure the (pre-extended) shift amount is wide enough for...
Simon Pilgrim [Tue, 2 Aug 2022 10:38:47 +0000 (11:38 +0100)]
[DAG] matchRotateSub - ensure the (pre-extended) shift amount is wide enough for the amount mask (PR56859)

matchRotateSub is given shift amounts that will already have stripped any/zero-extend nodes from - so make sure those values are wide enough to take a mask.

(cherry picked from commit b651fdff79027064071db7c1d0250553e3e6a232)

2 years agoworkflows: Remove symbol versions from libclang.so in the libclang ABI test
Tom Stellard [Tue, 2 Aug 2022 09:02:15 +0000 (02:02 -0700)]
workflows: Remove symbol versions from libclang.so in the libclang ABI test

Now that the symbol version for libclang.so changes for each release again,
we need to remove the symbol versions from the shared library in order
for the ABI checker to be able to compare with an older version of the
shared library.

2 years ago[lld/mac] Add support for $ld$previous symbols with explicit symbol name
Nico Weber [Thu, 9 Jun 2022 16:13:31 +0000 (12:13 -0400)]
[lld/mac] Add support for $ld$previous symbols with explicit symbol name

A symbol `$ld$previous$/Another$1.2.3$1$3.0$14.0$_xxx$` means
"pretend symbol `_xxx` is in dylib `/Another` with version `1.2.3`
if the deployment target is between `3.0` and `14.0` and we're
targeting platform `1` (ie macOS)".

This means dylibs can now inject synthetic dylibs into the link, so
DylibFile needs to grow a 3rd constructor.

The only other interesting thing is that such an injected dylib
counts as a use of the original dylib. This patch gets this mostly
right (if _only_ `$ld$previous` symbols are used from a dylib,
we don't add a dep on the dylib itself, matching ld64), but one case
where we don't match ld64 yet is that ld64 even omits the original
dylib when linking it with `-needed-l`. Lld currently still adds a load
command for the original dylib in that case. (That's for a future
patch.)

Fixes #56074.

Differential Revision: https://reviews.llvm.org/D130725

(cherry picked from commit 241f0e8b76d544a4a07a7f775b8421632539be19)

2 years ago[clang][Driver] Handle SPARC -mcpu=native etc.
Rainer Orth [Fri, 29 Jul 2022 07:27:09 +0000 (09:27 +0200)]
[clang][Driver] Handle SPARC -mcpu=native etc.

To make use of SPARC support in `getHostCPUName` as implemented by D130272
<https://reviews.llvm.org/D130272>, this patch uses it to handle
`-mcpu=native` and `-mtune=native`.  To match GCC, this patch rejects
`-march` instead of silently treating it as a no-op.

Tested on `sparcv9-sun-solaris2.11` and checking that those options are
passed on as `-target-cpu` resp. `-tune-cpu` as expected.

Differential Revision: https://reviews.llvm.org/D130273

(cherry picked from commit bf3714884ae4b4a0301bc6af78e8b4deff12558b)

2 years ago[Driver] Use libatomic for 32-bit SPARC atomics support on Linux
Rainer Orth [Fri, 29 Jul 2022 07:19:38 +0000 (09:19 +0200)]
[Driver] Use libatomic for 32-bit SPARC atomics support on Linux

This is the Linux/sparc64 equivalent to D118021
<https://reviews.llvm.org/D118021>, necessary to provide an external
implementation of atomics on 32-bit SPARC which LLVM cannot inline even
with `-mcpu=v9` or an equivalent default.

Tested on `sparc64-unknown-linux-gnu`.

Differential Revision: https://reviews.llvm.org/D130569

(cherry picked from commit 9b1897bbd0e3a6e9ef099e74c3d3ed35428c0460)

2 years ago[Support] Handle SPARC in sys::getHostCPUName
Rainer Orth [Wed, 27 Jul 2022 10:21:03 +0000 (12:21 +0200)]
[Support] Handle SPARC in sys::getHostCPUName

While working on D118450 <https://reviews.llvm.org/D118450>, I noticed that
`sys::getHostCPUName` lacks SPARC support.

This patch implements it.  The code is taken from/inspired by GCC's
`gcc/config/sparc/driver-sparc.cc`.  There's one caveat: since LLVM, unlike
GCC, doesn't support the SPARC-M7, -S7, and -M8 CPUs, I map all those to
the latest supported one (UltraSparc T4/`niagara4`).

Tested on `sparcv9-sun-solaris2.11` and `sparc64-unknown-linux-gnu` by
running `savcov --version` on

- Netra SPARC S7-2 (SPARC-S7, Solaris 11.4)
- SPARC T5-2 (SPARC T5, Solaris 11.4)
- SPARC Enterprise T5220 (UltraSPARC T2, Solaris 11.3)
- SPARC T5 (UltraSPARC T5, Debian sid)
- SPARC T3 (UltraSPARC T3, Debian sid)
- SPARC Enterprise T5220 (Debian sid)

Differential Revision: https://reviews.llvm.org/D130272

(cherry picked from commit 979ddfff37d7e3bf258c2e5cbdc272fcb44c15f0)

2 years ago[compiler-rt][Sanitizer] Link sanitizer libs with -latomic on SPARC
Rainer Orth [Wed, 27 Jul 2022 10:30:18 +0000 (12:30 +0200)]
[compiler-rt][Sanitizer] Link sanitizer libs with -latomic on SPARC

When building on Linux/sparc64, the 32-bit `libclang_rt.asan.so`,
`libclang_rt.ubsan_minimal.so`, and `libclang_rt.ubsan_standalone.so`
failed to link with undefined references to 64-bit atomics, which `clang`
cannot inline.  Even D130569 <https://reviews.llvm.org/D130569> didn't help
because those libraries are linked with `-nodefaultlibs`, so dependent
libraries need to be added explicitly.

That's what this patch does.

Tested on `sparc64-unknown-linux-gnu` and `sparcv9-sun-solaris2.11`.

Differential Revision: https://reviews.llvm.org/D130571

(cherry picked from commit 0b2d5fd48bc281af89e5e7bfa33a3054b826ed52)

2 years ago[IntelJITEvents] Add missing include.
Sunho Kim [Mon, 1 Aug 2022 23:44:18 +0000 (08:44 +0900)]
[IntelJITEvents] Add missing include.

Fixes compilation error.

Differential Revision: https://reviews.llvm.org/D130898

(cherry picked from commit 5680ef870f9058c4b52a09a6aec2ddf384c5a558)

2 years ago[lld-macho] Release notes for 15.x
Jez Ng [Sun, 31 Jul 2022 17:24:58 +0000 (13:24 -0400)]
[lld-macho] Release notes for 15.x

From inspection of

  git log origin/release/14.x..origin/release/15.x -- lld/MachO

Reviewed By: #lld-macho, thakis

Differential Revision: https://reviews.llvm.org/D130850

2 years agoRevert "[OpenMP] Remove noinline attributes in the device runtime"
Joseph Huber [Wed, 27 Jul 2022 15:04:25 +0000 (11:04 -0400)]
Revert "[OpenMP] Remove noinline attributes in the device runtime"

The behaviour of this patch is not great, but it has some side-effects
that are required for OpenMPOpt to work. The problem is that when we use
`-mlink-builtin-bitcode` we only import used symbols from the runtime.
Then OpenMPOpt will insert calls to symbols that were not previously
included. This patch removed this implicit behaviour as these functions
were kept alive by the `noinline` simply because it kept calls to them
in the module. This caused regression in some tests that relied on some
OpenMPOpt passes without using LTO. Reverting for the LLVM15 release but
will try to fix it more correctly on main.

This reverts commit d61d72dae604c3258e25c00622b1a85861450303.

Fixes #56752

(cherry picked from commit b08369f7f288b6efb0897953da42ed54e60cfc0b)

2 years ago[clang-tidy] Add CLANG_TIDY_CONFUSABLE_CHARS_GEN cmake cache variable to avoid buildi...
Martin Storsjö [Thu, 14 Jul 2022 19:46:04 +0000 (22:46 +0300)]
[clang-tidy] Add CLANG_TIDY_CONFUSABLE_CHARS_GEN cmake cache variable to avoid building when cross compiling

This is similar to the LLVM_TABLEGEN, CLANG_TABLEGEN and
CLANG_PSEUDO_GEN cmake cache variables.

Differential Revision: https://reviews.llvm.org/D129799

(cherry picked from commit dc95d0c525636aed53a3b38258efa2dff4c83edf)

2 years ago[clang-tidy] Rename the make-confusable-table executable
Martin Storsjö [Thu, 14 Jul 2022 19:39:55 +0000 (22:39 +0300)]
[clang-tidy] Rename the make-confusable-table executable

Rename it to clang-tidy-confusable-chars-gen, to make its role
clearer in a wider context.

In cross builds, the caller might want to provide this tool
externally (to avoid needing to rebuild it in the cross build).
In such a case, having the tool properly namespaced makes its role
clearer.

This matches how the clang-pseudo-gen tool was renamed in
a43fef05d4fae32f02365c7b8fef2aa631d23628 / D126725.

Differential Revision: https://reviews.llvm.org/D129798

(cherry picked from commit 18b4a8bcf3553174f770f09528c9bd01c8cebfe7)