platform/upstream/llvm.git
2 years ago[mlir][bufferize] Support fully dynamic layout maps in BufferResultsToOutParams
Matthias Springer [Mon, 23 May 2022 16:37:26 +0000 (18:37 +0200)]
[mlir][bufferize] Support fully dynamic layout maps in BufferResultsToOutParams

Also fixes integration of the pass into One-Shot Bufferize and adds additional test cases.

BufferResultsToOutParams can be used with "identity-layout-map" and "fully-dynamic-layout-map". "infer-layout-map" is not supported.

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

2 years ago[lldb] Fix should_skip_simulator_test decorator
Jonas Devlieghere [Mon, 23 May 2022 16:07:54 +0000 (09:07 -0700)]
[lldb] Fix should_skip_simulator_test decorator

Currently simulator tests get skipped when the reported platform is
macosx rather than darwin. Update the decorator to match both.

2 years ago[mlir][bufferization] Fix Python bindings
Matthias Springer [Mon, 23 May 2022 16:10:12 +0000 (18:10 +0200)]
[mlir][bufferization] Fix Python bindings

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

2 years ago[clang] Module global init mangling
Nathan Sidwell [Tue, 22 Mar 2022 17:49:08 +0000 (10:49 -0700)]
[clang] Module global init mangling

C++20 modules require emission of an initializer function, which is
called by importers of the module.  This implements the mangling for
that function.  It is the one place the ABI exposes partition names in
symbols -- but fortunately only needed by other TUs of that same module.

Reviewed By: bruno

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

2 years agoNFC: Silence two warnings for unused bufferization symbols in release mode.
Stella Laurenzo [Sun, 22 May 2022 04:30:01 +0000 (21:30 -0700)]
NFC: Silence two warnings for unused bufferization symbols in release mode.

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

2 years ago[clang-tidy] Improve add_new_check.py to recognize more checks
Richard [Fri, 20 May 2022 23:19:11 +0000 (17:19 -0600)]
[clang-tidy] Improve add_new_check.py to recognize more checks

When looking for whether or not a check provides fixits, the script
examines the implementation of the check.  Some checks are not
implemented in source files that correspond one-to-one with the check
name, e.g. cert-dcl21-cpp.  So if we can't find the check implementation
directly from the check name, open up the corresponding module file and
look for the class name that is registered with the check.  Then consult
the file corresponding to the class name.

Some checks are derived from a base class that implements fixits.  So if
we can't find fixits in the implementation file for a check, scrape out
the name of it's base class.  If it's not ClangTidyCheck, then consult
the base class implementation to look for fixit support.

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

Fixes #55630

2 years ago[InstCombine] Change operand order in recursive and/or of icmps fold
Nikita Popov [Mon, 23 May 2022 15:29:33 +0000 (17:29 +0200)]
[InstCombine] Change operand order in recursive and/or of icmps fold

The order obviously doesn't matter for bitwise and/or, but would
matter for logical and/or, so change it to preserve the original
order.

2 years ago[InstCombine] Add tests for recursive and/or of icmp folds (NFC)
Nikita Popov [Mon, 23 May 2022 15:24:19 +0000 (17:24 +0200)]
[InstCombine] Add tests for recursive and/or of icmp folds (NFC)

Add variations with bitwise and logical and/or, as well as
commuted operands.

2 years agoRevert "Revert "[AArch64] Set maximum VF with shouldMaximizeVectorBandwidth""
Jingu Kang [Mon, 23 May 2022 11:33:48 +0000 (12:33 +0100)]
Revert "Revert "[AArch64] Set maximum VF with shouldMaximizeVectorBandwidth""

This reverts commit 42ebfa8269470e6b1fe2de996d3f1db6d142e16a.

The commmit from https://reviews.llvm.org/D125918 has fixed the stage 2 build
failure.

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

2 years ago[mlir][bufferization][NFC] Improve assembly format of AllocTensorOp
Matthias Springer [Mon, 23 May 2022 14:53:17 +0000 (16:53 +0200)]
[mlir][bufferization][NFC] Improve assembly format of AllocTensorOp

No longer pass static dim sizes as an attribute. This was redundant and required extra checks in the verifier. This change also makes the op symmetrical to memref::AllocOp.

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

2 years ago[NFC][flang] Change the OpenMP atomic read/write test cases
PeixinQiao [Mon, 23 May 2022 14:50:06 +0000 (22:50 +0800)]
[NFC][flang] Change the OpenMP atomic read/write test cases

Remove the integration tests and rename the file.

Reviewed By: shraiysh, NimishMishra

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

2 years ago[mlir] Add Expm1 tp ComplexOps.td.
Alexander Belyaev [Mon, 23 May 2022 14:29:02 +0000 (16:29 +0200)]
[mlir] Add Expm1 tp ComplexOps.td.

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

2 years ago[TableGen] Remove an untrue statement from the docs
Jay Foad [Mon, 23 May 2022 14:18:34 +0000 (15:18 +0100)]
[TableGen] Remove an untrue statement from the docs

You can't use foreach in a record body. This was a mistake in the
documentation dating from when it was first written in D85838.

2 years ago[mlir] Add RSqrt tp ComplexOps.td.
Alexander Belyaev [Mon, 23 May 2022 14:10:20 +0000 (16:10 +0200)]
[mlir] Add RSqrt tp ComplexOps.td.

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

2 years ago[SLP]Do not emit extract elements for insertelements users, replace with shuffles...
Alexey Bataev [Wed, 4 Aug 2021 17:58:37 +0000 (10:58 -0700)]
[SLP]Do not emit extract elements for insertelements users, replace with shuffles directly.

