Commit Graph

423581 Commits

Author SHA1 Message Date
Quentin Colombet 9766fed9c1 [DeadArgElim] Re-apply: Set unused arguments for internal functions
The re-apply includes fixes to clang tests that were missed in
the original commit.

Original message:
Prior to this patch we would only set to undef the unused arguments of the
external functions. The rationale was that unused arguments of internal
functions wouldn't need to be turned into undef arguments because they
should have been simply eliminated by the time we reach that code.

This is actually not true because there are plenty of cases where we can't
remove unused arguments. For instance, if the internal function is used in
an indirect call, it may not be possible to change the function signature.
Yet, for statically known call-sites we would still like to mark the unused
arguments as undef.

This patch enables the "set undef arguments" optimization on internal
functions when we encounter cases where internal functions cannot be
optimized. I.e., whenever an internal function is marked "live".

Differential Revision: https://reviews.llvm.org/D124699
2022-05-12 08:46:16 -07:00
Chris Lattner 3cce374ee6 Various improvements suggested by river NFC.
Differential Revision: https://reviews.llvm.org/D125471
2022-05-12 16:18:23 +01:00
Chris Lattner f21896f2c6 [DenseElementAttr] Simplify the public API for creating these.
Instead of requiring the client to compute the "isSplat" bit,
compute it internally.  This makes the logic more consistent
and defines away a lot of "elements.size()==1" in the clients.

This addresses Issue #55185

Differential Revision: https://reviews.llvm.org/D125447
2022-05-12 16:18:23 +01:00
Eric Schweitz 6822ed035f Fixes a performance problem with lowering of forall loops and creating
too many temporaries.

Fix clang-format errors.

Differential Revision: https://reviews.llvm.org/D125336
2022-05-12 08:11:58 -07:00
Fraser Cormack 1106bc208c [CodeGen][NFC] Move some comments from the end of lines to above them
This avoids wrapping the line itself awkwardly when it exceeds 80 chars.
It also better matches our style most other places.
2022-05-12 15:45:04 +01:00
Jeremy Morse a975472fa6 [DebugInfo][InstrRef] Describe value sizes when spilt to stack
This is a re-apply of D123599, which was reverted in 4fe2ab5279, now
with a more appropriate assertion. Original commit message follow:

InstrRefBasedLDV can track and describe variable values that are spilt to
the stack -- however it does not current describe the size of the value on
the stack. This can cause uninitialized bytes to be read from the stack if
a small register is spilt for a larger variable, or theoretically on
big-endian machines if a large value on the stack is used for a small
variable.

Fix this by using DW_OP_deref_size to specify the amount of data to load
from the stack, if there's any possibility for ambiguity. There are a few
scenarios where this can be omitted (such as when using DW_OP_piece and a
non-DW_OP_stack_value location), see deref-spills-with-size.mir for an
explicit table of inputs flavours and output expressions.

Differential Revision: https://reviews.llvm.org/D123599
2022-05-12 15:52:55 +01:00
Pavel Samolysov 098afdb0a0 [ArgPromotion] Make a non-byval promotion attempt first
It makes sense to make a non-byval promotion attempt first and then
fall back to the byval one. The non-byval ('usual') promotion is
generally better, for example it does promotion even when a structure
has more elements than 'MaxElements' but not all of them are actually
used in the function.

Differential Revision: https://reviews.llvm.org/D124514
2022-05-12 16:44:52 +02:00
Richard Howell ee51e9795a [clang] serialize ORIGINAL_PCH_DIR relative to BaseDirectory
This diff changes the serialization of the `ORIGINAL_PCH_DIR`
entry in module files to be serialized relative to the module's
`BaseDirectory`. This will allow for the module to be relocatable
across machines.

The path is restored relative to the module's BaseDirectory on
deserialization.

Reviewed By: urnathan

Differential Revision: https://reviews.llvm.org/D124946
2022-05-12 07:31:19 -07:00
Richard Howell f11056943e [clang] serialize SUBMODULE_TOPHEADER relative to BaseDirectory
This diff changes the serialization of the `SUBMODULE_TOPHEADER`
entry in module files to be serialized relative to the module's
`BaseDirectory`. This matches the behavior of the
`SUBMODULE_HEADER` entry and will allow for the module to be
relocatable across machines.

