platform/upstream/llvm.git
20 months ago[Clang] Implement Change scope of lambda trailing-return-type
Corentin Jabot [Sun, 6 Feb 2022 21:58:43 +0000 (22:58 +0100)]
[Clang] Implement Change scope of lambda trailing-return-type

This implements P2036R3 and P2579R0.
That is, explicit, int, and implicit capture become visible
at the start of the parameter head.

Reviewed By: aaron.ballman, rupprecht, shafik

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

20 months ago[UTC] Include return type/attributes under --version 2
Nikita Popov [Tue, 24 Jan 2023 14:32:31 +0000 (15:32 +0100)]
[UTC] Include return type/attributes under --version 2

If --function-signature is used with --version 2, then also include
the return type/attributes in the check lines. This is the
implementation of D133943 rebased on the --version mechanism from
D142473.

This doesn't bump the default version yet, because I'd like to do
that together with D140212 (which enables --function-signature by
default), as these changes seem closely related. For now this
functionality can be accessed by explicitly passing --version 2
to UTC.

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

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

20 months ago[llvm-c] Remove bindings for creating legacy passes
Nikita Popov [Tue, 28 Feb 2023 15:38:45 +0000 (16:38 +0100)]
[llvm-c] Remove bindings for creating legacy passes

Legacy passes are only supported for codegen, and I don't believe
it's possible to write backends using the C API, so we should drop
all of those. Reduces the number of places that need to be modified
when removing legacy passes.

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

20 months agoRecommit "[X86] Add `TuningPreferShiftShuffle` for when Shifts are preferable to...
Noah Goldstein [Thu, 2 Mar 2023 08:34:41 +0000 (02:34 -0600)]
Recommit "[X86] Add `TuningPreferShiftShuffle` for when Shifts are preferable to shuffles." (2nd Try)

Move the opcode checks to after we have already verified we found a
valid shift instruction (`0 < ShiftAmt`) in `matchUnaryPermuteShuffle`
and `lowerShuffleAsShift`.

Reviewed By: pengfei, RKSimon

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

20 months ago[clang][Interp] Add ArrayElemPtr{,Pop} opcode
Timm Bäder [Sat, 31 Dec 2022 16:06:52 +0000 (17:06 +0100)]
[clang][Interp] Add ArrayElemPtr{,Pop} opcode

We usually access array elements in the same pattern, which uses
narrow(). Add an extra opcode for this. This saves us quite some
instructions and makes the bytecode easier to read.

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

20 months agoRevert "[SelectionDAG] Transitively copy NodeExtraInfo on RAUW"
Marco Elver [Thu, 2 Mar 2023 08:24:25 +0000 (09:24 +0100)]
Revert "[SelectionDAG] Transitively copy NodeExtraInfo on RAUW"

This reverts commit 7f635b90e7bdf1378fd9a65fc62b99e8e07d4aaf.

The current implementation causes pathological slowdowns in certain
cases: https://github.com/llvm/llvm-project/issues/61108

20 months ago[clang][Interp] Only check constructors for global variables
Timm Bäder [Wed, 28 Dec 2022 10:43:26 +0000 (11:43 +0100)]
[clang][Interp] Only check constructors for global variables

Local variables may be partially initialized.

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

20 months ago[clang][Interp] Implement C++ Range-for loops
Timm Bäder [Sat, 31 Dec 2022 15:14:33 +0000 (16:14 +0100)]
[clang][Interp] Implement C++ Range-for loops

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

20 months ago[mlir][Linalg] NFC - Improve debug messages for padding
Nicolas Vasilache [Thu, 2 Mar 2023 07:54:21 +0000 (23:54 -0800)]
[mlir][Linalg] NFC - Improve debug messages for padding

20 months ago[LLDB] XFAIL TestRunLocker.py for windows
Muhammad Omair Javaid [Thu, 2 Mar 2023 07:51:30 +0000 (11:51 +0400)]
[LLDB] XFAIL TestRunLocker.py for windows

TestRunLocker.py is failing on windows x64 and AArch64 buildbots.
Buildbot log suggests that test needs some minor modification for
windows which I will do later.

https://lab.llvm.org/buildbot/#/builders/83/builds/29680
https://lab.llvm.org/buildbot/#/builders/219/builds/942

20 months ago[flang] Use the newly introduced AliasAnalysisOpInterface.
Tobias Gysi [Thu, 2 Mar 2023 07:32:30 +0000 (08:32 +0100)]
[flang] Use the newly introduced AliasAnalysisOpInterface.

This revision uses the AliasAnalysisOpInterface introduced in
https://reviews.llvm.org/D144851 to set the tbaa attributes
of load and store ops. With the attribute it is also possible to
set the attribute on atomics as well as on memcopy and
memove intrinsics as soon as https://reviews.llvm.org/D144965
lands.

Reviewed By: vzakhari

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

20 months agoRevert "[LLDB] XFAIL TestRunLocker.py on Windows"
Muhammad Omair Javaid [Thu, 2 Mar 2023 07:22:08 +0000 (11:22 +0400)]
Revert "[LLDB] XFAIL TestRunLocker.py on Windows"

This reverts commit 9d28e00e741cb19684111656803434aceef4c2a0.

20 months ago[clang][Interp] Handle defined functions without a body
Timm Bäder [Fri, 30 Dec 2022 10:50:48 +0000 (11:50 +0100)]
[clang][Interp] Handle defined functions without a body

