platform/upstream/llvm.git
12 months ago[MLIR][OpenMP] Minor change to assembly format for Target Data op
Akash Banerjee [Tue, 20 Jun 2023 13:57:27 +0000 (14:57 +0100)]
[MLIR][OpenMP] Minor change to assembly format for Target Data op

Minor reordering of clauses in the assembly format for Target Data op to make it closer to the OpenMP standard.

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

12 months ago[flang] Fix bug with generic and homonymous specific module procedure
Peter Klausler [Tue, 20 Jun 2023 20:45:22 +0000 (13:45 -0700)]
[flang] Fix bug with generic and homonymous specific module procedure

An unconditional EraseSymbol() call was deleting a generic interface symbol
when the generic had a module procedure of the same name as a specific
procedure, and the module procedure's definition appeared in the same
module.  Also clean up some applications of the MODULE attribute to
symbols created along the way.

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

12 months ago[InstCombine] Fold assume(false) to non-terminator unreachable
Nikita Popov [Thu, 22 Jun 2023 10:15:58 +0000 (12:15 +0200)]
[InstCombine] Fold assume(false) to non-terminator unreachable

assume(false) is immediate UB, so fold it to (non-terminator)
unreachable.

12 months ago[LSR] Adjust test to make sure it keeps testing for the original issue.
Florian Hahn [Thu, 22 Jun 2023 14:36:31 +0000 (15:36 +0100)]
[LSR] Adjust test to make sure it keeps testing for the original issue.

Make sure the test keeps testing for the original issue after D153202.

12 months ago[flang] Fix USE with homonymous renaming
Peter Klausler [Wed, 21 Jun 2023 18:37:53 +0000 (11:37 -0700)]
[flang] Fix USE with homonymous renaming

Fortran requires that a USE with renaming prevent the USE'd symbol
from also being associated into a scope without renaming.  The
implementation in name resolution gets confused in the case of
a USE with renaming using the same name ("x => x").  Clean things
up.  Fixes LLVM bug https://github.com/llvm/llvm-project/issues/63397.

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

12 months ago[InstCombine] Remove instructions before non-terminator unreachable
Nikita Popov [Thu, 22 Jun 2023 14:19:47 +0000 (16:19 +0200)]
[InstCombine] Remove instructions before non-terminator unreachable

Treat non-terminator unreachable the same as unreachable, and
remove guaranteed-to-transfer instructions before it.

12 months ago[InstCombine] Add additional instructions in non-term unreachable test (NFC)
Nikita Popov [Thu, 22 Jun 2023 14:29:17 +0000 (16:29 +0200)]
[InstCombine] Add additional instructions in non-term unreachable test (NFC)

12 months ago[InstCombine] Avoid UB in tests (NFC)
Nikita Popov [Thu, 22 Jun 2023 14:25:49 +0000 (16:25 +0200)]
[InstCombine] Avoid UB in tests (NFC)

12 months ago[flang] Rewrite "1*j" to "(j)", not "j", when j is a variable
Peter Klausler [Wed, 21 Jun 2023 19:43:55 +0000 (12:43 -0700)]
[flang] Rewrite "1*j" to "(j)", not "j", when j is a variable

Expression folding currently unconditionally rewrites "1*j"
to "j", which is wrong when "j" is a variable, as it transforms
an expression into a variable and can lead to incorrect associations
in contexts like an actual argument or an ASSOCIATE selector.
Transform "1*j" to a parenthesized "(j)" when "j" is a variable.
Fixes LLVM bug https://github.com/llvm/llvm-project/issues/63259.

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

12 months ago[flang] Fix looping on LEN type parameter usage
Peter Klausler [Wed, 21 Jun 2023 20:35:53 +0000 (13:35 -0700)]
[flang] Fix looping on LEN type parameter usage

When a LEN type parameter of one PDT is being used as the value
of a LEN type parameter in another PDT, expression rewriting can
loop infinitely due to an incorrect assumption that the same PDT's
parameters are being referenced.

Fixes LLVM bug https://github.com/llvm/llvm-project/issues/63198

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

12 months ago[InstCombine] Remove code after non-terminator unreachable
Nikita Popov [Thu, 22 Jun 2023 13:37:33 +0000 (15:37 +0200)]
[InstCombine] Remove code after non-terminator unreachable

Instruction after a non-terminator unreachable are ... unreachable,
so remove them. Reuse the same logic we use for removing
instructions from dead blocks.

12 months ago[InstCombine] Add test for code after non-terminator unreachable (NFC)
Nikita Popov [Thu, 22 Jun 2023 13:56:41 +0000 (15:56 +0200)]
[InstCombine] Add test for code after non-terminator unreachable (NFC)

12 months ago[InstCombine] Don't remove non-terminator unreachable markers
Nikita Popov [Thu, 22 Jun 2023 13:50:22 +0000 (15:50 +0200)]
[InstCombine] Don't remove non-terminator unreachable markers

Even if the value happens to be undef, we should preserve these so
they get turned into an unreachable terminator later.

12 months ago[flang] Error recovery in bad specific MIN/MAX calls
Peter Klausler [Wed, 21 Jun 2023 21:33:48 +0000 (14:33 -0700)]
[flang] Error recovery in bad specific MIN/MAX calls

When a specific MIN/MAX intrinsic function (e.g. MAX1) reference
has an actual argument error, ensure that a later attempt to fold
the call into a constant doesn't crash due to a missing argument.
Fixes https://github.com/llvm/llvm-project/issues/63140

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

12 months ago[InstCombine] Avoid UB in tests (NFC)
Nikita Popov [Thu, 22 Jun 2023 13:42:31 +0000 (15:42 +0200)]
[InstCombine] Avoid UB in tests (NFC)

