platform/upstream/llvm.git
16 months ago[AArch64] Fix a warning
Kazu Hirata [Mon, 27 Feb 2023 20:56:19 +0000 (12:56 -0800)]
[AArch64] Fix a warning

This patch fixes:

  llvm/lib/Target/AArch64/AArch64MIPeepholeOpt.cpp:582:17: error:
  unused variable 'INSvilaneMI' [-Werror,-Wunused-variable]

16 months ago[SPIR-V] Support TargetExtType for SPIR-V builtin types
Michal Paszkowski [Mon, 27 Feb 2023 20:26:09 +0000 (21:26 +0100)]
[SPIR-V] Support TargetExtType for SPIR-V builtin types

This patch adds support for TargetExtType/target(...) representing
SPIR-V builtin types. After D135202, target(...) is the preferred way
for representing SPIR-V builtin types in LLVM IR and the only working
in the opaque pointer mode.

In order to maintain compatibility with LLVM IR generated by older
versions of Clang and LLVM/SPIR-V Translator, pointers-to-opaque-structs
denoting SPIR-V/OpenCL builtin types will be translated to equivalent
SPIR-V target extension types. This translation is only available in the
typed pointer mode (-opaque-pointers=0).

The relevant LIT tests with SPIR-V builtins were converted to use the
new target(...) notation.

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

16 months ago[SLP] Fixes crash in BoUpSLP::isGatherShuffledEntry()
Vasileios Porpodas [Mon, 27 Feb 2023 18:44:14 +0000 (10:44 -0800)]
[SLP] Fixes crash in BoUpSLP::isGatherShuffledEntry()

Crash caused by: 708eb1b96d9a36f9c0182b7d53c492059778fa35

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

16 months ago[AArch64] Avoid using intermediate integer registers for copying between source and...
Nilanjana Basu [Thu, 26 Jan 2023 01:35:31 +0000 (17:35 -0800)]
[AArch64] Avoid using intermediate integer registers for copying between source and destination floating point registers

In post-isel code, there are cases where there were redundant copies from a source FPR to an intermediate GPR in order to copy to a destination FPR. In this patch, we identify these patterns in post-isel peephole optimization and replace them with a direct FPR-to-FPR copy.
One example for this will be the insertion of the scalar result of 'uaddlv' neon intrinsic function into a destination vector. During instruction selection phase, 'uaddlv' result is copied to a GPR, & a vector insert instruction is matched separately to copy the previous result to a destination SIMD&FP register.

Reviewed By: dmgreen

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

16 months ago[Clang] [AVR] Fix USHRT_MAX for 16-bit int.
Daniel Thornburgh [Sun, 6 Feb 2022 13:20:54 +0000 (08:20 -0500)]
[Clang] [AVR] Fix USHRT_MAX for 16-bit int.

For AVR, the definition of USHRT_MAX overflows.

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

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

16 months ago[clang-format-diff] Correctly parse start-of-file diffs
Tamir Duberstein [Mon, 27 Feb 2023 20:02:51 +0000 (20:02 +0000)]
[clang-format-diff] Correctly parse start-of-file diffs

Handle the case where the diff is a pure removal of lines. Before this
change start_line would end up as 0 which is rejected by clang-format.

Submitting on behalf of @tamird.

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

16 months ago[Pass][CHR] Move ControlHeightReduction to module optimization pipeline
Rong Xu [Mon, 27 Feb 2023 17:51:28 +0000 (09:51 -0800)]
[Pass][CHR] Move ControlHeightReduction to module optimization pipeline

