platform/upstream/llvm.git
2 years ago[NFC][mlgo] Add feature declarations for the ML regalloc advisor
Mircea Trofin [Tue, 21 Dec 2021 04:50:55 +0000 (20:50 -0800)]
[NFC][mlgo] Add feature declarations for the ML regalloc advisor

This just adds feature declarations and some boilerplate.

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

2 years ago[CMake] Move the AIX archiver settings to a module
Petr Hosek [Tue, 7 Dec 2021 19:53:38 +0000 (11:53 -0800)]
[CMake] Move the AIX archiver settings to a module

This allows their reuse across projects. The name of the module
is intentionally generic because we would like to move more platform
checks there.

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

2 years ago[CodeGen] Initialize MaxBytesForAlignment in TargetLoweringBase::TargetLoweringBase.
David Green [Wed, 5 Jan 2022 19:34:27 +0000 (19:34 +0000)]
[CodeGen] Initialize MaxBytesForAlignment in TargetLoweringBase::TargetLoweringBase.

This appears to be missing from D114590, causing sanitizer errors.

2 years agoAdd test case from 356ada9
Philip Reames [Wed, 5 Jan 2022 19:16:03 +0000 (11:16 -0800)]
Add test case from 356ada9

2 years ago[llvm] Add support for DW_TAG_immutable_type
Luís Ferreira [Wed, 5 Jan 2022 18:48:41 +0000 (18:48 +0000)]
[llvm] Add support for DW_TAG_immutable_type

Added documentation about DW_TAG_immutable_type too.

Reviewed By: probinson

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

2 years agoFix accidental usage of cast<> instead of dyn_cast<> in 58a0e44
Philip Reames [Wed, 5 Jan 2022 19:00:01 +0000 (11:00 -0800)]
Fix accidental usage of cast<> instead of dyn_cast<> in 58a0e44

2 years ago[lld/tests] Stop setting the "asserts" and "debug" features
Nico Weber [Fri, 17 Dec 2021 15:04:30 +0000 (10:04 -0500)]
[lld/tests] Stop setting the "asserts" and "debug" features

The last use of `REQUIRES: debug` was removed in 2013 in 72c5d3d7c in favor of
`REQUIRES: asserts`.

The last use of `REQUIRES: asserts` was removed in 2015 in 251b0e268 when the
old COFF linker was removed.

lld's test suite currently has no behavior difference with respect to
assertions or debug builds (and hasn't had it for 6 years). Let's keep it that
way :)

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

2 years ago[instcombine] Allow sinking of calls with known writes to uses
Philip Reames [Wed, 5 Jan 2022 16:53:33 +0000 (08:53 -0800)]
[instcombine] Allow sinking of calls with known writes to uses

If we have a call whose only side effect is a write to a location which is known to be dead, we can sink said call to the users of the call's result value. This is analogous to the recent changes to delete said calls if unused, but framed as a sinking transform instead.

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

2 years agogithub: Add action for automated issue notification
Tom Stellard [Wed, 5 Jan 2022 18:30:30 +0000 (10:30 -0800)]
github: Add action for automated issue notification

This adds a github action that will mention a team called issue-subscribers-$LABEL
whenever a label is added to a bug.  Mentioning the team will automatically
subscribe all team members to the bug.

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

2 years ago[ELF] Demote all lazy symbols. NFC
Fangrui Song [Wed, 5 Jan 2022 18:24:29 +0000 (10:24 -0800)]
[ELF] Demote all lazy symbols. NFC

This complements D111365.

D111365 did not demote isUsedInRegularObj lazy symbols just to work around
a --symbol-ordering-file diagnostic quirk.

The quirk was dropped by 00dd2d15a40b0fe9916bb55a48f264498d8fe910,
so we can demote all lazy symbols now, not just the isUsedInRegularObj ones.

2 years agoRevert "Revert D109159 "[amdgpu] Enable selection of `s_cselect_b64`.""
Nico Weber [Wed, 5 Jan 2022 18:09:25 +0000 (13:09 -0500)]
Revert "Revert D109159 "[amdgpu] Enable selection of `s_cselect_b64`.""

This reverts commit 859ebca744e634dcc89a2294ffa41574f947bd62.
The change contained many unrelated changes and e.g. restored
unit test failes for the old lld port.

2 years ago[MLIR] Add clearAndCopyFrom to IntegerPolyhedron
Groverkss [Wed, 5 Jan 2022 17:49:36 +0000 (23:19 +0530)]
[MLIR] Add clearAndCopyFrom to IntegerPolyhedron

This patch adds clearAndCopyFrom to IntegerPolyhedron. This requires moving
LLVM-style RTTI from FlatAffineConstraints to IntegerPolyhedron.

This patch is part of a series of patches to move presburger math to Presburger
directory.

Reviewed By: arjunp

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

2 years ago[InstCombine] remove trunc user restriction for match of bswap
Sanjay Patel [Wed, 5 Jan 2022 16:53:59 +0000 (11:53 -0500)]
[InstCombine] remove trunc user restriction for match of bswap

This does not appear to cause any problems, and it
fixes #50910

Extra tests with a trunc user were added with:
3a239379
...but they don't match either way, so there's an
opportunity to improve the matching further.