12 months ago[flang] Rework name resolution of Cray pointer declarations
Peter Klausler [Tue, 20 Jun 2023 22:40:35 +0000 (15:40 -0700)]
[flang] Rework name resolution of Cray pointer declarations

The current code has redundancy with the infrastructure for
declaration checking that can be replaced by better usage of
the parse tree walking framework.  This also fixes LLVM flang
bug #58971.

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

12 months agowip
Peter Klausler [Tue, 20 Jun 2023 16:36:12 +0000 (09:36 -0700)]
wip

12 months ago[Headers][doc] Add various arith/logical intrinsic descriptions to avx2intrin.h
Paul Robinson [Wed, 21 Jun 2023 20:01:32 +0000 (13:01 -0700)]
[Headers][doc] Add various arith/logical intrinsic descriptions to avx2intrin.h

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

12 months ago[include-cleaner] No need to overwrite the source file if there is no
Haojian Wu [Thu, 22 Jun 2023 12:35:28 +0000 (14:35 +0200)]
[include-cleaner] No need to overwrite the source file if there is no
cleanups

12 months agoRevert "Revert "Revert "[LLD][ELF] Cortex-M Security Extensions (CMSE) Support"""
Mitch Phillips [Thu, 22 Jun 2023 12:28:42 +0000 (14:28 +0200)]
Revert "Revert "Revert "[LLD][ELF] Cortex-M Security Extensions (CMSE) Support"""

This reverts commit 9246df7049b0bb83743f860caff4221413c63de2.

Reason: This patch broke the UBSan buildbots. See more information in
the original phabricator review: https://reviews.llvm.org/D139092

12 months ago[AMDGPU] Regenerate some checks
Jay Foad [Thu, 22 Jun 2023 11:25:16 +0000 (12:25 +0100)]
[AMDGPU] Regenerate some checks

12 months ago[AArch64] Remove G_VECREDUCE_FADD from selectReduction
David Green [Thu, 22 Jun 2023 11:46:54 +0000 (12:46 +0100)]
[AArch64] Remove G_VECREDUCE_FADD from selectReduction

I believe that for fp reductions we can use the imported tablegen patterns for
selection, as opposed to going via selectReduction. Integer reductions are more
difficult, as the return types in selection DAG will be promoted to i32.

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

12 months ago[AMDGPU] Switch to the new cl option amdgpu-atomic-optimizer-strategy.
Pravin Jagtap [Thu, 22 Jun 2023 11:03:47 +0000 (07:03 -0400)]
[AMDGPU] Switch to the new cl option amdgpu-atomic-optimizer-strategy.

Atomic optimizer is turned on by default through D152649. This patch
removes the usage of old command line option amdgpu-atomic-optimizations
and transfer the responsibility to `amdgpu-atomic-optimizer-strategy`.

We can safely remove old option when LLPC remove its all usage.

Reviewed By: foad, arsenm, #amdgpu, cdevadas

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

12 months ago[LoopUnroll] Regenerate test checks (NFC)
Nikita Popov [Thu, 22 Jun 2023 11:00:02 +0000 (13:00 +0200)]
[LoopUnroll] Regenerate test checks (NFC)

12 months ago[InstCombine] Use CreateNonTerminatorUnreachable() helper
Nikita Popov [Thu, 22 Jun 2023 10:23:46 +0000 (12:23 +0200)]
[InstCombine] Use CreateNonTerminatorUnreachable() helper

Create the standard non-terminator unreachable, rather than a
slight variation on it.

12 months ago[NFC SVE ACLE] Remove IR combines that no longer apply.
Jolanta Jensen [Tue, 20 Jun 2023 12:51:41 +0000 (12:51 +0000)]
[NFC SVE ACLE] Remove IR combines that no longer apply.

Remove IR combines that no longer apply after the SVE merging
intrinsics taking an all active predicate, have been canonicalised
to their equivalent undef (_u) variants.

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

12 months agoDAG: Expand legalization of is.fpclass to fcmp for DAZ
Matt Arsenault [Wed, 1 Feb 2023 00:27:51 +0000 (20:27 -0400)]
DAG: Expand legalization of is.fpclass to fcmp for DAZ

Try to use a compare with 0 if DAZ is assumed.
FPClassTest really needs to be marked as a bimask enum, but the API
for that is currently broken.

12 months agoAdd some unit tests for DenormalMode helper
Matt Arsenault [Thu, 22 Jun 2023 01:31:36 +0000 (21:31 -0400)]
Add some unit tests for DenormalMode helper

Split out from D143180

12 months ago[DAG] ScalarizeVectorResult - add ISD::MULHS/ISD::MULHU handling
Simon Pilgrim [Thu, 22 Jun 2023 10:04:54 +0000 (11:04 +0100)]
[DAG] ScalarizeVectorResult - add ISD::MULHS/ISD::MULHU handling

Fixes #63439

12 months ago[AMDGPU][GFX11] Add test coverage for 16-bit conversions, part 14.
Ivan Kosarev [Thu, 22 Jun 2023 09:47:58 +0000 (10:47 +0100)]
[AMDGPU][GFX11] Add test coverage for 16-bit conversions, part 14.

Reviewed By: arsenm

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

12 months ago[AMDGPU][GFX11] Add test coverage for 16-bit conversions, part 13.
Ivan Kosarev [Thu, 22 Jun 2023 09:04:05 +0000 (10:04 +0100)]
[AMDGPU][GFX11] Add test coverage for 16-bit conversions, part 13.

Reviewed By: arsenm

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

12 months ago[mlir][linalg] Remove duplicate tensor.pad lowering pattern
Matthias Springer [Thu, 22 Jun 2023 09:30:57 +0000 (11:30 +0200)]
[mlir][linalg] Remove duplicate tensor.pad lowering pattern

There is another transform that lowers tensor.pad to tensor.empty + linalg.fill + tensor.insert_slice: `transform.structured.rewrite_in_destination_passing_style`. Delete the other transform.

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

