platform/upstream/llvm.git
2 years ago[BitstreamReader] Handle errors more gracefully
Nikita Popov [Fri, 4 Feb 2022 16:23:08 +0000 (17:23 +0100)]
[BitstreamReader] Handle errors more gracefully

Use proper error reporting instead of report_fatal_error().

2 years ago[BitcodeReader] Resolve error handling todo
Nikita Popov [Fri, 4 Feb 2022 16:13:02 +0000 (17:13 +0100)]
[BitcodeReader] Resolve error handling todo

If possible, forward the inner error instead of creating a new
one.

2 years agoTweak some uses of std::iota to skip initializing the underlying storage. NFCI.
Benjamin Kramer [Fri, 4 Feb 2022 16:00:50 +0000 (17:00 +0100)]
Tweak some uses of std::iota to skip initializing the underlying storage. NFCI.

2 years agoDon't dllexport reference temporaries
Hans Wennborg [Fri, 4 Feb 2022 10:11:11 +0000 (11:11 +0100)]
Don't dllexport reference temporaries

Even if the reference itself is dllexport, the temporary should not be.
In fact, we're already giving it internal linkage, so dllexporting it
is not just wasteful, but will fail to link, as in the example below:

  $ cat /tmp/a.cc
  void _DllMainCRTStartup() {}
  const int __declspec(dllexport) &foo = 42;

  $ clang-cl -fuse-ld=lld /tmp/a.cc /Zl /link /dll /out:a.dll
  lld-link: error: <root>: undefined symbol: int const &foo::$RT1

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

2 years ago[gn build] (manually) port e1db505b42f4 (clang-pseudo)
Nico Weber [Fri, 4 Feb 2022 15:17:02 +0000 (10:17 -0500)]
[gn build] (manually) port e1db505b42f4 (clang-pseudo)

2 years ago[libc] Set default CXX_STANDARD to C++17 and let targets set their own standard if...
Tue Ly [Thu, 3 Feb 2022 05:03:27 +0000 (00:03 -0500)]
[libc] Set default CXX_STANDARD to C++17 and let targets set their own standard if needed.

CMAKE_CXX_STANDARD 14 is set in the llvm-project/llvm folder overriding all COMPILE_OPTIONS -std=c++17.  We need to override the CXX_STANDARD property of the target in order to set the correct C++ standard flags.

Reviewed By: gchatelet

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

2 years ago[HIP] Support code object v5
Yaxun (Sam) Liu [Thu, 3 Feb 2022 19:07:45 +0000 (14:07 -0500)]
[HIP] Support code object v5

New device library supporting v4 and v5 has abi_version_400.bc and abi
version_500.bc.

For v5, abi_version_500.bc is linked.

For v2-4, abi_version_400.bc is linked.

For old device library, for v2-4, none of the above is linked. For v5,
error is emitted about unsupported ABI version.

Reviewed by: Artem Belevich

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

Fixes: SWDEV-321313

2 years ago[AMDGPU] SILoadStoreOptimizer: fewer calls to offsetsCanBeCombined
Jay Foad [Fri, 4 Feb 2022 14:51:28 +0000 (14:51 +0000)]
[AMDGPU] SILoadStoreOptimizer: fewer calls to offsetsCanBeCombined

Only call offsetsCanBeCombined with Modify = true in cases
where it will really do something. NFC.

2 years ago[AMDGPU][GFX9][DOC][NFC] Corrected description of registers available via getreg...
Dmitry Preobrazhensky [Fri, 4 Feb 2022 14:55:01 +0000 (17:55 +0300)]
[AMDGPU][GFX9][DOC][NFC] Corrected description of registers available via getreg/setreg

This is to reflect changes introduced by https://reviews.llvm.org/D118860.

2 years ago[NFC][SVE] Change useSVEForFixedLengthVectorVT to allow unconditional SVE usage for...
Paul Walker [Fri, 4 Feb 2022 00:52:18 +0000 (00:52 +0000)]
[NFC][SVE] Change useSVEForFixedLengthVectorVT to allow unconditional SVE usage for NEON sized vectors.

Previously useSVEForFixedLengthVectorVT only allowed SVE usage when
the target SVE register length was known to be at least 256bit.
This was true even for NEON sized vectors, which was an artificial
restriction imposed during early SVE bring up.  This now changes so
that callers can opt to use SVE for NEON sized vectors regardless
of the SVE register length.

The patch is NFC because for all places where OverrideNEON is used
we now explicitly also check that SVE code generation for larger
than NEON vectors is enabled.  The intent is that over time these
extra checks will either be removed or the lowering disabled if the
SVE usage proves not beneficial.

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

2 years ago[AMDGPU] SILoadStoreOptimizer: simplify class/subclass checks
Jay Foad [Fri, 28 Jan 2022 11:07:58 +0000 (11:07 +0000)]
[AMDGPU] SILoadStoreOptimizer: simplify class/subclass checks

Also add a comment explaining the difference between class
and subclass. NFCI.

2 years ago[AArch64] Expand UADDLV patterns to SADDLV
David Green [Fri, 4 Feb 2022 14:07:02 +0000 (14:07 +0000)]
[AArch64] Expand UADDLV patterns to SADDLV

We already had some patterns for UADDV(UADDLP(x)) -> UADDLV(x), this
simply expands them to the signed instructions by re-using the tablegen
patterns.

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

2 years ago[SimplifyCFG] Merge compatible `invoke`s of a `landingpad`
Roman Lebedev [Fri, 4 Feb 2022 14:04:10 +0000 (17:04 +0300)]
[SimplifyCFG] Merge compatible `invoke`s of a `landingpad`

While nowadays SimplifyCFG knows how to hoist code from then-else blocks,
sink code from unconditional predecessors, and even promote the latter
by tail-merging `ret`/`resume` function terminators, that isn't everything.

While i (& others) have been trying to deal with merging/sinking `unreachable`,
apparently perhaps the more impactful remaining problem is merging the `throw`
calls.

If we start at the `landingpad`, all the predecessors are unwind edges of `invoke`s,
and in some cases some of the `invoke`s are mergeable.
```
/// This is a weird mix of hoisting and sinking. Visually, it goes from:
///          [...]        [...]
///            |            |
///        [invoke0]    [invoke1]
///           / \          / \
///     [cont0] [landingpad] [cont1]
/// to:
///      [...] [...]
///          \ /
///       [invoke]
///          / \
///     [cont] [landingpad]
```

