platform/upstream/llvm.git
3 years ago[clang-tidy] Fix readability-identifer-naming duplicating prefix or suffix for replac...
Nathan James [Mon, 15 Mar 2021 14:20:47 +0000 (14:20 +0000)]
[clang-tidy] Fix readability-identifer-naming duplicating prefix or suffix for replacements.

If a identifier has a correct prefix/suffix but a bad case, the fix won't strip them when computing the correct case, leading to duplication when the are added back.

Reviewed By: aaron.ballman

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

3 years ago[ASTMatchers] Don't forward matchers in MapAnyOf
Nathan James [Mon, 15 Mar 2021 14:16:51 +0000 (14:16 +0000)]
[ASTMatchers] Don't forward matchers in MapAnyOf

Forwarding these means that if an r-value reference is passed, the matcher will be moved. However it appears this happens for each mapped node matcher, resulting in use-after-move issues.

Reviewed By: steveire

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

3 years ago[clang][lex] Speculative fix for buffer overrun on raw string parse
Jan Svoboda [Mon, 15 Mar 2021 14:07:53 +0000 (15:07 +0100)]
[clang][lex] Speculative fix for buffer overrun on raw string parse

This attempts to fix a (non-deterministic) buffer overrun when parsing raw string literals during modular build.

Similar fix to 4e5b5c36f47c9a406ea7f6b4f89fae477693973a.

Reviewed By: beccadax

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

3 years ago[NFC][PowerPC] Add additional load/store test cases
Amy Kwan [Mon, 15 Mar 2021 06:07:42 +0000 (01:07 -0500)]
[NFC][PowerPC] Add additional load/store test cases

This patch adds additional load/store test cases involving scalars, vectors,
and PC-Rel in preparation for the refactored load and store implementation
introduced in D93370.

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

3 years ago[mlir] fix integration tests post e2310704d890ad252aeb1ca28b4b84d29514b1d1
Alex Zinenko [Mon, 15 Mar 2021 13:40:01 +0000 (14:40 +0100)]
[mlir] fix integration tests post e2310704d890ad252aeb1ca28b4b84d29514b1d1

The commit in question moved some ops across dialects but did not update
some of the target-specific integration tests that use these ops,
presumably because the corresponding target hardware was not available.
Fix these tests.

3 years ago[PATCH] fix location of test case
Wael Yehia [Mon, 15 Mar 2021 13:34:20 +0000 (09:34 -0400)]
[PATCH] fix location of test case

from D97507.

3 years ago[SystemZ][z/OS] Define _LIBCPP_ELAST
Muiez Ahmed [Mon, 15 Mar 2021 13:23:36 +0000 (09:23 -0400)]
[SystemZ][z/OS] Define _LIBCPP_ELAST

The aim is to define _LIBCPP_ELAST for z/OS libc++ since strerror/strerror_r can't handle out-of-range errno values.

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

3 years ago[mlir] enable Python bindings for the MemRef dialect
Alex Zinenko [Mon, 15 Mar 2021 13:06:25 +0000 (14:06 +0100)]
[mlir] enable Python bindings for the MemRef dialect

A previous commit moved multiple ops from Standard to MemRef dialect.
Some of these ops are exercised in Python bindings. Enable bindings for
the newly created MemRef dialect and update a test accordingly.

3 years ago[ASTMatchers][Dynamic] Add missing matchers from Registry
Nathan James [Mon, 15 Mar 2021 13:07:39 +0000 (13:07 +0000)]
[ASTMatchers][Dynamic] Add missing matchers from Registry

Add the `fixedPointLiteral`, `hasAnyBody` and `templateArgumentLoc` to the dynamic matcher registry.

Reviewed By: steveire

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

3 years ago[ASTMatchers] Fix documentation for hasAnyBody matcher
Nathan James [Mon, 15 Mar 2021 13:06:48 +0000 (13:06 +0000)]
[ASTMatchers] Fix documentation for hasAnyBody matcher

Looks like a oversight when the matcher was added.

Reviewed By: steveire

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

3 years agoRevert "[Sanitizer][RISCV][AArch64][Android] Adjust allocator tests"
Luís Marques [Mon, 15 Mar 2021 13:01:26 +0000 (13:01 +0000)]
Revert "[Sanitizer][RISCV][AArch64][Android] Adjust allocator tests"

This reverts commit a00347b56e36b30b26f9e54e947b965acf2b7eec due to a
test failure on the `sanitizer-x86_64-linux-android` buildbot.

3 years ago[SLP][Test] Precommit test for PR40522
Anton Afanasyev [Mon, 15 Mar 2021 12:52:07 +0000 (15:52 +0300)]
[SLP][Test] Precommit test for PR40522

3 years ago[ast-dump-tool] fix regression if --empty-implementation but --json-input-path is not
Nico Weber [Mon, 15 Mar 2021 12:44:05 +0000 (08:44 -0400)]
[ast-dump-tool] fix regression if --empty-implementation but --json-input-path is not

Looks like this broke in one of the relands of
https://reviews.llvm.org/D93164

3 years ago[AMDGPU] Fix shortfalls in WQM marking
Carl Ritson [Mon, 15 Mar 2021 12:32:09 +0000 (21:32 +0900)]
[AMDGPU] Fix shortfalls in WQM marking

When tracking defined lanes through phi nodes in the live range
graph each branch of the phi must be handled independently.
Also rewrite the marking algorithm to reduce unnecessary
operations.

Previously a shared set of defined lanes was used which caused
marking to stop prematurely. This was observable in existing lit
tests, but test patterns did not cover this detail.

Reviewed By: piotr

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

3 years ago[X86][SSE] canonicalizeShuffleWithBinOps - add X86ISD::PSHUFB handling.
Simon Pilgrim [Mon, 15 Mar 2021 12:38:03 +0000 (12:38 +0000)]
[X86][SSE] canonicalizeShuffleWithBinOps - add X86ISD::PSHUFB handling.

Recommit rGcd938ab162b0ac560dd0e9fee290980c7e0e47e5 with an early-out if the pshub would introduce zeros across the binop.

3 years ago[mlir] fix shared-lib build fallout of e2310704d890ad252aeb1ca28b4b84d29514b1d1
Alex Zinenko [Mon, 15 Mar 2021 12:32:36 +0000 (13:32 +0100)]
[mlir] fix shared-lib build fallout of e2310704d890ad252aeb1ca28b4b84d29514b1d1