12 months ago[clang-tidy][NFC] Add missing argument comment to LexerUtils.cpp
Piotr Zegar [Thu, 22 Jun 2023 08:02:20 +0000 (08:02 +0000)]
[clang-tidy][NFC] Add missing argument comment to LexerUtils.cpp

D148697 post commit review change.

12 months ago[mlir][affine] Fix build after D153324
Matthias Springer [Thu, 22 Jun 2023 09:03:10 +0000 (11:03 +0200)]
[mlir][affine] Fix build after D153324

12 months ago[mlir][tensor] Clean up tensor::DimOp usage
Matthias Springer [Thu, 22 Jun 2023 08:49:37 +0000 (10:49 +0200)]
[mlir][tensor] Clean up tensor::DimOp usage

* Remove duplicate functions. `tensor::getMixedSize` and `tensor::getMixedSizes` should be used.
* Use `tensor::getMixedSize` instead of `createOrFold<tensor::DimOp>`. This is more efficient. `createOrFold` will create an op an immediately try to fold it. In case of a static dimension size, an attribute can be used directly.

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

12 months ago[AArch64] Mark vecreduce_fminimum and vecreduce_fmaximum as legal
David Green [Thu, 22 Jun 2023 08:52:02 +0000 (09:52 +0100)]
[AArch64] Mark vecreduce_fminimum and vecreduce_fmaximum as legal

This adds some simple lowering of vecreduce_fminimum and vecreduce_fmaximum to
fminv/fmaxv instructions, in the same way that vecreduce_fmax / vecreduce_fmin
is lowered to fminnmv / fmaxnmv.

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

12 months ago[SCEV] Don't store AddRec loop when simplifying multiplication of AddRecs
Dmitry Makogon [Mon, 19 Jun 2023 09:33:46 +0000 (16:33 +0700)]
[SCEV] Don't store AddRec loop when simplifying multiplication of AddRecs

When multiplying several AddRecs, we do the following simplification:

{A1,+,A2,+,...,+,An}<L> * {B1,+,B2,+,...,+,Bn}<L> = {x=1 in [ sum y=x..2x
[ sum z=max(y-x, y-n)..min(x,n) [
choose(x, 2x)*choose(2x-y, x-z)*A_{y-z}*B_z]]
],+,...up to x=2n}

This is done iteratively, pair by pair. So if we try to multiply three AddRecs
A1, A2, A3, then we'd try to simplify A1 * A2 to A1' and then try to
simplify A1' * A3 if A1' is also an AddRec.
The transform is only legal if the loops of the two AddRecs are the same.
It is checked in the code, but the loop of one of the AddRecs is stored
in a local variable and doesn't get updated when we simplify a pair to a new AddRec.
In the motivating test the new AddRec A1' was created for a different loop and,
as the loop variable didn't get updated, the check for different loops passed and
the transform worked for two AddRecs from different loops.
So it created a wrong SCEV. And it caused LSR to replace an instruction with another
one that had the same SCEV as the incorrectly computed one.

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

12 months ago[mlir][affine] More efficient `makeComposedFolded...` helpers
Matthias Springer [Thu, 22 Jun 2023 08:39:34 +0000 (10:39 +0200)]
[mlir][affine] More efficient `makeComposedFolded...` helpers

The old code used to materialize constants as ops, immediately folded them into the resulting affine map and then deleted the constant ops again. Instead, directly fold the attributes into the affine map. Furthermore, all helpers accept `OpFoldResult` instead of `Value` now. This makes the code at call sites more efficient, because it is no longer necessary to materialize a `Value`, just to be able to use these helper functions.

Note: The API has changed (accepts OpFoldResult instead of Value), otherwise this change is NFC.

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

12 months ago[AMDGPU] Add llvm.amdgcn.cs.chain intrinsic to IR & verifier
Diana Picus [Wed, 7 Jun 2023 08:47:22 +0000 (10:47 +0200)]
[AMDGPU] Add llvm.amdgcn.cs.chain intrinsic to IR & verifier

We only check a subset of the constraints in the verifier:
* that we only call the intrinsic from functions with a restricted set of
calling conventions
* that the 'flags' argument is an immediate

Other checks are (probably) more appropriate for codegen.

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

12 months ago[AMDGPU] Add amdgpu_cs_chain[_preserve] CCs to IR & verifier
Diana Picus [Wed, 7 Jun 2023 08:18:31 +0000 (10:18 +0200)]
[AMDGPU] Add amdgpu_cs_chain[_preserve] CCs to IR & verifier

Add the amdgpu_cs_chain and amdgpu_cs_chain_preserve keywords to
LLVM IR and make sure we can parse and print them. Also make sure we
perform some basic checks in the IR verifier - similar to what we check
for many of the other AMDGPU calling conventions, plus the additional
restriction that we can't have direct calls to functions with these
calling conventions.

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

12 months ago[BOLT][RISCV] Add tests for simple CFG transformations
Job Noorman [Thu, 22 Jun 2023 07:34:57 +0000 (09:34 +0200)]
[BOLT][RISCV] Add tests for simple CFG transformations

Reviewed By: rafauler

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

12 months ago[BOLT] Don't register internal func relocs as external references
Job Noorman [Thu, 22 Jun 2023 07:33:32 +0000 (09:33 +0200)]
[BOLT] Don't register internal func relocs as external references

Currently, all relocations that point inside a function are registered
as external references. If these relocations cannot be resolved as jump
tables or computed gotos, the containing function gets marked as
not-simple and excluded from optimizations.

RISC-V uses relocations for branches and jumps (to support linker
relaxation) and as such, almost no functions get marked as simple. This
patch fixes this by only registering relocations that originate outside
of the referenced function as external references.

Reviewed By: rafauler

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

