platform/upstream/llvm.git
2 years ago[clang-doc] SerializeIndex - pass Index param by constant reference
Simon Pilgrim [Thu, 17 Feb 2022 13:28:02 +0000 (13:28 +0000)]
[clang-doc] SerializeIndex - pass Index param by constant reference

Silence coverity warnings about unnecessary copies

2 years ago[NFC] Fix comment
Shao-Ce SUN [Thu, 17 Feb 2022 13:19:14 +0000 (21:19 +0800)]
[NFC] Fix comment

2 years ago[clang] CGDebugInfo::getOrCreateMethodType - use castAs<> instead of getAs<> to avoid...
Simon Pilgrim [Thu, 17 Feb 2022 13:18:02 +0000 (13:18 +0000)]
[clang] CGDebugInfo::getOrCreateMethodType - use castAs<> instead of getAs<> to avoid dereference of nullptr

The pointer is always dereferenced, so assert the cast is correct instead of returning nullptr

2 years ago[clang] CGCXXABI::EmitLoadOfMemberFunctionPointer - use castAs<> instead of getAs...
Simon Pilgrim [Thu, 17 Feb 2022 13:15:19 +0000 (13:15 +0000)]
[clang] CGCXXABI::EmitLoadOfMemberFunctionPointer - use castAs<> instead of getAs<> to avoid dereference of nullptr

The pointer is always dereferenced by arrangeCXXMethodType, so assert the cast is correct instead of returning nullptr

2 years ago[NFC] Correct typo `interger` to `integer`
Shao-Ce SUN [Thu, 17 Feb 2022 13:13:00 +0000 (21:13 +0800)]
[NFC] Correct typo `interger` to `integer`

2 years ago[BufferDeallocation] Don't assume successor operands are unique
Benjamin Kramer [Thu, 17 Feb 2022 12:51:27 +0000 (13:51 +0100)]
[BufferDeallocation] Don't assume successor operands are unique

This would create a double free when a memref is passed twice to the
same op. This wasn't a problem at the time the pass was written but is
common since the introduction of scf.while.

There's a latent non-determinism that's triggered by the test, but this
change is messy enough as-is so I'll leave that for later.

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

2 years ago[AArch64] Allow strict opcodes in faddp patterns
John Brawn [Fri, 28 Jan 2022 15:05:39 +0000 (15:05 +0000)]
[AArch64] Allow strict opcodes in faddp patterns

This also requires adjustment to code in AArch64ISelLowering so that
vector_extract is distributed over strict_fadd.

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

2 years ago[AArch64] Allow strict opcodes in indexed fmul and fma patterns
John Brawn [Fri, 28 Jan 2022 14:31:17 +0000 (14:31 +0000)]
[AArch64] Allow strict opcodes in indexed fmul and fma patterns

Using an indexed version instead of a non-indexed version doesn't
change anything with regards to exceptions or rounding.

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

2 years ago[AArch64] Allow strict opcodes in fp->int->fp patterns
John Brawn [Fri, 28 Jan 2022 14:10:51 +0000 (14:10 +0000)]
[AArch64] Allow strict opcodes in fp->int->fp patterns

These patterns don't change the fundamental instructions that are
used, just the variants that are used in order to remove some extra
MOVs.

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

2 years ago[AArch64] Add instruction selection for strict FP
John Brawn [Fri, 7 Jan 2022 14:47:26 +0000 (14:47 +0000)]
[AArch64] Add instruction selection for strict FP

This consists of marking the various strict opcodes as legal, and
adjusting instruction selection patterns so that 'op' is 'any_op'.

FP16 and vector instructions additionally require some extra work in
lowering and legalization, so we can't set IsStrictFPEnabled just yet.
Also more work needs to be done for full strict fp support (marking
instructions that can raise exceptions as such, and modelling FPCR use
for controlling rounding).

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

2 years ago[llvm][automemcpy] Allow distribution filtering in analysis
Guillaume Chatelet [Thu, 17 Feb 2022 11:51:59 +0000 (11:51 +0000)]
[llvm][automemcpy] Allow distribution filtering in analysis

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

2 years ago[AArch64][NFC] Fix unused-lambda-capture warning.
Adrian Kuegel [Thu, 17 Feb 2022 12:31:50 +0000 (13:31 +0100)]
[AArch64][NFC] Fix unused-lambda-capture warning.

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

2 years ago[Docs] Use correct rst syntax
Nikita Popov [Thu, 17 Feb 2022 13:08:29 +0000 (14:08 +0100)]
[Docs] Use correct rst syntax

2 years agoRemove duplicated code for printing the `uwtable` attribute (NFC)
Momchil Velikov [Thu, 17 Feb 2022 11:18:11 +0000 (11:18 +0000)]
Remove duplicated code for printing the `uwtable` attribute (NFC)

Committed as obvious.

Reviewed By: chill

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

2 years ago[Bazel] Fix build after ObjCopy move.
Adrian Kuegel [Thu, 17 Feb 2022 12:02:14 +0000 (13:02 +0100)]
[Bazel] Fix build after ObjCopy move.

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

2 years ago[flang][driver] Add support for `-emit-llvm`
Andrzej Warzynski [Fri, 4 Feb 2022 17:15:12 +0000 (17:15 +0000)]
[flang][driver] Add support for `-emit-llvm`

This patch adds support for the `-emit-llvm` option in the frontend
driver (i.e. `flang-new -fc1`). Similarly to Clang, `flang-new -fc1
-emit-llvm file.f` will generate a textual LLVM IR file.

Depends on D118985

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