2 years ago[mlir] Align LLVM_Type ODS constraint on type verifiers
Alex Zinenko [Wed, 5 Jan 2022 17:38:10 +0000 (18:38 +0100)]
[mlir] Align LLVM_Type ODS constraint on type verifiers

Verify only the outer type being LLVM-compatible, the elemental types if
present are already checked by the type verifiers. This makes some LLVM dialect
operations compatible with mixed-dialect types that appear during progressive
lowering.

Reviewed By: wsmoses

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

2 years agoRevert D109159 "[amdgpu] Enable selection of `s_cselect_b64`."
David Salinas [Thu, 23 Dec 2021 17:32:31 +0000 (17:32 +0000)]
Revert D109159 "[amdgpu] Enable selection of `s_cselect_b64`."

This reverts commit 640beb38e7710b939b3cfb3f4c54accc694b1d30.

That commit caused performance degradtion in Quicksilver test QS:sGPU and a functional test failure in (rocPRIM rocprim.device_segmented_radix_sort).
Reverting until we have a better solution to s_cselect_b64 codegen cleanup

Change-Id: Ibf8e397df94001f248fba609f072088a46abae08

Reviewed By: kzhuravl

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

Change-Id: Id169459ce4dfffa857d5645a0af50b0063ce1105

2 years ago[gn build] "port" 027ffb173a68
Nico Weber [Wed, 5 Jan 2022 17:57:10 +0000 (12:57 -0500)]
[gn build] "port" 027ffb173a68

2 years ago[MLIR] Simplex::normalizeRow: early exit when gcd is one
Arjun P [Wed, 5 Jan 2022 17:51:45 +0000 (23:21 +0530)]
[MLIR] Simplex::normalizeRow: early exit when gcd is one

Reviewed By: bondhugula

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

2 years ago[mlir] Fix a compiler warning
Kazu Hirata [Wed, 5 Jan 2022 17:42:03 +0000 (09:42 -0800)]
[mlir] Fix a compiler warning

This patch fixes:

  mlir/lib/Dialect/Linalg/ComprehensiveBufferize/ModuleBufferization.cpp:635:23:
  error: comparison of integers of different signs: 'int' and 'size_t'
  (aka 'unsigned long') [-Werror,-Wsign-compare]

2 years agoAdd codegen for allocate directive's 'align' clause
David Pagan [Wed, 5 Jan 2022 17:40:58 +0000 (12:40 -0500)]
Add codegen for allocate directive's 'align' clause

2 years ago[ASan] Moved optimized callbacks into a separate library.
Kirill Stoimenov [Wed, 5 Jan 2022 17:14:40 +0000 (17:14 +0000)]
[ASan] Moved optimized callbacks into a separate library.

This will allow linking in the callbacks directly instead of using PLT.

Reviewed By: vitalybuka

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

2 years ago[AMDGPU] Regenerate test checks in collapse-endcf.mir. NFC
Christudasan Devadasan [Wed, 5 Jan 2022 16:41:51 +0000 (11:41 -0500)]
[AMDGPU] Regenerate test checks in collapse-endcf.mir. NFC

2 years ago[LegalizeTypes] Remove IsVP argument from type legalization methods. NFC
Craig Topper [Wed, 5 Jan 2022 16:52:53 +0000 (08:52 -0800)]
[LegalizeTypes] Remove IsVP argument from type legalization methods. NFC

We can either check the opcode or number of operands or use
ISD::isVPOpcode inside the methods.

In some places I've used number of operands figuring that it is
cheaper than isVPOpcode. I've included isVPOpcode in an assert to
verify.

Reviewed By: frasercrmck

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

2 years ago[RISCV] Use macros to reduce repetive switch cases. NFC
Craig Topper [Wed, 5 Jan 2022 16:52:41 +0000 (08:52 -0800)]
[RISCV] Use macros to reduce repetive switch cases. NFC

These 3 switches map LMUL enum to instruction names. These follow
a regular pattern. Use a macro to reduce the number of source code
lines.

Reviewed By: arcbbb

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