This is a modified version of commit b374423304a8 by
Arthur (https://reviews.llvm.org/D143424).

Here we invoke to the pass independent of PGOOPT. We now check if the
profile is available through the program summary. This ensures CHR is
called in distributed ThinLTO BE compilation (where PGOOPT might not
be created).

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

16 months ago[SCEV] Hoist common cleanup code to function. (NFC)
Florian Hahn [Mon, 27 Feb 2023 19:38:39 +0000 (20:38 +0100)]
[SCEV] Hoist common cleanup code to function. (NFC)

This allows for easier updating of common code in follow-on patches.

Reviewed By: nikic

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

16 months ago[AArch64][GlobalISel] Reorder stack up-adjustment and register copies
Amara Emerson [Mon, 27 Feb 2023 19:02:37 +0000 (11:02 -0800)]
[AArch64][GlobalISel] Reorder stack up-adjustment and register copies

This change reorders the stack up-adjustment and return value copying phases of
machine-ir generation on Aarch64. Doing so prevents a bug observed for fastcc
calls with >8 arguments, where the up-adjustment required from making that call
is placed in the wrong place relative to spill and reloading code.

See: https://github.com/llvm/llvm-project/issues/60972 for full issue
reproduction and context.

Patch contributed by Bruce Collie

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

16 months ago[AArch64] Don't remove free sext_inreg(vector_extract(x)) if it leads to multiple...
David Green [Mon, 27 Feb 2023 19:20:10 +0000 (19:20 +0000)]
[AArch64] Don't remove free sext_inreg(vector_extract(x)) if it leads to multiple extracts

If we have sext_inreg(vector_extract(x)) but the top bits are not used, DAG
will try to remove the sext_inreg, using vector_extract(x) directly. This can
lead to multiple uses of both sext_inreg(vector_extract(x)) and
vector_extract(x), leading to the generation of both umov and smov extracts.
This adds a target hook to prevent that under AArch64 where the sext_inreg can
be considered free if there are multiple uses of the sext and no uses of the
vector_extract. This helps fix a small regression from D144550.

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

16 months ago[MLIR] Add primitive builders for scf.if
Frederik Gossen [Mon, 27 Feb 2023 18:52:15 +0000 (13:52 -0500)]
[MLIR] Add primitive builders for scf.if

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

16 months ago[scudo] Only prepare PageMap entry for partial region
Chia-hung Duan [Fri, 24 Feb 2023 04:20:30 +0000 (04:20 +0000)]
[scudo] Only prepare PageMap entry for partial region

This reduces the size of PageMap and we are more likely to use the
static local buffer. Note that now this is only supported for single
region case, i.e. on SizeClassAllocator64. For SizeClassAllocator32,
it needs a different way to save the PageMap.

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

16 months ago[libc++][NFC] Format __split_buffer and move constructors that are marked inline...
Nikolas Klauser [Tue, 24 Jan 2023 08:32:31 +0000 (09:32 +0100)]
[libc++][NFC] Format __split_buffer and move constructors that are marked inline into the class body

Reviewed By: ldionne, #libc

Spies: libcxx-commits

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

16 months ago[libc++] Simplify the modules_include.sh.cpp script a bit
Nikolas Klauser [Sun, 26 Feb 2023 14:57:25 +0000 (15:57 +0100)]
[libc++] Simplify the modules_include.sh.cpp script a bit

Reviewed By: #libc, ldionne

Spies: vvereschaka, libcxx-commits

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

16 months ago[libc++] Improves clang-format settings.
Mark de Wever [Fri, 24 Feb 2023 20:35:41 +0000 (21:35 +0100)]
[libc++] Improves clang-format settings.

Add a new test based .clang-format file which inherits from the generic
one. This moves some test specific formatting rules to the test
directory.

The main benefit is that headers are sorted, which makes it more likely
to catch these errors before creating a review instead of spotting the
error in the CI clang-tidy step.

Reviewed By: ldionne, philnik, #libc

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

16 months ago[libc++] Fixes operator& hijacking atomic types.
Mark de Wever [Sat, 25 Feb 2023 14:24:57 +0000 (15:24 +0100)]
[libc++] Fixes operator& hijacking atomic types.

This uses std::addressof everywherein atomic. This is not strictly
needed for the integral and floating point specializations. They should
not be used by user defined types. But it's easier to fix everything.

Note these changes are made using a WIP clang-tidy plugin.

Reviewed By: #libc, ldionne

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

16 months ago[LLVMContextImpl] Separate out integer constant ones
Arthur Eubanks [Fri, 24 Feb 2023 05:47:03 +0000 (21:47 -0800)]
[LLVMContextImpl] Separate out integer constant ones

Very small compile time improvement:
https://llvm-compile-time-tracker.com/compare.php?from=6a7a8907e8334eaf551742148079c628f78e6ed7&to=454d1181fbdb9121f0c7a3ecf526520db32ab420&stat=instructions:u

Reviewed By: nikic

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

16 months ago[LLVMContextImpl] Separate out integer constant zeroes
Arthur Eubanks [Fri, 24 Feb 2023 05:16:27 +0000 (21:16 -0800)]
[LLVMContextImpl] Separate out integer constant zeroes

Very small compile time improvement:
https://llvm-compile-time-tracker.com/compare.php?from=a628ca4925f7249b4fbd3e932c9627b12e2770dd&to=6a7a8907e8334eaf551742148079c628f78e6ed7&stat=instructions:u

Reviewed By: nikic

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

16 months ago[SLP]Fix PR61018: Assertion `Mask[I] == UndefMaskElem && "Multiple uses
Alexey Bataev [Mon, 27 Feb 2023 17:20:49 +0000 (09:20 -0800)]
[SLP]Fix PR61018: Assertion `Mask[I] == UndefMaskElem && "Multiple uses
of scalars."' failed.

Need to check for the reused indices when checking if 2 insertelement
instruction are from the same buildvector. If the inidices are reused,
better not to match buildvectors and consider them as differenet,
otherwise need to track the order of insertelement operations.

16 months ago[AMDGPU] Update the CHECK autogenerated as it's expired
zhongyunde [Mon, 27 Feb 2023 18:00:43 +0000 (02:00 +0800)]
[AMDGPU] Update the CHECK autogenerated as it's expired

Reviewed By: nikic
Differential Revision: https://reviews.llvm.org/D144771

16 months ago[Sema] Use isSVESizelessBuiltinType instead of isSizelessBuiltinType to prevent crash...
Craig Topper [Mon, 27 Feb 2023 17:19:27 +0000 (09:19 -0800)]
[Sema] Use isSVESizelessBuiltinType instead of isSizelessBuiltinType to prevent crashing on RISC-V.

These 2 spots are protecting calls to SVE specific functions. If RISC-V
sizeless types end up in there we trigger assertions.

Use the more specific isSVESizelessBuiltinType() to avoid letting
RISC-V vectors through.

Reviewed By: asb, c-rhodes

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

16 months ago[Flang][OpenMP][OpenACC] Error for loop with no control
Kiran Chandramohan [Mon, 27 Feb 2023 16:42:42 +0000 (16:42 +0000)]
[Flang][OpenMP][OpenACC] Error for loop with no control

Issue error if a DO construct associated with a loop does not have
loop control. Currently, it is issued only for the loop immediately
following the loop construct. This patch extends it to cases like
collapse where there is more than one loop associated. It also fixes
a crash since the existing code always expects loop control.

This is covered in OpenMP 4.5 standard, Section 2.7.1.
"The do-loop cannot be a DO WHILE or a DO loop without loop control."

OpenACC 3.3 covers this indirectly in Section 2.9.1.
The trip count for all loops associated with the collapse clause must
be computable and invariant in all the loops".

Reviewed By: clementval

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

16 months ago[OpenMP] Ignore implicit casts on assertion for `use_device_ptr`
Joseph Huber [Mon, 27 Feb 2023 14:46:32 +0000 (08:46 -0600)]
[OpenMP] Ignore implicit casts on assertion for `use_device_ptr`

There was an assertion triggering when invoking a captured member whose
initializer was in a blase class. This patch fixes it by allowing the
assertion on implicit casts to the base class rather than only the base
class itself.

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

Reviewed By: tianshilei1992

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

16 months ago[Flang][OpenMP] NFC: Change a few message/comments to fit 80chars
Kiran Chandramohan [Mon, 27 Feb 2023 16:31:16 +0000 (16:31 +0000)]
[Flang][OpenMP] NFC: Change a few message/comments to fit 80chars

Changes are all in the OpenMP semantic checks file.

Reviewed By: SBallantyne

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

16 months ago[mlir][Linalg] Reimplement hoisting on tensors as a subset-based transformation
Nicolas Vasilache [Wed, 22 Feb 2023 13:24:25 +0000 (05:24 -0800)]
[mlir][Linalg] Reimplement hoisting on tensors as a subset-based transformation

This revision significantly rewrites hoisting on tensors.
Previously, `vector.transfer_read/write` and `tensor.extract/insert_slice` would
be clumped together when looking for candidate pairs.
This would significantly increase the complexity of the logic and would not apply
independently to `tensor.extract/insert_slice`.

The new implementation decouples the cases and starts to cast the problem
as a generic matching subset extract/insert, which will be future proof when
other such operation pairs are introduced.

Lastly, the implementation makes the distinction clear between `vector.transfer_read/write` for
which we allow bypasses of the disjoint subsets from `tensor.extract/insert_slice` for which we
do not yet allow it.

This can be extended in the future and unified once we have subset disjunction implemented more generally.

The algorithm can be rewritten to be less of a fixed point with interspersed canonicalizations.
As a consequence, the test explicitly adds a canonicalization to clean up the IR and verify we end up in the same state.

That extra canonicalization exhibited that one of the uses in one of the tests was dead, so we fix the appropriate test.

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

16 months ago[mlir] Fix a -Wunused-variable warning, NFC
Haojian Wu [Mon, 27 Feb 2023 16:10:33 +0000 (17:10 +0100)]
[mlir] Fix a -Wunused-variable warning, NFC

16 months ago[ConstExpr] Avoid creation of select constant expressions
Nikita Popov [Mon, 27 Feb 2023 15:56:45 +0000 (16:56 +0100)]
[ConstExpr] Avoid creation of select constant expressions

These expressions will now only be created if explicitly requested
in IR/bitcode (and by LowerTypeTests, which has a tricky to remove
use).

This is in preparation for removing these expressions entirely,
but also fixes #60983 in the meantime.

16 months ago[MLIR] Add pass to deduplicate functions
Frederik Gossen [Mon, 27 Feb 2023 15:58:56 +0000 (10:58 -0500)]
[MLIR] Add pass to deduplicate functions

Deduplicate functions that are equivalent in all aspects but their symbol name.
The pass chooses one representative per equivalence class, erases the remainder, and updates function calls accordingly.

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

16 months ago[mlir] Port bazel for 115711c19cd287c098a872c63a00478ca635f642
Haojian Wu [Mon, 27 Feb 2023 15:50:39 +0000 (16:50 +0100)]
[mlir] Port bazel for 115711c19cd287c098a872c63a00478ca635f642

16 months ago[MLIR] Expose region equivalence check through OperationEquivalence
Frederik Gossen [Mon, 27 Feb 2023 15:49:22 +0000 (10:49 -0500)]
[MLIR] Expose region equivalence check through OperationEquivalence

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

16 months ago[InlineCost] Avoid ConstantExpr::getSelect()
Nikita Popov [Mon, 27 Feb 2023 15:36:07 +0000 (16:36 +0100)]
[InlineCost] Avoid ConstantExpr::getSelect()

Instead use ConstantFoldSelectInstruction(), which will return
nullptr if it cannot be folded and a constant expression would
be produced instead.

In preparation for removing select constant expressions.

16 months ago[mlir][sparse] Add checking parent op of SortOp
Kohei Yamaguchi [Mon, 27 Feb 2023 15:36:16 +0000 (16:36 +0100)]
[mlir][sparse] Add checking parent op of SortOp

Fix crash with segmentation fault caused by setting a parent operator
that is not func::FuncOp with sparse_tensor SortOp.

fixes https://github.com/llvm/llvm-project/issues/59988

Reviewed By: aartbik, wrengr

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

16 months ago[mlir][NFC] Cleanup Passes documentation
Kohei Yamaguchi [Mon, 27 Feb 2023 15:34:59 +0000 (16:34 +0100)]
[mlir][NFC]  Cleanup Passes documentation

- Fix a place of NVGPU dialect's pass
- Move a summary of `-finalize-memref-to-llvm` into description
- Fix broken links
- Replace back-quote dialect headers with single-quote headers for
  improved readability.

Reviewed By: rriddle

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

16 months ago[mlir][LinAlg][Transform][GPU] Add GPU memory hierarchy to the transform.promote op
Amir Mohammad Tavakkoli [Mon, 27 Feb 2023 15:28:54 +0000 (16:28 +0100)]
[mlir][LinAlg][Transform][GPU] Add GPU memory hierarchy to the transform.promote op

In this patch we are adding the support of copying a a `memref.subview` to the shared or private memory in GPU. The global to shared memory copy is adopted from codes implemented in IREE (https://github.com/iree-org/iree), but the private memory copy part has not been implemented in IREE. This patch enables transferring a subview from `global->shared`, `global->private`, and `shared->private`.

Our final aim is to provide a copy layout as an affine map to the `transform.promote` op to support transpose memory copy. This map is a permutation of the original affine index map. Although this has been implemented and user can copy data to arbitrary layout , this attempt is not included in this patch since we have still problem with `linalg.generic` operations to change their index map to the transformed index map. You can find more in following links ([[ https://github.com/tavakkoliamirmohammad/iree-llvm-fork/commit/4fd5f93355951ad0fb338858393ff409bd9c62f8 | Initial attempt to support layout map in promote op in transform dialect ]]) ([[ https://github.com/tavakkoliamirmohammad/iree-llvm-fork/commit/9062b5849f91d4defb84996392b71087dadf7a8c | Fix data transpose in shared memory ]])

Reviewed By: ftynse

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

16 months ago[SLP]Fix a crash when trying to find reduced ops for the reduced value.
Alexey Bataev [Mon, 27 Feb 2023 14:33:08 +0000 (06:33 -0800)]
[SLP]Fix a crash when trying to find reduced ops for the reduced value.

Need to use original reduced value, not the one the compiler gets after
reduction, it may be replaced by the extractelement instruction already.

16 months ago[InstCombine] Avoid ConstantExpr::getSelect() use (NFCI)
Nikita Popov [Mon, 27 Feb 2023 15:31:21 +0000 (16:31 +0100)]
[InstCombine] Avoid ConstantExpr::getSelect() use (NFCI)

Instead let IRBuilder take care of constant folding.

In preparation for removing select constantexprs.

16 months ago[AArch64] Add some tests for multiple uses of extended vector extracts. NFC
David Green [Mon, 27 Feb 2023 14:34:52 +0000 (14:34 +0000)]
[AArch64] Add some tests for multiple uses of extended vector extracts. NFC

16 months ago[mlir] Insert tensor.cast only when needed when folding tensor.cast into extract_slice.
Alexander Belyaev [Mon, 27 Feb 2023 14:16:27 +0000 (15:16 +0100)]
[mlir] Insert tensor.cast only when needed when folding tensor.cast into extract_slice.

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

16 months ago[OHOS] Add support for OpenHarmony
Pavel Kosov [Mon, 27 Feb 2023 14:15:45 +0000 (17:15 +0300)]
[OHOS] Add support for OpenHarmony

Add support for OpenHarmony OS

General OpenHarmony OS discussion on discourse thread "[RFC] Add support for OpenHarmony OS"
https://discourse.llvm.org/t/rfc-add-support-for-openharmony-os/66656

Reviewed By: DavidSpickett

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

16 months ago[SME2][AArch64] Add multi-indexed multiply-add long long intrinsics
Kerry McLaughlin [Mon, 27 Feb 2023 13:38:37 +0000 (13:38 +0000)]
[SME2][AArch64] Add multi-indexed multiply-add long long intrinsics

Adds intrinsics for the following SME2 instructions (1, 2 & 4 vector):
 - smlall
 - umlall
 - smlsll
 - umlsll
 - sumlall
 - usmlall

NOTE: These intrinsics are still in development and are subject to future changes.

Reviewed By: david-arm

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

16 months ago[GlobalOpt] Ignore only loaded / only stored global parts in global SRA heuristic
Nikita Popov [Wed, 22 Feb 2023 15:35:51 +0000 (16:35 +0100)]
[GlobalOpt] Ignore only loaded / only stored global parts in global SRA heuristic

When limiting the number of parts we split a global into, ignore
any parts that are either only loaded or only stored, because we
expect these to be optimized away after SRA.

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

16 months ago[libc++][ranges] Implement LWG-3860 range_common_reference_t is missing
Igor Zhukov [Sun, 19 Feb 2023 00:40:41 +0000 (07:40 +0700)]
[libc++][ranges] Implement LWG-3860 range_common_reference_t is missing

16 months ago[mlir] Use the same name as the generated parameter name (NFC).
Adrian Kuegel [Mon, 27 Feb 2023 13:01:20 +0000 (14:01 +0100)]
[mlir] Use the same name as the generated parameter name (NFC).

When commenting for which parameter a value is passed, the same name
should be used as is used for the real parameter. In this case, the
parameter name is generated from the TransformOps.td file.

16 months ago[flang][OpenMP] Handle lastprivate on sections construct
Nimish Mishra [Mon, 27 Feb 2023 11:54:02 +0000 (17:24 +0530)]
[flang][OpenMP] Handle lastprivate on sections construct

This patch adds support for lastprivate on sections construct.
One omp.sections operation can have several omp.section operation. As such, the privatization happens in the lexically last omp.section operation.

Reviewed By: kiranchandramohan, peixin

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

16 months ago[Flang] Add Minloc to simplify intrinsics pass
Sacha Ballantyne [Mon, 27 Feb 2023 11:00:45 +0000 (11:00 +0000)]
[Flang] Add Minloc to simplify intrinsics pass

This patch adds minloc to the simplify intrinsics pass, supporting calls with KIND or MASK arguments while calls which have BACK, DIM or have a CHARACTER input array are rejected. This patch is targeting exchange2, and in benchmarks provides a ~11% improvement in performance.

Also included are some minor style changes / cleanup in simplifyIntrinsics.cpp.

Reviewed By: vzakhari

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

16 months ago[LoopPredication] Account for critical edges when inserting assumes. PR26496
Max Kazantsev [Mon, 27 Feb 2023 11:22:52 +0000 (18:22 +0700)]
[LoopPredication] Account for critical edges when inserting assumes. PR26496

Loop predication can insert assumes to preserve knowledge about some facts that
may otherwise be lost, because loop predication is a lossy transform. When a guard
is represented as branch by widenable condition, it should insert it in the guarded
block. However, if the guarded block has other predecessors than the guard block,
then the condition might not dominate it. Currently we generate invalid code here.

One possible fix here is to split critical edge and insert the assume there, but in
this case we should modify CFG, which Loop Predication is not currently doing, and we
want to keep it that way.

The fix is to handle this case by inserting a Phi which takes `Cond` as input from the
guard block and `true` from any other blocks. This is valid in terms of IR and does
not introduce any new knowledge if we came from another block.

Differential Revision: https://reviews.llvm.org/D144859
Reviewed By: nikic, skatkov

16 months agoReapply [InstCombine] Remove early constant fold
Nikita Popov [Mon, 20 Feb 2023 08:46:54 +0000 (09:46 +0100)]
Reapply [InstCombine] Remove early constant fold

The reported compile-time regression has been address in
47f9109dff80a1abbe2705ee71dc0882b1d62274.

Additionally, this contains a change to immediately fold zext
with constant operand, even if it's used in a trunc. I'm not sure
if this is relevant for anything, but I noticed it as a behavioral
discrepancy when investigating this issue.

-----

InstCombine currently performs a constant folding attempt as part
of the main InstCombine loop, before visiting the instruction.
However, each visit method will also attempt to simplify the
instruction, which will in turn constant fold it. (Additionally,
we also constant fold instructions before the main InstCombine loop
and use a constant folding IR builder, so this is doubly redundant.)

There is one place where InstCombine visit methods currently don't
call into simplification, and that's casts. To be conservative,
I've added an explicit constant folding call there (though it has
no impact on tests).

This makes for a mild compile-time improvement and in particular
mitigates the compile-time regression from enabling load
simplification in be88b5814d9efce131dbc0c8e288907e2e6c89be.

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

16 months ago[SelectionDAG] Transitively copy NodeExtraInfo on RAUW
Marco Elver [Mon, 27 Feb 2023 11:05:02 +0000 (12:05 +0100)]
[SelectionDAG] Transitively copy NodeExtraInfo on RAUW

During legalization of the SelectionDAG, some nodes are replaced with
arch-specific nodes. These may be complex nodes, where the root node no
longer corresponds to the node that should carry the extra info.

Fix the issue by copying extra info to the new node and all its new
transitive operands during RAUW. See code comments for more details.

This fixes the remaining pcsections-atomics.ll tests on X86.

Reviewed By: dvyukov

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

16 months ago[X86][FixupBWInsts] Fix propagation of !pcsections metadata
Marco Elver [Mon, 27 Feb 2023 11:04:52 +0000 (12:04 +0100)]
[X86][FixupBWInsts] Fix propagation of !pcsections metadata

Use MIMetadata() to propagate both DebugLoc and !pcsections metadata.

This fixes several of the non-native sized !pcsections tests in
pcsections-atomics.ll.

Reviewed By: dvyukov

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

16 months ago[X86] Improve atomics test for !pcsections
Marco Elver [Mon, 27 Feb 2023 11:04:42 +0000 (12:04 +0100)]
[X86] Improve atomics test for !pcsections

Extend pcsections-atomics.ll to exhaustively test all atomic ops up to
64 bits. This currently shows that some atomic operations do not end up
in PC sections. This will be addressed in a subsequent change.

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

16 months ago[X86] Move atomics test for !pcsections into separate file
Marco Elver [Mon, 27 Feb 2023 11:04:21 +0000 (12:04 +0100)]
[X86] Move atomics test for !pcsections into separate file

The pcsections.ll test primarily tests that the AsmPrinter produces the
right output in sections. This output is not easily covered by
update_llc_test_checks.py, and as such is hand written. This makes
maintenance rather burdensome. Instead, let's keep pcsections.ll as
simple as possible.

Move the more complex tests that primarily test that some atomic
operations end up in the PC section to pcsections-atomics.ll.

NFC.

Reviewed By: dvyukov, vitalybuka

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

16 months ago[InstCombine] Guard against many users when swapping icmp operands
Nikita Popov [Mon, 27 Feb 2023 10:56:36 +0000 (11:56 +0100)]
[InstCombine] Guard against many users when swapping icmp operands

This addresses the compile-time regression reported on D144369.
If we don't fold constant operands early, then we might end up
walking very large use lists of constants here. Explicitly exclude
constants, and also limit the number of inspected users to avoid
degenerate cases like this.

This entire transform shouldn't be part of InstCombine in the
first place though.

16 months ago[clang-format] Fix assertion that doesn't hold under fuzzing.
Manuel Klimek [Mon, 27 Feb 2023 10:50:05 +0000 (10:50 +0000)]
[clang-format] Fix assertion that doesn't hold under fuzzing.

16 months ago[SVE] Add intrinsics for uniform dsp operations that explicitly undefine the result...
chendewen [Mon, 27 Feb 2023 09:24:11 +0000 (17:24 +0800)]
[SVE] Add intrinsics for uniform dsp operations that explicitly undefine the result for inactive lanes.

This patch adds new intrinsics for uniform dsp operations and changes the lowering for the following builtins to emit calls to the new aarch64.sve.###.u intrinsics.
  svsqsub_x
  svsqsub_n_x
  svuqsub_x
  svuqsub_n_x
  svsqsubr_x
  svsqsubr_n_x
  svuqsubr_x
  svuqsubr_n_x

Reviewed By: Paul Walker
Differential Revision: https://reviews.llvm.org/D144704

16 months ago[clang-format] Add macro replacement to fuzzing.
Manuel Klimek [Mon, 27 Feb 2023 09:39:40 +0000 (09:39 +0000)]
[clang-format] Add macro replacement to fuzzing.

16 months ago[bazel] Port Bazel for e7950fceb1e7f82370f6cff80b258e552eb410a6
Haojian Wu [Mon, 27 Feb 2023 10:33:45 +0000 (11:33 +0100)]
[bazel] Port Bazel for e7950fceb1e7f82370f6cff80b258e552eb410a6

16 months agoAllow building with CMAKE_SYSTEM_NAME=Generic
Michael Platings [Fri, 24 Feb 2023 21:07:27 +0000 (21:07 +0000)]
Allow building with CMAKE_SYSTEM_NAME=Generic

This is important for building runtimes for bare metal targets.

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

16 months ago[Test] Add failing test for PR61022
Max Kazantsev [Mon, 27 Feb 2023 10:19:17 +0000 (17:19 +0700)]
[Test] Add failing test for PR61022

Details: https://github.com/llvm/llvm-project/issues/61022

16 months agoRevert "[GVN] Support address translation through select instructions"
Sergey Kachkov [Mon, 27 Feb 2023 09:56:13 +0000 (12:56 +0300)]
Revert "[GVN] Support address translation through select instructions"

This reverts commit b5bf6f6392a3408be1b7b7e036eb69358c5a2c29.

16 months ago[SCEV] Make scalable size representation more explicit
Nikita Popov [Wed, 22 Feb 2023 16:05:33 +0000 (17:05 +0100)]
[SCEV] Make scalable size representation more explicit

Represent scalable type sizes using C * vscale, where vscale is
the vscale constant expression. This exposes a bit more information
to SCEV, because the vscale multiplier is explicitly modeled in SCEV
(rather than part of the sizeof expression).

This is mainly intended as an alternative to D143642.

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

16 months ago[clang-format] clang-format.el: fix warnings
Augustin Fabre [Mon, 27 Feb 2023 09:51:56 +0000 (01:51 -0800)]
[clang-format] clang-format.el: fix warnings

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

16 months ago[gn build] Port e7950fceb1e7
LLVM GN Syncbot [Mon, 27 Feb 2023 09:25:56 +0000 (09:25 +0000)]
[gn build] Port e7950fceb1e7

16 months ago[llvm-debuginfo-analyzer] (09/09) - CodeView Reader
Carlos Alberto Enciso [Mon, 27 Feb 2023 08:12:19 +0000 (08:12 +0000)]
[llvm-debuginfo-analyzer] (09/09) - CodeView Reader

llvm-debuginfo-analyzer is a command line tool that processes debug
info contained in a binary file and produces a debug information
format agnostic “Logical View”, which is a high-level semantic
representation of the debug info, independent of the low-level
format.

The code has been divided into the following patches:

1) Interval tree
2) Driver and documentation
3) Logical elements
4) Locations and ranges
5) Select elements
6) Warning and internal options
7) Compare elements
8) ELF Reader
9) CodeView Reader

