platform/upstream/llvm.git
17 months ago[Verifier] Check that !nonnull metadata is empty
Nikita Popov [Fri, 20 Jan 2023 16:06:46 +0000 (17:06 +0100)]
[Verifier] Check that !nonnull metadata is empty

!nonnull expectes an empty metadata argument, so check that this
is the case in the verifier. This came up as a problem in
https://reviews.llvm.org/D141386.

This requires dropping the verifier call in the compatibility-6.0.ll
test (which is not present in any of the other bitcode compatibility
tests). The original input unfortunately used typo'd nonnull
metadata.

17 months agoDAG: Use getNegatedExpression in combineMinNumMaxNum
Matt Arsenault [Mon, 19 Dec 2022 16:30:12 +0000 (11:30 -0500)]
DAG: Use getNegatedExpression in combineMinNumMaxNum

Computing the negated RHS expression just to see if it compares equal
and throw it away feels dirty.

17 months agoDAG: Look through fneg when trying to create unsafe minnum/maxnum
Matt Arsenault [Thu, 15 Dec 2022 17:57:10 +0000 (12:57 -0500)]
DAG: Look through fneg when trying to create unsafe minnum/maxnum

This makes most sense for isFNegFree targets, but shouldn't make
things worse without it. This avoids AMDGPU test regressions in a
future patch.

For some reason APFloat::compareAbsoluteValue is private, so compute
the neg of the constants.

17 months ago[MLIR][NFC] Fix a memset in MemRefUtils.h
Shivam Gupta [Mon, 23 Jan 2023 09:45:22 +0000 (15:15 +0530)]
[MLIR][NFC] Fix a memset in MemRefUtils.h

found by PVS-Studio - https://pvs-studio.com/en/blog/posts/cpp/1003/, N10.
memset function expects to take int as the second actual argument,
but receives a pointer. Here, the first and the second argument of
the function are mixed up.

Reviewed By: ftynse

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

17 months ago[clang][DebugInfo] Don't canonicalize names in template argument list for alias templates
Michael Buch [Sat, 21 Jan 2023 02:07:24 +0000 (02:07 +0000)]
[clang][DebugInfo] Don't canonicalize names in template argument list for alias templates

**Summary**

This patch customizes the `CGDebugInfo` printing policy to stop canonicalizing
the template arugment list in `DW_AT_name` for alias templates. The motivation for
this is that we want to be able to use the `TypePrinter`s support for
omitting defaulted template arguments when emitting `DW_AT_name`.

For reference, GCC currently completely omits the template arguments
when emitting alias template DIEs.

**Testing**

* Added unit-test

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

17 months ago[clang][Interp][NFC] Rename InlineDescptor::IsMutable to IsFieldMutable
Timm Bäder [Sun, 1 Jan 2023 12:22:59 +0000 (13:22 +0100)]
[clang][Interp][NFC] Rename InlineDescptor::IsMutable to IsFieldMutable

17 months ago[Flang] fix a copy-paste error in scope.cpp
Shivam Gupta [Mon, 23 Jan 2023 09:26:59 +0000 (14:56 +0530)]
[Flang] fix a copy-paste error in scope.cpp

found by PVS-Studio.

Reviewed By: jeanPerier, klausler

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

17 months ago[clang][Interp][NFC] Add Record::getDestructor()
Timm Bäder [Thu, 5 Jan 2023 12:40:26 +0000 (13:40 +0100)]
[clang][Interp][NFC] Add Record::getDestructor()

Unused for now but will be used in later commits.

17 months ago[clang][Interp][NFC] Remove unused using alias
Timm Bäder [Wed, 21 Dec 2022 09:35:20 +0000 (10:35 +0100)]
[clang][Interp][NFC] Remove unused using alias

17 months ago[libc][NFC] Detect host CPU features using try_compile instead of try_run.
Guillaume Chatelet [Thu, 19 Jan 2023 14:02:51 +0000 (14:02 +0000)]
[libc][NFC] Detect host CPU features using try_compile instead of try_run.

This implements the same behavior as D141997 but makes sure that the same detection mechanism is used between CMake and source code.

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

17 months ago[flang] Deal with NULL() passed as actual arg to unlimited polymorphic dummy
Valentin Clement [Mon, 23 Jan 2023 08:44:12 +0000 (09:44 +0100)]
[flang] Deal with NULL() passed as actual arg to unlimited polymorphic dummy

NULL() passed as actual argument to a procedure with an optional
dummy argument is represented with `fir.box<none>` type. When the dummy
argument is polymoprhic or unlimited polymorphic, the SelectOp will complain
if the types of the two arguments are not identical. Add a conversion from
`fir.box<none>` to `fir.class<none>` in that case.
Other situations with optional will require a fir.rebox and will be done in
a follow up patch.

Reviewed By: PeteSteinfeld

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

17 months ago[LangRef] Require i8s to be naturally aligned
Jannik Silvanus [Tue, 20 Dec 2022 13:03:12 +0000 (14:03 +0100)]
[LangRef] Require i8s to be naturally aligned

It is widely assumed that i8 is naturally aligned (i8:8),
and that hence i8s can be used to access arbitrary bytes.