12 months ago[BOLT][RISCV] Implement R_RISCV_ADD32/SUB32
Job Noorman [Thu, 22 Jun 2023 07:32:32 +0000 (09:32 +0200)]
[BOLT][RISCV] Implement R_RISCV_ADD32/SUB32

Thispatch implements the R_RISCV_ADD32 and R_RISCV_SUB32 relocations for
RISC-V.

Reviewed By: rafauler

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

12 months ago[coroutine] Add missing presplitcoroutine attr to example
Itay Bookstein [Thu, 22 Jun 2023 07:23:52 +0000 (10:23 +0300)]
[coroutine] Add missing presplitcoroutine attr to example

Signed-off-by: Itay Bookstein <itay.bookstein@nextsilicon.com>
12 months ago[Driver][BareMetal] Error if no matching multilib
Michael Platings [Mon, 19 Jun 2023 15:02:52 +0000 (16:02 +0100)]
[Driver][BareMetal] Error if no matching multilib

Previously if no matching multilib was found then the user would
typically see an error like "fatal error: 'stdio.h' file not found"
which gives no indication as to the underlying problem.
With this change the user will instead see an error like
  clang: error: no multilib found matching flags: --target=thumbv7em-none-unknown-eabi -march=...
  clang: note: available multilibs are:
  --target=armv4t-none-unknown-eabi
  --target=thumbv6m-none-unknown-eabi -mfpu=none
  ...

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

12 months ago[mlir][llvm] Fix import of SwitchOp
Tobias Gysi [Thu, 22 Jun 2023 06:27:12 +0000 (06:27 +0000)]
[mlir][llvm] Fix import of SwitchOp

This revision ensures SwitchOps with case and condition
bitwidths other than 32-bit are imported properly. It adds an
APInt based builder to the SwitchOp and implements
a verifier that checks that the condition and the case
value types match.

Reviewed By: Dinistro

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

12 months ago[libc] Place headers in the right include directory
Petr Hosek [Fri, 9 Jun 2023 07:14:28 +0000 (07:14 +0000)]
[libc] Place headers in the right include directory

When LLVM_ENABLE_PER_TARGET_RUNTIME_DIR is enabled, place headers
in `include/<target>` directory, otherwise use `include/`.

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

12 months ago[test][sanitizer] Reformat and print to stderr
Vitaly Buka [Thu, 22 Jun 2023 06:05:21 +0000 (23:05 -0700)]
[test][sanitizer] Reformat and print to stderr

12 months ago[Bazel][mlir] Avoid ODR violation introduced in 7ab749c.
Christian Sigg [Thu, 22 Jun 2023 05:50:38 +0000 (07:50 +0200)]
[Bazel][mlir] Avoid ODR violation introduced in 7ab749c.

This change also prepares for 9119325 to land again.

Adds `mlir_c_runner_utils_hdrs` and `mlir_runner_utils_hdrs` targets which do not depend on `//llvm::Support`.

These can be used by other 'runner.so' targets if they are loaded along with the 'runner_utils.so' without calling `__mlir_execution_engine_init()` twice.

12 months ago[llvm] Split out DenseMapInfo<variant> specialization
Elliot Goodrich [Thu, 22 Jun 2023 05:49:43 +0000 (06:49 +0100)]
[llvm] Split out DenseMapInfo<variant> specialization

Remove the `DenseMapInfo<std::variant<Ts...>>` variant out from
`llvm/ADT/DenseMapInfo.h` into a separate header
`llvm/ADT/DenseMapInfoVariant.h`

This allows us to remove the `<variant>` include, which is being
transitively and unncessary included in all translation units that
include `llvm/ADT/DenseMap.h`.

There have been similar changes to move out specializations for

    * `APInt.h` fd7e309e02fd226b0390888388ed732608e52c73 and
    * `StringRef.h`/`ArrayRef.h`
      983565a6fe4a9f40c7caf82b65c650c20dbcc104

to reduce the compilation time. As we are unable to move the
specialization into `<variant>`, we create a separate
`DenseMapInfoVariant.h` header that can be used by anyone who needs this
specialization.

This reduces the total number of preprocessing tokens across the LLVM
source files in lib from (roughly) 1,964,876,961 to 1,936,551,496 - a
reduction of ~1.44%. This should result in a small improvement in
compilation time.

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

12 months ago[mlir][docgen] Enable op grouping mechanism.
Jacques Pienaar [Mon, 19 Jun 2023 21:24:14 +0000 (14:24 -0700)]
[mlir][docgen] Enable op grouping mechanism.

Add ability to be able to group ops together in documentation generation. This
results in section of ops grouped together under one summary & description.
This doesn't do anything special for the groups beyond nesting yet.

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

12 months ago[NFC][sanitizer] Rename internal getters
Vitaly Buka [Thu, 22 Jun 2023 03:59:07 +0000 (20:59 -0700)]
[NFC][sanitizer] Rename internal getters

12 months ago[RISCV] Separate scheduler calsses for vfredmax/min
Michael Maitland [Wed, 21 Jun 2023 18:23:55 +0000 (11:23 -0700)]
[RISCV] Separate scheduler calsses for vfredmax/min

vfredmax/min may have different scheduling behavior on different
microarchitectures compared to other reductions. This different
behavior can be described by giving vfredmax/min separate
scheduling resources.

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

12 months agoIntrinsics: Allow tablegen to mark parameters with dereferenceable
Matt Arsenault [Sat, 7 Jan 2023 13:52:16 +0000 (08:52 -0500)]
Intrinsics: Allow tablegen to mark parameters with dereferenceable

12 months agoHIP: Directly call ldexp builtins
Matt Arsenault [Sun, 20 Nov 2022 16:37:13 +0000 (08:37 -0800)]
HIP: Directly call ldexp builtins