2 years ago[libc][automemcpy] Add mean/variance and simplify implementation
Guillaume Chatelet [Thu, 17 Feb 2022 10:56:25 +0000 (10:56 +0000)]
[libc][automemcpy] Add mean/variance and simplify implementation

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

2 years ago[Docs] Update opaque pointers docs
Nikita Popov [Thu, 17 Feb 2022 12:00:46 +0000 (13:00 +0100)]
[Docs] Update opaque pointers docs

Expand migration instructions.

2 years ago[NFC][PhaseOrdering] Improve test coverage for D119975
Roman Lebedev [Thu, 17 Feb 2022 11:30:02 +0000 (14:30 +0300)]
[NFC][PhaseOrdering] Improve test coverage for D119975

2 years ago[SystemZ] lowerDYNAMIC_STACKALLOC_XPLINK - use cast<> instead of dyn_cast<> to avoid...
Simon Pilgrim [Thu, 17 Feb 2022 11:56:29 +0000 (11:56 +0000)]
[SystemZ] lowerDYNAMIC_STACKALLOC_XPLINK - use cast<> instead of dyn_cast<> to avoid dereference of nullptr

The pointer is always dereferenced, so assert the cast is correct instead of returning nullptr

2 years ago[X86] X86tcret_1reg - use cast<> instead of dyn_cast<> to avoid dereference of nullptr
Simon Pilgrim [Thu, 17 Feb 2022 11:54:12 +0000 (11:54 +0000)]
[X86] X86tcret_1reg - use cast<> instead of dyn_cast<> to avoid dereference of nullptr

The pointer is always dereferenced, so assert the cast is correct instead of returning nullptr

2 years agoAArch64_MC::isQForm - Fix MSVC 'no default capture mode' lambda warning
Simon Pilgrim [Thu, 17 Feb 2022 11:41:47 +0000 (11:41 +0000)]
AArch64_MC::isQForm - Fix MSVC 'no default capture mode' lambda warning

2 years ago[RelLookupTableConverter] Ensure that GV, GEP and load types match
Nikita Popov [Thu, 17 Feb 2022 10:59:04 +0000 (11:59 +0100)]
[RelLookupTableConverter] Ensure that GV, GEP and load types match

This code could be generalized to be type-independent, but for now
just ensure that the same type constraints are enforced with opaque
pointers as with typed pointers.

2 years ago[SCEV] Infer ranges for SCC consisting of cycled Phis
Max Kazantsev [Thu, 17 Feb 2022 10:38:42 +0000 (17:38 +0700)]
[SCEV] Infer ranges for SCC consisting of cycled Phis

Our current strategy of computing ranges of SCEVUnknown Phis was to simply
compute the union of ranges of all its inputs. In order to avoid infinite recursion,
we mark Phis as pending and conservatively return full set for them. As result,
even simplest patterns of cycled phis always have a range of full set.

This patch makes this logic a bit smarter. We basically do the same, but instead
of taking inputs of single Phi we find its strongly connected component (SCC)
and compute the union of all inputs that come into this SCC from outside.

Processing entire SCC together has one more advantage: we can set range for all
of them at once, because the only thing that happens to them is the same value is
being passed between those Phis. So, despite we spend more time analyzing a
single Phi, overall we may save time by not processing other SCC members, so
amortized compile time spent should be approximately the same.

Differential Revision: https://reviews.llvm.org/D110620
Reviewed By: reames

2 years ago[OpenCL] Guard 64-bit atomic types
Sven van Haastregt [Thu, 17 Feb 2022 10:58:52 +0000 (10:58 +0000)]
[OpenCL] Guard 64-bit atomic types

Until now, overloads with a 64-bit atomic type argument were always
made available with `-fdeclare-opencl-builtins`.  Ensure these
overloads are only available when both the `cl_khr_int64_base_atomics`
and `cl_khr_int64_extended_atomics` extensions have been enabled, as
required by the OpenCL specification.

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

2 years ago[objcopy][NFC] Add doc comments to the executeObjcopy* functions.
Alexey Lapshin [Thu, 17 Feb 2022 10:25:48 +0000 (13:25 +0300)]
[objcopy][NFC] Add doc comments to the executeObjcopy* functions.

Add doc comments to the executeObjcopy* functions.

Depends on D88827

2 years ago[SchedModels][CortexA55] Add ASIMD integer instructions
Pavel Kosov [Thu, 17 Feb 2022 10:41:57 +0000 (13:41 +0300)]
[SchedModels][CortexA55] Add ASIMD integer instructions

Depends on D114642

Original review https://reviews.llvm.org/D112201

OS Laboratory. Huawei Russian Research Institute. Saint-Petersburg

Reviewed By: dmgreen

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

2 years ago[AArch64][SchedModels] Handle virtual registers in FP/NEON predicates
Pavel Kosov [Thu, 17 Feb 2022 10:41:05 +0000 (13:41 +0300)]
[AArch64][SchedModels] Handle virtual registers in FP/NEON predicates

Current implementation of Check[HSDQ]Form predicates doesn’t handle virtual registers and therefore isn’t useful for pre-RA scheduling. Patch fixes this implementing two function predicates: CheckQForm for checking that instruction writes 128-bit NEON register and CheckFpOrNEON which checks that instruction writes FP register (any width). The latter supersedes Check[HSD]Form predicates which are not used individually.

OS Laboratory. Huawei Russian Research Institute. Saint-Petersburg

Reviewed By: dmgreen

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

2 years ago[CodeGen] Rename deprecated Address constructor
Nikita Popov [Wed, 16 Feb 2022 15:38:11 +0000 (16:38 +0100)]
[CodeGen] Rename deprecated Address constructor

