platform/upstream/llvm.git
21 months ago[RISCV] Use branchless form for selects with 0 in either arm
Philip Reames [Wed, 12 Oct 2022 20:44:12 +0000 (13:44 -0700)]
[RISCV] Use branchless form for selects with 0 in either arm

Continuing the theme of adding branchless lowerings for simple selects, this time handle the 0 arm case. This is very common for various umin idioms, etc..

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

21 months ago[libc++] Add missing UNSUPPORTED annotations for std::pmr tests that use RTTI
Louis Dionne [Wed, 12 Oct 2022 20:39:26 +0000 (16:39 -0400)]
[libc++] Add missing UNSUPPORTED annotations for std::pmr tests that use RTTI

This is the equivalent of 340b48b267b9 applied to the non-experimental
std::pmr.

21 months ago[libc++][NFC] Fix incorrect main signatures in tests
Louis Dionne [Wed, 12 Oct 2022 20:24:30 +0000 (16:24 -0400)]
[libc++][NFC] Fix incorrect main signatures in tests

21 months ago [libc++] Replace some _LIBCPP_HIDDEN with _LIBCPP_HIDE_FROM_ABI
David Tenty [Wed, 12 Oct 2022 20:45:58 +0000 (16:45 -0400)]
 [libc++] Replace some _LIBCPP_HIDDEN with _LIBCPP_HIDE_FROM_ABI

These "implementation detail" function templates were already
hidden and have no specializations in the dylib, so they seem like they can safely
use _LIBCPP_HIDE_FROM_ABI instead and have the abi tags applied as well.

Seems some of these got over looked (e.g. D129823) in various places, and they
won't be flagged by the new checks added in D129968, as they were
already hidden.

Reviewed by: ldionne

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

21 months ago[HIP] Fix unbundling archive
Yaxun (Sam) Liu [Tue, 11 Oct 2022 22:53:59 +0000 (18:53 -0400)]
[HIP] Fix unbundling archive

When -lxxx is specified, if there happens to have a directory or
file with name xxx, clang will not look up libxxx.a, but will
try to unbundle xxx instead.

Reviewed by: Saiyedul Islam, Artem Belevich

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

21 months ago[libc] add headers sys/auxv sys/prctl and sys/time
Michael Jones [Tue, 11 Oct 2022 22:30:07 +0000 (15:30 -0700)]
[libc] add headers sys/auxv sys/prctl and sys/time

These headers are uncommonly used, and from extensions, but some basic
support is needed. Macros have been added where available.

Reviewed By: sivachandra

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

21 months ago[libc++][NFC] Fix typo in comment
Louis Dionne [Wed, 12 Oct 2022 20:06:17 +0000 (16:06 -0400)]
[libc++][NFC] Fix typo in comment

21 months ago[Hexagon] Handle packing of even/odd 32-bit words
Krzysztof Parzyszek [Wed, 12 Oct 2022 18:39:17 +0000 (11:39 -0700)]
[Hexagon] Handle packing of even/odd 32-bit words

This is a workaround until perfect shuffle generation is improved.

21 months ago[LTO][clang] Teaching Clang to Pass Plugin Options to the AIX Linker
Qiongsi Wu [Wed, 12 Oct 2022 19:16:07 +0000 (15:16 -0400)]
[LTO][clang] Teaching Clang to Pass Plugin Options to the AIX Linker

This patch teaches `clang` to use the prefix `-bplugin_opt:` (instead of `-plugin-opt`) on AIX, when passing plugin options to the linker. This patch follows https://reviews.llvm.org/D134668.

We put the code that decides what plugin option prefix to use at the top of the function `tools::addLTOOptions`. The plugin option prefix, the mcpu prefix, and the opt level prefix are different on AIX. We thought about choosing the strings in a function that reads the linker name and the target triple, or we could push the logic into different derived `ToolChain` classes. But this logic would not be used anywhere else, so these alternatives looked too complicated for what they did. Therefore we are doing it the current way. That said, I am all ears for suggestions to improve this code!

Subsequent code uses the `PluginOptPrefix` variable consistently instead of the hardcoded `-plugin-opt`.

Reviewed By: MaskRay

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

21 months ago[AMDGPU] Add GFX11 tests for fcmp and ballot. NFC
Joe Nash [Wed, 12 Oct 2022 14:53:10 +0000 (10:53 -0400)]
[AMDGPU] Add GFX11 tests for fcmp and ballot. NFC

Reviewed By: foad

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

21 months agoRevert "[runtimes] Always define cxx_shared, cxx_static & other targets"
Haowei Wu [Wed, 12 Oct 2022 19:54:48 +0000 (12:54 -0700)]
Revert "[runtimes] Always define cxx_shared, cxx_static & other targets"

This reverts commit 79ee0342dbf025bc70f237bdfe9ccb4e10a592ce which
breaks the LLVM TSan bots.

21 months agoMove interpreter check before modifying the allocation type.
Jacob Hegna [Wed, 12 Oct 2022 04:36:34 +0000 (04:36 +0000)]
Move interpreter check before modifying the allocation type.

21 months ago[MLGO] Force persistency in tflite buffers.
Jacob Hegna [Wed, 12 Oct 2022 02:05:19 +0000 (02:05 +0000)]
[MLGO] Force persistency in tflite buffers.

When training large models, we encounter use-after-free bugs when
writing to the input tensors for various MLGO models. This patch fixes the
issue by marking the tensors as "persistent".

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

21 months ago[Hexagon] Implement TLI::isExtractSubvectorCheap hook
Krzysztof Parzyszek [Wed, 12 Oct 2022 18:35:59 +0000 (11:35 -0700)]
[Hexagon] Implement TLI::isExtractSubvectorCheap hook