12 months ago[mlir][sparse][gpu] refine SDDMM pattern for cuSPARSE
Aart Bik [Thu, 22 Jun 2023 01:04:05 +0000 (18:04 -0700)]
[mlir][sparse][gpu] refine SDDMM pattern for cuSPARSE

Old pattern was missing some cases (e.g. swapping the arguments)
but it also allowed too many cases (e.g. non-empty "absent" or
different arguments for add/mul). This fixes the issues.

Reviewed By: K-Wu

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

12 months agoAMDGPU: Drop and upgrade llvm.amdgcn.atomic.inc/dec to atomicrmw
Matt Arsenault [Thu, 3 Nov 2022 06:43:38 +0000 (23:43 -0700)]
AMDGPU: Drop and upgrade llvm.amdgcn.atomic.inc/dec to atomicrmw

12 months ago[RISCV] Minor refactoring of some code in copyPhysReg. NFC
Craig Topper [Thu, 22 Jun 2023 01:02:53 +0000 (18:02 -0700)]
[RISCV] Minor refactoring of some code in copyPhysReg. NFC

Move some of the vmv.v.i handling into the vmv.v.v if. This
reduces the scope of one variable.

12 months ago[TableGen][Target] Rename Attribute field in SubtargetFeature class to FieldName.
Craig Topper [Thu, 22 Jun 2023 00:53:49 +0000 (17:53 -0700)]
[TableGen][Target] Rename Attribute field in SubtargetFeature class to FieldName.

The word "attribute" has a specific meaning in LLVM. Avoid using it
here to mean something different.

This addresses feedback from D153180.

Reviewed By: arsenm

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

12 months ago[flang] don't require -flang-experimental-exec flag anymore
Brad Richardson [Wed, 8 Feb 2023 16:13:12 +0000 (10:13 -0600)]
[flang] don't require -flang-experimental-exec flag anymore

Reviewed By: awarzynski, PeteSteinfeld

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

12 months ago[test][sanitizer] Pre-commit huge malloc test
Vitaly Buka [Wed, 21 Jun 2023 23:17:43 +0000 (16:17 -0700)]
[test][sanitizer] Pre-commit huge malloc test

12 months agoRevert "[test][sanitizer] Precommit huge malloc test"
Vitaly Buka [Wed, 21 Jun 2023 23:15:34 +0000 (16:15 -0700)]
Revert "[test][sanitizer] Precommit huge malloc test"

Wrong accidental commit.

This reverts commit 1f18c9624b44e763a76742634f0f95432ea7cb23.

12 months ago[MachO] Remove redundant `.section` directive
Shoaib Meenai [Wed, 21 Jun 2023 23:16:46 +0000 (16:16 -0700)]
[MachO] Remove redundant `.section` directive

See https://reviews.llvm.org/D153382#inline-1483291

12 months ago[test][sanitizer] Precommit huge malloc test
Vitaly Buka [Wed, 21 Jun 2023 23:13:17 +0000 (16:13 -0700)]
[test][sanitizer] Precommit huge malloc test

12 months ago[test] Add llvm-xray into XRAY_TEST_DEPS
Vitaly Buka [Wed, 21 Jun 2023 21:19:29 +0000 (14:19 -0700)]
[test] Add llvm-xray into XRAY_TEST_DEPS

12 months ago[test] Add lli into ORC_TEST_DEPS
Vitaly Buka [Wed, 21 Jun 2023 21:19:11 +0000 (14:19 -0700)]
[test] Add lli into ORC_TEST_DEPS

12 months agoRevert "[mlir][RunnerUtils] Make symbols private + implement loading mechanism."
Mitch Phillips [Wed, 21 Jun 2023 22:32:38 +0000 (00:32 +0200)]
Revert "[mlir][RunnerUtils] Make symbols private + implement loading mechanism."

This reverts commit bba2b656110209a3d9863b92c060082479b06ab1.

Reason: Broke the HWASan buildbot. See https://reviews.llvm.org/D153250
for more information.

12 months ago[-Wunsafe-buffer-usage] Handle pointer initializations for grouping related variables
Rashmi Mudduluru [Thu, 15 Jun 2023 21:36:23 +0000 (14:36 -0700)]
[-Wunsafe-buffer-usage] Handle pointer initializations for grouping related variables

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

12 months ago[Frontend] Remove ShowIncludesPretendHeader
Shoaib Meenai [Fri, 16 Jun 2023 22:44:28 +0000 (15:44 -0700)]
[Frontend] Remove ShowIncludesPretendHeader

It hasn't been written to since https://reviews.llvm.org/D46652, so it
was always empty. I don't have enough context on that diff to know if
the removal of the write to ShowIncludesPretendHeader in that diff was
intentional, but no one's complained about it for five years, so I
assume we're okay to just get rid of it entirely.

Reviewed By: hans

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

12 months ago[Frontend] Don't output skipped includes from predefines
Shoaib Meenai [Fri, 16 Jun 2023 22:32:34 +0000 (15:32 -0700)]
[Frontend] Don't output skipped includes from predefines

`-H` displays a tree of included header files, but that tree is supposed
to omit two categories of header files:
1. Any header files pulled in via `-include`, which the code refers to
   as the "predefines".
2. Any header files whose inclusion was skipped because they'd already
   been included (assuming header guards or `#pragma once`).

`-fshow-skipped-includes` was intended to make `-H` display the second
category of files. It wasn't checking for the first category, however,
so you could end up with only the middle of the `-include` hierarchy
displayed, e.g. the added test would previously output:

```
... /data/users/smeenai/llvm-project/clang/test/Frontend/Inputs/test2.h
. /data/users/smeenai/llvm-project/clang/test/Frontend/Inputs/test.h
```

This diff adds a check to prevent that and correctly omit headers from
`-include` even when `-fshow-skipped-includes` is passed. While I'm
here, add tests for the interaction between `-fshow-skipped-includes`
and `-sys-header-deps` as well.