The path is restored relative to the module's `BaseDirectory` on
deserialization.

Reviewed By: urnathan

Differential Revision: https://reviews.llvm.org/D124938
2022-05-12 07:29:37 -07:00
Richard Howell 646e502de0 [clang] add -fmodule-file-home-is-cwd
This diff adds a new frontend flag `-fmodule-file-home-is-cwd`.
The behavior of this flag is similar to
`-fmodule-map-file-home-is-cwd` but does not require the module
map files to be modified to have inputs relative to the cwd.
Instead the output modules will have their `BaseDirectory` set
to the cwd and will try and resolve paths relative to that.

The motiviation for this change is to support relocatable pcm
files that are built on different machines with different paths
without having to alter module map files, which is sometimes not
possible as they are provided by 3rd parties.

Reviewed By: urnathan

Differential Revision: https://reviews.llvm.org/D124874
2022-05-12 07:27:47 -07:00
serge-sans-paille 40d3a0ba4d [openmp] Fix strict aliasing issue in cmpxchg routine
Avoid warning under -fstrict-aliasing by using a call to memcpy to perform type
punning.

Differential Revision: https://reviews.llvm.org/D125467
2022-05-12 16:14:48 +02:00
Nikita Popov 44d85259d0 [AArch64] Preserve chain when lowering fixed length load to SVE (PR55281)
When a fixed length load is lowered to an SVE masked load, the
result chain is currently set to the input chain of the old load,
rather than the result chain of the new load. This may cause stores
to be incorrectly reordered.

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

Differential Revision: https://reviews.llvm.org/D125464
2022-05-12 16:03:32 +02:00
Tomasz Kamiński 14742443a2 Reland "[analyzer] Canonicalize SymIntExpr so the RHS is positive when possible"
This PR changes the `SymIntExpr` so the expression that uses a
negative value as `RHS`, for example: `x +/- (-N)`, is modeled as
`x -/+ N` instead.

This avoids producing a very large `RHS` when the symbol is cased to
an unsigned number, and as consequence makes the value more robust in
presence of casts.

Note that this change is not applied if `N` is the lowest negative
value for which negation would not be representable.

Reviewed By: steakhal

Patch By: tomasz-kaminski-sonarsource!

Differential Revision: https://reviews.llvm.org/D124658
2022-05-12 15:40:11 +02:00
Thomas Raoux d02f10d96d [mlir][vector] Add lowering pattern for vector.warp_execute_on_lane_0 op
Add lowering of the vector.warp_execute_on_lane_0 into scf.if plus memory
transfer for the operands and yield values.

This also add an integration test running on GPU warp. The same tests can be
later re-used with different comment lines to tests distribution
transformations.

This is mostly from @springerm contribution.

Differential Revision: https://reviews.llvm.org/D125430
2022-05-12 13:27:43 +00:00
Ken Matsui a1545f51a9 Warn if using `elifdef` & `elifndef` in not C2x & C++2b mode
This adds an extension warning when using the preprocessor conditionals
in a language mode they're not officially supported in, and an opt-in
warning for compatibility with previous standards.

Fixes #55306
Differential Revision: https://reviews.llvm.org/D125178
2022-05-12 09:26:44 -04:00
Pedro Olsen Ferreira 28a0b94d22 Rename and fix ValueMap::resize to reserve
The underlying map type (DenseMap) has had its resize() function
renamed to reserve() as part of
c04fc7a60f (SVN 264026).

This is only visible when the member function is called, as it is
template type name dependent.

Differential Revision: https://reviews.llvm.org/D125387
2022-05-12 13:44:47 +01:00
Martin Storsjö 2d8ce08b09 [AArch64] Stop creating unnecessary label MCSymbols for each Windows unwind opcode. NFC.
These labels aren't needed in the ARM version of WinEH tables, as each
unwind opcode maps to a specific instruction (each opcode is assumed
to represent one instruction), and the written tables don't contain
offsets like on x86_64.