2 years ago[clang][#52782] Bail on incomplete parameter type in stdcall name mangling
Markus Böck [Fri, 24 Dec 2021 20:55:07 +0000 (21:55 +0100)]
[clang][#52782] Bail on incomplete parameter type in stdcall name mangling

stdcall name mangling requires a suffix with the number equal to the sum of the byte count of all parameter types. In the case of a function prototype that has a parameter type of an incomplete type it is impossible to get the size of the type. While such a function is not callable or able to be defined in the TU, it may still be mangled when generating debug info, which would previously lead to a crash.
This patch fixes that by simply bailing out of the loop and using the so far accumulated byte count. This matches GCCs behaviour as well: https://github.com/gcc-mirror/gcc/blob/bc8d6c60137f8bbf173b86ddf31b15d7ba2a33dd/gcc/config/i386/winnt.c#L203

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

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

2 years agoRename doesNotReadMemory to onlyWritesMemory globally [NFC]
Philip Reames [Wed, 5 Jan 2022 16:20:53 +0000 (08:20 -0800)]
Rename doesNotReadMemory to onlyWritesMemory globally [NFC]

The naming has come up as a source of confusion in several recent reviews.  onlyWritesMemory is consist with onlyReadsMemory which we use for the corresponding readonly case as well.

2 years ago[lld-link] Consistently print all /verbose output to stderr
Nico Weber [Wed, 5 Jan 2022 16:24:44 +0000 (11:24 -0500)]
[lld-link] Consistently print all /verbose output to stderr

lld-link used to consistently print all /verbose output to stdout, and that was
an intentional decision: https://reviews.llvm.org/rG4bce7bcc88f3

https://reviews.llvm.org/rGe6e206d4b4814 added message() and log(),
and back then `log()` morally was just `if (verbose) message(...)`
and message() wrote to stdout.

So that change moved most /verbose-induced writes to outs() to
log(). Except for the one in printDiscardedMessage(), since
the check for `verbose` for that one is in the caller, in
Writer::createSections():

    if (config->verbose)
      sc->printDiscardedMessage();

Later, https://reviews.llvm.org/D41033 changed log() to write to
stderr. That moved lld-link from writing all its /verbose output
to stdout to writing almost all of its /verbose output to stderr --
except for printDiscardedMessage() output.

This change moves printDiscardedMessage() to call log() as well,
so that all /verbose output once again consistently goes to the same
stream.

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

2 years ago[Hexagon] Extend OptAddrMode pass to vgather
Shubham Pawar [Wed, 19 Jun 2019 16:38:06 +0000 (11:38 -0500)]
[Hexagon] Extend OptAddrMode pass to vgather

This change extends the addressing mode optimization
pass to HVX vgather. This is specifically intended to
resolve compiler not generating indexed addresses for
vgather stores to vtcm. Changed the vgather pseudo
instructions to accept an immediate operand and handled
addition of appropriate immediate operand in addressing
mode optimization pass.

2 years ago[libc++][format] Improve an exception message.
Mark de Wever [Sun, 2 Jan 2022 16:03:58 +0000 (17:03 +0100)]
[libc++][format] Improve an exception message.

The fix in D116381 makes an existing exception message wrong. This
improves the message and fixes the associated unit tests.

Note other message can be also be improved, but that will be done later.
Changing these messages may cause merge conflicts with other patches
that are under review or WIP.

Depends on D116381

Reviewed By: #libc, Quuxplusone, ldionne

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

2 years ago[libc++][format] Fix precision parser conformance.
Mark de Wever [Wed, 29 Dec 2021 18:50:38 +0000 (19:50 +0100)]
[libc++][format] Fix precision parser conformance.

@CaseyCarter reported that the tests for the std-format-spec rejects leading
zeroes for precision, which the Standard does not require. The Standard allows
them. Only for precision, not for the width or an arg-id.

Fixes the precision parser and adds some test for the arg-id since they
were missing.

Reviewed By: ldionne, #libc

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

2 years ago[mlir] Fix for 9a7d111f4fb65ad7343dcbd4f35ee608100634e8
Nicolas Vasilache [Wed, 5 Jan 2022 16:40:46 +0000 (11:40 -0500)]
[mlir] Fix for 9a7d111f4fb65ad7343dcbd4f35ee608100634e8

2 years ago[clang-format][NFC] Fix typo in comment
Jino Park [Wed, 5 Jan 2022 16:30:26 +0000 (17:30 +0100)]
[clang-format][NFC] Fix typo in comment

Fix typo (leftt -> left)

Reviewed By: curdeius

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

2 years ago[mlir][Linalg] NFC - Modernize transformation APIs.
Nicolas Vasilache [Wed, 5 Jan 2022 15:51:42 +0000 (10:51 -0500)]
[mlir][Linalg] NFC - Modernize transformation APIs.

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

2 years ago[Hexagon] Add setting hvx-qfloat in HexagonMCSubtargetInfo
Joshua Herrera [Tue, 28 Dec 2021 19:21:47 +0000 (11:21 -0800)]
[Hexagon] Add setting hvx-qfloat in HexagonMCSubtargetInfo

2 years ago[clangd] Don't index __reserved_names in headers.
Sam McCall [Tue, 7 Dec 2021 23:52:15 +0000 (00:52 +0100)]
[clangd] Don't index __reserved_names in headers.

Main use of these is in the standard library, where they generally clutter up
the index.

Certain macros are also common, we don't touch indexing of macros in this patch.

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

2 years ago[mlir][linalg][bufferize][NFC] Simplify bufferization of CallOps
Matthias Springer [Wed, 5 Jan 2022 15:22:38 +0000 (00:22 +0900)]
[mlir][linalg][bufferize][NFC] Simplify bufferization of CallOps

There is no need to inspect the ReturnOp of the called function.

This change also refactors the bufferization of CallOps in such a way that `lookupBuffer` is called only a single time. This is important for a later change that fixes CallOp bufferization. (There is currently a TODO among the test cases.)

Note: This change modifies a test case but is marked as NFC. There is no change of functionality, but FuncOps with empty bodies are now reported with a different error message.

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

2 years ago[mlir] Introduce Python bindings for the quantization dialect
Alex Zinenko [Tue, 4 Jan 2022 16:43:44 +0000 (17:43 +0100)]
[mlir] Introduce Python bindings for the quantization dialect

So far, only the custom dialect types are exposed.

The build and packaging is same as for Linalg and SparseTensor, and in
need of refactoring that is beyond the scope of this patch.

Reviewed By: stellaraccident

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

2 years ago[AIX][z/OS][Support] Provide alternate no-op mapped_file_region::dontNeedImpl impleme...
David Tenty [Tue, 4 Jan 2022 16:42:18 +0000 (10:42 -0600)]
[AIX][z/OS][Support] Provide alternate no-op mapped_file_region::dontNeedImpl implementation

mapped_file_region::dontNeedImpl added in D116366 calls madvise, which
causes problems for z/OS and AIX.

For z/OS, we don't have either madvise, so treat this as a no-op, same
as Windows does.

For AIX, it doesn't have any effect, doesn't have a standardized
signature, and it needs certain feature test macros (i.e. _ALL_SOURCE)
we don't set by default for LLVM on AIX, so just make it a no-op too.

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

2 years ago[mlir] Introduce C API for the Quantization dialect types
Alex Zinenko [Mon, 3 Jan 2022 18:01:07 +0000 (19:01 +0100)]
[mlir] Introduce C API for the Quantization dialect types

Reviewed By: nicolasvasilache

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

2 years ago[mlir][linalg][bufferize] Fix CallOps with non-tensor operands
Matthias Springer [Wed, 5 Jan 2022 15:13:55 +0000 (00:13 +0900)]
[mlir][linalg][bufferize] Fix CallOps with non-tensor operands

Such CallOps were not handled properly. When computing the new result types (and replacement values) of a CallOp, non-tensor return values were not accounted for.

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

2 years ago[mlir] Use public PybindAdaptors in Linalg dialect bindings
Alex Zinenko [Wed, 5 Jan 2022 12:06:45 +0000 (13:06 +0100)]
[mlir] Use public PybindAdaptors in Linalg dialect bindings

Previously, the Python bindings for the Linalg dialect relied on the internal
implementation of core bindings. Most of that functionality was moved, and the
remaining one does not need access to the implementation: it used to accept a
dialect pointer as argument, but it can always be extracted from the operation
that it also accepts; operations are available through PybindAdaptors in an
opaque way. Change the bindings in that direction.

This enables the decoupling of the Linalg dialect Python extension from the
core IR Python extension.

Reviewed By: nicolasvasilache

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

2 years ago[AArch64] Regenerate some mir tests to new format. NFC
David Green [Wed, 5 Jan 2022 15:12:22 +0000 (15:12 +0000)]
[AArch64] Regenerate some mir tests to new format. NFC

2 years ago[mlir][linalg][bufferize][NFC] Remove RewriterBase from BufferizationState
Matthias Springer [Wed, 5 Jan 2022 12:17:53 +0000 (21:17 +0900)]
[mlir][linalg][bufferize][NFC] Remove RewriterBase from BufferizationState

This change simplifies BufferizationState. Having `rewriter` in BufferizationState could be confusing to users because a rewriter is also passed to each `bufferize` function and it is not obvious (by looking at the API) that these two rewriters are the same.

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

2 years ago[clangd] Refine comment on declarator ranges
Sam McCall [Wed, 5 Jan 2022 15:00:13 +0000 (16:00 +0100)]
[clangd] Refine comment on declarator ranges

2 years ago[clangd] Fix typos in the SelectionTree comment.
Haojian Wu [Wed, 5 Jan 2022 14:50:07 +0000 (15:50 +0100)]
[clangd] Fix typos in the SelectionTree comment.

2 years ago[AArch64] Adding "armv8.8-a" memcpy/memset support.
Simon Tatham [Thu, 11 Feb 2021 11:41:20 +0000 (11:41 +0000)]
[AArch64] Adding "armv8.8-a" memcpy/memset support.

This family of instructions includes CPYF (copy forward), CPYB (copy
backward), SET (memset) and SETG (memset + initialise MTE tags), with
some sub-variants to indicate whether address translation is done in a
privileged or unprivileged way. For the copy instructions, you can
separately specify the read and write translations (so that kernels
can safely use these instructions in syscall handlers, to memcpy
between the calling process's user-space memory map and the kernel's
own privileged one).

The unusual thing about these instructions is that they write back to
multiple registers, because they perform an implementation-defined
amount of copying each time they run, and write back to _all_ the
address and size registers to indicate how much remains to be done
(and the code is expected to loop on them until the size register
becomes zero). But this is no problem in LLVM - you just define each
instruction to have multiple outputs, multiple inputs, and a set of
constraints tying their register numbers together appropriately.

This commit introduces a special subtarget feature called MOPS (after
the name the spec gives to the CPU id field), which is a dependency of
the top-level 8.8-A feature, and uses that to enable most of the new
instructions. The SETMG instructions also depend on MTE (and the test
checks that).

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

2 years ago[llvm-strings] Remove use of hard coded executable name
gbreynoo [Wed, 5 Jan 2022 14:34:45 +0000 (14:34 +0000)]
[llvm-strings] Remove use of hard coded executable name

Other tools take their tool name from argv[0] for use in output
messages. This change makes llvm-strings consistent with other tools
rather than using a hard coded value.

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

2 years ago[clangd] Handle declarators more consistently in Selection.
Sam McCall [Tue, 4 Jan 2022 21:46:25 +0000 (22:46 +0100)]
[clangd] Handle declarators more consistently in Selection.

Because declarators nest inside-out, we logically need to claim tokens for
parent declarators logically before child ones.
This is the ultimate reason we had problems with DeclaratorDecl, ArrayType etc.

However actually changing the order of traversal is hard, especially for nodes
that have both declarator and non-declarator children.
Since there's only a few TypeLocs corresponding to declarators, we just
have them claim the exact tokens rather than rely on nesting.

This fixes handling of complex declarators, like
`int (*Fun(OuterT^ype))(InnerType);`.

This avoids the need for the DeclaratorDecl early-claim hack, which is
removed.
Unfortunately the DeclaratorDecl early-claims were covering up an AST
anomaly around CXXConstructExpr, so we need to fix that up too.

Based on D116623 and D116618

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

2 years ago[mlir] Fix missing check on nested op values in LICM
Nicolas Vasilache [Wed, 5 Jan 2022 13:19:32 +0000 (08:19 -0500)]
[mlir] Fix missing check on nested op values in LICM

LICM checks that nested ops depend only on values defined outside
before performing hoisting.
However, it specifically omits to check for terminators which can
lead to SSA violations.
This revision fixes the incorrect behavior.

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

2 years ago[LV] Don't use getVPSingleValue for VPWidenMemoryInstRecipe (NFC).
Florian Hahn [Wed, 5 Jan 2022 13:51:50 +0000 (13:51 +0000)]
[LV] Don't use getVPSingleValue for VPWidenMemoryInstRecipe (NFC).

VPWidenMemoryInstructionRecipe is a VPValue, so this can be passed
directly, instead of relying on getVPSingleValue.

2 years ago[clang][lex] NFC: Simplify loop
Jan Svoboda [Wed, 5 Jan 2022 12:39:19 +0000 (13:39 +0100)]
[clang][lex] NFC: Simplify loop

2 years ago[mlir][vector] NFC - Split out transfer split patterns
Nicolas Vasilache [Wed, 5 Jan 2022 12:05:23 +0000 (07:05 -0500)]
[mlir][vector] NFC - Split out transfer split patterns

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

2 years ago[clang-tidy] Fix false positive in modernize-pass-by-value
Clement Courbet [Mon, 3 Jan 2022 13:25:29 +0000 (14:25 +0100)]
[clang-tidy] Fix false positive in modernize-pass-by-value

The check should not trigger on lvalue/rvalue overload pairs:

```
struct S {
  S(const A& a) : a(a) {}
  S(A&& a) : a(std::move(a)) {}

  A a;
}
```

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

2 years ago[InstCombine] add tests for bswap; NFC
Sanjay Patel [Tue, 4 Jan 2022 20:23:44 +0000 (15:23 -0500)]
[InstCombine] add tests for bswap; NFC

2 years ago[InstSimplify] add tests for udiv/urem with known bits; NFC
Sanjay Patel [Tue, 4 Jan 2022 18:52:29 +0000 (13:52 -0500)]
[InstSimplify] add tests for udiv/urem with known bits; NFC

2 years agoRetire llvm::make_reverse_iterator in favor of std::make_reverse_iterator
Benjamin Kramer [Wed, 5 Jan 2022 12:58:01 +0000 (13:58 +0100)]
Retire llvm::make_reverse_iterator in favor of std::make_reverse_iterator

std::make_reverse_iterator is a C++14 feature, gcc has it since GCC 5.1.

2 years ago[GlobalOpt][Evaluator] Fix off by one error in bounds check (PR53002)
Nikita Popov [Wed, 5 Jan 2022 13:05:00 +0000 (14:05 +0100)]
[GlobalOpt][Evaluator] Fix off by one error in bounds check (PR53002)

We should bail out if the index is >= the size, not > the size.

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

2 years ago[AArch64][CodeGen] Emit alignment "Max Skip" operand for AArch64 loops
Nicholas Guy [Tue, 7 Dec 2021 10:28:33 +0000 (10:28 +0000)]
[AArch64][CodeGen] Emit alignment "Max Skip" operand for AArch64 loops

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

2 years ago[CodeGen] Emit alignment "Max Skip" operand
Nicholas Guy [Wed, 1 Dec 2021 10:51:31 +0000 (10:51 +0000)]
[CodeGen] Emit alignment "Max Skip" operand

The current AsmPrinter has support to emit the "Max Skip" operand
(the 3rd of .p2align), however has no support for it to actually be specified.
Adding MaxBytesForAlignment to MachineBasicBlock provides this capability on a
per-block basis. Leaving the value as default (0) causes no observable differences
in behaviour.

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

2 years ago[clang-format] Fix indentation for array variables with alignment of consecutive...
Marek Kurdej [Wed, 5 Jan 2022 12:41:50 +0000 (13:41 +0100)]
[clang-format] Fix indentation for array variables with alignment of consecutive assignments and declarations.

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

Reviewed By: HazardyKnusperkeks, owenpan

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

2 years agomsan: mark test as x86-specific
Dmitry Vyukov [Wed, 5 Jan 2022 12:40:10 +0000 (13:40 +0100)]
msan: mark test as x86-specific

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

2 years ago[clang-format] Simplify raw string regex. NFC.
Marek Kurdej [Wed, 5 Jan 2022 12:39:08 +0000 (13:39 +0100)]
[clang-format] Simplify raw string regex. NFC.

Introduced in https://reviews.llvm.org/D115168.

Reviewed By: MyDeveloperDay, HazardyKnusperkeks

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

2 years ago[lldb/linux] Fix a race in handling of simultaneous thread exits
Pavel Labath [Wed, 5 Jan 2022 12:04:20 +0000 (13:04 +0100)]
[lldb/linux] Fix a race in handling of simultaneous thread exits

D116372, while fixing one kind of a race, ended up creating a new one.
The new issue could occur when one inferior thread exits while another
thread initiates termination of the entire process (exit_group(2)).

With some bad luck, we could start processing the exit notification
(PTRACE_EVENT_EXIT) only to have the become unresponsive (ESRCH) in the
middle of the MonitorCallback function. This function would then delete
the thread from our list even though it wasn't completely dead (it stays
zombified until we read the WIFEXITED event). The linux kernel will not
deliver the exited event for the entire process until we process
individual thread exits.

In a pre-D116372 world, this wouldn't be a problem because we would read
this event (even though we would not know what to do with it) with
waitpid(-1). Now, when we issue invididual waitpids, this event will
never be picked up, and we end up hanging.

The fix for this is actually quite simple -- don't delete the thread in
this situation. The thread will be deleted when the WIFEXITED event
comes.

This situation was kind of already tested by
TestCreateDuringInstructionStep (which is how I found this problem), but
it was mostly accidental, so I am also creating a dedicated test which
reproduces this situation.

2 years ago[LV] Remove what seems like stale code in collectElementTypesForWidening.
Sander de Smalen [Tue, 4 Jan 2022 16:20:45 +0000 (16:20 +0000)]
[LV] Remove what seems like stale code in collectElementTypesForWidening.

This was originally added in rG22174f5d5af1eb15b376c6d49e7925cbb7cca6be
although that patch doesn't really mention any reasons for ignoring the
pointer type in this calculation if the memory access isn't consecutive.

Reviewed By: david-arm

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

2 years agomsan: check that ucontext_t is initialized on signal return
Dmitry Vyukov [Thu, 23 Dec 2021 08:10:54 +0000 (09:10 +0100)]
msan: check that ucontext_t is initialized on signal return

A signal handler can alter ucontext_t to affect execution after
the signal returns. Check that the contents are initialized.
Restoring unitialized values in registers can't be good.

Reviewed By: vitalybuka

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

2 years agomsan: account for AVX state when unpoison ucontext_t
Dmitry Vyukov [Thu, 23 Dec 2021 08:06:37 +0000 (09:06 +0100)]
msan: account for AVX state when unpoison ucontext_t

ucontext_t can be larger than its static size if it contains
AVX state and YMM/ZMM registers.
Currently a signal handler that tries to access that state
can produce false positives with random origins on stack.
Account for the additional ucontext_t state.

Reviewed By: vitalybuka

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

2 years agoRevert "[Clang][ScanDeps] Use the virtual path for module maps"
Archibald Elliott [Wed, 5 Jan 2022 12:09:58 +0000 (12:09 +0000)]
Revert "[Clang][ScanDeps] Use the virtual path for module maps"

This reverts commits:
04192422c4e3b730c580498b8e948088cb15580b.
015e08c6badad6b27404d6f94569e25c18d79049

D114206 was landed before it was approved - and was landed knowing that
the test crashed on windows, without an xfail. The promised follow-up
commit with fixes has not appeared since it was promised on December 14th.

2 years ago[mlir][linalg][bufferize][NFC] Use RewriterBase instead of OpBuilder
Matthias Springer [Wed, 5 Jan 2022 11:36:05 +0000 (20:36 +0900)]
[mlir][linalg][bufferize][NFC] Use RewriterBase instead of OpBuilder

This is in preparation of unifying core bufferization and Comprehensive Bufferize.

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

2 years ago[SVE] Add ISel for fabs(fsub(a,b)) ==> FABD.
Paul Walker [Thu, 23 Dec 2021 17:47:38 +0000 (17:47 +0000)]
[SVE] Add ISel for fabs(fsub(a,b)) ==> FABD.

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

2 years ago[AArch64ISelLowering] Don't look through scalable extract_subvector when optimising...
Paul Walker [Fri, 31 Dec 2021 13:50:59 +0000 (13:50 +0000)]
[AArch64ISelLowering] Don't look through scalable extract_subvector when optimising DUPLANE.

When constructDup is passed an extract_subvector it tries to use
extract_subvector's operand directly when creating the DUPLANE.
This is invalid when extracting from a scalable vector because the
necessary DUPLANE ISel patterns do not exist.

NOTE: This patch is an update to https://reviews.llvm.org/D110524
that originally fixed this but introduced a bug when the result
VT is 64bits. I've restructured the code so the critial final
else block is entered when necessary.

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

2 years ago[ConstantFold] Use ConstantFoldLoadFromUniformValue() in more places
Nikita Popov [Wed, 5 Jan 2022 11:37:09 +0000 (12:37 +0100)]
[ConstantFold] Use ConstantFoldLoadFromUniformValue() in more places

In particular, this also preserves undef when loading from padding,
rather than converting it to zero through a different codepath.

This is the remaining part of D115924.

2 years ago[ConstantFold] Add test for load of padding (NFC)
Nikita Popov [Wed, 5 Jan 2022 11:34:10 +0000 (12:34 +0100)]
[ConstantFold] Add test for load of padding (NFC)

This currently load zero rather than undef.

2 years ago[clang-format][NFC] Put all state change into the for statement
Björn Schäpers [Mon, 3 Jan 2022 06:57:54 +0000 (07:57 +0100)]
[clang-format][NFC] Put all state change into the for statement

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

2 years ago[clang-format][NFC] Right.Previous is Left
Björn Schäpers [Sun, 2 Jan 2022 21:22:55 +0000 (22:22 +0100)]
[clang-format][NFC] Right.Previous is Left

Use that name. Also remove the one check for its existence, that is
given.

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

2 years ago[clang-format][NFC] Use Prev instead of Current->Previous
Björn Schäpers [Sun, 2 Jan 2022 21:16:52 +0000 (22:16 +0100)]
[clang-format][NFC] Use Prev instead of Current->Previous

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

2 years ago[clang-format][NFC] TokenAnnotator: Use range based for
Björn Schäpers [Sun, 2 Jan 2022 21:12:46 +0000 (22:12 +0100)]
[clang-format][NFC] TokenAnnotator: Use range based for

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

2 years ago[clang-format][NFC] Early return in TokenAnnotator::next
Björn Schäpers [Sun, 2 Jan 2022 21:06:18 +0000 (22:06 +0100)]
[clang-format][NFC] Early return in TokenAnnotator::next

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

2 years ago[clang-format][NFC] Don't pass member by argument
Björn Schäpers [Sun, 2 Jan 2022 21:01:49 +0000 (22:01 +0100)]
[clang-format][NFC] Don't pass member by argument

And then use the argument and member.

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

2 years ago[clang-format] Fix SeparateDefinitionBlocks docs and ...
Björn Schäpers [Mon, 3 Jan 2022 22:12:56 +0000 (23:12 +0100)]
[clang-format] Fix SeparateDefinitionBlocks docs and ...

the Style's equality operator.

This amends 6f6f88ffdae1e12e5f950ef418827a77a55c09c7

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

2 years ago[clang-format][NFC] Replace deque with vector
Björn Schäpers [Fri, 3 Dec 2021 07:27:18 +0000 (08:27 +0100)]
[clang-format][NFC] Replace deque with vector

I think the deque was chosen because of a better push_front, but in
combination with llvm::reverse the push_back'ed vector should be the
better choice.

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

2 years ago[ConstantFolding] Unify handling of load from uniform value
Nikita Popov [Wed, 5 Jan 2022 11:17:22 +0000 (12:17 +0100)]
[ConstantFolding] Unify handling of load from uniform value

There are a number of places that specially handle loads from a
uniform value where all the bits are the same (zero, one, undef,
poison), because we a) don't care about the load offset in that
case b) it bypasses casts that might not be legal generally but
do work with uniform values.