To make uses of the deprecated constructor easier to spot, and to
ensure that no new uses are introduced, rename it to
Address::deprecated().

While doing the rename, I've filled in element types in cases
where it was relatively obvious, but we're still left with 135
calls to the deprecated constructor.

2 years ago[RISCV] Add the passthru operand for vadc/vsbc/vmerge/vfmerge IR intrinsics.
Zakk Chen [Fri, 28 Jan 2022 16:16:25 +0000 (08:16 -0800)]
[RISCV] Add the passthru operand for vadc/vsbc/vmerge/vfmerge IR intrinsics.

The goal is support tail and mask policy in RVV builtins.
We focus on IR part first.
If the passthru operand is undef, we use tail agnostic, otherwise
use tail undisturbed.

Reviewed By: rogfer01

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

2 years agoRevert "[compiler-rt] Implement ARM atomic operations for architectures without...
Eli Friedman [Thu, 17 Feb 2022 10:17:27 +0000 (02:17 -0800)]
Revert "[compiler-rt] Implement  ARM atomic operations for architectures without SMP support"

This reverts commit 910a642c0a5b66a8d2517026b890a1acdc447f19.

There are serious correctness issues with the current approach: __sync_*
routines which are not actually atomic should not be enabled by default.

I'll continue discussion on the review.

2 years agoRevert "[NFC][compiler-rt] Format file lib/builtins/arm/sync-ops.h"
Eli Friedman [Thu, 17 Feb 2022 10:16:25 +0000 (02:16 -0800)]
Revert "[NFC][compiler-rt] Format file lib/builtins/arm/sync-ops.h"

This reverts commit f165c23bf3598990aaf2174a6bc40be75199ee1a.

Part of revert sequence for 910a642c0a.

2 years ago[llvm-objcopy][NFC] Move core implementation of llvm-objcopy into separate library.
Alexey Lapshin [Fri, 11 Feb 2022 18:42:40 +0000 (21:42 +0300)]
[llvm-objcopy][NFC] Move core implementation of llvm-objcopy into separate library.