Full details:
https://discourse.llvm.org/t/llvm-dev-rfc-llvm-dva-debug-information-visual-analyzer/62570

This patch:

This is a high level summary of the changes in this patch.

CodeView Reader
- Support for CodeView/PDB.
  LVCodeViewReader, LVTypeVisitor, LVSymbolVisitor, LVLogicalVisitor

Reviewed By: psamolysov, probinson, djtodoro, zequanwu

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

16 months ago[include-cleaner] Fix an unintended early return when checking the
Haojian Wu [Mon, 27 Feb 2023 09:07:16 +0000 (10:07 +0100)]
[include-cleaner] Fix an unintended early return when checking the
incompatible flags in the CLI tool.

16 months ago[GVN] Support address translation through select instructions
Sergey Kachkov [Wed, 25 Jan 2023 13:10:29 +0000 (16:10 +0300)]
[GVN] Support address translation through select instructions

Process cases when phi incoming in predecessor block has select
instruction, and this select address is unavailable, but there
are addresses translated from both sides of select instruction.

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

16 months ago[mlir][llvm] Stop exporting empty debug MD strings
Christian Ulmann [Mon, 27 Feb 2023 08:49:06 +0000 (09:49 +0100)]
[mlir][llvm] Stop exporting empty debug MD strings