The patch in question broke the build with shared libraries due to
missing dependencies, one of which would have been circular between
MLIRStandard and MLIRMemRef if added. Fix this by moving more code
around and swapping the dependency direction. MLIRMemRef now depends on
MLIRStandard, but MLIRStandard does _not_ depend on MLIRMemRef.
Arguably, this is the right direction anyway since numerous libraries
depend on MLIRStandard and don't necessarily need to depend on
MLIRMemref.

Other otable changes include:
- some EDSC code is moved inline to MemRef/EDSC/Intrinsics.h because it
  creates MemRef dialect operations;
- a utility function related to shape moved to BuiltinTypes.h/cpp
  because it only realtes to shaped types and not any particular dialect
  (standard dialect is erroneously believed to contain MemRefType);
- a Python test for the standard dialect is disabled completely because
  the ops it tests moved to the new MemRef dialect, but it is not
  exposed to Python bindings, and the change for that is non-trivial.

3 years ago[AArch64][SVE] Add unpredicated ld1/st1 patterns for reg+reg addressing modes
Bradley Smith [Thu, 28 Jan 2021 12:39:39 +0000 (12:39 +0000)]
[AArch64][SVE] Add unpredicated ld1/st1 patterns for reg+reg addressing modes

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

3 years agoRevert rG9ba577eca2e339726bfaad4e615c6324a705b292 "[X86][SSE] canonicalizeShuffleWith...
Simon Pilgrim [Mon, 15 Mar 2021 12:23:32 +0000 (12:23 +0000)]
Revert rG9ba577eca2e339726bfaad4e615c6324a705b292 "[X86][SSE] canonicalizeShuffleWithBinOps - handle target shuffles. NFCI."

Sorry this wasn't supposed to be committed yet (and certainly not tagged as NFCI....)

3 years agoRevert "[NFCI][ValueTracking] getUnderlyingObject(): gracefully handle cycles"
Nikita Popov [Mon, 15 Mar 2021 12:12:39 +0000 (13:12 +0100)]
Revert "[NFCI][ValueTracking] getUnderlyingObject(): gracefully handle cycles"

This reverts commit aa440ba24dc25e4c95f6dcf8ff647024f3b12661.

This has a non-trivial compile-time impact:
https://llvm-compile-time-tracker.com/compare.php?from=0c5b789c7342ee8384507c3242fc256e23248c4d&to=aa440ba24dc25e4c95f6dcf8ff647024f3b12661&stat=instructions

I don't believe this is the correct way to address the issue in
this case.

3 years ago[X86][SSE] canonicalizeShuffleWithBinOps - handle target shuffles. NFCI.
Simon Pilgrim [Mon, 15 Mar 2021 11:24:07 +0000 (11:24 +0000)]
[X86][SSE] canonicalizeShuffleWithBinOps - handle target shuffles. NFCI.

Fold SHUFFLE(BINOP(SHUFFLE(X),SHUFFLE(Y))) -> BINOP(SHUFFLE'(X),SHUFFLE'(Y)) style patterns as well as the existing shuffles of constants.

3 years ago[dexter] Check path != None before calling os.path.exists
OCHyams [Mon, 15 Mar 2021 11:28:28 +0000 (11:28 +0000)]
[dexter] Check path != None before calling os.path.exists

The test optnone-simple-functions.cpp added in D97668 fails on macOS.
os.path.exists raises an exception because we pass it None. Guard against this.

Related revision: https://reviews.llvm.org/D97668

3 years ago[LLDB] Skip TestExitDuringExpression on arm/linux buildbot
Muhammad Omair Javaid [Mon, 15 Mar 2021 11:01:02 +0000 (16:01 +0500)]
[LLDB] Skip TestExitDuringExpression on arm/linux buildbot

TestExitDuringExpression test_exit_before_one_thread_unwind fails
sporadically on arm/linux. This seems like a thread timing issue.
I am marking it skip for now.

3 years ago[Sanitizer][RISCV][AArch64][Android] Adjust allocator tests
Luís Marques [Mon, 15 Mar 2021 11:01:20 +0000 (11:01 +0000)]
[Sanitizer][RISCV][AArch64][Android] Adjust allocator tests

On 64-bit systems with small VMAs (e.g. 39-bit) we can't use
`SizeClassAllocator64` parameterized with size class maps containing a
large number of classes, as that will make the allocator region size too
small (< 2^32). Several tests were already disabled for Android because
of this.

This patch provides the correct allocator configuration for RISC-V
(riscv64), generalizes the gating condition for tests that can't be
enabled for small VMA systems, and tweaks the tests that can be made
compatible with those systems to enable them.

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

3 years ago[AST] Add generator for source location introspection
Stephen Kelly [Sun, 14 Mar 2021 16:18:54 +0000 (16:18 +0000)]
[AST] Add generator for source location introspection

Generate a json file containing descriptions of AST classes and their
public accessors which return SourceLocation or SourceRange.

Use the JSON file to generate a C++ API and implementation for accessing
the source locations and method names for accessing them for a given AST
node.

This new API can be used to implement 'srcloc' output in clang-query:

  http://ce.steveire.com/z/m_kTIo

The JSON file can also be used to generate bindings for other languages,
such as Python and Javascript:

  https://steveire.wordpress.com/2019/04/30/the-future-of-ast-matching

In this first version of this feature, only the accessors for Stmt
classes are generated, not Decls, TypeLocs etc.  Those can be added
after this change is reviewed, as this change is mostly about
infrastructure of these code generators.

Also in this version, the platforms/cmake configurations are excluded as
much as possible so that support can be added iteratively.  Currently a
break on any platform causes a revert of the entire feature.  This way,
the `OR WIN32` can be removed in a future commit and if it breaks the
buildbots, only that commit gets reverted, making the entire process
easier to manage.

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

3 years ago[NFCI][ValueTracking] getUnderlyingObject(): gracefully handle cycles
Roman Lebedev [Mon, 15 Mar 2021 08:51:23 +0000 (11:51 +0300)]
[NFCI][ValueTracking] getUnderlyingObject(): gracefully handle cycles

Normally, this function just doesn't bother about cycles,
and hopes that the caller supplied small-enough depth
so that at worst it will take a potentially large,
but limited amount of time. But that obviously doesn't work
if there is no depth limit.

This reapples 36f1c3db66f7268ea3183bcf0bbf05b3e1c570b4,
but without asserting, just bailout once cycle is detected.