SLP vectorizer emits extracts for externally used vectorized scalars and
estimates the cost for each such extract. But in many cases these
scalars are input for insertelement instructions, forming buildvector,
and instead of extractelement/insertelement pair we can emit/cost
estimate shuffle(s) cost and generate series of shuffles, which can be
further optimized.

Tested using test-suite (+SPEC2017), the tests passed, SLP was able to
generate/vectorize more instructions in many cases and it allowed to reduce
number of re-vectorization attempts (where we could try to vectorize
buildector insertelements again and again).

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

2 years ago[MSVC, ARM64] Add __writex18 intrinsics
Stephen Long [Mon, 23 May 2022 14:00:54 +0000 (07:00 -0700)]
[MSVC, ARM64] Add __writex18 intrinsics

https://docs.microsoft.com/en-us/cpp/intrinsics/arm64-intrinsics?view=msvc-170

  void __writex18byte(unsigned long, unsigned char)
  void __writex18word(unsigned long, unsigned short)
  void __writex18dword(unsigned long, unsigned long)
  void __writex18qword(unsigned long, unsigned __int64)

Given the lack of documentation of the intrinsics, we chose to align the offset with just
`CharUnits::One()` when calling `IRBuilderBase::CreateAlignedStore()`.

Reviewed By: efriedma

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

2 years ago[InstCombine] fold icmp of zext bool based on limited range
Sanjay Patel [Mon, 23 May 2022 13:26:43 +0000 (09:26 -0400)]
[InstCombine] fold icmp of zext bool based on limited range

X <u (zext i1 Y) --> (X == 0) && Y

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

This is a generalization of 4069cccf3b4ff4a based on the post-commit suggestion.
This also adds the i1 type check and tests that were missing from the earlier
attempt; that commit caused several bot fails and was reverted.

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

2 years ago[InstCombine] add tests for icmp of zext i1; NFC
Sanjay Patel [Sun, 22 May 2022 17:16:19 +0000 (13:16 -0400)]
[InstCombine] add tests for icmp of zext i1; NFC

2 years ago[SLP][NFC]Add a test for extracting scalar from undef result vector,
Alexey Bataev [Mon, 23 May 2022 13:43:02 +0000 (06:43 -0700)]
[SLP][NFC]Add a test for extracting scalar from undef result vector,
NFC.

2 years ago[InstCombine] Reuse icmp of and/or folds for logical and/or
Nikita Popov [Mon, 23 May 2022 13:12:15 +0000 (15:12 +0200)]
[InstCombine] Reuse icmp of and/or folds for logical and/or

Similarly to a change recently done for fcmps, add a flag that
indicates whether the and/or is logical to foldAndOrOfICmps, and
reuse the function when folding logical and/or.

We were already calling some parts of it, but this gives us a
clearer indication of which parts may need poison-safe variants,
and would also allow to fold combinations of bitwise and logical
and/or.

This change should be close to NFC, because all folds this enables
were either already called previously, or can make use of implied
poison reasoning.

2 years ago[SPIR-V] Allow setting SPIR-V version via target triple.
Anastasia Stulova [Mon, 23 May 2022 13:03:54 +0000 (14:03 +0100)]
[SPIR-V] Allow setting SPIR-V version via target triple.

Currently added versions are from v1.0 to v1.5, other versions
can be added as needed.

This change also adds documentation about SPIR-V target support
in LLVM.

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

2 years agoRevert "[clang][driver] Dynamically select gcc-toolset/devtoolset version"
Timm Bäder [Mon, 23 May 2022 13:22:27 +0000 (15:22 +0200)]
Revert "[clang][driver] Dynamically select gcc-toolset/devtoolset version"

This reverts commit 8717b492dfcd12d6387543a2f8322e0cf9059982.

The new unittest fails on Windows buildbots, e.g.
https://lab.llvm.org/buildbot/#/builders/119/builds/8647

2 years ago[AMDGPU][MC][GFX940] Disable v_mac_f32_dpp
Dmitry Preobrazhensky [Mon, 23 May 2022 12:48:47 +0000 (15:48 +0300)]
[AMDGPU][MC][GFX940] Disable v_mac_f32_dpp

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

2 years agoAdd support of the next Ubuntu (Ubuntu 22.10 - Kinetic Kudu)
Sylvestre Ledru [Mon, 23 May 2022 11:49:34 +0000 (13:49 +0200)]
Add support of the next Ubuntu (Ubuntu 22.10 - Kinetic Kudu)

2 years agoAdd support of the next Debian (Debian 13 - Trixie)
Sylvestre Ledru [Mon, 23 May 2022 11:47:13 +0000 (13:47 +0200)]
Add support of the next Debian (Debian 13 - Trixie)

2 years ago[AMDGPU] Remove unneeded regex escaping in FileCheck patterns
Jay Foad [Mon, 23 May 2022 11:04:43 +0000 (12:04 +0100)]
[AMDGPU] Remove unneeded regex escaping in FileCheck patterns

These must have crept in since D117298 was landed.

2 years agoTest stackmap support for i128
Edd Barrett [Mon, 23 May 2022 10:18:30 +0000 (11:18 +0100)]
Test stackmap support for i128

This diff adds tests that check the currently-working stackmap cases for i128.
This will help ensure no regressions are later introduced by D125680 (when
ready).

Note that i128 stackmap support is currently incomplete, so we cant test all
i128 functionality:

    i128 constants >= 2^{63} crash LLVM
    non-constant i128s crash LLVM

So this change tests only constant i128 operands of value < 2^{63}.