This commit ensures that no empty debug metadata strings are exported as
these are not legal names. Additionally, this commit ensures that
non-existing strings are not accidentially imported as empty strings.

Reviewed By: gysit

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

16 months ago[AMDGPU] Run update scripts on existing tests. NFC
Diana Picus [Thu, 23 Feb 2023 12:01:02 +0000 (13:01 +0100)]
[AMDGPU] Run update scripts on existing tests. NFC

Update a few tests where the checks aren't exactly kosher.

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

16 months ago[mlir][llvm] Builders dont access null attr (NFC)
Christian Ulmann [Mon, 27 Feb 2023 08:31:48 +0000 (09:31 +0100)]
[mlir][llvm] Builders dont access null attr (NFC)

Reviewed By: gysit

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

16 months ago[mlir][SCF] Fix incorrect API usage in RewritePatterns
Matthias Springer [Mon, 27 Feb 2023 08:35:37 +0000 (09:35 +0100)]
[mlir][SCF] Fix incorrect API usage in RewritePatterns

Incorrect API usage was detected by D144552.

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

16 months ago[flang][hlfir] Lower associate construct to HLFIR
Jean Perier [Mon, 27 Feb 2023 08:05:11 +0000 (09:05 +0100)]
[flang][hlfir] Lower associate construct to HLFIR