As discussed in https://discourse.llvm.org/t/status-of-overaligned-i8,
this patch makes this assumption explicit, by documenting it in
the LangRef, and enforcing it when parsing a data layout string.

Historically, there have been data layouts that violate this requirement,
notably the old DXIL data layout that aligns i8 to 32 bits.

A previous patch (df1a74a) enabled importing modules with invalid data layouts
using override callbacks.
Users who wish to continue importing modules with overaligned i8s (e.g. DXIL)
thus need to provide a data layout override callback that fixes the
data layout, at minimum by setting natural alignment for i8.

Any further adjustments to the module (e.g. adding padding bytes if necessary)
need to be done after module import. In the case of DXIL, this should not be
necessary, because i8 usage in DXIL is very limited and its alignment actually
does not matter, see
https://github.com/microsoft/DirectXShaderCompiler/blob/main/docs/DXIL.rst#primitive-types

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

17 months ago[Attributor] Add initial support for vectors in AAPointerInfo
Johannes Doerfert [Mon, 23 Jan 2023 07:11:55 +0000 (23:11 -0800)]
[Attributor] Add initial support for vectors in AAPointerInfo

While full support requires more work (see TODOs), this allows us to
handle vector writes with a single constant value properly. For now,
we can handle the same constant values stored to all elements if
everything is of a fixed size.

17 months ago[Attributor] Multi-range accesses can be exact
Johannes Doerfert [Mon, 23 Jan 2023 07:18:55 +0000 (23:18 -0800)]
[Attributor] Multi-range accesses can be exact

Even if we have multiple access ranges, the access can be exact. It is
not a MUST access but that is taken care of elsewhere. The tests were
wrong as they contained uninitialized memory. When the memory is
initialized it works as expected.

17 months ago[OpenMP] Identify non-aligned barriers executed in an aligned context
Johannes Doerfert [Mon, 23 Jan 2023 03:55:32 +0000 (19:55 -0800)]
[OpenMP] Identify non-aligned barriers executed in an aligned context

Even if a barrier does not enforce aligned execution, it will
effectively be like an aligned barrier if it is executed by all threads
in an aligned way. We lack control flow divergence analysis here so we
can only do (basic block) local reasoning for now.

17 months ago[gn build] Port 7458908f12da
LLVM GN Syncbot [Mon, 23 Jan 2023 04:09:18 +0000 (04:09 +0000)]
[gn build] Port 7458908f12da

17 months ago[OpenMP][FIX] Ensure not to dereference a nullptr
Johannes Doerfert [Mon, 23 Jan 2023 04:05:06 +0000 (20:05 -0800)]
[OpenMP][FIX] Ensure not to dereference a nullptr

17 months ago[libc++] Refactor clang-query checks to clang-tidy checks to get less obscure error...
Nikolas Klauser [Mon, 9 Jan 2023 02:01:26 +0000 (03:01 +0100)]
[libc++] Refactor clang-query checks to clang-tidy checks to get less obscure error messages

Also remove clang-query related code, since it's unused now.

Reviewed By: ldionne, Mordante, #libc

Spies: libcxx-commits, arichardson

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

17 months ago[libc++] Improve binary size when using __transaction
Nikolas Klauser [Thu, 8 Dec 2022 08:40:54 +0000 (09:40 +0100)]
[libc++] Improve binary size when using __transaction

__exception_guard is a no-op in -fno-exceptions mode to produce better code-gen. This means that we don't provide the strong exception guarantees. However, Clang doesn't generate cleanup code with exceptions disabled, so even if we wanted to provide the strong exception guarantees we couldn't. This is also only relevant for constructs with a stack of -fexceptions > -fno-exceptions > -fexceptions code, since the exception can't be caught where exceptions are disabled. While -fexceptions > -fno-exceptions is quite common (e.g. libc++.dylib > -fno-exceptions), having another layer with exceptions enabled seems a lot less common, especially one that tries to catch an exception through -fno-exceptions code.

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

Reviewed By: ldionne, Mordante, huixie90, #libc

Spies: EricWF, alexfh, hans, joanahalili, libcxx-commits

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

17 months ago[DAGCombine]Expand usage of CreateBuildVecShuffle to make full use of vector ops
Wang, Xin10 [Mon, 23 Jan 2023 02:37:26 +0000 (10:37 +0800)]
[DAGCombine]Expand usage of CreateBuildVecShuffle to make full use of vector ops

Now, when llc encounters the case that contains a lot of
extract_vector_elt and a BUILD_VECTOR, it will replace these to
vector_shuffle to decrease the size of code, the actions are done in
createBuildVecShuffle in DAGCombiner.cpp, but now the code cannot handle
the case that the size of source vector reg is more than twice the dest
size.

Reviewed By: pengfei

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

17 months ago[Support] Use llvm::byteswap in SwapByteOrder.h (NFC)
Kazu Hirata [Mon, 23 Jan 2023 03:14:33 +0000 (19:14 -0800)]
[Support] Use llvm::byteswap in SwapByteOrder.h (NFC)

This patch defines ByteSwap_{32,64} and getSwappedBytes with
llvm::byteswap.

