platform/upstream/llvm.git
2 years ago[Thumb2] Regenerate test checks (NFC)
Nikita Popov [Mon, 10 Jan 2022 15:12:29 +0000 (16:12 +0100)]
[Thumb2] Regenerate test checks (NFC)

2 years ago[clang][dataflow] Change `transfer` function to update lattice element in place.
Yitzhak Mandelbaum [Fri, 7 Jan 2022 19:39:12 +0000 (19:39 +0000)]
[clang][dataflow] Change `transfer` function to update lattice element in place.

Currently, the transfer function returns a new lattice element, which forces an
unnecessary copy on processing each CFG statement.

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

2 years ago[mlir][linalg][bufferize][NFC] Pass missing BufferizationState objs as const ref
Matthias Springer [Mon, 10 Jan 2022 14:36:46 +0000 (23:36 +0900)]
[mlir][linalg][bufferize][NFC] Pass missing BufferizationState objs as const ref

These should have been updated as part of D116742.

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

2 years ago[mlir][Linalg] Disable init_tensor elimination by default
Nicolas Vasilache [Mon, 10 Jan 2022 14:03:23 +0000 (09:03 -0500)]
[mlir][Linalg] Disable init_tensor elimination by default

init_tensor elimination is arguably a pre-optimization that should be separated from comprehensive bufferization.
In any case it is still experimental and easily results in wrong IR with violated SSA def-use orderings.
Isolate the optimization behind a flag, separate the test cases and add a test case that would results in wrong IR.

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

2 years agoRevert "[AST] Add RParen loc for decltype AutoTypeloc."
Haojian Wu [Mon, 10 Jan 2022 14:09:17 +0000 (15:09 +0100)]
Revert "[AST] Add RParen loc for decltype AutoTypeloc."

This breaks a clang-tidy check, needs to investigate and fix. Revert
them to bring the buildbot back.

This reverts commit 55d96ac3dc56bdebea854952a724c2a50d96ce19 and
37ec65e1d705f56fe5551de1dfcbac1e071588a2

2 years ago[LoopVectorize] Make VPWidenCanonicalIVRecipe::execute work for scalable vectors
David Sherwood [Wed, 3 Nov 2021 17:09:34 +0000 (17:09 +0000)]
[LoopVectorize] Make VPWidenCanonicalIVRecipe::execute work for scalable vectors

The code in VPWidenCanonicalIVRecipe::execute only worked for fixed-width
vectors due to the way we generate the values per lane. This patch changes
the code to use a combination of vector splats and step vectors to get
the same result. This then works for both fixed-width and scalable vectors.

Tests that exercise this code path for scalable vectors have been added here:

  Transforms/LoopVectorize/AArch64/sve-tail-folding.ll

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

2 years ago[SROA] Switch replacement of dead/UB/unreachable ops from undef to poison
Nuno Lopes [Mon, 10 Jan 2022 13:11:44 +0000 (13:11 +0000)]
[SROA] Switch replacement of dead/UB/unreachable ops from undef to poison

SROA has 3 data-structures where it stores sets of instructions that should
be deleted:
 - DeadUsers -> instructions that are UB or have no users
 - DeadOperands -> instructions that are UB or operands of useless phis
 - DeadInsts -> "dead" instructions, including loads of uninitialized memory
with users

The first 2 sets can be RAUW with poison instead of undef. No brainer as UB
can be replaced with poison, and for instructions with no users RAUW is a
NOP.

The 3rd case cannot be currently replaced with poison because the set mixes
the loads of uninit memory. I leave that alone for now.

Another case where we can use poison is in the construction of vectors from
multiple loads. The base vector for the first insertelement is now poison as
it doesn't matter as it is fully overwritten by inserts.

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

2 years ago[CodeGen] Avoid some pointer element type accesses
Nikita Popov [Mon, 10 Jan 2022 13:58:38 +0000 (14:58 +0100)]
[CodeGen] Avoid some pointer element type accesses

Possibly this is sufficient to fix PR53089.

2 years ago[libc++] Refactor the test for join_view's default constructor
Louis Dionne [Wed, 15 Dec 2021 16:35:09 +0000 (11:35 -0500)]
[libc++] Refactor the test for join_view's default constructor

In particular, this removes the need for adding a ad-hoc `operator==`
to forward_iterator.

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

2 years agoUse a sorted array instead of a map to store AttrBuilder string attributes
Serge Guelton [Mon, 3 Jan 2022 18:32:19 +0000 (13:32 -0500)]
Use a sorted array instead of a map to store AttrBuilder string attributes

Using and std::map<SmallString, SmallString> for target dependent attributes is
inefficient: it makes its constructor slightly heavier, and involves extra
allocation for each new string attribute. Storing the attribute key/value as
strings implies extra allocation/copy step.

Use a sorted vector instead. Given the low number of attributes generally
involved, this is cheaper, as showcased by

https://llvm-compile-time-tracker.com/compare.php?from=5de322295f4ade692dc4f1823ae4450ad3c48af2&to=05bc480bf641a9e3b466619af43a2d123ee3f71d&stat=instructions

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

2 years ago[TypeFinder] Support opaque pointers
Nikita Popov [Mon, 10 Jan 2022 09:40:33 +0000 (10:40 +0100)]
[TypeFinder] Support opaque pointers

We need to explicitly visit a number of types, as these are no
longer reachable through the pointer type if opaque pointers are
enabled. This is similar to ValueEnumerator changes that have
been done previously.

2 years agoset __NO_MATH_ERRNO__ if -fno-math-errno
Alex Xu (Hello71) [Mon, 10 Jan 2022 13:44:44 +0000 (08:44 -0500)]
set __NO_MATH_ERRNO__ if -fno-math-errno