Reviewed By: hans

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

12 months ago[flang] Enhance getTypeAsString to support more FIR types
Valentin Clement [Wed, 21 Jun 2023 22:33:03 +0000 (15:33 -0700)]
[flang] Enhance getTypeAsString to support more FIR types

Add support for couple of FIR types such as fir.ptr, fir.heap,
fir.box, fir.class

Reviewed By: razvanlupusoru

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

12 months ago[clang-format] Don't finalize #if, #else, #endif, etc.
Owen Pan [Mon, 19 Jun 2023 06:18:00 +0000 (23:18 -0700)]
[clang-format] Don't finalize #if, #else, #endif, etc.

Don't finalize a preprocessor branch directive if it's the first
token of an annotated line. See the rationale at
https://reviews.llvm.org/D150057#inline-1449546.

Fixes #63379

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

12 months ago[scudo] Change overloaded function name append.
Christopher Ferris [Wed, 21 Jun 2023 00:43:11 +0000 (17:43 -0700)]
[scudo] Change overloaded function name append.

The ScopedString class has two functions named append. One takes
a va_list, but on some platforms va_list is typedef'd to char*.
That means that this call:

  std::string value;
  Str.append("print this string %s", value.c_str());

The compiler can incorrectly think this is the va_list function,
leading to crashes when calling this. To fix this, change the name
of the va_list function to be vappend to avoid this.

Fix https://github.com/llvm/llvm-project/issues/62893

Reviewed By: Chia-hungDuan

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

12 months ago[libc++] Fix the check-format job
Louis Dionne [Wed, 21 Jun 2023 13:08:45 +0000 (09:08 -0400)]
[libc++] Fix the check-format job

Previously, it wouldn't take into account files in ignore_format.txt
(at least not on OSX) because the `find` command would return file names
like `libcxx/src//new_handler.cpp`, which never matched the file names
in `ignore_format.txt`.

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

12 months agoAdd two new entitlements when debugserver is built by Apple
Jason Molenda [Wed, 21 Jun 2023 21:54:00 +0000 (14:54 -0700)]
Add two new entitlements when debugserver is built by Apple

Two new entitlements, com.apple.private.thread-set-state and
com.apple.private.set-exception-port should be included in the
debugserver entitlement plist when built internally at Apple.
The desktop builds of debugserver don't need these entitlements;
don't add them to debugserver-macosx-entitlements.plist.

rdar://108912676
rdar://103032208

12 months ago[libc++] Refactor the selection of string's ABI in __config
Louis Dionne [Mon, 19 Jun 2023 16:58:51 +0000 (12:58 -0400)]
[libc++] Refactor the selection of string's ABI in __config

This doesn't change the selection, but it expands the conditions to
add comments and make it clearer what's happening. It also removes a
-Wundef instance when we checked __ARM_ARCH_7K__ >= 2 without checking
that it is defined in the first place.

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

12 months ago[ARM] Repair check lines in sub-cmp-peephole.ll test. NFC
David Green [Wed, 21 Jun 2023 21:47:30 +0000 (22:47 +0100)]
[ARM] Repair check lines in sub-cmp-peephole.ll test. NFC

Commit ec77747fbdca901e0fded58f940dae62e0f6b726 regenerated the check lines
without being very careful about which lines were updated. This attempts to fix
them to make sure the V7 and V8 lines are emitted as needed.

12 months agoRevert "Revert "[LLD][ELF] Cortex-M Security Extensions (CMSE) Support""
Amilendra Kodithuwakku [Wed, 21 Jun 2023 20:40:41 +0000 (21:40 +0100)]
Revert "Revert "[LLD][ELF] Cortex-M Security Extensions (CMSE) Support""

This reverts commit a685ddf1d104b3ce9d53cf420521f5aaff429630.

This relands Arm CMSE support (D139092) and fixes the GCC build bot errors.

12 months ago[mlir][openacc] Update host_data data operands list name
Razvan Lupusoru [Wed, 21 Jun 2023 21:24:24 +0000 (14:24 -0700)]
[mlir][openacc] Update host_data data operands list name

For all other compute and data constructs, the data operands list
is named `dataClauseOperands`. Update `acc.host_data` to be
consistent with this naming.

Reviewed By: clementval

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

12 months ago[mlir][sparse] rewrite arith::SelectOp to semiring operations to sparsify it.
Peiming Liu [Wed, 21 Jun 2023 04:16:40 +0000 (04:16 +0000)]
[mlir][sparse] rewrite arith::SelectOp to semiring operations to sparsify it.

Reviewed By: aartbik, K-Wu

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

12 months ago[DFSAN] Add support for strncat
Tomasz Kuchta [Wed, 21 Jun 2023 21:18:05 +0000 (21:18 +0000)]
[DFSAN] Add support for strncat

This patch adds a support for the libc strncat() function in DFSAN

Reviewed by: browneee

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

12 months ago[flang][openacc] Use acc.private and acc.firstprivate when lowering clauses
Valentin Clement [Wed, 21 Jun 2023 21:19:20 +0000 (14:19 -0700)]
[flang][openacc] Use acc.private and acc.firstprivate when lowering clauses

Lower private and firstprivate operands through their corresponding
data entry operation to support array section.

Depends on D152972

Reviewed By: razvanlupusoru

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

12 months ago[mlir][openacc] Add acc.firstprivate operation as data entry operation
Valentin Clement [Wed, 21 Jun 2023 21:18:08 +0000 (14:18 -0700)]
[mlir][openacc] Add acc.firstprivate operation as data entry operation

acc.firstprivate operation will be used as data entry operation
for the firstprivate operands.

Depends on D152970

Reviewed By: razvanlupusoru

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

12 months ago[mlir][openacc] Add acc.private operation as data entry operation
Valentin Clement [Wed, 21 Jun 2023 21:16:57 +0000 (14:16 -0700)]
[mlir][openacc] Add acc.private operation as data entry operation

