platform/upstream/llvm.git
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.

2 years ago[mlir][bufferization] Add bufferization.alloc_tensor op
Matthias Springer [Sat, 21 May 2022 00:31:07 +0000 (02:31 +0200)]
[mlir][bufferization] Add bufferization.alloc_tensor op

This change adds a new op `alloc_tensor` to the bufferization dialect. During bufferization, this op is always lowered to a buffer allocation (unless it is "eliminated" by a pre-processing pass). It is useful to have such an op in tensor land, because it allows users to model tensor SSA use-def chains (which drive bufferization decisions) and because tensor SSA use-def chains can be analyzed by One-Shot Bufferize, while memref values cannot.

This change also replaces all uses of linalg.init_tensor in bufferization-related code with bufferization.alloc_tensor.

linalg.init_tensor and bufferization.alloc_tensor are similar, but the purpose of the former one is just to carry a shape. It does not indicate a memory allocation.

linalg.init_tensor is not suitable for modelling SSA use-def chains for bufferization purposes, because linalg.init_tensor is marked as not having side effects (in contrast to alloc_tensor). As such, it is legal to move linalg.init_tensor ops around/CSE them/etc. This is not desirable for alloc_tensor; it represents an explicit buffer allocation while still in tensor land and such allocations should not suddenly disappear or get moved around when running the canonicalizer/CSE/etc.

BEGIN_PUBLIC
No public commit message needed for presubmit.
END_PUBLIC

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

2 years ago[lld][WebAssemlby] Add TLS test to lld/test/wasm/data-segments.ll. NFC
Sam Clegg [Fri, 20 May 2022 23:16:36 +0000 (16:16 -0700)]
[lld][WebAssemlby] Add TLS test to lld/test/wasm/data-segments.ll. NFC

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

2 years agoRevert "tsan: add lock free stack pattern test"
Paul Kirth [Sat, 21 May 2022 00:12:06 +0000 (00:12 +0000)]
Revert "tsan: add lock free stack pattern test"

This reverts commit 5deca650fdba22a20e24b397e905ad0abba6f9a9.

2 years agoRevert "Mark new TSan test as unsupported on PPC."
Paul Kirth [Sat, 21 May 2022 00:11:50 +0000 (00:11 +0000)]
Revert "Mark new TSan test as unsupported on PPC."

This reverts commit b517d679dd69a30ed84e9782a2e902cf4284ebc7.

2 years ago[mlir] MemRefToLLVM: convert memref.view operations for empty memrefs
Eugene Zhulenev [Fri, 20 May 2022 21:59:23 +0000 (14:59 -0700)]
[mlir] MemRefToLLVM: convert memref.view operations for empty memrefs

Reviewed By: mehdi_amini

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

2 years agoSystemZAsmPrinter.cpp: Fix a warning. [-Wunused-variable]
NAKAMURA Takumi [Fri, 20 May 2022 22:45:07 +0000 (07:45 +0900)]
SystemZAsmPrinter.cpp: Fix a warning. [-Wunused-variable]

This could be rewritten as `!ZFL->hasFP(*MF) || FrameReg < 16`
but I thought better to clarify it is `AllocaReg`.

2 years ago[ObjCARC] Drop nullary clang.arc.attachedcall bundles in autoupgrade.
Ahmed Bougacha [Fri, 20 May 2022 22:26:31 +0000 (15:26 -0700)]
[ObjCARC] Drop nullary clang.arc.attachedcall bundles in autoupgrade.

In certain use-cases, these can be emitted by old compilers, but the
operand is now always required.  These are only used for optimizations,
so it's safe to drop them if they happen to have the now-invalid format.
The semantically-required call is already a separate instruction.

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

2 years ago[WebAssembly] Strip TLS when "atomics" is not enabled
Dan Gohman [Fri, 20 May 2022 22:16:10 +0000 (15:16 -0700)]
[WebAssembly] Strip TLS when "atomics" is not enabled