We had multiple implementations of this, with a different set of
supported values each time. This replaces two usages with a more
complete helper. Other usages will be replaced separately, because
they have larger impact.

This is part of D115924.

2 years ago[ConstantFold] Add additional load from uniform value tests (NFC)
Nikita Popov [Wed, 5 Jan 2022 11:13:15 +0000 (12:13 +0100)]
[ConstantFold] Add additional load from uniform value tests (NFC)

2 years ago[mlir][linalg][bufferize][NFC] Refactor BufferizationOption ownership
Matthias Springer [Wed, 5 Jan 2022 11:23:46 +0000 (20:23 +0900)]
[mlir][linalg][bufferize][NFC] Refactor BufferizationOption ownership

Pass unique_ptr<BufferizationOption> to the bufferization. This allows the bufferization to enqueue additional PostAnalysisSteps. When running bufferization a second time, a new BufferizationOptions must be constructed.

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

2 years agoRevert "Revert "[InferAttrs] Add writeonly to all the math functions""
Benjamin Kramer [Wed, 5 Jan 2022 09:32:11 +0000 (10:32 +0100)]
Revert "Revert "[InferAttrs] Add writeonly to all the math functions""

This reverts commit 29b6e967f3e99ac45340ea37a70262c70e4e7528. The bug it
found in PartiallyInlineLibCalls was fixed in
c8ffc73350dbb6044ca947bbead127b9b914cdf3.