This patch moves core implementation of llvm-objcopy into Object library
(http://lists.llvm.org/pipermail/llvm-dev/2020-September/145075.html).
The functionality for parsing input options is left inside tools/llvm-objcopy.
The interface of ObjCopy library:

ObjCopy/ELF/ELFObjcopy.h

```
Error executeObjcopyOnIHex(const CopyConfig &Config, MemoryBuffer &In,
                           Buffer &Out);
Error executeObjcopyOnRawBinary(const CopyConfig &Config, MemoryBuffer &In,
                                Buffer &Out);
Error executeObjcopyOnBinary(const CopyConfig &Config,
                             object::ELFObjectFileBase &In, Buffer &Out);

```
ObjCopy/COFF/COFFObjcopy.h

```
Error executeObjcopyOnBinary(const CopyConfig &Config,
                             object::COFFObjectFile &In, Buffer &Out);

```
ObjCopy/MachO/MachOObjcopy.h

```
Error executeObjcopyOnBinary(const CopyConfig &Config,
                             object::MachOObjectFile &In, Buffer &Out);

```
ObjCopy/wasm/WasmObjcopy.h

```
Error executeObjcopyOnBinary(const CopyConfig &Config,
                             object::WasmObjectFile &In, Buffer &Out);

```

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

2 years ago[MLIR] add entry block to MLIR grammar.
Siddharth Bhat [Thu, 17 Feb 2022 10:10:19 +0000 (15:40 +0530)]
[MLIR] add entry block to MLIR grammar.

The MLIR parser allows regions to have an unnamed entry block.
Make this explicit in the language grammar.

Reviewed By: mehdi_amini

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

2 years ago[AArch64] Cleanup for performCommonVectorExtendCombine. NFC
David Green [Thu, 17 Feb 2022 10:03:28 +0000 (10:03 +0000)]
[AArch64] Cleanup for performCommonVectorExtendCombine. NFC

This is some NFC (hopefully!) cleanup for performCommonVectorExtendCombine
and related methods, removing conditions that cannot occur and otherwise
cleaning up the code a little.

2 years ago[AMDGPU] Return better Changed status from SILowerI1Copies
Jay Foad [Wed, 16 Feb 2022 11:00:44 +0000 (11:00 +0000)]
[AMDGPU] Return better Changed status from SILowerI1Copies

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

2 years ago[AMDGPU] Return better Changed status from SIAnnotateControlFlow
Jay Foad [Wed, 16 Feb 2022 11:00:25 +0000 (11:00 +0000)]
[AMDGPU] Return better Changed status from SIAnnotateControlFlow

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

2 years agoAdd missing break statement in switch.
Stanislav Gatev [Thu, 17 Feb 2022 09:37:02 +0000 (09:37 +0000)]
Add missing break statement in switch.

2 years ago[AMDGPU] Return better Changed status from AMDGPUPerfHintAnalysis
Jay Foad [Wed, 16 Feb 2022 11:00:05 +0000 (11:00 +0000)]
[AMDGPU] Return better Changed status from AMDGPUPerfHintAnalysis

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

2 years ago[AMDGPU] Return better Changed status from AMDGPUAnnotateUniformValues
Jay Foad [Wed, 16 Feb 2022 10:59:39 +0000 (10:59 +0000)]
[AMDGPU] Return better Changed status from AMDGPUAnnotateUniformValues

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

2 years ago[CodeGen] Return better Changed status from LocalStackSlotAllocation
Jay Foad [Wed, 16 Feb 2022 10:58:54 +0000 (10:58 +0000)]
[CodeGen] Return better Changed status from LocalStackSlotAllocation

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

2 years ago[CodeGen] Return false from LiveIntervals::runOnMachineFunction
Jay Foad [Wed, 16 Feb 2022 10:57:50 +0000 (10:57 +0000)]
[CodeGen] Return false from LiveIntervals::runOnMachineFunction

This is an analysis pass so it does not modify the MachineFunction.

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

2 years ago[CodeGen] Return better Changed status from DetectDeadLanes
Jay Foad [Wed, 16 Feb 2022 10:56:56 +0000 (10:56 +0000)]
[CodeGen] Return better Changed status from DetectDeadLanes

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

2 years agoRevert "[RISCV] LUI used for address computation should not isAsCheapAsAMove"
Ben Shi [Thu, 17 Feb 2022 09:24:38 +0000 (17:24 +0800)]
Revert "[RISCV] LUI used for address computation should not isAsCheapAsAMove"

This reverts commit 23a50736004e94704a2393aa36a905d737f2b20f.

Although this patch achieved better codegen in most cases, it is really
important to accurately describe the cost of instructions. So I revert it.

2 years ago[SimplifyCFG][PhaseOrdering] Defer lowering switch into an integer range comparison...
Roman Lebedev [Thu, 17 Feb 2022 09:07:17 +0000 (12:07 +0300)]
[SimplifyCFG][PhaseOrdering] Defer lowering switch into an integer range comparison and branch until after at least the IPSCCP

That transformation is lossy, as discussed in
https://github.com/llvm/llvm-project/issues/53853
and https://github.com/rust-lang/rust/issues/85133#issuecomment-904185574

This is an alternative to D119839,
which would add a limited IPSCCP into SimplifyCFG.

Unlike lowering switch to lookup, we still want this transformation
to happen relatively early, but after giving a chance for the things
like CVP to do their thing. It seems like deferring it just until
the IPSCCP is enough for the tests at hand, but perhaps we need to
be more aggressive and disable it until CVP.

Fixes https://github.com/llvm/llvm-project/issues/53853
Refs. https://github.com/rust-lang/rust/issues/85133

Reviewed By: nikic

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

2 years ago[mlir] call target materialization more in dialect conversion
Alex Zinenko [Wed, 16 Feb 2022 13:54:54 +0000 (14:54 +0100)]
[mlir] call target materialization more in dialect conversion

During dialect conversion, target materialization is triggered to create
cast-like operations when a type mismatch occurs between the value that
replaces a rewritten operation and the type that another operations expects as
operands processed by the type conversion. First, a dummy cast is inserted to
make sure the pattern application can proceed. The decision to trigger the
user-provided materialization hook is taken later based on the result of the
dummy cast having uses. However, it only has uses if other patterns constructed
new operations using the casted value as operand. If existing (legal)
operations use the replaced value, they may have not been updated to use the
casted value yet. The conversion infra would then delete the dummy cast first,
and then would replace the uses with now-invalid (null in the bast case) value.
When deciding whether to trigger cast materialization, check for liveness the
uses not only of the casted value, but also of all the values that it replaces.

This was discovered in the finalizing bufferize pass that cleans up
mutually-cancelling casts without touching other operations. It is not
impossible that there are other scenarios where the dialect converison infra
could produce invalid operand uses because of dummy casts erased too eagerly.

Reviewed By: springerm

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

2 years ago[clang][dataflow] Add transfer functions for logical and, or, not.
Stanislav Gatev [Wed, 16 Feb 2022 16:47:37 +0000 (16:47 +0000)]
[clang][dataflow] Add transfer functions for logical and, or, not.

This is part of the implementation of the dataflow analysis framework.
See "[RFC] A dataflow analysis framework for Clang AST" on cfe-dev.

Reviewed-by: xazax.hun
Differential Revision: https://reviews.llvm.org/D119953

2 years ago[MLIR][PDL] Fix typo (NFC)
Lorenzo Chelini [Thu, 17 Feb 2022 09:06:16 +0000 (10:06 +0100)]
[MLIR][PDL] Fix typo (NFC)

2 years ago[InstSimplify] Delay creation of constants for offsets (NFC)
Nikita Popov [Thu, 17 Feb 2022 08:54:07 +0000 (09:54 +0100)]
[InstSimplify] Delay creation of constants for offsets (NFC)

Return APInt from stripAndComputeConstantOffsets(), and only
create corresponding Constants later, if we actually need them.

2 years ago[libcxx] [test] Fix locale.time.get.byname get_date and get_date_wide on Windows
Martin Storsjö [Mon, 24 Jan 2022 22:25:41 +0000 (22:25 +0000)]
[libcxx] [test] Fix locale.time.get.byname get_date and get_date_wide on Windows

Also apply the same fix on glibc. This takes the test one step closer
to passing on glibc, but it still fails on the zh_CN test (which
requires a more involved fix in libc++ itself).

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

2 years ago[libcxx] [test] Fix the locale get_one_wide test for windows and glibc
Martin Storsjö [Tue, 25 Jan 2022 10:32:55 +0000 (10:32 +0000)]
[libcxx] [test] Fix the locale get_one_wide test for windows and glibc

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

2 years ago[libcxx] [test] Make the put_long_double test pass on mingw, clarify quirks in put_double
Martin Storsjö [Thu, 20 Jan 2022 09:30:57 +0000 (09:30 +0000)]
[libcxx] [test] Make the put_long_double test pass on mingw, clarify quirks in put_double

Expect the same NAN formatting on Windows as on Glibc. (Both MSVC and
MinGW produce the same formatting there.)

The hex float formatting tests pass on MinGW, so opt in to those tests.

Document exactly what issues are remaining in Clang-cl/MSVC
configurations. (It's easily possible to make the tests pass there too,
but it requires a whole lot of small-scope ifndefs in the test file;
around 60 ifdefs in total for those both test files. Those could
be avoided if the CI environment could run with a newer version
of UCRT, but that's nontrivial to fix right away.)

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

2 years ago[BOLT][NFC] Report errors from createBinaryContext and RewriteInstance ctor
Amir Ayupov [Thu, 17 Feb 2022 04:39:59 +0000 (20:39 -0800)]
[BOLT][NFC] Report errors from createBinaryContext and RewriteInstance ctor

Refactor createBinaryContext and RewriteInstance/MachORewriteInstance
constructors to report an error in a library and fuzzer-friendly way instead of
returning a nullptr or exiting.

Reviewed By: rafauler

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

2 years ago[clang-format] Fix wrong assertion with non-negative shift when aligning tokens.
Marek Kurdej [Thu, 17 Feb 2022 08:45:52 +0000 (09:45 +0100)]
[clang-format] Fix wrong assertion with non-negative shift when aligning tokens.

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

2 years ago[IndVars] Don't run full optimization pipeline in test (NFC)
Nikita Popov [Thu, 17 Feb 2022 08:28:33 +0000 (09:28 +0100)]
[IndVars] Don't run full optimization pipeline in test (NFC)

This extracts the IR prior to IndVarSimplify and only runs the
single pass.

2 years ago[mlir][gpu] Split ops sinking from gpu-kernel-outlining pass into separate pass
Ivan Butygin [Wed, 16 Feb 2022 12:38:14 +0000 (15:38 +0300)]
[mlir][gpu] Split ops sinking from gpu-kernel-outlining pass into separate pass

Previously `gpu-kernel-outlining` pass was also doing index computation sinking into gpu.launch before actual outlining.
Split ops sinking from `gpu-kernel-outlining` pass into separate pass, so users can use theirs own sinking pass before outlining.
To achieve old behavior users will need to call both passes: `-gpu-launch-sink-index-computations -gpu-kernel-outlining`.

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

2 years ago[NFC][compiler-rt] Format file lib/builtins/arm/sync-ops.h
Pavel Kosov [Thu, 17 Feb 2022 07:21:22 +0000 (10:21 +0300)]
[NFC][compiler-rt] Format file lib/builtins/arm/sync-ops.h

2 years ago[compiler-rt] Implement ARM atomic operations for architectures without SMP support
Pavel Kosov [Thu, 17 Feb 2022 07:11:25 +0000 (10:11 +0300)]
[compiler-rt] Implement  ARM atomic operations for architectures without SMP support

ARMv5 and older architectures don’t  support SMP and do not have atomic instructions. Still they’re in use in IoT world, where one has to stick to libgcc.

Reviewed By: mstorsjo

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

2 years ago[flang] add semantics test for sync images
Damian Rouson [Fri, 12 Nov 2021 00:20:30 +0000 (16:20 -0800)]
[flang] add semantics test for sync images

Test a range of acceptable forms of SYNC IMAGES statements,
including combinations with and without the stat-variable
and errmsg-variable present.  Also test that several invalid
forms of SYNC IMAGES call generate the correct error messages.

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

2 years agoissue-release-workflow: Add support for /cherry-pick command in issue body
Tom Stellard [Thu, 17 Feb 2022 06:18:03 +0000 (22:18 -0800)]
issue-release-workflow: Add support for /cherry-pick command in issue body

Reviewed By: kwk

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

2 years ago[mlir] Added oilist primitive
Shraiysh Vaishay [Thu, 17 Feb 2022 04:54:10 +0000 (10:24 +0530)]
[mlir] Added oilist primitive

This patch attempts to add the `oilist` primitive proposed in the [[ https://llvm.discourse.group/t/rfc-extending-declarative-assembly-format-to-support-order-independent-variadic-segments/4388 | RFC: Extending Declarative Assembly Format to support order-independent variadic segments ]].

This element supports optional order-independent variadic segments for operations. This will allow OpenACC and OpenMP Dialects to have similar and relaxed requirements while encouraging the use of Declarative Assembly Format and avoiding code duplication.

An oilist element parses grammar of the form:
```
clause-list := clause clause-list | empty
clause := `keyword` clause1 | `otherKeyword` clause2
clause1 := <assembly-format element>
clause2 := <assembly-format element>
```

AssemblyFormat specification:
```
let assemblyFormat = [{
  oilist( `keyword` clause1
        | `otherkeyword` clause2
        ...
        )
}];
```

Example:
```
oilist( `private` `(` $arg0 `:` type($arg0) `)`
      | `nowait`
      | `reduction` custom<ReductionClause>($arg1, type($arg1)))

oilist( `private` `=` $arg0 `:` type($arg0)
      | `reduction` `=` $arg1 `:` type($arg1)
      | `firstprivate` `=` $arg3 `:` type($arg2))
```

Reviewed By: Mogball, rriddle

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

2 years ago[mlir] NFC Async: always use 'b' for the current builder
Eugene Zhulenev [Thu, 17 Feb 2022 04:35:05 +0000 (20:35 -0800)]
[mlir] NFC Async: always use 'b' for the current builder

Currently some of the nested IR building inconsistently uses `nb` and `b`, it's very easy to call wrong builder outside of the current scope, so for simplicity all builders are always called `b`, and in nested IR building regions they just shadow the "parent" builder.

Reviewed By: mehdi_amini

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

2 years ago[flang] add semantics test for sync all
Damian Rouson [Thu, 11 Nov 2021 19:27:15 +0000 (11:27 -0800)]
[flang] add semantics test for sync all

Test a range of acceptable forms of SYNC ALL statements,
including combinations with and without the stat-variable
and errmsg-variable present.  Also test that several invalid
forms of SYNC ALL call generate the correct error messages.

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

2 years ago[MemoryDependency] Relax the re-ordering of atomic store and unordered load/store
Serguei Katkov [Tue, 15 Feb 2022 11:12:22 +0000 (18:12 +0700)]
[MemoryDependency] Relax the re-ordering of atomic store and unordered load/store

Atomic store with Release semantic allows re-ordering of unordered load/store before the store.
Implement it.

Reviewers: reames
Reviewed By: reames
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D119844

2 years agoOn Windows, the function name contains the return parameter, so
Jim Ingham [Thu, 17 Feb 2022 03:09:01 +0000 (19:09 -0800)]
On Windows, the function name contains the return parameter, so
the test has to be "function name contains the name we used to specify
the breakpoint" not IS the name...

2 years ago[libc] Use '+' constraint on inline assembly
Alex Brachet [Thu, 17 Feb 2022 03:00:17 +0000 (03:00 +0000)]
[libc] Use '+' constraint on inline assembly

As suggested by @mcgrathr in D118099

Reviewed By: lntue

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

2 years agoAdd a test for breaking on overloaded functions by name.
Jim Ingham [Thu, 17 Feb 2022 01:46:53 +0000 (17:46 -0800)]
Add a test for breaking on overloaded functions by name.

2 years ago[flang] Allow tabs as white space in formats
V Donaldson [Wed, 16 Feb 2022 23:26:50 +0000 (15:26 -0800)]
[flang] Allow tabs as white space in formats

The fortran standard views blanks in IO formats as white space in
non-string contexts.  Other compilers extend this to also view horizontal
tabs as white space.  Some compilers additionally add other white space
characters to this group.

Add recognition of horizontal and vertical tabs to runtime format
validation code to match what the runtime code currently does.

2 years ago[mlir][sparse] avoid some codeup in sparsification transformation
Aart Bik [Thu, 17 Feb 2022 00:30:46 +0000 (16:30 -0800)]
[mlir][sparse] avoid some codeup in sparsification transformation

A very small refactoring, but a big impact on tests that expect an exact order.
This revision fixes the tests, but also makes them less brittle for similar
minor changes in the future!

Reviewed By: bixia

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

2 years ago[AArch64][GlobalISel] Implement support for clang.arc.attachedcall call operand bundles.
Amara Emerson [Wed, 16 Feb 2022 23:06:07 +0000 (15:06 -0800)]
[AArch64][GlobalISel] Implement support for clang.arc.attachedcall call operand bundles.

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

2 years ago[BPF] Fix a BTF type pruning bug
Yonghong Song [Wed, 16 Feb 2022 19:54:38 +0000 (11:54 -0800)]
[BPF] Fix a BTF type pruning bug

In BPF backend, BTF type generation may skip
some debuginfo types if they are the pointee
type of a struct member. For example,
  struct task_struct {
    ...
    struct mm_struct                *mm;
    ...
  };
BPF backend may generate a forward decl for
'struct mm_struct' instead of full type if
there are no other usage of 'struct mm_struct'.
The reason is to avoid bringing too much unneeded types
in BTF.

Alexei found a pruning bug where we may miss
some full type generation. The following is an illustrating
example:
   struct t1 { ... }
   struct t2 { struct t1 *p; };
   struct t2 g;
   void foo(struct t1 *arg) { ... }
In the above case, we will have partial debuginfo chain like below:
   struct t2 -> member p
                        \ -> ptr -> struct t1
                        /
     foo -> argument arg
During traversing
   struct t2 -> member p -> ptr -> struct t1
The corresponding BTF types are generated except 'struct t1' which
will be in FixUp stage. Later, when traversing
   foo -> argument arg -> ptr -> struct t1
The 'ptr' BTF type has been generated and currently implementation
ignores 'pointer' type hence 'struct t1' is not generated.

This patch fixed the issue not just for the above case, but for
general case with multiple derived types, e.g.,
   struct t2 -> member p
                        \ -> const -> ptr -> volatile -> struct t1
                        /
     foo -> argument arg

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

2 years ago[bazel] Add libc dependency.
Alina Sbirlea [Thu, 17 Feb 2022 00:28:05 +0000 (16:28 -0800)]
[bazel] Add libc dependency.

2 years ago[lld-macho] Don't include CommandFlags.h in CommonLinkerContext.h
Jez Ng [Thu, 17 Feb 2022 01:03:57 +0000 (20:03 -0500)]
[lld-macho] Don't include CommandFlags.h in CommonLinkerContext.h

Main motivation: including `llvm/CodeGen/CommandFlags.h` in
`CommonLinkerContext.h` means that the declaration of `llvm::Reloc` is
visible in any file that includes `CommonLinkerContext.h`. Since our
cpp files have both `using namespace llvm` and `using namespace
lld::macho`, this results in conflicts with `lld::macho::Reloc`.

I suppose we could put `llvm::Reloc` into a nested namespace, but in general,
I think we should avoid transitively including too many header files in
a very widely used header like `CommonLinkerContext.h`.

RegisterCodeGenFlags' ctor initializes a bunch of function-`static`
structures and does nothing else, so it should be fine to "initialize"
it as a temporary stack variable rather than as a file static.

Reviewed By: aganea

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

2 years ago[RewriteStatepointsForGC] Add a test exposing an incorrect assertion
Daniil Suchkov [Tue, 15 Feb 2022 23:46:21 +0000 (23:46 +0000)]
[RewriteStatepointsForGC] Add a test exposing an incorrect assertion

2 years ago[WebAssembly] Make __wasm_lpad_context thread-local
Heejin Ahn [Mon, 14 Feb 2022 23:13:07 +0000 (15:13 -0800)]
[WebAssembly] Make __wasm_lpad_context thread-local

This makes `__wasm_lpad_context`, a struct that is used as a
communication channel between compiler-generated code and personality
function in libunwind, thread local. The library code will be changed to
thread local in the emscripten side.

Reviewed By: sbc100, tlively

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

2 years agoAMDGPU: Always reserve VGPR for AGPR copies on gfx908
Matt Arsenault [Mon, 14 Feb 2022 22:22:55 +0000 (17:22 -0500)]
AMDGPU: Always reserve VGPR for AGPR copies on gfx908

Just because there aren't AGPRs in the original program doesn't mean
the register allocator can't choose to use them (unless we were to
forcibly reserve all AGPRs if there weren't any uses). This happens in
high pressure situations and introduces copies to avoid spills.

In this test, the allocator ends up introducing a copy from SGPR to
AGPR which requires an intermediate VGPR. I don't believe it would
introduce a copy from AGPR to AGPR in this situation, since it would
be trying to use an intermediate with a different class.

Theoretically this is also broken on gfx90a, but I have been unable to
come up with a testcase.

2 years ago[mlir][doc] Add passes docs to Passes.md
Jacques Pienaar [Wed, 16 Feb 2022 23:42:20 +0000 (15:42 -0800)]
[mlir][doc] Add passes docs to Passes.md

2 years ago[NFC] [MTE] [HWASan] Remove unnecessary member of AllocaInfo
Florian Mayer [Tue, 15 Feb 2022 20:02:35 +0000 (12:02 -0800)]
[NFC] [MTE] [HWASan] Remove unnecessary member of AllocaInfo

Reviewed By: eugenis

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

2 years ago[AMDGPU] Add agpr_count to metadata and AsmParser
Jacob Lambert [Wed, 2 Feb 2022 03:40:11 +0000 (19:40 -0800)]
[AMDGPU] Add agpr_count to metadata and AsmParser

gfx90a allows the number of ACC registers (AGPRs) to be set
independently to the VGPR registers. For both HSA and PAL metadata, we
now include an "agpr_count" key to report the number of AGPRs set for
supported devices (gfx90a, gfx908, as determined by hasMAIInsts()).
This is collected from SIProgramInfo.NumAccVGPR for both HSA and PAL.
The AsmParser also now recognizes ".kernel.agpr_count" for supported
devices.

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

2 years ago[libc++] Remove a few unneeded _LIBCPP_CXX03_LANG ifdefs
Nikolas Klauser [Wed, 16 Feb 2022 17:55:43 +0000 (18:55 +0100)]
[libc++] Remove a few unneeded _LIBCPP_CXX03_LANG ifdefs

Reviewed By: Quuxplusone, ldionne, #libc

Spies: libcxx-commits

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

2 years ago[SLPVectorizer][OpaquePtrs] Check GEP source element type
Arthur Eubanks [Wed, 16 Feb 2022 22:30:51 +0000 (14:30 -0800)]
[SLPVectorizer][OpaquePtrs] Check GEP source element type

Fixes a miscompile with opaque pointers.

Reviewed By: #opaque-pointers, nikic

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

2 years ago[test][SLPVectorizer][OpaquePtr] Precommit test
Arthur Eubanks [Wed, 16 Feb 2022 22:26:58 +0000 (14:26 -0800)]
[test][SLPVectorizer][OpaquePtr] Precommit test

2 years ago[mlir] Async: create async.group inside the scf.if branch
Eugene Zhulenev [Wed, 16 Feb 2022 18:40:28 +0000 (10:40 -0800)]
[mlir] Async: create async.group inside the scf.if branch

Reviewed By: cota

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

2 years ago[lld][WebAssembly] Apply global relocs before data relocs
Sam Clegg [Sun, 13 Feb 2022 16:00:42 +0000 (08:00 -0800)]
[lld][WebAssembly] Apply global relocs before data relocs

Since the code for apply data relocations can sometimes use
the values stored in he globals, they need to be relocated
before the data relocations can be run.

Fixes: https://github.com/emscripten-core/emscripten/issues/13398

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

2 years ago[clang-format] Make checking for a record more robust and avoid a loop.
Marek Kurdej [Wed, 16 Feb 2022 22:05:34 +0000 (23:05 +0100)]
[clang-format] Make checking for a record more robust and avoid a loop.

2 years ago[Attributor][FIX] Heap2Stack needs to use the alloca AS
Johannes Doerfert [Tue, 15 Feb 2022 00:32:00 +0000 (18:32 -0600)]
[Attributor][FIX] Heap2Stack needs to use the alloca AS

When we move an allocation from the heap to the stack we need to
allocate it in the alloca AS and then cast the result. This also
prevents us from inserting the alloca after the allocation call but
rather right before.

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

2 years ago[Attributor][FIX] Use liveness information of the right function
Johannes Doerfert [Fri, 4 Feb 2022 09:17:20 +0000 (03:17 -0600)]
[Attributor][FIX] Use liveness information of the right function

When we use liveness for edges during the `genericValueTraversal` we
need to make sure to use the AAIsDead of the correct function. This
patch adds the proper logic and some simple caching scheme. We also
add an assertion to the `isEdgeDead` call to make sure future misuse
is detected earlier.

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

2 years ago[clang-format] Mark FormatToken::getPreviousNonComment() nodiscard. NFC.
Marek Kurdej [Wed, 16 Feb 2022 21:55:09 +0000 (22:55 +0100)]
[clang-format] Mark FormatToken::getPreviousNonComment() nodiscard. NFC.

2 years agotry to fix check-llvm after c5fb05f663f
Nico Weber [Wed, 16 Feb 2022 21:47:26 +0000 (16:47 -0500)]
try to fix check-llvm after c5fb05f663f

llvm-config wants all libraries referenced in
llvm/lib/CMakeLists.txt to exist on disk.

But WindowsDriver is only referenced in clang and lld and hence
wasn't built as a dependency of check-llvm.

Add it as an explicit dependency to make llvm-config happy.

2 years ago[lldb/test] Disable scripted_crashlog_json.test on non darwin aarch64 systems
Med Ismail Bennani [Wed, 16 Feb 2022 21:49:48 +0000 (13:49 -0800)]
[lldb/test] Disable scripted_crashlog_json.test on non darwin aarch64 systems

This patch adds requirement for the `scripted_crashlog_json` test to
make sure it only runs on apple silicon systems.

This should fix the following green dragon failure:
https://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/41454

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2 years ago[flang] Add Win32 to the list of supported triples
Andrzej Warzynski [Wed, 9 Feb 2022 14:19:22 +0000 (14:19 +0000)]
[flang] Add Win32 to the list of supported triples

This patch adds Win32 to the list of supported triples in
`fir::CodeGenSpecifics`. This change means that we can use the "native"
triple, even when running tests on Windows. Currently this affects only
1 test, but it will change once we start adding more tests for lowering
and code-generation.

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

2 years ago[OpenMP] Pass AMDGPU math libraries into the linker wrapper
Joseph Huber [Tue, 15 Feb 2022 14:57:54 +0000 (09:57 -0500)]
[OpenMP] Pass AMDGPU math libraries into the linker wrapper

This patch passes in the AMDPGU math libraries to the linker wrapper.
The wrapper already handles linking OpenMP bitcode libraries via the
`--target-library` option. This should be sufficient to link in math
libraries for the accompanying architecture.

Fixes #53526.

Reviewed By: jdoerfert

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

2 years ago[OpenMP] Properly save strings when doing LTO
Joseph Huber [Wed, 16 Feb 2022 21:30:45 +0000 (16:30 -0500)]
[OpenMP] Properly save strings when doing LTO

Summary:
We were not previously saving strings when saving symbol names during
LTO symbol resolution. This caused a crash inside the dense set when
some of the strings would rarely be moved internally by the object file
class.

2 years ago[clang-format] Fix formatting of struct-like records followed by variable declaration.
Marek Kurdej [Mon, 14 Feb 2022 21:25:36 +0000 (22:25 +0100)]
[clang-format] Fix formatting of struct-like records followed by variable declaration.

Fixes https://github.com/llvm/llvm-project/issues/24781.
Fixes https://github.com/llvm/llvm-project/issues/38160.

This patch splits `TT_RecordLBrace` for classes/enums/structs/unions (and other records, e.g. interfaces) and uses the brace type to avoid the error-prone scanning for record token.

The mentioned bugs were provoked by the scanning being too limited (and so not considering `const` or `constexpr`, or other qualifiers, on an anonymous struct variable declaration).

Moreover, the proposed solution is more efficient as we parse tokens once only (scanning being parsing too).

Reviewed By: MyDeveloperDay, HazardyKnusperkeks

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

2 years ago[NFC] Fix order in global_symbols.txt.
Florian Mayer [Wed, 16 Feb 2022 21:34:02 +0000 (13:34 -0800)]
[NFC] Fix order in global_symbols.txt.

I added posix_madvise out of order before.

2 years ago[libc++] Refactor the Apple build scripts
Louis Dionne [Thu, 3 Feb 2022 15:57:49 +0000 (10:57 -0500)]
[libc++] Refactor the Apple build scripts

This patch upstreams some changes we've made internally to how we're
building the libc++ dylib on Apple platforms. The goal is still to
eventually get rid of `apple-install-libcxx.sh` entirely and have a
proper way to mirror what we do internally with just the normal CMake
configuration.

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

2 years ago[libc++abi] Bump the libc++abi version and add it to the post-release list
Louis Dionne [Wed, 16 Feb 2022 15:44:39 +0000 (10:44 -0500)]
[libc++abi] Bump the libc++abi version and add it to the post-release list

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

2 years ago[NFC][PhaseOrdering] spurious-peeling.ll: also test -O1/-O2 results
Roman Lebedev [Wed, 16 Feb 2022 20:39:26 +0000 (23:39 +0300)]
[NFC][PhaseOrdering] spurious-peeling.ll: also test -O1/-O2 results

2 years ago[NFC][PhaseOrdering] Precommit tests from D119965
William S. Moses [Wed, 16 Feb 2022 20:29:42 +0000 (23:29 +0300)]
[NFC][PhaseOrdering] Precommit tests from D119965

2 years agoUse functions with prototypes when appropriate; NFC
Aaron Ballman [Wed, 16 Feb 2022 21:09:36 +0000 (16:09 -0500)]
Use functions with prototypes when appropriate; NFC

A significant number of our tests in C accidentally use functions
without prototypes. This patch converts the function signatures to have
a prototype for the situations where the test is not specific to K&R C
declarations. e.g.,

  void func();

becomes

  void func(void);

This is the twelfth batch of tests being updated (the end may be in
sight soon though).