platform/upstream/llvm.git
23 months ago[symbolizer] Fix build after 342e0eb
Vitaly Buka [Tue, 23 Aug 2022 21:50:51 +0000 (14:50 -0700)]
[symbolizer] Fix build after 342e0eb

342e0eb reverted LLVM_ENABLE_RUNTIMES incompletly and missed /runtimes
part. This target has no issues with LLVM_ENABLE_RUNTIMES, so we can
keep it.

23 months ago[symbolizer] Remove check if it's monorepo
Vitaly Buka [Tue, 23 Aug 2022 21:49:05 +0000 (14:49 -0700)]
[symbolizer] Remove check if it's monorepo

23 months ago[test][openmp] Relax condition in test
Vitaly Buka [Tue, 23 Aug 2022 21:27:41 +0000 (14:27 -0700)]
[test][openmp] Relax condition in test

It runs 8 threads. Sometimes tsan is able to detect more than one of the
same race.

23 months ago[CMake] Move cxx-headers to RUNTIME_DISTRIBUTION_COMPONENTS in Apple-stage2.cmake
Louis Dionne [Tue, 23 Aug 2022 17:27:03 +0000 (13:27 -0400)]
[CMake] Move cxx-headers to RUNTIME_DISTRIBUTION_COMPONENTS in Apple-stage2.cmake

We build libcxx using LLVM_ENABLE_RUNTIMES during Stage2, which requires
cxx-headers to be part of LLVM_RUNTIME_DISTRIBUTION_COMPONENTS instead
of LLVM_DISTRIBUTION_COMPONENTS.

rdar://99028431

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

23 months ago[clang] Create alloca to pass into static lambda
Vitaly Buka [Sat, 20 Aug 2022 04:11:59 +0000 (21:11 -0700)]
[clang] Create alloca to pass into static lambda

"this" parameter of lambda if undef, notnull and differentiable.
So we need to pass something consistent.

Any alloca will work. It will be eliminated as unused later by optimizer.

Otherwise we generate code which Msan is expected to catch.

Reviewed By: efriedma

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

23 months ago[Flang] Make the TODO messages for intrinsics more consistent
Peter Steinfeld [Thu, 18 Aug 2022 21:39:26 +0000 (14:39 -0700)]
[Flang] Make the TODO messages for intrinsics more consistent

This title says it all.

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

23 months ago[slp] Pull out a getOperandInfo variant helper [nfc]
Philip Reames [Tue, 23 Aug 2022 20:45:59 +0000 (13:45 -0700)]
[slp] Pull out a getOperandInfo variant helper [nfc]

23 months ago[llvm] Mark CFGuard fn ptr symbol as DSO local and add tests for mingw
Alvin Wong [Tue, 23 Aug 2022 20:09:50 +0000 (23:09 +0300)]
[llvm] Mark CFGuard fn ptr symbol as DSO local and add tests for mingw

For mingw target, if a symbol is not marked DSO local, a `.refptr` is
generated for it. This makes CFG check calls use an extra pointer
dereference, which adds extra overhead compared to the MSVC version,
so mark the CFG guard check funciton pointer DSO local to stop it.
This should have no effect on MSVC target.

Also adapt the existing cfguard tests to run for mingw targets, so that
this change is checked.

Reviewed By: rnk

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

23 months ago[clang] Add support for __attribute__((guard(nocf)))
Alvin Wong [Tue, 23 Aug 2022 20:08:05 +0000 (23:08 +0300)]
[clang] Add support for __attribute__((guard(nocf)))

To support using Control Flow Guard with mingw-w64, Clang needs to
accept `__declspec(guard(nocf))` also for the GNU target. Since mingw
has `#define __declspec(a) __attribute__((a))` as built-in, the simplest
solution is to accept `__attribute__((guard(nocf)))` to be compatible with
MSVC and Clang's msvc target.

As a side effect, this also adds `[[clang::guard(nocf)]]` for C++.

Reviewed By: aaron.ballman

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

23 months ago[Sample Profile Reader] Fix potential integer overflow/infinite loop bug in sample...
William Huang [Tue, 23 Aug 2022 18:58:31 +0000 (18:58 +0000)]
[Sample Profile Reader] Fix potential integer overflow/infinite loop bug in sample profile reader

Change loop induction variable type to match the type of "SIZE" where it's compared against, to prevent infinite loop caused by overflow wraparound if there are more than 2^32 samples

Reviewed By: wenlei

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

23 months agoRevert "[MLIR]Extend vector.gather to support n-D result"
Mehdi Amini [Tue, 23 Aug 2022 20:26:38 +0000 (20:26 +0000)]
Revert "[MLIR]Extend vector.gather to support n-D result"

This reverts commit 0cbfd6fd1633a075dcfd1bcd8a11e1c6d2785fa8.

A test is crashing with the shared_lib config.

23 months ago[clang-tidy] Skip unions in use-equals-default
Alexander Shaposhnikov [Tue, 23 Aug 2022 20:09:40 +0000 (20:09 +0000)]
[clang-tidy] Skip unions in use-equals-default

For unions constructors with empty bodies behave differently
(in comparison with structs/classes) and clang-tidy's fix
might break the code. This diff adjusts the check to skip unions
for now (it seems to be a relatively rare case).

Test plan: ninja check-all

Differential revision: https://reviews.llvm.org/D132290

23 months ago[mlir][spirv] Map memory space to OpenCL/Kernel storage class
Stanley Winata [Tue, 23 Aug 2022 19:56:29 +0000 (15:56 -0400)]
[mlir][spirv] Map memory space to OpenCL/Kernel storage class

Reviewed By: antiagainst

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