21 months ago[ConstraintElim] Move GEP decomposition code to separate fn (NFC).
Florian Hahn [Wed, 12 Oct 2022 19:38:30 +0000 (20:38 +0100)]
[ConstraintElim] Move GEP decomposition code to separate fn (NFC).

Breaks up a large function and allows for the use to early exits.

21 months ago[LLD] Enable --no-undefined-version by default.
Dan Albert [Thu, 6 Oct 2022 22:22:55 +0000 (15:22 -0700)]
[LLD] Enable --no-undefined-version by default.

Allowing incorrect version scripts is not a helpful default. Flip that
to help users find their bugs at build time rather than at run time.

Reviewed By: MaskRay

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

21 months ago[AArch64] Generate SEH info for PAC instructions
Martin Storsjö [Sat, 1 Oct 2022 15:49:32 +0000 (18:49 +0300)]
[AArch64] Generate SEH info for PAC instructions

Without this, unwinding through functions that does use PAC
would fail, if PAC actually was active.

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

21 months ago[AArch64] [SEH] Rename pac_sign_return_address to pac_sign_lr
Martin Storsjö [Wed, 12 Oct 2022 11:27:22 +0000 (14:27 +0300)]
[AArch64] [SEH] Rename pac_sign_return_address to pac_sign_lr

This new opcode was initially documented as "pac_sign_return_address"
in https://github.com/MicrosoftDocs/cpp-docs/pull/4202, but was
soon afterwards renamed into "pac_sign_lr" in
https://github.com/MicrosoftDocs/cpp-docs/pull/4209, as the other
name was unwieldy, and there were no other external references to
that name anywhere.

Rename our external .seh assembler directive - it hasn't been merged
for very long yet, so there's probably no external use to account for.

Rename all other internal references to the opcode similarly.

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

21 months ago[flang] Fix after introduction of ConditionallySpeculatable
Valentin Clement [Wed, 12 Oct 2022 19:14:46 +0000 (12:14 -0700)]
[flang] Fix after introduction of ConditionallySpeculatable

86771d0b65ee introduced some fialure for flang

https://buildkite.com/llvm-project/premerge-checks/builds/116406#0183ca8c-bc14-4314-9b1d-c764cf47e0aa

Update FIROps.td to fix the issues.

21 months ago[Clang] Do not crash when an invalid offload architecture is set
Joseph Huber [Wed, 12 Oct 2022 16:31:46 +0000 (11:31 -0500)]
[Clang] Do not crash when an invalid offload architecture is set

If an invalid architecture is set we currently return an empty string.
This will cause the offloading toolchain to continue to be built and
hit an assertion elsewhere due to the invalid architecture. This patch
fixes that so we now correctly exit.

Reviewed By: tra

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

21 months ago[libc++] Add test for bug that had been introduced in D98573 and fixed in D119633
Louis Dionne [Wed, 5 Oct 2022 18:03:31 +0000 (14:03 -0400)]
[libc++] Add test for bug that had been introduced in D98573 and fixed in D119633

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

21 months ago[gn build] Set _LIBCPP_ABI_NAMESPACE to __$libcxx_abi_version
Arthur Eubanks [Wed, 12 Oct 2022 18:58:01 +0000 (11:58 -0700)]
[gn build] Set _LIBCPP_ABI_NAMESPACE to __$libcxx_abi_version

Matches CMake build.
Otherwise currently everything is literally std::_LIBCPP_ABI_NAMESPACE::foo.

21 months ago[Frontend] Recognize environment variable SOURCE_DATE_EPOCH
Fangrui Song [Wed, 12 Oct 2022 18:55:26 +0000 (11:55 -0700)]
[Frontend] Recognize environment variable SOURCE_DATE_EPOCH

See https://reproducible-builds.org/docs/source-date-epoch/ . The environment
variable ``SOURCE_DATE_EPOCH`` been recognized by many compilers.

In GCC, if `SOURCE_DATE_EPOCH` is set, it specifies a UNIX timestamp to be used
in replacement of the current date and time in the `__DATE__` and `__TIME__`
macros. Note: GCC as of today does not update `__TIMESTAMP__` (the modification
time of the current source file) but
https://wiki.debian.org/ReproducibleBuilds/TimestampsFromCPPMacros expresses the
intention to update it.

This patches parses SOURCE_DATE_EPOCH and changes all the three macros.

In addition, in case gmtime/localtime returns null (e.g. on 64-bit Windows
gmtime returns null when the timestamp is larger than 32536850399
(3001-01-19T21:59:59Z)), use `??? ?? ????` as used by GCC.

Reviewed By: ychen

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

21 months ago[llvm-objcopy] Support --decompress-debug-sections when zlib is disabled
Fangrui Song [Wed, 12 Oct 2022 18:52:05 +0000 (11:52 -0700)]
[llvm-objcopy] Support --decompress-debug-sections when zlib is disabled

When zlib is disabled at build time, the diagnostic `LLVM was not compiled with
LLVM_ENABLE_ZLIB: cannot decompress` for --decompress-debug-sections may be
inaccurate: if zstd is enabled, we should still support zstd decompression.

It's not useful to test zlib and zstd. Just remove the diagnostic and add a new
one before `compression::decompress`.

This fixes compress-debug-sections-zstd.test

Reviewed By: mariusz-sikora-at-amd, jhenderson, phosek

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

21 months ago[ConstraintElimination] Add tests with 128 bit pointers.
Florian Hahn [Wed, 12 Oct 2022 18:49:29 +0000 (19:49 +0100)]
[ConstraintElimination] Add tests with 128 bit pointers.

21 months ago[libc++][NFC] Remove __lcpp prefix in math.h
Nikolas Klauser [Wed, 12 Oct 2022 13:45:09 +0000 (15:45 +0200)]
[libc++][NFC] Remove __lcpp prefix in math.h

Reviewed By: ldionne, #libc

Spies: libcxx-commits

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