It's tempting to define something like:

  template <typename T,
            typename = std::enable_if_t<std::is_integral_v<T>>>
  inline T getSwappedBytes(T C) { return llvm::byteswap(C); }

But this doesn't work.  The host compiler would issue:

  error: call to 'getSwappedBytes' is ambiguous

while compiling lldb/source/Utility/UUID.cpp.

17 months ago[OpenMP][FIX] Adjust enum size to avoid assertion after D142320
Johannes Doerfert [Mon, 23 Jan 2023 02:30:46 +0000 (18:30 -0800)]
[OpenMP][FIX] Adjust enum size to avoid assertion after D142320

17 months ago[HIP] Change default offload arch to gfx906
Yaxun (Sam) Liu [Fri, 20 Jan 2023 19:42:58 +0000 (14:42 -0500)]
[HIP] Change default offload arch to gfx906

Reviewed by: Artem Belevich

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

17 months agoARM: Add baseline test for fneg + fcmp + select combine
Matt Arsenault [Thu, 15 Dec 2022 18:33:16 +0000 (13:33 -0500)]
ARM: Add baseline test for fneg + fcmp + select combine

17 months ago[MC] Replace single-case switch with an if (NFC)
Sergei Barannikov [Mon, 23 Jan 2023 00:53:22 +0000 (03:53 +0300)]
[MC] Replace single-case switch with an if (NFC)

Same as e5f746e9 but for MasmParser.

17 months ago[AVR] Emit 'eicall' for devices with large program memory
Ben Shi [Sun, 22 Jan 2023 05:47:57 +0000 (13:47 +0800)]
[AVR] Emit 'eicall' for devices with large program memory

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

Reviewed By: aykevl

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

17 months ago[OpenMP] Merge barrier elimination into AAExecutionDomain
Johannes Doerfert [Wed, 14 Dec 2022 23:08:35 +0000 (15:08 -0800)]
[OpenMP] Merge barrier elimination into AAExecutionDomain

With this patch we track aligned barriers in AAExecutionDomain and also
delete unnecessary barriers there. This allows us to eliminate barriers
across blocks, across functions, and in the presence of complex accesses
that do not force a barrier. Further, we can use the collected
information to enable store-load forwarding in a threaded environment
(follow up patch).

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

17 months ago[MC] Replace a switch with two 'if's (NFC)
Sergei Barannikov [Mon, 23 Jan 2023 00:10:02 +0000 (03:10 +0300)]
[MC] Replace a switch with two 'if's (NFC)

This simplifies logic a bit and helps to reduce the future diff.