A couple of incorrect comments are also fixed.

2 years ago[AArch64] Regenerate andandshift.ll test checks
Simon Pilgrim [Mon, 23 May 2022 10:48:24 +0000 (11:48 +0100)]
[AArch64] Regenerate andandshift.ll test checks

2 years ago[clang][driver] Dynamically select gcc-toolset/devtoolset version
Timm Bäder [Wed, 18 May 2022 08:31:41 +0000 (10:31 +0200)]
[clang][driver] Dynamically select gcc-toolset/devtoolset version

And pick the highest one, instead of adding all possibilities to the
prefixes.

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

2 years ago[RISCV][NFC] Test cases for fmuladd intrinsic
LiaoChunyu [Mon, 23 May 2022 00:59:41 +0000 (08:59 +0800)]
[RISCV][NFC] Test cases for fmuladd intrinsic

These test cases are copy from fma

Reviewed By: reames

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

2 years ago[CGP] Freeze condition when despeculating ctlz/cttz
Nikita Popov [Wed, 18 May 2022 13:34:12 +0000 (15:34 +0200)]
[CGP] Freeze condition when despeculating ctlz/cttz

Freeze the condition of the newly introduced conditional branch,
to avoid immediate undefined behavior if the input to ctlz/cttz
was originally poison.

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

2 years ago[AArch64] Order STP Q's by ascending address
Andre Vieira [Mon, 23 May 2022 08:43:39 +0000 (09:43 +0100)]
[AArch64] Order STP Q's by ascending address

This patch adds an AArch64 specific PostRA MachineScheduler to try to schedule
STP Q's to the same base-address in ascending order of offsets. We have found
this to improve performance on Neoverse N1 and should not hurt other AArch64
cores.

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

2 years ago[AArch64] implement isReassocProfitable, disable for (u|s)mlal.
Florian Hahn [Mon, 23 May 2022 08:39:00 +0000 (09:39 +0100)]
[AArch64] implement isReassocProfitable, disable for (u|s)mlal.

Currently reassociating add expressions can lead to failing to select
(u|s)mlal. Implement isReassocProfitable to skip reassociating
expressions that can be lowered to (u|s)mlal.

The same issue exists for the *mlsl variants as well, but the DAG
combiner doesn't use the isReassocProfitable hook before reassociating.
To be fixed in a follow-up commit as this requires DAGCombiner changes
as well.

Reviewed By: dmgreen

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

2 years agoRevert "[C++20] [Coroutines] Conform the updates for CWG issue 2585"
Chuanqi Xu [Mon, 23 May 2022 08:21:42 +0000 (16:21 +0800)]
Revert "[C++20] [Coroutines] Conform the updates for CWG issue 2585"

This reverts commit 1b89a25a9b960886e486eb20b755634613c088f8.

The test would fail in windows versions.

2 years ago[LV] Improve register pressure estimate at high VFs
Peter Waller [Mon, 16 May 2022 20:59:17 +0000 (20:59 +0000)]
[LV] Improve register pressure estimate at high VFs

Previously, `getRegUsageForType` was implemented using
`getTypeLegalizationCost`.  `getRegUsageForType` is used by the loop
vectorizer to estimate the register pressure caused by using a vector
type.  However, `getTypeLegalizationCost` currently only appears to
understand splitting and not scalarization, so significantly
underestimates the register requirements.

Instead, use `getNumRegisters`, which understands when scalarization
can occur (via computeRegisterProperties).

This was discovered while investigating D118979 (Set maximum VF with
shouldMaximizeVectorBandwidth), where under fixed-length 512-bit SVE the
loop vectorizer previously ends up costing an v128i1 as 2 v64i*
registers where it actually occupies 128 i32 registers.

I'm sending this patch early for comment, I'm still doing some sanity checking
with LNT.  I note that getRegisterClassForType appears to return VectorRC even
though the type in question (large vNi1 types) end up occupying scalar
registers. That might be worth fixing too.

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

2 years ago[AArch64] Fix assumptions on input type of tryCombineFixedPointConvert
David Green [Mon, 23 May 2022 07:55:54 +0000 (08:55 +0100)]
[AArch64] Fix assumptions on input type of tryCombineFixedPointConvert

It is possible for the input type to not be v2i64 or v4i32, so weaken
the assertion to a return, fixing the crash in the new test.

Fixes #55606

2 years ago[C++20] [Coroutines] Conform the updates for CWG issue 2585
Chuanqi Xu [Mon, 23 May 2022 07:23:00 +0000 (15:23 +0800)]
[C++20] [Coroutines] Conform the updates for CWG issue 2585

According to the updates in CWG issue 2585
https://cplusplus.github.io/CWG/issues/2585.html, we shouldn't find an
allocation function with (size, p0, …, pn) in global scope.

2 years ago[Support] Add missing <cstdint> header to Base64.h
Sergei Trofimovich [Mon, 23 May 2022 07:39:48 +0000 (08:39 +0100)]
[Support] Add missing <cstdint> header to Base64.h

Without the change llvm build fails on this week's gcc-13 snapshot as:

    [ 91%] Building CXX object unittests/Support/CMakeFiles/SupportTests.dir/Base64Test.cpp.o
    In file included from llvm/unittests/Support/Base64Test.cpp:14:
    llvm/include/llvm/Support/Base64.h: In function 'std::string llvm::encodeBase64(const InputBytes&)':
    llvm/include/llvm/Support/Base64.h:29:5: error: 'uint32_t' was not declared in this scope
       29 |     uint32_t x = ((unsigned char)Bytes[i] << 16) |
          |     ^~~~~~~~