2 years ago[PartiallyInlineLibCalls] Don't crash when there's a writeonly attribute on the call
Benjamin Kramer [Wed, 5 Jan 2022 11:04:40 +0000 (12:04 +0100)]
[PartiallyInlineLibCalls] Don't crash when there's a writeonly attribute on the call

readnone subsumes writeonly, so just swap out the attributes. The
verifier doesn't allow us to have both on a call.

2 years ago[LegalizeTypes][VP] Add integer promotion support for vp.select
Victor Perez [Wed, 5 Jan 2022 09:23:31 +0000 (09:23 +0000)]
[LegalizeTypes][VP] Add integer promotion support for vp.select

Promote select, vselect and vp.select in a similar way.

Reviewed By: craig.topper

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

2 years ago[VPlan] Add value numbering in unit test after 65c4d6191fc4.
Florian Hahn [Wed, 5 Jan 2022 11:00:47 +0000 (11:00 +0000)]
[VPlan] Add value numbering in unit test after 65c4d6191fc4.

2 years ago[TTI] Return invalid cost for scalable vector in getShuffleCost
Jun Ma [Wed, 29 Dec 2021 07:24:16 +0000 (15:24 +0800)]
[TTI] Return invalid cost for scalable vector in getShuffleCost

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

2 years ago[VPlan] Add VPCanonicalIVPHIRecipe, partly retire createInductionVariable.
Florian Hahn [Wed, 5 Jan 2022 10:37:28 +0000 (10:37 +0000)]
[VPlan] Add VPCanonicalIVPHIRecipe, partly retire createInductionVariable.