3 years ago[RISCV] Support fixed-length vectors in the calling convention
Fraser Cormack [Tue, 2 Mar 2021 11:11:18 +0000 (11:11 +0000)]
[RISCV] Support fixed-length vectors in the calling convention

This patch adds fixed-length vector support to the calling convention
when RVV is used to lower fixed-length vectors. The scheme follows the
regular vector calling convention for the argument/return registers, but
uses scalable vector container types as the LocVTs, and converts to/from
the fixed-length vector value types as required.

Fixed-length vector types may be split when the combination of minimum
VLEN and the maximum allowable LMUL is not large enough to fully contain
the vector. In this case the behaviour differs between fixed-length
vectors passed as parameters and as return values:
1. For return values, vectors must be passed entirely via registers or
via the stack.
2. For parameters, unlike scalar values, split vectors continue to be
passed by value, and are split across multiple registers until there are
no remaining registers. Thus vector parameters may be found partly in
registers and partly on the stack.

As with scalable vectors, the first fixed-length mask vector is passed
via v0. Split mask fixed-length vectors are passed first via v0 and then
via the next available vector register: v8,v9,etc.

The handling of vector return values uses all available argument
registers v8-v23 which does not adhere to the calling convention we're
supposedly implementing, but since this issue affects both fixed-length
and scalable-vector values, it was left as-is.

Reviewed By: craig.topper

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

3 years ago[AMDGPU] Use depth first iterator instead of recursive DFS. NFCI.
Jay Foad [Fri, 12 Mar 2021 18:01:19 +0000 (18:01 +0000)]
[AMDGPU] Use depth first iterator instead of recursive DFS. NFCI.

The reason for this is to avoid deep recursion in DFS() which can cause
stack overflow on large CFGs, especially on Windows.

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

3 years ago[MLIR] Create memref dialect and move dialect-specific ops from std.
Julian Gross [Wed, 10 Feb 2021 12:53:11 +0000 (13:53 +0100)]
[MLIR] Create memref dialect and move dialect-specific ops from std.

Create the memref dialect and move dialect-specific ops
from std dialect to this dialect.

Moved ops:
AllocOp -> MemRef_AllocOp
AllocaOp -> MemRef_AllocaOp
AssumeAlignmentOp -> MemRef_AssumeAlignmentOp
DeallocOp -> MemRef_DeallocOp
DimOp -> MemRef_DimOp
MemRefCastOp -> MemRef_CastOp
MemRefReinterpretCastOp -> MemRef_ReinterpretCastOp
GetGlobalMemRefOp -> MemRef_GetGlobalOp
GlobalMemRefOp -> MemRef_GlobalOp
LoadOp -> MemRef_LoadOp
PrefetchOp -> MemRef_PrefetchOp
ReshapeOp -> MemRef_ReshapeOp
StoreOp -> MemRef_StoreOp
SubViewOp -> MemRef_SubViewOp
TransposeOp -> MemRef_TransposeOp
TensorLoadOp -> MemRef_TensorLoadOp
TensorStoreOp -> MemRef_TensorStoreOp
TensorToMemRefOp -> MemRef_BufferCastOp
ViewOp -> MemRef_ViewOp

The roadmap to split the memref dialect from std is discussed here:
https://llvm.discourse.group/t/rfc-split-the-memref-dialect-from-std/2667

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

3 years ago[mlir] better formatting in interface docs
Alex Zinenko [Mon, 15 Mar 2021 10:10:32 +0000 (11:10 +0100)]
[mlir] better formatting in interface docs

Start the description from a new line instead of putting the first
paragraph in the section header. Wrap the class name in backticks to
make it clear that it relates to the code.

3 years ago[mlir] fix cmake for generating data layout documentation
Alex Zinenko [Mon, 15 Mar 2021 10:01:35 +0000 (11:01 +0100)]
[mlir] fix cmake for generating data layout documentation

3 years agoFix MSVC "switch statement contains 'default' but no 'case' labels" warning. NFCI.
Simon Pilgrim [Mon, 15 Mar 2021 09:45:45 +0000 (09:45 +0000)]
Fix MSVC "switch statement contains 'default' but no 'case' labels" warning. NFCI.

3 years ago[X86][SSE] Attempt to merge single-op hops for slow targets.
Simon Pilgrim [Sun, 14 Mar 2021 22:27:57 +0000 (22:27 +0000)]
[X86][SSE] Attempt to merge single-op hops for slow targets.