Differential Revision: https://reviews.llvm.org/D125369
2022-05-12 15:23:04 +03:00
Martin Storsjö 490cd14fe6 [MC] [Win64EH] Simplify code using WinEH::Instruction::operator!=. NFC.
operator== and operator!= were added in
1308bb99e0 / D87369, but this existing
codepath wasn't updated to use them.

Also fix the indentation of the enclosed liens.

Differential Revision: https://reviews.llvm.org/D125368
2022-05-12 15:23:04 +03:00
Benjamin Kramer 303638248a [mlir][linalg] Add lowering of named ops on complex numbers
This lets linalg.dot and friends lower to a complex muladd using ops
from the complex dialect.

Differential Revision: https://reviews.llvm.org/D125461
2022-05-12 13:37:34 +02:00
owenca b6d8c84f28 [clang-format] Don't remove braces if a 1-statement body would wrap
Reimplement the RemoveBracesLLVM feature which handles a
single-statement block that would get wrapped.

Fixes #53543.

Differential Revision: https://reviews.llvm.org/D125137
2022-05-12 03:53:08 -07:00
Nikita Popov 50f846d634 [FastISel] Add some debug output (NFC)
Print a debug message when aborting isel (next to the ORE report)
and when folding a load.
2022-05-12 12:25:20 +02:00
Benjamin Kramer ca6cbbe8d0 [bazel] Add support for configuring the bazel build for PPC
TF already carries a patch for this.
2022-05-12 12:04:14 +02:00
Benjamin Kramer 27dad99622 [mlir][LLVM] Make the nested type restriction on complex constants less aggressive
Complex nested in other types is perfectly fine, just nested structs
aren't supported. Instead of checking whether there's nesting just check
whether the struct we're dealing with is a complex number.

Differential Revision: https://reviews.llvm.org/D125381
2022-05-12 11:47:01 +02:00
Max Kazantsev 2a40cc532b [Test] Regenerate checks using auto-update (work around PR55365) 2022-05-12 16:09:11 +07:00
Dmitry Vassiliev 7b22cf12ef [Intrinsics] Fix `nvvm_prmt` intrinsic attributes
`nvvm_prmt` doesn't seem to be `commutative`. nvvm also sets `IntrSpeculatable` for it.
Here is the doc https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#data-movement-and-conversion-instructions-prmt

Reviewed By: tra, jchlanda

Differential Revision: https://reviews.llvm.org/D125423
2022-05-12 10:46:03 +02:00
Daniil Dudkin 70c463efc8 [mlir][NFC] Fix `GpuKernelOutliningPass` copy constructor warnings
1. Call copy constructor of the base class
2. Assign value of the option directly

Reviewed By: dcaballe, rriddle

Differential Revision: https://reviews.llvm.org/D125101
2022-05-12 11:41:18 +03:00
Ivan Kosarev bf5fc0d603 [AMDGPU][NFC] Remove unused function.
Introduced in
https://reviews.llvm.org/rG229d5e669bbbe7ca38ad832627a9809405939f1b

and then became unused in
https://reviews.llvm.org/D19584

Reviewed By: foad, dp

Differential Revision: https://reviews.llvm.org/D125385
2022-05-12 08:52:06 +01:00
Nikita Popov f02716a806 [MLIR] Fix build without native arch
D125214 split off a MLIRExecutionEngineUtils library that is used
by MLIRGPUTransforms. However, currently the entire ExecutionEngine
directory is skipped if the LLVM_NATIVE_ARCH target is not available.

Move the check for LLVM_NATIVE_ARCH, such that MLIRExecutionEngineUtils
always gets built, and only the JIT-related libraries are omitted
without native arch.

Differential Revision: https://reviews.llvm.org/D125357
2022-05-12 09:50:51 +02:00
Ivan Kosarev cb67b2ccc4 [AMDGPU][GFX10] Support base+soffset+offset SMEM stores.
Also makes another step towards resolving
https://github.com/llvm/llvm-project/issues/38652