2 years ago[Support] Add missing <cstdint> header to Signals.h
Sergei Trofimovich [Mon, 23 May 2022 07:03:23 +0000 (08:03 +0100)]
[Support] Add missing <cstdint> header to Signals.h

Without the change llvm build fails on this week's gcc-13 snapshot as:

    [  0%] Building CXX object lib/Support/CMakeFiles/LLVMSupport.dir/Signals.cpp.o
    In file included from llvm/lib/Support/Signals.cpp:14:
    llvm/include/llvm/Support/Signals.h:119:8: error: variable or field 'CleanupOnSignal' declared void
      119 |   void CleanupOnSignal(uintptr_t Context);
          |        ^~~~~~~~~~~~~~~

2 years ago[analyzer][NFC] Factor out the copy-paste code repetition of assumeDual and assumeInc...
Gabor Marton [Thu, 19 May 2022 09:14:56 +0000 (11:14 +0200)]
[analyzer][NFC] Factor out the copy-paste code repetition of assumeDual and assumeInclusiveRangeDual

Depends on D125892. There might be efficiency and performance
implications by using a lambda. Thus, I am going to conduct measurements
to see if there is any noticeable impact.
I've been thinking about two more alternatives:
1) Make `assumeDualImpl` a variadic template and (perfect) forward the
   arguments for the used `assume` function.
2) Use a macros.
I have concerns though, whether these alternatives would deteriorate the
readability of the code.

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

2 years ago[analyzer] Implement assumeInclusiveRange in terms of assumeInclusiveRangeDual
Gabor Marton [Thu, 19 May 2022 09:05:24 +0000 (11:05 +0200)]
[analyzer] Implement assumeInclusiveRange in terms of assumeInclusiveRangeDual

Depends on D124758. This is the very same thing we have done for
assumeDual, but this time we do it for assumeInclusiveRange. This patch
is basically a no-brainer copy of that previous patch.

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

2 years agoRevert "[lldb] Consider binary as module of last resort"
Muhammad Omair Javaid [Mon, 23 May 2022 06:17:24 +0000 (11:17 +0500)]
Revert "[lldb] Consider binary as module of last resort"

This reverts commit a3c3482ceb529206b0ae4e7782e5496da5e0879d.
It broke LLDB API test TestBadAddressBreakpoints.py

Differential revision: https://reviews.llvm.org/D124731

2 years ago[InstCombine] add tests for bitcast; NFC
Chenbing Zheng [Mon, 23 May 2022 06:17:01 +0000 (14:17 +0800)]
[InstCombine] add tests for bitcast; NFC

2 years ago[Sparc] Have test use IAS
Brad Smith [Mon, 23 May 2022 05:21:06 +0000 (01:21 -0400)]
[Sparc] Have test use IAS

2 years ago[mlir][tblgen][ods][python] Use keyword-only arguments for optional builder arguments...
Jeremy Furtek [Sun, 22 May 2022 04:12:11 +0000 (21:12 -0700)]
[mlir][tblgen][ods][python] Use keyword-only arguments for optional builder arguments in generated Python bindings

This diff modifies `mlir-tblgen` to generate Python Operation class `__init__()`
functions that use Python keyword-only arguments.

Previously, all `__init__()` function arguments were positional. Python code to
create MLIR Operations was required to provide values for ALL builder arguments,
including optional arguments (attributes and operands). Callers that did not
provide, for example, an optional attribute would be forced to provide `None`
as an argument for EACH optional attribute. Proposed changes in this diff use
`tblgen` record information (as provided by ODS) to generate keyword arguments
for:
- optional operands
- optional attributes (which includes unit attributes)
- default-valued attributes

These `__init__()` function keyword arguments have default `None` values (i.e.
the argument form is `optionalAttr=None`), allowing callers to create Operations
more easily.

Note that since optional arguments become keyword-only arguments (since they are
placed after the bare `*` argument), this diff will require ALL optional
operands and attributes to be provided using explicit keyword syntax. This may,
in the short term, break any out-of-tree Python code that provided values via
positional arguments. However, in the long term, it seems that requiring
keywords for optional arguments will be more robust to operation changes that
add arguments.

Tests were modified to reflect the updated Operation builder calling convention.

This diff partially addresses the requests made in the github issue below.

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

Reviewed By: stellaraccident, mikeurbach

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

2 years ago[CSKY] Fix the conflict of default fpu features and -mfpu option
Zi Xuan Wu (Zeson) [Fri, 20 May 2022 07:11:43 +0000 (15:11 +0800)]
[CSKY] Fix the conflict of default fpu features and -mfpu option

The arch or cpu has its default fpu features and versions such as fpuv2_sf/fpuv3_sf.
And there is also -mfpu option to specify and override fpu version and features.
For example, C860 has fpuv3_sf/fpuv3_df feature as default, when
-mfpu=fpv2 is given, fpuv3_sf/fpuv3_df is replaced with fpuv2_sf/fpuv2_df.

2 years ago[mlir][NFC] Replace some nested if with logical and.
jacquesguan [Fri, 20 May 2022 08:48:52 +0000 (08:48 +0000)]
[mlir][NFC] Replace some nested if with logical and.

This patch replaces some nested if statement with logical and to reduce the nesting depth.

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

2 years ago[SelectionDAG] Add a freeze to ISD::ABS expansion.
Craig Topper [Sun, 22 May 2022 21:13:30 +0000 (14:13 -0700)]
[SelectionDAG] Add a freeze to ISD::ABS expansion.

