platform/upstream/llvm.git
3 years agoAdd AddDiscriminatorsPass to NPM default O0 pipeline
Yuanfang Chen [Thu, 8 Jul 2021 19:20:57 +0000 (12:20 -0700)]
Add AddDiscriminatorsPass to NPM default O0 pipeline

AddDiscriminatorsPass is in Legacy PM's O0 pipeline. This patch did the same
for NPM O0 pipeline.

Reviewed By: aeubanks, MaskRay

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

3 years ago[mlir][sparse] Add Merger unit tests
Gus Smith [Thu, 8 Jul 2021 22:43:59 +0000 (22:43 +0000)]
[mlir][sparse] Add Merger unit tests

We opt to use unit tests rather than check tests as the lattice/merger code is a small C++ component with a well-defined API. Testing this API via check tests would be far less direct and readable. In addition, as the check tests will only be able to test the API indirectly, the tests may break based on unrelated changes; e.g. changes in linalg.

Reviewed By: aartbik

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

3 years ago[AMDGPU] Mark more SOP instructions as rematerializable
Stanislav Mekhanoshin [Thu, 8 Jul 2021 22:15:47 +0000 (15:15 -0700)]
[AMDGPU] Mark more SOP instructions as rematerializable

The rest of the SOP instructions implicitly set SCC and not
suitable for the rematerialization.

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

3 years ago[ARM] Pass 2 instead of 0 to PHINode::Create in MVEGatherScatterLowering. NFC
Craig Topper [Thu, 8 Jul 2021 21:59:54 +0000 (14:59 -0700)]
[ARM] Pass 2 instead of 0 to PHINode::Create in MVEGatherScatterLowering. NFC

This parameter controls how much space is reserved for incoming
values. There are always going to be 2 incoming values in this case.

While there remove the unused std::vector right below.

Found while looking at porting this code to RISCV.

3 years agoMark TensorDialect legal and PadTensor op illegal
Yi Zhang [Thu, 8 Jul 2021 20:43:04 +0000 (13:43 -0700)]
Mark TensorDialect legal and PadTensor op illegal

`GeneralizePadTensorOpPattern` might generate `tensor.dim` op so the
TensorDialect should be marked legal. This pattern should also
transform all `linalg.pad_tensor` ops so mark those as illegal. Those
changes are missed from a previous change in
https://reviews.llvm.org/D105293

Reviewed By: silvas

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

3 years ago[WebAssembly] Scalarize extract_vector_elt of binops
Thomas Lively [Thu, 8 Jul 2021 21:31:53 +0000 (14:31 -0700)]
[WebAssembly] Scalarize extract_vector_elt of binops

Override the `shouldScalarizeBinop` target lowering hook using the same
implementation used in the x86 backend. This causes `extract_vector_elt`s of
vector binary ops to be scalarized if the scalarized version would be supported.

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

3 years ago[ARM] Extra v8i16 -> i64 reduction tests with loads. NFC
David Green [Thu, 8 Jul 2021 21:27:23 +0000 (22:27 +0100)]
[ARM] Extra v8i16 -> i64 reduction tests with loads. NFC

3 years ago[InstCombine][NFC]Use only `replaceInstUsesWith`, NFC.
Alexey Bataev [Thu, 8 Jul 2021 20:45:03 +0000 (13:45 -0700)]
[InstCombine][NFC]Use only `replaceInstUsesWith`, NFC.

3 years ago[mlir][bazel] Added missing MathDialect dep to LinalgOps target
Rob Suderman [Thu, 8 Jul 2021 20:25:46 +0000 (13:25 -0700)]
[mlir][bazel] Added missing MathDialect dep to LinalgOps target

LinalgOps needs MathDialect as a dependency for it to build correctly.

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

3 years agoRevert "PR51018: Disallow explicit construction of StringRef from SmallString due...
David Blaikie [Thu, 8 Jul 2021 20:46:36 +0000 (13:46 -0700)]
Revert "PR51018: Disallow explicit construction of StringRef from SmallString due to ambiguity in C++23"

This reverts commit e2d30846327c7ec5cc9d2a46aa9bcd9c2c4eff93.

MSVC doesn't seem to resolve the intended ambiguity in implicit
conversion contexts correctly: https://godbolt.org/z/ee16aqv4v

3 years agoPR51018: Disallow explicit construction of StringRef from SmallString due to ambiguit...
David Blaikie [Thu, 8 Jul 2021 20:26:40 +0000 (13:26 -0700)]
PR51018: Disallow explicit construction of StringRef from SmallString due to ambiguity in C++23

See bug for full details, but basically there's an upcoming ambiguity in
the conversion in `StringRef(SomeSmallString)` - either the implicit
conversion operator (SmallString::operator StringRef) could be used, or
the std::string_view range-based ctor (& then `StringRef(std::string_view)`
would be used)

To address this, make such a conversion invalid up-front - most uses are
more tersely written as `SomeSmallString.str()` anyway, or more clearly
written as `StringRef x = y;` rather than `StringRef x(y);` - so if you
hit this in out-of-tree code, please update in one of those ways.
Hopefully I've fixed everything in tree prior to this patch landing.

3 years agoPR51018: Remove explicit conversions from SmallString to StringRef to future-proof...
David Blaikie [Thu, 8 Jul 2021 20:30:14 +0000 (13:30 -0700)]
PR51018: Remove explicit conversions from SmallString to StringRef to future-proof against C++23

C++23 will make these conversions ambiguous - so fix them to make the
codebase forward-compatible with C++23 (& a follow-up change I've made
will make this ambiguous/invalid even in <C++23 so we don't regress
this & it generally improves the code anyway)

3 years ago[NFC][compiler-rt][fuchsia] Add InitShadowBounds declaration to header
Leonard Chan [Thu, 8 Jul 2021 20:19:17 +0000 (13:19 -0700)]
[NFC][compiler-rt][fuchsia] Add InitShadowBounds declaration to header

Forgot to include this as a part of
a11aea68a4b31e72bc0b84bde5f3210048287d28.