Reviewed By: foad, dp

Differential Revision: https://reviews.llvm.org/D125380
2022-05-12 08:48:05 +01:00
Matthias Springer 82ea0d8b82 [mlir][bufferize] Support alloc hoisting across function boundaries
This change integrates the BufferResultsToOutParamsPass into One-Shot Module Bufferization. This improves memory management (deallocation) when buffers are returned from a function.

Note: This currently only works with statically-sized tensors. The generated code is not very efficient yet and there are opportunities for improvment (fewer copies). By default, this new functionality is deactivated.

Differential Revision: https://reviews.llvm.org/D125376
2022-05-12 09:44:07 +02:00
Matthias Springer 2fe40c34ea [mlir][bufferize] Fix op filter
Bufferization has an optional filter to exclude certain ops from analysis+bufferization. There were a few remaining places in the codebase where the filter was not checked.

Differential Revision: https://reviews.llvm.org/D125356
2022-05-12 09:33:07 +02:00
Tim Northover 7b53a45e14 Revert "Add an error message to the default SIGPIPE handler"
It broke a PPC bot, for not immediately obvious reasons.
2022-05-12 08:31:20 +01:00
Matthias Springer 011f1b1c1f [mlir][bufferize] Add helpers for templatized DENY filters
We already have templatized ALLOW filters but the DENY filters were missing.

Differential Revision: https://reviews.llvm.org/D125358
2022-05-12 09:18:21 +02:00
Carl Ritson 698fda0e3e [AMDGPU] Remove pre-committed test for D124981. NFC. 2022-05-12 16:04:26 +09:00
Tim Northover e845f899e6 Add an error message to the default SIGPIPE handler
UNIX03 conformance requires utilities to flush stdout before exiting and raise
an error if writing fails. Flushing already happens on a call to exit
and thus automatically on a return from main. Write failure is then
detected by LLVM's default SIGPIPE handler. The handler already exits with
a non-zero code, but conformance additionally requires an error message.
2022-05-12 08:00:06 +01:00
Krasimir Georgiev 52328dafda silence new -Wunused-result warnings in test
No functional changes intended.

After f156b51aec,
new -Wunused-result warnings popped up in this test:
https://buildkite.com/llvm-project/upstream-bazel/builds/28320#bc3ec049-af39-4114-b7b8-4cbc180bc09b
2022-05-12 08:30:36 +02:00
River Riddle 1155c1fe65 [mlir:Parser] Emit a better diagnostic when a custom operation is unknown
When a custom operation is unknown and does not have a dialect prefix, we currently
emit an error using the name of the operation with the default dialect prefix. This
leads to a confusing error message, especially when operations get moved between dialects.
For example, `func` was recently moved out of `builtin` and to the `func` dialect. The current
error message we get is:

```
func @foo()
^ custom op 'builtin.func' is unknown
```

This could lead users to believe that there is supposed to be a `builtin.func`,
because there used to be. This commit adds a better error message that does
not assume that the operation is supposed to be in the default dialect:

```
func @foo()
^ custom op 'func' is unknown (tried 'builtin.func' as well)
```

Differential Revision: https://reviews.llvm.org/D125351
2022-05-11 22:54:44 -07:00
Mahesh Ravishankar 8be7e6f56a [mlir][Linalg] Combine canonicalizers that deal with removing dead/redundant args.
`linalg.generic` ops have canonicalizers that either remove arguments
not used in the payload, or redundant arguments. Combine these and
enhance the canonicalization to also remove results that have no use.
This is effectively dead code elimination for Linalg ops.

Differential Revision: https://reviews.llvm.org/D123632
2022-05-12 05:22:30 +00:00
Mogball 0ffef0c23b [mlir][ods] (NFC) don't use std::function for map_range 2022-05-12 05:15:03 +00:00
Mogball 19906262c9 [mlir] (NFC) Use assembly format for test.graph_region 2022-05-12 04:19:25 +00:00
bzcheeseman bc22b5c9a2 [MLIR][Operation] Simplify Operation casting, NFC
We can simplify the code needed to implement dyn_cast/cast/isa support for MLIR operations with documented interfaces via the CastInfo structures. This will also provide an example of how to use CastInfo.