For slow-hop targets, see if any single-op hops are duplicating work already done on another (dual-op) hop, which can sometimes occur as isHorizontalBinOp tries to find potential duplicates (but can't merge them itself). If so, reuse the other hop and shuffle the result.

3 years agoRevert "[Canonicalizer] Process regions top-down instead of bottom up & reuse existin...
Alex Zinenko [Mon, 15 Mar 2021 09:26:41 +0000 (10:26 +0100)]
Revert "[Canonicalizer] Process regions top-down instead of bottom up & reuse existing constants."

This reverts commit b5d9a3c92358349d5444ab28de8ab5b2bee33a01.

The commit introduced a memory error in canonicalization/operation
walking that is exposed when compiled with ASAN. It leads to crashes in
some "release" configurations.

3 years ago[AArch64][compiler-rt] Strip PAC from the link register.
Daniel Kiss [Mon, 15 Mar 2021 09:24:44 +0000 (10:24 +0100)]
[AArch64][compiler-rt] Strip PAC from the link register.

-mbranch-protection protects the LR on the stack with PAC.
When the frames are walked the LR need to be cleared.
This inline assembly later will be replaced with a new builtin.

Test: build with  -DCMAKE_C_FLAGS="-mbranch-protection=standard".

Reviewed By: kubamracek

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

3 years ago[MLIR] Add canonicalization for `shape.broadcast`
Frederik Gossen [Mon, 15 Mar 2021 09:10:07 +0000 (10:10 +0100)]
[MLIR] Add canonicalization for `shape.broadcast`

Remove redundant operands and fold if only one left.

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

3 years agoRevert "[NFCI][ValueTracking] getUnderlyingObject(): assert that no cycles are encoun...
Roman Lebedev [Mon, 15 Mar 2021 09:00:22 +0000 (12:00 +0300)]
Revert "[NFCI][ValueTracking] getUnderlyingObject(): assert that no cycles are encountered"

This reverts commit 36f1c3db66f7268ea3183bcf0bbf05b3e1c570b4.
Seems to make bots unhappy.

3 years ago[MLIR] Allow compatible shapes in `Elementwise` operations
Frederik Gossen [Mon, 15 Mar 2021 08:47:00 +0000 (09:47 +0100)]
[MLIR] Allow compatible shapes in `Elementwise` operations

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

3 years ago[NFCI][ValueTracking] getUnderlyingObject(): assert that no cycles are encountered
Roman Lebedev [Mon, 15 Mar 2021 08:51:23 +0000 (11:51 +0300)]
[NFCI][ValueTracking] getUnderlyingObject(): assert that no cycles are encountered

Jeroen Dobbelaere in
https://lists.llvm.org/pipermail/llvm-dev/2021-March/149206.html
is reporting that this function can end up in an endless loop
when called from SROA w/ full restrict patches.

For now, simply ensure that such problems are caught earlier/easier.

3 years ago[mlir][AVX512] Add while loop-based sparse vector-vector dot product variants.
Matthias Springer [Mon, 15 Mar 2021 07:52:40 +0000 (16:52 +0900)]
[mlir][AVX512] Add while loop-based sparse vector-vector dot product variants.

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

3 years ago[Test] Replace checks with auto-generated checks
Max Kazantsev [Mon, 15 Mar 2021 07:32:00 +0000 (14:32 +0700)]
[Test] Replace checks with auto-generated checks

3 years ago[NFC][Inliner] Debugging support to print funtion size after each inlining.
Hongtao Yu [Thu, 11 Mar 2021 18:38:15 +0000 (10:38 -0800)]
[NFC][Inliner] Debugging support to print funtion size after each inlining.

Reviewed By: wenlei

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

3 years agodebuginfo-tests: Fix check-gdb-mlir-support build after MLIR API change in a4bb667d831c
Nathan Chancellor [Mon, 15 Mar 2021 05:09:52 +0000 (05:09 +0000)]
debuginfo-tests: Fix check-gdb-mlir-support build after MLIR API change in a4bb667d831c

Reviewed By: mehdi_amini

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

3 years ago[m_Constant] Check #operands/results before hasTrait()
Chris Lattner [Mon, 15 Mar 2021 01:41:13 +0000 (18:41 -0700)]
[m_Constant] Check #operands/results before hasTrait()

We know that all ConstantLike operations have one result and no operands,
so check this first before doing the trait check.  This change speeds up
Canonicalize on a CIRCT testcase by ~5%.

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

3 years ago[RISCV] Support inline asm for vector instructions.
Hsiangkai Wang [Tue, 9 Mar 2021 00:53:02 +0000 (08:53 +0800)]
[RISCV] Support inline asm for vector instructions.

Types of fractional LMUL and LMUL=1 are all using VR register class. When
using inline asm, it will use the first type in the register class as the
type for the register. It is not necessary the same as the value type. We
need to use INSERT_SUBVECTOR/EXTRACT_SUBVECToR/BITCAST to make it legal
to put the value in the corresponding register class.

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

3 years ago[Canonicalizer] Process regions top-down instead of bottom up & reuse existing constants.
Chris Lattner [Sun, 14 Mar 2021 20:14:48 +0000 (13:14 -0700)]
[Canonicalizer] Process regions top-down instead of bottom up & reuse existing constants.

Two changes:
 1) Change the canonicalizer to walk the function in top-down order instead of
    bottom-up order.  This composes well with the "top down" nature of constant
    folding and simplification, reducing iterations and re-evaluation of ops in
    simple cases.
 2) Explicitly enter existing constants into the OperationFolder table before
    canonicalizing.  Previously we would "constant fold" them and rematerialize
    them, wastefully recreating a bunch fo constants, which lead to pointless
    memory traffic.

Both changes together provide a 33% speedup for canonicalize on some mid-size
CIRCT examples.

One artifact of this change is that the constants generated in normal pattern
application get inserted at the top of the function as the patterns are applied.
Because of this, we get "inverted" constants more often, which is an aethetic
change to the IR but does permute some testcases.

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

3 years agoRevert "[AST] Add generator for source location introspection"
Stephen Kelly [Mon, 15 Mar 2021 01:16:10 +0000 (01:16 +0000)]
Revert "[AST] Add generator for source location introspection"

This reverts commit 91abaa1f8d97e8efa249c31686fd643ff5f1e2c2.

3 years agoRevert "Attempt to fix ARM buildbot"
Stephen Kelly [Mon, 15 Mar 2021 01:16:07 +0000 (01:16 +0000)]
Revert "Attempt to fix ARM buildbot"

This reverts commit 12dac66f6b33dd14b72076800726817f682ab785.

3 years ago[RISCV] Give an explicit error if 'generic' CPU is passed instead of 'generic-rv32...
Craig Topper [Mon, 15 Mar 2021 00:17:50 +0000 (17:17 -0700)]
[RISCV] Give an explicit error if 'generic' CPU is passed instead of 'generic-rv32' or 'generic-rv64'. Validate 64Bit feature against the triple.

I encountered a project that uses llvm that passes "generic" by
default. While I could fix that project, I wouldn't be surprised
if other projects did something similar. So it seems like
a good idea to provide a better error here.

I've also added validation of the 64Bit feature against the
triple so that we can catch a mismatched CPU before failing in
a mysterious way. We can make it pretty far in isel because we
calculate XLenVT from the triple and use that to set up the legal
integer type.

Reviewed By: luismarques, khchen

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

3 years agoAttempt to fix ARM buildbot
Stephen Kelly [Mon, 15 Mar 2021 00:20:39 +0000 (00:20 +0000)]
Attempt to fix ARM buildbot

3 years ago[AST] Add generator for source location introspection
Stephen Kelly [Sun, 14 Mar 2021 16:18:54 +0000 (16:18 +0000)]
[AST] Add generator for source location introspection

Generate a json file containing descriptions of AST classes and their
public accessors which return SourceLocation or SourceRange.

Use the JSON file to generate a C++ API and implementation for accessing
the source locations and method names for accessing them for a given AST
node.

This new API can be used to implement 'srcloc' output in clang-query:

  http://ce.steveire.com/z/m_kTIo

The JSON file can also be used to generate bindings for other languages,
such as Python and Javascript:

  https://steveire.wordpress.com/2019/04/30/the-future-of-ast-matching

In this first version of this feature, only the accessors for Stmt
classes are generated, not Decls, TypeLocs etc.  Those can be added
after this change is reviewed, as this change is mostly about
infrastructure of these code generators.