23 months ago[tools][llvm-lipo] Fix off-by-one error in command-line argument parsing
Alexander Shaposhnikov [Tue, 23 Aug 2022 19:48:11 +0000 (19:48 +0000)]
[tools][llvm-lipo] Fix off-by-one error in command-line argument parsing

makeArrayRef(argv + 1, argc) -> makeArrayRef(argv + 1, argc - 1)
The previous behavior resulted in propagation of the null pointer
into later stages of arguments parsing instead of being automatically
handled by the existing check of MissingArgumentCount.

Test plan: ninja check-all

Differential revision: https://reviews.llvm.org/D132418

23 months ago[libc] Enable a few entrypoints on aarch64 which are now available on x86_64.
Siva Chandra [Tue, 23 Aug 2022 19:23:13 +0000 (12:23 -0700)]
[libc] Enable a few entrypoints on aarch64 which are now available on x86_64.

23 months ago[DebugInfo] Extend the InstrRef LDV to support DbgValues with many Ops
Stephen Tozer [Mon, 20 Jun 2022 15:39:28 +0000 (16:39 +0100)]
[DebugInfo] Extend the InstrRef LDV to support DbgValues with many Ops

This patch builds on prior support patches to enable support for
variadic debug values in InstrRefLDV, allowing DBG_VALUE_LISTs to
have their ranges extended.

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

23 months ago[OpenMP] Add option to assert no nested OpenMP parallelism on the GPU
Joseph Huber [Wed, 17 Aug 2022 21:39:12 +0000 (17:39 -0400)]
[OpenMP] Add option to assert no nested OpenMP parallelism on the GPU

The OpenMP device runtime needs to support the OpenMP standard. However
constructs like nested parallelism are very uncommon in real application
yet lead to complexity in the runtime that is sometimes difficult to
optimize out. As a stop-gap for performance we should supply an argument
that selectively disables this feature. This patch adds the
`-fopenmp-assume-no-nested-parallelism` argument which explicitly
disables the usee of nested parallelism in OpenMP.

Reviewed By: carlo.bertolli

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

23 months ago[TTI] Add SK_Splice shuffle mask detection and X86 costs
Simon Pilgrim [Tue, 23 Aug 2022 19:00:37 +0000 (20:00 +0100)]
[TTI] Add SK_Splice shuffle mask detection and X86 costs

Enables fixed sized vectors to detect SK_Splice shuffle patterns and provides basic X86 cost support

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

23 months ago[RISCV] Add cost model coverage for trig, log, and exp unary routines
Philip Reames [Tue, 23 Aug 2022 18:54:57 +0000 (11:54 -0700)]
[RISCV] Add cost model coverage for trig, log, and exp unary routines

23 months ago[ADT] Add llvm::has_single_bit helper similar to the c++20 std::has_single_bit implem...
Simon Pilgrim [Tue, 23 Aug 2022 18:50:52 +0000 (19:50 +0100)]
[ADT] Add llvm::has_single_bit helper similar to the c++20 std::has_single_bit implementation

Converted the llvm::isPowerOf2_32/64 helpers into wrappers

23 months ago[Clang] Implement P0848 (Conditionally Trivial Special Member Functions)
Roy Jacobson [Mon, 22 Aug 2022 17:45:03 +0000 (20:45 +0300)]
[Clang] Implement P0848 (Conditionally Trivial Special Member Functions)

This patch implements P0848 in Clang.

During the instantiation of a C++ class, in `Sema::ActOnFields`, we evaluate constraints for all the SMFs and compare the constraints to compute the eligibility. We defer the computation of the type's [copy-]trivial bits from addedMember to the eligibility computation, like we did for destructors in D126194. `canPassInRegisters` is modified as well to better respect the ineligibility of functions.

Note: Because of the non-implementation of DR1734 and DR1496, I treat deleted member functions as 'eligible' for the purpose of [copy-]triviallity. This is unfortunate, but I couldn't think of a way to make this make sense otherwise.

Reviewed By: #clang-language-wg, cor3ntin, aaron.ballman

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

23 months agoAdding a note about the macro __FLT_EVAL_METHOD__; NFC
Zahira Ammarguellat [Tue, 23 Aug 2022 18:35:57 +0000 (14:35 -0400)]
Adding a note about the macro __FLT_EVAL_METHOD__; NFC

This is to clarify that the macro __FLT_EVAL_METHOD__ is not pre-
defined like other preprocessor macros. It will not appear when
preprocessor macros are dumped.

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

23 months ago[NFC][PowerPC] Clean up a couple of lambdas from the PPCMIPeephole.
Stefan Pintilie [Mon, 22 Aug 2022 16:49:56 +0000 (11:49 -0500)]
[NFC][PowerPC] Clean up a couple of lambdas from the PPCMIPeephole.

There were two sections of code that had a lot of lambdas and in the patch
D40554 it was suggested that we clean them up as a follow-up NFC patch.

Reviewed By: nemanjai, #powerpc

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

23 months agoAMDGPU/MetaData: Restrict address space key to only be emitted for "global_buffer...
Raghav [Tue, 16 Aug 2022 15:08:17 +0000 (11:08 -0400)]
AMDGPU/MetaData: Restrict address space key to only be emitted for "global_buffer" and "dynamic_shared_pointer"

This matches .address_space docs at https://llvm.org/docs/AMDGPUUsage.html#amdgpu-amdhsa-code-object-kernel-argument-metadata-map-table-v3

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

23 months ago[Clang] follow-up D128745, use ClangABICompat15 instead of ClangABICompat14
Yuanfang Chen [Tue, 23 Aug 2022 17:25:02 +0000 (10:25 -0700)]
[Clang] follow-up D128745, use ClangABICompat15 instead of ClangABICompat14