- always use genExprAddr when lowering to HLFIR: it does not create
  temporary for array sections without vector subscripts, so there is
  no need to have custom logic.

- update mangling to deal with AssocDetailsEntity. Their name is
  required in HLFIR so that it can be added to the hlfir.declare
  that is created for the selector once it is lowered. This should
  allow getting debug info for selector when debug info are generated
  from hlfir.declare.

The rest of associate construct lowering is unchanged and shared with
the current lowering.

This patch also enables select type lowering to work properly, but some
other todos (mainly about parent component references) prevents porting
the tests for now, so this will be done later.

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

16 months ago[flang][hlfir] Lower allocatable assignment to HLFIR
Jean Perier [Mon, 27 Feb 2023 08:04:20 +0000 (09:04 +0100)]
[flang][hlfir] Lower allocatable assignment to HLFIR

Nothing much to do except set the right attributes on hlfir.assign.

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

16 months ago[flang][hlfir] add allocatable assignment semantic to hlfir.assign
Jean Perier [Mon, 27 Feb 2023 08:03:09 +0000 (09:03 +0100)]
[flang][hlfir] add allocatable assignment semantic to hlfir.assign

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

16 months ago[AArch64] Added tests for inserting scalar result of uaddlv neon instrinsic function...
Nilanjana Basu [Sat, 11 Feb 2023 05:34:43 +0000 (21:34 -0800)]
[AArch64] Added tests for inserting scalar result of uaddlv neon instrinsic function into a vector