Also in this version, the platforms/cmake configurations are excluded as
much as possible so that support can be added iteratively.  Currently a
break on any platform causes a revert of the entire feature.  This way,
the `OR WIN32` can be removed in a future commit and if it breaks the
buildbots, only that commit gets reverted, making the entire process
easier to manage.

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

3 years agoRevert "[AST] Add generator for source location introspection"
Stephen Kelly [Sun, 14 Mar 2021 22:51:45 +0000 (22:51 +0000)]
Revert "[AST] Add generator for source location introspection"

This reverts commit 477e4b974653f92960c0bf569d88da7baacef68a.

3 years agoRevert "Ensure that cache variable is set when not building introspection"
Stephen Kelly [Sun, 14 Mar 2021 22:51:40 +0000 (22:51 +0000)]
Revert "Ensure that cache variable is set when not building introspection"

This reverts commit 6b010c6f6e354966569e02841180c77df45bbd76.

3 years agoEnsure that cache variable is set when not building introspection
Stephen Kelly [Sun, 14 Mar 2021 22:44:38 +0000 (22:44 +0000)]
Ensure that cache variable is set when not building introspection

3 years ago[X86] Add -prefer-vector-width=256 tests for v16i8 smulo/umulo.
Craig Topper [Sun, 14 Mar 2021 22:17:03 +0000 (15:17 -0700)]
[X86] Add -prefer-vector-width=256 tests for v16i8 smulo/umulo.

3 years ago[AST] Add generator for source location introspection
Stephen Kelly [Sun, 14 Mar 2021 16:18:54 +0000 (16:18 +0000)]
[AST] Add generator for source location introspection

Generate a json file containing descriptions of AST classes and their
public accessors which return SourceLocation or SourceRange.

Use the JSON file to generate a C++ API and implementation for accessing
the source locations and method names for accessing them for a given AST
node.

This new API can be used to implement 'srcloc' output in clang-query:

  http://ce.steveire.com/z/m_kTIo

The JSON file can also be used to generate bindings for other languages,
such as Python and Javascript:

  https://steveire.wordpress.com/2019/04/30/the-future-of-ast-matching

In this first version of this feature, only the accessors for Stmt
classes are generated, not Decls, TypeLocs etc.  Those can be added
after this change is reviewed, as this change is mostly about
infrastructure of these code generators.

Also in this version, the platforms/cmake configurations are excluded as
much as possible so that support can be added iteratively.  Currently a
break on any platform causes a revert of the entire feature.  This way,
the `OR WIN32` can be removed in a future commit and if it breaks the
buildbots, only that commit gets reverted, making the entire process
easier to manage.

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

3 years ago[lldb] Move PlatformPOSIX::ConnectToWaitingProcesses to RemoteAwarePlatform
Pavel Labath [Sun, 14 Mar 2021 21:17:42 +0000 (22:17 +0100)]
[lldb] Move PlatformPOSIX::ConnectToWaitingProcesses to RemoteAwarePlatform

The functionality is not posix specific. Also force the usage of the
gdb-remote process plugin in the gdb platform class.

This is not sufficient to make TestPlatformConnect pass on windows (it
seems it suffers from module loading issues, unrelated to this test),
but it at least makes it shut down correctly, so I change the skip to an
xfail.

3 years ago[ArgPromotion] Copy additional metadata for loads.
Chenguang Wang [Sun, 14 Mar 2021 19:21:32 +0000 (19:21 +0000)]
[ArgPromotion] Copy additional metadata for loads.

Current ArgPromotion implementation does not copy it: https://godbolt.org/z/zzTKof

Reviewed By: fhahn

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

3 years ago[InstSimplify] Add additional GEP transform tests & regenerate
Simonas Kazlauskas [Sun, 14 Mar 2021 20:55:29 +0000 (22:55 +0200)]
[InstSimplify] Add additional GEP transform tests & regenerate

3 years ago[llvm] [dwarf] Fix DWARFListTableHeader::getOffsetEntry off-by-one
Jan Kratochvil [Sun, 14 Mar 2021 20:42:44 +0000 (21:42 +0100)]
[llvm] [dwarf] Fix DWARFListTableHeader::getOffsetEntry off-by-one

D98289 was erroneously reporting `invalid range list offset 0x20110`
instead of `invalid range list table index 0`.

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

3 years ago[M68k] Tidy up some bit shifting during code emission
Ricky Taylor [Sun, 14 Mar 2021 18:53:14 +0000 (11:53 -0700)]
[M68k] Tidy up some bit shifting during code emission

This fixes some issues with bit masking when emitting instructions
(including one TODO).

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

3 years ago[M68k] Make M68k TargetMachine use getter function
Ricky Taylor [Sun, 14 Mar 2021 18:51:58 +0000 (11:51 -0700)]
[M68k] Make M68k TargetMachine use getter function

This makes M68k match other platforms in this regard.

This was done as part of the AsmParser/Disassembler work since the entry
functions of those modules usually reference `getTheXXXTarget()`.

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

3 years ago[M68k] Fix extract-section.py under Python 3
Ricky Taylor [Sun, 14 Mar 2021 18:36:57 +0000 (11:36 -0700)]
[M68k] Fix extract-section.py under Python 3

read_raw_stdin() was opening a file in binary mode, but Popen
was being told to use text mode (universal_newlines). This is
benign on Python 2 but an error on Python 3.

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

3 years agoRevert "[gn build] (manually) kind of merge d627a27d26"
Nico Weber [Sun, 14 Mar 2021 16:18:22 +0000 (12:18 -0400)]
Revert "[gn build] (manually) kind of merge d627a27d26"

This reverts commit 5123327edab15bacb44a63a874d9d379d4873407.
d627a27d26 was reverted in e0f70a8a979f.

3 years agoRevert "[AST] Add generator for source location introspection"
Nikita Popov [Sun, 14 Mar 2021 16:04:34 +0000 (17:04 +0100)]
Revert "[AST] Add generator for source location introspection"

Breaks the build ... somehow: https://llvm-compile-time-tracker.com/show_error.php?commit=77f7d2be214a1de29d583c75739f563593991fc3