I had initially assumed this was the problem with
https://github.com/llvm/llvm-project/issues/55271#issuecomment-1133426243

But it turns out that was a simpler issue. This patch is still
more correct than what we were doing before so figured I'd submit
it anyway.

No test case because I'm not sure how to get an undef around
until expansion.

Looking at the test deltas I wonder if it be valid to combine
(sext_inreg (freeze (aextload X))) -> (freeze (sextload X)).

Reviewed By: efriedma

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

2 years ago[SelectionDAG] Fold abs(undef) to 0 instead of undef.
Craig Topper [Sun, 22 May 2022 19:47:27 +0000 (12:47 -0700)]
[SelectionDAG] Fold abs(undef) to 0 instead of undef.

abs should only produce a positive value or the signed minimum
value. This means we can't fold abs(undef) to undef as that would
allow more values. Fold to 0 instead to match InstSimplify.

Fixes test mentioned in comment on pr55271.

Reviewed By: nikic

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

2 years ago[LV] Add check line to test interleaving only with induction cast.
Florian Hahn [Sun, 22 May 2022 19:11:47 +0000 (20:11 +0100)]
[LV] Add check line to test interleaving only with induction cast.

Also simplify the value names a bit in the test.

2 years agoTest more C DR conformance (part two of many)
Aaron Ballman [Sun, 22 May 2022 17:36:10 +0000 (13:36 -0400)]
Test more C DR conformance (part two of many)

This continues the work started earlier at filling our the C DR status
page based on test coverage.

2 years ago[LV] Use exiting block instead of latch in addUsersInExitBlock.
Florian Hahn [Sun, 22 May 2022 17:27:41 +0000 (18:27 +0100)]
[LV] Use exiting block instead of latch in addUsersInExitBlock.

The latch may not be the exiting block. Use the exiting block instead
when looking up the incoming value of the LCSSA phi node. This fixes a
crash with early-exit loops.

2 years ago[LV] Re-generate check lines for loop-form.ll test.
Florian Hahn [Sun, 22 May 2022 17:20:33 +0000 (18:20 +0100)]
[LV] Re-generate check lines for loop-form.ll test.

2 years agoADT::GenericCycleInfo: Hide validateTree() in -Asserts.
NAKAMURA Takumi [Sun, 22 May 2022 16:03:15 +0000 (01:03 +0900)]
ADT::GenericCycleInfo: Hide validateTree() in -Asserts.

validateTree() is instantiated with __FILE__.
It will be pruned at link time due to -ffunction-sections but be left in
object files.
Its user is only GenericCycleInfo::compute() with assert(validateTree());
Therefore I think validateTree() may be hidden with NDEBUG.

This is a fixup for https://reviews.llvm.org/D112696

2 years agoRevert "[InstCombine] fold icmp with sub and bool"
Sanjay Patel [Sun, 22 May 2022 16:13:20 +0000 (12:13 -0400)]
Revert "[InstCombine] fold icmp with sub and bool"

This reverts commit 4069cccf3b4ff4afb743d3d371ead9e2d5491e3a.
This causes bot failures, and there's a possibly a better way to get this and other patterns.

2 years ago[InstCombine] fold icmp with sub and bool
Sanjay Patel [Sun, 22 May 2022 15:02:28 +0000 (11:02 -0400)]
[InstCombine] fold icmp with sub and bool

This is the specific pattern seen in #53432, but it can be extended
in multiple ways:
1. The 'zext' could be an 'and'
2. The 'sub' could be some other binop with a similar ==0 property (udiv).

There might be some way to generalize using knownbits, but that
would require checking that the 'bool' value is created with
some instruction that can be replaced with new icmp+logic.

https://alive2.llvm.org/ce/z/-KCfpa

2 years ago[InstCombine] add tests for icmp + sub patterns; NFC
Sanjay Patel [Fri, 20 May 2022 21:31:01 +0000 (17:31 -0400)]
[InstCombine] add tests for icmp + sub patterns; NFC

2 years ago[SystemZ] Bugfix for symbolic displacements.
Jonas Paulsson [Thu, 19 May 2022 15:16:49 +0000 (17:16 +0200)]
[SystemZ] Bugfix for symbolic displacements.

Properly handle the case where only the second operand of e.g. an MVC
instruction uses a fixup for the displacement.

Reviewed By: Ulrich Weigand

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

2 years ago[LV] Widen ptr-inductions with scalar uses for scalable VFs.
Florian Hahn [Sun, 22 May 2022 15:24:13 +0000 (16:24 +0100)]
[LV] Widen ptr-inductions with scalar uses for scalable VFs.

Current codegen only supports scalarization of pointer inductions for
scalable VFs if they are uniform. After 3bebec659 we now may enter the
scalarization code path in VPWidenPointerInductionRecipe::execute for
scalable vectors.

Fall back to widening for scalable vectors if necessary.

This should fix a build failure when bootstrapping LLVM with SVE, e.g.
https://lab.llvm.org/buildbot/#/builders/176/builds/1723

2 years agoCWG 1394: Incomplete types as parameters of deleted functions
James Y Knight [Sun, 22 May 2022 14:12:50 +0000 (10:12 -0400)]
CWG 1394: Incomplete types as parameters of deleted functions

Follow-up to previous commit: Add a DR test-case so the
make_cxx_dr_status automation works.

Bug: #52802
Fixes: 50b1faf5c188956fb59ea7d9f9d470591771aedb

2 years ago[SVE] Enable use of 32bit gather/scatter indices for fixed length vectors
Paul Walker [Thu, 28 Apr 2022 20:06:05 +0000 (21:06 +0100)]
[SVE] Enable use of 32bit gather/scatter indices for fixed length vectors

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