Inserting scalar result of 'uaddlv' neon intrinsic function to a destination vector currently makes use of the integer unit. Subsequent patches will eliminate the redundant use of the integer registers in a more generic way that will include this special case. This is an initial set of tests for this functionality.

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

16 months ago[mlir][spirv] Fix Physical32/Physical64 support for OpenCL
Lei Zhang [Mon, 27 Feb 2023 06:22:56 +0000 (06:22 +0000)]
[mlir][spirv] Fix Physical32/Physical64 support for OpenCL

We use `use64bitIndex` in the option to decide the target device
address bitwidth. This makes it consistent with index type
conversion too.

Reviewed By: kuhar

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

16 months ago[mlir][spirv] Respect client API requirements for 64-bit index
Lei Zhang [Mon, 27 Feb 2023 06:15:18 +0000 (06:15 +0000)]
[mlir][spirv] Respect client API requirements for 64-bit index

Vulkan requires GPU processor ID/count builtin variables to be
32-bit scalar or vector for all the cases. Similarly there
are special requirements for OpenCL. We need to make sure those
rules are respected when converting using 64bit for index.

Reviewed By: kuhar

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

16 months ago[mlir][python] Don't emit diagnostics when printing invalid ops
Rahul Kayaith [Sat, 25 Feb 2023 08:51:31 +0000 (03:51 -0500)]
[mlir][python] Don't emit diagnostics when printing invalid ops