acc.private operation will be used as data entry operation
for the private operands.

Reviewed By: razvanlupusoru

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

12 months ago[lldb/test] Disable TestStackCoreScriptedProcess.py
Med Ismail Bennani [Wed, 21 Jun 2023 21:05:55 +0000 (14:05 -0700)]
[lldb/test] Disable TestStackCoreScriptedProcess.py

This patch disables TestStackCoreScriptedProcess.py since it times out
non deterministicly.

Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
12 months ago[test] Add test for null_pointer_is_valid and Inliner instsimplify interaction
Arthur Eubanks [Wed, 21 Jun 2023 15:31:42 +0000 (08:31 -0700)]
[test] Add test for null_pointer_is_valid and Inliner instsimplify interaction

As requested in D151254

Reviewed By: arsenm

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

12 months ago[NFC][sanitizer] Pass user region into OnMapSecondary
Vitaly Buka [Wed, 21 Jun 2023 20:50:42 +0000 (13:50 -0700)]
[NFC][sanitizer] Pass user region into OnMapSecondary

12 months ago[NFC][sanitizer] Add OnMapSecondary callback
Vitaly Buka [Wed, 21 Jun 2023 20:30:44 +0000 (13:30 -0700)]
[NFC][sanitizer] Add OnMapSecondary callback

Now it implemented as OnMap everywhere, but in follow up patches
we can optimize Asan handler.

12 months ago[PhaseOrdering] Add test showing mis-compile caused by 17fdaccccf.
Florian Hahn [Wed, 21 Jun 2023 20:15:13 +0000 (21:15 +0100)]
[PhaseOrdering] Add test showing mis-compile caused by 17fdaccccf.

The test shows a mis-compile where @test gets incorrectly simplified to
unreachable. The test case is reduced from a ThinLTO build of Clang,
with only the relevant pass sequence included.

12 months ago[NFC][sanitizer] Remove MapUnmapCallback from sanitizer_flat_map.h
Vitaly Buka [Wed, 21 Jun 2023 20:04:34 +0000 (13:04 -0700)]
[NFC][sanitizer] Remove MapUnmapCallback from sanitizer_flat_map.h

It's used by test only to test "test-only" code.

12 months agoEmit DW_LLE_base_address + DW_LLE_offset_pair for DWARF v5
Shubham Sandeep Rastogi [Wed, 14 Jun 2023 23:35:38 +0000 (16:35 -0700)]
Emit DW_LLE_base_address + DW_LLE_offset_pair for DWARF v5

This patch tries to reduce the size of the debug_loclist section by
replacing the DW_LLE_start_length opcodes currently emitted by dsymutil
in favor of using DW_LLE_base_address + DW_LLE_offset_pair instead.

The DW_LLE_start_length is one AddressSize followed by a ULEB per entry,
whereas, the DW_LLE_base_address + DW_LLE_offset_pair will use one
AddressSize for the base address, and then the DW_LLE_offset_pair is a
pair of ULEBs. This will be more efficient where a loclist fragment has
many entries.

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

12 months ago[MBP] Enable duplicating return block to remove jump to return
Guozhi Wei [Wed, 21 Jun 2023 18:54:31 +0000 (18:54 +0000)]
[MBP] Enable duplicating return block to remove jump to return

Sometimes LLVM generates branch to return instruction, like PR63227.

It is because in function MachineBlockPlacement::canTailDuplicateUnplacedPreds
we avoid duplicating a BB into another already placed BB to prevent destroying
computed layout. But if the successor BB is a return block, duplicating it will
only reduce taken branches without hurt to any other branches.

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

12 months ago[NFC][asan] Move AsanStats update
Vitaly Buka [Wed, 21 Jun 2023 18:46:31 +0000 (11:46 -0700)]
[NFC][asan] Move AsanStats update

Deallocate is a more appropiate place to update free count.

12 months ago[gn build] Port 1ee4d880e876
LLVM GN Syncbot [Wed, 21 Jun 2023 18:41:47 +0000 (18:41 +0000)]
[gn build] Port 1ee4d880e876

12 months agoNVPTX: Lower unreachable to exit to allow ptxas to accurately reconstruct the CFG.
Tim Besard [Tue, 20 Jun 2023 17:29:16 +0000 (10:29 -0700)]
NVPTX: Lower unreachable to exit to allow ptxas to accurately reconstruct the CFG.

PTX does not have a notion of `unreachable`, which results in emitted basic
blocks having an edge to the next block:

```
block1:
  call @does_not_return();
  // unreachable
block2:
  // ptxas will create a CFG edge from block1 to block2
```

This may result in significant changes to the control flow graph, e.g., when
LLVM moves unreachable blocks to the end of the function. That's a problem
in the context of divergent control flow, as `ptxas` uses the CFG to determine
divergent regions, while some intructions may not be executed divergently.

For example, `bar.sync` is not allowed to be executed divergently on Pascal
or earlier. If we start with the following:

```
entry:
  // start of divergent region
  @%p0 bra cont;
  @%p1 bra unlikely;
  ...
  bra.uni cont;
unlikely:
  ...
  // unreachable
cont:
  // end of divergent region
  bar.sync 0;
  bra.uni exit;
exit:
  ret;
```

it is transformed by the branch-folder and block-placement passes to:

```
entry:
  // start of divergent region
  @%p0 bra cont;
  @%p1 bra unlikely;
  ...
  bra.uni cont;
cont:
  bar.sync 0;
  bra.uni exit;
unlikely:
  ...
  // unreachable
exit:
  // end of divergent region
  ret;
```

After moving the `unlikely` block to the end of the function, it has an edge
to the `exit` block, which widens the divergent region and makes the `bar.sync`
instruction happen divergently. That causes wrong computations, as we've been
running into for years with Julia code (which emits a lot of `trap` +
`unreachable` code all over the place).