2 years ago[clang-tidy] Fix not updating storeOptions after af77b1d9901
Nathan James [Sun, 22 May 2022 09:28:52 +0000 (10:28 +0100)]
[clang-tidy] Fix not updating storeOptions after af77b1d9901

2 years ago[clang-tidy] add support for Demorgan conversions to readability-simplify-bool-expr
Nathan James [Sun, 22 May 2022 08:28:39 +0000 (09:28 +0100)]
[clang-tidy] add support for Demorgan conversions to readability-simplify-bool-expr

Adds support for recognising and converting boolean expressions that can be simplified using De Morgans Law.

This is a different implementation to D124650.

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

Reviewed By: LegalizeAdulthood

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

2 years ago[NFC][M68k][test] Add disassembler tests for move instructions
Sheng [Sun, 22 May 2022 02:34:25 +0000 (10:34 +0800)]
[NFC][M68k][test] Add disassembler tests for move instructions

2 years ago[M68k][Disassembler] Fix decoding conflict
Sheng [Sun, 22 May 2022 02:30:08 +0000 (10:30 +0800)]
[M68k][Disassembler] Fix decoding conflict

This diff fixes decoding conflict between move instructions and
their tail-call counterpart

Reviewed By: myhsu

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

2 years ago[LegalizeTypes][VP] Add integer promotion support for vp.sitofp/vp.uitofp
Ping Deng [Sun, 22 May 2022 02:13:35 +0000 (02:13 +0000)]
[LegalizeTypes][VP] Add integer promotion support for vp.sitofp/vp.uitofp

Reviewed By: craig.topper

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

2 years agoRe-add release notes for GCC ABI compatibility for non-POD in packed structs
David Blaikie [Sun, 22 May 2022 01:15:34 +0000 (01:15 +0000)]
Re-add release notes for GCC ABI compatibility for non-POD in packed structs

2 years ago[M68k][Disassembler] Cleanup unused variables. NFC
Min-Yih Hsu [Sun, 22 May 2022 00:23:51 +0000 (17:23 -0700)]
[M68k][Disassembler] Cleanup unused variables. NFC

  - Remove `MaxInstrWord` in M68kDisassembler.cpp.
  - Remove `MCII` field in `M68kDisassembler` class.

NFC.

2 years ago[clang-format] Format unit tests with InsertBraces/RemoveBracesLLVM
owenca [Sat, 21 May 2022 23:13:35 +0000 (16:13 -0700)]
[clang-format] Format unit tests with InsertBraces/RemoveBracesLLVM

2 years ago[clang-format] Fix a crash on lambda trailing return type
owenca [Sat, 21 May 2022 22:50:50 +0000 (15:50 -0700)]
[clang-format] Fix a crash on lambda trailing return type

Fixes #55625.

2 years ago[clang-format] Fix a bug in "AfterControlStatement: MultiLine"
owenca [Sat, 21 May 2022 22:10:21 +0000 (15:10 -0700)]
[clang-format] Fix a bug in "AfterControlStatement: MultiLine"

Fixes #55582.

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

2 years ago[clang-format] Handle "complex" conditionals in RemoveBracesLLVM
owenca [Mon, 16 May 2022 20:52:32 +0000 (13:52 -0700)]
[clang-format] Handle "complex" conditionals in RemoveBracesLLVM

Do not remove braces if the conditional of if/for/while might not
fit on a single line even after the opening brace is removed.

Examples:
// ColumnLimit: 20
// 45678901234567890
if (a) { /* Remove. */
  foo();
}
if (-b >= c) { // Keep.
  bar();
}

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

2 years ago[ORC] Check for errors when materializing absolute symbols.
Lang Hames [Sat, 21 May 2022 20:52:55 +0000 (13:52 -0700)]
[ORC] Check for errors when materializing absolute symbols.

This code previously used cantFail, but both steps (resolution and emission)
can fail if the resource tracker associated with the
AbsoluteSymbolsMaterializationUnit is removed. Checking these errors is
necessary for correct error propagation.

2 years ago[TypePromotion] Refine fix sext/zext for promoted constant from D125294.
Craig Topper [Sat, 21 May 2022 21:02:22 +0000 (14:02 -0700)]
[TypePromotion] Refine fix sext/zext for promoted constant from D125294.

Reviewing the code again, I believe the sext is needed on the LHS
or RHS for ICmp and only on the RHS for Add.

Add an opcode check before checking the operand number.

Fixes PR55627.

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

2 years ago[ORC] Allow FailedToMaterialize errors to outlive ExecutionSessions.
Lang Hames [Sat, 21 May 2022 01:38:13 +0000 (18:38 -0700)]
[ORC] Allow FailedToMaterialize errors to outlive ExecutionSessions.

Idiomatic llvm::Error usage can result in a FailedToMaterialize error tearing
down an ExecutionSession instance. Since the FailedToMaterialize error holds
SymbolStringPtrs and JITDylib references this leads to crashes when accessing
or logging the error.

This patch modifies FailedToMaterialize to retain the SymbolStringPool and
JITDylibs involved in the failure so that we can safely report an error message
to the client, even if the error tears down the session.

The contract for JITDylibs allows the getName method to be used even after the
session has been torn down, but no other JITDylib fields should be accessed via
the FailedToMaterialize error if the ssesion has been torn down. Logging the
error is guaranteed to be safe in all cases.

2 years ago[clang-tidy] Add a useful note about -std=c++11-or-later
Balazs Benics [Sat, 21 May 2022 20:16:55 +0000 (22:16 +0200)]
[clang-tidy] Add a useful note about -std=c++11-or-later