The asm printer grew the ability to automatically fall back to the
generic format for invalid ops, so this logic doesn't need to be in the
bindings anymore. The printer already handles supressing diagnostics
that get emitted while checking if the op is valid.

Reviewed By: mehdi_amini, stellaraccident

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

16 months agoPrecommit test for D144777, NFC
Jun Zhang [Mon, 27 Feb 2023 04:22:18 +0000 (12:22 +0800)]
Precommit test for D144777, NFC

Signed-off-by: Jun Zhang <jun@junz.org>
16 months ago[Clang] Copy strictfp attribute from pattern to instantiation
Serge Pavlov [Mon, 27 Feb 2023 04:19:20 +0000 (11:19 +0700)]
[Clang] Copy strictfp attribute from pattern to instantiation

If a template function contained a pragma that made it strictfp, code
generation for such function crashed, because the instantiation did not
have strictfp attribute. As a solution this attribute is copied from the
template to instantiation.

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

16 months ago[TableGen] Use raw_svector_ostream and ListSeparator to simplify some code. NFC
Craig Topper [Mon, 27 Feb 2023 03:36:34 +0000 (19:36 -0800)]
[TableGen] Use raw_svector_ostream and ListSeparator to simplify some code. NFC

16 months ago[X86][MC] Fix -Wimplicit-fallthrough in X86MCCodeEmitter.cpp (NFC)
Jie Fu [Mon, 27 Feb 2023 02:17:27 +0000 (10:17 +0800)]
[X86][MC] Fix -Wimplicit-fallthrough in X86MCCodeEmitter.cpp (NFC)

/data/llvm-project/llvm/lib/Target/X86/MCTargetDesc/X86MCCodeEmitter.cpp:1200:3: error: unannotated fall-through between switch labels [-Werror,-Wimplicit-fallthrough]
  case X86II::RawFrm:
  ^

16 months ago[X86][MC] Assert unexpected form in emitREXPrefix, NFCI
Shengchen Kan [Sat, 25 Feb 2023 05:57:34 +0000 (13:57 +0800)]
[X86][MC] Assert unexpected form in emitREXPrefix, NFCI

1. Add a variable `HasRegOp` to record if the instruction has a register operand
2. Enumerate all the formats with a register operand in the switch
2. Add a default (unreachable) label in the switch (suggested by @reames)

Reviewed By: pengfei

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

16 months ago[TableGen] Remove duplicate call to getPredicateCheck. NFC
Craig Topper [Mon, 27 Feb 2023 00:32:25 +0000 (16:32 -0800)]
[TableGen] Remove duplicate call to getPredicateCheck. NFC

16 months ago[GlobalISel] Fix an assertion failure in matchHoistLogicOpWithSameOpcodeHands().
Amara Emerson [Sun, 26 Feb 2023 23:42:57 +0000 (15:42 -0800)]
[GlobalISel] Fix an assertion failure in matchHoistLogicOpWithSameOpcodeHands().

We use this combine in the AArch64 postlegalizer combiner, which causes this
function to query the legalizer rules for the action for an invalid opcode/type
combination (G_AND and p0). Moving the legalizer query until after the validity
check in matchHoistLogicOpWithSameOpcodeHands() fixes this.

16 months ago[clang-tidy] handle exceptions properly in `ExceptionAnalyzer`
isuckatcs [Fri, 7 Oct 2022 22:23:33 +0000 (00:23 +0200)]
[clang-tidy] handle exceptions properly in `ExceptionAnalyzer`

This patch implements the exception handling rules found in
N4849 14.4 and as a result fixes many false positives in
the bugprone-exception-escape checker.

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

16 months ago[mlir] NFC: Prepare GPUToSPIRV tests for supporting 64bit index
Lei Zhang [Sun, 26 Feb 2023 21:23:07 +0000 (21:23 +0000)]
[mlir] NFC: Prepare GPUToSPIRV tests for supporting 64bit index

This commit just adds options to control index type bitwidth in
GPUToSPIRV conversion, and updates tests to prepare for 64bit
index conversion.

Reviewed By: kuhar

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