Depends on D123901

Reviewed By: rriddle

Differential Revision: https://reviews.llvm.org/D124963
2022-05-12 00:17:01 -04:00
bzcheeseman f156b51aec [LLVM][Casting.h] Update dyn_cast machinery to provide more control over how the casting is performed.
This patch expands the expressive capability of the casting utilities in LLVM by introducing several levels of configurability. By creating modular CastInfo classes we can enable projects like MLIR that need more fine-grained control over how a cast is actually performed to retain that control, while making it easy to express the easy cases (like a checked pointer to pointer cast).

The current implementation of Casting.h doesn't make it clear where the entry points for customizing the cast behavior are, so part of the motivation for this patch is adding that documentation. Another part of the motivation is to support using LLVM RTTI with a wider set of use cases, such as nullable value to value casts, or pointer to value casts (as in MLIR).

Reviewed By: lattner, rriddle

Differential Revision: https://reviews.llvm.org/D123901
2022-05-12 00:15:09 -04:00
Fangrui Song bb353df589 [Bitcode] Simplify code after FUNC_CODE_BLOCKADDR_USERS changes (D124878)
Switch to the more common `Constant && !GlobalValue` test.
Use the more common `Worklist/Visited` variable names.
2022-05-11 20:27:12 -07:00
Jim Lin 50f5cef391 [BPF] Implement mod operation
Implement BPF_MOD instruction to fix lack of assembly parser support mentioned in https://github.com/llvm/llvm-project/issues/55192.

Reviewed By: ast

Differential Revision: https://reviews.llvm.org/D125207
2022-05-12 10:59:18 +08:00
Lian Wang 9176096c86 [LegalizeVectorTypes] Enable WidenVecRes_SETCC work for scalable vector.
Reviewed By: frasercrmck

Differential Revision: https://reviews.llvm.org/D125359
2022-05-12 02:52:43 +00:00
Ping Deng 995d38925b [RISCV][NFC] Simplify tests by reorganizing check prefixes
Reviewed By: benshi001, asb

Differential Revision: https://reviews.llvm.org/D125354
2022-05-12 02:22:56 +00:00
grosul1 a4b227c28a [mlir] Fix loop unrolling: properly replace the arguments of the epilogue loop.
Using "replaceUsesOfWith" is incorrect because the same initializer value may appear multiple times.

For example, if the epilogue is needed when this loop is unrolled
```
%x:2 = scf.for ... iter_args(%arg1 = %c1, %arg2 = %c1) {
  ...
}
```
then both epilogue's arguments will be incorrectly renamed to use the same result index (note #1 in both cases):
```
%x_unrolled:2 = scf.for ... iter_args(%arg1 = %c1, %arg2 = %c1) {
  ...
}
%x_epilogue:2 = scf.for ... iter_args(%arg1 = %x_unrolled#1, %arg2 = %x_unrolled#1) {
  ...
}
```
2022-05-12 01:54:39 +00:00
Weining Lu 24532d05f8 [LoongArch] Check msb is not less than lsb for the bstr{ins/pick}.{w/d} instructions
Differential Revision: https://reviews.llvm.org/D124825
2022-05-12 09:31:44 +08:00
David Tenty 9519dacab7 Revert "[NFC][tests][AIX] XFAIL test for lack of visibility support"
This reverts commit f5a9b5cc12 since
https://reviews.llvm.org/D125141 has resolved the test issue.
2022-05-11 20:47:48 -04:00
Tapan Thaker d64bad8ff1
[lld/macho] Fixes the -ObjC flag
When checking the segment name for Swift symbols, we should be checking that they start with `__swift` instead of checking for equality

Fixes the issue https://github.com/llvm/llvm-project/issues/55355

Reviewed By: #lld-macho, keith, thevinster

Differential Revision: https://reviews.llvm.org/D125250
2022-05-11 17:00:39 -07:00