This simplifies the IR/CFG, at the cost of debug info and extra PHI nodes.

Note that we don't require for *all* the `invokes` of the `landingpad`
to be mergeable, they can form more than a single set, we gracefully handle that.

For now, i completely disallowed normal destination, PHI nodes and indirect invokes
but that can be supported.

Out of all the CTMark projects, only 7zip is C++, so there isn't much impact:
https://llvm-compile-time-tracker.com/compare.php?from=ba8eb31bd9542828f6424e15a3014f80f14522c8&to=722fc871c84f14157d45c2159bc9c8c7e2825785&stat=size-total
... but there it currently causes size-total decrease.

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

2 years ago[ConstraintElimination] Add initial signed support.
Florian Hahn [Fri, 4 Feb 2022 14:02:48 +0000 (14:02 +0000)]
[ConstraintElimination] Add initial signed support.

This patch adds initial support for signed conditions. To do so,
ConstraintElimination maintains two separate systems, one with facts
from signed and one for unsigned conditions.

To start with this means information from signed and unsigned conditions
is kept completely separate. When it is safe to do so, information from
signed conditions may be also transferred to the unsigned system and
vice versa. That's left for follow-ups.

In the initial version, de-composition of signed values just handles
constants and otherwise just uses the value, without trying to
decompose the operation. Again this can be extended in follow-up
changes.

The main benefit of this limited signed support is proving >=s 0
pre-conditions added in D118799. But even this initial version also
fixes PR53273.

Depends on D118799.

Reviewed By: reames

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

2 years ago[NFC][SimplifyCFG] 'merge compatible invokes': test with PHI nodes in unreachable...
Roman Lebedev [Fri, 4 Feb 2022 13:50:32 +0000 (16:50 +0300)]
[NFC][SimplifyCFG] 'merge compatible invokes': test with PHI nodes in unreachable normal destinations

2 years ago[Statepoint] Determine return type from elementtype attribute
Nikita Popov [Fri, 4 Feb 2022 13:37:02 +0000 (14:37 +0100)]
[Statepoint] Determine return type from elementtype attribute

Based on the LangRef change in D117890, this uses the elementtype
attribute rather than the pointer element type to determine the
statepoint callee function type, making statepoints compatible
with opaque pointers.

2 years ago[Verifier] Require elementtype on gc.statepoint intrinsics
Nikita Popov [Fri, 4 Feb 2022 11:29:01 +0000 (12:29 +0100)]
[Verifier] Require elementtype on gc.statepoint intrinsics

This enforces the requirement specified in D117890.

2 years ago[AMDGPU] SILoadStoreOptimizer: simplify optimizeInstsWithSameBaseAddr
Jay Foad [Fri, 4 Feb 2022 13:24:11 +0000 (13:24 +0000)]
[AMDGPU] SILoadStoreOptimizer: simplify optimizeInstsWithSameBaseAddr

Common up all the calls to CI.setMI. NFCI.

2 years ago[Statepoint] Update gc.statepoint calls in tests with elementtype (NFC)
Nikita Popov [Fri, 4 Feb 2022 11:47:03 +0000 (12:47 +0100)]
[Statepoint] Update gc.statepoint calls in tests with elementtype (NFC)

This updates tests for the LangRef change in D117890.

2 years ago[AMDGPU] SILoadStoreOptimizer: simplify OptimizeListAgain test
Jay Foad [Fri, 4 Feb 2022 13:02:19 +0000 (13:02 +0000)]
[AMDGPU] SILoadStoreOptimizer: simplify OptimizeListAgain test

At this point CI represents the combined access (original CI combined
with Paired) so it doesn't make any sense to add in Paired.width again.
NFCI.

2 years ago[AArch64] Fix legalization of v1f64 strict_fsetcc and strict_fsetccs
John Brawn [Tue, 25 Jan 2022 17:41:33 +0000 (17:41 +0000)]
[AArch64] Fix legalization of v1f64 strict_fsetcc and strict_fsetccs

These operations are scalarized but the result type v1i1 isn't which
needs special handling (the same as is done for the non-strict
versions of these operations).

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

2 years ago[AArch64] Generate fcmps when appropriate for neon intrinsics
John Brawn [Tue, 25 Jan 2022 17:29:52 +0000 (17:29 +0000)]
[AArch64] Generate fcmps when appropriate for neon intrinsics

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

2 years agoRevert "[x86] try harder to scalarize a vector load with extracted integer op uses"
Sanjay Patel [Fri, 4 Feb 2022 12:45:57 +0000 (07:45 -0500)]
Revert "[x86] try harder to scalarize a vector load with extracted integer op uses"

This reverts commit b4b97ec813a02585000f30ac7d532dda74e8bfda.

As discussed in post-commit feedback at:
https://reviews.llvm.org/D118376
...there's a stage 2 failure on a Mac running a clang-refactor tool test.

2 years ago[lldb] Remove Log:Channel::GetLogIfAll
Pavel Labath [Thu, 3 Feb 2022 13:54:13 +0000 (14:54 +0100)]
[lldb] Remove Log:Channel::GetLogIfAll

after the recent refactor, the function is unused.

2 years ago[OpenMP][Clang] Allow ancestor device modifier only with reverse offloading
Saiyedul Islam [Thu, 3 Feb 2022 11:28:04 +0000 (11:28 +0000)]
[OpenMP][Clang] Allow ancestor device modifier only with reverse offloading

OpenMP Spec 5.0 [2.12.5, Restrictions]: If a device clause in which the
ancestor device-modifier appears is present on the target construct,
then a requires directive with the reverse_offload clause must be
specified.

Reviewed By: ABataev

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

2 years ago[libc++] Remove vector base class
Nikolas Klauser [Thu, 3 Feb 2022 22:09:37 +0000 (23:09 +0100)]
[libc++] Remove vector base class

Remove the vector base class as suggested by @ldionne

Reviewed By: ldionne, Quuxplusone, #libc

Spies: libcxx-commits, ldionne

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

2 years ago[ConstraintElimination] Allow adding pre-conditions for constraints.
Florian Hahn [Fri, 4 Feb 2022 11:45:07 +0000 (11:45 +0000)]
[ConstraintElimination] Allow adding pre-conditions for constraints.