This causes modern glibc to unset math_errhandling MATH_ERRNO. gcc 12
also sets some other macros, but most of them are associated with
flags ignored by clang, so without library examples, it is difficult to
determine whether they should be set. I think setting this one macro is
OK for now.

2 years ago[libc++] Add missing `return 0` to main() functions in the tests
Louis Dionne [Mon, 10 Jan 2022 13:37:54 +0000 (08:37 -0500)]
[libc++] Add missing `return 0` to main() functions in the tests

2 years ago[mlir][linalg][bufferize][NFC] Update comments in BufferizableOpInterface
Matthias Springer [Mon, 10 Jan 2022 13:31:49 +0000 (22:31 +0900)]
[mlir][linalg][bufferize][NFC] Update comments in BufferizableOpInterface

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

2 years ago[libc++] Fix link to bug tracker
Louis Dionne [Mon, 10 Jan 2022 13:33:14 +0000 (08:33 -0500)]
[libc++] Fix link to bug tracker

2 years ago[CostModel][X86] Update ROTL/ROTR vXi8/vXi16 costs on AVX512BW targets
Simon Pilgrim [Mon, 10 Jan 2022 12:40:02 +0000 (12:40 +0000)]
[CostModel][X86] Update ROTL/ROTR vXi8/vXi16 costs on AVX512BW targets

Refresh based off recent improvements to codegen and the helper script from D103695

2 years ago[libc++] Fix the documentation and re-enable documentation CI
Louis Dionne [Sun, 9 Jan 2022 19:40:10 +0000 (14:40 -0500)]
[libc++] Fix the documentation and re-enable documentation CI

The documentation CI job is very cheap, so we can afford to keep it
around even with reduced capacity. This commit fixes the documentation
(which had an invalid reference in it) and re-enables that CI step.

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

2 years ago[mlir][linalg][bufferize][NFC] Clean up bufferization entry point
Matthias Springer [Mon, 10 Jan 2022 12:40:05 +0000 (21:40 +0900)]
[mlir][linalg][bufferize][NFC] Clean up bufferization entry point

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

2 years ago[clangd] Enable expand-auto for decltype(auto).
Haojian Wu [Mon, 10 Jan 2022 09:10:41 +0000 (10:10 +0100)]
[clangd] Enable expand-auto for decltype(auto).

Based on https://reviews.llvm.org/D116919.

Fixes https://github.com/clangd/clangd/issues/121

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

2 years ago[llvm-objcopy] Implement the PE-COFF specific --subsystem option
Martin Storsjö [Mon, 3 Jan 2022 13:51:37 +0000 (15:51 +0200)]
[llvm-objcopy] Implement the PE-COFF specific --subsystem option

This implements the parsing of the highly PE-COFF specific option
in ConfigManager.cpp, setting Optional<> values in COFFConfig, which
then are used in COFFObjcopy.

This should fix https://github.com/mstorsjo/llvm-mingw/issues/239.

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

2 years agoAArch64: don't claim to preserve registers used by prologue code
Tim Northover [Tue, 16 Nov 2021 12:26:16 +0000 (12:26 +0000)]
AArch64: don't claim to preserve registers used by prologue code

2 years agoAMDGPU/GlobalISel: Rework legalization for extract/insert vector elt
Petar Avramovic [Mon, 10 Jan 2022 12:14:28 +0000 (13:14 +0100)]
AMDGPU/GlobalISel: Rework legalization for extract/insert vector elt

Use G_MERGE_VALUES and G_UNMERGE_VALUES on vector elements instead of
G_EXTRACT and G_INSERT when doing custom legalization for
G_EXTRACT_VECTOR_ELT and G_INSERT_VECTOR_ELT.
With this approach legalization artifact combiner gets direct access
to all vector elements.

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

2 years ago[SROA] Reduce the number of times a IRBuilder is constructed (NFC).
Florian Hahn [Mon, 10 Jan 2022 12:09:13 +0000 (12:09 +0000)]
[SROA] Reduce the number of times a IRBuilder is constructed (NFC).

This patch reduces the number of times IRBuilders need to be constructed
in SROA.cpp by passing existing ones by reference to the appropriate
places.

2 years ago[AST] Add RParen loc for decltype AutoTypeloc.
Haojian Wu [Fri, 7 Jan 2022 23:12:18 +0000 (00:12 +0100)]
[AST] Add RParen loc for decltype AutoTypeloc.

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

2 years ago[AST] Use recovery-expr to preserve incomplete-type-member-access expression.
Haojian Wu [Fri, 7 Jan 2022 21:55:58 +0000 (22:55 +0100)]
[AST] Use recovery-expr to preserve incomplete-type-member-access expression.

Fixes https://github.com/clangd/clangd/issues/502

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

2 years ago[mlir] address post-commit review for D116759
Alex Zinenko [Mon, 10 Jan 2022 11:40:38 +0000 (12:40 +0100)]
[mlir] address post-commit review for D116759

2 years ago[SCEVExpander] Only create trunc when needed.
Florian Hahn [Mon, 10 Jan 2022 11:31:26 +0000 (11:31 +0000)]
[SCEVExpander] Only create trunc when needed.

9345ab3a4550 updated generateOverflowCheck to skip creating checks that
always evaluate to false. This in turn means that we only need to
create TruncTripCount if it is actually used.

Sink the TruncTripCount creating into ComputeEndCheck, so it is only
created when there's an actual check.

2 years ago[Dexter] Allow tests to specify command line options
Jeremy Morse [Mon, 10 Jan 2022 11:22:51 +0000 (11:22 +0000)]
[Dexter] Allow tests to specify command line options