3 years ago[GWP-ASan] Change unreachable -> trap to work around DCE bug.
Mitch Phillips [Thu, 8 Jul 2021 20:06:34 +0000 (13:06 -0700)]
[GWP-ASan] Change unreachable -> trap to work around DCE bug.

trapOnAddress is designed to SEGV on a specific address. Unfortunately,
with an IR change, __builtin_unreachable() ends up doing DCE on things
that have side effects, like the load that causes the trap.

Change to __builtin_trap() to avoid the optimisation.

Root cause is still an LLVM bug, and tracked in
https://bugs.llvm.org/show_bug.cgi?id=47480.

Reviewed By: eugenis

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

3 years ago[msan] Handle funnel shifts
Vitaly Buka [Sat, 3 Jul 2021 02:13:03 +0000 (19:13 -0700)]
[msan] Handle funnel shifts

Fixes https://bugs.llvm.org/show_bug.cgi?id=50840

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

3 years ago[msan] Add funel shift tests
Vitaly Buka [Sat, 3 Jul 2021 01:19:23 +0000 (18:19 -0700)]
[msan] Add funel shift tests

For https://bugs.llvm.org/show_bug.cgi?id=50840

3 years ago[SLP]Improve vectorization of stores.
Alexey Bataev [Fri, 11 Jun 2021 13:02:47 +0000 (06:02 -0700)]
[SLP]Improve vectorization of stores.

Patch tries to improve the vectorization of stores. Originally, we just
check the type and the base pointer of the store.
Patch adds some extra checks to avoid non-profitable vectorization
cases. It includes analysis of the scalar values to be stored and
triggers the vectorization attempt only if the scalar values have
same/alt opcode and are from same basic block, i.e. we don't end up
immediately with the gather node, which is not profitable.
This also improves compile time by filtering out non-profitable cases.

Part of D57059.

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

3 years ago[CodeGen] Avoid nullptr arg to CreateStructGEP (NFC)
Nikita Popov [Thu, 8 Jul 2021 19:20:17 +0000 (21:20 +0200)]
[CodeGen] Avoid nullptr arg to CreateStructGEP (NFC)

For now just make the getPointerElementType() explicit.

3 years ago[AMDGPU] Simplify GEP construction (NFC)
Nikita Popov [Thu, 8 Jul 2021 19:13:52 +0000 (21:13 +0200)]
[AMDGPU] Simplify GEP construction (NFC)

Noticed while making a related change. This code was doing
something really peculiar: Creating an APInt by parsing a string.
And then creating a SmallVector with one element to create the
GEP.

Instead create the APInt from integers and directly pass the single
index to GetElementPtrInst::Create().

3 years ago[AMDGPU] Pass explicit GEP type in printf transform (NFC)
Nikita Popov [Thu, 8 Jul 2021 19:10:03 +0000 (21:10 +0200)]
[AMDGPU] Pass explicit GEP type in printf transform (NFC)

This code is working on an i8*. Avoid nullptr element type in
preparation for removing support.

3 years ago[NVPTX] Pass explicit GEP type (NFC)
Nikita Popov [Thu, 8 Jul 2021 18:59:56 +0000 (20:59 +0200)]
[NVPTX] Pass explicit GEP type (NFC)

Use source element type of original GEP, as we're just changing
the address space.

3 years ago[OPENMP]Do no privatize const firstprivates in target regions.
Alexey Bataev [Thu, 8 Jul 2021 17:58:10 +0000 (10:58 -0700)]
[OPENMP]Do no privatize const firstprivates in target regions.

No need to emit private copyfor firstprivate constants in target
regions, we can use the original copy instead.

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

3 years ago[SLP][COST][X86]Improve cost model for masked gather.
Alexey Bataev [Mon, 28 Jun 2021 15:56:08 +0000 (08:56 -0700)]
[SLP][COST][X86]Improve cost model for masked gather.

Revived D101297 in its original form + added some changes in X86
legalization cehcking for masked gathers.

This solution is the most stable and the most correct one. We have to
check the legality before trying to build the masked gather in SLP.
Without this check we have incorrect cost (for SLP) in case if the masked gather
is not legal/slower than the gather. And we're missing some
vectorization opportunities.

This can be fixed in the cost model, but in this case we need to add
special checks for the cost of GEPs for ScatterVectorize node, add
special check for small trees, etc., i.e. there are a lot of corner
cases here and there, which insrease code base and make it harder to
maintain the code.

> Can't we rely on cost model to deal with this? This can be profitable for futher vectorization, when we can start from such gather loads as seed.

The question from D101297. Actually, no, it can't. Actually, simple
gather may give us better result, especially after we started
vectorization of insertelements. Plus, like I said before, the cost for
non-legal masked gathers leads to missed vectorization opportunities.

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

3 years ago[ARM] Use matchSimpleRecurrence to simplify some code in MVEGatherScatterLowering...
Craig Topper [Thu, 8 Jul 2021 18:42:53 +0000 (11:42 -0700)]
[ARM] Use matchSimpleRecurrence to simplify some code in MVEGatherScatterLowering. NFCI

Reviewed By: dmgreen

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

3 years ago[libc++] Add XFAIL for Clang ToT with modules
Louis Dionne [Thu, 8 Jul 2021 18:39:15 +0000 (14:39 -0400)]
[libc++] Add XFAIL for Clang ToT with modules

This is what I should have done instead of 6afd6e96ce20.

3 years ago[CodeGen] Avoid CreateGEP with nullptr type (NFC)
Nikita Popov [Thu, 8 Jul 2021 18:33:37 +0000 (20:33 +0200)]
[CodeGen] Avoid CreateGEP with nullptr type (NFC)

In preparation for dropping support for it. I've replaced it with
a proper type where the correct type was obvious and left an
explicit getPointerElementType() where it wasn't.

3 years ago[X86][NFC]Add run lines for AVX512VL for masked gather test, NFC.
Alexey Bataev [Thu, 8 Jul 2021 18:29:40 +0000 (11:29 -0700)]
[X86][NFC]Add run lines for AVX512VL for masked gather test, NFC.