FAILED: tools/clang/include/clang/Tooling/NodeIntrospection.inc
cd /root/llvm-compile-time-tracker/llvm-project-build/tools/clang/lib/Tooling && /usr/bin/cmake -E make_directory /root/llvm-compile-time-tracker/llvm-project-build/tools/clang/lib/Tooling/generated/ && /root/llvm-compile-time-tracker/llvm-project/clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py --json-input-path /root/llvm-compile-time-tracker/llvm-project-build/ASTNodeAPI.json --output-file generated/NodeIntrospection.inc --empty-implementation 0 && /usr/bin/cmake -E copy_if_different /root/llvm-compile-time-tracker/llvm-project-build/tools/clang/lib/Tooling/generated/NodeIntrospection.inc /root/llvm-compile-time-tracker/llvm-project-build/tools/clang/include/clang/Tooling/NodeIntrospection.inc
/bin/sh: 1: /root/llvm-compile-time-tracker/llvm-project/clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py: not found

This reverts commit cefe711135c40b6fb9670cf92118f94f88964b23.
This reverts commit f72f122feebe7f980c22ed4a7e04fc274ce2c976.
This reverts commit 970c21e345548a967c1bc000462198330982ed7e.
This reverts commit 77f7d2be214a1de29d583c75739f563593991fc3.

3 years agoFix license headers
Stephen Kelly [Sun, 14 Mar 2021 15:45:34 +0000 (15:45 +0000)]
Fix license headers

3 years ago[X86] Add test for PR49587 (NFC)
Nikita Popov [Sun, 14 Mar 2021 15:39:03 +0000 (16:39 +0100)]
[X86] Add test for PR49587 (NFC)

Shows a miscompile with FastISel.

3 years agoUpdate python script per review comments
Stephen Kelly [Sun, 14 Mar 2021 15:08:15 +0000 (15:08 +0000)]
Update python script per review comments

Wrap to 80 cols, introduce main() function and use argparse instead of
optparse.

3 years agoRemove unneeded targets dependency
Stephen Kelly [Sun, 14 Mar 2021 15:30:12 +0000 (15:30 +0000)]
Remove unneeded targets dependency

3 years ago[AArch64] Expand build-vector-extract.ll tests to i8's. NFC
David Green [Sun, 14 Mar 2021 15:29:14 +0000 (15:29 +0000)]
[AArch64] Expand build-vector-extract.ll tests to i8's. NFC

3 years ago[InstCombine] Restrict a GEP transform to avoid changing provenance
Simonas Kazlauskas [Sat, 13 Mar 2021 19:55:26 +0000 (21:55 +0200)]
[InstCombine] Restrict a GEP transform to avoid changing provenance

This is an alternative to D98120. Herein, instead of deleting the transformation entirely, we check
that the underlying objects are both the same and therefore this transformation wouldn't incur a
provenance change, if applied.

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

Reviewed By: lebedev.ri

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

3 years agoCodeGen: Reorder MachinePointerInfo fields
Matt Arsenault [Sun, 14 Mar 2021 13:45:36 +0000 (09:45 -0400)]
CodeGen: Reorder MachinePointerInfo fields

This saves a little bit of padding.

3 years ago[gn build] (manually) kind of merge d627a27d26
Nico Weber [Wed, 10 Mar 2021 23:57:52 +0000 (18:57 -0500)]
[gn build] (manually) kind of merge d627a27d26

This only merges the no-op generator part for now.

3 years ago[Clang][ARM] Reenable arm_acle.c test.
David Green [Sun, 14 Mar 2021 10:59:24 +0000 (10:59 +0000)]
[Clang][ARM] Reenable arm_acle.c test.

This test was apparently disabled in 6fcd4e080f09c9765d6, without any
sign of how it was going to be reenabled. This patch rewrites the test
to use update_cc_test_checks, with midend optimizations other that
mem2reg disabled.

The first attempt of this patch in 5ae949a9276542b46 failed on bots even
though it worked locally.  I've attempted to adjust the RUN lines and
made the test AArch64/ARM specific.

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

3 years ago[AST] Add generator for source location introspection
Stephen Kelly [Sat, 12 Dec 2020 13:17:49 +0000 (13:17 +0000)]
[AST] Add generator for source location introspection

Generate a json file containing descriptions of AST classes and their
public accessors which return SourceLocation or SourceRange.

Use the JSON file to generate a C++ API and implementation for accessing
the source locations and method names for accessing them for a given AST
node.

This new API can be used to implement 'srcloc' output in clang-query:

  http://ce.steveire.com/z/m_kTIo

In this first version of this feature, only the accessors for Stmt
classes are generated, not Decls, TypeLocs etc.  Those can be added
after this change is reviewed, as this change is mostly about
infrastructure of these code generators.

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

3 years ago[X86][AMX] Prevent transforming load pointer from <256 x i32>* to x86_amx*.
Luo, Yuanke [Tue, 9 Mar 2021 11:55:58 +0000 (19:55 +0800)]
[X86][AMX] Prevent transforming load pointer from <256 x i32>* to x86_amx*.

The load/store instruction will be transformed to amx intrinsics
in the pass of AMX type lowering. Prohibiting the pointer cast
make that pass happy.

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

3 years agoX86: adjust the windows 64 calling convention for Swift
Saleem Abdulrasool [Sun, 14 Mar 2021 00:50:23 +0000 (16:50 -0800)]
X86: adjust the windows 64 calling convention for Swift

Adjust the Win64 calling convention for Swift to pass self in R13, which
is traditionally a CSR.  This makes the behaviour similar to the SysV CC
for Swift as well.  This should improve the argument passing on Windows,
although it comes at a high cost of ABI incompatibility.  Fortunately in
this case, there is no guarantee of ABI stability, and so we can make
this incompatible change.

3 years ago[libc][Obvious] Fix except flags reading overflow detected by asan.
Siva Chandra Reddy [Sun, 14 Mar 2021 00:30:01 +0000 (16:30 -0800)]
[libc][Obvious] Fix except flags reading overflow detected by asan.

3 years agoRestore fixed version of "[CodeGenPrepare] Fix isIVIncrement (PR49466)"
Philip Reames [Sat, 13 Mar 2021 23:02:48 +0000 (15:02 -0800)]
Restore fixed version of "[CodeGenPrepare] Fix isIVIncrement (PR49466)"

Change was reverted in commit 8d20f2c2c66eb486ff23cc3d55a53bd840b36971 because it was causing an infinite loop.  9228f2f32 fixed the root issue in the code structure, this change just reapplies the original change w/adaptation to the new code structure.

3 years ago[CGP] Consolidate logic for getIVIncrement and isIVIncrement
Philip Reames [Sat, 13 Mar 2021 22:37:15 +0000 (14:37 -0800)]
[CGP] Consolidate logic for getIVIncrement and isIVIncrement

