platform/upstream/llvm.git
17 months ago[Clang] Improve hermeticity of clang_rt tests
Michael Platings [Wed, 22 Feb 2023 08:43:35 +0000 (08:43 +0000)]
[Clang] Improve hermeticity of clang_rt tests

Specifying --sysroot prevents libclang_rt from being located in standard
library directories.

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

17 months ago[AArch64] Fix abs(sub nsw) -> absd
Ricardo Jesus [Mon, 20 Feb 2023 16:44:40 +0000 (16:44 +0000)]
[AArch64] Fix abs(sub nsw) -> absd

This partially reverts a regression introduced in 8f25e382c5b1 for
AArch64 targets. In particular, we restore the logic of `(abs (sub nsw
x, y)) -> abds(x, y)` for all targets except X86, which keeps the logic
introduced in 8f25e382c5b1. See also https://reviews.llvm.org/D142288.

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

17 months ago[Lex] Fix a crash in updateConsecutiveMacroArgTokens.
Haojian Wu [Tue, 14 Feb 2023 23:39:10 +0000 (00:39 +0100)]
[Lex] Fix a crash in updateConsecutiveMacroArgTokens.

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

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

17 months ago[TableGen] Emit static const globals in getOperandType
Michael Liao [Wed, 22 Feb 2023 08:36:36 +0000 (03:36 -0500)]
[TableGen] Emit static const globals in getOperandType

- That saves the overhead of operand type querying.

17 months ago[clang] Add the check of membership for the issue #58674 and improve the lookup process
Liming Liu [Sun, 12 Feb 2023 01:08:13 +0000 (09:08 +0800)]
[clang] Add the check of membership for the issue #58674 and improve the lookup process

This patch includes the commit 01adf96ebc86 and a fix of unhandled declaration
references.

When looking up base classes, Clang first checks whether a base class is a
template and takes the specialized template based on it. However, the base class
might be instantiated, and the above behavior can lose information.

This patch fixes the problem by first checking whether a base class is a record
declaration, so the instantiated one will be taken.

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

17 months ago[FunctionAttrs] Slightly clean up returned attr inference (NFC)
Nikita Popov [Wed, 22 Feb 2023 08:31:12 +0000 (09:31 +0100)]
[FunctionAttrs] Slightly clean up returned attr inference (NFC)

Use hasAttrSomewhere() and directly return Argument from the
helper.

17 months agoThis change makes `RewriterBase` symmetric to `OpBuilder`.
Matthias Springer [Wed, 22 Feb 2023 08:12:24 +0000 (09:12 +0100)]
This change makes `RewriterBase` symmetric to `OpBuilder`.

```
  OpBuilder           OpBuilder::Listener
      ^                        ^
      |                        |
RewriterBase        RewriterBase::Listener
```

* Clients can listen to IR modifications with `RewriterBase::Listener`.
* `RewriterBase` no longer inherits from `OpBuilder::Listener`.
* Only a single listener can be registered at the moment (same as `OpBuilder`).

RFC: https://discourse.llvm.org/t/rfc-listeners-for-rewriterbase/68198

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

17 months ago[flang][runtime] Add API to help with the difficult array constructor cases
Jean Perier [Wed, 22 Feb 2023 08:16:01 +0000 (09:16 +0100)]
[flang][runtime] Add API to help with the difficult array constructor cases

This runtime API can be used to lower any flavor of array constructors,
but is mainly intended to be used with:

- array constructors for which the extent or length parameters cannot
 be computed without lowering some ac-value or ac-implied-do-control
 that cannot be pre-evaluated.

- array constructors of a derived type with allocatable component where
 copy is not trivial or PDTS.

Example of use cases:
 - `[((i+j,i=1, ifoo()), j=1,n)]` where ifoo() is not pure.
 - `[return_allocatable_array(), return_allocatable_array()]`

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

17 months ago[X86][MC] Correct the description & assert for mmm field of EVEX, NFCI
Shengchen Kan [Wed, 22 Feb 2023 07:56:08 +0000 (15:56 +0800)]
[X86][MC] Correct the description & assert for mmm field of EVEX, NFCI

17 months agoRevert "[NFC] Make FPClassTest a bitmask enumeration"
Nikita Popov [Wed, 22 Feb 2023 07:56:19 +0000 (08:56 +0100)]
Revert "[NFC] Make FPClassTest a bitmask enumeration"

This reverts commit 2e416cdd52c1079b8c7cb1f7d7e557c889a4fb56.

Breaks the GCC build:

In file included from /home/npopov/repos/llvm-project/llvm/include/llvm/ADT/FloatingPointMode.h:18,
                 from /home/npopov/repos/llvm-project/llvm/include/llvm/ADT/APFloat.h:20,
                 from /home/npopov/repos/llvm-project/llvm/lib/Support/APFloat.cpp:14:
/home/npopov/repos/llvm-project/llvm/include/llvm/ADT/BitmaskEnum.h:66:22: error: extra qualification not allowed [-fpermissive]
   66 |   template <> struct llvm::is_bitmask_enum<Enum> : std::true_type {};          \
      |                      ^~~~