This patch adds a "DexCommandLine" command, allowing dexter tests to
specify what command line options the test should be started with. I've
also plumbed it through into the debuggers.

This eases the matter of pointing Dexter at larger tests, or controlling
different paths through a single binary from a Dexter test.

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

2 years ago[Clang][AArch64][ARM] PMUv3.4 Option Added
Mubashar Ahmad [Wed, 5 Jan 2022 16:53:59 +0000 (16:53 +0000)]
[Clang][AArch64][ARM] PMUv3.4 Option Added

An option has been added to Clang to enable or disable
the PMU v3.4 architecture extension.

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

2 years ago[clangd] Include fixer for missing functions in C
Sam McCall [Fri, 10 Dec 2021 03:17:50 +0000 (04:17 +0100)]
[clangd] Include fixer for missing functions in C

A function call `unresolved()` in C will generate an implicit declaration
of the missing function and warn `ext_implicit_function_decl` or so.
(Compared to in C++ where we get `err_undeclared_var_use`).
We want to try to resolve these names.

Unfortunately typo correction is disabled in sema for performance
reasons unless this warning is promoted to error.
(We need typo correction for include-fixer.)
It's not clear to me where a switch to force this correction on should
go, include-fixer is kind of a hack. So hack more by telling sema we're
promoting them to error.

Fixes https://github.com/clangd/clangd/issues/937

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

2 years ago[mlir] Don't inline calls from dead SCCs
Alex Zinenko [Mon, 10 Jan 2022 10:39:06 +0000 (11:39 +0100)]
[mlir] Don't inline calls from dead SCCs

During iterative inlining of the functions in a multi-step call chain, the
inliner could add the same call operation several times to the worklist, which
led to use-after-free when this op was considered more than once.

Closes #52887.

Reviewed By: wsmoses

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

2 years agoRevert "[LoopFlatten] Move it to a LoopPassManager"
David Green [Mon, 10 Jan 2022 11:03:49 +0000 (11:03 +0000)]
Revert "[LoopFlatten] Move it to a LoopPassManager"

This commit caused performance regressions due to differences in the
expected code during loop flattening. Reverting it until the fix is
ready, which hopefully wont take too long.

This reverts commit 86825fc2fb363b807569327880c05e4b0b5393ec.

2 years ago[mlir][memref] Tighten verification of memref.reinterpret_cast
Stephan Herhut [Fri, 7 Jan 2022 08:53:14 +0000 (09:53 +0100)]
[mlir][memref] Tighten verification of memref.reinterpret_cast

We allow the omission of a map in memref.reinterpret_cast under the assumption,
that the cast might cast to an identity layout. This change adds verification
that the static knowledge that is present in the reinterpret_cast supports
this assumption.

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

2 years ago[LoopVectorize] Add support for tail folding using scalable vectors
David Sherwood [Tue, 26 Oct 2021 08:55:30 +0000 (09:55 +0100)]
[LoopVectorize] Add support for tail folding using scalable vectors

This patch fixes up an issue with InnerLoopVectorizer::getOrCreateVectorTripCount
whereby we weren't correctly generating the runtime trip count
for scalable vectors when tail-folding.

It also removes some asserts in the tail-folding path for cases when
the VF is not scalable.

In this patch I have only permitted tail-folding to be enabled
explicitly for scalable vectors when the user has specified one
of the following flags:

  -prefer-predicate-over-epilogue=predicate-dont-vectorize
  -prefer-predicate-over-epilogue=predicate-else-scalar-epilogue

For now it's best not to enable tail-folding with scalable vectors for
low trip counts or when optimising for code size, since there has been
no analysis on whether this is worth it.

Various tests have been added here:

  Transforms/LoopVectorize/AArch64/sve-tail-folding.ll
  Transforms/LoopVectorize/AArch64/sve-tail-folding-forced.ll

The tests cannot be target independent because they require masked
load/store support, i.e. TTI.isLegalMaskedLoad and TTI.isLegalMaskedStore
need to return true.

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

2 years ago[AArch64][SVE] Fold predicate into compare
Cullen Rhodes [Mon, 10 Jan 2022 10:21:52 +0000 (10:21 +0000)]
[AArch64][SVE] Fold predicate into compare

Codegen of added testcase before this patch:

  ptrue   p0.s
  cmpgt   p1.s, p0/z, z0.s, z1.s
  cmpge   p2.s, p0/z, z2.s, z1.s
  and     p0.b, p0/z, p1.b, p2.b
  ret

Patterns originally authored by Will Lovett.

Reviewed By: david-arm

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

2 years ago[mlir][OpenMP] Change the syntax of omp.atomic.read op
Shraiysh Vaishay [Mon, 10 Jan 2022 09:56:20 +0000 (15:26 +0530)]
[mlir][OpenMP] Change the syntax of omp.atomic.read op

This patch changes the syntax of omp.atomic.read to take the address of
destination, instead of having the value in a result. This will allow
using omp.atomic.read operation within an omp.atomic.capture operation
thus making its implementation less complex.

Reviewed By: peixin

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

2 years ago[NFC] Add tests for splats of illegal integer vector types
David Sherwood [Fri, 7 Jan 2022 14:01:29 +0000 (14:01 +0000)]
[NFC] Add tests for splats of illegal integer vector types

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

2 years ago[clangd] Support configuration of inlay hints.
Sam McCall [Thu, 6 Jan 2022 01:01:13 +0000 (02:01 +0100)]
[clangd] Support configuration of inlay hints.

The idea is that the feature will always be advertised at the LSP level, but
depending on config we'll return partial or no responses.

We try to avoid doing the analysis for hints we're not going to return.

