platform/upstream/llvm.git
20 months ago[mlgo] Use have_tflite instead of have_tf_api
Kazu Hirata [Thu, 15 Dec 2022 21:54:25 +0000 (13:54 -0800)]
[mlgo] Use have_tflite instead of have_tf_api

We are in the process of retiring LLVM_HAVE_TF_API in favor of
LLVM_HAVE_TFLITE.  This patch takes care of the transition in
llvm/test.

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

20 months ago[flang] Correct folding of SAME_TYPE_AS()
Peter Klausler [Mon, 5 Dec 2022 23:26:28 +0000 (15:26 -0800)]
[flang] Correct folding of SAME_TYPE_AS()

The result can't be known to be true at compilation time when
either operand is polymorphic.

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

20 months agoHeaders: tweak inclusion condition for stdatomic.h
Saleem Abdulrasool [Thu, 15 Dec 2022 20:34:04 +0000 (20:34 +0000)]
Headers: tweak inclusion condition for stdatomic.h

MSVC requires that C++23 be available (_HAS_CXX23) else the entire
content is elided. Conditionalise the inclusion properly so that C/C++
code using stdatomic.h for memory_order_* constants are able to do
so without changing the C++ standard. This repairs builds of Swift and
libdispatch after ba49d39b20cc5358da28af2ac82bd336028780bc.

Differential Revision: https://reviews.llvm.org/D139266
Reviewed By: aaron.ballman, Mordante, fsb4000

20 months ago[mailmap] Add my entry
Tommy Chiang [Thu, 15 Dec 2022 21:30:29 +0000 (05:30 +0800)]
[mailmap] Add my entry

20 months ago[PowerPC][GIsel] Materialize i64 constants.
Kai Nacke [Thu, 15 Dec 2022 20:26:32 +0000 (20:26 +0000)]
[PowerPC][GIsel] Materialize i64 constants.

Adds support for i64 constant. It uses the same pattern-based
approach as in SDAG (see PPCISelDAGToDAG::selectI64ImmDirect(),
PPCISelDAGToDAG::selectI64Imm()). It does not support the
prefixed instructions.

Reviewed By: arsenm, tschuett

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

20 months ago[NFC] Cleanup: Remove instances of Function::getBasicBlockList()
Vasileios Porpodas [Thu, 15 Dec 2022 03:07:24 +0000 (19:07 -0800)]
[NFC] Cleanup: Remove instances of Function::getBasicBlockList()

This is part of a series of patches that aim at making Function::getBasicBlockList() private.

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

20 months ago[libc] Handle allocation failures in the dirent API gracefully.
Siva Chandra Reddy [Wed, 14 Dec 2022 22:37:28 +0000 (22:37 +0000)]
[libc] Handle allocation failures in the dirent API gracefully.

Along the way, setting of errno has been moved out of the internal code.

Reviewed By: lntue

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

20 months ago[libc] fix shifting exact multiples of 64 in uint
Michael Jones [Thu, 15 Dec 2022 00:51:23 +0000 (16:51 -0800)]
[libc] fix shifting exact multiples of 64 in uint

The internal uint class had a bug introduced recently when optimizing
the shift routines. When calculating the value of a block, it would
shift an adjacent block by 64 - the shift amount. If the shift amount
was 0, this would be a shift of 64, which is undefined for a 64 bit
integer. This patch fixes this by adding a conditional to catch this
case.

Reviewed By: lntue

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

20 months ago[WindowsDriver] Improve VSInstallPath check for IDE subdirectory
Dimitry Andric [Thu, 15 Dec 2022 20:38:07 +0000 (21:38 +0100)]
[WindowsDriver] Improve VSInstallPath check for IDE subdirectory

This avoids potential memory allocation failures, if VSInstallPath is
not empty, but also does not contain the string "\Common7\IDE".

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

Reviewed By: mstorsjo

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

20 months agoRevert "[WindowsDriver] Improve VSInstallPath check for IDE subdirectory"
Dimitry Andric [Thu, 15 Dec 2022 20:36:32 +0000 (21:36 +0100)]
Revert "[WindowsDriver]  Improve VSInstallPath check for IDE subdirectory"

This reverts commit cc40dacbd0b736522d0254fb5525cde22bd5f166.

20 months ago[WindowsDriver] Improve VSInstallPath check for IDE subdirectory
Dimitry Andric [Sun, 11 Dec 2022 18:18:21 +0000 (19:18 +0100)]
[WindowsDriver]  Improve VSInstallPath check for IDE subdirectory

This avoids potential memory allocation failures, if VSInstallPath is
not empty, but also does not contain the string "\Common7\IDE".

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

Reviewed By: mstorsjo

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

20 months ago[NFC] Rename Instruction::insertAt() to Instruction::insertInto(), to be consistent...
Vasileios Porpodas [Thu, 15 Dec 2022 01:42:26 +0000 (17:42 -0800)]
[NFC] Rename Instruction::insertAt() to Instruction::insertInto(), to be consistent with BasicBlock::insertInto()

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

20 months ago[clang] Convert tests to check 'target=...'
Paul Robinson [Thu, 15 Dec 2022 20:25:59 +0000 (12:25 -0800)]
[clang] Convert tests to check 'target=...'

Part of the project to eliminate special handling for triples in lit
expressions.

20 months agoRevert "[NFC][DebugInfo] Autogenerate check lines in assignment-tracking/sroa/*"
Roman Lebedev [Thu, 15 Dec 2022 20:20:37 +0000 (23:20 +0300)]
Revert "[NFC][DebugInfo] Autogenerate check lines in assignment-tracking/sroa/*"