21 months ago[NFC][libc++] Moves transitive includes location.
Mark de Wever [Sun, 2 Oct 2022 17:42:46 +0000 (19:42 +0200)]
[NFC][libc++] Moves transitive includes location.

This moves some includes missed in D133212.

Reviewed By: ldionne, #libc, philnik

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

21 months ago[libc++][NFC] Replace _LIBCPP_INLINE_VISIBILITY in math.h
Nikolas Klauser [Wed, 12 Oct 2022 13:41:22 +0000 (15:41 +0200)]
[libc++][NFC] Replace _LIBCPP_INLINE_VISIBILITY in math.h

Reviewed By: ldionne, #libc

Spies: libcxx-commits

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

21 months ago[PowerPC] Pre-commit unit test change for D132978
Peter Rong [Wed, 12 Oct 2022 18:26:57 +0000 (11:26 -0700)]
[PowerPC] Pre-commit unit test change for D132978

21 months ago[modules] Allow to validate system headers less often with `-fmodules-validate-once...
Volodymyr Sapsai [Wed, 5 Oct 2022 00:25:03 +0000 (17:25 -0700)]
[modules] Allow to validate system headers less often with `-fmodules-validate-once-per-build-session`.

Make flags `-fmodules-validate-system-headers` and
`-fmodules-validate-once-per-build-session` orthogonal, so they have
their own independent responsibilities - if system headers should be
validated and how often.

rdar://87988889

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

21 months agoIntroduce a ConditionallySpeculatable op interface
Sanjoy Das [Thu, 6 Oct 2022 22:57:25 +0000 (15:57 -0700)]
Introduce a ConditionallySpeculatable op interface

This patch takes the first step towards a more principled modeling of undefined behavior in MLIR as discussed in the following discourse threads:

 1. https://discourse.llvm.org/t/semantics-modeling-undefined-behavior-and-side-effects/4812
 2. https://discourse.llvm.org/t/rfc-mark-tensor-dim-and-memref-dim-as-side-effecting/65729

This patch in particular does the following:

 1. Introduces a ConditionallySpeculatable OpInterface that dynamically determines whether an Operation can be speculated.
 2. Re-defines `NoSideEffect` to allow undefined behavior, making it necessary but not sufficient for speculation.  Also renames it to `NoMemoryEffect`.
 3. Makes LICM respect the above semantics.
 4. Changes all ops tagged with `NoSideEffect` today to additionally implement ConditionallySpeculatable and mark themselves as always speculatable.  This combined trait is named `Pure`.  This makes this change NFC.

For out of tree dialects:

 1. Replace `NoSideEffect` with `Pure` if the operation does not have any memory effects, undefined behavior or infinite loops.
 2. Replace `NoSideEffect` with `NoSideEffect` otherwise.

The next steps in this process are (I'm proposing to do these in upcoming patches):

 1. Update operations like `tensor.dim`, `memref.dim`, `scf.for`, `affine.for` to implement a correct hook for `ConditionallySpeculatable`.  I'm also happy to update ops in other dialects if the respective dialect owners would like to and can give me some pointers.
 2. Update other passes that speculate operations to consult `ConditionallySpeculatable` in addition to `NoMemoryEffect`.  I could not find any other than LICM on a quick skim, but I could have missed some.
 3. Add some documentation / FAQs detailing the differences between side effects, undefined behavior, speculatabilty.

Reviewed By: rriddle, mehdi_amini

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

21 months ago[AST] Preserve more structure in UsingEnumDecl node.
Sam McCall [Tue, 20 Sep 2022 19:39:47 +0000 (21:39 +0200)]
[AST] Preserve more structure in UsingEnumDecl node.

- store NestedNameSpecifier & Loc for the qualifiers
  This information was entirely missing from the AST.
- expose the location information for qualifier/identifier/typedefs as typeloc
  This allows many traversals/astmatchers etc to handle these generically along
  with other references. The decl vs type split can help preserve typedef
  sugar when https://github.com/llvm/llvm-project/issues/57659 is resolved.
- fix the SourceRange of UsingEnumDecl to include 'using'.

Fixes https://github.com/clangd/clangd/issues/1283

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

21 months ago[X86] Pre-commit more unit tests for D134477
Han Zhu [Wed, 12 Oct 2022 06:58:27 +0000 (23:58 -0700)]
[X86] Pre-commit more unit tests for D134477

21 months agoAdd test to show missed optimization for masked load/stores
Benjamin Maxwell [Wed, 12 Oct 2022 11:25:51 +0000 (11:25 +0000)]
Add test to show missed optimization for masked load/stores

This test shows instcombine failing to remove a alloca and memcpy for
for a constant array that is read with a masked load.

This will be addressed in a subsequent commit.

21 months ago[AArch64] Pre-commit test case to show sub-optimal codegen for Github issue #57502
Mingming Liu [Mon, 5 Sep 2022 02:30:28 +0000 (19:30 -0700)]
[AArch64] Pre-commit test case to show sub-optimal codegen for Github issue #57502

Pre-commit test cases to show cases when UZP1 (TRUNC, TRUNC) could be
combined into TRUNC (UZP1) (with some proper bit conversions in the middle) to generate more efficient code.

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

21 months ago[libcxxabi]: Resync llvm & libcxxabi's demangler
Nathan Sidwell [Fri, 7 Oct 2022 14:03:32 +0000 (07:03 -0700)]
[libcxxabi]: Resync llvm & libcxxabi's demangler

Sadly the demangler copies have diverged.  This resyncs them by
a) pulling the meaningful llvm changes into libcxxabi's gold copy.
b) rerunning the sync script.

I notice uses of placement new, which assume the allocator succeeds --
that's incorrect in general, but an orthogonal problem.

Reviewed By: bader

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

21 months ago[PrintPipeline] Handle CoroConditionalWrapper and add more verification
Arthur Eubanks [Tue, 11 Oct 2022 18:14:53 +0000 (11:14 -0700)]
[PrintPipeline] Handle CoroConditionalWrapper and add more verification

Add a check (can be disabled via a flag) that the pipeline we generate is actually parsable.
Can be disabled because we don't expect to handle every pass in -print-pipeline-passes.

Fixes #58280.

Reviewed By: ChuanqiXu

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

21 months agoApply clang-tidy fixes for modernize-use-using in SparseBufferRewriting.cpp (NFC)
Mehdi Amini [Thu, 6 Oct 2022 19:23:10 +0000 (19:23 +0000)]
Apply clang-tidy fixes for modernize-use-using in SparseBufferRewriting.cpp (NFC)

21 months agoApply clang-tidy fixes for performance-unnecessary-copy-initialization in CodegenUtil...
Mehdi Amini [Thu, 6 Oct 2022 19:22:18 +0000 (19:22 +0000)]
Apply clang-tidy fixes for performance-unnecessary-copy-initialization in CodegenUtils.cpp (NFC)

21 months ago[InstCombine] add test for udiv with shl divisor; NFC
Sanjay Patel [Wed, 12 Oct 2022 15:36:27 +0000 (11:36 -0400)]
[InstCombine] add test for udiv with shl divisor; NFC

This would solve an example from issue #58137 more
generally, but it may require adding a canonicalization
for shift + shift to shift + add.

21 months ago[libc++] Implements constexpr <charconv>.
Mark de Wever [Sat, 6 Aug 2022 08:47:53 +0000 (10:47 +0200)]
[libc++] Implements constexpr <charconv>.

Implements:
- P2291R3 Add Constexpr Modifiers to Functions to_chars and from_chars for
  Integral Types in <charconv> Header

Reviewed By: #libc, ldionne

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

21 months ago[libc++][format] Improves CTAD.
Mark de Wever [Wed, 5 Oct 2022 17:54:44 +0000 (19:54 +0200)]
[libc++][format] Improves CTAD.

This partly reverts D133535 and enables CTAD for more parts in format.

Reviewed By: ldionne, #libc

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

21 months ago[mlir][Linalg] Quarantine usage of LinalgTransformationFilter to TestTilingInterface.
Nicolas Vasilache [Wed, 12 Oct 2022 12:52:30 +0000 (05:52 -0700)]
[mlir][Linalg] Quarantine usage of LinalgTransformationFilter to TestTilingInterface.

This revision also retires code that has now become dead.

Context: https://discourse.llvm.org/t/psa-retire-linalg-filter-based-patterns/63785

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

21 months agoRevert "[libc] New version of the mem* framework"
Guillaume Chatelet [Wed, 12 Oct 2022 15:35:18 +0000 (15:35 +0000)]
Revert "[libc] New version of the mem* framework"

This reverts commit 4c19439d249256db720e323a446e39d05496732f.

21 months ago[SelectionDAG] Use consistent type sizes for opcode
Mirko Brkusanin [Wed, 12 Oct 2022 15:20:46 +0000 (17:20 +0200)]
[SelectionDAG] Use consistent type sizes for opcode

21 months ago[InstCombine] fold sdiv with common shl amount in operands
Sanjay Patel [Wed, 12 Oct 2022 15:18:55 +0000 (11:18 -0400)]
[InstCombine] fold sdiv with common shl amount in operands

(X << Z) / (Y << Z) --> X / Y

https://alive2.llvm.org/ce/z/CLKzqT

This requires a surprising "nuw" constraint because we have
to guard against immediate UB via signed-div overflow with
-1 divisor.

This extends 008a89037a49ca0d9 and is another transform
derived from issue #58137.

21 months ago[libc] New version of the mem* framework
Guillaume Chatelet [Tue, 4 Oct 2022 08:49:02 +0000 (08:49 +0000)]
[libc] New version of the mem* framework

This version is more composable and also simpler at the expense of being more explicit and more verbose.
This patch is not meant to be submitted but gives an idea of the change.
Codegen can be checked in https://godbolt.org/z/6z1dEoWbs by removing the "static inline" before individual functions.

Unittests are coming.

Suggested review order:
 - utils
 - op_base
 - op_builtin
 - op_generic
 - op_x86 / op_aarch64
 - *_implementations.h

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

21 months ago[SLP]Fix insertpoint of the extractellements instructions to avoid reshuffle crash.
Alexey Bataev [Mon, 10 Oct 2022 14:40:35 +0000 (07:40 -0700)]
[SLP]Fix insertpoint of the extractellements instructions to avoid reshuffle crash.

Need to set the insertpoint for extractelement to point to the first
instruction in the node to avoid possible crash during external uses
combine  process. Without it we may endup with the incorrect
transformation.

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

21 months ago[libc] Update benchmarks/README.md
Andre Vieira [Wed, 12 Oct 2022 15:12:23 +0000 (16:12 +0100)]
[libc] Update benchmarks/README.md

This patch updates the instructions on how to run the mem* benchmarks in
README.md.

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

21 months ago[InstCombine] fold udiv with common shl amount in operands
Sanjay Patel [Wed, 12 Oct 2022 14:58:03 +0000 (10:58 -0400)]
[InstCombine] fold udiv with common shl amount in operands

(X << Z) / (Y << Z) --> X / Y

https://alive2.llvm.org/ce/z/E5eaxU

This fixes the motivating example from issue #58137,
but it is not the most general transform. We should
probably also convert left-shift in the divisor to
right-shift in the dividend for that, but that exposes
another missed canonicalization for shifts and adds.

21 months ago[FunctionAttrs] Regenerate test checks (NFC)
Nikita Popov [Wed, 12 Oct 2022 14:59:42 +0000 (16:59 +0200)]
[FunctionAttrs] Regenerate test checks (NFC)

21 months ago[NFC] Ignore unused var in no-asserts builds
Jordan Rupprecht [Wed, 12 Oct 2022 15:11:10 +0000 (08:11 -0700)]
[NFC] Ignore unused var in no-asserts builds

21 months ago[UpdateTestChecks] Add basic BPF triple handling
Simon Pilgrim [Wed, 12 Oct 2022 14:57:45 +0000 (15:57 +0100)]
[UpdateTestChecks] Add basic BPF triple handling

Working on Issue #57872 - its really useful to be able to autogenerate checks

21 months ago[libc++] Remove _LIBCPP_HAS_NO_CXX20_COROUTINES
Louis Dionne [Wed, 5 Oct 2022 15:35:53 +0000 (11:35 -0400)]
[libc++] Remove _LIBCPP_HAS_NO_CXX20_COROUTINES

As far as I can tell, all the compilers we support have support for
C++20 coroutines now.

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

21 months ago[libc++] Disable the GDB pretty printer tests again, since they break the CI
Louis Dionne [Wed, 12 Oct 2022 14:40:06 +0000 (10:40 -0400)]
[libc++] Disable the GDB pretty printer tests again, since they break the CI

21 months ago[CGStmt] Use helper functions to set memory attributes (NFC)
Nikita Popov [Wed, 12 Oct 2022 12:34:03 +0000 (14:34 +0200)]
[CGStmt] Use helper functions to set memory attributes (NFC)

21 months ago[SLP]Fix PR58177: Improve isUndefVector function to avoid extra freeze.
Alexey Bataev [Thu, 6 Oct 2022 18:01:54 +0000 (11:01 -0700)]
[SLP]Fix PR58177: Improve isUndefVector function to avoid extra freeze.

Freeze instruction in some cases makes codegen worse, so need to be very
careful when emitting it. Instead improve analysis in isUndefVector
function to generate mask of unused elements and use it in the analysis.

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

21 months ago[mlir][Linalg] Drop filter-based splitReduction
Nicolas Vasilache [Wed, 12 Oct 2022 12:21:52 +0000 (05:21 -0700)]
[mlir][Linalg] Drop filter-based splitReduction

This transformation is available and tested via the transform dialect.

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

21 months ago[mlir][Linalg] NFC - Drop LinalgLoweringPattern
Nicolas Vasilache [Wed, 12 Oct 2022 12:06:18 +0000 (05:06 -0700)]
[mlir][Linalg] NFC - Drop LinalgLoweringPattern

Linalg ops are generally lowered to loops using a pass and the individual application
of patterns has no concrete uses.
If/when necessary, this can later be reintroduced via a proper transform dialect op.

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

21 months ago[SystemZ] Revert migration of SystemZ/Large/branch-01.ll
Kai Nacke [Wed, 12 Oct 2022 14:10:05 +0000 (14:10 +0000)]
[SystemZ] Revert migration of SystemZ/Large/branch-01.ll

Root cause for the regression is that value %6598 is
defined as a label, and later as an i32 value.

Reviewed By: uweigand

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

21 months ago[LV] Add extra tests for epilogue vectorization with widened inductions.
Florian Hahn [Wed, 12 Oct 2022 14:21:38 +0000 (15:21 +0100)]
[LV] Add extra tests for epilogue vectorization with widened inductions.

Extend test coverage to also include inductions with step > 1 and also
with runtime trip counts.

21 months ago[flang] Use fir.rebox for tbp fir.dispatch call with allocatable or pointer
Valentin Clement [Wed, 12 Oct 2022 14:18:18 +0000 (16:18 +0200)]
[flang] Use fir.rebox for tbp fir.dispatch call with allocatable or pointer

Polymorphic entities with allocatable or pointer attribute cannot be passed
directly as passed-object when the type-bound procedure is expecting a
simply dummy polymorphic entity. Use fir.rebox to adapt the fir.class box
to the tbp type.

Depends on D135649

Reviewed By: jeanPerier

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

21 months ago[mlir] Fix bitwidth of memref-to-llvm constant.
Tobias Gysi [Wed, 12 Oct 2022 14:12:21 +0000 (17:12 +0300)]
[mlir] Fix bitwidth of memref-to-llvm constant.

One constant generated in MemRefToLLVM had a hardcoded bitwidth of
64 bits. The fix uses the typeConverter to create a constant that
matches the bitwidth of the provided by the data layout. The issue was
detected in an attempt to add a verifier to the LLVM ICmp operation that
checks that the types of the compared arguments match.

Reviewed By: ftynse

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

21 months ago[runtimes] Always define cxx_shared, cxx_static & other targets
Louis Dionne [Mon, 19 Sep 2022 20:17:02 +0000 (16:17 -0400)]
[runtimes] Always define cxx_shared, cxx_static & other targets

However, mark them as EXCLUDE_FROM_ALL when we don't want to build them.
Simply declaring the targets should be of no harm, and it allows other
projects to mention these targets regardless of whether they end up
being built or not.

While the diff may not make that obvious, this patch basically
moves the definition of e.g. `cxx_shared` out of the `if (LIBCXX_ENABLE_SHARED)`
and instead marks it as `EXCLUDE_FROM_ALL` conditionally on whether
LIBCXX_ENABLE_SHARED is passed. It then does the same for libunwind
and libc++abi targets.

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

21 months ago[LoongArch] Handle missing CondCodes
gonglingqin [Wed, 12 Oct 2022 13:11:29 +0000 (21:11 +0800)]
[LoongArch] Handle missing CondCodes

Support SETLE/SETEQ and expand SETGE/SETNE/SETGT

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

21 months ago[InstCombine] propagate "exact" through folds of div
Sanjay Patel [Wed, 12 Oct 2022 13:05:34 +0000 (09:05 -0400)]
[InstCombine] propagate "exact" through folds of div

These folds were added recently with:
6b869be8100d
8da2fa856f1b
...but they didn't account for the "exact" attribute,
and that can be safely propagated:
https://alive2.llvm.org/ce/z/F_WhnR
https://alive2.llvm.org/ce/z/ft9Cgr

21 months ago[InstCombine] add "exact" to div tests to show missing propagation; NFC
Sanjay Patel [Wed, 12 Oct 2022 12:53:39 +0000 (08:53 -0400)]
[InstCombine] add "exact" to div tests to show missing propagation; NFC

21 months ago[InstCombine] add helper function for div+shl folds; NFC
Sanjay Patel [Wed, 12 Oct 2022 12:50:13 +0000 (08:50 -0400)]
[InstCombine] add helper function for div+shl folds; NFC

There are at least 2 similar patterns that could be added here,
and the existing fold can be improved because it fails to
propagate "exact".

21 months ago[InstCombine] add tests for div with shl operands; NFC
Sanjay Patel [Tue, 11 Oct 2022 21:06:01 +0000 (17:06 -0400)]
[InstCombine] add tests for div with shl operands; NFC

21 months ago[flang] Lower type-bound procedure call needing dynamic dispatch to fir.dispatch
Valentin Clement [Wed, 12 Oct 2022 13:24:21 +0000 (15:24 +0200)]
[flang] Lower type-bound procedure call needing dynamic dispatch to fir.dispatch

Lower call with polymorphic entities to fir.dispatch operation. This patch only
focus one lowering with simple scalar polymorphic entities. A follow-up patch
will deal with allocatble, pointer and array of polymorphic entities as they
require box manipulation for the passed-object.

Reviewed By: jeanPerier

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

21 months ago[LoongArch] Add earlyclobber of destination register to atomic instructions
gonglingqin [Wed, 12 Oct 2022 12:43:22 +0000 (20:43 +0800)]
[LoongArch] Add earlyclobber of destination register to atomic instructions

If the AM* atomic memory access instruction has the same register number as
rd and rj, the execution will trigger an Instruction Non-defined Exception.
If the AM* atomic memory access instruction has the same register number as
rd and rk, the execution result is uncertain.

Reference: https://github.com/loongson/LoongArch-Documentation

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

21 months agoFix false positive related to handling of [[noreturn]] function pointers
Arseniy Zaostrovnykh [Wed, 12 Oct 2022 12:46:32 +0000 (14:46 +0200)]
Fix false positive related to handling of [[noreturn]] function pointers

Before this change, the `NoReturnFunctionChecker` was missing function pointers
with a `[[noreturn]]` attribute, while `CFG` was constructed taking that into
account, which leads CSA to take impossible paths. The reason was that the
`NoReturnFunctionChecker` was looking for the attribute in the type of the
entire call expression rather than the type of the function being called.

This change makes the `[[noreturn]]` attribute of a function pointer visible
to `NoReturnFunctionChecker`. This leads to a more coherent behavior of the
CSA on the AST involving.

Reviewed By: xazax.hun

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

21 months ago[flang][NFC] Fix FIRTypes.td
Peixin Qiao [Wed, 12 Oct 2022 12:25:34 +0000 (20:25 +0800)]
[flang][NFC] Fix FIRTypes.td

Fix two typos and remove the incorrectly added `extraClassDeclaration` in
`FIRTypes.td`.

Reviewed By: clementval

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

21 months ago[PowerPC][NFC] refactor some test cases.
Chen Zheng [Wed, 12 Oct 2022 12:15:15 +0000 (12:15 +0000)]
[PowerPC][NFC] refactor some test cases.

21 months ago[lldb] Fix member access in GetExpressionPath
Tonko Sabolčec [Wed, 12 Oct 2022 11:46:23 +0000 (11:46 +0000)]
[lldb] Fix member access in GetExpressionPath

This change fixes two issues in ValueObject::GetExpressionPath method:

 1. Accessing members of struct references used to produce expression
    paths such as "str.&str.member" (instead of the expected
    "str.member"). This is fixed by assigning the flag tha the child
    value is a dereference when calling Dereference() on references
    and adjusting logic in expression path creation.

 2. If the parent of member access is dereference, the produced
    expression path was "*(ptr).member". This is incorrect, since it
    dereferences the member instead of the pointer. This is fixed by
    wrapping dereference expression into parenthesis, resulting with
    "(*ptr).member".

Reviewed By: werat, clayborg

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

21 months ago[mlir][Bazel] Port 8446f24ef03928f511ab59dae17a8aa581b0ab62
Adrian Kuegel [Wed, 12 Oct 2022 12:07:31 +0000 (14:07 +0200)]
[mlir][Bazel] Port 8446f24ef03928f511ab59dae17a8aa581b0ab62

21 months ago[mlir][Linalg] Add MapOp to Linalg structured ops.
Adrian Kuegel [Wed, 12 Oct 2022 08:18:38 +0000 (10:18 +0200)]
[mlir][Linalg] Add MapOp to Linalg structured ops.

This will allow to model elementwise ops with this special op instead of using
GenericOp.
Also allow MapOp and ReduceOp to have no result if the output type is not a tensor.
This is needed for buffer semantics.

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

21 months ago[VPlan] Remove dead recipes before sinking.
Florian Hahn [Wed, 12 Oct 2022 11:47:18 +0000 (12:47 +0100)]
[VPlan] Remove dead recipes before sinking.

optimizeInductions may leave dead recipes which can prevent sinking.
Sinking on the other hand should not introduce new dead recipes, so
clean up dead recipes before sinking.

Reviewed By: Ayal

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

21 months ago[mlir][Linalg] NFC - Drop filter from LinalgGeneralizationPattern
Nicolas Vasilache [Wed, 12 Oct 2022 11:14:33 +0000 (04:14 -0700)]
[mlir][Linalg] NFC - Drop filter from LinalgGeneralizationPattern

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

21 months ago[mlir][Linalg] NFC - Drop CodegenStrategy and remaining strategy passes
Nicolas Vasilache [Wed, 12 Oct 2022 10:26:55 +0000 (03:26 -0700)]
[mlir][Linalg] NFC - Drop CodegenStrategy and remaining strategy passes

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

21 months ago[mlir][llvm] Tablegen based operation import from LLVM IR.
Tobias Gysi [Wed, 12 Oct 2022 11:23:10 +0000 (14:23 +0300)]
[mlir][llvm] Tablegen based operation import from LLVM IR.

The revision uses tablegen generated builders to convert the most common
LLVM IR instructions to MLIR LLVM dialect operations. All instructions
with special handlers, except for alloca and fence, still use manual
handlers. The revision also introduces an additional "instructions.ll"
test file to test the import of instructions that have tablegen builders
(except for the resume instruction whose test remains untouched). A part
of the test cases are new, for example the integer instruction test,
while others are migrated from the "basic.ll" test file.

Reviewed By: ftynse

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

21 months ago[NFC] Perform all legality checks for non-trivial unswitch in one function
Max Kazantsev [Wed, 12 Oct 2022 11:14:06 +0000 (18:14 +0700)]
[NFC] Perform all legality checks for non-trivial unswitch in one function

They have been scattered over the code. For better structuring, perform
them in one place. Potential CT drop is possible because we collect exit
blocks twice, but it's small price to pay for much better code structure.

21 months agoDon't widen shuffle element with AVX512
Luo, Yuanke [Wed, 12 Oct 2022 10:42:32 +0000 (18:42 +0800)]
Don't widen shuffle element with AVX512

Fix crash issue of D129537 and reopen it.

Currently the X86 shuffle lowering would widen the element type for
shuffle if the mask element value is adjacent. For below example

  %t2 = add nsw <16 x i32> %t0, %t1
  %t3 = sub nsw <16 x i32> %t0, %t1
  %t4 = shufflevector <16 x i32> %t2, <16 x i32> %t3,
                      <16 x i32> <i32 16, i32 17, i32 2, i32 3, i32 4,
                       i32 5, i32 6, i32 7, i32 8, i32 9, i32 10,
                       i32 11, i32 12, i32 13, i32 14, i32 15>

  ret <16 x i32> %t4

Compiler would transform the shuffle to
  %t4 = shufflevector <8 x i64> %t2, <8 x i64> %t3,
                      <8 x i64> <i32 8, i32 1, i32 2, i32 3, i32 4,
                                 i32 5, i32 6, i32 7>
This may lose the oppotunity to let ISel select mask instruction when
avx512 is enabled.

This patch is to prevent the tranform when avx512 feature is enabled.
Thank Simon for the idea.

Reviewed By: RKSimon

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

21 months ago[Dexter] Ignore step information in __libc_start_call_main
OCHyams [Wed, 12 Oct 2022 11:11:50 +0000 (12:11 +0100)]
[Dexter] Ignore step information in __libc_start_call_main

The test dexter/feature_tests/commands/perfect/expect_step_kind/direction.cpp
was failing on a machine because __libc_start_call_main was not identified as a
"frame below main" (a frame we don't want to gather information from), causing
dexter to count one more step than expected in the test.

Add __libc_start_call_main to the list of "frames below main". There may
be a more robust way of doing this but this is a pragmatic solution we can
use for now.

21 months ago[VPlan] Add test for sinking pointer induction increments.
Florian Hahn [Wed, 12 Oct 2022 11:06:40 +0000 (12:06 +0100)]
[VPlan] Add test for sinking pointer induction increments.

Extra test for D133762.

21 months ago[mlir][doc] move transform dialect docs to .md, NFC
Alex Zinenko [Wed, 12 Oct 2022 11:02:01 +0000 (11:02 +0000)]
[mlir][doc] move transform dialect docs to .md, NFC

The description of the Transform dialect has become quite lengthy to be
kept as a Tablegen string literal. Move it to a proper Markdown file.

21 months ago[mlir] document transform dialect types
Alex Zinenko [Wed, 12 Oct 2022 10:55:54 +0000 (10:55 +0000)]
[mlir] document transform dialect types

21 months ago[test][DebugInfo] Convert some test cases to opaque pointers. NFC
Bjorn Pettersson [Wed, 12 Oct 2022 10:00:25 +0000 (12:00 +0200)]
[test][DebugInfo] Convert some test cases to opaque pointers. NFC

Conversion performed using the script at:
https://gist.github.com/nikic/98357b71fd67756b0f064c9517b62a34

21 months ago[mlir] Apply ClangTidyLegacy findings.
Adrian Kuegel [Wed, 12 Oct 2022 10:45:35 +0000 (12:45 +0200)]
[mlir] Apply ClangTidyLegacy findings.

Use '= default' to define a trivial default constructor.

21 months ago[llvm-objdump] Support nonzero section addresses in addSymbolizer
Pierre van Houtryve [Fri, 7 Oct 2022 08:12:36 +0000 (08:12 +0000)]
[llvm-objdump] Support nonzero section addresses in addSymbolizer

The previous calculations seem to have assumed that the section address would be zero.
This is true for relocatable object files, but certainly not for linked files like shared libraries.

Fixed the calculations to make them identical to the "real" `getInstruction` call below & added a regression test.

Reviewed By: scott.linder, simon_tatham

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

21 months agoRevert "[AArch64] Add support for 128-bit non temporal loads."
David Green [Wed, 12 Oct 2022 10:11:32 +0000 (11:11 +0100)]
Revert "[AArch64] Add support for 128-bit non temporal loads."

This reverts commit 661403b85c219a83baa37335a870d4d93dc4b1c3 as the
custom lowering of loads prevents expanding unaligned loads with
strict-align.

21 months ago[AArch64] Exclude instructions after setting the FP from SEH prologues
Martin Storsjö [Tue, 11 Oct 2022 12:11:39 +0000 (15:11 +0300)]
[AArch64] Exclude instructions after setting the FP from SEH prologues

After setting up the FP, the rest of the prologue doesn't need to
be replayed for unwinding the stack frame.

This allows reverting the functional parts of
2f7fbf837625267193351cc334e506a3a9161958 (but fixing inconsistent
duplicate setting of HasWinCFI).

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

21 months ago[LLDB] Fix x86_64 build
David Spickett [Wed, 12 Oct 2022 09:19:29 +0000 (09:19 +0000)]
[LLDB] Fix x86_64 build

28e65a6a63ab39be97d1a88fe7b4d0fa2f532643 changed the parameter
type of SetType but I forgot to build on x86 as well as arm64.

21 months ago[AArch64][SVE] Add instcombine for PTEST_ANY(X=OP(PG,...), X) -> PTEST_ANY(PG, X))
Cullen Rhodes [Wed, 12 Oct 2022 08:36:03 +0000 (08:36 +0000)]
[AArch64][SVE] Add instcombine for PTEST_ANY(X=OP(PG,...), X) -> PTEST_ANY(PG, X))

Given this is an OR reduction the two are equivalent and later
optimizations (AArch64InstrInfo::optimizePTestInstr) may rewrite the
sequence to use the flag-setting variant of instruction X, to remove the
PTEST altogether.

Reviewed By: paulwalker-arm, bsmith

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

21 months ago[AArch64][SVE] NFC: auto-generate llvm/test/Transforms/InstCombine/AArch64/sve-intrin...
Cullen Rhodes [Fri, 7 Oct 2022 14:29:17 +0000 (14:29 +0000)]
[AArch64][SVE] NFC: auto-generate llvm/test/Transforms/InstCombine/AArch64/sve-intrinsics-ptest.ll

21 months ago[CMake] Add option LLVM_FORCE_CREATE_SYMLINKS
Tobias Hieta [Wed, 12 Oct 2022 08:04:21 +0000 (10:04 +0200)]
[CMake] Add option LLVM_FORCE_CREATE_SYMLINKS

On Windows we don't create symlinks for the binaries (clang++, clang-cl)
since the support requires special setup (group policy settings and
you need to know exactly our distribution story). But if you know
about these things and have a controlled environment there is a lot
of storage to be saved, so let's add a manual opt-in for using symlinks
on Windows with LLVM_FORCE_CREATE_SYMLINKS=ON.

Reviewed By: phosek

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

21 months ago[clang-tidy] Dump effective diagnostics level in YAML output
Dmitry Polukhin [Thu, 6 Oct 2022 14:56:19 +0000 (07:56 -0700)]
[clang-tidy] Dump effective diagnostics level in YAML output

Before this patch YAML output had default diagnostic level instead of effective level reported to the user on stdout. Wrapper scripts for clang-tidy usually use YAML output and they pick wrong diagnostics level without this patch.

Test Plan: check-clang-tools

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

21 months ago[Attributes] Make intrinsic attribute generation more flexible (NFC)
Nikita Popov [Tue, 11 Oct 2022 11:56:06 +0000 (13:56 +0200)]
[Attributes] Make intrinsic attribute generation more flexible (NFC)

Currently attributes for intrinsics are emitted using the
ArrayRef<AttrKind> based constructor for AttributeLists. This works
out fine for simple enum attributes, but doesn't really generalize
to attributes that accept values. We're already doing something
awkward for alignment attributes, and I'd like to have a cleaner
solution to this with
https://discourse.llvm.org/t/rfc-unify-memory-effect-attributes/65579 in mind.

The new generation approach is to instead directly construct
Attributes, giving us access to the full generality of that
interface. To avoid significantly increasing the size of the
generated code, we now also deduplicate the attribute sets. The
code generated per unique AttributeList looks like this:

  case 204: {
    AS[0] = {1, getIntrinsicArgAttributeSet(C, 5)};
    AS[1] = {AttributeList::FunctionIndex, getIntrinsicFnAttributeSet(C, 10)};
    NumAttrs = 2;
    break;
  }

and then the helper functions contain something like

  case 5:
    return AttributeSet::get(C, {
      Attribute::get(C, Attribute::NoCapture),
    });

and

  case 10:
    return AttributeSet::get(C, {
      Attribute::get(C, Attribute::NoUnwind),
      Attribute::get(C, Attribute::ArgMemOnly),
    });

A casualty of this change is the intrin-properties.td test, as I
don't think that FileCheck allows matching this kind of output.

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

21 months ago[LLDB] Change EmulateInstriction::ReadRegister to return Optional
David Spickett [Wed, 28 Sep 2022 15:32:33 +0000 (15:32 +0000)]
[LLDB] Change EmulateInstriction::ReadRegister to return Optional

Making it easier to understand and harder to misuse.
This only applies to the ReadRegister(const RegisterInfo &reg_info) variant.

Depends on D135671

Reviewed By: clayborg

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

21 months ago[AArch64][SVE] Fix BRKNS bug in optimizePTestInstr
Cullen Rhodes [Wed, 12 Oct 2022 08:17:45 +0000 (08:17 +0000)]
[AArch64][SVE] Fix BRKNS bug in optimizePTestInstr

The BRKNS instruction is unlike the other instructions that set flags
since it has an all active implicit predicate, so the existing

  PTEST(PG, BRKN(PG, A, B)) -> BRKNS(PG, A, B)

in AArch64InstrInfo::optimizePTestInstr is incorrect, however

  PTEST(PTRUE_B(31), BRKN(PG, A, B)) -> BRKNS(PG, A, B)

is correct.

Spotted by @paulwalker-arm in D134946.

Reviewed By: paulwalker-arm

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