I and @whisperity spent some time debugging a LIT test case using the
`-std=c++11-or-later` `check_clang_tidy.py` flag when the test had
fixits.

It turns out if the test wants to report a diagnostic into a header
file AND into the test file as well, one needs to first copy the header
somewhere under the build directory.
It needs to be copied since `clang-tidy` sorts the reports into
alphabetical order, thus to have a deterministic order relative to the
diagnostic in the header AND the diagnostic in the test cpp file.

There is more to this story.

The `-std=c++11-or-later` turns out executes the test with multiple
`-std=XX` version substitution, and each execution will also have the
`-fix` tidy parameter. This means that the freshly copied header file I
stated in the previous paragraph gets fixed up and the very next tidy
execution will fail miserably.

Following @whisperity's advice, I'm leaving a reminder about such
//shared// state in the related doc comment.

Reviewed By: LegalizeAdulthood

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

2 years agoFix failing test bots from df46fb40557a14807dd508af32251ceb1cab8b86
Aaron Ballman [Sat, 21 May 2022 20:08:32 +0000 (16:08 -0400)]
Fix failing test bots from df46fb40557a14807dd508af32251ceb1cab8b86

Should fix bots like:
https://lab.llvm.org/buildbot/#/builders/188/builds/14403
https://lab.llvm.org/buildbot/#/builders/171/builds/14928
https://lab.llvm.org/buildbot/#/builders/123/builds/10852
(and others)

2 years agoRevert "[SLP]Do not emit extract elements for insertelements users, replace with...
Florian Hahn [Sat, 21 May 2022 19:57:49 +0000 (20:57 +0100)]
Revert "[SLP]Do not emit extract elements for insertelements users, replace with shuffles directly."

This reverts commit fc9c59c355cb255446e571b4515b5e41a76503c4.

The patch triggers an assertion when building SPEC on X86. Reduced
reproducer shared at D107966.

Also reverts follow-up commit 11a09af76d11ad5a9f1f95b561112af17ff81f80.

2 years ago[MLIR][Presburger] Update equality and subset checks asserts in IntegerRelation
Groverkss [Sat, 21 May 2022 19:50:50 +0000 (01:20 +0530)]
[MLIR][Presburger] Update equality and subset checks asserts in IntegerRelation

This patch updates asserts in IntegerRelation::isEqual and
IntegerRelation::isCompatible to allow these functions when number of
local identifiers are different. This change is done to reflect the
algorithmic changes done before this patch.

2 years agoTest C DR conformance (part one of many)
Aaron Ballman [Sat, 21 May 2022 18:59:16 +0000 (14:59 -0400)]
Test C DR conformance (part one of many)

This starts to fill out the C DR status page with information
determined from tests. It also starts to add some test coverage for the
DRs we can add tests for (some are difficult as not all C DRs involve
questions about code and some DRs are about the behavior of linking
multiple TUs together).

Note: there is currently no automation for filling out the HTML page
from test coverage like there is for the C++ DRs, but this commit
attempts to use a similar comment style in case we want to add such a
script in the future.

2 years ago[clang-format] Fix an infinite loop in parseJavaEnumBody()
owenca [Sat, 21 May 2022 17:28:54 +0000 (10:28 -0700)]
[clang-format] Fix an infinite loop in parseJavaEnumBody()

Fixes #55623.

2 years ago[ORC] Add a ~ExectionSession destructor to verify that endSession was called.
Lang Hames [Sat, 21 May 2022 00:36:47 +0000 (17:36 -0700)]
[ORC] Add a ~ExectionSession destructor to verify that endSession was called.

Clients are required to call ExecutionSession::endSession before destroying the
ExecutionSession. Failure to do so can lead to memory leaks and other difficult
to debug issues. Enforcing this requirement by assertion makes it easy to spot
or debug situations where the contract was not followed.

2 years ago[VPlan] Model first exit values using VPLiveOut.
Florian Hahn [Sat, 21 May 2022 15:01:38 +0000 (16:01 +0100)]
[VPlan] Model first exit values using VPLiveOut.

This patch introduces a new VPLiveOut subclass of VPUser  to model
 exit values explicitly. The initial version handles exit values that
are neither part of induction or reduction chains nor first order
recurrence phis.

Fixes #51366, #54867, #55167, #55459

Reviewed By: Ayal

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

2 years ago[LV] Precommit test for PR55167.
Florian Hahn [Sat, 21 May 2022 15:01:33 +0000 (16:01 +0100)]
[LV] Precommit test for PR55167.

Test for #55167.

2 years ago[ARM] Add register-mask for tail returns
David Green [Sat, 21 May 2022 14:28:24 +0000 (15:28 +0100)]
[ARM] Add register-mask for tail returns

The TC_RETURN/TCRETURNdi under Arm does not currently add the
register-mask operand when tail folding, which leads to the register
(like LR) not being 'used' by the return. This changes the code to
unconditionally set the register mask on the call, as opposed to
skipping it for tail calls.

I don't believe this will currently alter any codegen, but should glue
things together better post-frame lowering. It matches the AArch64 code
better.

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

2 years ago[SCEV] Use umin_seq for BECount of multi-exit loops
Nikita Popov [Sat, 21 May 2022 13:39:08 +0000 (15:39 +0200)]
[SCEV] Use umin_seq for BECount of multi-exit loops

When computing the BECount for multi-exit loops, we need to combine
individual exit counts using umin_seq rather than umin. This is
because an earlier exit may exit on the first iteration, in which
case later exit expressions will not be evaluated and could be
poisonous. We cannot propagate potential poison values from later
exits.