As per post-commit feedback, DebugInfo owners are not receptive of the
idea of having a single source of truth instead of relying on everyone
to know how to update these tests manually.

This reverts commit 4ff8d1e315bdd26daae8a6928aa46e347fe0d6eb.
This reverts commit a33b40d61c64b95d736f1a0dd537e9087c330304.

20 months ago[mlir][sparse] performs a tab cleanup (NFC)
Aart Bik [Thu, 15 Dec 2022 19:38:55 +0000 (11:38 -0800)]
[mlir][sparse] performs a tab cleanup (NFC)

Reviewed By: Peiming

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

20 months ago[AArch64] Minor changes and sanity checks in relation to https://reviews.llvm.org...
Nilanjana Basu [Thu, 15 Dec 2022 19:35:34 +0000 (01:05 +0530)]
[AArch64] Minor changes and sanity checks in relation to https://reviews.llvm.org/D135229

20 months ago[clang] Support for read-only types
MalavikaSamak [Thu, 15 Dec 2022 19:02:46 +0000 (11:02 -0800)]
[clang] Support for read-only types

The main goal of this work is to allow developers to express the need to place instances
of a class or structure in the read-only part of the program memory. Such a placement is
desirable to prevent any further modifications to the instances of a given structure, by
leveraging the read-only run time protection.

To achieve this, we are introducing a new attribute that can be attached to any record
definition or a declaration. The compiler enforces that every instance of this type can
be placed in the read-only segment of the program memory, provided the target triplet
supports such a placement. If an instance of a given type bearing this attribute doesn’t
satisfy such a placement, the compiler attaches an appropriate warning at suitable program
locations. In other words, adding this attribute to a type requires every instance of this
type to be a global const, which are placed in the read-only segments for most target
triplets. However, this is *not a language feature* and it *need not* be true for
*all target triplets*.

The current patch emits a warning at global variable declaration sites of types bearing
the attribute without const qualification and corresponding note attached to the type
definition/declaration.

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

20 months ago[OpenMP][libomptarget] Add utility header for AMDGPU plugins
Kevin Sala [Sun, 11 Dec 2022 15:28:02 +0000 (16:28 +0100)]
[OpenMP][libomptarget] Add utility header for AMDGPU plugins

This patch prepares the PluginInterface for the new AMDGPU NextGen plugin. The original and the
NextGen plugin will share some structures and functionalities. We use this header for defining
them and avoiding code duplication.

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

20 months ago[libc][NFC] Rename "loader" to "startup".
Siva Chandra Reddy [Wed, 14 Dec 2022 20:38:45 +0000 (20:38 +0000)]
[libc][NFC] Rename "loader" to "startup".

Reviewed By: lntue

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

20 months ago[mlir][sparse] remove unintended file and trailing white space
Peiming Liu [Thu, 15 Dec 2022 19:32:25 +0000 (19:32 +0000)]
[mlir][sparse] remove unintended file and trailing white space

Reviewed By: aartbik

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

20 months ago[mlir][VectorToGPU] Support transposed+broadcasted 2D MMA load
Lei Zhang [Thu, 15 Dec 2022 19:34:14 +0000 (19:34 +0000)]
[mlir][VectorToGPU] Support transposed+broadcasted 2D MMA load

This is loading from 2-D memref, in addition to D139655 where we
load from 1-D memref cases.

Reviewed By: ThomasRaoux

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

20 months agoFix: use "using namespace" in a header file.
Emmmer [Thu, 15 Dec 2022 19:30:55 +0000 (03:30 +0800)]
Fix: use "using namespace" in a header file.

20 months ago[mlir][VectorToGPU] Support transposed+broadcasted 1D MMA load
Lei Zhang [Thu, 15 Dec 2022 19:16:01 +0000 (19:16 +0000)]
[mlir][VectorToGPU] Support transposed+broadcasted 1D MMA load

This is now possible with transpose semantics on subgroup MMA
load ops.

Reviewed By: ThomasRaoux

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

20 months ago[AutoFDO] Use getHeadSamplesEstimate instead of getTotalSamples to compute profile...
wlei [Wed, 14 Dec 2022 22:47:37 +0000 (14:47 -0800)]
[AutoFDO] Use getHeadSamplesEstimate instead of getTotalSamples to compute profile callsite staleness

Fix two issues for profile staleness report.

1) It should be more accurate to use the sum of all entry count(`getHeadSamplesEstimate`) for the callsite samples than the total samples, since even the top-level callsite is mismatched, it does affect the inlining but it can still be merged into base profile and used later.

2) I accidentally missed to persist the num of mismatched callsite into binary.

Also added the asm testing to test the decoding of the section.

Reviewed By: hoy, wenlei

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

20 months agoRevert "Revert "[AArch64][GlobalISel][Legalizer] Legalize G_SHUFFLE_VECTOR with diffe...
Kevin Athey [Thu, 15 Dec 2022 19:19:24 +0000 (11:19 -0800)]
Revert "Revert "[AArch64][GlobalISel][Legalizer] Legalize G_SHUFFLE_VECTOR with different lengths""

This reverts commit 192cc76e0be688106492989cd845ba786a7ae36d.

Reverted Revert, as build was fixed while I was examining.