3 years ago[clang] fix constexpr code generation for user conversions.
Matheus Izvekov [Mon, 5 Jul 2021 22:24:43 +0000 (00:24 +0200)]
[clang] fix constexpr code generation for user conversions.

When building the member call to a user conversion function during an
implicit cast, the expression was not being checked for immediate
invocation, so we were never adding the ConstantExpr node to AST.

This would cause the call to the user conversion operator to be emitted
even if it was constantexpr evaluated, and this would even trip an
assert when said user conversion was declared consteval:
`Assertion failed: !cast<FunctionDecl>(GD.getDecl())->isConsteval() && "consteval function should never be emitted", file clang\lib\CodeGen\CodeGenModule.cpp, line 3530`

Fixes PR48855.

Signed-off-by: Matheus Izvekov <mizvekov@gmail.com>
Reviewed By: rsmith

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

3 years ago[AMDGPU] Fix more indention in llc-pipeline test. NFC.
Stanislav Mekhanoshin [Thu, 8 Jul 2021 18:13:43 +0000 (11:13 -0700)]
[AMDGPU] Fix more indention in llc-pipeline test. NFC.

3 years ago[libc++][ci] Install Clang 11, Clang 12 and Clang ToT in the Docker image
Louis Dionne [Thu, 8 Jul 2021 16:19:53 +0000 (12:19 -0400)]
[libc++][ci] Install Clang 11, Clang 12 and Clang ToT in the Docker image

The compiler support policy mentions that we support Clang 11 and 12, so
we should test those. We already test on Clang 12, but I'll add testers
for Clang 11 once the new Docker image is in use on all the builders.

3 years ago[mlir][Linalg] Fix tensor.extract_slice(linalg.init_tensor) canonicalization for...
Nicolas Vasilache [Thu, 8 Jul 2021 14:26:57 +0000 (14:26 +0000)]
[mlir][Linalg] Fix tensor.extract_slice(linalg.init_tensor) canonicalization for rank-reducing extract

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

3 years ago[Metadata] Decorate methods with 'const'. NFC.
Michael Liao [Thu, 8 Jul 2021 18:05:54 +0000 (14:05 -0400)]
[Metadata] Decorate methods with 'const'. NFC.

- Minor coding style fix.

3 years ago[AMDGPU] Fix indention in llc-pipeline test. NFC.
Stanislav Mekhanoshin [Thu, 8 Jul 2021 18:08:25 +0000 (11:08 -0700)]
[AMDGPU] Fix indention in llc-pipeline test. NFC.

3 years agoMips/GlobalISel: Remove custom splitToValueTypes
Matt Arsenault [Thu, 8 Jul 2021 15:32:57 +0000 (11:32 -0400)]
Mips/GlobalISel: Remove custom splitToValueTypes

3 years agoGlobalISel: Track original argument index in ArgInfo
Matt Arsenault [Thu, 8 Jul 2021 15:26:30 +0000 (11:26 -0400)]
GlobalISel: Track original argument index in ArgInfo

SelectionDAG's equivalents in ISD::InputArg/OutputArg track the
original argument index. Mips relies on this, and its currently
reinventing its own parallel CallLowering infrastructure which tracks
these indexes on the side. Add this to help move towards deleting the
custom mips handling.

3 years agoMips/GlobalISel: Use correct callee calling convention
Matt Arsenault [Wed, 7 Jul 2021 22:28:57 +0000 (18:28 -0400)]
Mips/GlobalISel: Use correct callee calling convention

This was using the convention from the calling function.

3 years ago[LangRef] Fix typo about SHF_LINK_ORDER
Fangrui Song [Thu, 8 Jul 2021 17:29:43 +0000 (10:29 -0700)]
[LangRef] Fix typo about SHF_LINK_ORDER

3 years ago[compiler-rt][hwasan] Define fuchsia implementations of required hwasan functions
Leonard Chan [Wed, 9 Jun 2021 19:38:08 +0000 (12:38 -0700)]
[compiler-rt][hwasan] Define fuchsia implementations of required hwasan functions

This contains all the definitions required by hwasan for the fuchsia
implementation and can be landed independently from the remaining parts of D91466.

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

3 years ago[ScalarEvolution] Fix overflow in computeBECount.
Eli Friedman [Tue, 29 Jun 2021 22:22:13 +0000 (15:22 -0700)]
[ScalarEvolution] Fix overflow in computeBECount.

There are two issues with the current implementation of computeBECount:

1. It doesn't account for the possibility that adding "Stride - 1" to
Delta might overflow. For almost all loops, it doesn't, but it's not
actually proven anywhere.
2. It doesn't account for the possibility that Stride is zero. If Delta
is zero, the backedge is never taken; the value of Stride isn't
relevant. To handle this, we have to make sure that the expression
returned by computeBECount evaluates to zero.

To deal with this, add two new checks:

1. Use a variety of tricks to try to prove that the addition doesn't
overflow.  If the proof is impossible, use an alternate sequence which
never overflows.
2. Use umax(Stride, 1) to handle the possibility that Stride is zero.

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

3 years agoFix MSVC "truncation from 'int' to 'bool'" warning. NFCI.
Simon Pilgrim [Thu, 8 Jul 2021 16:51:32 +0000 (17:51 +0100)]
Fix MSVC "truncation from 'int' to 'bool'" warning. NFCI.

3 years ago[CostModel][X86] Account for older SSE targets with slow fp->int conversions
Simon Pilgrim [Thu, 8 Jul 2021 16:21:08 +0000 (17:21 +0100)]
[CostModel][X86] Account for older SSE targets with slow fp->int conversions

Both the conversion cost and the xmm->gpr transfer cost tend to be a lot higher on early SSE targets

3 years ago[LangRef] Clarify !associated
Fangrui Song [Thu, 8 Jul 2021 17:07:10 +0000 (10:07 -0700)]
[LangRef] Clarify !associated

Notably, a global variable with the metadata should generally not be referenced
by a function function. E.g. -fstack-size-section usage is fine, but
-fsanitize-coverage= used to have a linker GC problem (fixed by D97430).