With f3b4f99007cdcb3306484c9a39d31addc20aaa69, the exclusive source of
truth for whether threads are supported is the -matomics flag.
Accordingly, strip TLS flags when -matomic is not specified, even if
bulk-memory is specified and it would theoretically be supportable.
This allows the backend to compile TLS variables when -mbulk-memory is
enabled but threads are not enabled.

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

2 years agoConvert the test file for TestIgnoredExceptions.py to the mach_vm API.
Jim Ingham [Fri, 20 May 2022 22:14:26 +0000 (15:14 -0700)]
Convert the test file for TestIgnoredExceptions.py to the mach_vm API.

The previous version of this test uses mprotect, and that seemed to be
flakey on older systems.  I converted the test to use the underlying
mach_vm API's.  The test only runs on Darwin anyway, so this is not a
real limitation, and I'm hoping the lower level API's work more
consistently.

2 years ago[lld-macho] Stop crash when emitting personalities with -dead_strip
Alex Brachet [Fri, 20 May 2022 21:39:16 +0000 (21:39 +0000)]
[lld-macho] Stop crash when emitting personalities with -dead_strip

The <internal> symbol was tripping an assertion in getVA() because it
was not marked as used. Per the comment above that symbols creation,
dead stripping has already occurred so marking this symbol as used is
accurate.

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

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

2 years ago[mlir][sparse] Support more complex operations.
Bixia Zheng [Thu, 19 May 2022 22:18:50 +0000 (15:18 -0700)]
[mlir][sparse] Support more complex operations.

Add complex operations abs, neg, sin, log1p, sub and div.

Add test cases.

Reviewed By: aartbik

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

2 years ago[NVPTX] Enable AtomicExpandPass for NVPTX
Shilei Tian [Fri, 20 May 2022 21:25:14 +0000 (17:25 -0400)]
[NVPTX] Enable AtomicExpandPass for NVPTX

This patch enables `AtomicExpandPass` for NVPTX.

Depend on D125652.

Reviewed By: tra

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

2 years ago[LLVM] Add a check if should cast atomic operations to integer type
Shilei Tian [Fri, 20 May 2022 21:23:34 +0000 (17:23 -0400)]
[LLVM] Add a check if should cast atomic operations to integer type

Currently for atomic load, store, and rmw instructions, as long as the
operand is floating-point value, they are casted to integer. Nowadays many
targets can actually support part of atomic operations with floating-point
operands. For example, NVPTX supports atomic load and store of floating-point
values. This patch adds a series interface functions `shouldCastAtomicXXXInIR`,
and the default implementations are same as what we currently do. Later for
targets can have their specialization.

Reviewed By: jdoerfert

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

2 years agoPPC+TSan whack-a-mole, round 3.
Mitch Phillips [Fri, 20 May 2022 21:21:58 +0000 (14:21 -0700)]
PPC+TSan whack-a-mole, round 3.

More details in https://reviews.llvm.org/D110552.

Last try until I revert the whole shenanigans.

2 years ago[lldb] Fix spurious assertion in PrintCommandOutput
Jonas Devlieghere [Fri, 20 May 2022 21:04:09 +0000 (14:04 -0700)]
[lldb] Fix spurious assertion in PrintCommandOutput

When the string passed to PrintCommandOutput doesn't end with a newline,
`written` will exceed `size` and result in an lldbassert.

After 8e776bb660dda6c51ce7ca6cea641db1f47aa9cf we don't really need
written anymore and we can check whether `str` is empty instead. This
patch simplifies the code and removes the assert that's no longer
relevant.

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

2 years ago[lldb] Consider binary as module of last resort
Will Hawkins [Fri, 20 May 2022 20:50:42 +0000 (13:50 -0700)]
[lldb] Consider binary as module of last resort

When setting an address breakpoint using a non-section address in lldb
before having ever run the program, the binary itself is not considered
a module. As a result, the breakpoint is unresolved (and never gets
resolved subsequently).