Examples of syntax:
```
InlayHints:
  Enabled: No
---
InlayHints:
  ParameterNames: No
---
InlayHints:
  ParameterNames: Yes
  DeducedTypes: Yes
```

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

2 years ago[Parse] Use empty RecoveryExpr when if/while/do/switch conditions fail to parse
Sam McCall [Thu, 11 Nov 2021 14:27:10 +0000 (15:27 +0100)]
[Parse] Use empty RecoveryExpr when if/while/do/switch conditions fail to parse

This allows the body to be parsed.
An special-case that would replace a missing if condition with OpaqueValueExpr
was removed as it's now redundant (unless recovery-expr is disabled).

For loops are not handled at this point, as the parsing is more complicated.

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

2 years ago[SCEVExpander] Only create multiplication if needed.
Florian Hahn [Mon, 10 Jan 2022 08:39:12 +0000 (08:39 +0000)]
[SCEVExpander] Only create multiplication if needed.

9345ab3a4550 updated generateOverflowCheck to skip creating checks that
always evaluate to false. This in turn means that we only need to
compute |Step| * Trip count  if the result of the multiplication is
actually used.

Sink the multiplication into ComputeEndCheck, so it is only created
when there's an actual check.

2 years ago[gn build] Port c0fdc748871f
LLVM GN Syncbot [Mon, 10 Jan 2022 08:36:39 +0000 (08:36 +0000)]
[gn build] Port c0fdc748871f

2 years ago[AST] Add more source information for DecltypeTypeLoc.
Haojian Wu [Thu, 6 Jan 2022 19:46:33 +0000 (20:46 +0100)]
[AST] Add more source information for DecltypeTypeLoc.

Adds the paren source location, and removes the hack in clangd.

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

2 years ago[clang-format] Ensure we can correctly parse lambda in the template argument list
mydeveloperday [Mon, 10 Jan 2022 08:28:42 +0000 (08:28 +0000)]
[clang-format] Ensure we can correctly parse lambda in the template argument list

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

The presence of a lambda in an argument template list ignored the [] as a lambda at all, this caused the contents of the <> to be incorrectly analyzed.

```
struct Y : X < [] {
  return 0;
} > {};
```
Fixes: #46505

Reviewed By: curdeius

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

2 years ago[ORC][JITLink] Add dependence on OrcShared to JITLink.
Lang Hames [Mon, 10 Jan 2022 08:24:38 +0000 (19:24 +1100)]
[ORC][JITLink] Add dependence on OrcShared to JITLink.

JITLink depends on OrcShared as of c0fdc748871. This should fix the build
failure at https://lab.llvm.org/buildbot#builders/61/builds/19796.

2 years ago[lld-macho] Fix shadowed variable
Vincent Lee [Mon, 10 Jan 2022 08:07:42 +0000 (00:07 -0800)]
[lld-macho] Fix shadowed variable

This fixes a windows build failure from D115416.

2 years ago[MemoryBuiltins] Remove isNoAliasFn() in favor of isNoAliasCall()
Nikita Popov [Fri, 7 Jan 2022 08:57:53 +0000 (09:57 +0100)]
[MemoryBuiltins] Remove isNoAliasFn() in favor of isNoAliasCall()

We currently have two similar implementations of this concept:
isNoAliasCall() only checks for the noalias return attribute.
isNoAliasFn() also checks for allocation functions.