In particular, this avoids the introduction of "branch on poison"
UB when optimizing multi-exit loops.

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

2 years ago[mlir] Move diagnostic handlers instead of copying
Benjamin Kramer [Sat, 21 May 2022 11:25:24 +0000 (13:25 +0200)]
[mlir] Move diagnostic handlers instead of copying

This also allows using unique_ptr instead of shared_ptr for the CAPI
user data. NFCI.

2 years ago[STLExtras] Make indexed_accessor_range operator== compatible with C++20
Benjamin Kramer [Sat, 21 May 2022 10:58:39 +0000 (12:58 +0200)]
[STLExtras] Make indexed_accessor_range operator== compatible with C++20

This would be ambigious with itself when C++20 tries to lookup the
reversed form. I didn't find a use in LLVM, but MLIR does a lot of
comparisons of ranges of different types.

2 years ago[lldb] fix 'command container' help text
Luboš Luňák [Sat, 21 May 2022 10:26:22 +0000 (12:26 +0200)]
[lldb] fix 'command container' help text

2 years ago[AMDGPU] Regenerate permute.ll test checks for future patch
Simon Pilgrim [Fri, 20 May 2022 21:12:45 +0000 (22:12 +0100)]
[AMDGPU] Regenerate permute.ll test checks for future patch

2 years ago[JumpThreading] Insert freeze when unfolding select
Nikita Popov [Sat, 21 May 2022 09:19:29 +0000 (11:19 +0200)]
[JumpThreading] Insert freeze when unfolding select

JumpThreading may convert selects into branch instructions,
in which case the condition needs to be frozen (as branch on
poison is immediate undefined behavior, unlike select on poison).

The necessary code for this is already in place, this just enables
the option.

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

2 years ago[SVE] Refactor lowering for fixed length MGATHER/MSCATTER.
Paul Walker [Sun, 10 Apr 2022 12:38:27 +0000 (13:38 +0100)]
[SVE] Refactor lowering for fixed length MGATHER/MSCATTER.

Lower fixed length MGATHER/MSCATTER operations to scalable vector
equivalents, which are then lowered to SVE specific nodes. This
two stage process is in preparation for making scalable vector
MGATHER/MSCATTER operations legal.

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

2 years ago[bufferization] Simplify code. NFCI.
Benjamin Kramer [Sat, 21 May 2022 08:58:57 +0000 (10:58 +0200)]
[bufferization] Simplify code. NFCI.

2 years ago[LegalizeTypes] Remove double map lookup in DAGTypeLegalizer::PerformExpensiveChecks...
Craig Topper [Sat, 21 May 2022 07:00:01 +0000 (00:00 -0700)]
[LegalizeTypes] Remove double map lookup in DAGTypeLegalizer::PerformExpensiveChecks. NFC

Remove repeated checks for ResId being 0.

2 years ago[LegalizeTypes] Use SmallDenseMap::count instead of SmallDenseMap::find. NFC
Craig Topper [Sat, 21 May 2022 06:15:42 +0000 (23:15 -0700)]
[LegalizeTypes] Use SmallDenseMap::count instead of SmallDenseMap::find. NFC

It's more readable and more efficient.

2 years ago[mlir][LLVMIR] Use the correct way to determine if it's a scalable vector
Min-Yih Hsu [Thu, 21 Apr 2022 16:45:42 +0000 (09:45 -0700)]
[mlir][LLVMIR] Use the correct way to determine if it's a scalable vector

One of the ShuffleVectorOp::build functions checks if the incoming
vector operands is scalable vector by casting its type to
mlir::VectorType first. However, in some cases the operand is not
necessarily mlir::VectorType (e.g. it might be a LLVMVectorType).

This patch fixes this issue by using the dedicated
`LLVM::isScalableVectorType` function to determine if the incoming
vector is scalable vector or not.

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

2 years ago[mlir][LLVMIR] Add support for translating from some simple LLVM instructions
Min-Yih Hsu [Thu, 21 Apr 2022 03:17:07 +0000 (20:17 -0700)]
[mlir][LLVMIR] Add support for translating from some simple LLVM instructions

Add support for translating from llvm::Select, llvm::FNeg, and llvm::Unreachable.
This patch also cleans up (NFC) the opcode map for simple instructions and
adds `// clang-format off/on` comments to prevent those lines from being
churned by clang-format between commits.

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

2 years ago[ORC][examples] Fix off-by-one error when handling null terminators.
Lang Hames [Sat, 21 May 2022 00:31:31 +0000 (17:31 -0700)]
[ORC][examples] Fix off-by-one error when handling null terminators.

LLVMCreateMemoryBufferWithMemoryRange checks for a null terminator after the
given range, so we need to pass the length of the module string (excluding the
null terminator).

2 years ago[ORC][examples] Add missing EPCIndirectionUtils::cleanup call.
Lang Hames [Sat, 21 May 2022 00:12:05 +0000 (17:12 -0700)]
[ORC][examples] Add missing EPCIndirectionUtils::cleanup call.

Clients are required to make this call prior to destroying the object. Adding
the missing call fixes an assertion that was triggering at program termination
time in the LLJITWithExecutorProcessControl example.

2 years ago[ORC] Remove usused Error variable.
Lang Hames [Fri, 20 May 2022 23:58:19 +0000 (16:58 -0700)]
[ORC] Remove usused Error variable.

This was left in by accident, and caused unchecked-error assertions
during program termination in BuildingAJIT-Ch4.