This patch changes that behavior: as a last resort, the binary is
considered as a module when resolving a non-section address breakpoint.

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

2 years agoAdd 'ppc' as a target (for both 32- and 64-bit ppc).
Mitch Phillips [Fri, 20 May 2022 20:56:25 +0000 (13:56 -0700)]
Add 'ppc' as a target (for both 32- and 64-bit ppc).

Needed for a TSan test that won't pass on PPC. Relevant information is
in https://reviews.llvm.org/D110552.

2 years ago[OpenMP] Fix partial unrolling off-by-one.
Michael Kruse [Thu, 19 May 2022 21:52:58 +0000 (16:52 -0500)]
[OpenMP] Fix partial unrolling off-by-one.

Even though the comment description is ".unroll_inner.iv < NumIterations", the code emitted a BO_LE ('<=') operator for the inner loop that is to be unrolled. This lead to one additional copy of the body code in a partially unrolled. It only manifests when the unrolled loop is consumed by another loop-associated construct. Fix by using the BO_LT operator instead.

The condition for the outer loop and the corresponding code for tiling correctly used BO_LT already.

Fixes #55236

2 years agoAdd a page to track C defect report status
Aaron Ballman [Fri, 20 May 2022 20:03:20 +0000 (16:03 -0400)]
Add a page to track C defect report status

We currently have a page for tracking defects against the C++ standard,
but we don't have the same information for the C standard. This starts
us down the path of being able to track that in a way our users can see.

There are *a lot* of entries marked as "Unknown". As we validate
Clang's behavior for a given DR by adding a test case for it, we can
slowly begin to improve this page over time.

This page is now linked from the existing C status page, which was
updated slightly as a result of these changes as well.

Note, unlike with the C++ defect report page, this content is not auto-
generated from a source document and is not automatically updated from
test comments. It may be worthwhile to automate the updates based on
our test coverage, but that can happen later.

2 years agoMark new TSan test as unsupported on PPC.
Mitch Phillips [Fri, 20 May 2022 20:06:44 +0000 (13:06 -0700)]
Mark new TSan test as unsupported on PPC.

Notably fails under PPC. For now, just exclude it. More details in the
original Phabricator review, https://reviews.llvm.org/D110552.

2 years ago[clang-tidy] modernize-deprecated-headers should ignore system headers
Balazs Benics [Fri, 20 May 2022 19:41:25 +0000 (21:41 +0200)]
[clang-tidy] modernize-deprecated-headers should ignore system headers

The end-user has no way of 'fixing' bugs in the system library anyway.
Let's suppress these as well.

Reviewed By: LegalizeAdulthood

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

2 years ago[clang-tidy] Introduce the WarnIntoHeaders option to modernize-deprecated-headers
Balazs Benics [Fri, 20 May 2022 19:41:25 +0000 (21:41 +0200)]
[clang-tidy] Introduce the WarnIntoHeaders option to modernize-deprecated-headers

Unfortunately, we must restrict the checker to warn for deprecated headers
only if the header is included directly from a c++ source file.

For header files, we cannot know if the project has a C source file
that also directly/indirectly includes the offending header file
otherwise. Thus, it's better to be on the safe side and suppress those
reports.

One can opt-in the old behavior, emitting diagnostics into header files,
if one explicitly sets the WarnIntoHeaders=true, in which case nothing
will be changed.

Reviewed By: LegalizeAdulthood

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

2 years ago[Libomptarget] Add branch prediction intrinsic to state check
Joseph Huber [Fri, 20 May 2022 19:37:55 +0000 (15:37 -0400)]
[Libomptarget] Add branch prediction intrinsic to state check

Summary:
We usually used the `OMP_LIKELY` and `OMP_UNLIKELY` macros to add branch
prediction intrinsics to help the optimizer ignore unlikely loops. This
wasn't applied to this one loop so add that in.