This happens when explicitly defaulting a constructor, for example.

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

20 months ago[llvm][GenericUniformity] Prevent assert while calculating temporal divergence
Yashwant Singh [Thu, 2 Mar 2023 07:08:52 +0000 (12:38 +0530)]
[llvm][GenericUniformity] Prevent assert while calculating temporal divergence

analyzeTemporalDivergence() was missing the check for always-uniform before
evaluating weather an instruction depends on a value defined in the cycle.
Fix for #60638
https://github.com/llvm/llvm-project/issues/60638

Reviewed By: sameerds, foad, #amdgpu

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

20 months ago[LLDB] XFAIL TestRunLocker.py on Windows
Muhammad Omair Javaid [Thu, 2 Mar 2023 07:05:11 +0000 (11:05 +0400)]
[LLDB] XFAIL TestRunLocker.py on Windows

20 months ago[x86] Precommit a test
Kazu Hirata [Thu, 2 Mar 2023 07:03:39 +0000 (23:03 -0800)]
[x86] Precommit a test

This patch precommits a test for:

https://github.com/llvm/llvm-project/issues/60802

20 months ago[clang][Interp] Implement remaining MaterializeTemporaryExpr bits
Timm Bäder [Mon, 26 Dec 2022 08:18:56 +0000 (09:18 +0100)]
[clang][Interp] Implement remaining MaterializeTemporaryExpr bits

As well as support for CompoundLiteralExprs.

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

20 months agoELF: Respect MEMORY command when specified without a SECTIONS command.
Peter Collingbourne [Thu, 2 Mar 2023 00:54:24 +0000 (16:54 -0800)]
ELF: Respect MEMORY command when specified without a SECTIONS command.

We were previously ignoring the MEMORY command unless SECTIONS was also
specified. Fix it.

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

20 months ago[llvm-lib] 'llvm-lib' currently cannot generate an import library from a Windows
Vadim Paretsky (Intel Americas Inc) [Thu, 2 Mar 2023 04:32:35 +0000 (20:32 -0800)]
[llvm-lib] 'llvm-lib' currently cannot generate an import library from a Windows
.def file, functionality supported by 'lib'. This incompatibility is
breaking clang based Windows openmp builds. This revision adds
basic support for this feature to llvm-lib by cloning the corresponding
code from 'dlltool'.

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

20 months agoRevert D143786 "[X86] Add `TuningPreferShiftShuffle` for when Shifts are preferable...
Fangrui Song [Thu, 2 Mar 2023 03:08:55 +0000 (19:08 -0800)]
Revert D143786 "[X86] Add `TuningPreferShiftShuffle` for when Shifts are preferable to shuffles."

This reverts commit a98ee27416916c3f8af4cd229e0a633423d6d9a3.
It caused MemorySanitizer use-of-uninitialized-value in matchUnaryPermuteShuffle.

20 months ago[libcxx][NFC] Added a note about the P2520R0
Shivam kunwar [Thu, 2 Mar 2023 02:28:15 +0000 (07:58 +0530)]
[libcxx][NFC] Added a note about the P2520R0

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

20 months ago[libc++] [FreeBSD] correct 64-bit test
Ed Maste [Wed, 1 Mar 2023 23:39:29 +0000 (18:39 -0500)]
[libc++] [FreeBSD] correct 64-bit test

Using __SIZEOF_LONG__ == 8 rather than __LP64__ is needed so we use umtx
on CHERI.  I accidentally landed an older diff.

Fixes: 17ecbb3ea6ff0ae716dd524c0e2bf75a4815c95b

20 months ago[memprof] Avoid meaningless pod copy
Wu, Yingcong [Thu, 2 Mar 2023 01:36:37 +0000 (01:36 +0000)]
[memprof] Avoid meaningless pod copy

The pointer `Buffer` is not changed, so there is no need to use reference, and the `Pod` here should use reference to avoid meaningless copy.

Reviewed By: snehasish

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

20 months ago[WebAssembly] Skip implied bitmask operation in LowerShift
Jun Ma [Thu, 23 Feb 2023 07:45:48 +0000 (15:45 +0800)]
[WebAssembly] Skip implied bitmask operation in LowerShift

This patch skips redundant explicit masks of the shift count since
it is implied inside wasm shift instruction.

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

20 months agoRevert "[MergeICmps] Adapt to non-eq comparisons, retry"
Zhongyunde [Thu, 2 Mar 2023 01:07:44 +0000 (09:07 +0800)]
Revert "[MergeICmps] Adapt to non-eq comparisons, retry"

This reverts commit 74ad19c25d7217d8f580a21d12fd4c784a1a0094.

test unittests/ProfileData/ProfileDataTests fails when built with
optimisations level -O1 with clang including this patch.

20 months ago[SPIR-V] Remove redundant check and fix typos
Michal Paszkowski [Wed, 1 Mar 2023 23:51:18 +0000 (00:51 +0100)]
[SPIR-V] Remove redundant check and fix typos

20 months ago[ExecutionEngine] Silence warnings about sprintf use in interpreter.
Lang Hames [Wed, 1 Mar 2023 23:34:23 +0000 (15:34 -0800)]
[ExecutionEngine] Silence warnings about sprintf use in interpreter.

