platform/upstream/llvm.git
19 months agomlir/tosa: move tosa.pad from Linalg to Tensor conversion
Ramkumar Ramachandra [Thu, 1 Dec 2022 10:48:24 +0000 (11:48 +0100)]
mlir/tosa: move tosa.pad from Linalg to Tensor conversion

Since tosa.pad is lowered strictly to artih and tensor ops, move
ConvertPad from TosaToLinalg to TosaToTensor, benefitting non-Linalg
Tosa targets. TensorToLinalg exists, and is trivial, so nothing is lost.

Signed-off-by: Ramkumar Ramachandra <r@artagnon.com>
Differential Revision: https://reviews.llvm.org/D139091

19 months ago[clang-tools-extra] Use std::nullopt instead of llvm::None (NFC)
Kazu Hirata [Tue, 6 Dec 2022 06:37:22 +0000 (22:37 -0800)]
[clang-tools-extra] Use std::nullopt instead of llvm::None (NFC)

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

19 months ago[clang-tools-extra] Use std::nullopt instead of llvm::None (NFC)
Kazu Hirata [Tue, 6 Dec 2022 05:49:31 +0000 (21:49 -0800)]
[clang-tools-extra] Use std::nullopt instead of llvm::None (NFC)

This patch mechanically replaces None with std::nullopt where the
compiler would warn if None were deprecated.  The intent is to reduce
the amount of manual work required in migrating from Optional to
std::optional.

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

19 months ago[lldb] Use std::nullopt instead of None (NFC)
Kazu Hirata [Tue, 6 Dec 2022 04:54:05 +0000 (20:54 -0800)]
[lldb] Use std::nullopt instead of None (NFC)

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

19 months agoRemove "using llvm::None;" in *.cpp
Kazu Hirata [Tue, 6 Dec 2022 04:39:10 +0000 (20:39 -0800)]
Remove "using llvm::None;" in *.cpp

These .cpp files do not use llvm::None anymore.

Since these are not header files, we can remove them pretty safely
without deprecating them first.

19 months ago[mlir] UnsignedWhenEquivalent ignore dead code
Jeff Niu [Tue, 6 Dec 2022 04:00:38 +0000 (20:00 -0800)]
[mlir] UnsignedWhenEquivalent ignore dead code

The pass was not checking for uninitialized states due to dead code.
This patch also makes LLVMFuncOp correctly return a null body when it is
external.

Fixes #58807

Depends on D139388

Reviewed By: rriddle

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

19 months ago[mlir][llvm] Mark LLVMReturnOp as ReturnLike
Jeff Niu [Tue, 6 Dec 2022 03:34:14 +0000 (19:34 -0800)]
[mlir][llvm] Mark LLVMReturnOp as ReturnLike

Reviewed By: rriddle

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

19 months ago[RISCV] Fold vector binary operatrion into select with identity constant.
jacquesguan [Wed, 21 Sep 2022 07:51:18 +0000 (15:51 +0800)]
[RISCV] Fold vector binary operatrion into select with identity constant.

This patch implements shouldFoldSelectWithIdentityConstant for RISCV. It would try to generate vmerge after the binary instruction and let them folded to maksed instruction later.

Reviewed By: craig.topper

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

19 months ago[mlir][ods] Allow ArrayOfAttr implicit conversion to ArrayRef
Jeff Niu [Mon, 5 Dec 2022 21:15:27 +0000 (13:15 -0800)]
[mlir][ods] Allow ArrayOfAttr implicit conversion to ArrayRef

Reviewed By: rriddle

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

19 months ago[X86][clang] Lift _BitInt() supported max width.
Freddy Ye [Tue, 6 Dec 2022 02:19:12 +0000 (10:19 +0800)]
[X86][clang] Lift _BitInt() supported max width.

Reviewed By: mgehre-amd

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

19 months ago[OpenMP] Let predefined allocator fallback to default instead of returning null
Nawrin Sultana [Mon, 5 Dec 2022 23:53:54 +0000 (17:53 -0600)]
[OpenMP] Let predefined allocator fallback to default instead of returning null

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

19 months agoCallGraph: Fix IgnoreAssumeLikeCalls option to Function::hasAddressTaken
Matt Arsenault [Fri, 2 Dec 2022 23:30:19 +0000 (18:30 -0500)]
CallGraph: Fix IgnoreAssumeLikeCalls option to Function::hasAddressTaken

This was added in 29e2d9461a91b and likely never worked in a useful
way.

The test added for it fails when converted to opaque pointers, since
the lifetime intrinsic now directly uses the address. The code was
only trying to handle a user indirectly through a bitcast
instruction. That would never have been useful; a bitcast of a global
value would be folded to a ConstantExpr cast.

I also don't understand why it was special casing use_empty on the
cast. Relax the check to be either BitCastOperator or
AddrSpaceCastOperator. In practice, BitCastOperator won't appear
today.

I believe the change in parallel_deletion_cg_update is a correct
improvement but I didn't fully follow it. .omp_outlined..0 is used in
a constant expression cast to a call which ends up getting deleted.

19 months ago[RISCV][test] Add pre-commit test for D131551.
jacquesguan [Tue, 16 Aug 2022 07:45:28 +0000 (15:45 +0800)]
[RISCV][test] Add pre-commit test for D131551.

Reviewed By: craig.topper

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

19 months ago[lldb][Test] TestRerunAndExpr.py: skip on Windows
Michael Buch [Tue, 6 Dec 2022 02:13:59 +0000 (02:13 +0000)]
[lldb][Test] TestRerunAndExpr.py: skip on Windows