Since the patch missed release 15.x and will be included in release 16.x. Also, simplify related tests.

Reviewed By: aaron.ballman

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

23 months ago[ubsan-minimal][NFC] Use GET_CALLER_PC() to get the return address
Igor Kudrin [Tue, 23 Aug 2022 17:39:27 +0000 (21:39 +0400)]
[ubsan-minimal][NFC] Use GET_CALLER_PC() to get the return address

This is a preparation step for D131914.

23 months ago[Support] MathExtras.h - use llvm::bitcast<> for float-bits cast helpers. NFCI.
Simon Pilgrim [Tue, 23 Aug 2022 17:27:03 +0000 (18:27 +0100)]
[Support] MathExtras.h - use llvm::bitcast<> for float-bits cast helpers. NFCI.

23 months ago[libc] Add Linux implementations of POSIX chdir, fchdir, chmod and fchmod.
Siva Chandra Reddy [Mon, 22 Aug 2022 19:02:25 +0000 (19:02 +0000)]
[libc] Add Linux implementations of POSIX chdir, fchdir, chmod and fchmod.

Reviewed By: michaelrj

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

23 months ago[mlir][LLVMIR] Add `sym_name` attribute to LLVMFuncOp in ODS
Jeff Niu [Tue, 23 Aug 2022 17:00:10 +0000 (10:00 -0700)]
[mlir][LLVMIR] Add `sym_name` attribute to LLVMFuncOp in ODS

This is a required attribute for FunctionOpInterface. Add an ODS
definition so that a more efficient accessor is generated.

23 months ago[MLIR]Extend vector.gather to support n-D result
Che-Yu Wu [Tue, 23 Aug 2022 16:45:43 +0000 (16:45 +0000)]
[MLIR]Extend vector.gather to support n-D result

Currently vector.gather only supports reading memory into a 1-D result vector.
This patch extends it to support an n-D result vector with the indices, masks,
and passthroughs in n-D vectors.

As we are trying to vectorize tensor.extract with vector.gather
(https://github.com/iree-org/iree/issues/9198), it will need to gather the
elements into an n-D vector. Having vector.gather with n-D results allows us
to avoid flatten and reshape at the vectorization stage. The backends can then
decide the optimal ways to lower the vector.gather op.

Note that this is different from n-D gathering, which is about reading n-D
memory with the n-D indices. The indices here are still only 1-D offsets on
the base.

Reviewed By: dcaballe

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

23 months ago[analyzer] Drop deprecated flags
Balazs Benics [Tue, 23 Aug 2022 16:39:21 +0000 (18:39 +0200)]
[analyzer] Drop deprecated flags

As proposed in D126215 (ffe7950ebc62380c3afc7c71f454a1db3f6f5c76),
I'm dropping the `-analyzer-store` and
`-analyzer-opt-analyze-nested-blocks` clang frontend flags.
I'm also dropping the corresponding commandline handlers of `scanbuild`.

This behavior is planned to be part of `clang-16`.

Reviewed By: xazax.hun

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

23 months ago[analyzer] Deadstore static analysis: Fix false positive on C++17 assignments
Fred Tingaud [Tue, 23 Aug 2022 16:33:26 +0000 (18:33 +0200)]
[analyzer] Deadstore static analysis: Fix false positive on C++17 assignments

Dead store detection automatically checks that an expression is a
CXXConstructor and skips it because of potential side effects. In C++17,
with guaranteed copy elision, this check can fail because we actually
receive the implicit cast of a CXXConstructor.
Most checks in the dead store analysis were already stripping all casts
and parenthesis and those that weren't were either forgotten (like the
constructor) or would not suffer from it, so this patch proposes to
factorize the stripping.
It has an impact on where the dead store warning is reported in the case
of an explicit cast, from

  auto a = static_cast<B>(A());
           ^~~~~~~~~~~~~~~~~~~

to

  auto a = static_cast<B>(A());
                          ^~~

which we think is an improvement.

Patch By: frederic-tingaud-sonarsource

Reviewed By: steakhal

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

23 months ago[clangd] Bump timeout for a flaky test
Kadir Cetinkaya [Tue, 23 Aug 2022 16:17:44 +0000 (18:17 +0200)]
[clangd] Bump timeout for a flaky test

This has been failing on some build bots with timeout, increasing it to
5 seconds.

23 months ago[NFC][AMDGPU] Some cleanups in the SIOptimizeExecMasking pass.
Thomas Symalla [Sat, 20 Aug 2022 13:09:17 +0000 (15:09 +0200)]
[NFC][AMDGPU] Some cleanups in the SIOptimizeExecMasking pass.

Fix typos and remove an unused argument.

Reviewed By: foad

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

23 months ago[FastISel] Respect musttail over "disable-tail-calls"
Arthur Eubanks [Fri, 19 Aug 2022 00:59:38 +0000 (17:59 -0700)]
[FastISel] Respect musttail over "disable-tail-calls"

musttail should be honored even in the presence of attributes like "disable-tail-calls". SelectionDAG properly handles this.

Update LangRef to explicitly mention that this is the semantics of musttail.

Reviewed By: rnk

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

23 months ago[TTI] Kill last couple uses of OperandValueKind in targets [nfc]
Philip Reames [Tue, 23 Aug 2022 15:45:01 +0000 (08:45 -0700)]
[TTI] Kill last couple uses of OperandValueKind in targets [nfc]

Use the accessor methods on the containing class instead so that we can change the representation.

23 months ago[ADT] Deprecate is_splat and replace all uses with all_equal
Jakub Kuderski [Tue, 23 Aug 2022 15:36:12 +0000 (11:36 -0400)]
[ADT] Deprecate is_splat and replace all uses with all_equal