20 months agoRevert "[AArch64][GlobalISel][Legalizer] Legalize G_SHUFFLE_VECTOR with different...
Kevin Athey [Thu, 15 Dec 2022 17:21:37 +0000 (09:21 -0800)]
Revert "[AArch64][GlobalISel][Legalizer] Legalize G_SHUFFLE_VECTOR with different lengths"

This reverts commit 4c52fb1a5ee20846627d16e38f5dec08c08f8884.

Breaks sanitizer ubsan buildbot:
https://lab.llvm.org/buildbot/#/builders/85/builds/12983

20 months ago[mlgo] Use LLVM_HAVE_TFLITE instead of LLVM_HAVE_TF_API
Kazu Hirata [Thu, 15 Dec 2022 19:11:24 +0000 (11:11 -0800)]
[mlgo] Use LLVM_HAVE_TFLITE instead of LLVM_HAVE_TF_API

This patch replaces uses of LLVM_HAVE_TF_API with LLVM_HAVE_TFLITE in
a couple of CMakeLists.txt.

Now that 842b0d0fe2dd142305a9461e50cdce9aff7f86bc has landed,
we now have:

  LLVM_HAVE_TF_API is defined if and only if LLVM_HAVE_TFLITE
  evaluates to true

in the CMake variable world (assuming that you do not set
LLVM_HAVE_TF_API on the cmake invocation).

FWIW, the story is a little different in the C++ macro world, where:

  LLVM_HAVE_TF_API is defined if and only if LLVM_HAVE_TFLITE is
  defined

This is why edc83a15b45e6b91fce3f35622a6b0a6d34e5211 consisted only of
mechanical replacements.

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

20 months ago[RISCV][InsertVSETVL] Incorporate demanded fields into compatibility interface [nfc]
Philip Reames [Thu, 15 Dec 2022 19:09:49 +0000 (11:09 -0800)]
[RISCV][InsertVSETVL] Incorporate demanded fields into compatibility interface [nfc]

This reworks the API to explicitly pass in the demanded fields instead of requering them internally.  At the moment, this is NFC, but it will stop being so in future changes which adjust the demanded bits in the caller.

20 months agoAPFloat: Add isSmallestNormalized predicate function
Matt Arsenault [Thu, 1 Dec 2022 14:12:20 +0000 (09:12 -0500)]
APFloat: Add isSmallestNormalized predicate function

It was annoying to write the check for this in the one case I added,
and I'm planning on adding another, so add a convenient PatternMatch
like for other special case values.

I have no idea what is going on in the DoubleAPFloat case, I reversed
this from the makeSmallestNormalized test. Also could implement this
as *this == getSmallestNormalized() for less code, but this avoids the
construction of a temporary APFloat copy and follows the style of the
other functions.

20 months ago[RISCV] Teach RISCVSExtWRemoval to remove sext.w whose upper bits aren't demanded.
Craig Topper [Thu, 15 Dec 2022 19:01:20 +0000 (11:01 -0800)]
[RISCV] Teach RISCVSExtWRemoval to remove sext.w whose upper bits aren't demanded.

SelectionDAG aggressively creates sext_inreg operations after
promoting an i32 add. If the add is later matched to a sh1add,
sh2add or sh3add, a sext.w from the sext_inreg will get left behind.
In many cases we can prove this sext.w is unnecessary by checking
if its upper bits are ever used.

20 months ago[APInt] Fix a bug in the unit testing introduced in 55968109d
Peter Rong [Thu, 15 Dec 2022 18:51:33 +0000 (10:51 -0800)]
[APInt] Fix a bug in the unit testing introduced in 55968109d

Signed-off-by: Peter Rong <PeterRong96@gmail.com>
20 months ago[flang] Semantic-check for procedure pointers with assumed character length
Kelvin Li [Thu, 15 Dec 2022 16:59:08 +0000 (11:59 -0500)]
[flang] Semantic-check for procedure pointers with assumed character length

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

Committed on behalf of tislam

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

20 months ago[NFC][DebugInfo] assignment-tracking/sroa: do check !DIAssignID, and the metadata
Roman Lebedev [Thu, 15 Dec 2022 18:20:17 +0000 (21:20 +0300)]
[NFC][DebugInfo] assignment-tracking/sroa: do check !DIAssignID, and the metadata

Based on post-commit feedback for the original change.

20 months ago[UpdateTestChecks] Handle !DIAssignID metadata
Roman Lebedev [Thu, 15 Dec 2022 18:19:07 +0000 (21:19 +0300)]
[UpdateTestChecks] Handle !DIAssignID metadata

20 months ago[NFC][UpdateTestChecks] Add coverage for missing !DIAssignID handling
Roman Lebedev [Thu, 15 Dec 2022 18:05:47 +0000 (21:05 +0300)]
[NFC][UpdateTestChecks] Add coverage for missing !DIAssignID handling

20 months agoFix buildbot out of memory
Emmmer [Sun, 30 Oct 2022 17:35:16 +0000 (01:35 +0800)]
Fix buildbot out of memory

https://lab.llvm.org/buildbot#builders/17/builds/31659

20 months ago[AMDGPU] Test fixup
Christudasan Devadasan [Thu, 15 Dec 2022 17:46:53 +0000 (23:16 +0530)]
[AMDGPU] Test fixup

Changing cast_lds_gv into a kernel function to
lower the LDS usage appropriately. The LDS lowering
is currently won't happen for orphan device functions.

20 months ago[APInt] provide a safe API for zext value and sext value.
Peter Rong [Fri, 9 Dec 2022 00:59:22 +0000 (16:59 -0800)]
[APInt] provide a safe API for zext value and sext value.