This fixes the bug demonstrated by the test case in the commit message of 8d20f2c2 (which was a revert of cf82700).  The root issue was that we have two transforms which are inverses of each other.  We use one for simple induction variables (where we can use the post-inc form), and the other for everything else.  The problem was that the two transforms could disagree about whether something was an induction variable.

The reverted commit made a change to one of the matcher routines which was used for one of the two transforms without updating the other matcher.  However, it's worth noting the existing code w/o the reverted change also has cases where the decision could differ between the two paths.

The fix is simply to consolidate the code such that two paths must agree by construction, and to add an assert to catch any potential future re-divergence.

Triggering the infinite loop requires side stepping the SunkAddrs cache.  The SunkAddrs cache has the effect of suppressing the iteration in the common case, but there are codepaths through CGP which restart iteration and clear this cache.

Unfortunately, I have not been able to construct a standalone IR test case for this.  The original test case is a c++ program which when compiled by clang demonstrates the infinite loop, but all of my attempts at extracting an IR test case runnable through opt/llc have failed to reproduce.  (Including capturing the IR at point of the transform itself!)  I have no idea what weird state clang is creating here.

I also tried creating a test case by hand, but gave up after about an hour of trying to find the right combination to dance through multiple transforms to create the end result needed to trip the bug.

3 years ago[flang][OpenMP] Add support for getting parent context and clauses and modify the...
Arnamoy Bhattacharyya [Sat, 13 Mar 2021 14:27:53 +0000 (09:27 -0500)]
[flang][OpenMP] Add support for getting parent context and clauses and modify the relevant sema checks to use the new functions.

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

3 years ago[lld-macho][nfc] Move list of section names into InputSection.h
Jez Ng [Sat, 13 Mar 2021 22:41:44 +0000 (17:41 -0500)]
[lld-macho][nfc] Move list of section names into InputSection.h

They were previously in SyntheticSections.h, but now there are
a bunch of non-synthetic section names in the list.

Also renamed `__functionStarts` to `__func_starts` for uniformity with
other section names + keeps the name under 16 characters (in case we ever
want to write it out as a real section).

Reviewed By: #lld-macho, compnerd

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

3 years ago[InstCombine] Update GEP tests
Simonas Kazlauskas [Sat, 13 Mar 2021 21:38:53 +0000 (23:38 +0200)]
[InstCombine] Update GEP tests

Adds a test for D98588 and updates the test checks.

3 years ago[SROA] Regenerate test checks (NFC)
Nikita Popov [Sat, 13 Mar 2021 14:59:09 +0000 (15:59 +0100)]
[SROA] Regenerate test checks (NFC)

3 years ago[compiler-rt] Use arm-specific builtins sources for arm/mingw builds
Martin Storsjö [Thu, 11 Mar 2021 20:17:48 +0000 (22:17 +0200)]
[compiler-rt] Use arm-specific builtins sources for arm/mingw builds

Previously, that configuration only used the generic sources, in
addition to the couple specifically chosen arm/mingw files.

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

3 years ago[MemCpyOpt] Handle read from lifetime.start with offset
Nikita Popov [Sat, 13 Mar 2021 19:28:53 +0000 (20:28 +0100)]
[MemCpyOpt] Handle read from lifetime.start with offset

This fixes a regression from the MemDep-based implementation:
MemDep completely ignores lifetime.start intrinsics that aren't
MustAlias -- this is probably unsound, but it does mean that the
MemDep based implementation successfully eliminated memcpy's from
lifetime.start if the memcpy happens at an offset, rather than
the base address of the alloca.

Add a special case for the case where the lifetime.start spans the
whole alloca (which is pretty much the only kind of lifetime.start
that frontends ever emit), as we don't need to figure out our exact
aliasing relationship in that case, the whole alloca is dead prior
to the call.

If this doesn't cover all practically relevant cases, then it
would be possible to make use of the recently added PartialAlias
clobber offsets to make this more precise.

3 years ago[MemCpyOpt] Add additional tests for memcpy of undef (NFC)
Nikita Popov [Sat, 13 Mar 2021 17:51:46 +0000 (18:51 +0100)]
[MemCpyOpt] Add additional tests for memcpy of undef (NFC)

3 years ago[DAGCombiner] Optimize 1-bit smulo to AND+SETNE.
Craig Topper [Sat, 13 Mar 2021 17:39:33 +0000 (09:39 -0800)]
[DAGCombiner] Optimize 1-bit smulo to AND+SETNE.

A 1-bit smulo overflows is both inputs are -1 since the result
should be +1 which can't be represented in a signed 1 bit value.

We can detect this with an AND and a setcc. The multiply result
can also use the same AND.

Reviewed By: RKSimon

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

3 years ago[Orc] Deallocate debug objects properly when removing resources from DebugObjectManag...
Stefan Gränitz [Sat, 13 Mar 2021 15:25:41 +0000 (16:25 +0100)]
[Orc] Deallocate debug objects properly when removing resources from DebugObjectManagerPlugin

3 years ago[Attributor][fix] Remove problematic EXPENSIVE_CHECK
kuterd [Sat, 13 Mar 2021 14:46:38 +0000 (17:46 +0300)]
[Attributor][fix] Remove problematic EXPENSIVE_CHECK

Remove the check that is causing compilation issues in
some build configurations.

3 years ago[InstCombine] avoid creating an extra instruction in zext fold and possible inf-loop
Sanjay Patel [Sat, 13 Mar 2021 13:26:27 +0000 (08:26 -0500)]
[InstCombine] avoid creating an extra instruction in zext fold and possible inf-loop

The structure of this fold is suspect vs. most of instcombine
because it creates instructions and tries to delete them
immediately after.

If we don't have the operand types for the icmps, then we are
not behaving as assumed. And as shown in PR49475, we can inf-loop.

3 years agoReland [SCEV] Improve modelling for (null) pointer constants
Roman Lebedev [Sat, 13 Mar 2021 06:12:26 +0000 (09:12 +0300)]
Reland [SCEV] Improve modelling for (null) pointer constants

This reverts commit 329aeb5db43f5e69df038fb20d2def77fe6f8595,
and relands commit 61f006ac655431bd44b9e089f74c73bec0c1a48c.

This is a continuation of D89456.