17 months ago[OpenMP][DeviceRTL][NFC] Use `OMPTgtExecModeFlags` from `llvm/include/llvm/Frontend...
Shilei Tian [Mon, 23 Jan 2023 00:10:46 +0000 (19:10 -0500)]
[OpenMP][DeviceRTL][NFC] Use `OMPTgtExecModeFlags` from `llvm/include/llvm/Frontend/OpenMP/OMPDeviceConstants.h`

This patch makes preparation for a series that will enable per-kernel information
used in both host and device runtime. Some variables/enums, such as `OMPTgtExecModeFlags`,
have to be shared by both of them. A new header `OMPDeviceConstants.h` is added,
containing code that will be shared by them. We will introduce more variables soon.

Reviewed By: jdoerfert

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

17 months ago[OpenMP] Guarding restrictions are required only for guarding
Johannes Doerfert [Fri, 23 Dec 2022 02:21:00 +0000 (18:21 -0800)]
[OpenMP] Guarding restrictions are required only for guarding

If we do not guard code during SPMDzation, we do not need to check
conditions for successfull guarding. That is, even if some code is
executed in different modes, it does not prevent SPMDzation if there is
no guarded code in there.

17 months ago[OpenMP][FIX] Properly update ParallelLevels tracker
Johannes Doerfert [Sun, 22 Jan 2023 23:44:30 +0000 (15:44 -0800)]
[OpenMP][FIX] Properly update ParallelLevels tracker

17 months ago[OpenMP][FIX] Use thread id not team id for masked section
Johannes Doerfert [Sat, 14 Jan 2023 03:10:46 +0000 (19:10 -0800)]
[OpenMP][FIX] Use thread id not team id for masked section

17 months ago[Support] Use llvm::bit_floor in PowerOf2Floor (NFC)
Kazu Hirata [Sun, 22 Jan 2023 22:34:43 +0000 (14:34 -0800)]
[Support] Use llvm::bit_floor in PowerOf2Floor (NFC)

17 months ago[llvm] Use llvm::bit_ceil (NFC)
Kazu Hirata [Sun, 22 Jan 2023 22:05:14 +0000 (14:05 -0800)]
[llvm] Use llvm::bit_ceil (NFC)

In both of these cases, the arguments to Log2_32_Ceil are known to be
nonzero.

17 months ago[llvm] Use llvm::bit_floor (NFC)
Kazu Hirata [Sun, 22 Jan 2023 21:41:23 +0000 (13:41 -0800)]
[llvm] Use llvm::bit_floor (NFC)

In all these cases, the arguments to Log2_32 are known to be nonzero,
so we don't have to worry about "1 << -1".

17 months ago[compiler-rt][builtins] Skip building (b)float16 support on i386-freebsd
Dimitry Andric [Sun, 16 Oct 2022 18:24:42 +0000 (20:24 +0200)]
[compiler-rt][builtins] Skip building (b)float16 support on i386-freebsd

Since bfloat16 and float16 support is not available for i386-freebsd,
the `truncdfbf2.c` and `truncsfbf2.c` builtin sources should be skipped
when targeting that platform, and `COMPILER_RT_HAS_FLOAT16` should not
be defined.

However, the CMake configuration stage runs its tests with the default
target, which normally is amd64-freebsd, so it will detect both bfloat16
and float16 support.

Move adding of the `COMPILER_RT_HAS_FLOAT16` define to the `foreach()`
loop where all the supported architectures are handled, and do not
enable it when targeting i386-freebsd.

Also remove the bfloat16 sources from the `i386_SOURCES` list, when
targeting i386-freebsd.

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

17 months agoUse llvm::popcount instead of llvm::countPopulation(NFC)
Kazu Hirata [Sun, 22 Jan 2023 20:48:51 +0000 (12:48 -0800)]
Use llvm::popcount instead of llvm::countPopulation(NFC)

17 months ago[CMake] Look up target subcomponents in LLVM_AVAILABLE_LIBS
Aaron Puchert [Sun, 22 Jan 2023 20:35:09 +0000 (21:35 +0100)]
[CMake] Look up target subcomponents in LLVM_AVAILABLE_LIBS

In an installation using the all-contained libLLVM.so, individual
components are not available as targets, so we have to look them up in
LLVM_AVAILABLE_LIBS just like llvm_map_components_to_libnames does it.
Here I don't think we need the capitalized names though because we know
the right capitalization. But I might be wrong.

This is required by dragonffi, who call llvm_map_components_to_libnames
on a list containing ${LLVM_NATIVE_ARCH}. Downstream bug report:
https://bugzilla.opensuse.org/show_bug.cgi?id=1180748.

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

17 months ago[SCEV] `getRangeRefIter()`: don't forget to recurse into casts
Roman Lebedev [Sun, 22 Jan 2023 19:25:38 +0000 (22:25 +0300)]
[SCEV] `getRangeRefIter()`: don't forget to recurse into casts

I'm not really sure the problem can be nicely exposed via a lit test,
since we don't give up on range calculation for deeply nested ranges,
but if i add an assertion that those opcodes are never encountered,
the assertion fails in a number of existing tests.

In reality, the iterative approach is still pretty partial:
1. `Seen` should not be there. We want the last instance of expression, not the first one
2. There should be a check that `getRangeRefIter()` does not self-recurse

17 months ago[NFC][SCEV] Reflow `getRangeRefIter()` into an exhaustive switch
Roman Lebedev [Sun, 22 Jan 2023 18:49:04 +0000 (21:49 +0300)]
[NFC][SCEV] Reflow `getRangeRefIter()` into an exhaustive switch

And, this shows a bug in the original code:
why do we not recurse into casts?

If i add an assertion that those opcodes are never encountered,
the assertion fails in a number of existing tests.

17 months ago[NFC][SCEV] `GetMinTrailingZerosImpl()`: deduplicate handling
Roman Lebedev [Sun, 22 Jan 2023 18:55:28 +0000 (21:55 +0300)]
[NFC][SCEV] `GetMinTrailingZerosImpl()`: deduplicate handling

`scPtrToInt` recieves same treatment as normal n-ary ops.

17 months ago[NFC][SCEV] Reflow `GetMinTrailingZerosImpl()` into an exhaustive switch
Roman Lebedev [Sun, 22 Jan 2023 18:29:07 +0000 (21:29 +0300)]
[NFC][SCEV] Reflow `GetMinTrailingZerosImpl()` into an exhaustive switch

17 months ago[Dominators] Introduce DomTreeNodeTraits to allow customization. (NFC)
Florian Hahn [Sun, 22 Jan 2023 20:22:41 +0000 (20:22 +0000)]
[Dominators] Introduce DomTreeNodeTraits to allow customization. (NFC)

This patch introduces DomTreeNodeTraits for customization. Clients can implement
DomTreeNodeTraitsCustom to provide custom ParentPtr, getEntryNode and getParent.
There's also a default specialization if DomTreeNodeTraitsCustom is not implemented,
that assume a Function-like NodeT. This is what is used for the existing DominatorTree
and MachineDominatorTree.

The main motivation for this patch is using DominatorTreeBase across all
regions of a VPlan, see D140513.

Reviewed By: kuhar

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

17 months ago[NFC] Fix "form/from" typos
Piotr Fusik [Sun, 22 Jan 2023 18:59:52 +0000 (19:59 +0100)]
[NFC] Fix "form/from" typos

Reviewed By: #libc, ldionne

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

17 months ago[Support] Use functions from bit.h (NFC)
Kazu Hirata [Sun, 22 Jan 2023 18:41:13 +0000 (10:41 -0800)]
[Support] Use functions from bit.h (NFC)

This patch makes the following replacements:

  countLeadingZeros  -> llvm::countl_zero
  countTrailingZeros -> llvm::countr_zero
  countPopulation    -> llvm::popcount

17 months ago[ADT] llvm::bit_cast - use __builtin_bit_cast if available
Simon Pilgrim [Sun, 22 Jan 2023 18:21:08 +0000 (18:21 +0000)]
[ADT] llvm::bit_cast - use __builtin_bit_cast if available

If the compiler supports __builtin_bit_cast we should try to use it instead of std::memcpy (and avoid including the cstring header).

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

17 months ago[ADT] Add llvm::byteswap to bit.h
Kazu Hirata [Sun, 22 Jan 2023 17:29:35 +0000 (09:29 -0800)]
[ADT] Add llvm::byteswap to bit.h

This patch adds C++23-style byteswap to bit.h.

The implementation and tests are largely taken from
llvm/include/llvm/Support/SwapByteOrder.h and
llvm/unittests/Support/SwapByteOrderTest.cpp, respectively.

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

17 months ago[MC][test] Fix a typo
Sergei Barannikov [Sun, 22 Jan 2023 17:07:16 +0000 (20:07 +0300)]
[MC][test] Fix a typo

17 months ago[PowerPC] Regenerate vec_absd.ll test checks
Simon Pilgrim [Sun, 22 Jan 2023 17:09:46 +0000 (17:09 +0000)]
[PowerPC] Regenerate vec_absd.ll test checks

17 months ago[DAG] visitINSERT_VECTOR_ELT - use mergeEltWithShuffle to merge inserted vector eleme...
Simon Pilgrim [Sun, 22 Jan 2023 15:41:44 +0000 (15:41 +0000)]
[DAG] visitINSERT_VECTOR_ELT - use mergeEltWithShuffle to merge inserted vector element chain into base shuffle node

This allows us to merge insert_elt(insert_elt(shuffle(x,y),extract_elt(x,c1),c2),extract_elt(y,c3),c4) style insertion chains into a new shuffle node.

I had hoped to remove mergeInsertEltWithShuffle entirely, but that case doesn't have the one use limits so we would regress in a few other cases.

Fixes the vector-shuffle-combining.ll regressions in D127115

17 months ago[Flang][NFC] fix a cpoy-paste in fold-logical.cpp
Shivam Gupta [Sun, 22 Jan 2023 16:11:19 +0000 (21:41 +0530)]
[Flang][NFC] fix a cpoy-paste in fold-logical.cpp

found by PVS-Studio.

17 months ago[NFC][SCEV] Reflow `impliesPoison()` into an exhaustive switch
Roman Lebedev [Sun, 22 Jan 2023 15:50:52 +0000 (18:50 +0300)]
[NFC][SCEV] Reflow `impliesPoison()` into an exhaustive switch

17 months ago[PVS-Studio][NFC] fix a typo in ShapeUtils.h
Shivam Gupta [Sun, 22 Jan 2023 15:54:52 +0000 (21:24 +0530)]
[PVS-Studio][NFC] fix a typo in ShapeUtils.h

17 months ago[libc++][test] Disable parts requiring locales.
Mark de Wever [Sun, 22 Jan 2023 15:49:39 +0000 (16:49 +0100)]
[libc++][test] Disable parts requiring locales.

This part should be guarded, but there are no proper guards yet.
Therefore disable the offending part. This was reported post commit in
D140653.

17 months ago[InstSimplify] (X || Y) && Y --> Y (for poison-safe logical ops)
Sanjay Patel [Sun, 22 Jan 2023 14:43:35 +0000 (09:43 -0500)]
[InstSimplify] (X || Y) && Y --> Y (for poison-safe logical ops)

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

This is the conjugate/sibling pattern suggested in post-commit
feedback for:
9444252a674df5952bb5af2b76348ae4b45

issue #60167

17 months ago[InstSimplify] add tests for poison-safe variants of (X || Y) && Y; NFC
Sanjay Patel [Sun, 22 Jan 2023 14:19:55 +0000 (09:19 -0500)]
[InstSimplify] add tests for poison-safe variants of (X || Y) && Y; NFC

17 months ago[clang][doc] Fixes formatting of a text block.
Mark de Wever [Sun, 22 Jan 2023 15:21:11 +0000 (16:21 +0100)]
[clang][doc] Fixes formatting of a text block.

17 months ago[X86] avx2-vbroadcast.ll - use X86 check prefix instead of X32
Simon Pilgrim [Sun, 22 Jan 2023 15:19:17 +0000 (15:19 +0000)]
[X86] avx2-vbroadcast.ll - use X86 check prefix instead of X32

We try to use X32 for tests on gnux32 triples

17 months ago[mlir][ods] Simplify signature of `custom` printers and parsers of Attributes and...
Markus Böck [Sun, 22 Jan 2023 15:11:27 +0000 (16:11 +0100)]
[mlir][ods] Simplify signature of `custom` printers and parsers of Attributes and Types in presence of default constructible parameters

The vast majority of parameters of C++ types used as parameters for Attributes and Types are likely to be default constructible. Nevertheless, TableGen conservatively generates code for the custom directive, expecting signatures using FailureOr<T> for all parameter types T to accomodate them possibly not being default constructible. This however reduces the ergonomics of the likely case of default constructible parameters.

This patch fixes that issue, while barely changing the generated TableGen code, by using a helper function that is used to pass any parameters into custom parser methods. If the type is default constructible, as deemed by the C++ compiler, a default constructible instance is created and passed into the parser method by reference. In all other cases it is a Noop and a FailureOr is passed as before.

Documentation was also updated to document the new behaviour.

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

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

17 months ago[X86] commute-3dnow.ll - use X86 check prefix instead of X32
Simon Pilgrim [Sun, 22 Jan 2023 14:07:20 +0000 (14:07 +0000)]
[X86] commute-3dnow.ll - use X86 check prefix instead of X32

We try to use X32 for tests on gnux32 triples

17 months ago[X86] avx-vbroadcastf128.ll - use X86 check prefix instead of X32
Simon Pilgrim [Sun, 22 Jan 2023 14:01:04 +0000 (14:01 +0000)]
[X86] avx-vbroadcastf128.ll - use X86 check prefix instead of X32

We try to use X32 for tests on gnux32 triples

17 months ago[NFC][SCEVExpander] `CmpSelCost`: use the cost of the expression, not operand
Roman Lebedev [Sun, 22 Jan 2023 14:27:17 +0000 (17:27 +0300)]
[NFC][SCEVExpander] `CmpSelCost`: use the cost of the expression, not operand

Currently, for all invocations, it's equivalent, since that is literally
how `SCEVMinMaxExpr::getType()` is defined. But for e.g. `select`,
we'll want to ask about the hand type, and not the type of the operand
that happens to be first.

17 months ago[NFC][SCEV] Reflow `computeSCEVAtScope()` into an exhaustive switch
Roman Lebedev [Sun, 22 Jan 2023 14:35:25 +0000 (17:35 +0300)]
[NFC][SCEV] Reflow `computeSCEVAtScope()` into an exhaustive switch

17 months ago[NFC][SCEV] `getRelevantLoop()`: deduplicate handling
Roman Lebedev [Sun, 22 Jan 2023 14:15:16 +0000 (17:15 +0300)]
[NFC][SCEV] `getRelevantLoop()`: deduplicate handling

17 months ago[NFC][SCEV] `getBlockDisposition()`: deduplicate handling
Roman Lebedev [Sun, 22 Jan 2023 14:08:45 +0000 (17:08 +0300)]
[NFC][SCEV] `getBlockDisposition()`: deduplicate handling

17 months ago[NFC][SCEV] `getLoopDisposition()`: deduplicate handling
Roman Lebedev [Sun, 22 Jan 2023 13:56:28 +0000 (16:56 +0300)]
[NFC][SCEV] `getLoopDisposition()`: deduplicate handling

17 months ago[NFC][SCEV] `computeSCEVAtScope()`: deduplicate handling
Roman Lebedev [Sun, 22 Jan 2023 13:32:02 +0000 (16:32 +0300)]
[NFC][SCEV] `computeSCEVAtScope()`: deduplicate handling

Casts and udiv get the exactly the same handling as n-ary,
there is no point in special-handling anything.

17 months agoAMDGPU: Copy a source modifier test for f16/v2f16
Matt Arsenault [Fri, 16 Dec 2022 03:04:36 +0000 (22:04 -0500)]
AMDGPU: Copy a source modifier test for f16/v2f16

This is essentially a modernized copy of
select-fabs-fneg-extract.ll. Stop using kernels with loads and stores,
don't use fsub for fneg, and port the examples to half.

17 months agoAMDGPU: Add modern copy of fneg combines test
Matt Arsenault [Sun, 18 Dec 2022 12:25:56 +0000 (07:25 -0500)]
AMDGPU: Add modern copy of fneg combines test

17 months ago[DAG] mergeInsertEltWithShuffle - pull out mergeEltWithShuffle helper. NFCI.
Simon Pilgrim [Sun, 22 Jan 2023 13:57:49 +0000 (13:57 +0000)]
[DAG] mergeInsertEltWithShuffle - pull out mergeEltWithShuffle helper. NFCI.

This will allow us to reuse the code to merge an extracted scalar into an updated shuffle in a future patch.

Another step towards fixing some shuffle regressions in D127115.

17 months ago[NFC][X86] Fixup typo in `blend-of-shift.ll`
Roman Lebedev [Sun, 22 Jan 2023 13:14:06 +0000 (16:14 +0300)]
[NFC][X86] Fixup typo in `blend-of-shift.ll`

17 months ago[NFC][X86] Fixup `-mattr=<>` in one runline in `elementwise-store-of-scalar-splat.ll`
Roman Lebedev [Sun, 22 Jan 2023 13:13:16 +0000 (16:13 +0300)]
[NFC][X86] Fixup `-mattr=<>` in one runline in `elementwise-store-of-scalar-splat.ll`

17 months ago[NFC] Small indentation fix in lld/ELF/Relocations.cpp
Shivam Gupta [Sun, 22 Jan 2023 13:10:58 +0000 (18:40 +0530)]
[NFC] Small indentation fix in lld/ELF/Relocations.cpp

17 months ago[SVE] Add intrinsics for integer binops that explicitly undefine the result for inact...
Paul Walker [Fri, 13 Jan 2023 12:00:11 +0000 (12:00 +0000)]
[SVE] Add intrinsics for integer binops that explicitly undefine the result for inactive lanes.

The intent is to lower the clang X form SVE builtins to these
intrinsics. The suffix _x is already in use to signify unpredicated
SVE intrinsics hence my choice to use _u to signify those intrinsics
where the result for inactive lanes is undefined.

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

17 months ago[Mips] Use MCInstrInfo::get in MipsAsmParser instead of reinventing it. NFC.
Jay Foad [Wed, 11 Jan 2023 15:34:37 +0000 (15:34 +0000)]
[Mips] Use MCInstrInfo::get in MipsAsmParser instead of reinventing it. NFC.

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

17 months ago[clang-format][NFC] Add .clang-format to clang/tools/clang-format/
Owen Pan [Sun, 22 Jan 2023 10:59:23 +0000 (02:59 -0800)]
[clang-format][NFC] Add .clang-format to clang/tools/clang-format/

And reformat ClangFormat.cpp in the directory.

17 months ago[clang-format][NFC] Set LineEnding to LF in config files
Owen Pan [Sun, 22 Jan 2023 10:37:39 +0000 (02:37 -0800)]
[clang-format][NFC] Set LineEnding to LF in config files

To prevent \r\n line endings from getting into the source files.

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

17 months ago[LoongArch] Allow %pc_lo12 relocs in JIRL's immediate operand position
WANG Xuerui [Sun, 22 Jan 2023 05:24:43 +0000 (13:24 +0800)]
[LoongArch] Allow %pc_lo12 relocs in JIRL's immediate operand position

Currently, gcc-13 will generate such assembly when `-mcmodel=medium`,
which is ostensibly a dirty hack to allow bigger offsets for extern
function calls without having to add more reloc types. This is not the
best way to accomplish the original goal, but such usages will appear
soon and we have to support it anyway.

Example:

```c
extern int foo(int);