/home/npopov/repos/llvm-project/llvm/include/llvm/ADT/FloatingPointMode.h:223:1: note: in expansion of macro ‘LLVM_DECLARE_ENUM_AS_BITMASK’
  223 | LLVM_DECLARE_ENUM_AS_BITMASK(FPClassTest, /* LargestValue */ fcPosInf);
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/npopov/repos/llvm-project/llvm/include/llvm/ADT/BitmaskEnum.h:67:22: error: extra qualification not allowed [-fpermissive]
   67 |   template <> struct llvm::largest_bitmask_enum_bit<Enum> {                    \
      |                      ^~~~
/home/npopov/repos/llvm-project/llvm/include/llvm/ADT/FloatingPointMode.h:223:1: note: in expansion of macro ‘LLVM_DECLARE_ENUM_AS_BITMASK’
  223 | LLVM_DECLARE_ENUM_AS_BITMASK(FPClassTest, /* LargestValue */ fcPosInf);
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
[43/4396] Building CXX object lib/Supp...iles/LLVMSupport.dir/CommandLine.cpp.o

17 months ago[Clang] Fix clang_rt tests when LLVM_ENABLE_PER_TARGET_RUNTIME_DIR is ON
Michael Platings [Thu, 9 Feb 2023 18:07:52 +0000 (18:07 +0000)]
[Clang] Fix clang_rt tests when LLVM_ENABLE_PER_TARGET_RUNTIME_DIR is ON

If clang is part of a toolchain that can locate clang_rt libraries
outside its resource directory and these are built with
LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON then the tests would fail because
the library names don't have the arch suffix. This change makes the arch
suffix optional.

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

17 months ago[NFC] Make FPClassTest a bitmask enumeration
Serge Pavlov [Wed, 22 Feb 2023 07:20:04 +0000 (14:20 +0700)]
[NFC] Make FPClassTest a bitmask enumeration

With this change bitwise operations are allowed for FPClassTest
enumeration, it must simplify using this type. Also some functions
changed to get argument of type FPClassTest instead of unsigned.

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

17 months ago[mlir][Vector] Add support for high-order masked contractions
Diego Caballero [Wed, 22 Feb 2023 06:53:37 +0000 (06:53 +0000)]
[mlir][Vector] Add support for high-order masked contractions

This patch adds support for masked vector.contract ops that needs to be
decomposed using the ContractionOpLowering pattern. It just slices the
mask according to the rest of the lowering.

Reviewed By: ThomasRaoux

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

17 months ago[mlir][Vector] Add folding for masked reductions and vector.mask
Diego Caballero [Wed, 22 Feb 2023 06:37:38 +0000 (06:37 +0000)]
[mlir][Vector] Add folding for masked reductions and vector.mask

This patch adds support for folding trivial masked reductions and
multi-reductions (e.g., multi-reductions with only parallel dims,
reductions of a single element, etc.). To support those foldings in
a composable way we also add support for folding different flavors of
empty vector.mask opertions.

Reviewed By: ThomasRaoux

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

17 months ago[mlir][linalg] Allow constant exprs in pack/unpack propagation through elementwise
Quinn Dawkins [Tue, 21 Feb 2023 01:52:49 +0000 (20:52 -0500)]
[mlir][linalg] Allow constant exprs in pack/unpack propagation through elementwise

The pack/unpack propagation patterns currently assume all map results
for non-scalar arguments are AffineDimExprs, leading to crashes when the
input operand being packed has constant expressions.

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

17 months ago[mlir][Analysis] Guard data flow analysis from no block function
Kai Sasaki [Wed, 22 Feb 2023 06:09:09 +0000 (15:09 +0900)]
[mlir][Analysis] Guard data flow analysis from no block function

Foo analysis for testing the data flow analysis does not support the region without any block. Although that analysis is assumed to be used for testing purpose, it is generally better to be explicit about the scope the framework supports.

The original issue was reported here.
https://github.com/llvm/llvm-project/issues/60580

Reviewed By: springerm

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

17 months ago[X86][NFC] Remove useless code in X86MCCodeEmitter.cpp
Shengchen Kan [Wed, 22 Feb 2023 05:59:28 +0000 (13:59 +0800)]
[X86][NFC] Remove useless code in X86MCCodeEmitter.cpp

Neither the switch in A nor the switch in B is fully covered, so we
don't need write an impossible format there.

17 months ago[CMake] Unify llvm_check_linker_flag and llvm_check_compiler_linker_flag
Petr Hosek [Wed, 1 Feb 2023 08:25:35 +0000 (08:25 +0000)]
[CMake] Unify llvm_check_linker_flag and llvm_check_compiler_linker_flag

These have the same purposes but two different implementations.
llvm_check_compiler_linker_flag uses CMAKE_REQUIRED_FLAGS which affects
flags used both for compilation and linking which is problematic because
some flags may be link-only and trigger unused argument warning when set
during compilation. llvm_check_linker_flag does not have this issue so
we chose it as the prevailaing implementation.

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

17 months ago[ORC] Add an ExecutionSession::getTargetTriple convenience function.
Lang Hames [Wed, 22 Feb 2023 03:09:34 +0000 (19:09 -0800)]
[ORC] Add an ExecutionSession::getTargetTriple convenience function.

Forwards to ExecutorProcessControl::getTargetTriple, and saves clients the
trouble of spelling 'getExecutorProcessControl()' everywhere.

17 months ago[flang] Run MathToLLVM conversion as part of math conversion PM.
Slava Zakharin [Tue, 21 Feb 2023 22:55:00 +0000 (14:55 -0800)]
[flang] Run MathToLLVM conversion as part of math conversion PM.

We used to specify benefit=0 for MathToLibm patterns so that
MathToLLVM patterns are more preferable. D144450 removed
the benefit parameter, so we have to run MathToLLVM separately now.

This resolves Intrinsics/math-codegen failure caused by D144450.

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

17 months ago[Support] Fix data race with “safe libc++”
Vitaly Buka [Wed, 22 Feb 2023 02:28:06 +0000 (18:28 -0800)]
[Support] Fix data race with “safe libc++”

Otherwise NFC.

17 months ago[ORC-RT] Remove the '__' prefix from the ORC runtime's public API.
Lang Hames [Wed, 22 Feb 2023 02:18:58 +0000 (18:18 -0800)]
[ORC-RT] Remove the '__' prefix from the ORC runtime's public API.

The '__' prefix should only be used for the parts of the ORC runtime that
implement compiler / loader runtime details (e.g. ORC-RT's __tlv_get_addr
implementations).

This patch only fixes the public API. Future changes will fix internal names.

17 months ago[NFC] Use single quotes for single char output during `printPipline`
Liren Peng [Wed, 22 Feb 2023 02:30:13 +0000 (02:30 +0000)]
[NFC] Use single quotes for single char output during `printPipline`

Reviewed By: arsenm

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

17 months ago[Clang][OpenMP] Update tests using update_cc_test_checks.py
Shilei Tian [Wed, 22 Feb 2023 02:09:20 +0000 (21:09 -0500)]
[Clang][OpenMP] Update tests using update_cc_test_checks.py

Make preparation for other patches

Reviewed By: jdoerfert

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

17 months ago[WebAssembly] Add more combine pattern for vector shift
Jun Ma [Mon, 20 Feb 2023 05:54:20 +0000 (13:54 +0800)]
[WebAssembly] Add more combine pattern for vector shift

After change with D144169, the codegen generates redundant instructions
like and and wrap. This fixes it.

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

17 months ago[mlir][Vector] Support masking for more contraction flavors
Diego Caballero [Wed, 22 Feb 2023 01:20:10 +0000 (01:20 +0000)]
[mlir][Vector] Support masking for more contraction flavors

This patch adds masking support for more contraction flavors including those
with any combiner operation (add, mul, min, max, and, or, etc.) and
regular matmul contractions.

Combiner operations that are performing vertical reductions (and,
therefore, they are not represented with a horizontal reduction
operation) can be executed unmasked. However, the previous value of
the accumulator must be propagated for lanes that shouldn't accumulate.
We achieve this goal by introducing a select operation after the
accumulator to choose between the combined and the previous accumulator
value. This design decision is made to avoid introducing masking support
to all the arithmetic and logical operations in the Arith dialect. VP
intrinsics do not support pass-thru values either so we would have to
generate the same sequence when lowering to LLVM. The op + select
pattern is peepholed by some backend with native masking support for those
operations.

Consequently, this patch removes masking support from the vector.fma
operation to follow the same approach for all the combiner operations.

Reviewed By: ThomasRaoux

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

17 months agoRevert "[Clang][OpenMP] Update tests using update_cc_test_checks.py"
Shilei Tian [Wed, 22 Feb 2023 01:28:00 +0000 (20:28 -0500)]
Revert "[Clang][OpenMP] Update tests using update_cc_test_checks.py"

This reverts commit 61faf261506f93819e48f050f318f96452831f92 as it makes buildbot unhappy.

17 months ago[PowerPC][NFC] add const-splat-array-init.ll
Ting Wang [Wed, 22 Feb 2023 01:24:12 +0000 (20:24 -0500)]
[PowerPC][NFC] add const-splat-array-init.ll

Add test case and will show combiner can improve these.

Reviewed By: lkail

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

17 months ago[X86][NFC] Refactor X86InstrArithmetic.td by class
Wang, Xin10 [Wed, 22 Feb 2023 00:41:12 +0000 (08:41 +0800)]
[X86][NFC] Refactor X86InstrArithmetic.td by class

1. Extract the common code of some instructions into a class to reduce duplication
2. Refine some comments to the make the description of the class clearer

By this way, the records defined here will be consistent and easier to
maintain, I think.

Reviewed By: skan

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

17 months ago[Clang][OpenMP] Update tests using update_cc_test_checks.py
Shilei Tian [Wed, 22 Feb 2023 01:09:09 +0000 (20:09 -0500)]
[Clang][OpenMP] Update tests using update_cc_test_checks.py

Make preparation for other patches

Reviewed By: jdoerfert

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

17 months ago[flang] Avoid linking step for failing LIT tests added in D143301.
Slava Zakharin [Wed, 22 Feb 2023 01:03:53 +0000 (17:03 -0800)]
[flang] Avoid linking step for failing LIT tests added in D143301.

17 months ago[ORC-RT][MachO] Use 'UseCallbackStyleUnwindInfo' flag, rather than re-test.
Lang Hames [Sat, 18 Feb 2023 04:28:07 +0000 (20:28 -0800)]
[ORC-RT][MachO] Use 'UseCallbackStyleUnwindInfo' flag, rather than re-test.

The UseCallbackStyleUnwindInfo flag already captures the original conditional,
and using the flag everywhere makes it easier to switch registration styles
when debugging.

17 months ago[Test] Set gitattributes for line endings in tapi inputs
Justin Bogner [Tue, 21 Feb 2023 22:37:18 +0000 (14:37 -0800)]
[Test] Set gitattributes for line endings in tapi inputs

LLVM's parsing of .tbd files errors out with "unsupported file type"
if the tbd files have CRLF line endings. Add gitattributes for the
inputs to avoid test failures on windows.

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

17 months ago[Test] Invoke GetErrcMessages from config-ix instead of llvm/CMakeLists
Justin Bogner [Tue, 21 Feb 2023 22:28:04 +0000 (14:28 -0800)]
[Test] Invoke GetErrcMessages from config-ix instead of llvm/CMakeLists

Since GetErrcMessages uses cmake's `try_run` mechanism it's sensitive
to changes to CMAKE_CXX_FLAGS, so we move it into config-ix with the
similar flag-sensitive configuration. This makes it run before
HandleLLVMOptions and avoids issues with LLVM_ENABLE_WERROR and other
configuration that manipulate CMAKE_CXX_FLAGS.

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

17 months ago[runtimes] Remove unused functions from Handle{Libcxx,Libunwind}Flags.cmake
Nikolas Klauser [Mon, 20 Feb 2023 16:12:09 +0000 (17:12 +0100)]
[runtimes] Remove unused functions from Handle{Libcxx,Libunwind}Flags.cmake

Reviewed By: phosek, #libunwind, #libc

Spies: libcxx-commits

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

17 months ago[PowerPC] Include vector bool and pixel when emitting lax warning
Maryam Moghadas [Thu, 2 Feb 2023 18:31:44 +0000 (18:31 +0000)]
[PowerPC] Include vector bool and pixel when emitting lax warning

This patch is to fix some missing lax-vector-conversion warnings including
cases that involve vector bool and vector pixel, also to fix the vector
compatibility check for the warnings.

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

17 months ago[flang] Handle unsupported warning flags
Ethan Luis McDonough [Tue, 21 Feb 2023 22:09:34 +0000 (16:09 -0600)]
[flang] Handle unsupported warning flags

This PR makes flang emit a warning when the user passes an unsupported gfortran warning flag in as a CLI arg.  This PR also checks each `-W` argument instead of just looking at the last one passed in.

Reviewed By: awarzynski

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

17 months ago[InstSimplify] enhance simplifyWithOpReplaced() to allow more 'select' removal
Sanjay Patel [Tue, 21 Feb 2023 20:03:32 +0000 (15:03 -0500)]
[InstSimplify] enhance simplifyWithOpReplaced() to allow more 'select' removal

This is a generalization of a suggestion from issue #60799
that allows removing a redundant guard of an input value
via icmp+select. It should also solve issue #60801.

This only comes into play for a select with an equality
condition where we are trying to substitute a constant into
the false arm of a select. (A 'true' select arm substitution
allows "refinement", so it is not on this code path.)

The constant must be the same in the compare and the select,
and it must be a "binop absorber" (X op C = C). That query
currently includes 'or', 'and', and 'mul', so there are tests
for all of those opcodes.

We then use "impliesPoison" on the false arm binop and the
original "Op" to be replaced to ensure that the select is not
actually blocking poison from leaking. That could be
potentially expensive as we recursively test each operand, but
it is currently limited to a depth of 2. That's enough to catch
our motivating cases, but probably nothing more complicated
(although that seems unlikely).

I don't know how to generalize a proof for Alive2 for this, but
here's a positive and negative test example to help illustrate
the subtle logic differences of poison/undef propagation:
https://alive2.llvm.org/ce/z/Sz5K-c

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

17 months ago[InstCombine] Don't fold freeze poison when it's used in shufflevector
ManuelJBrito [Tue, 21 Feb 2023 21:58:27 +0000 (21:58 +0000)]
[InstCombine] Don't fold freeze poison when it's used in shufflevector

With this patch freeze undef/poison will no longer be folded into a constant if it's used as a
vector operand in a shufflevector.

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

17 months ago[PowerPC] Fix the implicit casting for the emulated intrinsics
Maryam Moghadas [Tue, 21 Feb 2023 21:23:54 +0000 (15:23 -0600)]
[PowerPC] Fix the implicit casting for the emulated intrinsics

This patch is to fix some implicit castings for emulated intrinsics
so that there are no lax-vector-conversions errors and warnings.

Reviewed By: nemanjai, #powerpc

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

17 months ago[Flang] Add user option -funderscoring/-fnounderscoring to control trailing underscor...
Mark Danial [Tue, 21 Feb 2023 21:33:06 +0000 (16:33 -0500)]
[Flang] Add user option -funderscoring/-fnounderscoring to control trailing underscore added to external names

This patch adds user option -funderscoring/-fnounderscoring  to control the trailing underscore being appended to external names (e.g. procedure names, common block names). The option in gfortran is documented in https://gcc.gnu.org/onlinedocs/gfortran/Code-Gen-Options.html.

Reviewed By: clementval

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

17 months ago[mlir][sparse] revert optimization for dense->csc conversion.
Peiming Liu [Tue, 21 Feb 2023 21:26:46 +0000 (21:26 +0000)]
[mlir][sparse] revert optimization for dense->csc conversion.

Eliminates the sort seems make the whole conversion slower (probably because loop rotation leads to bad locality).

Reviewed By: aartbik

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

17 months ago[SLP]Do not swap not counted extractelements.
Alexey Bataev [Tue, 21 Feb 2023 18:20:41 +0000 (10:20 -0800)]
[SLP]Do not swap not counted extractelements.

No need to swap extractelements, which were not excluded from the list
during cost analysis. It leads to incorrect cost calculation and make
vector code more profitable than it is actually is.

17 months ago[libc] Introduce a libc internal assertion macro named LIBC_ASSERT.
Siva Chandra Reddy [Thu, 16 Feb 2023 01:01:33 +0000 (01:01 +0000)]
[libc] Introduce a libc internal assertion macro named LIBC_ASSERT.

Few existing call-sites have been modified to use LIBC_ASSERT.

Reviewed By: lntue, michaelrj

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

17 months ago[Hexagon] Improve selection algorithm in HvxSelector::select
Krzysztof Parzyszek [Fri, 17 Feb 2023 17:39:04 +0000 (09:39 -0800)]
[Hexagon] Improve selection algorithm in HvxSelector::select

The previous algorithm could order nodes incorrectly, this one strictly
follows the topological order.

17 months ago[SPIR-V] Emit spv_undef intrinsic for aggregate undef operands
Michal Paszkowski [Thu, 16 Feb 2023 20:23:48 +0000 (21:23 +0100)]
[SPIR-V] Emit spv_undef intrinsic for aggregate undef operands

This change adds a new spv_undef intrinsic which is emitted in place of
aggregate undef operands and later selected to single OpUndef SPIR-V
instruction. The behavior matches that of Khronos SPIR-V Translator and
should support nested aggregates.

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

17 months ago[RISCV] Minor style cleanup in lowerVECTOR_SHUFFLEAsVNSRL [nfc]
Philip Reames [Tue, 21 Feb 2023 19:57:37 +0000 (11:57 -0800)]
[RISCV] Minor style cleanup in lowerVECTOR_SHUFFLEAsVNSRL [nfc]

17 months ago[MemProf] Make hasSingleAllocType helper non-static
Teresa Johnson [Sat, 18 Feb 2023 02:44:29 +0000 (18:44 -0800)]
[MemProf] Make hasSingleAllocType helper non-static

As suggested in D140908, make the hasSingleAllocType helper non-static
so that it can be used in other files. Add unit testing.

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

17 months ago[libc][CMake] Missing TableGen include
Petr Hosek [Mon, 20 Feb 2023 23:07:09 +0000 (23:07 +0000)]
[libc][CMake] Missing TableGen include

HdrGen CMake build uses TableGen so it should include TableGen module.

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

17 months ago[Driver][FreeBSD] Fix DWARF test after 2a2c0fd96757871f4e8052624000c208cc574fdf
Brad Smith [Tue, 21 Feb 2023 19:51:18 +0000 (14:51 -0500)]
[Driver][FreeBSD] Fix DWARF test after 2a2c0fd96757871f4e8052624000c208cc574fdf

The default DWARF version without a FreeBSD version specified is 4.

17 months ago[mlir][GPUToLLVM] Add support for emitting opaque pointers
Markus Böck [Tue, 21 Feb 2023 06:51:44 +0000 (07:51 +0100)]
[mlir][GPUToLLVM] Add support for emitting opaque pointers

Part of https://discourse.llvm.org/t/rfc-switching-the-llvm-dialect-and-dialect-lowerings-to-opaque-pointers/68179

This patch adds the new pass option `use-opaque-pointers` to the GPU to LLVM lowerings (including ROCD and NVVM) and adapts the code to support using opaque pointers in addition to typed pointers.
The required changes mostly boil down to avoiding `getElementType` and specifying base types in GEP and Alloca.

In the future opaque pointers will be the only supported model, hence tests have been ported to using opaque pointers by default. Additional regression tests for typed-pointers have been added to avoid breaking existing clients.

Note: This does not yet port the `GpuToVulkan` passes.

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

17 months ago[mlir][LLVM] Don't make `LLVM_IntPtrBase` a `BuildableType` to allow the use of opaqu...
Markus Böck [Tue, 21 Feb 2023 14:29:32 +0000 (15:29 +0100)]
[mlir][LLVM] Don't make `LLVM_IntPtrBase` a `BuildableType` to allow the use of opaque pointers

Making the constraint a buildable type makes them incompatible with opaque pointers, at least while we still support typed pointers, since Ops making use of the constraint will then automatically create a typed pointer on parse.

This patch therefore fixes that issue by removing the `BuildableType` mixin. This has a bit of a cascading effect however, as all users of the constraint now need operands of that type to be added to the assembly format, hence a lot of adjustments to the syntax of a lot of (mostly intrinsic) ops.

Few things of note: The syntax as is, is only required while we're supporting both typed and opaque pointers. Once we drop support for typed pointers, we can make it a `BuildableType` again. As a drive by I also fixed the address space not being verified in the constraint. Finally, I added some roundtripping tests, most importantly for ops with `type($specific_operand)` occurences. These are printed incorrectly with typed pointers if not wrapped within a `qualified`.

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

17 months ago[PowerPC] clang-format isPPC64ELFv2ABI() function. NFC
Brad Smith [Tue, 21 Feb 2023 19:41:22 +0000 (14:41 -0500)]
[PowerPC] clang-format isPPC64ELFv2ABI() function. NFC

17 months agoReland "[ADT] Relax type requirements for `is_contained`"
Jakub Kuderski [Tue, 21 Feb 2023 19:32:01 +0000 (14:32 -0500)]
Reland "[ADT] Relax type requirements for `is_contained`"

17 months ago[flang] Make sure the length is propagated when emboxing a char to unlimited polymopr...
Valentin Clement [Tue, 21 Feb 2023 19:31:56 +0000 (20:31 +0100)]
[flang] Make sure the length is propagated when emboxing a char to unlimited polymoprhic box

When passing a character with unknown length to a subroutine expecting
an unlimited polymorphic pointer, a new descriptor is created. The
fir.embox operation needs to carry over the length from the character
to be passed correctly.

Reviewed By: PeteSteinfeld

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

17 months ago[flang] Make assignment of derived-type with allocatable polymorphic components with...
Valentin Clement [Tue, 21 Feb 2023 19:30:47 +0000 (20:30 +0100)]
[flang] Make assignment of derived-type with allocatable polymorphic components with the runtime

Derived-type assignment was already handling the case of derived-type with
allocatable components with the runtime. Extend the code so the polymorphic
allocatable component are also taken into account.

Reviewed By: PeteSteinfeld

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

17 months agoRevert "[ADT] Relax type requirements for `is_contained`"
Jakub Kuderski [Tue, 21 Feb 2023 19:30:35 +0000 (14:30 -0500)]
Revert "[ADT] Relax type requirements for `is_contained`"

This reverts commit 75272d5c1299db93aa619fc9e616832f578726c2.

This fails to compile on the clang-debian-cpp20 buildbot:
https://lab.llvm.org/buildbot#builders/249/builds/945.

17 months ago[Driver][FreeBSD] Correct driver behavior if a triple is provided without a version
Brad Smith [Tue, 21 Feb 2023 19:05:34 +0000 (14:05 -0500)]
[Driver][FreeBSD] Correct driver behavior if a triple is provided without a version

While looking at other usage of getOSMajorVersion() I noticed if a version number is not
included in the FreeBSD triple it won't include the --hash-style=both linker option or
not disable the use of .init_array. Without a version should be the latest.

FreeBSD 8 and 9 are no longer supported. So simplify things with the version handling
as well.

Reviewed By: dim

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

17 months ago[PowerPC] Use member function to determine PowerPC Secure PLT
Brad Smith [Tue, 21 Feb 2023 19:00:43 +0000 (14:00 -0500)]
[PowerPC] Use member function to determine PowerPC Secure PLT

Add a member function isPPC32SecurePlt() to determine whether Secure
PLT is used by the target 32-bit PowerPC operating environment.

Reviewed By: dim, maskray

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

17 months ago[NFC][SLP]Add a test for optimistic vectorization, NFC.
Alexey Bataev [Tue, 21 Feb 2023 18:43:52 +0000 (10:43 -0800)]
[NFC][SLP]Add a test for optimistic vectorization, NFC.

17 months ago[SelectionDAG] Migrate away from soft-deprecated functions. NFC
Fangrui Song [Tue, 21 Feb 2023 19:01:34 +0000 (11:01 -0800)]
[SelectionDAG] Migrate away from soft-deprecated functions. NFC

17 months ago[libc] Fix LIBC_GPU_ARCHITECTURES not being used
Joseph Huber [Tue, 21 Feb 2023 18:59:02 +0000 (12:59 -0600)]
[libc] Fix LIBC_GPU_ARCHITECTURES not being used

Summary:
This variable is supposed to control the architectures to build for. At
some point this was changes out for testing and never fixed.

17 months ago[mlir][linalg] Match element type of result when doing propagation of unpack through...
Quinn Dawkins [Mon, 20 Feb 2023 21:27:51 +0000 (16:27 -0500)]
[mlir][linalg] Match element type of result when doing propagation of unpack through elementwise

When propagating tensor.unpack ops through elementwise generics, a new
output tensor is needed if the element type of the input differs from
that of the output in the elementwise op.

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

17 months ago[flang] Remove parameter for libm mlir::populateMathToLibmConversionPatterns.
Alexander Belyaev [Tue, 21 Feb 2023 18:41:17 +0000 (19:41 +0100)]
[flang] Remove parameter for libm mlir::populateMathToLibmConversionPatterns.

https://reviews.llvm.org/rG8a9d4895df780231a14a1afc44e18b1f6b7eab93

17 months ago[libc++][NFC] Simplify __sort{4,5}
Nikolas Klauser [Tue, 21 Feb 2023 14:09:12 +0000 (15:09 +0100)]
[libc++][NFC] Simplify __sort{4,5}

Don't return the number of swaps; it's not used anywhere.

Reviewed By: Mordante, #libc, avogelsgesang

Spies: libcxx-commits

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

17 months ago[docs] Improve guidance on installing the correct buildbot-worker version
Alex Bradbury [Tue, 21 Feb 2023 18:38:33 +0000 (18:38 +0000)]
[docs] Improve guidance on installing the correct buildbot-worker version

The docs currently state that buildbot-worker 2.8.5 is used. However,
looking at the buildbot release notes
<http://docs.buildbot.net/current/relnotes/index.html>, this release
doesn't seem to exist (it's not on PyPI either). The document also links
to http://trac.buildbot.net/ as a source to retrieve an old version and
install it manually, but this is dead.