As it was suggested there, now that SCEV models `PtrToInt`,
we can try to improve SCEV's pointer handling.
In particular, i believe, i will need this in the future
to further fix `SCEVAddExpr`operation type handling.

This removes special handling of `ConstantPointerNull`
from `ScalarEvolution::createSCEV()`, and add constant folding
into `ScalarEvolution::getPtrToIntExpr()`.
This way, `null` constants stay as such in SCEV's,
but gracefully become zero integers when asked.

Reviewed By: Meinersbur

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

3 years ago[LSR] Don't try to fixup uses in 'EH pad' instructions
Roman Lebedev [Sat, 13 Mar 2021 12:11:12 +0000 (15:11 +0300)]
[LSR] Don't try to fixup uses in 'EH pad' instructions

The added test case crashes before this fix:
```
opt: /repositories/llvm-project/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:5172: BasicBlock::iterator (anonymous namespace)::LSRInstance::AdjustInsertPositionForExpand(BasicBlock::iterator, const (anonymous namespace)::LSRFixup &, const (anonymous namespace)::LSRUse &, llvm::SCEVExpander &) const: Assertion `!isa<PHINode>(LowestIP) && !LowestIP->isEHPad() && !isa<DbgInfoIntrinsic>(LowestIP) && "Insertion point must be a normal instruction"' failed.
```
This is fully analogous to the previous commit,
with the pointer constant replaced to be something non-null.

The comparison here can be strength-reduced,
but the second operand of the comparison happens to be identical
to the constant pointer in the `catch` case of `landingpad`.

While LSRInstance::CollectLoopInvariantFixupsAndFormulae()
already gave up on uses in blocks ending up with EH pads,
it didn't consider this case.

Eventually, `LSRInstance::AdjustInsertPositionForExpand()`
will be called, but the original insertion point it will get
is the user instruction itself, and it doesn't want to
deal with EH pads, and asserts as much.

It would seem that this basically never happens in-the-wild,
otherwise it would have been reported already,
so it seems safe to take the cautious approach,
and just not deal with such users.

3 years ago[NFC][LSR] Add test case that from https://reviews.llvm.org/D98147#2623549
Roman Lebedev [Sat, 13 Mar 2021 08:27:48 +0000 (11:27 +0300)]
[NFC][LSR] Add test case that from https://reviews.llvm.org/D98147#2623549

With that patch, this test fails with an assertion
```
opt: /repositories/llvm-project/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:5169: BasicBlock::iterator (anonymous namespace)::LSRInstance::AdjustInsertPositionForExpand(BasicBlock::iterator, const (anonymous namespace)::LSRFixup &, const (anonymous namespace)::LSRUse &, llvm::SCEVExpander &) const: Assertion `!isa<PHINode>(LowestIP) && !LowestIP->isEHPad() && !isa<DbgInfoIntrinsic>(LowestIP) && "Insertion point must be a normal instruction"' failed.
```

3 years ago[libomptarget] Add allocator support for target memory
George Rokos [Wed, 3 Mar 2021 19:48:32 +0000 (11:48 -0800)]
[libomptarget] Add allocator support for target memory

This patch adds the infrastructure for allocator support for target memory.
Three allocators are introduced for device, host and shared memory.
The corresponding API functions have the llvm_ prefix temporarily, until they become part of the OpenMP standard.

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

3 years ago[MemCpyOpt] Use AA to check for MustAlias between memset and memcpy
Nikita Popov [Sat, 13 Mar 2021 10:37:31 +0000 (11:37 +0100)]
[MemCpyOpt] Use AA to check for MustAlias between memset and memcpy

Rather than checking for simple equality, check for MustAlias, as
we do in other transforms. This catches equivalent GEPs.

3 years ago[MemCpyOpt] Don't generate zero-size memset
Nikita Popov [Sat, 13 Mar 2021 10:34:58 +0000 (11:34 +0100)]
[MemCpyOpt] Don't generate zero-size memset

If a memset destination is overwritten by a memcpy and the sizes
are exactly the same, then the memset is simply dead. We can
directly drop it, instead of replacing it with a memset of zero
size, which is particularly ugly for the case of a dynamic size.

3 years ago[MemCpyOpt] Add additional tests for memset+memcpy overwrite (NFC)
Nikita Popov [Sat, 13 Mar 2021 10:32:24 +0000 (11:32 +0100)]
[MemCpyOpt] Add additional tests for memset+memcpy overwrite (NFC)

3 years ago[MemorySSA] Don't bail on phi starting access
Nikita Popov [Fri, 12 Mar 2021 22:03:36 +0000 (23:03 +0100)]
[MemorySSA] Don't bail on phi starting access

When calling getClobberingMemoryAccess() with MemoryLocation on a
MemoryPHI starting access, the walker currently immediately bails
and returns the starting access. This makes sense for the API that
does not accept a location (as we wouldn't know what clobber we
should be checking for), but doesn't make sense for the
MemoryLocation-based API. This means that it can't look through
a MemoryPHI if it's the starting access, but can if there is one
more non-clobbering def in between. This patch removes the limitation.

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

3 years agochange rvv frame layout
luxufan [Sat, 20 Feb 2021 06:02:56 +0000 (14:02 +0800)]
change rvv frame layout

This patch change the rvv frame layout that proposed in D94465. In patch D94465, In the eliminateFrameIndex function,
to eliminate the rvv frame index, create temp virtual register is needed. This virtual register should be scavenged by class
RegsiterScavenger. If the machine function has other unused registers, there is no problem. But if there isn't unused registers,
we need a emergency spill slot. Because of the emergency spill slot belongs to the scalar local variables field, to access emergency
spill slot, we need a temp virtual register again. This makes the compiler report the "Incomplete scavenging after 2nd pass" error.
So I change the rvv frame layout as follows:

```
|--------------------------------------|
|   arguments passed on the stack      |
|--------------------------------------|<--- fp
|   callee saved registers             |
|--------------------------------------|
|   rvv vector objects(local variables |
|   and outgoing arguments             |
|--------------------------------------|
|   realignment field                  |
|--------------------------------------|
|   scalar local variable(also contains|
|   emergency spill slot)              |
|--------------------------------------|<--- bp
|   variable-sized local variables     |
|--------------------------------------|<--- sp
```

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

3 years ago[RISCV] Remove redundancy -mattr=+d in test file
luxufan [Mon, 22 Feb 2021 05:46:46 +0000 (13:46 +0800)]
[RISCV] Remove redundancy -mattr=+d in test file

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