On Windows rebuilding the binary isn't enough to unload it
on progrem restart. But the assumption of the test is that on
program re-run LLDB destroys and replaces the old module with
the newly built version. One will have to try hard to evict the
module from the ModuleList (possibly including a call to
`SBDebugger::MemoryPressureDetected`.

See D138724

19 months ago[llvm-objcopy] Reland "Fix --add-section when section contain empty bytes"
Guilhem [Tue, 6 Dec 2022 02:04:45 +0000 (18:04 -0800)]
[llvm-objcopy] Reland "Fix --add-section when section contain empty bytes"

Implicit cast between char* and StringRef when writing sections.

Reproduce:
```
$> llvm-objcopy --dump-section=name=name.data out.wasm
$> llvm-objcopy --remove-section=name out.wasm out_no_name.wasm
$> llvm-objcopy --add-section=name=name.data out_no_name.wasm out_new_name.wasm

```

Reviewed By: dschuff

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

19 months agoDon't use root logger at import time
Stella Laurenzo [Tue, 6 Dec 2022 01:42:38 +0000 (17:42 -0800)]
Don't use root logger at import time

At import time, these calls to `logging.debug()` implicitly call `logging.basicConfig` (https://docs.python.org/3/library/logging.html#logging.basicConfig), setting logging config for the whole project which cannot then be overwritten later. For instance, consider the following test script:

```
import logging
import jax

logger = logging.getLogger(__name__)
logging.basicConfig(level=logging.INFO)
logger.info('info')
```
This should log out `'info'`, but because when `import jax` is called, this `_mlir_lib/__init__.py` file is run and a `logging.debug` is called, calling `logging.basicConfig`, my `logging.basicConfig(level=logging.INFO)` does nothing.

Fix: instead of using root logger, use a module level logger.

Found in this issue: https://github.com/google/jax/issues/12526

Reviewed By: stellaraccident

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

19 months ago[NFC][SimplifyCFG] Add few more fold-branch-to-common-dest tests
Roman Lebedev [Tue, 6 Dec 2022 01:16:13 +0000 (04:16 +0300)]
[NFC][SimplifyCFG] Add few more fold-branch-to-common-dest tests

19 months agoDebugInfo: Add support for new DWARFv5 language codes
David Blaikie [Tue, 6 Dec 2022 01:13:44 +0000 (01:13 +0000)]
DebugInfo: Add support for new DWARFv5 language codes

19 months ago[RISCV]Keep (select c, 0/-1, X) during PerformDAGCombine
ChunyuLiao [Tue, 6 Dec 2022 01:10:00 +0000 (09:10 +0800)]
[RISCV]Keep (select c, 0/-1, X) during PerformDAGCombine

D135833, lowerSelect: (select C, -1/0, X) -> or/and
Keep (select c, 0/-1, X), thus making better use of lowerSelect to eliminate branch instructions.

Reviewed By: craig.topper

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

19 months agoRevert "[mlir][sparse] Refactoring: abstract sparse tensor memory scheme into a Spars...
Stella Stamenova [Tue, 6 Dec 2022 01:20:01 +0000 (17:20 -0800)]
Revert "[mlir][sparse] Refactoring: abstract sparse tensor memory scheme into a SparseTensorDescriptor class."

This reverts commit 8a7e69d145ff72e7e4fc10ce6b81c3aa4794201c.

This broke the windows mlir buildbot: https://lab.llvm.org/buildbot/#/builders/13/builds/29257

19 months ago[mlir][sparse] Cleaning up the dim/lvl distinction in SparseTensorConversion
wren romano [Fri, 2 Dec 2022 03:08:45 +0000 (19:08 -0800)]
[mlir][sparse] Cleaning up the dim/lvl distinction in SparseTensorConversion

This change cleans up the conversion pass re the "dim"-vs-"lvl" and "sizes"-vs-"shape" distinctions of the runtime. A quick synopsis includes:

* Adds new `SparseTensorStorageBase::getDimSize` method, with `sparseDimSize` wrapper in SparseTensorRuntime.h, and `genDimSizeCall` generator in SparseTensorConversion.cpp
* Changes `genLvlSizeCall` to perform no logic, just generate the function call.
* Adds `createOrFold{Dim,Lvl}Call` functions to handle the logic of replacing `gen{Dim,Lvl}SizeCall` with constants whenever possible. The `createOrFoldDimCall` function replaces the old `sizeFromPtrAtDim`.
* Adds `{get,fill}DimSizes` functions for iterating `createOrFoldDimCall` across the whole type. These functions replace the old `sizesFromPtr`.
* Adds `{get,fill}DimShape` functions for lowering a `ShapedType` into constants. These functions replace the old `sizesFromType`.
* Changes the `DimOp` rewrite to do the right thing.
* Changes the `ExpandOp` rewrite to compute the proper expansion size.

Depends On D138365

Reviewed By: aartbik

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

19 months agoRevert "[OpenMP] Use `add_llvm_library` to build the target `PluginInterface` in...
Roman Lebedev [Tue, 6 Dec 2022 00:49:23 +0000 (03:49 +0300)]
Revert "[OpenMP] Use `add_llvm_library` to build the target `PluginInterface` in `plugins-nextgen`"

Breaks cmake regeneration for me:
```
CMake Error: install(EXPORT "LLVMExports" ...) includes target "omptarget.rtl.cuda.nextgen" which requires target "PluginInterface" that is not in any export set.
CMake Error: install(EXPORT "LLVMExports" ...) includes target "omptarget.rtl.x86_64.nextgen" which requires target "PluginInterface" that is not in any export set.
```

This reverts commit 08c4081bd3605e1b01a7ccd6accc9052c8966250.

19 months ago[NFC][PPC] Autogenerate checklines in ppc-ctr-dead-code.ll to simplify update
Roman Lebedev [Tue, 6 Dec 2022 00:45:50 +0000 (03:45 +0300)]
[NFC][PPC] Autogenerate checklines in ppc-ctr-dead-code.ll to simplify update

19 months ago[NFC][LICM] Autogenerate checklines for one function to simplify update
Roman Lebedev [Tue, 6 Dec 2022 00:45:12 +0000 (03:45 +0300)]
[NFC][LICM] Autogenerate checklines for one function to simplify update

19 months ago[OpenMP] Use `add_llvm_library` to build the target `PluginInterface` in `plugins...
Shilei Tian [Tue, 6 Dec 2022 00:46:04 +0000 (19:46 -0500)]
[OpenMP] Use `add_llvm_library` to build the target `PluginInterface` in `plugins-nextgen`

This patch uses `add_llvm_library` to build the target `PluginInterface` since it can handle LLVM dependences much better. One temporary drawback of using this is that currently LLVM CMake macro doesn't support object libraries very well (there was a try a couple years ago but it was reverted later https://github.com/llvm/llvm-project/commit/29e57229497711a3a294f437b59afa6ddc36a3d8). After switching to that, `CXX_VISIBILITY_PRESET` can not be set correctly, which can cause runtime error that a function call from one plugin could go to another. As a consequence, `PluginInterface` is built as a static library for now. I have asked the question in CMake community (https://discourse.cmake.org/t/set-target-properties-doesnt-work-properly/7016). Once that issue is solved, I'll switch it back to object library. It is not necessarily too bad to use static library, especially `BUILDTREE_ONLY` is already set such that `PluginInterface.a` will not be installed.

Reviewed By: jhuber6

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

19 months ago[NFC][SimplifyCFG] Add one more fold-branch-to-common-dest test
Roman Lebedev [Mon, 5 Dec 2022 23:13:50 +0000 (02:13 +0300)]
[NFC][SimplifyCFG] Add one more fold-branch-to-common-dest test

19 months ago[CodeView] Don't generate dummy unnamed strcut/class/union type.
Zequan Wu [Mon, 5 Dec 2022 23:58:28 +0000 (07:58 +0800)]
[CodeView] Don't generate dummy unnamed strcut/class/union type.

19 months ago[RISCV] Remove some RISCVMatInt early exits.
Craig Topper [Tue, 6 Dec 2022 00:29:16 +0000 (16:29 -0800)]
[RISCV] Remove some RISCVMatInt early exits.

These were early exiting if we replaced a sequence with a 2 instruction
sequence since that is the best we could do. All the later optimizations
only occur if the sequence is more than 2 instructions so this wasn't a
functional check.

At best it helps the compiler generate better code, but I don't think
that was analyzed when it was added. Remove it to simplify the code.

19 months ago[Polly] Use std::nullopt to unbreak build.
Michael Kruse [Mon, 5 Dec 2022 23:27:10 +0000 (17:27 -0600)]
[Polly] Use std::nullopt to unbreak build.

19 months ago[Driver][test] Fix test by creating empty archive instead of empty file
Jacob Lambert [Wed, 2 Nov 2022 17:38:17 +0000 (10:38 -0700)]
[Driver][test] Fix test by creating empty archive instead of empty file

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

19 months agoRevert "[-Wunsafe-buffer-usage] Initial commit - Transition away from raw buffers."
Artem Dergachev [Mon, 5 Dec 2022 23:38:40 +0000 (15:38 -0800)]
Revert "[-Wunsafe-buffer-usage] Initial commit - Transition away from raw buffers."

This reverts commit 200007ec85f81122fd260a4e68308e54607ca37a.

19 months agoReland "[llvm] Teach FastISel for AArch64 about tagged globals"
Leonard Chan [Mon, 5 Dec 2022 23:26:50 +0000 (23:26 +0000)]
Reland "[llvm] Teach FastISel for AArch64 about tagged globals"

This reverts commit aacf17aa0ca8a67efc0ad2d4cfd90e551b5d6a7f.

Fixed by using the right register class for the movk.

19 months ago[gn build] Port 200007ec85f8
LLVM GN Syncbot [Mon, 5 Dec 2022 23:13:55 +0000 (23:13 +0000)]
[gn build] Port 200007ec85f8

19 months ago[-Wunsafe-buffer-usage] Initial commit - Transition away from raw buffers.
Artem Dergachev [Fri, 2 Dec 2022 20:58:56 +0000 (12:58 -0800)]
[-Wunsafe-buffer-usage] Initial commit - Transition away from raw buffers.

This is the initial commit for -Wunsafe-buffer-usage, a warning that helps
codebases (especially modern C++ codebases) transition away from raw buffer
pointers.

The warning is implemented in libAnalysis as it's going to become a non-trivial
analysis, mostly the fixit part where we try to figure out if we understand
a variable's use pattern well enough to suggest a safe container/view
as a replacement. Some parts of this analsysis may eventually prove useful
for any similar fixit machine that tries to change types of variables.

The warning is disabled by default.

RFC/discussion in https://discourse.llvm.org/t/rfc-c-buffer-hardening/65734

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

19 months agoIncrease search for kernel image from 32MB to 128MB
Jason Molenda [Wed, 30 Nov 2022 20:28:47 +0000 (12:28 -0800)]
Increase search for kernel image from 32MB to 128MB

DynamicLoaderDarwinKernel::SearchForKernelNearPC() searches for a
Darwin kernel mach-o header starting at $pc and working backwards,
stopping on the first memory read error encountered.  The kernel,
and the kexts linked in to the kernel, have grown over the years
and the original 32MB scan limit is giving a high chance of failing
to find the kernel if we're in a random kext.

In non-kernel environments, firmware and bare board typically, we
will hit a memory read error on an unmapped page quickly so this
doesn't add a lot of random memory read requests in those environments.

We only check at one megabyte boundaries, so worst case this is 128
reads at the start of a gdb-remote connection.  The check for a
memory read error & stopping was a more recent addition (a few years
ago), so I kept the scan region a bit small.

19 months ago[mlir] List more elementwise ops in VectorToGPU MMA conversion
Lei Zhang [Mon, 5 Dec 2022 22:40:39 +0000 (22:40 +0000)]
[mlir] List more elementwise ops in VectorToGPU MMA conversion

Reviewed By: ThomasRaoux

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

19 months agoRevert "[llvm] Teach FastISel for AArch64 about tagged globals"
Leonard Chan [Mon, 5 Dec 2022 22:45:04 +0000 (22:45 +0000)]
Revert "[llvm] Teach FastISel for AArch64 about tagged globals"

This reverts commit 7358c29a42714eb8d7d7bcdb58688d20430689e4.

This broke an upstream builder:
https://lab.llvm.org/buildbot/#/builders/16/builds/39356

19 months ago[lldb-tests] Force system's libcxx on tests failing with debug symbols
Felipe de Azevedo Piovezan [Mon, 5 Dec 2022 20:49:13 +0000 (15:49 -0500)]
[lldb-tests] Force system's libcxx on tests failing with debug symbols

The tests in this patch expose failures of LLDBs expression evaluator
when a standard library is compiled with debug symbols. This is the case
for RelWithDebugInfo builds of llvm-project (with libcxx).

Until these bugs are fixed, we force these tests to use the system's
standard library.

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

19 months ago[mlir][spirv] Add extensions implied by SPIR-V 1.6
Jakub Kuderski [Mon, 5 Dec 2022 22:40:29 +0000 (17:40 -0500)]
[mlir][spirv] Add extensions implied by SPIR-V 1.6

This adds existing extensions as implied by SPIR-V 1.6.

Also clean up the surrounding code.

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

Reviewed By: antiagainst

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

19 months ago[mlir][spirv] Add GPU subgroup MMA to spirv.MMAMatrixTimesScalar
Lei Zhang [Mon, 5 Dec 2022 22:18:34 +0000 (22:18 +0000)]
[mlir][spirv] Add GPU subgroup MMA to spirv.MMAMatrixTimesScalar

Along the way, make the default pattern fail instead of crashing
when an elementwise op is not supported yet.

Reviewed By: kuhar

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

19 months agoRevert "[CMake] Use LLVM_TARGET_TRIPLE in runtimes"
Leonard Chan [Mon, 5 Dec 2022 22:20:51 +0000 (22:20 +0000)]
Revert "[CMake] Use LLVM_TARGET_TRIPLE in runtimes"

This reverts commit bec8a372fc0db95852748691c0f4933044026b25.

This causes many of these errors to appear when rebuilding runtimes part
of fuchsia's toolchain:

ld.lld: error:
/usr/local/google/home/paulkirth/llvm-upstream/build/lib/x86_64-unknown-linux-gnu/libunwind.a(libunwind.cpp.o)
is incompatible with elf64-x86-64

This can be reproduced by making a complete toolchain, saving any source
file with no changes, then rerunning ninja distribution.

19 months ago[llvm] Teach FastISel for AArch64 about tagged globals
Leonard Chan [Mon, 5 Dec 2022 22:16:55 +0000 (22:16 +0000)]
[llvm] Teach FastISel for AArch64 about tagged globals

This addresses https://github.com/llvm/llvm-project/issues/57750. For
some globals, the tag wasn't propagated correctly because the necessary
movk wasn't emitted sometimes.

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

19 months ago[mlir][spirv] Fix spirv.MatrixTimesScalar for cooperative matrix
Lei Zhang [Mon, 5 Dec 2022 22:03:54 +0000 (22:03 +0000)]
[mlir][spirv] Fix spirv.MatrixTimesScalar for cooperative matrix

spirv.MatrixTimesScalar is allowed to use cooperative matrix.

Reviewed By: kuhar

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

19 months ago[mlir][sparse] Refactoring: abstract sparse tensor memory scheme into a SparseTensorD...
Peiming Liu [Thu, 24 Nov 2022 00:42:43 +0000 (00:42 +0000)]
[mlir][sparse] Refactoring: abstract sparse tensor memory scheme into a SparseTensorDescriptor class.

This patch abstracts sparse tensor memory scheme into a SparseTensorDescriptor class. Previously, the field accesses are performed in a relatively error-prone way, this patch hides the hairy details behind a SparseTensorDescriptor class to allow users access sparse tensor fields in a more cohesive way.

Reviewed By: aartbik

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

19 months ago[mlir][tensor] Implement TilingInterface for tensor.pack op.
Hanhan Wang [Thu, 24 Nov 2022 02:07:12 +0000 (18:07 -0800)]
[mlir][tensor] Implement TilingInterface for tensor.pack op.

We can compute the offsets and sizes for the slice of input because the
iteration domain is defined over outer loops. If the dimension is tiled,
the i-th index is the product of offset_i and inner_tile_i.

Different from tiling a pad op, we do not have to deal with reading zero
data from input. Because the tiling sizes are indicated to packed outer
dimensions. We will read either the entire tile or partial tile for each
packed tile. The scf.if and tensor.generate ops are not needed in this
context.

Co-authored-by: Lorenzo Chelini <l.chelini@icloud.com>
Reviewed By: rengolin, mravishankar

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

19 months agoReland "[lld-macho] Overhaul map file code"
Jez Ng [Thu, 1 Dec 2022 05:57:16 +0000 (00:57 -0500)]
Reland "[lld-macho] Overhaul map file code"

This reverts commit 38d6202a425462ce5923d038bc54532115a80a1f.

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

19 months ago[lldb] Make sure the value of `eSymbolContextVariable` is not conflicting with `RESOL...
Argyrios Kyrtzidis [Thu, 1 Dec 2022 01:06:28 +0000 (17:06 -0800)]
[lldb] Make sure the value of `eSymbolContextVariable` is not conflicting with `RESOLVED_FRAME_CODE_ADDR`

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

19 months ago[mlir] Remove TypedAttr and ElementsAttr from DenseArrayAttr
Jeff Niu [Tue, 8 Nov 2022 04:20:59 +0000 (20:20 -0800)]
[mlir] Remove TypedAttr and ElementsAttr from DenseArrayAttr

This patch removes the implementation of TypedAttr and ElementsAttr
from DenseArrayAttr and, in doing so, removes the need store a shaped
type. The attribute now stores a size (number of elements), an MLIR type
as a discriminator, and a raw byte array.

The intent of DenseArrayAttr was not to be a drop-in replacement for DenseElementsAttr. It was meant to be a simple container of integers or floats that map to C++ types. The ElementsAttr implementation on DenseArrayAttr had many holes in it, and fixing those holes would require evolving DenseArrayAttr in a way that is incompatible with its original purpose.

Reviewed By: rriddle

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

19 months ago[InstCombine] Regenerate select-gep.ll test checks
Simon Pilgrim [Mon, 5 Dec 2022 21:19:05 +0000 (21:19 +0000)]
[InstCombine] Regenerate select-gep.ll test checks

Fixes superfluous diffs identified in D139253

19 months ago[InstCombine] Regenerate select-bitext.ll test checks
Simon Pilgrim [Mon, 5 Dec 2022 21:18:31 +0000 (21:18 +0000)]
[InstCombine] Regenerate select-bitext.ll test checks

Fixes superfluous diffs identified in D139253

19 months ago[InstCombine] Regenerate select-cmpxchg.ll test checks
Simon Pilgrim [Mon, 5 Dec 2022 21:15:49 +0000 (21:15 +0000)]
[InstCombine] Regenerate select-cmpxchg.ll test checks

19 months ago[InstCombine] Regenerate select-masked_load.ll test checks
Simon Pilgrim [Mon, 5 Dec 2022 21:15:02 +0000 (21:15 +0000)]
[InstCombine] Regenerate select-masked_load.ll test checks

19 months ago[InstCombine] Regenerate opaque-ptr.ll test checks
Simon Pilgrim [Mon, 5 Dec 2022 21:13:39 +0000 (21:13 +0000)]
[InstCombine] Regenerate opaque-ptr.ll test checks

Fixes superfluous diffs identified in D139253

19 months ago[X86] Remove unnecessary x87 overrides from znver1/znver2 model
Simon Pilgrim [Mon, 5 Dec 2022 21:12:07 +0000 (21:12 +0000)]
[X86] Remove unnecessary x87 overrides from znver1/znver2 model

Reported by D138359 - the overrides matched the base class schedule WriteMicrocoded definition

19 months ago[lld-macho] Canonicalize LSDA pointers
Jez Ng [Mon, 5 Dec 2022 21:18:15 +0000 (16:18 -0500)]
[lld-macho] Canonicalize LSDA pointers

This was causing an uncaught exception issue in one of our programs. The
issue was fairly subtle / rare as it required two identical LSDAs that were
referenced by a pair of non-identical compact unwind encodings.

Reviewed By: #lld-macho, smeenai

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

19 months ago[mlir][tosa] Handle tosa.resize nearest rounding correctly
Rob Suderman [Mon, 5 Dec 2022 20:45:06 +0000 (12:45 -0800)]
[mlir][tosa] Handle tosa.resize nearest rounding correctly

Rounding of tosa.resize did not handle rounding to the nearest pixel correctly.
Rather than dividing the scale by 2 we should double the partial pixel to
guarantee we include a check on the lowest bit.

Reviewed By: NatashaKnk

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

19 months ago[Clang] Don't consider default constructors ineligible if the more constrained constr...
Roy Jacobson [Sun, 4 Dec 2022 19:02:57 +0000 (21:02 +0200)]
[Clang] Don't consider default constructors ineligible if the more constrained constructor is a template

Partially solves https://github.com/llvm/llvm-project/issues/59206:

We now mark trivial constructors as eligible even if there's a more constrained templated default constructor. Although technically non-conformant, this solves problems with pretty reasonable uses cases like
```
template<int n>
struct Foo {
constexpr Foo() = default;

template<class... Ts>
Foo(Ts... vals) requires(sizeof...(Ts) == n) {}
};
```
where we currently consider the default constructor to be ineligible and therefor inheriting/containing classes have non trivial constructors. This is aligned with GCC: https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=c75ebe76ae12ac4020f20a24f34606a594a40d15

This doesn't change `__is_trivial`. Although we're technically standard conformant in this regard, GCC/MSVC exhibit different behaviors that seem to make more sense. An issue has been filed to CWG and we await their response.

Reviewed By: erichkeane, #clang-language-wg

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

19 months ago[flang] Lower F08 NORM2 intrinsic
Tarun Prabhu [Mon, 5 Dec 2022 20:50:33 +0000 (13:50 -0700)]
[flang] Lower F08 NORM2 intrinsic

The implementation follows the pattern used in comparable intrinsics.
Change the runtime API for Norm2 so it does not expect a mask argument
since the Norm2 intrinsic does not accept a mask in Fortran.

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

19 months ago[Hexagon] Remove leftover debug messages after 87a3f1ab
Krzysztof Parzyszek [Mon, 5 Dec 2022 20:45:03 +0000 (12:45 -0800)]
[Hexagon] Remove leftover debug messages after 87a3f1ab

19 months ago[gn build] Fix build of merge-fdata in a clean build dir
Nico Weber [Mon, 5 Dec 2022 20:42:42 +0000 (15:42 -0500)]
[gn build] Fix build of merge-fdata in a clean build dir

merge-fdata doesn't depend on any libraries except Support,
but it includes headers that require Attributes.inc to exist.
Add a dep that ensures that it does exist.
Corresponds to the intrinsics_gen dep in CMake.

19 months ago[SDAG] Allow scalable vectors in SimplifyDemanded routines
Philip Reames [Mon, 5 Dec 2022 19:59:06 +0000 (11:59 -0800)]
[SDAG] Allow scalable vectors in SimplifyDemanded routines

This is a continuation of the series of patches adding lane wise support for scalable vectors in various knownbit-esq routines.

The basic idea here is that we track a single lane for scalable vectors which corresponds to an unknown number of lanes at runtime. This is enough for us to perform lane wise reasoning on many arithmetic operations.

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

19 months ago[Hexagon] Better detection of impossible completions to perfect shuffles
Krzysztof Parzyszek [Mon, 5 Dec 2022 20:21:21 +0000 (12:21 -0800)]
[Hexagon] Better detection of impossible completions to perfect shuffles

If there is an entry P that has C bits set, it could become one of C
different possibilities. If P occurs more than C times, then there are
no valid completions.

19 months ago[Flang] Restore Flang cmake configuration data
Peter Steinfeld [Mon, 5 Dec 2022 19:50:14 +0000 (11:50 -0800)]
[Flang] Restore Flang cmake configuration data

Patch D138274 removed some Flang cmake configuration information that we
need for our internal builds.  This change restores them.

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

19 months agotest/Transforms/Scalarizer: re-run update_test_checks.py
Nicolai Hähnle [Mon, 5 Dec 2022 09:40:59 +0000 (10:40 +0100)]
test/Transforms/Scalarizer: re-run update_test_checks.py

Goal is to get a cleaner diff in an upcoming functional change.

19 months ago[llvm-objdump][docs] Mention --show-all-symbols
Fangrui Song [Mon, 5 Dec 2022 20:01:01 +0000 (20:01 +0000)]
[llvm-objdump][docs] Mention --show-all-symbols

after D131589

Reviewed By: jhenderson

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

19 months agomlir/TosaToLinalg: improve debugging during conversion
Ramkumar Ramachandra [Mon, 5 Dec 2022 19:15:57 +0000 (11:15 -0800)]
mlir/TosaToLinalg: improve debugging during conversion

Make systematic use of notifyMatchFailure.

Signed-off-by: Ramkumar Ramachandra <r@artagnon.com>
Reviewed By: rsuderman

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

19 months ago[mlir] Fix alias printing for dialect attribute self types
River Riddle [Mon, 5 Dec 2022 19:12:54 +0000 (11:12 -0800)]
[mlir] Fix alias printing for dialect attribute self types

This was donked up in the last patch that only considered
aliases for things actually getting printed.

19 months ago[mlir] Slightly optimize getRegions checks by inlining size check
River Riddle [Mon, 5 Dec 2022 18:40:28 +0000 (10:40 -0800)]
[mlir] Slightly optimize getRegions checks by inlining size check

Calculating the position of the region trailing objects isn't free,
given that it's the last trailing object, and inlining the size check
removes the need for users to explicitly add size checks for
micro-optimization.

19 months ago[NFC] Port all runlines for LoopVectorize pass tests to -passes syntax
Roman Lebedev [Mon, 5 Dec 2022 18:44:25 +0000 (21:44 +0300)]
[NFC] Port all runlines for LoopVectorize pass tests to -passes syntax

19 months agoFix DirectX test build
Chris Bieneman [Mon, 5 Dec 2022 19:12:13 +0000 (13:12 -0600)]
Fix DirectX test build

This broke when some headers got moved aorund.

19 months agoReland "A new hidden option exec-on-ir-change=exe that calls exe each time IR changes"
Jamie Schmeiser [Mon, 5 Dec 2022 19:11:15 +0000 (14:11 -0500)]
Reland "A new hidden option exec-on-ir-change=exe that calls exe each time IR changes"

Summary:
This relands commit dff0e8b4ff13af311512c369d059f1e095e83a60.  The test is now
guarded with a lit.local.cfg that ensures /bin/cat is available.  Also, the
code has been updated to match changes made to relevant code.

Author: Jamie Schmeiser <schmeise@ca.ibm.com>
Reviewed By:aeubanks (Arthur Eubanks)
Differential Revision: https://reviews.llvm.org/D110776

19 months ago[gn build] Port 5ecd36329508
LLVM GN Syncbot [Mon, 5 Dec 2022 18:56:16 +0000 (18:56 +0000)]
[gn build] Port 5ecd36329508

19 months agoReapply "[CodeGen] Add new pass for late cleanup of redundant definitions."
Jonas Paulsson [Mon, 5 Dec 2022 14:14:40 +0000 (08:14 -0600)]
Reapply "[CodeGen] Add new pass for late cleanup of redundant definitions."

This reverts commit 122efef8ee9be57055d204d52c38700fe933c033.

- Patch fixed to not reuse definitions from predecessors in EH landing pads.
- Late review suggestions (by MaskRay) have been addressed.
- M68k/pipeline.ll test updated.
- Init captures added in processBlock() to avoid capturing structured bindings.
- RISCV has this disabled for now.

Original commit message:

A new pass MachineLateInstrsCleanup is added to be run after PEI.

This is a simple pass that removes redundant and identical instructions
whenever found by scanning the MF once while keeping track of register
definitions in a map. These instructions are typically immediate loads
resulting from rematerialization, and address loads emitted by target in
eliminateFrameInde().

This is enabled by default, but a target could easily disable it by means of
'disablePass(&MachineLateInstrsCleanupID);'.

This late cleanup is naturally not "optimal" in removing instructions as it
is done by looking at phys-regs, but still quite effective. It would be
desirable to improve other parts of CodeGen and avoid these redundant
instructions in the first place, but there are no ideas for this yet.

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

Reviewed By: RKSimon, foad, craig.topper, arsenm, asb

19 months ago[flang] Catch attempts to copy pointers in allocatables in PURE
Peter Klausler [Fri, 18 Nov 2022 00:30:49 +0000 (16:30 -0800)]
[flang] Catch attempts to copy pointers in allocatables in PURE

In a pure context, a pointer acquired from an INTENT(IN) dummy argument
may not be copied.  Catch the case in which the pointer is a component
of an allocatable component at some depth of nesting.

(This patch adds a new component iterator kind that is a variant of
a potential subobject component iterator; it visits all potential
subobject components, plus pointers, into which it does not descend.)

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

19 months ago[lldb][Test] TestRerunAndExprDylib.py on Linux: dlclose solib to force destruction...
Michael Buch [Mon, 5 Dec 2022 18:12:56 +0000 (18:12 +0000)]
[lldb][Test] TestRerunAndExprDylib.py on Linux: dlclose solib to force destruction module

Previously we didn't properly trigger the destructor of
the `lldb_private::Module` backing `libfoo.so`. So the newly
rebuilt version wouldn't actually be loaded on a program re-run.
The test expects the fresh module to be loaded.

19 months ago[NFC] Port all runlines for SimplifyCFG pass tests to -passes syntax
Roman Lebedev [Mon, 5 Dec 2022 18:10:54 +0000 (21:10 +0300)]
[NFC] Port all runlines for SimplifyCFG pass tests to -passes syntax

19 months agoAMDGPU: Convert a test to generated checks
Matt Arsenault [Fri, 25 Nov 2022 21:52:01 +0000 (16:52 -0500)]
AMDGPU: Convert a test to generated checks

Also switch to not using kernels to test, since it shouldn't matter
for these addressing modes. This should reduce some of the diffs
between subtargets, but it's still not enough to share the same
checks.

The test could use some additional modernization. Probably should also
round this out with the new maximium offsets.

19 months ago[flang] Fold the RHS of assignment
Peter Klausler [Wed, 16 Nov 2022 00:23:13 +0000 (16:23 -0800)]
[flang] Fold the RHS of assignment

In order to emit overflow warnings from assignment statements whose
right-hand sides are constants that undergo conversions, run the
right-hand sides of assignments through constant folding after the
conversions have been made explicit in expression analysis.

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

19 months ago[flang] Fix pointer association with remap on polymorphic entities
Valentin Clement [Mon, 5 Dec 2022 17:28:13 +0000 (18:28 +0100)]
[flang] Fix pointer association with remap on polymorphic entities

Runtime is expecting a 1d array. This patch fixes the generation
of the array holding the bounds to be passed to the runtime function call.

Reviewed By: jeanPerier, PeteSteinfeld

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

19 months ago[flang] Retrieve rank before updating the pointer
Valentin Clement [Mon, 5 Dec 2022 17:26:16 +0000 (18:26 +0100)]
[flang] Retrieve rank before updating the pointer

The code is iterating on the rank of the pointer to set the bounds.
If the rank is retrieved after the `pointer = target` it does not
reflect the actual rank of the pointer.

This could happen in code like the following:

```
type t1
  integer :: a
end type

type(t), pointer :: p(:)
class(t), pointer :: q(:,:)
q(0:1,-2:2) => p(10:1:-1)
```

Reviewed By: klausler

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

19 months agoExpand loop peeling phi computation to handle binary ops and casts
Jamie Schmeiser [Mon, 5 Dec 2022 17:10:53 +0000 (12:10 -0500)]
Expand loop peeling phi computation to handle binary ops and casts

Summary:
Expand the capabilities of the code for computing how many peels are
needed to make phis determined.  A cast gets the peel count for the
value being casted while a binary op gets the maximum of the operands.

Respond to review comments: remove redundant asserts.

Author: Jamie Schmeiser <schmeise@ca.ibm.com>
Reviewed By:mkazantsev (Max Kazantsev),syzaara (Zaara Syeda)
Differential Revision: https://reviews.llvm.org/D138719

19 months agoSupport `transpose` mode for `gpu.subgroup` WMMA ops
Navdeep Katel [Mon, 5 Dec 2022 10:44:56 +0000 (16:14 +0530)]
Support `transpose` mode for `gpu.subgroup` WMMA ops

Add support for loading, computing, and storing `gpu.subgroup` WMMA ops
in transpose mode as well. Update the GPU to NVVM lowerings to support
`transpose` mode and update integration tests as well.

Reviewed By: ThomasRaoux

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

19 months ago[InstCombine] Increase test coverage of vector.reverse ready for follow on work.
Paul Walker [Mon, 21 Nov 2022 16:56:55 +0000 (16:56 +0000)]
[InstCombine] Increase test coverage of vector.reverse ready for follow on work.

19 months agoAMDGPU: Bulk update memory legalizer tests to use opaque pointers
Matt Arsenault [Mon, 5 Dec 2022 16:45:17 +0000 (11:45 -0500)]
AMDGPU: Bulk update memory legalizer tests to use opaque pointers

19 months agoReland "[lldb][Target] Flush the scratch TypeSystem when owning lldb_private::Module...
Michael Buch [Fri, 25 Nov 2022 14:45:09 +0000 (14:45 +0000)]
Reland "[lldb][Target] Flush the scratch TypeSystem when owning lldb_private::Module gets unloaded"

This relands commit `71f3cac7895ad516ec25438f803ed3c9916c215a`

Fixes LLDB Linux bots and improves TypeSystem flushing for shared libraries.

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

19 months agoDAG: ComputeNumSignBits from load range metadata
Matt Arsenault [Mon, 4 Jun 2018 10:12:39 +0000 (13:12 +0300)]
DAG: ComputeNumSignBits from load range metadata

The cases where the result type doesn't match the range type
are inadequately tested, but I'm not sure how to write such a
test. During the pre-legalize combine, any obviously optimizable
code gets handled so it's harder to test legalized extloads.

19 months agoAMDGPU: Add baseline tests for known sign bits of load range metadata
Matt Arsenault [Sat, 12 Nov 2022 18:55:48 +0000 (10:55 -0800)]
AMDGPU: Add baseline tests for known sign bits of load range metadata

19 months ago[SDAG] Allow scalable vectors in ComputeKnownBits (try 2)
Philip Reames [Mon, 5 Dec 2022 16:49:42 +0000 (08:49 -0800)]
[SDAG] Allow scalable vectors in ComputeKnownBits (try 2)

This was previously reverted due to a hang on a Hexagon bot.  This turned out to be a bug in the Hexagon backend around how splat_vectors are legalized (which they're using for fixed length vectors!).  I adjusted this patch to remove the implicit truncate support.  This hides the hexagon bug for now, and unblocks the rest of the change.

Original commit message:

This is the SelectionDAG equivalent of D136470, and is thus an alternate patch to D128159.

The basic idea here is that we track a single lane for scalable vectors which corresponds to an unknown number of lanes at runtime. This is enough for us to perform lane wise reasoning on many arithmetic operations.

This patch also includes an implementation for SPLAT_VECTOR as without it, the lane wise reasoning has no base case. The original patch which inspired this (D128159), also included STEP_VECTOR. I plan to do that as a separate patch.

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

19 months ago[ConstraintElim] Queue facts and checks directly.
Florian Hahn [Mon, 5 Dec 2022 16:44:19 +0000 (16:44 +0000)]
[ConstraintElim] Queue facts and checks directly.

This allows interleaving facts and checks in a single block. In
particular this enables using facts from assumes for conditions in the
same block that come after the assume.

This could be extended to only try to simplify checks at the point where
a condition is used.

Reviewed By: nikic

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

19 months agoPGOProfile: Only keep opaque pointer tests
Matt Arsenault [Sat, 26 Nov 2022 22:23:01 +0000 (17:23 -0500)]
PGOProfile: Only keep opaque pointer tests

The typed pointer tests were already converted, these were identical
now.

19 months agoPredicateInfo: Convert test to opaque pointers
Matt Arsenault [Sat, 26 Nov 2022 20:43:31 +0000 (15:43 -0500)]
PredicateInfo: Convert test to opaque pointers

Drops the "has predicate info" for the first block.

19 months ago[NFC][PatternMatch] Add helper for m_Intrinsic<Intrinsic::experimental_vector_reverse>.
Paul Walker [Mon, 21 Nov 2022 17:35:49 +0000 (17:35 +0000)]
[NFC][PatternMatch] Add helper for m_Intrinsic<Intrinsic::experimental_vector_reverse>.

19 months ago[ConstraintElim] Add test subtracting SIGNED_MIN.
Florian Hahn [Mon, 5 Dec 2022 16:32:45 +0000 (16:32 +0000)]
[ConstraintElim] Add test subtracting SIGNED_MIN.

19 months ago[Instcombine] Precommit tests for some or canonicalization; NFC
chenglin.bi [Mon, 5 Dec 2022 16:31:58 +0000 (00:31 +0800)]
[Instcombine] Precommit tests for some or canonicalization; NFC
~((A & B) ^ (A | ?)) -> (A & B) | ~(A | ?)
~(A & B) ^ (A | ?) -> (A & B) | ~(A | ?)

19 months ago[clang][Interp][NFC] Move to std::optional
Timm Bäder [Mon, 5 Dec 2022 16:30:24 +0000 (17:30 +0100)]
[clang][Interp][NFC] Move to std::optional

19 months ago[Instcombine] Precommit tests for D139080; NFC
chenglin.bi [Mon, 5 Dec 2022 16:23:28 +0000 (00:23 +0800)]
[Instcombine] Precommit tests for D139080; NFC
Test pattern for
(C & X) | ~(C | Y) -> C ? X : ~Y

19 months ago[NFC][WebAssembly] Add codegen tests
Samuel Parker [Mon, 5 Dec 2022 16:01:36 +0000 (16:01 +0000)]
[NFC][WebAssembly] Add codegen tests

19 months agoExecutionEngine: Convert tests to opaque pointers
Matt Arsenault [Sun, 27 Nov 2022 18:47:09 +0000 (13:47 -0500)]
ExecutionEngine: Convert tests to opaque pointers

19 months ago[InstCombine] Precommit tests for D139253; NFC
chenglin.bi [Mon, 5 Dec 2022 16:00:54 +0000 (00:00 +0800)]
[InstCombine] Precommit tests for D139253; NFC

19 months ago[lld/mac] Fix --start-lib/--end-lib with split thinlto inputs
Nico Weber [Fri, 2 Dec 2022 14:29:18 +0000 (09:29 -0500)]
[lld/mac] Fix --start-lib/--end-lib with split thinlto inputs

Fixes #59162. The test has a comment explaining what's going on.
See also Symbol::extract() in lld/ELF/Symbols.cpp.

The included test sadly also passes if I pass just bd448f01a62,
while doing that isn't enough to make my bigger repro case work
(if I port just that, something else asserts later on, but with
this fix here everything's fine in my bigger repro).

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