To work around this, add an `exit` instruction before every `unreachable`,
as `ptxas` understands that exit terminates the CFG. Note that `trap` is not
equivalent, and only future versions of `ptxas` will model it like `exit`.
Another alternative would be to emit a branch to the block itself, but emitting
`exit` seems like a cleaner solution to represent `unreachable` to me.

Also note that this may not be sufficient, as it's possible that the block
with unreachable control flow is branched to from different divergent regions,
e.g. after block merging, in which case it may still be the case that `ptxas`
could reconstruct a CFG where divergent regions are merged (I haven't confirmed
this, but also haven't encountered this pattern in the wild yet):

```
entry:
  // start of divergent region 1
  @%p0 bra cont1;
  @%p1 bra unlikely;
  bra.uni cont1;
cont1:
  // intended end of divergent region 1
  bar.sync 0;
  // start of divergent region 2
  @%p2 bra cont2;
  @%p3 bra unlikely;
  bra.uni cont2;
cont2:
  // intended end of divergent region 2
  bra.uni exit;
unlikely:
  ...
  exit;
exit:
  // possible end of merged divergent region?
```

I originally tried to avoid the above by cloning paths towards `unreachable` and
splitting the outgoing edges, but that quickly became too complicated. I propose
we go with the simple solution first, also because modern GPUs with more flexible
hardware thread schedulers don't even suffer from this issue.

Finally, although I expect this to fix most of
https://bugs.llvm.org/show_bug.cgi?id=27738, I do still encounter
miscompilations with Julia's unreachable-heavy code when targeting these
older GPUs using an older `ptxas` version (specifically, from CUDA 11.4 or
below). This is likely due to related bugs in `ptxas` which have been fixed
since, as I have filed several reproducers with NVIDIA over the past couple of
years. I'm not inclined to look into fixing those issues over here, and will
instead be recommending our users to upgrade CUDA to 11.5+ when using these GPUs.

Also see:
- https://github.com/JuliaGPU/CUDAnative.jl/issues/4
- https://github.com/JuliaGPU/CUDA.jl/issues/1746
- https://discourse.llvm.org/t/llvm-reordering-blocks-breaks-ptxas-divergence-analysis/71126

Reviewed By: jdoerfert, tra

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

12 months ago[lldb] Fix failure in TestStackCoreScriptedProcess on x86_64
Med Ismail Bennani [Tue, 13 Jun 2023 20:47:14 +0000 (13:47 -0700)]
[lldb] Fix failure in TestStackCoreScriptedProcess on x86_64

This patch should address the failure of TestStackCoreScriptedProcess
that is happening specifically on x86_64.

It turns out that in 1370a1cb5b97, I changed the way we extract integers
from a `StructuredData::Dictionary` and in order to get a stop info from
the scripted process, we call a method that returns a `SBStructuredData`
containing the stop reason data.

TestStackCoreScriptedProcess` was failing specifically on x86_64 because
the stop info dictionary contains the signal number, that the `Scripted
Thread` was trying to extract as a signed integer where it was actually
parsed as an unsigned integer. That caused `GetValueForKeyAsInteger` to
return the default value parameter, `LLDB_INVALID_SIGNAL_NUMBER`.

This patch address the issue by extracting the signal number with the
appropriate type and re-enables the test.

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

Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
12 months ago[MC] Add .pushsection/.popsection support to COFFAsmParser
cynecx [Wed, 21 Jun 2023 17:39:56 +0000 (10:39 -0700)]
[MC] Add .pushsection/.popsection support to COFFAsmParser

The COFFAsmParser (to my surprise) didn't support the .pushsection and
.popsection directives. These directives aren't directly useful, however for
frontends that have inline asm support this is really useful. Rust in
particular, has support for inline asm, which can be used together with these
directives to "emulate" features like static generics. This patch adds support
for the two mentioned directives.

Reviewed By: MaskRay

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

12 months ago[lldb][MachO] Fix section type recognition for new DWARF 5 sections
Felipe de Azevedo Piovezan [Wed, 21 Jun 2023 15:25:14 +0000 (11:25 -0400)]
[lldb][MachO] Fix section type recognition for new DWARF 5 sections

When LLDB needs to access a debug section, it generally calls
SectionList::FindSectionByType with the corresponding type (we have one type for
each DWARF section). However, the missing entries made some sections be
classified as "eSectionTypeOther", which makes all calls to `FindSectionByType`
fail.

With this patch, a check-lldb build with
`-DLLDB_TEST_USER_ARGS=--dwarf-version=5` reports a much lower number of
failures:

  Unsupported      :  327
  Passed           : 2423
  Expectedly Failed:   16
  Unresolved       :    2
  Failed           :   52

This is down from previously 400~ failures.

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

12 months agoRevert "Define/guard MLIR_STANDALONE_BUILD LLVM_LIBRARY_OUTPUT_INTDIR var."
Stella Laurenzo [Wed, 21 Jun 2023 17:20:35 +0000 (10:20 -0700)]
Revert "Define/guard MLIR_STANDALONE_BUILD LLVM_LIBRARY_OUTPUT_INTDIR var."

This reverts commit f55fd19b6b565827af5fbf504952dcc35b8b7360.

As noted on the original thread, other uses of LLVM_LIBRARY_OUTPUT_INTDIR are optional. Will make a separate patch that makes this use optional as well.

12 months ago[lldb][NFCI] Remove ConstString from GDBRemoteCommunicationClient::ConfigureRemoteStr...
Alex Langford [Fri, 16 Jun 2023 22:49:03 +0000 (15:49 -0700)]
[lldb][NFCI] Remove ConstString from GDBRemoteCommunicationClient::ConfigureRemoteStructuredData

ConstString's benefits are not being utilized here, StringRef is
sufficient.

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