With this patch pre-conditions can be added to a list of constraints.
Constraints with pre-conditions can only be used if all pre-conditions
are satisfied when the constraint is used.

The pre-conditions at the moment are specified as a list of
(Predicate, Value *,Value *) tuples. This allow easily checking them
like any other condition, using the existing infrastructure.

This then is used to limit GEP decomposition to cases where we can
prove that offsets are signed positive.

This fixes a couple of incorrect transforms where GEP offsets where
assumed to be signed positive, but they were not.

Note that this effectively disables GEP decomposition, as there's no
support for reasoning about signed predicates. D118806 adds initial
signed support.

Fixes PR49624.

Reviewed By: reames

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

2 years ago[Format] Also test rvalue-qualified functions
Sam McCall [Fri, 4 Feb 2022 11:17:25 +0000 (12:17 +0100)]
[Format] Also test rvalue-qualified functions

2 years ago[Format] Don't derive pointers right based on space before method ref-qualifiers
Sam McCall [Thu, 3 Feb 2022 17:15:49 +0000 (18:15 +0100)]
[Format] Don't derive pointers right based on space before method ref-qualifiers

The second space in `void foo() &` is always produced by clang-format,
and isn't evidence of any particular style.

Before this patch, it was considered evidence of PAS_Right, because
there is a space before a pointerlike ampersand.

This caused the following code to have "unstable" pointer alignment:
  void a() &;
  void b() &;
  int *x;
PAS_Left, Derive=false would produce 'int* x' with other lines unchanged.
But subsequent formatting with Derive=true would produce 'int *x' again.

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

2 years ago[clang][CodeGen] Use memory type representation in `va_arg`
Jan Svoboda [Thu, 3 Feb 2022 14:59:55 +0000 (15:59 +0100)]
[clang][CodeGen] Use memory type representation in `va_arg`

Some types (e.g. `_Bool`) have different scalar and memory representations. CodeGen for `va_arg` didn't take this into account, leading to an assertion failures with different types.

This patch makes sure we use memory representation for `va_arg`.

Reviewed By: ahatanak

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

2 years ago[syntax][pseudo] Introduce the C++ spec grammar.
Haojian Wu [Thu, 20 Jan 2022 10:02:50 +0000 (11:02 +0100)]
[syntax][pseudo] Introduce the C++ spec grammar.

Add a dummy clang-pseudo tool (right now it accepts and parses the
grammar file).

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

2 years agoReduce dependencies on llvm/BinaryFormat/Dwarf.h
serge-sans-paille [Wed, 2 Feb 2022 12:53:56 +0000 (13:53 +0100)]
Reduce dependencies on llvm/BinaryFormat/Dwarf.h

This header is very large (3M Lines once expended) and was included in location
where dwarf-specific information were not needed.

More specifically, this commit suppresses the dependencies on
llvm/BinaryFormat/Dwarf.h in two headers: llvm/IR/IRBuilder.h and
llvm/IR/DebugInfoMetadata.h. As these headers (esp. the former) are widely used,
this has a decent impact on number of preprocessed lines generated during
compilation of LLVM, as showcased below.

This is achieved by moving some definitions back to the .cpp file, no
performance impact implied[0].

As a consequence of that patch, downstream user may need to manually some extra
files:

llvm/IR/IRBuilder.h no longer includes llvm/BinaryFormat/Dwarf.h
llvm/IR/DebugInfoMetadata.h no longer includes llvm/BinaryFormat/Dwarf.h

In some situations, codes maybe relying on the fact that
llvm/BinaryFormat/Dwarf.h was including llvm/ADT/Triple.h, this hidden
dependency now needs to be explicit.