Reviewed By: eugenis

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

3 years ago[mlir][sparse] updated setter/getter comments
Aart Bik [Wed, 7 Jul 2021 23:09:22 +0000 (16:09 -0700)]
[mlir][sparse] updated setter/getter comments

For the getters, it is bad practice to keep the reference
around for too long, as explained in the new comment

Reviewed By: gussmith23

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

3 years ago[AMDGPU] Set LoopInfo as preserved by SIAnnotateControlFlow
Stanislav Mekhanoshin [Wed, 7 Jul 2021 19:28:30 +0000 (12:28 -0700)]
[AMDGPU] Set LoopInfo as preserved by SIAnnotateControlFlow

The pass does not change loops, it just adds calls.

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

3 years ago[libc++][ci] Stop testing on GCC previous, since we don't support it anymore
Louis Dionne [Thu, 8 Jul 2021 16:14:31 +0000 (12:14 -0400)]
[libc++][ci] Stop testing on GCC previous, since we don't support it anymore

This is the first of a few commits that update the CI to match the
recently officialized compiler support policy. I'm staging those
changes to try and keep the CI green at all times, accounting how
builders refresh their Docker image.

3 years ago[IR] Restore vector support for deprecated CreateGEP methods
Nikita Popov [Thu, 8 Jul 2021 15:49:56 +0000 (17:49 +0200)]
[IR] Restore vector support for deprecated CreateGEP methods

As pointed out in post-commit review on rG8e22539067d9, it's
necessary to call getScalarType() to support GEPs with a vector
base. Dropping that call was an oversight on my side.

3 years ago[libc++][docs] Update documentation to reflect libc++'s compiler support policy
Louis Dionne [Tue, 6 Jul 2021 19:47:29 +0000 (15:47 -0400)]
[libc++][docs] Update documentation to reflect libc++'s compiler support policy

In https://lists.llvm.org/pipermail/llvm-dev/2021-March/148881.html, we
discussed updating the compiler support policy for libc++ to match more
closely what we do actually support.

This commit enshrines that policy decision in libc++'s documentation.

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

3 years ago[libc++] Workaround failures with modules on Clang ToT
Louis Dionne [Thu, 8 Jul 2021 15:11:07 +0000 (11:11 -0400)]
[libc++] Workaround failures with modules on Clang ToT

3 years ago[DebugInfo][InstrRef][4/4] Support DBG_INSTR_REF through all backend passes
Jeremy Morse [Wed, 2 Jun 2021 14:58:03 +0000 (15:58 +0100)]
[DebugInfo][InstrRef][4/4] Support DBG_INSTR_REF through all backend passes

This is a cleanup patch -- we're now able to support all flavours of
variable location in instruction referencing mode. This patch updates
various tests for debug instructions to be broader: numerous code paths
try to ignore debug isntructions, and they now have to ignore the
additional DBG_PHI and DBG_INSTR_REFs that we can generate.

A small amount of rework happens for LiveDebugVariables: as we don't need
to track live intervals through regalloc any more, we can get away with
unlinking debug instructions before regalloc, then re-inserting them after.
Note that this isn't (yet) true of DBG_VALUE_LISTs, they still have to go
through live interval tracking.

In SelectionDAG, add a helper lambda that emits half-formed DBG_INSTR_REFs
for arguments in instr-ref mode, DBG_VALUE otherwise. This is one of the
final locations where DBG_VALUEs are emitted for vreg arguments.

X86InstrInfo now un-sets the debug instr number on SUB instructions that
get mutated into CMP instructions. As the instruction no longer computes a
subtraction, we can't use it for variable locations.

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

3 years ago[gn build] Port 321c2ea91cb1
LLVM GN Syncbot [Thu, 8 Jul 2021 15:35:54 +0000 (15:35 +0000)]
[gn build] Port 321c2ea91cb1

3 years ago[libc++][NFC] Move monostate to its own header.
Mark de Wever [Wed, 7 Jul 2021 19:27:27 +0000 (21:27 +0200)]
[libc++][NFC] Move monostate to its own header.

The format library uses `std::monostate`, but not a `std::variant`.
Moving `std::monostate` to its own header allows the format library to
reduce the amount of included code.

Reviewed By: #libc, ldionne

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

3 years ago[libc++] Guard testing implementation details.
Mark de Wever [Wed, 7 Jul 2021 18:22:19 +0000 (20:22 +0200)]
[libc++] Guard testing implementation details.

The unit tests test some implementation details. As @Quuxplusone pointed
out in D96664 this should only be tested when the tests use libc++. This
addresses the issue for code already in main.

Reviewed By: #libc, ldionne

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

3 years agoRecommit: Support: add llvm::thread class that supports specifying stack size.
Tim Northover [Wed, 26 May 2021 10:25:11 +0000 (11:25 +0100)]
Recommit: Support: add llvm::thread class that supports specifying stack size.

This adds a new llvm::thread class with the same interface as std::thread
except there is an extra constructor that allows us to set the new thread's
stack size. On Darwin even the default size is boosted to 8MB to match the main
thread.

It also switches all users of the older C-style `llvm_execute_on_thread` API
family over to `llvm::thread` followed by either a `detach` or `join` call and
removes the old API.

Moved definition of DefaultStackSize into the .cpp file to hopefully
fix the build on some (GCC-6?) machines.

3 years ago[Instcombine]Transform reduction+(sext/zext(<n x i1>) to <n x im>) to [-]zext/trunc...
Alexey Bataev [Wed, 7 Jul 2021 20:02:54 +0000 (13:02 -0700)]
[Instcombine]Transform reduction+(sext/zext(<n x i1>) to <n x im>) to [-]zext/trunc(ctpop(bitcast <n x i1> to in)) to im.

Some of the SPEC tests end up with reduction+(sext/zext(<n x i1>) to <n x im>) pattern, which can be transformed to [-]zext/trunc(ctpop(bitcast <n x i1> to in)) to im.
Also, reduction+(<n x i1>) can be transformed to ctpop(bitcast <n x i1> to in) & 1 != 0.

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