At the moment, the primary induction variable for the vector loop is
created as part of the skeleton creation. This is tied to creating the
vector loop latch outside of VPlan. This prevents from modeling the
*whole* vector loop in VPlan, which in turn is required to model
preheader and exit blocks in VPlan as well.

This patch introduces a new recipe VPCanonicalIVPHIRecipe to represent the
primary IV in VPlan and CanonicalIVIncrement{NUW} opcodes for
VPInstruction to model the increment.

This allows us to partly retire createInductionVariable. At the moment,
a bit of patching up is done after executing all blocks in the plan.

Reviewed By: Ayal

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

2 years ago[clang][scandeps] Update Module Cache Path in Test
Archibald Elliott [Wed, 5 Jan 2022 10:41:48 +0000 (10:41 +0000)]
[clang][scandeps] Update Module Cache Path in Test

This fixes the test introduced in D114206 so it no longer writes to the current working directory.

Reviewed By: simon_tatham

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

2 years ago[ELF] Remove redundant cast. NFC
Fangrui Song [Wed, 5 Jan 2022 10:07:14 +0000 (02:07 -0800)]
[ELF] Remove redundant cast. NFC

2 years ago[ELF] --symbol-ordering-file: use getLocalSymbols. NFC
Fangrui Song [Wed, 5 Jan 2022 10:06:30 +0000 (02:06 -0800)]
[ELF] --symbol-ordering-file: use getLocalSymbols. NFC