Currently, APInt::getSExtValue and getZExtValue crashes on values with more than 64 bits.
Users may accidently crash the compiler with this setting when the integer may be i128.
As shown in https://github.com/llvm/llvm-project/issues/59316

In this patch we provide a trySExtValue and tryZExtValue to return an Optional, the user
needs to explictly unwrap it and condsier the possibility where there my no value in it.

Reviewed By: RKSimon

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

20 months ago[NFC] Rename Function::insertBasicBlockAt() to Function::insert().
Vasileios Porpodas [Wed, 14 Dec 2022 23:57:08 +0000 (15:57 -0800)]
[NFC] Rename Function::insertBasicBlockAt() to Function::insert().

I think this is a better name because it is what STL uses.

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

20 months ago[clang-tools-extra] Convert tests to check 'target=...'
Paul Robinson [Thu, 15 Dec 2022 17:50:21 +0000 (09:50 -0800)]
[clang-tools-extra] Convert tests to check 'target=...'

Part of the project to eliminate special handling for triples in lit
expressions.

20 months ago[libc] Templatize ato* tests
Alex Brachet [Thu, 15 Dec 2022 17:30:00 +0000 (17:30 +0000)]
[libc] Templatize ato* tests

This catches missing corner cases from atol tests.

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

20 months ago[ADT] Remove llvm::Optional::transform
Kazu Hirata [Thu, 15 Dec 2022 17:24:54 +0000 (09:24 -0800)]
[ADT] Remove llvm::Optional::transform

I've removed the last uses of transform on Dec 14, 2022 in commit
230df792e17519071a9ef4dc0fb10132540dfbb8.

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

20 months agoApply clang-tidy fixes for llvm-qualified-auto in ElementwiseOpFusion.cpp (NFC)
Mehdi Amini [Sat, 10 Dec 2022 10:57:20 +0000 (10:57 +0000)]
Apply clang-tidy fixes for llvm-qualified-auto in ElementwiseOpFusion.cpp (NFC)

20 months agoApply clang-tidy fixes for bugprone-argument-comment in BufferizableOpInterfaceImpl...
Mehdi Amini [Sat, 10 Dec 2022 10:50:43 +0000 (10:50 +0000)]
Apply clang-tidy fixes for bugprone-argument-comment in BufferizableOpInterfaceImpl.cpp (NFC)

20 months ago[lldb] Fix a warning
Kazu Hirata [Thu, 15 Dec 2022 17:18:55 +0000 (09:18 -0800)]
[lldb] Fix a warning

This patch fixes:

  lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp:1402:18:
  error: default label in switch which covers all enumeration values
  [-Werror,-Wcovered-switch-default]

20 months ago[InstCombine] add nuw to any (1<<x)
Sanjay Patel [Thu, 15 Dec 2022 16:41:22 +0000 (11:41 -0500)]
[InstCombine] add nuw to any (1<<x)

https://alive2.llvm.org/ce/z/9EjDKE

This was mentioned as a missing fold in D139598.

It can unlock follow-on folds in some cases.
This verifies one of the changed tests:
https://alive2.llvm.org/ce/z/B_btDM

20 months ago[mlir][bufferize][NFC] Add statistics to OneShotBufferizePass
Matthias Springer [Thu, 15 Dec 2022 16:55:39 +0000 (17:55 +0100)]
[mlir][bufferize][NFC] Add statistics to OneShotBufferizePass

Print statistics about the number of alloc/deallocs and in-place/out-of-place bufferization.

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

20 months ago[LLDB][RISCV] Add RVD instruction support for EmulateInstructionRISCV
Emmmer [Sat, 10 Dec 2022 08:59:13 +0000 (16:59 +0800)]
[LLDB][RISCV] Add RVD instruction support for EmulateInstructionRISCV

RVD extension is a double-precision floating-point instruction-set extension, which adds double-precision floating-point computational instructions compliant with the IEEE 754-2008 arithmetic standard.

This patch:
- Reuse most of the functions in the "F extension" to impl the"D extension"
- corresponding unittests.

Reviewed By: DavidSpickett

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

20 months agoRevert "[SelectionDAG] Do not second-guess alignment for alloca"
Ron Lieberman [Thu, 15 Dec 2022 16:54:41 +0000 (10:54 -0600)]
Revert "[SelectionDAG] Do not second-guess alignment for alloca"

Breaks amdgpu buildbot https://lab.llvm.org/buildbot/#/builders/193
 23491

This reverts commit ffedf47d8b793e07317f82f9c2a5f5425ebb71ad.

20 months ago[mlir][memref] Fold subview(subview(x))
Matthias Springer [Thu, 15 Dec 2022 16:49:46 +0000 (17:49 +0100)]
[mlir][memref] Fold subview(subview(x))

Folding of rank-reduced subviews is also supported.

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

20 months ago[mlir][cf] Print message in cf.assert to LLVM lowering
Matthias Springer [Thu, 15 Dec 2022 16:37:49 +0000 (17:37 +0100)]
[mlir][cf] Print message in cf.assert to LLVM lowering

The assert message was previously ignored. The lowered IR now calls `puts` it in case of a failed assertion.

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

20 months ago[X86] combineBitcastvxi1 - handle boolmask sign-extension through vselect
Simon Pilgrim [Thu, 15 Dec 2022 16:40:39 +0000 (16:40 +0000)]
[X86] combineBitcastvxi1 - handle boolmask sign-extension through vselect