3 years ago[Internalize] Preserve variables externally initialized.
Michael Liao [Tue, 29 Jun 2021 15:03:52 +0000 (11:03 -0400)]
[Internalize] Preserve variables externally initialized.

- ``externally_initialized`` variables would be initialized or modified
  elsewhere. Particularly, CUDA or HIP may have host code to initialize
  or modify ``externally_initialized`` device variables, which may not
  be explicitly referenced on the device side but may still be used
  through the host side interfaces. Not preserving them triggers the
  elimination of them in the GlobalDCE and breaks the user code.

Reviewed By: yaxunl

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

3 years ago[mlir] Fully qualify types and expressions in Interfaces
Markus Böck [Thu, 8 Jul 2021 14:44:16 +0000 (16:44 +0200)]
[mlir] Fully qualify types and expressions in Interfaces

This patch adds full qualification to the types and function calls used inside of (Static)InterfaceMethod in OpInterfaces. Without this patch using many of these interfaces in a downstream project yields compiler errors as the types and default implementations are mostly copied verbatim. Without then putting using namespace mlir; in the header file of the implementations of those interfaces, compilation is impossible.

Using fully qualified lookup fixes this issue.

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

3 years ago[Instcombine][NFC]Add a test for reduce+([sext/zext](<n x i1)) case, NFC.
Alexey Bataev [Thu, 8 Jul 2021 14:38:11 +0000 (07:38 -0700)]
[Instcombine][NFC]Add a test for reduce+([sext/zext](<n x i1)) case, NFC.

3 years ago[amdgpu] Remove the GlobalDCE pass prior to the internalization pass.
Michael Liao [Wed, 7 Jul 2021 20:44:47 +0000 (16:44 -0400)]
[amdgpu] Remove the GlobalDCE pass prior to the internalization pass.