int bar(int x) {
    return foo(x + 123);
}
```

will produce the following (simplified) assembly when compiled with
`-O2 -mcmodel=medium`:

```
    .globl  bar
    .type   bar, @function
bar:
    .cfi_startproc
    addi.w  $r4,$r4,123
    pcalau12i   $r12,%pc_hi20(foo)
    jirl    $r0,$r12,%pc_lo12(foo)
    .cfi_endproc
```

Reviewed By: SixWeining, wangleiat, MaskRay, xry111

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

17 months ago[C++20][Modules] Fix named module import diagnostics.
Iain Sandoe [Tue, 13 Dec 2022 08:45:08 +0000 (08:45 +0000)]
[C++20][Modules] Fix named module import diagnostics.

We have been incorrectly disallowing imports of named modules in the
global and private module fragments.

This addresses: https://github.com/llvm/llvm-project/issues/59688

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

17 months ago[bazel] Add missing dependencies for 4f1e244eb5
Benjamin Kramer [Sun, 22 Jan 2023 09:58:47 +0000 (10:58 +0100)]
[bazel] Add missing dependencies for 4f1e244eb5

17 months ago[OpenMP] Simplify `llvm.assume` operands in device code
Johannes Doerfert [Sun, 22 Jan 2023 09:27:41 +0000 (01:27 -0800)]
[OpenMP] Simplify `llvm.assume` operands in device code

17 months ago[Attributor] Handle constant icmp expressions in AAPotentialValues
Johannes Doerfert [Sun, 22 Jan 2023 09:13:24 +0000 (01:13 -0800)]
[Attributor] Handle constant icmp expressions in AAPotentialValues

A `ConstantExpr` ICmp is pretty much the same thing as an ICmpInst when
we want to simplify it. We just need to be less restrictive wrt. the
type and use the static helper functions directly.

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

17 months ago[clang][Interp][NFCI] Make InitMap::isInitialized() const
Timm Bäder [Sat, 21 Jan 2023 18:48:37 +0000 (19:48 +0100)]
[clang][Interp][NFCI] Make InitMap::isInitialized() const

17 months ago[clang][Interp][NFC] Forward-declare Boolean in PrimTypes.h
Timm Bäder [Sat, 21 Jan 2023 18:32:02 +0000 (19:32 +0100)]
[clang][Interp][NFC] Forward-declare Boolean in PrimTypes.h

We don't need the full header file here.

17 months ago[clang][Interp][NFC] Fix header comment file name
Timm Bäder [Sat, 21 Jan 2023 16:25:57 +0000 (17:25 +0100)]
[clang][Interp][NFC] Fix header comment file name

17 months agoTransform ctpop(Pow2) -> icmp ne Pow2, 0
Noah Goldstein [Sun, 22 Jan 2023 06:00:14 +0000 (22:00 -0800)]
Transform ctpop(Pow2) -> icmp ne Pow2, 0

This makes folding to 0/1 later on easier and regardless `icmp ne` is
'probably' faster on most targets (especially for vectors).

Reviewed By: nikic

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

17 months agoAdd tests for ctpop(Pow2); NFC
Noah Goldstein [Sun, 22 Jan 2023 05:59:58 +0000 (21:59 -0800)]
Add tests for ctpop(Pow2); NFC

Reviewed By: nikic

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

17 months ago[libc++] Rename take_while_view::__sentinel to __take_while_view_sentinel
Nikolas Klauser [Sat, 21 Jan 2023 07:34:47 +0000 (08:34 +0100)]
[libc++] Rename take_while_view::__sentinel to __take_while_view_sentinel

This makes it easier to specialize traits classes, like __segmented_iterator_traits.

Reviewed By: var-const, #libc

Spies: libcxx-commits

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

17 months ago[BPF][Clang] Fix func argument pattern in bpf-stack-protector test
Yonghong Song [Sun, 22 Jan 2023 06:24:22 +0000 (22:24 -0800)]
[BPF][Clang] Fix func argument pattern in bpf-stack-protector test

Commit 56b038f887f3("[BPF][clang] Ignore stack protector options for BPF
target") added a test for its corresponding functionality.
Douglas Yung found that the test will fail with the release build
buildbot due to different func argument patterns (from %msg
to %0). This patch fixed the issue by using pattern [0-9a-z]+
which allows both %msg and %0.

17 months ago[OpenMP] Try to fix Flang after new clause was added
Johannes Doerfert [Sun, 22 Jan 2023 04:24:43 +0000 (20:24 -0800)]
[OpenMP] Try to fix Flang after new clause was added

17 months ago[OpenMP][FIX] Split test into amdgpu and nvptx specific ones
Johannes Doerfert [Sun, 22 Jan 2023 03:54:35 +0000 (19:54 -0800)]
[OpenMP][FIX] Split test into amdgpu and nvptx specific ones

This avoids running the test for the host.

17 months ago[OpenMP][FIX] Add default clause to switch
Johannes Doerfert [Sun, 22 Jan 2023 03:50:22 +0000 (19:50 -0800)]
[OpenMP][FIX] Add default clause to switch

17 months ago[OpenMP] Introduce the `ompx_dyn_cgroup_mem(<N>)` clause
Johannes Doerfert [Sun, 8 Jan 2023 00:14:48 +0000 (16:14 -0800)]
[OpenMP] Introduce the `ompx_dyn_cgroup_mem(<N>)` clause

Dynamic memory allows users to allocate fast shared memory when a kernel
is launched. We support a single size for all kernels via the
`LIBOMPTARGET_SHARED_MEMORY_SIZE` environment variable but now we can
control it per kernel invocation, hence allow computed values.

Note: Only the nextgen plugins will allocate memory based on the clause,
      the old plugins will silently miscompile.

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

17 months agoAdd the test dialect as dependent for the "test-legalize-patterns" test pass
Mehdi Amini [Sun, 22 Jan 2023 02:39:49 +0000 (02:39 +0000)]
Add the test dialect as dependent for the "test-legalize-patterns" test pass

Fixes #60183

17 months agoAdd missing dependent dialects to "convert-gpu-to-rocdl"
Mehdi Amini [Sun, 22 Jan 2023 02:26:34 +0000 (02:26 +0000)]
Add missing dependent dialects to "convert-gpu-to-rocdl"

Fixes #60198

17 months ago[NFC][SCEV] `CompareSCEVComplexity`: deduplicate handling
Roman Lebedev [Sun, 22 Jan 2023 01:45:38 +0000 (04:45 +0300)]
[NFC][SCEV] `CompareSCEVComplexity`: deduplicate handling

For all but unknown/constant/recurrences, the handling is identical,
there is no point in special-casing anything.

17 months ago[NFC][SCEV] `SCEVTraversal::visitAll()`: deduplicate handling
Roman Lebedev [Sun, 22 Jan 2023 01:12:11 +0000 (04:12 +0300)]
[NFC][SCEV] `SCEVTraversal::visitAll()`: deduplicate handling

They don't not do anything different from what we do for n-ary expressions,
there is no point in special-casing them.

17 months ago[NFC][SCEV] `createNodeForSelectOrPHIInstWithICmpInstCond()`: directly take `Type...
Roman Lebedev [Sun, 22 Jan 2023 01:09:39 +0000 (04:09 +0300)]
[NFC][SCEV] `createNodeForSelectOrPHIInstWithICmpInstCond()`: directly take `Type`, not `Instruction`

We don't use the `Instruction` itself, only it's type anyways.

17 months ago[NFC][SCEV] `createNodeForSelectOrPHIInstWithICmpInstCond()`: return optional
Roman Lebedev [Sun, 22 Jan 2023 01:07:26 +0000 (04:07 +0300)]
[NFC][SCEV] `createNodeForSelectOrPHIInstWithICmpInstCond()`: return optional

We only want about the result if it succeeds, and don't want `SCEVUnknown`.

17 months agoRemove trailing whitespace from comment
Noah Goldstein [Sat, 21 Jan 2023 19:33:38 +0000 (11:33 -0800)]
Remove trailing whitespace from comment

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