See the discussion thread for more details:
https://discourse.llvm.org/t/adt-is-splat-and-empty-ranges/64692

Reviewed By: dblaikie

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

23 months ago[SPIRV] Fix the wrong patch from https://reviews.llvm.org/D131886
Michael Liao [Tue, 23 Aug 2022 15:13:10 +0000 (11:13 -0400)]
[SPIRV] Fix the wrong patch from https://reviews.llvm.org/D131886

- The body of that predicate lambda is removed by mistake.

23 months ago[clang] Pull some utility functions into CompilerInvocation NFC
Ben Langmuir [Mon, 22 Aug 2022 22:42:52 +0000 (15:42 -0700)]
[clang] Pull some utility functions into CompilerInvocation NFC

Move copying compiler arguments to a vector<string> and modifying
common module-related options into CompilerInvocation in preparation for
using some of them in more places and to avoid duplicating this code
accidentally in the future.

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

23 months ago[OffloadPackager] Resolve copy elision warnings
Joseph Huber [Tue, 23 Aug 2022 15:00:53 +0000 (10:00 -0500)]
[OffloadPackager] Resolve copy elision warnings

Summary:
The buildbots are giving failures on the explicit move operations here.
Previously I had problems where not perfomring an explicit move would
cause problems with older compilers so we'll see if this works as
expected.