- In [D98783](https://reviews.llvm.org/D98783), an extra GlobalDCE pass
  is inserted before the internalization pass to ensure a global
  variable without users could be internalized even if there are dead
  users. Instead of inserting a dedicated optimization pass, the
  dead user checking, i.e. 'use_empty()', should be preceeded with
  constant dead user removal to ensure an accurate result.

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

3 years agoRevert "Support: add llvm::thread class that supports specifying stack size."
Tim Northover [Thu, 8 Jul 2021 13:59:47 +0000 (14:59 +0100)]
Revert "Support: add llvm::thread class that supports specifying stack size."

It's causing build failures because DefaultStackSize isn't defined everywhere
it should be and I need time to investigate.

3 years agoSupport: add llvm::thread class that supports specifying stack size.
Tim Northover [Wed, 26 May 2021 10:25:11 +0000 (11:25 +0100)]
Support: add llvm::thread class that supports specifying stack size.

This adds a new llvm::thread class with the same interface as std::thread
except there is an extra constructor that allows us to set the new thread's
stack size. On Darwin even the default size is boosted to 8MB to match the main
thread.

It also switches all users of the older C-style `llvm_execute_on_thread` API
family over to `llvm::thread` followed by either a `detach` or `join` call and
removes the old API.

3 years ago[NFC] Mark Expected<T>::assertIsChecked() as const
xndcn [Thu, 1 Jul 2021 15:21:29 +0000 (23:21 +0800)]
[NFC] Mark Expected<T>::assertIsChecked() as const

Some const methods of Expected<T> invoke assertIsChecked(),
so we should mark it as const too.

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

3 years ago[mlir-reduce] Fix the memory leak and recycle unused modules.
Chia-hung Duan [Thu, 8 Jul 2021 12:03:23 +0000 (20:03 +0800)]
[mlir-reduce] Fix the memory leak and recycle unused modules.

Reviewed By: jpienaar

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

3 years ago[AArch64][SVE] Add ISel patterns for floating point compare with zero instructions
Bradley Smith [Tue, 6 Jul 2021 14:12:04 +0000 (15:12 +0100)]
[AArch64][SVE] Add ISel patterns for floating point compare with zero instructions

Additionally, lower the floating point compare SVE intrinsics to
SETCC_MERGE_ZERO ISD nodes to avoid duplicating ISel patterns.

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

3 years ago[Test] Add loop deletion switch tests
Max Kazantsev [Thu, 8 Jul 2021 10:27:18 +0000 (17:27 +0700)]
[Test] Add loop deletion switch tests

Patch by Dmitry Makogon!

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

3 years agoRevert "[mlir][MemRef] Fix DimOp folding of OffsetSizeAndStrideInterface."
Nicolas Vasilache [Thu, 8 Jul 2021 10:09:00 +0000 (10:09 +0000)]
Revert "[mlir][MemRef] Fix DimOp folding of OffsetSizeAndStrideInterface."

This reverts commit 6c0fd4db79f2def432f761627bb8c7d4171a3237.

This simple implementation is unfortunately not extensible and needs to be reverted.
The extensible way should be to extend https://reviews.llvm.org/D104321.

3 years ago[IR] Added operator delete to subclasses of User to avoid UB
Moritz Sichert [Wed, 26 May 2021 08:50:15 +0000 (10:50 +0200)]
[IR] Added operator delete to subclasses of User to avoid UB

Several subclasses of User override operator new without also overriding
operator delete. This means that delete expressions fall back to using
operator delete of the base class, which would be User. However, this is
only allowed if the base class has a virtual destructor which is not the
case for User, so this is UB.

See also [expr.delete] (3) for the exact wording.

This is actually detected in some cases by GCC 11's
-Wmismatched-new-delete now which is how I found this error.

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

3 years ago[libcxx] [test] Fix spurious failures in the thread detach test on Windows
Martin Storsjö [Wed, 7 Jul 2021 21:06:08 +0000 (21:06 +0000)]
[libcxx] [test] Fix spurious failures in the thread detach test on Windows

Make sure that the detached thread has started up before exiting
the process.

If the detached thread hasn't started up at all, and the main thread
exits, global data structures in the process are torn down, which
then can cause crashes when the thread starts up late after required
mutexes have been destroyed. (In particular, the mutex used internally
in _Init_thread_header, which is used in the initialization of
__thread_local_data()::__p, can cause crashes if the main thread already
has finished and progressed far with destruction.)

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

3 years ago[mlir][linalg][python] Add exp and log to the OpDSL.
Tobias Gysi [Thu, 8 Jul 2021 08:48:23 +0000 (08:48 +0000)]
[mlir][linalg][python] Add exp and log to the OpDSL.

Introduce the exp and log function in OpDSL. Add the soft plus operator to test the emitted IR in Python and C++.

Reviewed By: nicolasvasilache

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

3 years ago[mlir][linalg] Remove GenericOpBase.
Tobias Gysi [Thu, 8 Jul 2021 07:02:15 +0000 (07:02 +0000)]
[mlir][linalg] Remove GenericOpBase.

Remove the GenericOpBase class formerly used to factor out common logic shared be GenericOp and IndexedGenericOp. After removing IndexedGenericOp, the base class is not used anymore.

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

3 years ago[mlir][MemRef] Fix DimOp folding of OffsetSizeAndStrideInterface.
Nicolas Vasilache [Wed, 7 Jul 2021 16:11:10 +0000 (16:11 +0000)]
[mlir][MemRef] Fix DimOp folding of OffsetSizeAndStrideInterface.

This addresses the issue reported in

https://llvm.discourse.group/t/rank-reducing-memref-subview-offsetsizeandstrideopinterface-interface-issues/3805

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

3 years ago[mlir] factor out ConvertToLLVMPattern
Alex Zinenko [Wed, 7 Jul 2021 09:45:27 +0000 (11:45 +0200)]
[mlir] factor out ConvertToLLVMPattern

This class and classes that extend it are general utilities for any dialect
that is being converted into the LLVM dialect. They are in no way specific to
Standard-to-LLVM conversion and should not make their users depend on it.

Reviewed By: nicolasvasilache

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

3 years ago[AMDGPU] Fix typo
Sebastian Neubauer [Thu, 8 Jul 2021 08:07:33 +0000 (10:07 +0200)]
[AMDGPU] Fix typo

3 years ago[lld/mac] Fix warning about unused variable [NFC]
Mikael Holmen [Thu, 8 Jul 2021 07:46:30 +0000 (09:46 +0200)]
[lld/mac] Fix warning about unused variable [NFC]

Change "dyn_cast" to "isa" to get rid of the unused
variable "bitcodeFile".

gcc warned with

lld/MachO/Driver.cpp:531:17: warning: unused variable 'bitcodeFile' [-Wunused-variable]
531 |       if (auto *bitcodeFile = dyn_cast<BitcodeFile>(file)) {
    |                 ^~~~~~~~~~~

3 years ago[mlir][linalg] Tighter StructuredOp Verification.
Tobias Gysi [Thu, 8 Jul 2021 06:23:55 +0000 (06:23 +0000)]
[mlir][linalg] Tighter StructuredOp Verification.

Verify the number of results matches exactly the number of output tensors. Simplify the FillOp verification since part of it got redundant.

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

3 years ago[ORC] Introduce ExecutorAddress type, fix broken LLDB bot.
Lang Hames [Thu, 8 Jul 2021 06:29:39 +0000 (16:29 +1000)]
[ORC] Introduce ExecutorAddress type, fix broken LLDB bot.

ExecutorAddressRange depended on JITTargetAddress, but JITTargetAddress is
defined in ExecutionEngine, which OrcShared should not depend on.

This seems like as good a time as any to introduce a new ExecutorAddress type
to eventually replace JITTargetAddress. For now it's just another uint64_t
alias, but it will soon be changed to a class type to provide greater type
safety.

3 years ago[ORC] Improve computeLocalDeps / computeNamedSymbolDependencies performance.
Lang Hames [Thu, 8 Jul 2021 05:29:47 +0000 (15:29 +1000)]
[ORC] Improve computeLocalDeps / computeNamedSymbolDependencies performance.

The computeNamedSymbolDependencies and computeLocalDeps methods on
ObjectLinkingLayerJITLinkContext are responsible for computing, for each symbol
in the current MaterializationResponsibility, the set of non-locally-scoped
symbols that are depended on. To calculate this we have to consider the effect
of chains of dependence through locally scoped symbols in the LinkGraph. E.g.

        .text
        .globl  foo
foo:
        callq   bar                    ## foo depneds on external 'bar'
        movq    Ltmp1(%rip), %rcx      ## foo depends on locally scoped 'Ltmp1'
        addl    (%rcx), %eax
        retq

        .data
Ltmp1:
        .quad   x                      ## Ltmp1 depends on external 'x'

In this example symbol 'foo' depends directly on 'bar', and indirectly on 'x'
via 'Ltmp1', which is locally scoped.

Performance of the existing implementations appears to have been mediocre:
Based on flame graphs posted by @drmeister (in #jit on the LLVM discord server)
the computeLocalDeps function was taking up a substantial amount of time when
starting up Clasp (https://github.com/clasp-developers/clasp).

This commit attempts to address the performance problems in three ways:

1. Using jitlink::Blocks instead of jitlink::Symbols as the nodes of the
dependencies-introduced-by-locally-scoped-symbols graph.

Using either Blocks or Symbols as nodes provides the same information, but since
there may be more than one locally scoped symbol per block the block-based
version of the dependence graph should always be a subgraph of the Symbol-based
version, and so faster to operate on.

2. Improved worklist management.

The older version of computeLocalDeps used a fixed worklist containing all
nodes, and iterated over this list propagating dependencies until no further
changes were required. The worklist was not sorted into a useful order before
the loop started.

The new version uses a variable work-stack, visiting nodes in DFS order and
only adding nodes when there is meaningful work to do on them.

Compared to the old version the new version avoids revisiting nodes which
haven't changed, and I suspect it converges more quickly (due to the DFS
ordering).

3. Laziness and caching.

Mappings of...

jitlink::Symbol* -> Interned Name (as SymbolStringPtr)
jitlink::Block* -> Immediate dependencies (as SymbolNameSet)
jitlink::Block* -> Transitive dependencies (as SymbolNameSet)

are all built lazily and cached while running computeNamedSymbolDependencies.

According to @drmeister these changes reduced Clasp startup time in his test
setup (averaged over a handful of starts) from 4.8 to 2.8 seconds (with
ORC/JITLink linking ~11,000 object files in that time), which seems like
enough to justify switching to the new algorithm in the absence of any other
perf numbers.

3 years ago[WebAssembly][lld] Fix segfault on .bss sections in mapfile
Thomas Lively [Thu, 8 Jul 2021 06:31:48 +0000 (23:31 -0700)]
[WebAssembly][lld] Fix segfault on .bss sections in mapfile

When memory is declared in the Wasm module, we rely on the implicit zero
initialization behavior and do not explicitly output .bss sections. The means
that they do not have associated `outputSec` entries, which was causing
segfaults in the mapfile support. Fix the issue by guarding against null
`outputSec` and falling back to using a zero offset.

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

3 years ago[WebAssembly] Optimize out shift masks
Thomas Lively [Thu, 8 Jul 2021 06:14:31 +0000 (23:14 -0700)]
[WebAssembly] Optimize out shift masks

WebAssembly's shift instructions implicitly masks the shift count, so optimize
out redundant explicit masks of the shift count. For vector shifts, this
currently only works if the mask is applied before splatting the shift count,
but this should be addressed in a future commit. Resolves PR49655.

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

3 years ago[ORC] Replace MachOJITDylibInitializers::SectionExtent with ExecutorAddressRange
Lang Hames [Thu, 8 Jul 2021 04:10:15 +0000 (14:10 +1000)]
[ORC] Replace MachOJITDylibInitializers::SectionExtent with ExecutorAddressRange

MachOJITDylibInitializers::SectionExtent represented the address range of a
section as an (address, size) pair. The new ExecutorAddressRange type
generalizes this to an address range (for any object, not necessarily a section)
represented as a (start-address, end-address) pair.

The aim is to express more of ORC (and the ORC runtime) in terms of simple types
that can be serialized/deserialized via SPS. This will simplify SPS-based RPC
involving arguments/return-values of these types.

3 years ago[ORC] Fix file comments.
Lang Hames [Wed, 7 Jul 2021 11:16:06 +0000 (21:16 +1000)]
[ORC] Fix file comments.

3 years agoRevert "[MCA] [AMDGPU] Adding an implementation to AMDGPUCustomBehaviour for handling...
Patrick Holland [Thu, 8 Jul 2021 03:48:42 +0000 (20:48 -0700)]
Revert "[MCA] [AMDGPU] Adding an implementation to AMDGPUCustomBehaviour for handling s_waitcnt instructions."

Build failures when building with shared libraries. Reverting until I can fix.

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

3 years ago[PowerPC] Fix i64 to vector lowering on big endian
Qiu Chaofan [Thu, 8 Jul 2021 03:05:09 +0000 (11:05 +0800)]
[PowerPC] Fix i64 to vector lowering on big endian

Lowering for scalar to vector would skip if current subtarget is big
endian and the scalar is larger or equal than 64 bits. However there's
some issue in implementation that SToVRHS may refer to SToVLHS's scalar
size if SToVLHS is present, which leads to some crash.o

Reviewed By: nemanjai, shchenz

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

3 years ago[AIX] Don't pass no-integrated-as by default
Jinsong Ji [Thu, 8 Jul 2021 02:24:48 +0000 (02:24 +0000)]
[AIX] Don't pass no-integrated-as by default

D105314 added the abibility choose to use AsmParser for parsing inline
asm. -no-intergrated-as will override this default if specified
explicitly.

If toolchain choose to use MCAsmParser for inline asm, don't pass
the option to disable integrated-as explictly unless set by user.

Reviewed By: #powerpc, shchenz

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

3 years ago[gn build] (manually) port ef16c8eaa5cd5679759 (MCACustomBehaviorAMDGPU)
Nico Weber [Thu, 8 Jul 2021 01:59:07 +0000 (21:59 -0400)]
[gn build] (manually) port ef16c8eaa5cd5679759 (MCACustomBehaviorAMDGPU)

3 years ago[Bazel] Fixes for b5d847b1b95750d0af40cfc8c71a8fec50bb8613 and 6412a13539ab2914eed8e1...
Jordan Rupprecht [Wed, 7 Jul 2021 23:50:23 +0000 (16:50 -0700)]
[Bazel] Fixes for b5d847b1b95750d0af40cfc8c71a8fec50bb8613 and 6412a13539ab2914eed8e1df83c399b9a16e3408

3 years ago[gn build] (semi-manually) port 966386514bec
Nico Weber [Wed, 7 Jul 2021 23:27:19 +0000 (19:27 -0400)]
[gn build] (semi-manually) port 966386514bec

3 years ago[AMDGPU] Disable garbage collection passes
Stanislav Mekhanoshin [Wed, 7 Jul 2021 21:25:24 +0000 (14:25 -0700)]
[AMDGPU] Disable garbage collection passes

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

3 years ago[compiler-rt][Fuchsia] Disable interceptors while enabling new/delete replacements
Leonard Chan [Wed, 2 Jun 2021 18:33:49 +0000 (11:33 -0700)]
[compiler-rt][Fuchsia] Disable interceptors while enabling new/delete replacements

This disables use of hwasan interceptors which we do not use on Fuchsia. This
explicitly sets the macro for defining the hwasan versions of new/delete.

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

3 years ago[clang] disable P2266 simpler implicit moves under -fms-compatibility
Matheus Izvekov [Wed, 7 Jul 2021 00:22:45 +0000 (02:22 +0200)]
[clang] disable P2266 simpler implicit moves under -fms-compatibility

The Microsoft STL currently has some issues with P2266.
We disable it for now in that mode, but we might come back later with a
more targetted approach.

Signed-off-by: Matheus Izvekov <mizvekov@gmail.com>
Reviewed By: aaron.ballman

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

3 years ago[compiler-rt][hwasan] Setup hwasan thread handling on Fuchsia
Leonard Chan [Fri, 11 Jun 2021 17:32:04 +0000 (10:32 -0700)]
[compiler-rt][hwasan] Setup hwasan thread handling on Fuchsia

This patch splits up hwasan thread creation between `__sanitizer_before_thread_create_hook`,
`__sanitizer_thread_create_hook`, and `__sanitizer_thread_start_hook`.
The linux implementation creates the hwasan thread object inside the
new thread. On Fuchsia, we know the stack bounds before thread creation,
so we can initialize part of the thread object in `__sanitizer_before_thread_create_hook`,
then initialize the stack ring buffer in `__sanitizer_thread_start_hook`
once we enter the thread.

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

3 years ago[llvm-nm][test] Fix just-symbols.test
Fangrui Song [Wed, 7 Jul 2021 22:04:18 +0000 (15:04 -0700)]
[llvm-nm][test] Fix just-symbols.test

3 years ago[OpaquePtr] Use ArgListEntry::IndirectType for lowering ABI attributes
Arthur Eubanks [Wed, 7 Jul 2021 21:50:30 +0000 (14:50 -0700)]
[OpaquePtr] Use ArgListEntry::IndirectType for lowering ABI attributes

Consolidate PreallocatedType and ByValType into IndirectType, and use that for inalloca.

3 years ago[PowerPC] Add P7 RUN line for load and splat test
Jinsong Ji [Wed, 7 Jul 2021 21:35:56 +0000 (21:35 +0000)]
[PowerPC] Add P7 RUN line for load and splat test

3 years ago[OpaquePtr] Remove checking pointee type for byval/preallocated type
Arthur Eubanks [Wed, 7 Jul 2021 21:28:41 +0000 (14:28 -0700)]
[OpaquePtr] Remove checking pointee type for byval/preallocated type

These currently always require a type parameter. The bitcode reader
already upgrades old bitcode without the type parameter to use the
pointee type.

In cases where the caller does not have byval but the callee does, we
need to follow CallBase::paramHasAttr() and also look at the callee for
the byval type so that CallBase::isByValArgument() and
CallBase::getParamByValType() are in sync. Do the same for preallocated.

While we're here add a corresponding version for inalloca since we'll
need it soon.

Reviewed By: nikic

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

3 years agoutils: add a revert checker
George Burgess IV [Wed, 7 Jul 2021 18:00:27 +0000 (11:00 -0700)]
utils: add a revert checker

Chrome OS and Android have found it useful to have an automated revert
checker. It was requested to upstream it, since other folks in the LLVM
community may also find value in it.

The tests depend on having a full (non-shallow) checkout of LLVM. This
seems reasonable to me, since:

- the tests should only be run if the user is developing on this script
- it's kind of hard to develop on this script without local git history
  :)

If people really want, the tests' dependency on LLVM's history can be
removed. It's mostly just effort/complexity that doesn't seem necessary.

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

3 years ago[MCA] [AMDGPU] Adding an implementation to AMDGPUCustomBehaviour for handling s_waitc...
Patrick Holland [Sat, 19 Jun 2021 00:33:19 +0000 (17:33 -0700)]
[MCA] [AMDGPU] Adding an implementation to AMDGPUCustomBehaviour for handling s_waitcnt instructions.

This commit also makes some slight changes to the scheduling model for AMDGPU to set the RetireOOO flag for all scheduling classes.

This flag is only used by llvm-mca and allows instructions to retire out of order.

See the differential link below for a deeper explanation of everything.

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

3 years ago[ARM] Add some opaque pointer gather/scatter tests. NFC
David Green [Wed, 7 Jul 2021 21:03:53 +0000 (22:03 +0100)]
[ARM] Add some opaque pointer gather/scatter tests. NFC

They seem to work OK. Some other test cleanups at the same time.

3 years ago[AsmWriter] Simplify type attribute printing (NFC)
Nikita Popov [Wed, 7 Jul 2021 20:46:57 +0000 (22:46 +0200)]
[AsmWriter] Simplify type attribute printing (NFC)

Avoid enumerating all supported type attributes, instead fetch
their name from the attribute kind.

3 years ago[IR] Simplify Attribute::getAsString() (NFC)
Nikita Popov [Wed, 7 Jul 2021 20:41:12 +0000 (22:41 +0200)]
[IR] Simplify Attribute::getAsString() (NFC)

Avoid enumerating all attributes here and instead use
getNameFromAttrKind(), which is based on the tablegen data.

This only leaves us with custom handling for int attributes,
which don't have uniform printing.

3 years ago[llvm-nm] Switch command line parsing from llvm::cl to OptTable
Fangrui Song [Wed, 7 Jul 2021 20:34:33 +0000 (13:34 -0700)]
[llvm-nm] Switch command line parsing from llvm::cl to OptTable

Part of https://lists.llvm.org/pipermail/llvm-dev/2021-July/151622.html
"Binary utilities: switch command line parsing from llvm::cl to OptTable"

Users should generally observe no difference as long as they only use intended
option forms. Behavior changes:

* `-t=d` is removed. Use `-t d` instead.
* `--demangle=0` cannot be used. Omit the option or use `--no-demangle` instead.
* `--help-list` is removed. This is a `cl::` specific option.

Note:

* `-t` diagnostic gets improved.
* This patch avoids cl::opt collision if we decide to support multiplexing for binary utilities
* One-dash long options are still supported.
* The `-s` collision (`-s segment section` for Mach-O) is unfortunate. `-s` means `--print-armap` in GNU nm.
* This patch removes the last `cl::multi_val` use case from the `llvm/lib/Support/CommandLine.cpp` library

`-M` (`--print-armap`), `-U` (`--defined-only`), and `-W` (`--no-weak`)
are now deprecated. They could conflict with future GNU nm options.
(--print-armap has an existing alias -s, so GNU will unlikely add a new one.
--no-weak (not in GNU nm) is rarely used anyway.)

`--just-symbol-name` is now deprecated in favor of
`--format=just-symbols` and `-j`.

Reviewed By: jhenderson

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