$ clang++ -E  -Iinclude -I../llvm/include ../llvm/lib/Transforms/Scalar/*.cpp -std=c++14 -fno-rtti -fno-exceptions | wc -l
after:   10978519
before:  11245451

Related Discourse thread: https://llvm.discourse.group/t/include-what-you-use-include-cleanup
[0] https://llvm-compile-time-tracker.com/compare.php?from=fa7145dfbf94cb93b1c3e610582c495cb806569b&to=995d3e326ee1d9489145e20762c65465a9caeab4&stat=instructions

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

2 years ago[flang] Upstream partial lowering of GET_COMMAND_ARGUMENT intrinsic
Josh Mottley [Thu, 6 Jan 2022 14:55:33 +0000 (14:55 +0000)]
[flang] Upstream partial lowering of GET_COMMAND_ARGUMENT intrinsic

This patch adds partial lowering of the "GET_COMMAND_ARGUMENT"
intrinsic to the backend runtime hook implemented in patches D109227,
D109813, D109814.

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

2 years ago[OpenCL] Move OpenCL 2.0 atomics into multiclass; NFC
Sven van Haastregt [Fri, 4 Feb 2022 10:17:48 +0000 (10:17 +0000)]
[OpenCL] Move OpenCL 2.0 atomics into multiclass; NFC

This is in preparation for adding the OpenCL 3.0 builtins with named
address space arguments.

2 years ago[AArch64][SVE] Remove false register dependency for unary FP convert operations
Matt Devereau [Mon, 31 Jan 2022 16:24:48 +0000 (16:24 +0000)]
[AArch64][SVE] Remove false register dependency for unary FP convert operations

Generate movprfx for floating point convert zeroing pseudo operations

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

2 years ago[RS4GC] Restore DAG check line (NFC)
Nikita Popov [Fri, 4 Feb 2022 09:25:00 +0000 (10:25 +0100)]
[RS4GC] Restore DAG check line (NFC)

It's fishy that this is needed, but this is what the test did
previously. Should hopefully address buildbot failures.

2 years agoSplit fast-basictest.ll according to passes responsible for optimizations
Daniil Kovalev [Fri, 4 Feb 2022 08:40:10 +0000 (11:40 +0300)]
Split fast-basictest.ll according to passes responsible for optimizations

- add logically missing test cases.
- add appropriate comments.
- add appropriate TODO's.

See initial motivation in https://reviews.llvm.org/D117302

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

2 years ago[flang] Handle logical constant value for quiet in STOP stmt
Valentin Clement [Fri, 4 Feb 2022 09:11:46 +0000 (10:11 +0100)]
[flang] Handle logical constant value for quiet in STOP stmt

This patch handles the quiet argument in the STOP statement. It adds
ability to lower LOGICAL constant.

This patch is part of the upstreaming effort from fir-dev branch.

Reviewed By: kiranchandramohan, PeteSteinfeld

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

Co-authored-by: Jean Perier <jperier@nvidia.com>
2 years ago[pseudo] NFC, clangSyntaxPsuedo => clangToolingSyntaxPseudo
Haojian Wu [Fri, 4 Feb 2022 08:57:20 +0000 (09:57 +0100)]
[pseudo] NFC, clangSyntaxPsuedo => clangToolingSyntaxPseudo

To be consistent with existing name pattern.

2 years ago[pseudo] Rename Tests.cpp => Test.cpp
Haojian Wu [Fri, 4 Feb 2022 08:31:53 +0000 (09:31 +0100)]
[pseudo] Rename Tests.cpp => Test.cpp

To be consistent with other files in clang unittest directory.

2 years ago[IRBuilder][RS4GC] Require FunctionCallee when creating statepoint
Nikita Popov [Thu, 3 Feb 2022 10:29:06 +0000 (11:29 +0100)]
[IRBuilder][RS4GC] Require FunctionCallee when creating statepoint

This makes the statepoint methods in IRBuilder accept a
FunctionCallee, which carries both the callee and function type.
This is used to add the elementtype attribute to the statepoint call.

RS4GC requires an additional tweak to actually preserve that attribute
-- previously the attributes on the call were completely overwritten.

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

2 years ago[LangRef] Require elementtype attribute for gc.statepoint intrinsic
Nikita Popov [Fri, 21 Jan 2022 14:46:00 +0000 (15:46 +0100)]
[LangRef] Require elementtype attribute for gc.statepoint intrinsic

The gc.statepoint intrinsic currently determines the target function
type based on the pointer element type of the argument. In order to
support opaque pointers, require that the argument is annotated with
an elementtype attribute.

Here's an example of the change:

    ; Before:
      %safepoint_token = tail call token (i64, i32, i1 ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_i1f(i64 0, i32 0, i1 ()* @return_i1, i32 0, i32 0, i32 0, i32 0)

    ; After:
      %safepoint_token = tail call token (i64, i32, i1 ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_i1f(i64 0, i32 0, i1 ()* elementtype(i1 ()) @return_i1, i32 0, i32 0, i32 0, i32 0)

    ; After with opaque pointers:
      %safepoint_token = tail call token (i64, i32, i1 ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0(i64 0, i32 0, ptr elementtype(i1 ()) @return_i1, i32 0, i32 0, i32 0, i32 0)

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

2 years ago[DAGCombiner] Fix dependency analysis in checkMergeStoreCandidatesForDependencies
Bjorn Pettersson [Thu, 3 Feb 2022 21:16:42 +0000 (22:16 +0100)]
[DAGCombiner] Fix dependency analysis in checkMergeStoreCandidatesForDependencies

In the aftermath of D116895 a problem was found in the analysis of
dependencies between store merge candidates in
checkMergeStoreCandidatesForDependencies, that is needed to avoid
the cycles are introduced in the DAG.

In the past it has been enough (or assumed to be enough) to start
scanning from non-chain operands when analysing the store merge
candidates for dependencies, assuming that the analysis of chain
dependencies performed when finding the candidates would cover
up for potential dependencies that exist involving the chain operands.
It was however discovered that one could end up with scenarios such
as descibed in the aarch64-checkMergeStoreCandidatesForDependencies.ll
test case, when the dependency between two stores is given by a mix
of chain operand dependencies and non-chain operand dependencies.

The fix in this patch make sure that we also account for chain operand
dependencies when doing the more elaborate analysis in
checkMergeStoreCandidatesForDependencies, no longer relying on that
the earlier check involving chain operands is enough.

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

2 years ago[ORC] Fix JITDylib debug output: don't output symbol table entry flags twice.
Lang Hames [Fri, 4 Feb 2022 07:28:25 +0000 (18:28 +1100)]
[ORC] Fix JITDylib debug output: don't output symbol table entry flags twice.

2 years ago[libc++][NFC] Use cpp17_output_iterator in tests.
Mark de Wever [Sat, 22 Jan 2022 15:37:20 +0000 (16:37 +0100)]
[libc++][NFC] Use cpp17_output_iterator in tests.

The renames the output_iterator to cpp17_output_iterator. These
iterators are still used in C++20 so it's not possible to change the
current type to the new C++20 requirements. This is done in a similar
fashion as the cpp17_input_iterator.

Reviewed By: #libc, Quuxplusone, ldionne

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

2 years ago[mlir] Add pass to privatize symbols unless excluded.
Jacques Pienaar [Fri, 4 Feb 2022 04:20:54 +0000 (20:20 -0800)]
[mlir] Add pass to privatize symbols unless excluded.

Simple pass that changes all symbols to private unless symbol is excluded (and
in which case there is no change to symbol's visibility).

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

2 years ago[SLP] Have only ready items in ready list [NFC]
Philip Reames [Fri, 4 Feb 2022 03:33:27 +0000 (19:33 -0800)]
[SLP] Have only ready items in ready list [NFC]

This adds the assertion that all items in the ready list are in-fact scheduleable entities ready to be scheduled.  This involves changing the ReadyInsts structure to be a set, and fixing a couple places where we left nodes on the list when they were no longer ready.

2 years ago[libc][Obvious] Fix a mismatch signature of HighPrecisionDecimal::should_round_up.
Tue Ly [Wed, 2 Feb 2022 15:18:28 +0000 (10:18 -0500)]
[libc][Obvious] Fix a mismatch signature of HighPrecisionDecimal::should_round_up.

Its input should be int32_t instead of uint32_t.

Reviewed By: michaelrj, sivachandra

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

2 years ago[test-release.sh] Set TEST_SUITE_HOST_CC to the release testing build compiler when...
Amy Kwan [Fri, 4 Feb 2022 03:31:44 +0000 (21:31 -0600)]
[test-release.sh] Set TEST_SUITE_HOST_CC to the release testing build compiler when compiling test-suite tools.

The tools used by test-suite are originally configured to compile with cc by
default, and this is dictated by TEST_SUITE_HOST_CC.
However, it is possible that on some systems that the version of cc may either
not be present or it may not be able to compile the tools as it may be too old,
which could be an issue seen during release testing.

This patch updates the compiler to be the default build compiler that is used
for release testing. If no such compiler it specified, then cc will be set as
the test-suite tools build compiler by default (as it already is set under
TEST_SUITE_HOST_CC).

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

2 years ago[RS4GC] Extract rematerilazable candidate search. NFC.
Serguei Katkov [Thu, 27 Jan 2022 09:23:10 +0000 (16:23 +0700)]
[RS4GC] Extract rematerilazable candidate search. NFC.

Finding re-materialization chain for derived pointer does not depend on
call site. To avoid this finding for each call site it can be extracted in
a separate routine.

Reviewers: reames, dantrushin
Reviewed By: reames
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D118676

2 years ago[hwasan] [nfc] simplify getAllocaSizeInBytes
Florian Mayer [Fri, 4 Feb 2022 01:42:19 +0000 (17:42 -0800)]
[hwasan] [nfc] simplify getAllocaSizeInBytes

AllocaInst::getAllocationSize implements essentially the same logic as
our custom function.

Reviewed By: hctim

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

2 years ago[OpenMP] Add Cuda path to linker wrapper tool
Joseph Huber [Thu, 3 Feb 2022 21:41:47 +0000 (16:41 -0500)]
[OpenMP] Add Cuda path to linker wrapper tool

The linker wrapper tool uses the 'nvlink' and 'ptxas' binaries to link
and assemble device files. Previously we searched for this using the
binaries in the user's path. This didn't work in cases where the user
passed in a specific Cuda path to Clang. This patch changes the linker
wrapper to accept an argument for the Cuda path we can get from Clang.
This should fix #53573.

Reviewed By: tianshilei1992

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

2 years ago[nfc][mlgo][regalloc] Cache live interval feature components
Mircea Trofin [Tue, 1 Feb 2022 02:53:54 +0000 (18:53 -0800)]
[nfc][mlgo][regalloc] Cache live interval feature components

Lazily cache the feature components of a LiveInterval.

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

2 years ago[Support] unsafe pointer arithmetic in llvm_regcomp()
Miod Vallat [Fri, 4 Feb 2022 00:50:58 +0000 (19:50 -0500)]
[Support] unsafe pointer arithmetic in llvm_regcomp()

regcomp.c uses the "start + count < end" idiom to check that there are
"count" bytes available in an array of char "start" and "end" both point
to.

This is fine, unless "start + count" goes beyond the last element of the
array. In this case, pedantic interpretation of the C standard makes
the comparison of such a pointer against "end" undefined, and optimizers
from hell will happily remove as much code as possible because of this.

An example of this occurs in regcomp.c's bothcases(), which defines
bracket[3], sets "next" to "bracket" and "end" to "bracket + 2". Then it
invokes p_bracket(), which starts with "if (p->next + 5 < p->end)"...

Because bothcases() and p_bracket() are static functions in regcomp.c,
there is a real risk of miscompilation if aggressive inlining happens.

The following diff rewrites the "start + count < end" constructs into
"end - start > count". Assuming "end" and "start" are always pointing in
the array (such as "bracket[3]" above), "end - start" is well-defined
and can be compared without trouble.

As a bonus, MORE2() implies MORE() therefore SEETWO() can be simplified
a bit.

Bug report: https://github.com/llvm/llvm-project/issues/47993

Reviewed By: MaskRay, vitalybuka

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

2 years ago[lld-macho][nfc] Eliminate InputSection::Shared
Jez Ng [Fri, 4 Feb 2022 00:53:29 +0000 (19:53 -0500)]
[lld-macho][nfc] Eliminate InputSection::Shared

Earlier in LLD's evolution, I tried to create the illusion that
subsections were indistinguishable from "top-level" sections. Thus, even
though the subsections shared many common field values, I hid those
common values away in a private Shared struct (see D105305). More
recently, however, @gkm added a public `Section` struct in D113241 that
served as an explicit way to store values that are common to an entire
set of subsections (aka InputSections). Now that we have another "common
value" struct, `Shared` has been rendered redundant. All its fields can
be moved into `Section` instead, and the pointer to `Shared` can be replaced
with a pointer to `Section`.

This `Section` pointer also has the advantage of letting us inspect other
subsections easily, simplifying the implementation of {D118798}.

P.S. I do think that having both `Section` and `InputSection` makes for
a slightly confusing naming scheme. I considered renaming `InputSection`
to `Subsection`, but that would break the symmetry with `OutputSection`.
It would also make us deviate from LLD-ELF's naming scheme.

This change is perf-neutral on my 3.2 GHz 16-Core Intel Xeon W machine:

             base           diff           difference (95% CI)
  sys_time   1.258 ± 0.031  1.248 ± 0.023  [  -1.6% ..   +0.1%]
  user_time  3.659 ± 0.047  3.658 ± 0.041  [  -0.5% ..   +0.4%]
  wall_time  4.640 ± 0.085  4.625 ± 0.063  [  -1.0% ..   +0.3%]
  samples    49             61

There's also no stat sig change in RSS (as measured by `time -l`):

           base                         diff                           difference (95% CI)
  time     998038627.097 ± 13567305.958 1003327715.556 ± 15210451.236  [  -0.2% ..   +1.2%]
  samples  31                           36

Reviewed By: #lld-macho, oontvoo

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

2 years agoRevert "[ProfileData] Read and symbolize raw memprof profiles."
Snehasish Kumar [Fri, 4 Feb 2022 00:09:23 +0000 (16:09 -0800)]
Revert "[ProfileData] Read and symbolize raw memprof profiles."

This reverts commit 26f978d4c5ad0d2217940ef7625b0c3c0d576988.

This patch added a transitive dependency on libcurl via symbolize.
See discussion
https://reviews.llvm.org/D116784#inline-1137928
https://reviews.llvm.org/D113717#3295350

2 years agogithub: Fix issue-subscriber workflow
Tom Stellard [Fri, 4 Feb 2022 00:11:04 +0000 (16:11 -0800)]
github: Fix issue-subscriber workflow

This stopped working due to additional dependencies added to github-automation.py
by daf82a51a0c2ba9990cde172a4a1b8c1004d584d

2 years ago[gn build] Set -fmsc-version=1920 on Windows
Arthur Eubanks [Thu, 3 Feb 2022 23:55:53 +0000 (15:55 -0800)]
[gn build] Set -fmsc-version=1920 on Windows

Now that the minimum version version of MSVC required to build LLVM has
been bumped, we see

  ../../llvm/include\llvm/Support/Compiler.h(94,2): error: LLVM requires
  at least VS 2019.
  #error LLVM requires at least VS 2019.

e.g. http://45.33.8.238/win/53703/step_4.txt

1920 corresponds to the earliest version of VS 2019.

Reviewed By: thakis

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

2 years agoRevert "[instrprof][NFC] Sort link components and dedupe."
Snehasish Kumar [Thu, 3 Feb 2022 23:41:24 +0000 (15:41 -0800)]
Revert "[instrprof][NFC] Sort link components and dedupe."

This reverts commit 28ba0b9f6dd6dd08c7c2380a0c00c7170d3ddf48.

clang ppc build failed
https://lab.llvm.org/buildbot#builders/121/builds/16080

2 years ago[LLDB][NativePDB] terminal entry has lower precedence than new entry
Zequan Wu [Thu, 3 Feb 2022 23:41:18 +0000 (15:41 -0800)]
[LLDB][NativePDB] terminal entry has lower precedence than new entry

2 years ago[instrprof][NFC] Sort link components and dedupe.
Snehasish Kumar [Thu, 3 Feb 2022 23:32:32 +0000 (15:32 -0800)]
[instrprof][NFC] Sort link components and dedupe.

Accidentally added a duplicate link component in D116784.

2 years ago[clang][utils] Remove StringRef lldb summary provider
Dave Lee [Tue, 11 Jan 2022 02:46:29 +0000 (18:46 -0800)]
[clang][utils] Remove StringRef lldb summary provider

Remove the `StringRef` summary provider in favor of the implementation in
`llvm/utils/lldbDataFormatters.py`.

This implementation was resulting in errors in some cases.

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

2 years ago[libc++] Fix chrono::duration constructor constraint
Tiago Macarios [Thu, 3 Feb 2022 15:23:15 +0000 (10:23 -0500)]
[libc++] Fix chrono::duration constructor constraint

As per [time.duration.cons]/1, the constructor constraint should be on
const Rep2&. As it is now the code will fail to compile in certain
cases, for example (https://godbolt.org/z/c7fPrcTYM):

     struct S{
          operator int() const&& noexcept = delete;
          operator int() const& noexcept;
     };

     const S &fun();

     auto k = std::chrono::microseconds{fun()};

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

2 years agogithub: Add actions to automate part of the release workflow
Tom Stellard [Thu, 3 Feb 2022 22:44:07 +0000 (14:44 -0800)]
github: Add actions to automate part of the release workflow

This adds support for automatically cherry-picking and testing fixes for the
release branch using 'commands' in issue comments.  The two supported commands are:

/cherry-pick <commit1> <commit2> ...

Which will backport and test commits from main.  And also

/branch owner/repo/branch

Which will test commits from the given branch.

Reviewed By: alexbatashev, kwk

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

2 years ago[SLP] Strengthen internal invariant assertions slightly
Philip Reames [Thu, 3 Feb 2022 21:46:30 +0000 (13:46 -0800)]
[SLP] Strengthen internal invariant assertions slightly

This builds on the invariant checks introduced in 1519629, and adds a couple more than seem to hold without additional work.

2 years agoRevert "[OpenMP] Don't use bound architecture when checking cache on the host"
Joseph Huber [Thu, 3 Feb 2022 22:43:02 +0000 (17:43 -0500)]
Revert "[OpenMP] Don't use bound architecture when checking cache on the host"

This reverts commit 9138d96f8b01605b213e8c4d587853a46cca3f44.

2 years ago[ProfileData] Read and symbolize raw memprof profiles.
Snehasish Kumar [Wed, 29 Dec 2021 23:52:11 +0000 (15:52 -0800)]
[ProfileData] Read and symbolize raw memprof profiles.

This change extends the RawMemProfReader to read all the sections of the
raw profile and symbolize the virtual addresses recorded as part of the
callstack for each allocation. For now the symbolization is used to
display the contents of the profile with llvm-profdata.

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

2 years ago[memprof] Print out the summary in YAML format.
Snehasish Kumar [Fri, 7 Jan 2022 00:14:41 +0000 (16:14 -0800)]
[memprof] Print out the summary in YAML format.

Print out the profile summary in YAML format to make it easier to for
tools and tests to read in the contents of the raw profile.

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

2 years ago[instrprof][NFC] Templatize the instrprof iterator.
Snehasish Kumar [Wed, 29 Dec 2021 23:58:44 +0000 (15:58 -0800)]
[instrprof][NFC] Templatize the instrprof iterator.

This change templatizes the InstrProfIterator where the default
specialization is based on the current usage, i.e. the reader_type is
InstrProfReader and the record_type (value_type) is
NamedInstrProfRecord. A subsequent patch will use the same iterator
template to implement an iterator for the RawMemProfReader.

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

2 years ago[DebugInfo] Move the SymbolizableObjectFile header to include/llvm.
Snehasish Kumar [Wed, 29 Dec 2021 23:46:22 +0000 (15:46 -0800)]
[DebugInfo] Move the SymbolizableObjectFile header to include/llvm.

This change moves the SymbolizableObjectFile header to
include/llvm/DebugInfo/Symbolize. Making this header available to other
llvm libraries simplifies use cases where implicit caching, multiple
platform support and other features of the Symbolizer class are not
required. This also makes the dependent libraries easier to unit test
by having mocks which derive from SymbolizableModule.

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

2 years ago[GlobalISel] Combine (G_*ADDO x, 0) -> x + no carry out
Jessica Paquette [Mon, 31 Jan 2022 22:13:18 +0000 (14:13 -0800)]
[GlobalISel] Combine (G_*ADDO x, 0) -> x + no carry out

Similar to the G_*MULO change.

The code for checking if a constant is legal/pre-legalize is shared between
these, and is kind of hairy. So, factor it out into a new function:
`isConstantLegalOrBeforeLegalizer`.

To make the refactoring clean, further refactor `isLegalOrBeforeLegalizer` into
a wrapper for two functions:

- `isPreLegalize`
- `isLegal`

This is a bit easier to read in general.

https://godbolt.org/z/KW7oszP1o

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

2 years ago[GlobalISel] Combine: (G_*MULO x, 0) -> 0 + no carry out
Jessica Paquette [Mon, 31 Jan 2022 18:42:19 +0000 (10:42 -0800)]
[GlobalISel] Combine: (G_*MULO x, 0) -> 0 + no carry out

Similar to the following combine in `DAGCombiner::visitMULO`:

```
  // fold (mulo x, 0) -> 0 + no carry out
  if (isNullOrNullSplat(N1))
    return CombineTo(N, DAG.getConstant(0, DL, VT),
                     DAG.getConstant(0, DL, CarryVT));
```

This fixes some generally poor codegen for `*mulo`:

https://godbolt.org/z/eTxYsvz8f

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

2 years ago[mlir] Keep sorted vector of registered operation names for efficient lookup
Eugene Zhulenev [Thu, 3 Feb 2022 21:16:14 +0000 (13:16 -0800)]
[mlir] Keep sorted vector of registered operation names for efficient lookup

I see a lot of array sorting in stack traces of our compiler, canonicalizer traverses this list every time it builds a pattern set, and it gets expensive very quickly.

Reviewed By: rriddle, mehdi_amini

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

2 years ago[OpenMP] Don't use bound architecture when checking cache on the host
Joseph Huber [Thu, 3 Feb 2022 00:07:39 +0000 (19:07 -0500)]
[OpenMP] Don't use bound architecture when checking cache on the host

When we are creating jobs for the new driver we first check the cache to
see if the job was already created as a part of the offloading
toolchain. This would sometimes fail if the bound architecture was set
for the host during offloading. We want to ingore this because it is not
relevant for looking up host actions. Previously it was set on some
machines and would cause the cache lookup to fail.

Reviewed By: jdoerfert

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

2 years ago[lld-macho] Minor clean up: use .find() to check for key existence rather than [...
Vy Nguyen [Thu, 3 Feb 2022 22:04:18 +0000 (17:04 -0500)]
[lld-macho] Minor clean up: use .find() to check for key existence rather than [], which would create a new entry.

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

2 years ago[LLDB] remove an extra register enum on windows x64
Zequan Wu [Thu, 3 Feb 2022 22:12:18 +0000 (14:12 -0800)]
[LLDB] remove an extra register enum on windows x64

2 years ago[libc++] Remove the std::string base class
Nikolas Klauser [Wed, 2 Feb 2022 19:15:40 +0000 (20:15 +0100)]
[libc++] Remove the std::string base class

Removing the base class of std::basic_string is not an ABI break, so we can remove any references to it from the header.

Reviewed By: ldionne, Mordante, #libc

Spies: libcxx-commits

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

2 years ago[clang-format][NFC] Code Tidies in UnwrappedLineFormatter
Björn Schäpers [Fri, 3 Dec 2021 07:13:57 +0000 (08:13 +0100)]
[clang-format][NFC] Code Tidies in UnwrappedLineFormatter

* Give I[1] and I[-1] a name:
  - Easier to understand
  - Easier to debug (since you don't go through operator[] everytime)
* TheLine->First != TheLine->Last follows since last is a l brace and
  first isn't.
* Factor the check for is(tok::l_brace) out.
* Drop else after return.

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

2 years ago[gn build] (manually) attempt to port 95d609b549bb
Nico Weber [Thu, 3 Feb 2022 21:53:34 +0000 (16:53 -0500)]
[gn build] (manually) attempt to port 95d609b549bb

2 years ago[clang-format] Use wider comment prefix space rule
ksyx [Thu, 3 Feb 2022 03:18:09 +0000 (22:18 -0500)]
[clang-format] Use wider comment prefix space rule

This commit changes the condition of requiring comment to start with
alphanumeric characters to make no change only for a certain set of
characters, currently horizontal whitespace and punctuation characters,
to support wider set of leading characters unrelated to documentation
generation directives.

Reviewed By: HazardyKnusperkeks
Differential Revision: https://reviews.llvm.org/D118869

2 years ago[VFS] Add back setFallthrough for downstream users
Ben Barham [Thu, 3 Feb 2022 21:35:16 +0000 (13:35 -0800)]
[VFS] Add back setFallthrough for downstream users

This fixes lldb's build. We can remove this in the future if we want but
for now this will be nicer to existing consumers.

2 years agoUse functions with prototypes when appropriate; NFC
Aaron Ballman [Thu, 3 Feb 2022 21:39:21 +0000 (16:39 -0500)]
Use functions with prototypes when appropriate; NFC

A significant number of our tests in C accidentally use functions
without prototypes. This patch converts the function signatures to have
a prototype for the situations where the test is not specific to K&R C
declarations. e.g.,

  void func();

becomes

  void func(void);

This is the first batch of tests being updated (there are a significant
number of other tests left to be updated).

2 years ago[cmake] Increase -fms-compatibility-version in Windows toolchain file
Shoaib Meenai [Thu, 3 Feb 2022 21:39:54 +0000 (13:39 -0800)]
[cmake] Increase -fms-compatibility-version in Windows toolchain file

Make it match LLVM's new minimum requirement (after https://reviews.llvm.org/D114639).

2 years ago[GSYM] Add Split Dwarf Support to DwarfTransformer
Alexander Yermolovich [Thu, 3 Feb 2022 21:39:03 +0000 (13:39 -0800)]
[GSYM] Add Split Dwarf Support to DwarfTransformer

The convert only worked on CUs in main binary.
If it's a skeleton CU it will now use the DWO CU
when invoking handleDie.

Test Plan:
llvm-lit

Reviewed By: clayborg

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

2 years agoRevert "[clang] Mark `trivial_abi` types as "trivially relocatable"."
Dmitri Gribenko [Thu, 3 Feb 2022 21:19:35 +0000 (22:19 +0100)]
Revert "[clang] Mark `trivial_abi` types as "trivially relocatable"."

This reverts commit 19aa2db023c0128913da223d4fb02c474541ee22. It breaks
a PS4 buildbot.

2 years ago[llvm-objcopy][COFF] Implement --update-section
Alex Brachet [Thu, 3 Feb 2022 21:30:42 +0000 (21:30 +0000)]
[llvm-objcopy][COFF] Implement --update-section

Reviewed By: jhenderson, MaskRay

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

2 years ago[SLP] Add basic self consistency asserts into scheduling
Philip Reames [Thu, 3 Feb 2022 21:23:02 +0000 (13:23 -0800)]
[SLP] Add basic self consistency asserts into scheduling

The idea here is to have a verify routine we can call during scheduling to ensure broken invariants are reported.  The intent is to help in debugging scheduling bugs.

At the moment, only the most basic properties are checked as adding several I thought held reported failures.

2 years ago[mlir][scf] Fix bug in pipelining prologue emission
Thomas Raoux [Thu, 3 Feb 2022 19:42:49 +0000 (11:42 -0800)]
[mlir][scf] Fix bug in pipelining prologue emission

Induction variable calculation was ignoring scf.for step value. Fix it to get
the correct induction variable value in the prologue.

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

2 years ago[VFS] Add a "redirecting-with" field to overlays
Ben Barham [Thu, 3 Feb 2022 20:53:22 +0000 (12:53 -0800)]
[VFS] Add a "redirecting-with" field to overlays

Extend "fallthrough" to allow a third option: "fallback". Fallthrough
allows the original path to used if the redirected (or mapped) path
fails. Fallback is the reverse of this, ie. use the original path and
fallback to the mapped path otherwise.

While this result *can* be achieved today using multiple overlays, this
adds a much more intuitive option. As an example, take two directories
"A" and "B". We would like files from "A" to be used, unless they don't
exist, in which case the VFS should fallback to those in "B".

With the current fallthrough option this is possible by adding two
overlays: one mapping from A -> B and another mapping from B -> A. Since
the frontend *nests* the two RedirectingFileSystems, the result will
be that "A" is mapped to "B" and back to "A", unless it isn't in "A" in
which case it fallsthrough to "B" (or fails if it exists in neither).

Using "fallback" semantics allows a single overlay instead: one mapping
from "A" to "B" but only using that mapping if the operation in "A"
fails first.

"redirect-only" is used to represent the current "fallthrough: false"
case.

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

2 years ago[HWASan] Add __hwasan_init to .preinit_array.
Matt Morehouse [Thu, 3 Feb 2022 21:07:11 +0000 (13:07 -0800)]
[HWASan] Add __hwasan_init to .preinit_array.

Fixes segfaults on x86_64 caused by instrumented code running before
shadow is set up.

Reviewed By: pcc

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

2 years ago[AMDGPU] Fix scheduler live-ins with debug inst at start of block
Vang Thao [Wed, 2 Feb 2022 23:33:40 +0000 (15:33 -0800)]
[AMDGPU] Fix scheduler live-ins with debug inst at start of block

GCNDownwardRPTracker RPTracker.reset() skips debug instructions for NextMI so RPTracker.getNext() will never give the beginning of a sched region if it is a debug value. In this case we will never set the live-ins for that block.

Add check to see if getNext also equals the MI after skipping debug instructions.

Reviewed By: rampitec

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

2 years ago[nfc][regalloc] const LiveIntervals within the allocator
Mircea Trofin [Thu, 3 Feb 2022 17:07:42 +0000 (09:07 -0800)]
[nfc][regalloc] const LiveIntervals within the allocator

Once built, LiveIntervals are immutable. This patch captures that.

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

2 years ago[tests] Add coverage for SLP reschedule event
Philip Reames [Thu, 3 Feb 2022 20:22:25 +0000 (12:22 -0800)]
[tests] Add coverage for SLP reschedule event

This is slightly reduced from the crash reported against D117951.

2 years ago[SampleProfile] Reduce indentation with an early return (NFC)
Kazu Hirata [Thu, 3 Feb 2022 20:22:23 +0000 (12:22 -0800)]
[SampleProfile] Reduce indentation with an early return (NFC)

2 years ago[CodeGenPrepare] Avoid out-of-bounds shift
Bjorn Pettersson [Mon, 31 Jan 2022 12:49:35 +0000 (13:49 +0100)]
[CodeGenPrepare] Avoid out-of-bounds shift

AddressingModeMatcher::matchOperationAddr may attempt to shift a
variable by the same amount of steps as found in the IR in a SHL
instruction. This was done without considering that there could be
undefined behavior in the IR, so the shift performed when compiling
could end up having undefined behavior as well.

This patch avoid UB in the codegenprepare by making sure that we
limit the shift amount used, in a similar way as already being done
in CodeGenPrepare::optimizeLoadExt.

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

2 years ago[AMDGPU] Fix windows build warning with IMMBitSelConst. NFC.
Stanislav Mekhanoshin [Thu, 3 Feb 2022 19:44:45 +0000 (11:44 -0800)]
[AMDGPU] Fix windows build warning with IMMBitSelConst. NFC.

VS gives this warning for an integer constant:
AMDGPUGenDAGISel.inc(214687): warning C4334: '<<': result of 32-bit
shift implicitly converted to 64 bits (was 64-bit shift intended?)

2 years ago[lld][clang][cmake] Clean up a few things
John Ericson [Wed, 2 Feb 2022 15:37:13 +0000 (15:37 +0000)]
[lld][clang][cmake] Clean up a few things

- If not using `llvm-config`, `LLVM_MAIN_SRC_DIR` now has a sane default

- `LLVM_CONFIG_PATH` will continue to work for LLD for back compat.

- More quoting of paths in an abundance of caution.

Reviewed By: nikic

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

2 years ago[mlir:Vector][NFC] Remove unnecessary dependency on Affine
River Riddle [Thu, 3 Feb 2022 19:45:39 +0000 (11:45 -0800)]
[mlir:Vector][NFC] Remove unnecessary dependency on Affine

2 years ago[LLDB] Fix window bot failure
Zequan Wu [Thu, 3 Feb 2022 01:12:40 +0000 (17:12 -0800)]
[LLDB] Fix window bot failure

This attempts to fix this bot failure: https://lab.llvm.org/buildbot/#/builders/83/builds/14736 caused by D118750 by un-xfail those expected failed tests.

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

2 years ago[AArch64][SVE] Add more folds to make use of gather/scatter with 32-bit indices
Caroline Concatto [Thu, 13 Jan 2022 16:52:41 +0000 (16:52 +0000)]
[AArch64][SVE] Add more folds to make use of gather/scatter with 32-bit indices

In AArch64ISelLowering.cpp this patch implements this fold:

1) GEP (%ptr, SHL ((stepvector(A) + splat(%offset))) << splat(B)))
into GEP (%ptr + (%offset << B), step_vector (A << B))

The above transform simplifies the index operand so that it can be expressed
as i32 elements.
This allows using only one gather/scatter assembly instruction instead of two.

Patch by Paul Walker (@paulwalker-arm).

Depends on D117900

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