16 months ago[gn build] Port ff93c9beefd4
LLVM GN Syncbot [Sun, 26 Feb 2023 21:40:55 +0000 (21:40 +0000)]
[gn build] Port ff93c9beefd4

16 months ago[gn] port 6e93bf5f66
Nico Weber [Sun, 26 Feb 2023 21:40:09 +0000 (16:40 -0500)]
[gn] port 6e93bf5f66

16 months ago[WebAssembly][test] Clean up ir-locals.ll after opaque pointer conversion
Alex Bradbury [Sun, 26 Feb 2023 19:17:06 +0000 (19:17 +0000)]
[WebAssembly][test] Clean up ir-locals.ll after opaque pointer conversion

The `tyname_cell` definitions at the top are now all the same, so
replace them with a single `alloca_cell` type.

16 months ago[Webassembly][test] Regenerate ir-locals.ll using update_llc_test_checks.py
Alex Bradbury [Sun, 26 Feb 2023 19:12:36 +0000 (19:12 +0000)]
[Webassembly][test] Regenerate ir-locals.ll using update_llc_test_checks.py

Preparation for further additions.

16 months ago[DWARFLinker][DWARFv5] Add support for .debug_rnglists.
Alexey Lapshin [Sun, 26 Feb 2023 17:57:50 +0000 (18:57 +0100)]
[DWARFLinker][DWARFv5] Add support for .debug_rnglists.

This patch adds support of DWARFv5 .debug_rnglists table.
As DWARFLinker resolves relocations, it is able to always
use DW_FORM_addr instead of DW_FORM_addrx. DW_FORM_addrx
helps to minimize number of relocations, it is also used for
split DWARF. Both of these cases are not relevant for the
DWARFLinker. Thus, this patch converts all DW_FORM_addrx
forms into the DW_FORM_addr. And, as the result, it converts
range lists of DW_FORM_rnglistx form into the DW_FORM_sec_offset.
For the --update case all DW_FORM_addrx, DW_FORM_rnglistx
are preserved as is.

Reviewed By: aprantl

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

16 months agoAdd additional operations that masked instructions can combine with
Noah Goldstein [Sun, 26 Feb 2023 17:25:59 +0000 (11:25 -0600)]
Add additional operations that masked instructions can combine with

Added: OR, SMAX, SMIN, UMAX, UMIN, ABS, SHL, SRL, SRA, MUL

Intentionally not generically using TLI.isBinOp as that causes
regressions as there are many binops that cannot combine with masked
instructions.

Reviewed By: RKSimon

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

16 months agoAdd tests for combining mask with shuffles; NFC
Noah Goldstein [Thu, 16 Feb 2023 17:57:39 +0000 (11:57 -0600)]
Add tests for combining mask with shuffles; NFC

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

16 months agoWiden i16 shuffle masks if vector width < 512 even with BWI
Noah Goldstein [Thu, 16 Feb 2023 17:57:31 +0000 (11:57 -0600)]
Widen i16 shuffle masks if vector width < 512 even with BWI

`{v}blend{d|ps|pd}` is preferable to `{v}blendw` so widen so that we
can match it.

Reviewed By: RKSimon

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

16 months agoAdd more tests for promoting `blendw` -> `blendd`; NFC
Noah Goldstein [Thu, 16 Feb 2023 17:57:23 +0000 (11:57 -0600)]
Add more tests for promoting `blendw` -> `blendd`; NFC

Reviewed By: RKSimon

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

16 months ago[X86] Add additional uses tests for select(icmp(x,y),sub(x,y),sub(y,x)) -> abd(x...
Simon Pilgrim [Sun, 26 Feb 2023 18:01:05 +0000 (18:01 +0000)]
[X86] Add additional uses tests for select(icmp(x,y),sub(x,y),sub(y,x)) -> abd(x,y) patterns

16 months ago[LICM] Ensure LICM can hoist invariant.group
William S. Moses [Tue, 14 Feb 2023 23:36:07 +0000 (18:36 -0500)]
[LICM] Ensure LICM can hoist invariant.group

Invariant.group's are not sufficiently handled by LICM. Specifically,
if a given invariant.group loaded pointer is not overwritten between
the start of a loop, and its use in the load, it can be hoisted.
The invariant.group (on an already invariant pointer operand) ensures
the result is the same. If it is not overwritten between the start
of the loop and the load, it is therefore legal to hoist.

Reviewed By: nikic

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

16 months ago[MergeICmps] Adapt to non-eq comparisons, retry
zhongyunde [Sun, 26 Feb 2023 17:21:24 +0000 (01:21 +0800)]
[MergeICmps] Adapt to non-eq comparisons, retry

Fix https://github.com/llvm/llvm-project/issues/59740.
NOTE: retry as we can't reproduce the break locally when first commit.

Reviewed By: vitalybuka
Differential Revision: https://reviews.llvm.org/D141188

16 months ago[X86] Add vector test coverage for select(icmp(x,y),sub(x,y),sub(y,x)) -> abd(x,y...
Simon Pilgrim [Sun, 26 Feb 2023 17:05:46 +0000 (17:05 +0000)]
[X86] Add vector test coverage for select(icmp(x,y),sub(x,y),sub(y,x)) -> abd(x,y) patterns

16 months ago[X86] Add scalar test coverage for select(icmp(x,y),sub(x,y),sub(y,x)) -> abd(x,y...
Simon Pilgrim [Sun, 26 Feb 2023 16:45:18 +0000 (16:45 +0000)]
[X86] Add scalar test coverage for select(icmp(x,y),sub(x,y),sub(y,x)) -> abd(x,y) patterns

16 months ago[Driver][OpenBSD] Simplify command-line option handling. NFC
Brad Smith [Sun, 26 Feb 2023 15:45:00 +0000 (10:45 -0500)]
[Driver][OpenBSD] Simplify command-line option handling. NFC