2 years ago[ELF] --symbol-ordering-file: remove weird !lazy condition for "no such symbol" diagn...
Fangrui Song [Wed, 5 Jan 2022 10:04:36 +0000 (02:04 -0800)]
[ELF] --symbol-ordering-file: remove weird !lazy condition for "no such symbol" diagnostic

The diagnostic is emitted for an unextracted lazy symbol but suppressed for an
undefined symbol. Suppressing the diagnostic for unextracted lazy symbol
probably makes more sense because (a) an unextracted lazy symbol is quite
similar to an undefined symbol and (b) an unextracted lazy symbol is different
from "no such symbol".

2 years ago[mlir][scf] NFC - refactor the implementation of outlineIfOp
Nicolas Vasilache [Tue, 4 Jan 2022 11:35:52 +0000 (06:35 -0500)]
[mlir][scf] NFC - refactor the implementation of outlineIfOp

This revision refactors the implementation of outlineIfOp to expose
a finer-grain functionality `outlineSingleBlockRegion` that will be
reused in other contexts.

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

2 years ago[LegalizeTypes][VP] Add widening support for vp.select
Victor Perez [Wed, 5 Jan 2022 08:07:46 +0000 (08:07 +0000)]
[LegalizeTypes][VP] Add widening support for vp.select