2 years agoReland "[clang-tidy] modernize-deprecated-headers check should respect extern "C...
Balazs Benics [Fri, 20 May 2022 19:12:39 +0000 (21:12 +0200)]
Reland "[clang-tidy] modernize-deprecated-headers check should respect extern "C" blocks""

This partially reverts commit e8cae487022c2216182ae1ec24f248f287a614b7.
Changes since that commit:
 - Use `SourceManager::isBeforeInTranslationUnit` instead of the fancy
   decomposed decl logarithmic search.
 - Add a test for including a system header containing a deprecated
   include.
 - Add `REQUIRES: system-linux` clause to the test.

Reviewed By: LegalizeAdulthood, whisperity

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

2 years ago[CodeView] Combine variable def ranges that are continuous.
Zequan Wu [Mon, 16 May 2022 20:01:28 +0000 (13:01 -0700)]
[CodeView] Combine variable def ranges that are continuous.

It saves about 1.13% size for chrome.dll.pdb on chrome official build.

Reviewed By: rnk

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

2 years ago[AArch64] Use proper instruction mnemonics for FPRs
Bill Wendling [Fri, 20 May 2022 19:02:26 +0000 (12:02 -0700)]
[AArch64] Use proper instruction mnemonics for FPRs

The FPR128 regs need MOVIv2d_ns and SVE regs need DUP_ZI_D.

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

2 years agoRecommit "[ConstantRange] Improve the implementation of binaryOr"
Alexander Shaposhnikov [Fri, 20 May 2022 18:39:21 +0000 (18:39 +0000)]
Recommit "[ConstantRange] Improve the implementation of binaryOr"

This recommits https://reviews.llvm.org/rG6990e7477d24ff585ae86549f5280f0be65422a6
as the problematic test has been updated updated in
https://reviews.llvm.org/rG3bd112c720dc614a59e3f34ebf9b45075037bfa0.

2 years agoAdd some diagnostics to diagnose bot-only failures for TestIgnoredExceptions.py
Jim Ingham [Fri, 20 May 2022 18:36:55 +0000 (11:36 -0700)]
Add some diagnostics to diagnose bot-only failures for TestIgnoredExceptions.py

The test for commit bff4673b41781ec5bff6b96b52cf321d2271726c is failing on the
GreenDragon bot but none of us can repro the failure locally.  Adding some logging
to the test failure to help diagnose the issue.

2 years agoAvoid uninitialized Diag.ID (which we pass but never read)
Sam McCall [Fri, 20 May 2022 18:29:47 +0000 (20:29 +0200)]
Avoid uninitialized Diag.ID (which we pass but never read)

2 years agoFix up fuzzing test on Windows.
Mitch Phillips [Fri, 20 May 2022 18:25:29 +0000 (11:25 -0700)]
Fix up fuzzing test on Windows.

3bd112c720dc fixed the fuzzing test on Linux, which, after
https://reviews.llvm.org/D125933, has one less branch. Turns out, on
Windows, that it still has the extra branch. I'm guessing that's because
exit() isn't known to be noreturn on Windows or something.

Either way, just make the test more tolerant.

2 years agoAdapt C++ std::string dataformatter for D125496
Adrian Prantl [Fri, 20 May 2022 18:24:24 +0000 (11:24 -0700)]
Adapt C++ std::string dataformatter for D125496

https://reviews.llvm.org/D125496 changed the layout of std::string
without updating the LLDB dataformatter. This patch adds code to
recognize the new format.

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

2 years agoUpdate fuzzing test to comply with new optimisation.
Mitch Phillips [Fri, 20 May 2022 17:59:29 +0000 (10:59 -0700)]
Update fuzzing test to comply with new optimisation.

https://reviews.llvm.org/D125933 improved some of LLVM's handling of
binary ORs, which meant we have one less conditional branch, because the
'if (Size > 5 && Data[5] == 'R')' and 'if (bits == 63)' branches are now
correctly folded.