We should review memory safety in the interpreter
(https://github.com/llvm/llvm-project/issues/58086), but for now just silence
the warnings to reduce noise.

rdar://100555195

20 months ago[ORC] Drop StaticLibraryDefinitionGenerator Load/Create overloads with triples.
Lang Hames [Wed, 22 Feb 2023 05:22:28 +0000 (21:22 -0800)]
[ORC] Drop StaticLibraryDefinitionGenerator Load/Create overloads with triples.

We can get the triple from the ExecutionSession, so clients shouldn't have to
provide it.

20 months ago[libc] add basic Intel MacOS configuration
Michael Jones [Wed, 1 Mar 2023 19:35:40 +0000 (11:35 -0800)]
[libc] add basic Intel MacOS configuration

The config is based on the ARM MacOS config, but with fenv and math
functions disabled.

This should unblock this bug: https://github.com/llvm/llvm-project/issues/60910

Reviewed By: sivachandra

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

20 months ago[RegAllocFast] insert additional spills along indirect edges of INLINEASM_BR
Nick Desaulniers [Wed, 1 Mar 2023 23:20:55 +0000 (15:20 -0800)]
[RegAllocFast] insert additional spills along indirect edges of INLINEASM_BR

When generating spills (stores) for values produced by INLINEASM_BR
instructions, make sure to insert one spill per indirect target.
Otherwise the reload generated may load from a stack slot that has not
yet been stored to (resulting in a load of an uninitialized stack slot).

Link: https://github.com/llvm/llvm-project/issues/53562
Fixes: https://github.com/llvm/llvm-project/issues/60855

Reviewed By: MatzeB

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

20 months agoprecommit test for pr60855
Nick Desaulniers [Mon, 27 Feb 2023 19:22:42 +0000 (11:22 -0800)]
precommit test for pr60855

This test demonstrates an issue with callbr outputs being used along
indirect edges when using regallocfast.

Link: https://github.com/llvm/llvm-project/issues/60855
Differential Revision: https://reviews.llvm.org/D144906

20 months ago[mlir][python] Remove "Raw" OpView classes
Rahul Kayaith [Mon, 23 Jan 2023 04:31:18 +0000 (23:31 -0500)]
[mlir][python] Remove "Raw" OpView classes

The raw `OpView` classes are used to bypass the constructors of `OpView`
subclasses, but having a separate class can create some confusing
behaviour, e.g.:
```
op = MyOp(...)
# fails, lhs is 'MyOp', rhs is '_MyOp'
assert type(op) == type(op.operation.opview)
```

Instead we can use `__new__` to achieve the same thing without a
separate class:
```
my_op = MyOp.__new__(MyOp)
OpView.__init__(my_op, op)
```

Reviewed By: stellaraccident

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

20 months ago[mlir][python] Allow running pass manager on any operation
rkayaith [Wed, 9 Nov 2022 03:48:26 +0000 (22:48 -0500)]
[mlir][python] Allow running pass manager on any operation

`PassManager.run` is currently restricted to running on `builtin.module`
ops, but this restriction doesn't exist on the C++ side. This updates it
to take `ir.Operation/OpView` instead of `ir.Module`.

Depends on D143354

Reviewed By: mehdi_amini

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

20 months ago[mlir][CAPI] Allow running pass manager on any operation
rkayaith [Wed, 9 Nov 2022 03:39:18 +0000 (22:39 -0500)]
[mlir][CAPI] Allow running pass manager on any operation

`mlirPassManagerRun` is currently restricted to running on
`builtin.module` ops, but this restriction doesn't exist on the C++
side. This renames it to `mlirPassManagerRunOnOp` and updates it to take
`MlirOperation` instead of `MlirModule`.

Depends on D143352

Reviewed By: mehdi_amini

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

20 months ago[mlir][python] Add generic operation parse APIs
rkayaith [Tue, 8 Nov 2022 21:55:06 +0000 (16:55 -0500)]
[mlir][python] Add generic operation parse APIs

Currently the bindings only allow for parsing IR with a top-level
`builtin.module` op, since the parse APIs insert an implicit module op.
This change adds `Operation.parse`, which returns whatever top-level op
is actually in the source.

To simplify parsing of specific operations, `OpView.parse` is also
added, which handles the error checking for `OpView` subclasses.

Reviewed By: ftynse, stellaraccident

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

20 months ago[mlir][AsmParser] Improve parse{Attribute,Type} error handling
Rahul Kayaith [Sat, 25 Feb 2023 07:30:46 +0000 (02:30 -0500)]
[mlir][AsmParser] Improve parse{Attribute,Type} error handling

Currently these functions report errors directly to stderr, this updates
them to use diagnostics instead. This also makes partially-consumed
strings an error if the `numRead` parameter isn't provided (the
docstrings already claimed this happened, but it didn't.)

While here I also tried to reduce the number of overloads by switching
to using default parameters.

Reviewed By: rriddle

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

20 months ago[NFC][Pipeline] Move PromotePass into GlobalCleanupPM
Arthur Eubanks [Wed, 1 Mar 2023 21:21:04 +0000 (13:21 -0800)]
[NFC][Pipeline] Move PromotePass into GlobalCleanupPM

20 months ago[OpenMP][NFC] Clean up Twines and other issues in plugins
Joseph Huber [Wed, 1 Mar 2023 21:02:00 +0000 (15:02 -0600)]
[OpenMP][NFC] Clean up Twines and other issues in plugins

Summary:
Tihs patch is mostly NFC to fix some warning currently present in OpenMP
offloading plugins. Specifically this mostly removes the use of Twine
variables in favor of LLVM's small string. Twine variables are prone to
use-after-free and this is a cleaner way to concatenate a string.

20 months ago[llvm][LowerConstantIntrinsics] add debug statements
Nick Desaulniers [Wed, 1 Mar 2023 20:58:13 +0000 (12:58 -0800)]
[llvm][LowerConstantIntrinsics] add debug statements

These can help us better understand what __builtin_constant_p and
__builtin_object_size get folded to.

$ clang -mllvm -debug-only=lower-is-constant-intrinsic ...

Reviewed By: void

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

20 months ago[libc] Fix mismatch in exception decl
Jeff Bailey [Wed, 1 Mar 2023 20:55:59 +0000 (20:55 +0000)]
[libc] Fix mismatch in exception decl

When running the libc tests under vscode, I got an error about a
mismatches exception declaration for strerror.  Since string.h
seems to be getting included transitively anyway, just include
it and rely on its definition.

Reviewed By: michaelrj

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

20 months ago[mlir][sparse] support coiteration with fused reshape tensor
Peiming Liu [Wed, 1 Mar 2023 19:03:02 +0000 (19:03 +0000)]
[mlir][sparse] support coiteration with fused reshape tensor

Reviewed By: aartbik

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

20 months ago[libc++] [FreeBSD] only use _umtx_op(2) on 64bit arches
Konstantin Belousov [Fri, 20 Jan 2023 23:32:11 +0000 (18:32 -0500)]
[libc++] [FreeBSD] only use _umtx_op(2) on 64bit arches

Only 64bit architectures can be supported this way, because libcxx
defines __cxx_contention_t to be int64_t for FreeBSD, and 32bit
arches do not have a kind of UMTX_OP_WAIT_INT64_PRIVATE operation.

Fixes: 83387dbc18e7998f87aa4a2d35320bcb2ed5c392

Reviewed by: arichardson, ldionne, emaste, Mordante
Differential Revision: https://reviews.llvm.org/D142422

20 months ago[Flang][Tool][bbc] Emit module wrapper in addition to body
Andrew Gozillon [Wed, 1 Mar 2023 20:32:54 +0000 (14:32 -0600)]
[Flang][Tool][bbc] Emit module wrapper in addition to body

This change seeks to emit the full module from the bbc tool and
not just the body. This change currently does not break existing tests
when running check-(mlir, flang, all). This stops the discarding of
any attributes that may be applied to the Module during
compilation.

Reviewed By: jeanPerier
Differential Revision: https://reviews.llvm.org/D144869

20 months ago[libc++] Use generic-cxx20 instead of apple-cxx20 on Apple CI
Louis Dionne [Wed, 1 Mar 2023 20:25:29 +0000 (15:25 -0500)]
[libc++] Use generic-cxx20 instead of apple-cxx20 on Apple CI

apple-cxx20 is equivalent to generic-cxx20, so we don't need it anymore.
It had been introduced when clang-tidy was enabled explicitly from
run-buildbot, but that's not needed anymore since clang-tidy is
enabled from the buildkite pipeline definition.

20 months ago[libc++][NFC] Remove trailing whitespace on line and clang-format
Louis Dionne [Wed, 1 Mar 2023 20:11:44 +0000 (15:11 -0500)]
[libc++][NFC] Remove trailing whitespace on line and clang-format

This broke the CI after 813e1da974 was checked in.

20 months ago[Libomptarget] Fix block and thread limit environment variables not being respected
Joseph Huber [Wed, 1 Mar 2023 20:02:40 +0000 (14:02 -0600)]
[Libomptarget] Fix block and thread limit environment variables not being respected

The next-gen plugins did not properly set the values from
`OMP_NUM_TEAMS` and `OMP_TEAMS_THREAD_LIMIT`. This is because these
maximum values are set by each plugin to its hardware maximum. This
happens *after* the previous initialization. Move it to the correct
place and then add a test.

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

Reviewed By: tianshilei1992

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

20 months ago[AArch64] Precommit some more LD1R splat tests for scalar int/fp loads
Sjoerd Meijer [Wed, 1 Mar 2023 14:43:35 +0000 (14:43 +0000)]
[AArch64] Precommit some more LD1R splat tests for scalar int/fp loads

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

20 months ago[flang] Check for BIND(C) through use association.
Slava Zakharin [Wed, 1 Mar 2023 16:42:22 +0000 (08:42 -0800)]
[flang] Check for BIND(C) through use association.

If the interface specifies BIND(C), then the declarations using
this interface inherit BIND(C), and if they are referenced via use
association they must be classified as BIND(C) subprograms.

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

20 months ago[libc++] Refactor the std/depr C headers tests
Louis Dionne [Wed, 1 Mar 2023 19:45:17 +0000 (14:45 -0500)]
[libc++] Refactor the std/depr C headers tests

Move multiple tests to .compile.pass.cpp when they were not running
anything and reindent a bit more consistently.

20 months ago[llvm] Prevent building for riscv32-unknown-fuchsia
Leonard Chan [Wed, 1 Mar 2023 19:42:15 +0000 (19:42 +0000)]
[llvm] Prevent building for riscv32-unknown-fuchsia

Fuchsia is exclusively 64-bit so this throw an error when using this
triple.

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

20 months ago[MLIR] Add `print-ir` pass for debugging purposes
Frederik Gossen [Wed, 1 Mar 2023 19:33:49 +0000 (14:33 -0500)]
[MLIR] Add `print-ir` pass for debugging purposes

Add pass to print the entire IR on the debug stream.
This is meant for debugging purposes to inspect the IR at a specific point in the pipeline.

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

20 months ago[flang] Move fir.select_type into the PolymorphicOpConversion pass
Renaud-K [Mon, 27 Feb 2023 22:39:18 +0000 (14:39 -0800)]
[flang] Move fir.select_type into the PolymorphicOpConversion pass
https://reviews.llvm.org/D144921

20 months ago[DivRemPairs] Remove legacy pass
Fangrui Song [Wed, 1 Mar 2023 19:16:18 +0000 (11:16 -0800)]
[DivRemPairs] Remove legacy pass

Following recent changes to remove non-core legacy passes.

20 months ago[LLDB] Expose several methods in SBWatchpoint
Dan Liew [Tue, 28 Feb 2023 01:05:19 +0000 (17:05 -0800)]
[LLDB] Expose several methods in SBWatchpoint

This patch adds the following methods:

* `GetType()`
* `GetWatchValueKind()`
* `GetWatchSpec()`
* `IsWatchingReads()`
* `IsWatchingWrites()`

These mostly expose methods that `lldb_private::Watchpoint` already
had. Tests are included that exercise these new methods.

The motivation for exposing these are as follows:

* `GetType()` - With this information and the address from a watchpoint
  it is now possible to construct an SBValue from an SBWatchpoint.
  Previously this wasn't possible. The included test case illustrates
  doing this.
* `GetWatchValueKind()` - This allows the caller to determine whether the
  watchpoint is a variable watchpoint or an expression watchpoint. A new
  enum (`WatchpointValueKind`) has been introduced to represent the
  return values. Unfortunately the name `WatchpointKind` was already
  taken.
* `GetWatchSpec()` - This allows (at least for variable watchpoints)
  to use a sensible name for SBValues created from an SBWatchpoint.
* `IsWatchingReads()` - This allow checking if a watchpoint is
  monitoring read accesses.
* `IsWatchingWRites()` - This allow checking if a watchpoint is
  monitoring write accesses.

rdar://105606978

Reviewers: jingham, mib, bulbazord, jasonmolenda, JDevlieghere

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

20 months ago[lld] [MTE] Add DT_AARCH64_MEMTAG_* dynamic entries, and small cleanup
Mitch Phillips [Wed, 1 Mar 2023 19:00:49 +0000 (11:00 -0800)]
[lld] [MTE] Add DT_AARCH64_MEMTAG_* dynamic entries, and small cleanup

Adds the new AArch64-ABI dynamic entry generation to LLD. This will
allow Android to move from the Android-specific ELF note onto the
dynamic entries.

Change the behaviour of an unspecified --android-memtag-mode. Now, when
unspecified, this will print a warning that you're doing a no-op, rather
than implicitly turning on sync mode. This is important for MTE globals
later, where a binary containing static tagged global descriptors
shouldn't have MTE turned on without specific intent being passed to the
linker.

For now, continue to emit the Android ELF note by default. In future, we
can probably make it only emit the note when provided a flag.

Do a quick NFC-cleanup of the ELF note while we're here. It doesn't
change anything about the ELF note itself, but makes it more clear to
the reader of the code what alignment requirements are being (previously
implicitly) met.

Reviewed By: fmayer, MaskRay

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

20 months ago[Sanitizers] Error out for -static-libsan on darwin
usama hameed [Wed, 1 Mar 2023 19:07:03 +0000 (00:07 +0500)]
[Sanitizers] Error out for -static-libsan on darwin
since it is not supported

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

20 months ago[mlir][sparse] fuse collapse_shape on sparse tensor with GenericOp.
Peiming Liu [Mon, 27 Feb 2023 22:40:34 +0000 (22:40 +0000)]
[mlir][sparse] fuse collapse_shape on sparse tensor with GenericOp.

Instead of always materializing a new sparse tensor after reshape, this patch tries to fuses the reshape (currently only on COO) with GenericOp and coiterates with the reshaped tensors without allocating a new sparse tensor.

Reviewed By: aartbik

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

20 months ago[mlir][spirv] Support shaped types with index element
Jakub Kuderski [Wed, 1 Mar 2023 19:03:17 +0000 (14:03 -0500)]
[mlir][spirv] Support shaped types with index element

This makes the SPIR-V type converter first convert `index` element types
to the right integer type.

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

Reviewed By: antiagainst

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

20 months ago[DAG] expandIntMINMAX - attempt to match existing SETCC node
Simon Pilgrim [Wed, 1 Mar 2023 19:03:56 +0000 (19:03 +0000)]
[DAG] expandIntMINMAX - attempt to match existing SETCC node

As noticed on D144789, when we have pairs of min/max nodes we often end up with multiple comparisons which we could reuse with commuted select ops, so check to see if a suitable SETCC already exists. This also allowed us to remove a similar X86 peephole.

There are other getSETCC cases where we could safely reuse other CondCodes as well - I've been trying to think of how we could reuse this logic in SelectionDAG but haven't found anything that always works well.

An alternative would be to have a TLI callback that returns a preferred CondCode from a list of options, I've noticed this helped fpclamptosat tests on some other targets (MVE + WebAssembly), but other tests suffered.

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

20 months ago[llvm-readobj] Add --memtag
Mitch Phillips [Wed, 1 Mar 2023 18:49:39 +0000 (10:49 -0800)]
[llvm-readobj] Add --memtag

This adds functionality to readelf/readobj to specifically handle
MTE-related bits, like the AARCH64_MEMTAG_* dynamic entries, and a
decoder for the Android-specific ELF note.

Reviewed By: jhenderson, MaskRay

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

20 months ago[libc] Fix strcspn
Alex Brachet [Wed, 1 Mar 2023 18:57:07 +0000 (18:57 +0000)]
[libc] Fix strcspn

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

20 months ago[libc] Fix printf %f rounding condition
Michael Jones [Tue, 28 Feb 2023 23:10:08 +0000 (15:10 -0800)]
[libc] Fix printf %f rounding condition

When running the tbin2dec tests I found a rounding error in my code.
Upon inspection I realized it was due to a lack of parenthesis when
calculating the number of trailing digits. This patch fixes that mistake
and adds unit tests to catch regressions in future.

Reviewed By: lntue

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

20 months ago[GWP-ASan][Fuchsia] Use more modern zxtest testing macros
Alex Brachet [Wed, 1 Mar 2023 18:54:05 +0000 (18:54 +0000)]
[GWP-ASan][Fuchsia] Use more modern zxtest testing macros

20 months ago[GWP-ASan] Stop using type aliases for ::testing:: types
Alex Brachet [Wed, 1 Mar 2023 18:49:18 +0000 (18:49 +0000)]
[GWP-ASan] Stop using type aliases for ::testing:: types

20 months ago[libc++][NFC] Move test to .compile.pass.cpp since it doesn't run anything
Louis Dionne [Wed, 1 Mar 2023 18:21:01 +0000 (13:21 -0500)]
[libc++][NFC] Move test to .compile.pass.cpp since it doesn't run anything

20 months ago[libc++] implement move_iterator<T*> should be a random access iterator \n Differntia...
Shivam kunwar [Wed, 1 Mar 2023 18:11:36 +0000 (23:41 +0530)]
[libc++] implement move_iterator<T*> should be a random access iterator \n Differntial Revision- https://reviews.llvm.org/D135248

20 months ago[PhaseOrdering] add test for vector load and cast transforms; NFC
Sanjay Patel [Wed, 1 Mar 2023 17:18:44 +0000 (12:18 -0500)]
[PhaseOrdering] add test for vector load and cast transforms; NFC

issue #51397

20 months ago[InstCombine] add tests for signed absolute diff; NFC
Sanjay Patel [Wed, 1 Mar 2023 14:24:54 +0000 (09:24 -0500)]
[InstCombine] add tests for signed absolute diff; NFC

20 months ago[mlir] Fix a warning
Kazu Hirata [Wed, 1 Mar 2023 17:42:31 +0000 (09:42 -0800)]
[mlir] Fix a warning

This patch fixes:

  mlir/lib/Dialect/Linalg/Transforms/HoistPadding.cpp:37:13: error:
  unused function 'debugPrintLoopInShortForm'
  [-Werror,-Wunused-function]

20 months ago[ADCE] Keep track of if we modified the CFG and preserve analyses accordingly
Arthur Eubanks [Tue, 28 Feb 2023 23:06:51 +0000 (15:06 -0800)]
[ADCE] Keep track of if we modified the CFG and preserve analyses accordingly

No measurable compile time impact, but might as well resolve the TODO.

Reviewed By: nikic

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

20 months ago[PassBuilder] Always enable CountVisitsPass when stats are enabled
Arthur Eubanks [Tue, 28 Feb 2023 23:38:01 +0000 (15:38 -0800)]
[PassBuilder] Always enable CountVisitsPass when stats are enabled

Rather than having a separate flag.

Reviewed By: asbirlea

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

20 months ago[SIAnnotateControlFlow] Use Uniformity analysis
Anshil Gandhi [Wed, 1 Mar 2023 17:19:17 +0000 (10:19 -0700)]
[SIAnnotateControlFlow] Use Uniformity analysis

Reviewed By: foad

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

20 months ago[AMDGPUUnifyDivergentExitNodes] Use Uniformity Analysis
Anshil Gandhi [Wed, 1 Mar 2023 17:15:31 +0000 (10:15 -0700)]
[AMDGPUUnifyDivergentExitNodes] Use Uniformity Analysis

Reviewed By: foad

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

20 months ago[clang] drop buggy use of `-serialize-diagnostics` flag
Ashay Rane [Tue, 28 Feb 2023 01:14:13 +0000 (19:14 -0600)]
[clang] drop buggy use of `-serialize-diagnostics` flag

The `-serialize-diagnostics` flag requires a filename to be passed
immediately after it, but the filename argument was skipped in the
P1689.cppm clang test.  This caused the code to incorrectly consume the
argument that followed as the dignostics file.

Since the `-serialize-diagnostics` flag isn't needed for this test to
work, this patch removes it instead of passing a file argument.

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

20 months ago[ASTMatcher] Add coroutineBodyStmt matcher
Chris Cotter [Wed, 1 Mar 2023 16:51:46 +0000 (11:51 -0500)]
[ASTMatcher] Add coroutineBodyStmt matcher

The coroutineBodyStmt matcher matches CoroutineBodyStmt AST nodes.

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

20 months ago[DAG] ABD is not reassociative
David Green [Wed, 1 Mar 2023 16:22:13 +0000 (16:22 +0000)]
[DAG] ABD is not reassociative

I'm not sure how I missed this in the testing, but as far as I understand
whilst ABDS and ABDU are commutive they are not associative. This patch
disables reassociateOps from visitABD, fixing the problems found in #61069.
ABDU: https://alive2.llvm.org/ce/z/eiT5QG
ABDS: https://alive2.llvm.org/ce/z/HzE29l

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

20 months ago[ADT] Use `adl_begin`/`end` in `enumerate`
Jakub Kuderski [Wed, 1 Mar 2023 16:10:40 +0000 (11:10 -0500)]
[ADT] Use `adl_begin`/`end` in `enumerate`

This allows `enumerate` to work with range types that expose custom
`begin`/`end` functions.

This is a cleanup in preparation for future changes in
https://reviews.llvm.org/D144503.

Reviewed By: zero9178

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

20 months agoFix Bazel build post c888a0ce8846e7ebf30914d4959125da80b3f566
Nicolas Vasilache [Wed, 1 Mar 2023 16:10:49 +0000 (08:10 -0800)]
Fix Bazel build post c888a0ce8846e7ebf30914d4959125da80b3f566

20 months ago[clang][Interp] Handle DecompositionDecls
Timm Bäder [Thu, 12 Jan 2023 11:47:02 +0000 (12:47 +0100)]
[clang][Interp] Handle DecompositionDecls

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

20 months ago[libc++] Fix modules issues on OS X
Arthur O'Dwyer [Sun, 31 Jul 2022 16:25:05 +0000 (12:25 -0400)]
[libc++] Fix modules issues on OS X

First, fix a collision with the Point type from MacTypes.h, which was
reported on Slack, 2022-07-31: https://cpplang.slack.com/archives/C2X659D1B/p1659284691275889

Second, rename the meta:: namespace to types::. OSX's "/usr/include/ncurses.h"
defines a `meta` function, and is (for some reason) included in
"<SDK>/usr/include/module.modulemap", so that identifier is off-limits
for us to use in anything that compiles with -fmodules:

    libcxx/test/support/type_algorithms.h:16:11: error: redefinition of 'meta' as different kind of symbol
    namespace meta {
               ^
    <SDK>/usr/include/ncurses.h:603:28: note: previous definition is here
    extern NCURSES_EXPORT(int) meta (WINDOW *,bool);                        /* implemented */
                                ^

Finally, add a CI configuration for modules on OS X to make sure it
does not regress.

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

20 months ago[mlir][sparse] Improve the implementation of sparse_tensor.new for the codegen path.
bixia1 [Tue, 28 Feb 2023 20:52:16 +0000 (12:52 -0800)]
[mlir][sparse] Improve the implementation of sparse_tensor.new for the codegen path.

Rewrite a NewOp into a NewOp of a sorted COO tensor and a ConvertOp for
converting the sorted COO tensor to the destination tensor type.

Codegen a NewOp of a sorted COO tensor to use the new bulk reader API and sort
the elements only when the input is not sorted.

Reviewed By: aartbik

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

20 months ago[mlir][MemRef] Rewrite multi-buffering with proper composable abstractions
Nicolas Vasilache [Wed, 1 Mar 2023 11:47:56 +0000 (03:47 -0800)]
[mlir][MemRef] Rewrite multi-buffering with proper composable abstractions

Rewrite and document multi-buffering properly:
1. Use IndexingUtils / StaticValueUtils instead of duplicating functionality
2. Properly plumb RewriterBase through.
3. Add support
4. Better debug messages.

This revision is otherwise almost NFC, if it weren't for the extra DeallocOp
support that would previoulsy make multi-buffering fail.

Depends on: D145036

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

20 months ago[clang][RISCV][test] Add coverage for __fp16 support in arguments/returns
Alex Bradbury [Wed, 1 Mar 2023 15:17:19 +0000 (15:17 +0000)]
[clang][RISCV][test] Add coverage for __fp16 support in arguments/returns

By choice, we don't set HalfArgsAndReturns=true (which would allow
__fp16 in args and returns). Add test coverage for this to ensure it
isn't changed by accident.

20 months ago[SimpleLoopUnswitch] Forget loops before invalidating IR.
Florian Hahn [Wed, 1 Mar 2023 15:06:33 +0000 (16:06 +0100)]
[SimpleLoopUnswitch] Forget loops before invalidating IR.

Invalidate SCEV before adjusting switch instruction, so the IR remains
in a valid state for SCEV invalidation.

20 months ago[ARM] Remove a redundant function fixupBTI
Jirui Wu [Mon, 27 Feb 2023 15:03:42 +0000 (15:03 +0000)]
[ARM] Remove a redundant function fixupBTI

Since the redundant BTI instructions emitted by jump tables are now
removed in the ARMBranchTargets pass, the fixupBTI function is not needed
in the ARMConstantIslandPass. Some related tests are removed as well.

The relevant patch that removes the redundant BTI instructions:
https://reviews.llvm.org/D144470

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

20 months ago[flang] MERGE result is polymorphic only if TSOURCE and FSOURCE are polymorphic
Valentin Clement [Wed, 1 Mar 2023 14:43:34 +0000 (15:43 +0100)]
[flang] MERGE result is polymorphic only if TSOURCE and FSOURCE are polymorphic

16.9.129 point 4: the result is polymorphic if and only if both TSOURCE and
FSOURCE are polymorphic.

If neither TSOURCE and FSOURCE are polymorphic then the current behavior is
preserved.

Depends on D145058

Reviewed By: jeanPerier

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

20 months agoLibclangTest: remove libclang-test-* tmp dir reliably
Igor Kushnir [Wed, 1 Mar 2023 14:44:43 +0000 (09:44 -0500)]
LibclangTest: remove libclang-test-* tmp dir reliably

Temporary directories created by two LibclangReparseTest tests -
ReparseWithModule and clang_parseTranslationUnit2FullArgv - remained in
the system temporary directory after running libclangTests, because not
all files and subdirectories created in TestDir were added to set
LibclangParseTest::Files.

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

20 months ago[flang] Allow scalar boxed record type in intrinsic elemental lowering
Valentin Clement [Wed, 1 Mar 2023 14:41:56 +0000 (15:41 +0100)]
[flang] Allow scalar boxed record type in intrinsic elemental lowering

Relax a bit the condition added in D144417 and allow scalar polymorphic entities
and boxed scalar record type.

Reviewed By: jeanPerier

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

20 months ago[clang][Interp] This pointers are writable in de-/constructors
Timm Bäder [Wed, 26 Oct 2022 09:20:13 +0000 (11:20 +0200)]
[clang][Interp] This pointers are writable in de-/constructors

This is possible in C++20, so we need to check this when doing stores.

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

20 months ago[SLP][NFC]Update the test to simplify and avoid dead instruction
Alexey Bataev [Wed, 1 Mar 2023 14:34:52 +0000 (06:34 -0800)]
[SLP][NFC]Update the test to simplify and avoid dead instruction
removal, NFC.

20 months ago[CodeGen] Always expand division larger than i128
Nikita Popov [Mon, 27 Feb 2023 14:23:01 +0000 (15:23 +0100)]
[CodeGen] Always expand division larger than i128

Default MaxDivRemBitWidthSupported to 128, so that divisions larger
than 128 bits are always expanded, without requiring additional
configuration from the target.

Note that this may still emit calls to __udivti3 on 32-bit targets,
which likely don't have an implementation of that builtin. However,
I believe this is sufficient to fix
https://github.com/llvm/llvm-project/issues/60531, because Zig must
already be defining those builtins.

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

20 months ago[RISCV] Pre-commit test case for ordered reduction, NFC
Mel Chen [Tue, 21 Feb 2023 07:08:37 +0000 (23:08 -0800)]
[RISCV] Pre-commit test case for ordered reduction, NFC

Reviewed By: reames

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

20 months ago[LoopVectorize] Use overflow-check analysis to improve tail-folding.
Sander de Smalen [Mon, 30 Jan 2023 11:21:31 +0000 (11:21 +0000)]
[LoopVectorize] Use overflow-check analysis to improve tail-folding.

This work follows on from D142109 and addresses a possible regression
when we know the loop iteration counter cannot overflow.

When we know the overflow-check always evaluates to false, it's better to
use the other style of tail folding where it assumes a runtime check was
added, because that avoids having to calculate a modified trip-count.

Reviewed By: paulwalker-arm

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

20 months ago[gn build] Port f8d10d5ac9ab
LLVM GN Syncbot [Wed, 1 Mar 2023 14:01:57 +0000 (14:01 +0000)]
[gn build] Port f8d10d5ac9ab

20 months ago[InstCombine] prevent miscompiles from select-of-div/rem transform
Sanjay Patel [Wed, 1 Mar 2023 13:32:27 +0000 (08:32 -0500)]
[InstCombine] prevent miscompiles from select-of-div/rem transform

This avoids the danger shown in issue #60906.
There were no regression tests for these patterns, so these potential
failures have been around for a long time.

We freeze the condition and preserve the optimization because
getting rid of a div/rem is always a win.

Here are a couple of examples that can be corrected by freezing the
condition:
https://alive2.llvm.org/ce/z/sXHTTC

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

20 months ago[AArch64] Load into zero vector patterns
David Green [Wed, 1 Mar 2023 13:54:03 +0000 (13:54 +0000)]
[AArch64] Load into zero vector patterns

A LDR will implicitly zero the rest of the vector, so vector_insert(zeros,
load, 0) can use a single load. This adds tablegen patterns for both scaled and
unscaled loads, detecting where we are inserting a load into the lower element
of a zero vector.

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

20 months ago[gn] port e281d102fb73 more
Nico Weber [Wed, 1 Mar 2023 13:50:44 +0000 (08:50 -0500)]
[gn] port e281d102fb73 more

20 months agoMove close() to the proper else block
Wu, Yingcong [Wed, 1 Mar 2023 13:38:00 +0000 (19:08 +0530)]
Move close() to the proper else block

`LogWriter::Close(LW)` is outside the null check if-else block, which, when `LW == nullptr`, will causing a NULL dereference.
I think the close() means to be in else block, which is when `LW != nullptr`.

Reviewed By: xgupta

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

20 months ago[clang][RISCV][test] Add further test coverage for _Float16 on RISC-V
Alex Bradbury [Wed, 1 Mar 2023 13:31:40 +0000 (13:31 +0000)]
[clang][RISCV][test] Add further test coverage for _Float16 on RISC-V

Check for size and alignment as we do for other types.

20 months ago[flang] Implement isnan and ieee_is_nan intrinsics
David Truby [Thu, 23 Feb 2023 16:24:50 +0000 (16:24 +0000)]
[flang] Implement isnan and ieee_is_nan intrinsics

To implement these we call the LLVM intrinsic is.fpclass indicating that
we are checking for either a quiet or signalling NaN.

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