Widen vp.select the same way as select and vselect.

Reviewed By: craig.topper

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

2 years agoSilence a few unused variable warnings. NFC.
Sjoerd Meijer [Wed, 5 Jan 2022 09:11:43 +0000 (09:11 +0000)]
Silence a few unused variable warnings. NFC.

2 years agoRevert "[InferAttrs] Add writeonly to all the math functions"
Martin Storsjö [Wed, 5 Jan 2022 08:54:07 +0000 (10:54 +0200)]
Revert "[InferAttrs] Add writeonly to all the math functions"

This reverts commit ea75be3d9df448b6abafaf752a8141764d93ca33 and
1eb5b6e85045d22720f177a02aaf7097930e4b4f.

That commit caused crashes with compilation e.g. like this
(not fixed by the follow-up commit):

$ cat sqrt.c
float a;
b() { sqrt(a); }
$ clang -target x86_64-linux-gnu -c -O2 sqrt.c
Attributes 'readnone and writeonly' are incompatible!
  %sqrtf = tail call float @sqrtf(float %0) #1
in function b
fatal error: error in backend: Broken function found, compilation aborted!

2 years ago[M68k][test][NFC] Remove new line at end of file
Jim Lin [Wed, 5 Jan 2022 08:28:14 +0000 (16:28 +0800)]
[M68k][test][NFC] Remove new line at end of file

2 years ago[LoopInfo] Clarify description of `makeLoopInvariant`. NFC.
Sjoerd Meijer [Wed, 5 Jan 2022 08:55:26 +0000 (08:55 +0000)]
[LoopInfo] Clarify description of `makeLoopInvariant`. NFC.

Clarify that `Changed` is set to true if the instruction/value was made
loop-invariant; the function is returning true if it was already invariant.

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

2 years ago[MemCpyOpt] Look through pointer casts when checking capture
Nikita Popov [Wed, 5 Jan 2022 08:48:17 +0000 (09:48 +0100)]
[MemCpyOpt] Look through pointer casts when checking capture

The user scanning loop above looks through pointer casts, so we
also need to strip pointer casts in the capture check. Previously
the source was incorrectly considered not captured if a bitcast
was passed to the call.

2 years ago[ELF] Symbol::getVA: assert not called on a lazy symbol
Fangrui Song [Wed, 5 Jan 2022 08:46:48 +0000 (00:46 -0800)]
[ELF] Symbol::getVA: assert not called on a lazy symbol

The code path is dead after D111365.