See if we can freely sign-extend both sources of a vselect operand, also handle allones constant build vectors (easily rematerializable and uses in the test case).

Fixes #59526

20 months ago[LoopVersioningLICM] Regenerate test checks (NFC)
Nikita Popov [Thu, 15 Dec 2022 16:33:13 +0000 (17:33 +0100)]
[LoopVersioningLICM] Regenerate test checks (NFC)

20 months ago[RISCV] Bugfix for 90f91683 noticed in follow up work
Philip Reames [Thu, 15 Dec 2022 16:26:25 +0000 (08:26 -0800)]
[RISCV] Bugfix for 90f91683 noticed in follow up work

I went to extend this locally, and then promptly tripped across a bug which is possible with the landed patch.  The problematic case is:
vsetvli zero, 4, <some vtype>
vmv.x.s x1, v0
vsetvli a0, zero, <same type>

In this case, the naive rewrite - what I had implemented - would form:
vsetvli zero, zero, <same vtype>
vmv.x.s x1, v0

This is, amusingly, correct for the vmv.x.s, but is incorrect for the instructions which follow the sequence and probably rely on VL=VLMAX.  (The VL before the sequence is unknown, and thus doesn't have to be VLMAX.)

I plan to rework the rewrite code to be more robust here, but I wanted to directly fix the bug first.  Sorry for the lack of test; I didn't manage to reproduce this without an additional optimization change after a few minutes of trying.

20 months ago[UpdateTestChecks][PowerPC] Add ppc64 triple support
Kai Nacke [Thu, 15 Dec 2022 15:44:38 +0000 (15:44 +0000)]
[UpdateTestChecks][PowerPC] Add ppc64 triple support

Newer tests use ppc64le-linux triple. It is identical to ppc32.
Some of the PPC GIsel tests were generated by this change.

Reviewed by: RKSimon

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

20 months ago[X86] Add test case for Issue #59526
Simon Pilgrim [Thu, 15 Dec 2022 16:19:35 +0000 (16:19 +0000)]
[X86] Add test case for Issue #59526

20 months ago[ProgressMeter] Remove unnecessary semicolon (NFC)
Nikita Popov [Thu, 15 Dec 2022 16:04:37 +0000 (17:04 +0100)]
[ProgressMeter] Remove unnecessary semicolon (NFC)

Fix compiler warning.

20 months ago[clang][PPC] Supporting -mcpu=405
Qiongsi Wu [Thu, 15 Dec 2022 15:03:05 +0000 (10:03 -0500)]
[clang][PPC] Supporting -mcpu=405

The  ClangBuiltLinux  project relies on `-mcpu=405`. Before https://reviews.llvm.org/D139720, `clang` treated `-mcpu=405` implicitly in the same way as `-mcpu=generic`, because `405` was an unknown value and `clang` did not validate unknown input values. https://reviews.llvm.org/D139720 added the validation of `-mcpu` input value, and `clang` now generates an error with `-mcpu=405`. For further details of the problem, see https://github.com/ClangBuiltLinux/linux/issues/1771.

This patch adds support of `-mcpu=405` explicitly, and treats it as an equivalent of `-mcpu=generic`.

Reviewed By: nemanjai

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

20 months ago[NFC][DebugInfo] Autogenerate check lines in assignment-tracking/sroa/*
Roman Lebedev [Thu, 15 Dec 2022 15:43:36 +0000 (18:43 +0300)]
[NFC][DebugInfo] Autogenerate check lines in assignment-tracking/sroa/*

Manual checklines are generally not welcomed in LLVM tests.
They are really brittle, and really hard to update.
*Please* use scripts!

20 months ago[GVN] reportMayClobberedLoad - avoid repeated cast<> calls. NFCI.
Simon Pilgrim [Thu, 15 Dec 2022 15:44:27 +0000 (15:44 +0000)]
[GVN] reportMayClobberedLoad - avoid repeated cast<> calls. NFCI.

Just perform each cast<Instruction> once - we can make OtherAccess a Instruction* type as we only ever assign it from a known LoadInst/StoreInst

20 months ago[clang-tidy] Add configuration option to bugprone-unchecked-optional-access check.
Yitzhak Mandelbaum [Wed, 14 Dec 2022 14:05:38 +0000 (14:05 +0000)]
[clang-tidy] Add configuration option to bugprone-unchecked-optional-access check.

The underlying model already supports ignoring accesses to optionals through
smart pointers. This patch exposes that option through ClangTidy's configuration
options.

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

20 months ago[MRI] Print more debug infor in clearVirtRegs() (NFC)
Nikita Popov [Thu, 15 Dec 2022 15:42:23 +0000 (16:42 +0100)]
[MRI] Print more debug infor in clearVirtRegs() (NFC)

20 months ago[clang][dataflow] Improve optional model's support for ignoring smart pointers.
Yitzhak Mandelbaum [Wed, 14 Dec 2022 13:54:38 +0000 (13:54 +0000)]
[clang][dataflow] Improve optional model's support for ignoring smart pointers.

The optional model has an option to ignore optionals accessed through smart
pointer types (other than optional itself). This patch improves this feature in
two ways:

1. We extend support to optionals accessed directly through the smart pointer,
like `ptr->value()`. Previously, support was limited to cases that went through
an intermediate field.

2. We clean up the implementation by removing the option from the analysis,
leaving it only in the diagnostic phase (where it is relevant).

3. Adjusts a test which was misleading in what it was testing.

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

20 months agoFix failing test in presence of exceptions D140098
Guillaume Chatelet [Thu, 15 Dec 2022 15:32:21 +0000 (15:32 +0000)]
Fix failing test in presence of exceptions D140098

There is no point in testing this behavior since this is std::optional's semantic.

20 months ago[RISCV][InsertVSETVLI] Mutate prior vsetvli AVL if doing so allows us to remove a...
Philip Reames [Wed, 14 Dec 2022 20:27:53 +0000 (12:27 -0800)]
[RISCV][InsertVSETVLI] Mutate prior vsetvli AVL if doing so allows us to remove a toggle

This extends the backwards walk to allow mutating the previous vsetvl's AVL value if it was not used by any instructions in between. In practice, this mostly benefits vmv.x.s and fvmv.f.s patterns since vector instructions which ignore VL are rare.

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

20 months ago[AArch64] Extending lowering of 'trunc <(8|16) x i64> %x to <(8|16) x i8>' to use...
Nilanjana Basu [Tue, 22 Nov 2022 20:04:26 +0000 (12:04 -0800)]
[AArch64] Extending lowering of 'trunc <(8|16) x i64> %x to <(8|16) x i8>' to use tbl instructions

[AArch64] Patch for lowering trunc instructions to 'tbl' for (8|16)xi32 -> (8|16)xi8 conversions in https://reviews.llvm.org/D133495 is extended to support trunc to tbl lowering for (8|16) x i64 to (8|16) x i8.

A microbenchmark for runtime for these transformations is added in https://reviews.llvm.org/D136274

Reviewed by: fhahn, t.p.northover

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

20 months ago[AArch64] Extra unit tests for trunc lowering of vectors
Nilanjana Basu [Wed, 23 Nov 2022 00:16:44 +0000 (16:16 -0800)]
[AArch64] Extra unit tests for trunc lowering of vectors

These tests show code generation for vectorized trunc lowering from i16 to i8 in AArch64.

Reviewed By: fhahn

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

20 months ago[Hexagon] Record original result type in wide multiplication
Krzysztof Parzyszek [Thu, 15 Dec 2022 00:23:45 +0000 (16:23 -0800)]
[Hexagon] Record original result type in wide multiplication

20 months ago[SelectionDAG] Do not second-guess alignment for alloca
Andrew Savonichev [Thu, 15 Dec 2022 15:16:45 +0000 (18:16 +0300)]
[SelectionDAG] Do not second-guess alignment for alloca

Alignment of an alloca in IR can be lower than the preferred alignment
on purpose, but this override essentially treats the preferred
alignment as the minimum alignment.

The patch changes this behavior to always use the specified
alignment. If alignment is not set explicitly in LLVM IR, it is set to
DL.getPrefTypeAlign(Ty) in computeAllocaDefaultAlign.

Tests are changed as well: explicit alignment is increased to match
the preferred alignment if it changes output, or omitted when it is
hard to determine the right value (e.g. for pointers, some structs, or
weird types).

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

20 months ago[NFC] Use std::optional over llvm::Optional to implement MaybeAlign
Guillaume Chatelet [Thu, 15 Dec 2022 13:52:00 +0000 (13:52 +0000)]
[NFC] Use std::optional over llvm::Optional to implement MaybeAlign

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

20 months agoRevert "[clang][CodeGen] Use base subobject type layout for potentially-overlapping...
Vladislav Dzhidzhoev [Thu, 15 Dec 2022 15:09:06 +0000 (18:09 +0300)]
Revert "[clang][CodeGen] Use base subobject type layout for potentially-overlapping fields"

This reverts commit 731abdfdcc33d813e6c3b4b89eff307aa5c18083.

This commit breaks some tests in libcxx, e.g.
`std/utilities/expected/expected.expected/ctor/ctor.inplace.pass.cpp`

20 months ago[CodeComplete] Complete members of dependent `auto` variables
Sam McCall [Wed, 14 Dec 2022 19:53:18 +0000 (20:53 +0100)]
[CodeComplete] Complete members of dependent `auto` variables

When the initializer of an `auto` variable is dependent, clang doesn't give the
DeclRefExpr a useful dependent type that we can apply heuristics to.
However we can dig one up by looking at the initializer.

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

20 months ago[PowerPC] Simplify PPCSubtarget
Kai Nacke [Wed, 14 Dec 2022 15:55:53 +0000 (15:55 +0000)]
[PowerPC] Simplify PPCSubtarget

The flags, initialization of the flags, and the getter methods for
features defined in PPC.td can be generated by TableGen.

Reviewed By: shchenz

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

20 months ago[PPC] Convert tests to check 'target=<triple>'
Paul Robinson [Tue, 29 Nov 2022 22:41:36 +0000 (14:41 -0800)]
[PPC] Convert tests to check 'target=<triple>'

Two tests checked 'ppc64be' which appears not to exist; the tests
pass on clang-ppc64be-linux-multistage so I assume they are fine
and just removed those UNSUPPORTED lines. All others were converted
to the new target= format, and get the same results on ppc bots as
before.

Part of the project to eliminate special handling for triples in lit
expressions.

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

20 months agoReland "[TargetLowering] Teach DemandedBits about VSCALE"
Benjamin Maxwell [Mon, 12 Dec 2022 16:26:20 +0000 (16:26 +0000)]
Reland "[TargetLowering] Teach DemandedBits about VSCALE"

Reland with a fixup to avoid converting APInts to int64_t which allowed for
overflows (UB) with sufficiently high/low multiplier values.

This allows DemandedBits to see the result of VSCALE will be at most
VScaleMax * some compile-time constant. This relies on the vscale_range()
attribute being present on the function, with a max set. (This is done by
default when clang is targeting AArch64+SVE).

Using this various redundant operations (zexts, sexts, ands, ors, etc)
can be eliminated.

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

20 months ago[MachineCombiner][RISCV] Support inverse instructions reassociation
Anton Sidorenko [Thu, 24 Nov 2022 12:30:01 +0000 (15:30 +0300)]
[MachineCombiner][RISCV] Support inverse instructions reassociation

This patch adds reassociation of FADD/FSUB instruction pairs.

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

20 months ago[NFC][LLDB] Using namespace llvm in EmulateInstructionRISCV
Emmmer [Thu, 15 Dec 2022 11:16:08 +0000 (19:16 +0800)]
[NFC][LLDB] Using namespace llvm in EmulateInstructionRISCV

The `EmulateInstructionRISCV` uses a lot of types and functions in `llvm` and `lldb`, this change is to make the code look cleaner.

PS: This patch should be merged before D140032.

Reviewed By: DavidSpickett

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

20 months ago[InstCombine] limit pair-of-insertelement folds to avoid miscompile
Sanjay Patel [Wed, 14 Dec 2022 22:52:50 +0000 (17:52 -0500)]
[InstCombine] limit pair-of-insertelement folds to avoid miscompile

This transform was added with 4446f71ce392. However, as noted in
the post-commit feedback, the transform is not safe with an
arbitrary base vector because we may leak poison from a narrow
element into an adjacent element when bitcasting.

I made the least invasive code change in case we do figure out
a way to make this safe.

20 months ago[clang-format] make doc for SLS_Inline more clearly
Backl1ght [Thu, 15 Dec 2022 01:08:54 +0000 (09:08 +0800)]
[clang-format] make doc for SLS_Inline more clearly

Reviewed By: HazardyKnusperkeks, MyDeveloperDay
Differential Revision: https://reviews.llvm.org/D139937

20 months ago[flang] Lower binary and unary elemental array operations
Jean Perier [Thu, 15 Dec 2022 11:54:56 +0000 (12:54 +0100)]
[flang] Lower binary and unary elemental array operations

Lower binary and unary elemental operations with an array argument
using hlfir.elemental, hlfir.yield_element, and hlfir.apply.

Concat implementation, which is a binary operation, is moved to a
BinaryOp struct so that it can leverage this new code.

This patch implements the "not yet implemented: character array
expression temp with dynamic length" TODO of the current lowering
by splitting the result length computation from the result value
computation. That way, the result length computation can be done
before lowering the operation to an hlfir.elemental, and the length
of the hlfir.elemental is known and storage for it can later be
allocated.

It adds a DesignatorOp builder to make "dumb" indexing (without triplets,
component, substrings or derived type component ref) easier since indexing
needs to be generated for array variables in elemental expression (in
the added hlfir::genElementAt helper).

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

20 months ago[clang][CodeGen] Use base subobject type layout for potentially-overlapping fields
Vladislav Dzhidzhoev [Fri, 9 Dec 2022 18:36:16 +0000 (21:36 +0300)]
[clang][CodeGen] Use base subobject type layout for potentially-overlapping fields

RecordLayoutBuilder assumes the size of a potentially-overlapping field
with non-zero size as the size of the base subobject type corresponding
to the field type.
Make CGRecordLayoutBuilder to acknowledge that in order to avoid incorrect
padding insertion.

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

20 months ago[DAGCombine] Fix always true condition in combineShiftToMULH
Juan Manuel MARTINEZ CAAMAÑO [Thu, 15 Dec 2022 10:33:30 +0000 (11:33 +0100)]
[DAGCombine] Fix always true condition in combineShiftToMULH

Reviewed By: RKSimon

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

20 months ago[AArch64][GlobalISel][Legalizer] Legalize G_SHUFFLE_VECTOR with different lengths
Vladislav Dzhidzhoev [Mon, 15 Aug 2022 18:51:13 +0000 (21:51 +0300)]
[AArch64][GlobalISel][Legalizer] Legalize G_SHUFFLE_VECTOR with different lengths

Legalize G_SHUFFLE_VECTOR having destination vector length greater than
source vector length by reshaping source vectors.

Partial implementation of SelectionDAGBuilder::visitShuffleVector.

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

20 months ago[Clang][CodeGen] Use poison instead of undef in CodeGen for ARM Builtins [NFC]
Manuel Brito [Thu, 15 Dec 2022 11:54:52 +0000 (11:54 +0000)]
[Clang][CodeGen] Use poison instead of undef in CodeGen for ARM Builtins [NFC]

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

20 months ago[PowerPC] Fix MSVC "switch statement contains 'default' but no 'case' labels" warning...
Simon Pilgrim [Thu, 15 Dec 2022 11:53:59 +0000 (11:53 +0000)]
[PowerPC] Fix MSVC "switch statement contains 'default' but no 'case' labels" warning. NFC.

20 months agoRevert "[TargetLowering] Teach DemandedBits about VSCALE"
Benjamin Maxwell [Thu, 15 Dec 2022 11:29:34 +0000 (11:29 +0000)]
Revert "[TargetLowering] Teach DemandedBits about VSCALE"

This reverts commit c165b0553a96394b9bbf3984782703cdae99821d.

20 months ago[mlir][linalg][NFC] Split populateFoldUnitExtentDimsViaReshapesPatterns
Matthias Springer [Thu, 15 Dec 2022 10:44:47 +0000 (11:44 +0100)]
[mlir][linalg][NFC] Split populateFoldUnitExtentDimsViaReshapesPatterns

MoveInitOperandsToInput is put into a separate populate... function because it can interfere with certain transformations.

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

20 months ago[flang] Fix associating entity when selector is an array, pointer or allocatable
Valentin Clement [Thu, 15 Dec 2022 11:02:11 +0000 (12:02 +0100)]
[flang] Fix associating entity when selector is an array, pointer or allocatable

In SELECT TYPE, within the block following TYPE IS, the associating entity is not polymorphic.
It has the type named in the type guard and other properties taken from the
selector. Within the block following a CLASS IS type guard statement, the
associating entity is polymorphic and has the declared type named in the type
guard statement.
This patch makes sure the associating entity matches the selector if it is
an array, a pointer or an allocatable.

Reviewed By: jeanPerier

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

20 months ago[WebAssembly] Use ComplexPattern on remaining memory instructions
Luke Lau [Thu, 15 Dec 2022 10:18:06 +0000 (10:18 +0000)]
[WebAssembly] Use ComplexPattern on remaining memory instructions

This continues the refactoring work of selecting offset + address
operands with the AddrOpsN pattern, previously called LoadOpsN.

This is not an NFC, since constant addresses are now folded into the
offset in more places for v128.storeN_lane.

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

20 months ago[flang][NFC] add builder to simplify fir.shape creation
Jean Perier [Thu, 15 Dec 2022 10:13:54 +0000 (11:13 +0100)]
[flang][NFC] add builder to simplify fir.shape creation

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

20 months ago[flang] Add hlfir.apply definition
Jean Perier [Thu, 15 Dec 2022 10:12:29 +0000 (11:12 +0100)]
[flang] Add hlfir.apply definition

hlfir.apply allows retrieving element values from an array expression
value. See https://github.com/llvm/llvm-project/blob/main/flang/docs/HighLevelFIR.md
for more detail.

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

20 months ago[flang] Add hlfir.elemental and hlfir.yield_element definition
Jean Perier [Thu, 15 Dec 2022 10:09:57 +0000 (11:09 +0100)]
[flang] Add hlfir.elemental and hlfir.yield_element definition

hlfir.elemental is the operation that will allow representing all
Fortran elemental expressions and more as functions of the indices.
See https://github.com/llvm/llvm-project/blob/main/flang/docs/HighLevelFIR.md for
more details about it.

Also add hlfir.yield_elemement which is the hlfir.elemental region terminator.

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

20 months ago[RISCV] Allow conversion of fp divisions to fp multiplications by the reciprocal
Anton Sidorenko [Wed, 30 Nov 2022 14:57:33 +0000 (17:57 +0300)]
[RISCV] Allow conversion of fp divisions to fp multiplications by the reciprocal

If the divisor is repeated at least twice, we will convert the FDIVs to the
calculation of the reciprocal and FMULs.

We perform the transformation only under fast-math mode. FDIVs must have
'arcp' flag.

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

20 months ago[RISCV] Precommit test for D140024
Anton Sidorenko [Wed, 30 Nov 2022 13:57:20 +0000 (16:57 +0300)]
[RISCV] Precommit test for D140024

Simple test to check converson of repeated fp divisors.

20 months agoYAMLParser: llvm::Optional => std::optional
Fangrui Song [Thu, 15 Dec 2022 09:34:31 +0000 (09:34 +0000)]
YAMLParser: llvm::Optional => std::optional

20 months ago[mlir][test] Add expand-strided-metadata to lower-to-llvm
Quentin Colombet [Mon, 12 Dec 2022 14:37:30 +0000 (14:37 +0000)]
[mlir][test] Add expand-strided-metadata to lower-to-llvm

This patch adds the `ExpandStridedMetadataPass` to the LowerToLLVM named
pipeline.
This is required now that "complex" memref operations, like subviews,
need to be expanded before being lowered.

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

20 months agoMIPS: fix build from IR files, nan2008 and FpAbi
YunQiang Su [Thu, 15 Dec 2022 09:04:36 +0000 (09:04 +0000)]
MIPS: fix build from IR files, nan2008 and FpAbi

When we use llc or lld to compiler IR files, the features +nan2008 and +fpxx/+fp64 are not used.
Thus wrong format files are produced.

In IR files, the attributes are only set for function while not the whole compile units.
So we output `.nan 2008` and `.module fp=xx/64` before every function.

`isFPXXDefault`: for o32, the FPXX should always be the default, no matter about the vendors.
Of course some distributions with FP64 default enabled should be listed explicit.
Let's add them in future if we know about one.

Reviewed By: MaskRay

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

20 months ago[SCEV] Convert some tests to opaque pointers (NFC)
Nikita Popov [Thu, 15 Dec 2022 08:59:15 +0000 (09:59 +0100)]
[SCEV] Convert some tests to opaque pointers (NFC)

20 months ago[CostModel] Convert some tests to opaque pointers (NFC)
Nikita Popov [Thu, 15 Dec 2022 08:54:44 +0000 (09:54 +0100)]
[CostModel] Convert some tests to opaque pointers (NFC)

These required some manual fixup.

20 months ago[CostModel] Convert test to opaque pointers (NFC)
Nikita Popov [Thu, 15 Dec 2022 08:52:14 +0000 (09:52 +0100)]
[CostModel] Convert test to opaque pointers (NFC)

Replace GEP index from 0 to 1 so it is not a trivial GEP.