23 months ago[Clang][OpenMP] Make copyin clause on combined and composite construct work (patch...
utsumi [Tue, 23 Aug 2022 14:18:23 +0000 (07:18 -0700)]
[Clang][OpenMP] Make copyin clause on combined and composite construct work (patch by Yuichiro Utsumi (utsumi.yuichiro@fujitsu.com))

Make copyin clause on the following constructs work.

- parallel for
- parallel for simd
- parallel sections

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

Patch by Yuichiro Utsumi (utsumi.yuichiro@fujitsu.com)

Reviewed By: ABataev

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

23 months ago[TTI] Plumb through OperandValueInfo in getMemoryOpCost [NFC]
Philip Reames [Mon, 22 Aug 2022 22:26:36 +0000 (15:26 -0700)]
[TTI] Plumb through OperandValueInfo in getMemoryOpCost [NFC]

This has the effect of exposing the power-of-two property for use in memory op costing, but no target actually uses it yet.  The main point of this change is simple consistency with the recently changes getArithmeticInstrCost, and to remove the last (interface) use of OperandValueKind.

23 months ago[clang-cl] Expose the /volatile:{iso,ms} choice via _ISO_VOLATILE
David Majnemer [Tue, 23 Aug 2022 14:18:24 +0000 (14:18 +0000)]
[clang-cl] Expose the /volatile:{iso,ms} choice via _ISO_VOLATILE

MSVC allows interpreting volatile loads and stores, when combined with
/volatile:iso, as having acquire/release semantics. MSVC also exposes a
define, _ISO_VOLATILE, which allows users to enquire if this feature is
enabled or disabled.

23 months ago[flang] Allow configuring building the flang runtime standalone
Martin Storsjö [Tue, 19 Jul 2022 21:47:02 +0000 (00:47 +0300)]
[flang] Allow configuring building the flang runtime standalone

This allows building the flang runtime and libFortranDecimal standalone,
without setting up the full llvm build, by pointing cmake to these
directories.

This is the other one out of two essential steps for building the flang runtimes
for a foreign target, i.e. setting up cross compiling with flang.

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

23 months ago[flang] Make runtimes headers independent of the main llvm headers
Martin Storsjö [Wed, 20 Jul 2022 13:32:31 +0000 (16:32 +0300)]
[flang] Make runtimes headers independent of the main llvm headers

llvm/Support/Compiler.h requires llvm-config.h, i.e. to include it,
you'd need to actually set up building llvm for that target.

If using flang to cross compile code for a different target, we need
the runtimes built for that target, but we might not want to build
llvm itself for that target.

This is one out of two essential steps for building the flang runtimes
for a foreign target, i.e. setting up cross compiling with flang.

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

23 months ago[clang/test] Correctly specify simulator env in target flag in fsanitize.c
Nico Weber [Mon, 22 Aug 2022 17:34:42 +0000 (13:34 -0400)]
[clang/test] Correctly specify simulator env in target flag in fsanitize.c

Putting "simulator" in the `-target` flag requires putting it in the
"environment" part of the triple, which is the 4th `-`-separated component.

Some places in the tests currently use "iossimulator" which puts it in the
OS field. The triple parsing code in llvm::Triple uses startswith("ios")
in parseOS(), so that successfully sets the OS to "iOS", and all these
triples use an intel arch, and iOS + intel triple implicitly make the
driver convert the environment to "simulator", so this happened to work --
but it led to the somewhat strange "simulator-simulator" in the diag
in the test.

No behavior change.

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

23 months ago[clang] Remove a FIXME that we can't fix
Nico Weber [Mon, 22 Aug 2022 17:42:46 +0000 (13:42 -0400)]
[clang] Remove a FIXME that we can't fix

I added this recently, but it looks like several tests very intentionally
check that `-mios-version-min=foo --target=x86_64-apple-ios` does simulator
builds. So we can't easily remove this hack, even though it makes little
sense in an arm mac world. (Here, you _have_ to say
`-mios-simulator-version-min=` or `--target=arm64-apple-ios-simulator`.)

The tests that check this:
  Clang :: Driver/darwin-ld.c
  Clang :: Driver/darwin-simulator-macro.c
  Clang :: Driver/darwin-version.c

No behavior change.

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

23 months ago[NFC] LoopAccess: Move expressions close to usage
Aditya Kumar [Mon, 22 Aug 2022 00:19:37 +0000 (17:19 -0700)]
[NFC] LoopAccess: Move expressions close to usage

Avoids useless evaluation of these expressions.

Reviewed By: michaelmaitland, fhahn

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

23 months ago[libc++] Update oss-fuzz.sh to use LLVM_ENABLE_RUNTIMES
Louis Dionne [Tue, 23 Aug 2022 14:06:15 +0000 (10:06 -0400)]
[libc++] Update oss-fuzz.sh to use LLVM_ENABLE_RUNTIMES

23 months ago[DebugInfo][InstrRef] Handle transfers of variadic debug values in LDV
Stephen Tozer [Mon, 20 Jun 2022 11:06:00 +0000 (12:06 +0100)]
[DebugInfo][InstrRef] Handle transfers of variadic debug values in LDV

This patch adds the last of the changes required to enable
DBG_VALUE_LIST handling in InstrRefLDV, handling variadic debug values
during the transfer tracking step. Most of the changes are fairly
straightforward, and based around tracking multiple locations per
variable in TransferTracker::VLocTracker.

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

23 months agoRevert the removal of LLVM_ENABLE_PROJECTS for libc++ and libc++abi
Louis Dionne [Tue, 23 Aug 2022 13:48:36 +0000 (09:48 -0400)]
Revert the removal of LLVM_ENABLE_PROJECTS for libc++ and libc++abi

This commit reverts the following commits:

952f90b72b3546d6b6b038d410f07ce520c59b48
e6a0800532bb409f6d1c62f3698bdd6994a877dc (D132298)
176db3b3ab25ff8a9b2405f50ef5a8bd9304a6d5 (D132324)

These commits caused CI instability and need to be reverted in order
to figure things out again. See the discussion in https://llvm.org/D132324
for more information.

23 months ago[PowerPC] Autogenerate crbits.ll . NFC
Amaury Séchet [Tue, 23 Aug 2022 13:40:01 +0000 (13:40 +0000)]
[PowerPC] Autogenerate crbits.ll . NFC

23 months ago[lldb] [gdb-remote] Use Communication::WriteAll() over Write()
Michał Górny [Mon, 22 Aug 2022 16:59:08 +0000 (18:59 +0200)]
[lldb] [gdb-remote] Use Communication::WriteAll() over Write()

Replace the uses of Communication::Write() with WriteAll() to avoid
partial writes.  None of the call sites actually accounted for that
possibility and even if it is unlikely to actually happen, there doesn't
seem to be any real harm from using WriteAll() instead.

Ideally, we'd remove Write() from the public API.  However, that would
change the API of SBCommunication.  The alternative would be to alias it
to WriteAll().

Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.llvm.org/D132395

23 months ago[llvm][Cmake] Expand "all" in LLVM_ENABLE_PROJECTS before other checks
Kadir Cetinkaya [Tue, 23 Aug 2022 09:04:44 +0000 (11:04 +0200)]
[llvm][Cmake] Expand "all" in LLVM_ENABLE_PROJECTS before other checks

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

23 months ago[OffloadPackager] Add necessary move statement on returned value
Joseph Huber [Tue, 23 Aug 2022 13:44:13 +0000 (08:44 -0500)]
[OffloadPackager] Add necessary move statement on returned value

Summary:
Some older compilers cannot automatically elide the returned vector of
unique pointers, causing build errors. This patch explicitly moves the
returned value instead which should solve the problem.

23 months ago[pseudo] Eliminate a false parse of structured binding declaration.
Haojian Wu [Fri, 19 Aug 2022 19:55:39 +0000 (21:55 +0200)]
[pseudo] Eliminate a false parse of structured binding declaration.

Using the guard to implement part of the rule https://eel.is/c++draft/dcl.pre#6.

```
void foo() {
  // can be parsed as
  //   - structured-binding declaration (a false parse)
  //   - assignment expression
  array[index] = value;
}
```

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

23 months ago[NFC] Fix typo in dbg message in RegisterCoalescer.
Thomas Symalla [Tue, 23 Aug 2022 13:14:45 +0000 (15:14 +0200)]
[NFC] Fix typo in dbg message in RegisterCoalescer.

funcion => function

23 months ago[pseudo] Fix HeadsPartition is not initialized correctly.
Haojian Wu [Tue, 23 Aug 2022 13:08:26 +0000 (15:08 +0200)]
[pseudo] Fix HeadsPartition is not initialized correctly.

The bug was that if we recover from the token 0, we will make the
Heads empty (Line646), which results no recovery being applied.

Reviewed By: sammccall

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

23 months ago[MLIR] Harden gpu.func verification
Christian Sigg [Tue, 23 Aug 2022 10:45:49 +0000 (12:45 +0200)]
[MLIR] Harden gpu.func verification

GPUFuncOpLowering moves the body out of gpu.func op and erases it. An empty gpu.func may fail verification but should not crash it. Verification of an erased op is triggered e.g. with debug printing on.

Reviewed By: akuegel

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

23 months ago[OffloadPackager] Add option to extract files from images
Joseph Huber [Wed, 17 Aug 2022 18:10:04 +0000 (14:10 -0400)]
[OffloadPackager] Add option to extract files from images

We use the `clang-offload-packager` too bundle many files into a single
binary format containing metadata. This is used for offloading
compilation which may contain multiple device binaries of different
types and architectures in a single file. We use this special binary
format to store these files along with some necessary metadata around
them. We use this format because of the difficulty of determining the
filesize of the various binary inputs that will be passed to the
offloading toolchain rather than engineering a solution for each input.

Previously we only support packaing many files into a single binary.
This patch adds support for doing the reverse by using the same
`--image=` syntax. To unpackage a binary we now present an input file
instead of an output.

Reviewed By: tra

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

23 months ago[runtimes] Handle interface targets in runtimes distribution components
Louis Dionne [Mon, 22 Aug 2022 16:00:40 +0000 (12:00 -0400)]
[runtimes] Handle interface targets in runtimes distribution components

As reported in [1], cxx-headers is not a valid distribution target
because it is an interface target in CMake. This breaks the most
basic MultiDistributionExample of the runtimes build.

This patch handles interface targets by getting rid of the assumption
that all distribution components have a target associated to them. It
is valid for a distribution component to only have a `install-FOO`
target.

In the case where only `cxx-headers` is provided as a distribution
component, `ninja toolchain-distribution` will not build anything
after this patch, since there is effectively nothing to build for
the `cxx-headers` target. However, running `ninja install-toolchain-distribution`
will build everything, as expected.

[1]: https://discord.com/channels/636084430946959380/636732894974312448/1010013287464828968

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

23 months ago[Globals] Treat nobuiltin fns as maybe-derefined.
Florian Hahn [Tue, 23 Aug 2022 12:44:59 +0000 (13:44 +0100)]
[Globals] Treat nobuiltin fns as maybe-derefined.

Callsites could be marked as `builtin` while calling `nobuiltin`
functions. This can lead to problems, if local optimizations apply
transformations based on the semantics of the builtin, but then IPO
treats the function as `nobuiltin` and applies a transform that breaks
builtin semantics (assumed earlier).

To avoid this, mark such functions as maybey-derefined, to avoid IPO
transforms on them that may break assumptions of earlier calls.

Fixes #57075
Fixes #48366

Reviewed By: ychen

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

23 months ago[reland][NFC][libc] standardize string_view
Guillaume Chatelet [Tue, 23 Aug 2022 09:56:57 +0000 (09:56 +0000)]
[reland][NFC][libc] standardize string_view

23 months agoRevert "[reland][NFC][libc] standardize string_view"
Guillaume Chatelet [Tue, 23 Aug 2022 12:40:07 +0000 (12:40 +0000)]
Revert "[reland][NFC][libc] standardize string_view"

This reverts commit df99774ef7d9c910941fe915689f9126258800ee.

23 months agobuffer-deallocation: consider aliases introduced by arith.select.
Johannes Reifferscheid [Tue, 23 Aug 2022 12:21:40 +0000 (14:21 +0200)]
buffer-deallocation: consider aliases introduced by arith.select.

Currently, buffer deallocation considers arith.select to be
non-aliasing, which results in deallocs being inserted incorrectly. Since
arith.select doesn't implement any useful interfaces, this change just handles
it explicitly. Eventually this should probably be fixed properly, if this pass
is going to be used long term.

Reviewed By: springerm

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

23 months ago[DebugInfo][InstrRef][NFC] Emit variadic debug values from InstrRefLDV
Stephen Tozer [Mon, 20 Jun 2022 11:46:08 +0000 (12:46 +0100)]
[DebugInfo][InstrRef][NFC] Emit variadic debug values from InstrRefLDV

In preparation for supporting DBG_VALUE_LIST in InstrRefLDV, this patch
adds the logic for emitting DBG_VALUE_LIST instructions from
InstrRefLDV. The logical changes here are fairly simple, with the main
change being that instead of directly prepending offsets to the DIExpr,
we use appendOpsToArg to modify the expression for individual debug
operands in the expression. The function emitLoc is also changed to take
a list of debug ops, with an empty list meaning an undef value.

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

23 months ago[mlir][Bufferization] Use DestinationStyleOpInterface where possible.
Adrian Kuegel [Tue, 23 Aug 2022 11:42:19 +0000 (13:42 +0200)]
[mlir][Bufferization] Use DestinationStyleOpInterface where possible.

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

23 months ago[reland][NFC][libc] standardize string_view
Guillaume Chatelet [Tue, 23 Aug 2022 09:56:57 +0000 (09:56 +0000)]
[reland][NFC][libc] standardize string_view

23 months ago[DeadArgElim] Add test case for #48366, #57075
Florian Hahn [Tue, 23 Aug 2022 12:08:38 +0000 (13:08 +0100)]
[DeadArgElim] Add test case for #48366, #57075

23 months agoRevert "[reland][NFC][libc] standardize string_view"
Guillaume Chatelet [Tue, 23 Aug 2022 11:50:56 +0000 (11:50 +0000)]
Revert "[reland][NFC][libc] standardize string_view"

This reverts commit 522d29a6a745e38d635739b05383770804bac311.

23 months ago[reland][NFC][libc] standardize string_view
Guillaume Chatelet [Tue, 23 Aug 2022 09:56:57 +0000 (09:56 +0000)]
[reland][NFC][libc] standardize string_view

23 months ago[gn build] Port 134d017b88ca
LLVM GN Syncbot [Tue, 23 Aug 2022 11:31:54 +0000 (11:31 +0000)]
[gn build] Port 134d017b88ca

23 months ago[ADT] Add unittest coverage for ADT/bit.h header
Simon Pilgrim [Tue, 23 Aug 2022 11:23:11 +0000 (12:23 +0100)]
[ADT] Add unittest coverage for ADT/bit.h header

23 months ago[mlir] Extract DestinationStyleOpInterface from LinalgStructuredInterface.
Adrian Kuegel [Tue, 23 Aug 2022 10:34:58 +0000 (12:34 +0200)]
[mlir] Extract DestinationStyleOpInterface from LinalgStructuredInterface.

There are several use cases where a destination style operation needs an interface
that contains a subset of the methods from LinalgStructuredInterface.
In this change, we move all such methods to a new interface, and add forwarding
methods to LinalgStructuredInterface to make the change the less invasive.
It may be possible to refactor the code later to get rid of (some or all) of the
forwarding methods.
This change also removes the cloneWithMapper interface methods, as it is not used anywhere.

RFC:
https://discourse.llvm.org/t/rfc-interface-for-destination-style-ops/64056

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

23 months agoRevert "[reland][NFC][libc] standardize string_view"
Guillaume Chatelet [Tue, 23 Aug 2022 11:00:22 +0000 (11:00 +0000)]
Revert "[reland][NFC][libc] standardize string_view"

This reverts commit 187099da1c415bd8f717eb5adc75bb1d73c7a0ba.

23 months ago[reland][NFC][libc] standardize string_view
Guillaume Chatelet [Tue, 23 Aug 2022 09:56:57 +0000 (09:56 +0000)]
[reland][NFC][libc] standardize string_view

23 months ago[CodeGen][InstrRef] Remove unused variables from test case
Stephen Tozer [Tue, 23 Aug 2022 09:59:14 +0000 (10:59 +0100)]
[CodeGen][InstrRef] Remove unused variables from test case

23 months agoRevert "[NFC][libc] standardize string_view"
Guillaume Chatelet [Tue, 23 Aug 2022 10:43:11 +0000 (10:43 +0000)]
Revert "[NFC][libc] standardize string_view"

This reverts commit abe0fa6b17d866ef21e7c2abb799658c490b8508.

23 months ago[AArch64] Fix list of features for Cortex-X1C
Lucas Prates [Thu, 18 Aug 2022 09:21:22 +0000 (10:21 +0100)]
[AArch64] Fix list of features for Cortex-X1C

This patch fixes the list of subtarget features enabled for the
Cortex-X1C processor, including the following:

* Fix incorrect version used for FeatureRCPC:
  * Use FEAT_LRCPC2 instead of FEAT_LRCPC.
* Add missing v8.4-A features included in the TRM:
  * Flag Manipulation Instructions - FeatureFlagM (FEAT_FlagM)
  * Large System Extension 2 - FeatureLSE2 (FEAT_LSE2)

Reviewed By: vhscampos

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

23 months ago[StructurizeCFG] Autogenerate checks
Jay Foad [Tue, 23 Aug 2022 10:22:14 +0000 (11:22 +0100)]
[StructurizeCFG] Autogenerate checks

23 months ago[AMDGPU][MC][GFX9][NFC] Consolidate tests by encoding
Dmitry Preobrazhensky [Tue, 23 Aug 2022 10:09:47 +0000 (13:09 +0300)]
[AMDGPU][MC][GFX9][NFC] Consolidate tests by encoding

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

23 months ago[NFC][libc] standardize string_view
Guillaume Chatelet [Tue, 23 Aug 2022 09:56:57 +0000 (09:56 +0000)]
[NFC][libc] standardize string_view

23 months ago[tensor][bufferize] Use affine.apply instead of arith.addi in PadOp lowering
Matthias Springer [Tue, 23 Aug 2022 09:38:54 +0000 (11:38 +0200)]
[tensor][bufferize] Use affine.apply instead of arith.addi in PadOp lowering

Affine exprs compose better than arith ops.

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

23 months ago[docs] Add examples for printing asynchronous stack for coroutines
Chuanqi Xu [Tue, 23 Aug 2022 08:34:01 +0000 (16:34 +0800)]
[docs] Add examples for printing asynchronous stack for coroutines

Previously when I wrote this document, I felt the completed scripts was
lengthy, redundant and not easy to read. So I didn't add complete
examples in the previous commit.

However, in the recent discussion with @avogelsgesang, I found people
may not know how to use debugging scripts to improve their debugging
efficiency. So now, I feel like it is helpful to put the examples even
if they are a little bit long.

Test Plan: make docs-clang-html

Reviewed By: avogelsgesang

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

23 months ago[ADT] Add llvm::popcount to <bit> helper wrapper
Simon Pilgrim [Tue, 23 Aug 2022 09:36:32 +0000 (10:36 +0100)]
[ADT] Add llvm::popcount to <bit> helper wrapper

This patch proposes to move the llvm::detail::PopulationCounter internal helpers into ADT/bit.h and provide a llvm::popcount implementation.

I've left the countPopulation implementation in place in MathExtras.h for now, but updated it to use llvm::popcount.

Hopefully I've got the type_traits correct - I don't use them very often.

Someday we'll move to C++20 with an actual <bit> std header, and we already have this header in place to simplify matters. We'd probably benefit from moving the other <bit> helpers here at some point, but this is a first step.

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

23 months ago[TwoAddressInstruction] Handle pointer compare sunk past statepoint.
Denis Antrushin [Fri, 19 Aug 2022 11:31:15 +0000 (18:31 +0700)]
[TwoAddressInstruction] Handle pointer compare sunk past statepoint.

CodeGenPrepare pass can sink pointer comparison across statepoint
to the point of use (see comment in IR/SafepointIRVerifier.cpp)
Due to specifics of statepoints, it is still legal to have tied
def and use rewritten to the same register in TwoAddress pass.
However, properly updating LiveIntervals and LiveVariables becomes
complicated. For simplicity, let's fall back to generic handling of
tied registers when we detect such case.
TODO: This fixes functional (assertion) failure. Ideally we should
try to recompute new live range/liveness in place.

Reviewed By: skatkov

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

23 months ago[LoopUtils] Remove unused Loop arg from addDiffRuntimeChecks (NFC).
Florian Hahn [Tue, 23 Aug 2022 09:15:27 +0000 (10:15 +0100)]
[LoopUtils] Remove unused Loop arg from addDiffRuntimeChecks (NFC).

The argument is no longer used, remove it.

23 months ago[LoongArch] Optimize the atomic store with amswap_db.[w/d]
gonglingqin [Tue, 23 Aug 2022 08:58:22 +0000 (16:58 +0800)]
[LoongArch] Optimize the atomic store with amswap_db.[w/d]

When AtomicOrdering is release or stronger, use
    amswap_db.[w/d] $zero, $a1, $a0
instead of
    dbar 0
    st.[w/d] $a0, $a1, 0

Thanks to @xry111 for the suggestion: https://reviews.llvm.org/D128901#3626635

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

23 months ago[NFC][LoopVectorize] Precommit masked vector function call tests
Graham Hunter [Tue, 23 Aug 2022 08:45:18 +0000 (09:45 +0100)]
[NFC][LoopVectorize] Precommit masked vector function call tests

23 months ago[mlir][Linalg] Retire LinalgStrategyGeneralizePass
Guray Ozen [Tue, 23 Aug 2022 08:02:13 +0000 (10:02 +0200)]
[mlir][Linalg] Retire LinalgStrategyGeneralizePass

This revision deletes LinalgStrategyGeneralizePass.

Context: https://discourse.llvm.org/t/psa-retire-linalg-filter-based-patterns/63785

Reviewed By: nicolasvasilache

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

23 months ago[NFC] Remove undef from xfailed SimplifyCFG test
Dmitry Makogon [Tue, 23 Aug 2022 07:51:29 +0000 (14:51 +0700)]
[NFC] Remove undef from xfailed SimplifyCFG test

The test fails not because of undef, so replacing with
normal condition.

23 months ago[mlir][Linalg] Retire Linalg generic interchange pattern and pass
Guray Ozen [Tue, 23 Aug 2022 07:28:16 +0000 (09:28 +0200)]
[mlir][Linalg] Retire Linalg generic interchange pattern and pass

This revision removes the Linalg generic interchange pattern and pass.

It also changes transform-patterns test to make use of transform dialect.

Context: https://discourse.llvm.org/t/psa-retire-linalg-filter-based-patterns/63785

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

23 months ago[clang][AST] RecursiveASTVisitor should visit owned TagDecl of friend type.
Balázs Kéri [Tue, 23 Aug 2022 06:51:54 +0000 (08:51 +0200)]
[clang][AST] RecursiveASTVisitor should visit owned TagDecl of friend type.

A FriendDecl node can have a friend record type that owns a RecordDecl
object. This object is different than the one got from TypeSourceInfo
object of the FriendDecl. When building a ParentMapContext this owned
tag decaration has to be encountered to have the parent set for it.

Reviewed By: sammccall

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

23 months ago[mlir][Linalg] Remove unused method declaration.
Adrian Kuegel [Fri, 19 Aug 2022 13:20:06 +0000 (15:20 +0200)]
[mlir][Linalg] Remove unused method declaration.

The "real" method declaration is in LinalgInterfaces.h

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

23 months ago[llvm-profdata][NFC] fix warning
liaochunyu [Tue, 23 Aug 2022 05:53:06 +0000 (13:53 +0800)]
[llvm-profdata][NFC] fix warning

warning: unused variable ‘FC’

Reviewed By: kazu

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

23 months ago[gn build] Port 15b65bcd6519
LLVM GN Syncbot [Tue, 23 Aug 2022 05:49:48 +0000 (05:49 +0000)]
[gn build] Port 15b65bcd6519

23 months ago[Clang][LoongArch] Add initial LoongArch target and driver support
Weining Lu [Tue, 23 Aug 2022 05:11:32 +0000 (13:11 +0800)]
[Clang][LoongArch] Add initial LoongArch target and driver support

With the initial support added, clang can compile `helloworld` C
to executable file for loongarch64. For example:

```
$ cat hello.c
int main() {
  printf("Hello, world!\n");
  return 0;
}
$ clang --target=loongarch64-unknown-linux-gnu --gcc-toolchain=xxx --sysroot=xxx hello.c
```

The output a.out can run within qemu or native machine. For example:

```
$ file ./a.out
./a.out: ELF 64-bit LSB pie executable, LoongArch, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-loongarch-lp64d.so.1, for GNU/Linux 5.19.0, with debug_info, not stripped
$ ./a.out
Hello, world!
```

Currently gcc toolchain and sysroot can be found here:
https://github.com/loongson/build-tools/releases/download/2022.08.11/loongarch64-clfs-5.1-cross-tools-gcc-glibc.tar.xz

Reference: https://github.com/loongson/LoongArch-Documentation
The last commit hash (main branch) is:
99016636af64d02dee05e39974d4c1e55875c45b

Note loongarch32 is not fully tested because there is no reference
gcc toolchain yet.

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

23 months ago[CMake] Support passing arguments to build tool (bootstrap).
Carlos Alberto Enciso [Tue, 23 Aug 2022 04:45:25 +0000 (05:45 +0100)]
[CMake] Support passing arguments to build tool (bootstrap).

For bootstrap builds (CLANG_ENABLE_BOOTSTRAP=ON) allow
arguments to be passed to the native tool used in CMake
for the stage2 step.

Can be used to pass extra arguments for enhanced versions
of build tools, e.g. distributed build options.

Reviewed By: phosek

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

23 months ago[VE] Support inlineasm memory operand
Kazushi (Jam) Marukawa [Mon, 22 Aug 2022 14:31:44 +0000 (23:31 +0900)]
[VE] Support inlineasm memory operand

Support inline asm memory operand for VE.  Add regression tests also.

Reviewed By: efocht

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

23 months ago[LV][NFC] Modify code comments
liqinweng [Tue, 23 Aug 2022 04:13:06 +0000 (12:13 +0800)]
[LV][NFC] Modify code comments

Reviewed By: jacquesguan

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