We should switch to only checking the attribute. SLC is responsible
for inferring the noalias return attribute for non-new allocation
functions (with a missing case fixed in
https://github.com/llvm/llvm-project/commit/348bc76e3548c52dbcd442590ca0a7f5b09b7534).
For new, clang is responsible for setting the attribute,
if -fno-assume-sane-operator-new is not passed.

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

2 years ago[ORC] Add helper functions for running finalize / dealloc actions.
Lang Hames [Mon, 10 Jan 2022 08:08:59 +0000 (19:08 +1100)]
[ORC] Add helper functions for running finalize / dealloc actions.

runFinalizeActions takes an AllocActions vector and attempts to run its finalize
actions. If any finalize action fails then all paired dealloc actions up to the
failing pair are run, and the error(s) returned. If all finalize actions succeed
then a vector containing the dealloc actions is returned.

runDeallocActions takes a vector<WrapperFunctionCall> containing dealloc action
calls and runs them all, returning any error(s).

These helpers are intended to simplify the implementation of
JITLinkMemoryManager::InFlightAlloc::finalize and
JITLinkMemoryManager::deallocate overrides by taking care of execution (and
potential roll-back) of allocation actions.

2 years ago[RISCV] Generalize (srl (and X, 0xffff), C) -> (srli (slli X, (XLen-16), (XLen-16...
Craig Topper [Mon, 10 Jan 2022 07:23:45 +0000 (23:23 -0800)]
[RISCV] Generalize (srl (and X, 0xffff), C) -> (srli (slli X, (XLen-16), (XLen-16) + C) optimization.

This can be generalized to (srl (and X, C2), C) ->
(srli (slli X, (XLen-C3), (XLen-C3) + C). Where C2 is a mask with
C3 trailing ones.

This can avoid constant materialization for C2. This is beneficial
even when C2 can be selected to ANDI because the SLLI can become
C.SLLI, but C.ANDI cannot cover all the immediates of ANDI.

This also enables CSE in some cases of i8 sdiv by constant codegen.

2 years agoFix exported MLIR_TABLEGEN_EXE
Stephen Neuendorffer [Mon, 10 Jan 2022 06:16:58 +0000 (22:16 -0800)]
Fix exported MLIR_TABLEGEN_EXE

LLVM_OPTIMIZED_TABLEGEN results in MLIR_TABLEGEN_EXE pointing to
an absolute path in the build directory.  This doesn't work
when exporting to an install directory.  This patch fixes the exported
information for an install directory to refer to the installed
mlir-tblgen.  (Note that this is probably a debug version if
LLVM_OPTIMIZED_TABLEGEN is set)

2 years ago[SchedModels][CortexA55] Fix scheduling of FP loads
Pavel Kosov [Mon, 10 Jan 2022 06:57:13 +0000 (09:57 +0300)]
[SchedModels][CortexA55] Fix scheduling of FP loads

Patch fixes scheduling of FP load instructions with pre/post increment adding WriteAdr for address operand.

Reviewed By: dmgreen

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

OS Laboratory. Huawei Russian Research Institute. Saint-Petersburg

2 years ago[lldb] Remove LLDB_RECORD_RESULT macro
Jonas Devlieghere [Mon, 10 Jan 2022 06:54:08 +0000 (22:54 -0800)]
[lldb] Remove LLDB_RECORD_RESULT macro

2 years ago[lldb] Skip TestTargetXMLArch if no support for x86 target
Dave Lee [Mon, 10 Jan 2022 06:34:47 +0000 (22:34 -0800)]
[lldb] Skip TestTargetXMLArch if no support for x86 target

If LLVM is configured without X86 as one of its TARGETS_TO_BUILD, then lldb
will crash when using X86 disassembler (which it does while running `image
show-unwind`).

2 years ago[CSKY] Lower leaf DAG node such as global symbol, frame address and jumptable, etc.
Zi Xuan Wu [Thu, 6 Jan 2022 09:21:49 +0000 (17:21 +0800)]
[CSKY] Lower leaf DAG node such as global symbol, frame address and jumptable, etc.

Lower global symbols such as call/external symbol.
Lower other leaf DAG node such as frame address/block address/jumptable/vastart.

Normally some leaf symbols need reside in constant pool as ABI prefers, and are addressed by
lrw or jsri instructions.

Every symbol in constant pool is lowered with one entry in target constant pool. The
entry has different type corresponding to different leaf node such as blockaddress,
jumptable, or global value.

2 years ago[libc] Re-enable thrd_test.
Siva Chandra Reddy [Mon, 10 Jan 2022 05:51:30 +0000 (05:51 +0000)]
[libc] Re-enable thrd_test.

Other threads related tests have been using the API that is tested here
without any problems. The main reason for disabling the test has also been
fixed many months ago.

2 years ago[lldb] Skip TestVSCode_coreFile if no x86 target support
Dave Lee [Mon, 10 Jan 2022 06:01:02 +0000 (22:01 -0800)]
[lldb] Skip TestVSCode_coreFile if no x86 target support

2 years ago[lldb] Remove reproducer instrumentation
Jonas Devlieghere [Sat, 8 Jan 2022 00:26:40 +0000 (16:26 -0800)]
[lldb] Remove reproducer instrumentation

This patch removes most of the reproducer instrumentation. It keeps
around the LLDB_RECORD_* macros for logging. See [1] for more details.

[1] https://lists.llvm.org/pipermail/lldb-dev/2021-September/017045.html

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

2 years ago[lldb] Guard libstdc++ specific 'frame var' test
Dave Lee [Sun, 9 Jan 2022 23:01:53 +0000 (15:01 -0800)]
[lldb] Guard libstdc++ specific 'frame var' test

While working on D116788 (properly error out of `frame var`), this libstdc++
specific `frame var` invocation was found in the tests. This test is in the
generic directory, but has this one case that requires libstdc++. The fix here
is to put the one `expect()` inside of a condition that checks for libstdc++.

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

2 years ago[lldb] Check for arm64 in TestDisassembleRawData
Dave Lee [Mon, 10 Jan 2022 04:10:38 +0000 (20:10 -0800)]
[lldb] Check for arm64 in TestDisassembleRawData

This test checks for `aarch64` but the lit config could also contain `arm64`.
This change adds `arm64` to make the test pass in all cases.

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

2 years ago[lldb] Require x86 support for dwo-relative-path test
Dave Lee [Mon, 10 Jan 2022 05:29:39 +0000 (21:29 -0800)]
[lldb] Require x86 support for dwo-relative-path test

2 years ago[RISCV] Isel (sra (sext_inreg X, i16), C) -> (srai (slli X, (XLen-16), (XLen-16)...
Craig Topper [Mon, 10 Jan 2022 03:55:13 +0000 (19:55 -0800)]
[RISCV] Isel (sra (sext_inreg X, i16), C) -> (srai (slli X, (XLen-16), (XLen-16) + C).

Similar for (sra (sext_inreg X, i8), C).

With Zbb, sext_inreg of i8 and i16 are legal for sext.b and sext.h.
This transform makes the Zbb codegen the same as without Zbb. The
shifts are more compressible. This also exposes an opportunity for
CSE with another slli in the i16 sdiv by constant codegen.

2 years ago[lld][ELF] Support adrp+ldr GOT optimization for AArch64
Alexander Shaposhnikov [Mon, 10 Jan 2022 05:20:37 +0000 (05:20 +0000)]
[lld][ELF] Support adrp+ldr GOT optimization for AArch64

This diff adds first bits to support relocation relaxations for AArch64
discussed on https://github.com/ARM-software/abi-aa/pull/106.
In particular, the case of

adrp x0, :got: symbol
ldr x0, [x0, :got_lo12: symbol]

is handled.

Test plan: make check-all

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

2 years ago[RISCV] Disable EEW=64 for index values when XLEN=32.
jacquesguan [Thu, 22 Jul 2021 03:40:31 +0000 (11:40 +0800)]
[RISCV] Disable EEW=64 for index values when XLEN=32.

Disable EEW=64 for vector index load/store when XLEN=32.

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

2 years agoControl-flow Enforcement Technology (CET), published by Intel, introduces
jinge90 [Mon, 10 Jan 2022 01:23:28 +0000 (09:23 +0800)]
Control-flow Enforcement Technology (CET), published by Intel, introduces
indirect branch tracking(IBT) feature aiming to ensure the target address
of an indirect jump/call is not tampered.
When IBT is enabled, each function or target of any indirect jump/call will start
with an 'endbr32/64' instruction otherwise the program will crash during execution.
To build an application with CET enabled. we need to ensure:

  1. build the source code with "-fcf-protection=full"
  2. all the libraries linked with .o files must be CET enabled too

This patch aims to enable CET for compiler-rt builtins library, we add an option
"COMPILER_RT_ENABLE_CET" whose default value is OFF to enable CET for compiler-rt
in building time and when this option is "ON", "-fcf-protection=full" is added to
BUILTINS_CFLAG and the "endbr32/64" will be placed in the beginning of each assembly
function. We also enabled CET for crtbegin, crtend object files in this patch.

Reviewed by: MaskRay, compnerd, manojgupta, efriedma
Differential Revision: https://reviews.llvm.org/D109811

Signed-off-by: jinge90 <ge.jin@intel.com>
2 years ago[Builtins] Add missing the macro 'y' description in comments
Jim Lin [Mon, 10 Jan 2022 01:43:20 +0000 (09:43 +0800)]
[Builtins] Add missing the macro 'y' description in comments

New type str 'y' added from D76077. But missed its description in
comments.

Reviewed By: stuij

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

2 years ago[RISCV] Fold (srl (and X, 0xffff), C)->(srli (slli X, (XLen-16), (XLen-16) + C) even...
Craig Topper [Mon, 10 Jan 2022 02:15:49 +0000 (18:15 -0800)]
[RISCV] Fold (srl (and X, 0xffff), C)->(srli (slli X, (XLen-16), (XLen-16) + C) even with Zbb/Zbp.

We can use zext.h with Zbb, but srli/slli may offer more opportunities
for compression.

2 years ago[yaml2obj][XCOFF] parsing auxiliary symbols.
Esme-Yi [Mon, 10 Jan 2022 02:38:49 +0000 (02:38 +0000)]
[yaml2obj][XCOFF] parsing auxiliary symbols.

Summary: The patch adds support for yaml2obj parsing auxiliary
symbols for XCOFF. Since the test cases of this patch are
interdependent with D113825 ([llvm-readobj][XCOFF] dump
auxiliary symbols), test cases of this patch will be committed
after D113825 is committed.

Reviewed By: jhenderson, DiggerLin

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

2 years ago[PowerPC] fast isel can lower intrinsics call on AIX.
Chen Zheng [Tue, 30 Nov 2021 08:34:05 +0000 (08:34 +0000)]
[PowerPC] fast isel can lower intrinsics call on AIX.

Reviewed By: qiucf

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

2 years ago[SelectionDAG] Add FP_TO_UINT_SAT/FP_TO_SINT_SAT to computeKnownBits/computeNumSignBits.
Craig Topper [Mon, 10 Jan 2022 01:28:04 +0000 (17:28 -0800)]
[SelectionDAG] Add FP_TO_UINT_SAT/FP_TO_SINT_SAT to computeKnownBits/computeNumSignBits.

These nodes should saturate to their saturating VT. We can use this
information to know the bits past the VT are all zeros or all sign bits.

I think we might only have test coverage for the unsigned case. I'll
verify and add tests.

Reviewed By: nikic

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

2 years ago[CodeGen] Rename emitCalleeSavedFrameMoves
Alexander Shaposhnikov [Mon, 10 Jan 2022 01:27:11 +0000 (01:27 +0000)]
[CodeGen] Rename emitCalleeSavedFrameMoves

This diff renames emitCalleeSavedFrameMoves to avoid conflicts with
non-virtual methods of derived classes having the same name but different semantics.
E.g. the class AArch64FrameLowering used to have (non-virtual) "emitCalleeSavedFrameMoves"
but it started to override TargetFrameLowering::emitCalleeSavedFrameMoves after
https://github.com/llvm/llvm-project/commit/c3e6555616 though its usage and semantics didn't change.
P.S. for x86 there was no conflict because the signature of
non-virtual X86FrameLowering::emitCalleeSavedFrameMoves is different

Test plan: make check-all

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

2 years agoApply clang-tidy fixes for performance-move-const-arg in ReductionNode.cpp (NFC)
Mehdi Amini [Sat, 8 Jan 2022 22:13:51 +0000 (22:13 +0000)]
Apply clang-tidy fixes for performance-move-const-arg in ReductionNode.cpp (NFC)

2 years agoApply clang-tidy fixes for performance-for-range-copy in ElementwiseOpFusion.cpp...
Mehdi Amini [Sat, 8 Jan 2022 21:26:54 +0000 (21:26 +0000)]
Apply clang-tidy fixes for performance-for-range-copy in ElementwiseOpFusion.cpp (NFC)

2 years agoApply clang-tidy fixes for performance-for-range-copy in ModuleBufferization.cpp...
Mehdi Amini [Sat, 8 Jan 2022 21:21:42 +0000 (21:21 +0000)]
Apply clang-tidy fixes for performance-for-range-copy in ModuleBufferization.cpp (NFC)

2 years agoApply clang-tidy fixes for modernize-use-equals-default in IRCore.cpp (NFC)
Mehdi Amini [Sat, 8 Jan 2022 20:37:39 +0000 (20:37 +0000)]
Apply clang-tidy fixes for modernize-use-equals-default in IRCore.cpp (NFC)

2 years agoRevert "[lldb] Set result error state in 'frame variable'"
Dave Lee [Sun, 9 Jan 2022 22:12:47 +0000 (14:12 -0800)]
Revert "[lldb] Set result error state in 'frame variable'"

This reverts commit 2bcff220bf1e372e91491911fe0bb76c4c4bbef8.

2 years ago[ELF] Move gotIndex/pltIndex/globalDynIndex to SymbolAux
Fangrui Song [Sun, 9 Jan 2022 21:43:26 +0000 (13:43 -0800)]
[ELF] Move gotIndex/pltIndex/globalDynIndex to SymbolAux

to decrease sizeof(SymbolUnion) by 8 on ELF64 platforms.

Symbols needing such information are typically 1% or fewer (5134 out of 560520
when linking clang, 19898 out of 5550705 when linking chrome). Storing them
elsewhere can decrease memory usage and symbol initialization time.
There is a ~0.8% saving on max RSS when linking a large program.

Future direction:

* Move some of dynsymIndex/verdefIndex/versionId to SymbolAux
* Support mixed TLSDESC and TLS GD without increasing sizeof(SymbolUnion)

Reviewed By: peter.smith

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

2 years ago[lldb] Set result error state in 'frame variable'
Dave Lee [Fri, 7 Jan 2022 03:38:31 +0000 (19:38 -0800)]
[lldb] Set result error state in 'frame variable'

Ensure that errors in `frame variable` are reflected in result object.

The statistics for `frame variable` show invocations as being successful, even
when executing one of the error paths.

This change replaces `result.GetErrorStream()` with `result.AppendError()`,
which also sets the status to `eReturnStatusFailed`.

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

(cherry picked from commit 2c7d10c41278181e3e45c68f28b501cd95193a8a)

2 years ago[lldb][docs] Update references to SVN
Dave Lee [Sun, 9 Jan 2022 20:42:52 +0000 (12:42 -0800)]
[lldb][docs] Update references to SVN

2 years agoUse true/false instead of 1/0 (NFC)
Kazu Hirata [Sun, 9 Jan 2022 20:21:06 +0000 (12:21 -0800)]
Use true/false instead of 1/0 (NFC)

Identified by modernize-use-bool-literals.

2 years ago[lldb] Remove redundant member initialization (NFC)
Kazu Hirata [Sun, 9 Jan 2022 20:21:04 +0000 (12:21 -0800)]
[lldb] Remove redundant member initialization (NFC)

2 years agoFix bugprone argument comments.
Kazu Hirata [Sun, 9 Jan 2022 20:21:02 +0000 (12:21 -0800)]
Fix bugprone argument comments.

Identified by bugprone-argument-comment.

2 years ago[clang] Remove unused forward declarations (NFC)
Kazu Hirata [Sun, 9 Jan 2022 20:21:00 +0000 (12:21 -0800)]
[clang] Remove unused forward declarations (NFC)

2 years ago[lldb] Compute fully qualified command names in FindCommandsForApropos
Dave Lee [Sun, 2 Jan 2022 04:07:07 +0000 (20:07 -0800)]
[lldb] Compute fully qualified command names in FindCommandsForApropos

Fixes incomplete command names in `apropos` results.

The full command names given by `apropos` have come from command name string
literals given to `CommandObject` constructors. For most commands, this has
been accurate, but some commands have incorrect strings. This results in
`apropos` output that doesn't tell the user the full command name they might
want learn more about. These strings can be fixed.

There's a seperate issue that can't be fixed as easily: plugin commands. With
the way they're implemented, plugin commands have to exclude the root command
from their command name string. To illustrate, the `language objc` subcommand
has to set its command name string to "objc", which results in apropos printing
results as `objc ...` instead of `language objc ...`.

To fix both of these issues, this commit changes `FindCommandsForApropos` to
derive the fully qualified command name using the keys of subcommand maps.

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

(cherry picked from commit b3bfd595a548cd85b12e4e83729436cb73b26f29)

2 years ago[lldb] Remove ProcessStructReader from NSStringSummaryProvider (NFC)
Dave Lee [Thu, 30 Dec 2021 22:41:27 +0000 (14:41 -0800)]
[lldb] Remove ProcessStructReader from NSStringSummaryProvider (NFC)

Simplify getting the length of `NSPathStore2` strings.

`NSStringSummaryProvider` uses a single field from `NSPathStore2` instances,
its first ivar: `_lengthAndRefCount`. This change uses
`GetSyntheticChildAtOffset` to replace the use of `ProcessStructReader`, and
removes the hard coded `CompilerType` definition of `NSPathStore2`.

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

2 years ago[mlir][MemRef] NFC - Improve assertion error message
Nicolas Vasilache [Sun, 9 Jan 2022 19:17:28 +0000 (14:17 -0500)]
[mlir][MemRef] NFC - Improve assertion error message

2 years ago[Attributor][FIX] Remove assumption that doesn't have to hold
Johannes Doerfert [Sun, 9 Jan 2022 03:11:51 +0000 (21:11 -0600)]
[Attributor][FIX] Remove assumption that doesn't have to hold

There is no guarantee we strip all GEPOperators and the conservative
handling doesn't even require us to.

2 years ago[mlir][Bufferize] NFC - Introduce areCastCompatible assertions to catch misformed...
Nicolas Vasilache [Sun, 9 Jan 2022 16:51:58 +0000 (11:51 -0500)]
[mlir][Bufferize] NFC - Introduce areCastCompatible assertions to catch misformed CastOp early

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

2 years ago[SCEVExpander] Simplify cleanup, skip sorting by dominance.
Florian Hahn [Sun, 9 Jan 2022 18:38:41 +0000 (18:38 +0000)]
[SCEVExpander] Simplify cleanup, skip sorting by dominance.

There is no need to sort inserted instructions by dominance, as the
deletion loop still requires RAUW with undef before deleting. Removing
instructions in reverse insertion order should still insure that the
number of uselist updates is kept to a minimum.

2 years ago[AIX] Disable tests that fail because of no 64-bit XCOFF object file support
Jake Egan [Sun, 9 Jan 2022 17:20:38 +0000 (12:20 -0500)]
[AIX] Disable tests that fail because of no 64-bit XCOFF object file support

The modified tests fail because 64-bit XCOFF object files are not currently supported on AIX. This patch disables these tests on 64-bit AIX for now.

This patch is similar to D111887 except the failures on this patch are on a 64-bit build.

Reviewed By: shchenz, #powerpc

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

2 years ago[x86] exclude "X==0 ? Y :-1" from math/logic transform
Sanjay Patel [Sun, 9 Jan 2022 13:59:48 +0000 (08:59 -0500)]
[x86] exclude "X==0 ? Y :-1" from math/logic transform

This is the last step in a series to improve lowering
via "SBB" asm:
68defc0134
aab1f55e33
...and fixes #53006

2 years ago[SCEVExpander] Only check overflow if it is needed.
Florian Hahn [Thu, 6 Jan 2022 21:13:04 +0000 (21:13 +0000)]
[SCEVExpander] Only check overflow if it is needed.

9345ab3a4550 updated generateOverflowCheck to skip creating checks that
always evaluate to false. This in turn means that we only need to check
for overflows if the result of the multiplication is actually used.

Sink the Or for the overflow check into ComputeEndCheck, so it is only
created when there's an actual check.

2 years ago[InstCombine] (~A | B) & (A ^ B) -> ~A & B
Sanjay Patel [Sun, 9 Jan 2022 11:17:11 +0000 (06:17 -0500)]
[InstCombine] (~A | B) & (A ^ B) -> ~A & B

This is part of a set of 2-variable logic optimizations
suggested here:
https://lists.llvm.org/pipermail/llvm-dev/2021-December/154470.html

The 'not' op must not propagate undef elements of a vector,
so this patch creates a new 'full' not, but I am not counting
that as an extra-use restriction because it should get folded
with the existing value by CSE.

https://alive2.llvm.org/ce/z/7v65im

2 years ago[InstCombine] add tests for and(orn, xor); NFC
Sanjay Patel [Fri, 7 Jan 2022 19:40:55 +0000 (14:40 -0500)]
[InstCombine] add tests for and(orn, xor); NFC

2 years ago[x86] use SETCC_CARRY instead of SBB node for select lowering
Sanjay Patel [Fri, 7 Jan 2022 18:35:59 +0000 (13:35 -0500)]
[x86] use SETCC_CARRY instead of SBB node for select lowering

This is a suggested follow-up to D116765.
This removes a clear of the register operand, so it is better
for code size, but it does potentially create a false register
dependency on surrounding code. If that is a problem, it should
be solvable using dependency-breaking code that is used for
other instructions.

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

2 years ago[clang] Remove redundant member initialization (NFC)
Kazu Hirata [Sun, 9 Jan 2022 08:19:51 +0000 (00:19 -0800)]
[clang] Remove redundant member initialization (NFC)

Identified with readability-redundant-member-init.

2 years ago[clang] Fix bugprone argument comments (NFC)
Kazu Hirata [Sun, 9 Jan 2022 08:19:49 +0000 (00:19 -0800)]
[clang] Fix bugprone argument comments (NFC)

Identified with bugprone-argument-comment.

2 years ago[clang] Use true/false instead of 1/0 (NFC)
Kazu Hirata [Sun, 9 Jan 2022 08:19:47 +0000 (00:19 -0800)]
[clang] Use true/false instead of 1/0 (NFC)

Identified with modernize-use-bool-literals.

2 years ago[libcxx][test] `_VSTD` doesn't belong in test code
Casey Carter [Wed, 29 Dec 2021 22:31:23 +0000 (14:31 -0800)]
[libcxx][test] `_VSTD` doesn't belong in test code

2 years ago[OpenMP][FIX] Emit debug declares only if debug info is available
Johannes Doerfert [Sat, 8 Jan 2022 19:53:39 +0000 (13:53 -0600)]
[OpenMP][FIX] Emit debug declares only if debug info is available

The `EmitDeclareOfAutoVariable` introduced in D114504 and D115510 has a
precondition that cannot be violated. It is unclear if we should call it
directly given the sparse usage in clang but for now we should at least
not crash if the debug info kind is too low.

Fixes #52938.

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

2 years ago[Attributor][FIX] Ensure order for multiple references into map
Johannes Doerfert [Sat, 8 Jan 2022 18:17:04 +0000 (12:17 -0600)]
[Attributor][FIX] Ensure order for multiple references into map

If we have multiple references into a map we need to ensure the ones
created late do not invalidate the ones created early. To do that we
need to make sure all but the first are not modifying the map, hence
for them the keys have to be present already.

Fixes #52875.

2 years ago[RISCV] Add i8/i16 fptosi/fptoui and fptosi_sat/fptoui_sat tests. NFC
Craig Topper [Sat, 8 Jan 2022 21:56:40 +0000 (13:56 -0800)]
[RISCV] Add i8/i16 fptosi/fptoui and fptosi_sat/fptoui_sat tests. NFC

Use signext/zeroext return attributes to show unnecessary ands or
shifts in the saturating tests.