Instead, drop that advice and suggest pip3 install
buildbot-worker==2.8.4, as done by the Dockerfiles in
llvm-zorg/buildbot/google/docker/*.

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

17 months ago[STLExtras] Allow for non-member `begin`/`end` in `append_range`
Jakub Kuderski [Tue, 21 Feb 2023 18:23:17 +0000 (13:23 -0500)]
[STLExtras] Allow for non-member `begin`/`end` in `append_range`

This makes `append_range` useable with, C arrays and types with custom
`begin`/`end` functions.

Reviewed By: kazu

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

17 months ago[mlir] Use foldDynamicIndexList instead of canonicalizeSubViewPart.
Alexander Belyaev [Tue, 21 Feb 2023 08:16:14 +0000 (09:16 +0100)]
[mlir] Use foldDynamicIndexList instead of canonicalizeSubViewPart.

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

17 months ago[mlir] Clean-up math -> libm/llvm conversion.
Alexander Belyaev [Tue, 21 Feb 2023 07:18:45 +0000 (08:18 +0100)]
[mlir] Clean-up math -> libm/llvm conversion.

At the moment, there is an optional log1pBenefit
populateMathToLibmConversionPatterns which is used to increase the priority of
the log1p->libm pattern compared to log1p->llvm pattern that approximates
log1p with precision issues. Instead, we can have a flag for the MathToLLVM
pass to enable or disable the imprecise approximation.

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

17 months ago[ADT] Relax type requirements for `is_contained`
Jakub Kuderski [Tue, 21 Feb 2023 18:05:01 +0000 (13:05 -0500)]
[ADT] Relax type requirements for `is_contained`

- Do not require both the `Set` and `Element` to be exactly the same type and, instead, only require them to be comparable.
- Do not require `Element` to be copyable.
- Add missing documentation comment.

Reviewed By: beanz

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

17 months ago[RISCV] Extract a helper routine for computing (runtime) VLMax [nfc]
Philip Reames [Tue, 21 Feb 2023 17:55:23 +0000 (09:55 -0800)]
[RISCV] Extract a helper routine for computing (runtime) VLMax [nfc]

17 months ago[InstSimplify] add tests for simplifyWithOpReplaced(); NFC
Sanjay Patel [Tue, 21 Feb 2023 13:23:27 +0000 (08:23 -0500)]
[InstSimplify] add tests for simplifyWithOpReplaced(); NFC

issue #60799
issue #60801

17 months ago[clang]Fix warning for signed conversion on LP64
Yaxun (Sam) Liu [Tue, 14 Feb 2023 14:52:42 +0000 (09:52 -0500)]
[clang]Fix warning for signed conversion on LP64

Currently clang emits warning with -Wconversion for the following code
on LP64 system e.g. x86_64-unknown-linux-gnu:

long foo(long x) {
  return 1LL<<x;
}
warning: implicit conversion changes signedness: 'long long' to 'long' [-Wsign-conversion]

return 1ll << x;
~~~~~~ ~~~~^~~~
This does not make sense since all operands are signed.

This patch fixes that to match -m32 and GCC behaviour.

Reviewed by: Fangrui Song

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

17 months ago[IRMover] Remove UB implying parameter attributes when necessary
Tim Neumann [Tue, 21 Feb 2023 17:35:30 +0000 (18:35 +0100)]
[IRMover] Remove UB implying parameter attributes when necessary

When importing functions from some module X into some module Y, they may reference other functions already present in Y. The signature (especially attributes) of those other functions may have diverged between X and Y (e.g. due to the Dead Argument Elimination optimization). If necessary, modify the attributes to avoid UB.

See the added test and implementation comments for more details.

This was exposed by https://reviews.llvm.org/D133036 before it was reverted. Fixes https://github.com/llvm/llvm-project/issues/58976.

Reviewed By: tejohnson

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

17 months ago[libc] Add Month enum, refactor mktime_test
Jeff Bailey [Tue, 21 Feb 2023 17:20:23 +0000 (17:20 +0000)]
[libc] Add Month enum, refactor mktime_test

Introduce Month enum.

Use designated initializers instead of comments to ensure that tm_data
is initialized correctly.  Use Month enum for initializing .tm_mon to
avoid off-by-one errors.

Co-authored-by: Raman Tenneti <rtenneti@google.com>
Reviewed By: rtenneti

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

17 months ago[GlobalOpt] Add tests with non-GEP ConstExpr.
Florian Hahn [Tue, 21 Feb 2023 17:16:09 +0000 (17:16 +0000)]
[GlobalOpt] Add tests with non-GEP ConstExpr.

Extra tests for CleanupPointerRootUsers with non-GEP constant
expressions for D144468.

17 months ago[clang][docs] Document ThinLTO options for ld64.lld
Jez Ng [Tue, 21 Feb 2023 15:32:07 +0000 (10:32 -0500)]
[clang][docs] Document ThinLTO options for ld64.lld

The LTO-cache-related flags were added here: {D105922}

Reviewed By: tejohnson

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

17 months ago[NFC] Use find_last_of when seraching for code in getRawCommentForDeclNoCacheImpl
Kugan Vivekanandarajah [Tue, 21 Feb 2023 16:24:26 +0000 (16:24 +0000)]
[NFC] Use find_last_of when seraching for code in getRawCommentForDeclNoCacheImpl

ASTContext::getRawCommentForDeclNoCacheImpl in this case, extracts the text between
the comment and declaration to make sure if there are  no other declarations or preprocessor
directives between  comment or declarations.

While using Text.find_first_of or Text.find_last_of  is functionally the same,
 using Text.find_last_of terminates fast in the presence of such.

Especially in generated code with sparse comments, it takes longer
to bailout when there is code in-between. Searching from last
(with find_last_of) bails out faster.

This shows up in perf profiles with clangd in some auto-generated code.
ASTContext::getRawCommentForDeclNoCacheImpl showing as much as 18.2% in this
case. With find_last_of, this drops to 2.8%.

Reviewed By: aaron.ballman

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

17 months ago[gn build] Port b4ecfd3c4675
LLVM GN Syncbot [Tue, 21 Feb 2023 16:11:42 +0000 (16:11 +0000)]
[gn build] Port b4ecfd3c4675

17 months ago[libc++] Forward to std::memcmp for trivially comparable types in equal
Nikolas Klauser [Wed, 7 Dec 2022 17:51:28 +0000 (18:51 +0100)]
[libc++] Forward to std::memcmp for trivially comparable types in equal

Reviewed By: #libc, ldionne

Spies: ldionne, Mordante, libcxx-commits

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

17 months ago[gn build] Port e8cb3559eec0
LLVM GN Syncbot [Tue, 21 Feb 2023 16:02:37 +0000 (16:02 +0000)]
[gn build] Port e8cb3559eec0

17 months ago[Flang][OpenMP] Fix when the toplevel unit is present in declare target
Kiran Chandramohan [Tue, 21 Feb 2023 15:39:19 +0000 (15:39 +0000)]
[Flang][OpenMP] Fix when the toplevel unit is present in declare target

If the toplevel unit is present in a declare target construct, do not
try to again find the enclosing construct.
Patch also re-arranges the checks.

Reviewed By: peixin

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

17 months ago[SLP]Properly define incoming block for user PHI nodes.
Alexey Bataev [Tue, 21 Feb 2023 15:07:43 +0000 (07:07 -0800)]
[SLP]Properly define incoming block for user PHI nodes.

MainOp of the PHI vectorizable entries contains the proper order of
incoming blocks, not the last instruction in the block.

17 months ago[libc++] Move constexpr <cstring> functions into their own headers and remove unused...
Nikolas Klauser [Sat, 4 Feb 2023 23:21:11 +0000 (00:21 +0100)]
[libc++] Move constexpr <cstring> functions into their own headers and remove unused <cstring> includes

Reviewed By: ldionne, Mordante, #libc, #libc_abi

Spies: libcxx-commits

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

17 months ago[OpenMP] Update the bug report link for `libomp` assertion failures
Joseph Huber [Mon, 20 Feb 2023 20:30:17 +0000 (14:30 -0600)]
[OpenMP] Update the bug report link for `libomp` assertion failures

Currently we still print the old https://bugs.llvm.org/ bugzilla link.
We should update this to the issues pane for the LLVM github.

Reviewed By: tlwilmar

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

17 months ago[InstCombine] Add additional alloca comparison tests (NFC)
Nikita Popov [Tue, 21 Feb 2023 15:38:42 +0000 (16:38 +0100)]
[InstCombine] Add additional alloca comparison tests (NFC)

17 months ago[Flang][OpenMP] Use the ultimate symbol for allocatable check
Kiran Chandramohan [Tue, 21 Feb 2023 15:16:16 +0000 (15:16 +0000)]
[Flang][OpenMP] Use the ultimate symbol for allocatable check

Reviewed By: peixin

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

17 months ago[NFC][clang][Modules] Refine test checks by adding `:`
Mariya Podchishchaeva [Tue, 21 Feb 2023 15:07:47 +0000 (10:07 -0500)]
[NFC][clang][Modules] Refine test checks by adding `:`

The test can fail if wokring directory where the test was launched
has a `error` substring in its path.

Reviewed By: ChuanqiXu

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

17 months ago[AArch64] Add a test for loading into a zerovector. NFC
David Green [Tue, 21 Feb 2023 14:42:53 +0000 (14:42 +0000)]
[AArch64] Add a test for loading into a zerovector. NFC

17 months ago[mlir][Linalg][Transform] NFC - Replace assert by more graceful error
Nicolas Vasilache [Tue, 21 Feb 2023 14:09:21 +0000 (06:09 -0800)]
[mlir][Linalg][Transform] NFC - Replace assert by more graceful error

17 months ago[flang][OpenMP] Add parser support for order clause
Kavitha Natarajan [Tue, 24 Jan 2023 09:06:22 +0000 (14:36 +0530)]
[flang][OpenMP] Add parser support for order clause

Added parser support for OpenMP 5.0 & 5.1 feature
ORDER([order-modifier :]concurrent) clause for all
applicable and supported OpenMP directives.

Reviewed By: kiranchandramohan, abidmalikwaterloo

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

17 months ago[AMDGPU] MIR-Tests for Multiplication using KBA
Jessica Del [Mon, 20 Feb 2023 15:51:15 +0000 (16:51 +0100)]
[AMDGPU] MIR-Tests for Multiplication using KBA

These tests show inefficient behavior that will be optimized by a
later change.

By using Known Bits Analysis, we can avoid unnecessary multiplications
or additions with 0.

17 months ago[SimplifyCFG] Check if the return instruction causes undefined behavior
DianQK [Tue, 21 Feb 2023 12:25:59 +0000 (20:25 +0800)]
[SimplifyCFG] Check if the return instruction causes undefined behavior

This should fix https://github.com/rust-lang/rust/issues/107681.

Return undefined to a noundef return value is undefined.

Example:

```
define noundef i32 @test_ret_noundef(i1 %cond) {
entry:
  br i1 %cond, label %bb1, label %bb2
bb1:
  br label %bb2
bb2:
  %r = phi i32 [ undef, %entry ], [ 1, %bb1 ]
  ret i32 %r
}
```

Reviewed By: nikic

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

17 months ago[IPSCCP] Remove noundef when zapping return values
Nikita Popov [Tue, 21 Feb 2023 10:01:18 +0000 (11:01 +0100)]
[IPSCCP] Remove noundef when zapping return values

When replacing return values with undef, we should also drop the
noundef attribute (and other UB implying attributes).

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

17 months ago[NFC] Added a lit test for the arithmetic fence builtin.
Ammarguellat [Fri, 17 Feb 2023 21:52:19 +0000 (16:52 -0500)]
[NFC] Added a lit test for the arithmetic fence builtin.

17 months ago[libomptarget] Remove unused image from global data movement function
Joseph Huber [Mon, 20 Feb 2023 23:03:28 +0000 (17:03 -0600)]
[libomptarget] Remove unused image from global data movement function

This interface function does not actually need the device image type.
It's unused in the function, so it should be able to be safely removed.
The motivation for this is to facilitate downsteam porting of the
amd-stg-open RPC module into the nextgen plugin so we can delete the old
plugin entirely. For that to work we need to be able to call this
function at kernel-launch time, which doesn't have the image. Also it's
cleaner.

Reviewed By: jplehr

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

17 months ago[mlir][OpenACCToLLVM] Add pass option to emit opaque pointers
Markus Böck [Tue, 21 Feb 2023 10:05:27 +0000 (11:05 +0100)]
[mlir][OpenACCToLLVM] Add pass option to emit opaque pointers

Part of https://discourse.llvm.org/t/rfc-switching-the-llvm-dialect-and-dialect-lowerings-to-opaque-pointers/68179

This patch simply adds the pass option use-opaque-pointers to instruct the pass to use opaque-pointers instead of typed pointers during conversion.
The pass itself does not actually make use of any pointers or anything, so did not require any changes except simply setting the option in the type converter. The tests have also been converted to using opaque-pointers

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

17 months ago[GlobalOpt] Add test with large number of stores with non-null loads.
Florian Hahn [Tue, 21 Feb 2023 13:01:10 +0000 (13:01 +0000)]
[GlobalOpt] Add test with large number of stores with non-null loads.

17 months ago[Flang][OpenMP] Add convert to match the argument and result of update Op
Kiran Chandramohan [Tue, 21 Feb 2023 12:34:03 +0000 (12:34 +0000)]
[Flang][OpenMP] Add convert to match the argument and result of update Op

Fixes #60873

Reviewed By: peixin

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

17 months ago[Flang][WWW] Add link to doxygen page
Kiran Chandramohan [Tue, 21 Feb 2023 12:26:38 +0000 (12:26 +0000)]
[Flang][WWW] Add link to doxygen page

Reviewed By: PeteSteinfeld

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