platform/upstream/llvm.git
3 years ago[dfsan] Track origin at loads
Jianzhou Zhao [Wed, 21 Apr 2021 04:54:29 +0000 (04:54 +0000)]
[dfsan] Track origin at loads

    The first version of origin tracking tracks only memory stores. Although
    this is sufficient for understanding correct flows, it is hard to figure
    out where an undefined value is read from. To find reading undefined values,
    we still have to do a reverse binary search from the last store in the chain
    with printing and logging at possible code paths. This is
    quite inefficient.

    Tracking memory load instructions can help this case. The main issues of
    tracking loads are performance and code size overheads.

    With tracking only stores, the code size overhead is 38%,
    memory overhead is 1x, and cpu overhead is 3x. In practice #load is much
    larger than #store, so both code size and cpu overhead increases. The
    first blocker is code size overhead: link fails if we inline tracking
    loads. The workaround is using external function calls to propagate
    metadata. This is also the workaround ASan uses. The cpu overhead
    is ~10x. This is a trade off between debuggability and performance,
    and will be used only when debugging cases that tracking only stores
    is not enough.

Reviewed By: gbalats

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

3 years ago[libc++] [test] Fix nodiscard_extensions.pass.cpp in _LIBCPP_DEBUG mode.
Arthur O'Dwyer [Thu, 22 Apr 2021 16:15:09 +0000 (12:15 -0400)]
[libc++] [test] Fix nodiscard_extensions.pass.cpp in _LIBCPP_DEBUG mode.

`std::clamp(2, 1, 3, std::greater<int>())` has UB because (1 > 3) is false.
Swap the operands to fix the _LIBCPP_ASSERT failure in this test.

3 years ago[flang][openmp] Add General Semantic Checks for Allocate Directive
Irina Dobrescu [Thu, 22 Apr 2021 15:45:19 +0000 (15:45 +0000)]
[flang][openmp] Add General Semantic Checks for Allocate Directive

This patch adds semantic checks for the General Restrictions of the
Allocate Directive.

Since the requires directive is not yet implemented in Flang, the
restriction:
```
allocate directives that appear in a target region must
specify an allocator clause unless a requires directive with the
dynamic_allocators clause is present in the same compilation unit
```
will need to be updated at a later time.

A different patch will be made with the Fortran specific restrictions of
this directive.

I have used the code from https://reviews.llvm.org/D89395 for the
CheckObjectListStructure function.

Co-authored-by: Isaac Perry <isaac.perry@arm.com>
Reviewed By: clementval, kiranchandramohan

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

3 years ago[x86] remove stale comment from test file; NFC
Sanjay Patel [Thu, 22 Apr 2021 16:11:47 +0000 (12:11 -0400)]
[x86] remove stale comment from test file; NFC

3 years ago[libc++] Eliminate macro _LIBCPP_UNUSED_VAR. NFCI.
Arthur O'Dwyer [Mon, 19 Apr 2021 02:17:44 +0000 (22:17 -0400)]
[libc++] Eliminate macro _LIBCPP_UNUSED_VAR. NFCI.

Reviewed as part of https://reviews.llvm.org/D100737

3 years ago[libc++] Fix some typos and remove unused macros. NFCI.
Arthur O'Dwyer [Mon, 19 Apr 2021 02:15:38 +0000 (22:15 -0400)]
[libc++] Fix some typos and remove unused macros. NFCI.

Reviewed as part of https://reviews.llvm.org/D100737

3 years ago[SLP]Skip undefs trying to find perfect/shuffled tree entries matching.
Alexey Bataev [Thu, 22 Apr 2021 13:15:27 +0000 (06:15 -0700)]
[SLP]Skip undefs trying to find perfect/shuffled tree entries matching.

We can skip check for undefs trying to find perfect/shuffled tree
entries matching, they can be ignored completely improving the final
cost/vectorization results.

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

3 years ago[llvm-profgen] A couple tweaks to the testing harness.
Hongtao Yu [Thu, 22 Apr 2021 01:02:11 +0000 (18:02 -0700)]
[llvm-profgen] A couple tweaks to the testing harness.

1. Remove unnecessary filtering code.
2. Add llvm-profgen to tool substitutions.

Reviewed By: wenlei

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

3 years ago[flang] Fix checking of argument passing for parameterized derived types
Peter Steinfeld [Wed, 21 Apr 2021 19:12:26 +0000 (12:12 -0700)]
[flang] Fix checking of argument passing for parameterized derived types

We were erroneously not taking into account the constant values of LEN type
parameters of parameterized derived types when checking for argument
compatibility.  The required checks are identical to those for assignment
compatibility.  Since argument compatibility is checked in .../lib/Evaluate and
assignment compatibility is checked in .../lib/Semantics, I moved the common
code into .../lib/Evaluate/tools.cpp and changed the assignment compatibility
checking code to call it.

After implementing these new checks, tests in resolve53.f90 were failing
because the tests were erroneous.  I fixed these tests and added new tests
to call03.f90 to test argument passing of parameterized derived types more
completely.

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

3 years ago[flang][driver][Revert] Reverts f18 to allow options passed to -W
Arnamoy Bhattacharyya [Thu, 22 Apr 2021 15:45:30 +0000 (11:45 -0400)]
[flang][driver][Revert] Reverts f18 to allow options passed to -W

Reviewed By: awarzynski

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

3 years ago[PowerPC] Add missing casts for vec_xlds and vec_load_splats
Nemanja Ivanovic [Thu, 22 Apr 2021 15:28:50 +0000 (10:28 -0500)]
[PowerPC] Add missing casts for vec_xlds and vec_load_splats

The previous commits just missed some pointer casts and ended up
producing warnings.

3 years ago[PowerPC] Add vec_vclz as an alias for vec_cntlz in altivec.h
Nemanja Ivanovic [Thu, 22 Apr 2021 13:47:31 +0000 (08:47 -0500)]
[PowerPC] Add vec_vclz as an alias for vec_cntlz in altivec.h

Another addition for compatibility with XLC. The functions have the
same overloads so just add it as a preprocessor define.

3 years ago[PowerPC] Add vec_load_splats to altivec.h
Nemanja Ivanovic [Thu, 22 Apr 2021 12:27:51 +0000 (07:27 -0500)]
[PowerPC] Add vec_load_splats to altivec.h

Add these overloads for compatibility with XLC. This is a word
load-and-splat.

3 years ago[PowerPC] Add vec_xlds to altivec.h
Nemanja Ivanovic [Thu, 22 Apr 2021 11:43:42 +0000 (06:43 -0500)]
[PowerPC] Add vec_xlds to altivec.h

Add these overloads for compatibility with XLC. This is a doubleword
load-and-splat.

3 years ago[PowerPC] Add vec_roundz as alias for vec_trunc in altivec.h
Nemanja Ivanovic [Thu, 22 Apr 2021 10:53:37 +0000 (05:53 -0500)]
[PowerPC] Add vec_roundz as alias for vec_trunc in altivec.h

Add the overloads for compatibility with XLC.

3 years ago[PowerPC] Add vec_roundp as alias for vec_ceil
Nemanja Ivanovic [Thu, 22 Apr 2021 10:47:00 +0000 (05:47 -0500)]
[PowerPC] Add vec_roundp as alias for vec_ceil

Add the overloads for compatibility with XLC.

3 years ago[PowerPC] Add missing VSX guard for vec_roundm with vector double
Nemanja Ivanovic [Thu, 22 Apr 2021 10:41:37 +0000 (05:41 -0500)]
[PowerPC] Add missing VSX guard for vec_roundm with vector double

The guard was missed in the previous commit.

3 years ago[PowerPC] Add vec_roundm as alias for vec_floor in altivec.h
Nemanja Ivanovic [Thu, 22 Apr 2021 10:38:11 +0000 (05:38 -0500)]
[PowerPC] Add vec_roundm as alias for vec_floor in altivec.h

Add the overloads for compatibility with XLC.

3 years ago[libc++] Re-apply `std::indirectly_readable` and `std::indirectly_writable`
Louis Dionne [Thu, 22 Apr 2021 15:05:30 +0000 (11:05 -0400)]
[libc++] Re-apply `std::indirectly_readable` and `std::indirectly_writable`

That was originally committed in 04733181b513 and then reverted in
a9f11cc0d965 because it broke several people.

The problem was a missing include of __iterator/concepts.h, which has now
been fixed.

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

3 years ago[Hexagon] Unmasked and masked load pair to dame bae -? one load and selects
Coplin, Jared [Thu, 22 Apr 2021 15:15:46 +0000 (10:15 -0500)]
[Hexagon] Unmasked and masked load pair to dame bae -? one load and selects

3 years ago[lld/mac] tweak comment in a test
Nico Weber [Thu, 22 Apr 2021 15:14:58 +0000 (11:14 -0400)]
[lld/mac] tweak comment in a test

3 years ago[AArch64] Block tryCombineToBSL combines for vectors wider than NEON
Joe Ellis [Thu, 22 Apr 2021 15:07:26 +0000 (15:07 +0000)]
[AArch64] Block tryCombineToBSL combines for vectors wider than NEON

There are no patterns for the AArch64ISD::BSP ISD node for anything
other than NEON vectors at the moment. As a result, if we hit these
combines for vectors wider than a NEON vector (such as what we might get
with fixed length SVE) we will fail to lower.

This patch simply prevents us from attempting the combines if the input
vector type is too wide.

Reviewed By: peterwaller-arm

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

3 years ago[OPENMP]Mark test as unsupported to avoid possible unexpected passes,
Alexey Bataev [Thu, 22 Apr 2021 14:58:56 +0000 (07:58 -0700)]
[OPENMP]Mark test as unsupported to avoid possible unexpected passes,
NFC.

3 years ago[LoopVectorize] Fix bug where predicated loads/stores were dropped
Joe Ellis [Wed, 31 Mar 2021 10:41:15 +0000 (10:41 +0000)]
[LoopVectorize] Fix bug where predicated loads/stores were dropped

This commit fixes a bug where the loop vectoriser fails to predicate
loads/stores when interleaving for targets that support masked
loads and stores.

Code such as:

     1  void foo(int *restrict data1, int *restrict data2)
     2  {
     3    int counter = 1024;
     4    while (counter--)
     5      if (data1[counter] > data2[counter])
     6        data1[counter] = data2[counter];
     7  }

... could previously be transformed in such a way that the predicated
store implied by:

    if (data1[counter] > data2[counter])
       data1[counter] = data2[counter];

... was lost, resulting in miscompiles.

This bug was causing some tests in llvm-test-suite to fail when built
for SVE.

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

3 years ago[SLP]Replace more `TTI` with `TTIRef`, NFC.
Alexey Bataev [Thu, 22 Apr 2021 14:53:20 +0000 (07:53 -0700)]
[SLP]Replace more `TTI` with `TTIRef`, NFC.

To pacify MSVC buildbots.

3 years ago[SLP]Added explicit ref to TargetTransformInfo to try to pacify MSVC
Alexey Bataev [Thu, 22 Apr 2021 14:49:08 +0000 (07:49 -0700)]
[SLP]Added explicit ref to TargetTransformInfo to try to pacify MSVC
buildbots, NFC.

3 years ago[lld/mac] make a few "named parameter comments" more consistent
Nico Weber [Thu, 22 Apr 2021 14:44:56 +0000 (10:44 -0400)]
[lld/mac] make a few "named parameter comments" more consistent

Most of LLVM and almost all of lld/MachO uses `/*foo=*/bar` style.
No behavior change.

3 years ago[SLP]Improve cost model for the vectorized extractelements.
Alexey Bataev [Tue, 6 Apr 2021 17:26:25 +0000 (10:26 -0700)]
[SLP]Improve cost model for the vectorized extractelements.

1. No need to call `areAllUsersVectorized` as later the cost is
   calculated only if the instruction has one use and gets vectorized.
2. Need to calculate the cost of the dead extractelement more precisely,
   taking the vector type of the vector operand, not the resulting
   vector type.

Part of D57059.

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

3 years ago[LoopIdiom] Added testcase for double memset (fixed in LLVM 12); NFC
Dávid Bolvanský [Thu, 22 Apr 2021 14:39:07 +0000 (16:39 +0200)]
[LoopIdiom] Added testcase for double memset (fixed in LLVM 12); NFC

3 years ago[C++4OpenCL] Add extra diagnostics for kernel argument types
Anastasia Stulova [Thu, 22 Apr 2021 12:46:46 +0000 (13:46 +0100)]
[C++4OpenCL] Add extra diagnostics for kernel argument types

Add restrictions on type layout (PR48099):
- Types passed by pointer or reference must be standard layout types.
- Types passed by value must be POD types.

Patch by olestrohm (Ole Strohm)!

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

3 years ago[mlir] Move PyConcreteAttribute to header. NFC.
Alex Zinenko [Thu, 22 Apr 2021 13:52:01 +0000 (15:52 +0200)]
[mlir] Move PyConcreteAttribute to header. NFC.

This allows out-of-tree users to derive PyConcreteAttribute to bind custom
attributes.

Reviewed By: nicolasvasilache

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

3 years ago[OpenCL] Add missing C++ legacy atomics with generic
Sven van Haastregt [Thu, 22 Apr 2021 14:08:36 +0000 (15:08 +0100)]
[OpenCL] Add missing C++ legacy atomics with generic

https://reviews.llvm.org/D62335 added some C++ for OpenCL specific
builtins to opencl-c.h, but these were not mirrored to the TableGen
builtin functions yet.

The TableGen builtins machinery does not have dedicated version
handling for C++ for OpenCL at the moment: all builtin versioning is
tied to `LangOpts.OpenCLVersion` (i.e., the OpenCL C version).  As a
workaround, to add builtins that are only available in C++ for OpenCL,
we define a function extension guarded by the __cplusplus macro.

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

Fixes PR50041.

3 years agoRevert "[Hexagon] Masked and unmasked load to same base -> load and two selects"
Krzysztof Parzyszek [Thu, 22 Apr 2021 14:06:18 +0000 (09:06 -0500)]
Revert "[Hexagon] Masked and unmasked load to same base -> load and two selects"

This reverts commit 96dc8d7e7dee68592e56d69184b92fcb021cdb9c.

It breaks a few builds.

3 years agoAArch64: support mixed-size fp <-> int conversions in GlobalISel.
Tim Northover [Tue, 20 Apr 2021 14:05:11 +0000 (15:05 +0100)]
AArch64: support mixed-size fp <-> int conversions in GlobalISel.

3 years agoAArch64: expand G_DIVREM operations in GlobalISel
Tim Northover [Tue, 20 Apr 2021 09:19:02 +0000 (10:19 +0100)]
AArch64: expand G_DIVREM operations in GlobalISel

We don't have a specific instruction for these, so they should be expanded to
whatever separate division & multiplication is needed.

3 years agoRevert "[libcxx][iterator] adds `std::indirectly_readable` and `std::indirectly_writa...
David Zarzycki [Thu, 22 Apr 2021 13:36:49 +0000 (09:36 -0400)]
Revert "[libcxx][iterator] adds `std::indirectly_readable` and `std::indirectly_writable`"

This reverts commit 04733181b5136e2b3df2b37c6bdd9e25f8afecd0 which was
failing for multiple people.

3 years agoUpdate shebang for clang-format-diff script to python3.
Paula Toth [Thu, 22 Apr 2021 13:43:06 +0000 (06:43 -0700)]
Update shebang for clang-format-diff script to python3.

Different distributions have different strategies migrating the `python` symlink. Debian and its derivatives provide `python-is-python2` and `python-is-python3`. If neither is installed, the user gets no `/usr/bin/python`. The clang-format-diff script and consequently `arc diff` can thus fail with a python not found error.  Since we require python greater than 3.6 as part of llvm prerequisites (https://llvm.org/docs/GettingStarted.html#software), let's go ahead and update this shebang.

Reviewed By: MaskRay

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

3 years ago[Hexagon] Masked and unmasked load to same base -> load and two selects
Coplin, Jared [Thu, 22 Apr 2021 13:44:01 +0000 (08:44 -0500)]
[Hexagon] Masked and unmasked load to same base -> load and two selects

3 years ago[lld/mac] add a comment pointing to a test that took me a while to find
Nico Weber [Thu, 22 Apr 2021 13:09:39 +0000 (09:09 -0400)]
[lld/mac] add a comment pointing to a test that took me a while to find

3 years ago[X86] Regenerate atomic-eflags-reuse.ll
Simon Pilgrim [Thu, 22 Apr 2021 13:06:57 +0000 (14:06 +0100)]
[X86] Regenerate atomic-eflags-reuse.ll

3 years ago[LTO] Caching.h - remove unused <string> include. NFCI.
Simon Pilgrim [Thu, 22 Apr 2021 10:40:54 +0000 (11:40 +0100)]
[LTO] Caching.h - remove unused <string> include. NFCI.

3 years ago[InstCombine][NFC] Use --check-globals flag in tests.
Dawid Jurczak [Thu, 22 Apr 2021 13:06:20 +0000 (15:06 +0200)]
[InstCombine][NFC] Use --check-globals flag in tests.

This patch adds strings content checking to printf-2.ll via --check-globals flag.

Split off from D100724.

Reviewed By: xbolva00

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

3 years ago[SimplifyLibCalls][NFC] Use StringRef::back instead explicit indexing.
Dawid Jurczak [Thu, 22 Apr 2021 13:01:44 +0000 (15:01 +0200)]
[SimplifyLibCalls][NFC] Use StringRef::back instead explicit indexing.

Split off from D100724.

Reviewed By: xbolva00

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

3 years ago[DAGCombiner] Allow operand of step_vector to be negative.
Jun Ma [Mon, 19 Apr 2021 09:16:08 +0000 (17:16 +0800)]
[DAGCombiner] Allow operand of step_vector to be negative.

It is proper to relax non-negative limitation of step_vector.
Also this patch adds more combines for step_vector:
(sub X, step_vector(C)) -> (add X,  step_vector(-C))

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

3 years ago[mlir] Add `tensor.reshape`.
Alexander Belyaev [Thu, 22 Apr 2021 12:50:13 +0000 (14:50 +0200)]
[mlir] Add `tensor.reshape`.

This operation a counterpart of `memref.reshape`.

RFC [Reshape Ops Restructuring](https://llvm.discourse.group/t/rfc-reshape-ops-restructuring/3310)

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

3 years ago[X86][AMX][NFC] Remove assert for comparison between different BBs.
Wang, Pengfei [Thu, 22 Apr 2021 09:26:36 +0000 (17:26 +0800)]
[X86][AMX][NFC] Remove assert for comparison between different BBs.

SmallSet may use operator `<` when we insert MIRef elements, so we
cannot limit the comparison between different BBs.

We allow MIRef() to be less that any initialized MIRef object, otherwise,
we always reture false when compare between different BBs.

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

3 years ago[gn build] (manually) port aee6c86c4d better
Nico Weber [Thu, 22 Apr 2021 12:40:48 +0000 (08:40 -0400)]
[gn build] (manually) port aee6c86c4d better

"EmptyNodeIntrospection.inc.in" needs to be a source of the action,
so that ninja knows to rerun this action if that input changes.

3 years ago[AST] Make comment a bit more specific
Stephen Kelly [Thu, 22 Apr 2021 12:40:01 +0000 (13:40 +0100)]
[AST] Make comment a bit more specific

3 years ago[gn build] (manually) port aee6c86c4d
Nico Weber [Thu, 22 Apr 2021 12:36:19 +0000 (08:36 -0400)]
[gn build] (manually) port aee6c86c4d

3 years ago[lldb/elf] Avoid side effects in function calls ParseUnwindSymbols
Pavel Labath [Thu, 22 Apr 2021 12:13:27 +0000 (14:13 +0200)]
[lldb/elf] Avoid side effects in function calls ParseUnwindSymbols

This addresses post-commit feedback to cd64273.

3 years agoclang: libstdc++ LWM is 4.8.3
Nathan Sidwell [Wed, 14 Apr 2021 11:18:23 +0000 (04:18 -0700)]
clang: libstdc++ LWM is 4.8.3

Document oldest libstdc++ as 4.8.3, remove a hack for a 4.6 issue.

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

3 years ago[AArch64][SVE] Regression test all ACLE tests with C++
Sander de Smalen [Wed, 7 Apr 2021 16:06:22 +0000 (17:06 +0100)]
[AArch64][SVE] Regression test all ACLE tests with C++

We found issues with a number of intrinsics when building them with
C++, so it makes sense to guard these tests with some extra RUN lines
to build the tests in C++ mode.

3 years ago[-Wcalled-once] Do not run analysis on Obj-C++
Valeriy Savchenko [Wed, 21 Apr 2021 13:49:06 +0000 (16:49 +0300)]
[-Wcalled-once] Do not run analysis on Obj-C++

Objective-C++ is not yet suppoerted.

rdar://76729552

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

3 years ago[MLIR][Shape] Add canonicalizations for `shape.broadcast`
Frederik Gossen [Thu, 22 Apr 2021 12:09:14 +0000 (14:09 +0200)]
[MLIR][Shape] Add canonicalizations for `shape.broadcast`

Eliminate empty shapes from the operands, partially fold all constant shape
operands, and fix normal folding.

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

3 years ago[lldb] Don't leak LineSequence in PDB parsers
Raphael Isemann [Thu, 22 Apr 2021 10:29:08 +0000 (12:29 +0200)]
[lldb] Don't leak LineSequence in PDB parsers

`InsertSequence` doesn't take ownership of the pointer so releasing this pointer
is just leaking memory.

Follow up to D100806 that was fixing other leak sanitizer test failures

Reviewed By: JDevlieghere

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

3 years ago[clang][deps] Check extra args in tests
Jan Svoboda [Thu, 22 Apr 2021 11:55:23 +0000 (13:55 +0200)]
[clang][deps] Check extra args in tests

These flags are being generated by `clang-scan-deps` and it makes sense to ensure it keeps doing so.

3 years ago[AST] Add clarification comment
Stephen Kelly [Thu, 22 Apr 2021 11:51:25 +0000 (12:51 +0100)]
[AST] Add clarification comment

3 years ago[lldb] XFAIL TestStoppedInStaticMemberFunction on Windows
Raphael Isemann [Thu, 22 Apr 2021 11:45:15 +0000 (13:45 +0200)]
[lldb] XFAIL TestStoppedInStaticMemberFunction on Windows

It seems we can't find the symbols of static members on Windows? The bug is not
 relevant to what this test is actually testing so let's just XFAIL it.

3 years agoFix typo "beneficiates" in comments
Jay Foad [Thu, 22 Apr 2021 11:29:49 +0000 (12:29 +0100)]
Fix typo "beneficiates" in comments

3 years ago[AST] De-duplicate empty node introspection
Stephen Kelly [Wed, 17 Mar 2021 01:48:50 +0000 (01:48 +0000)]
[AST] De-duplicate empty node introspection

This way we can add support for other nodes without duplication.

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

3 years ago[lldb-vscode] Use a DenseMap to pacify overly aggressive linters
Benjamin Kramer [Thu, 22 Apr 2021 11:01:16 +0000 (13:01 +0200)]
[lldb-vscode] Use a DenseMap to pacify overly aggressive linters

Some linters get rather upset upon seeing
`std::unordered_map<const char*`, because it looks like a map of
strings but isn't. lldb uses interned strings so this is not a problem.
DenseMap is a better data structure for this anyways, so use that
instead.

3 years ago[Bitcode] Ensure DIArgList in bitcode has no null or forward metadata refs
Stephen Tozer [Wed, 21 Apr 2021 15:56:38 +0000 (16:56 +0100)]
[Bitcode] Ensure DIArgList in bitcode has no null or forward metadata refs

This patch fixes an issue in which ConstantAsMetadata arguments to a
DIArglist, as well as the Constant values referenced by that metadata,
would not be always be emitted correctly into bitcode. This patch fixes
this issue firstly by searching for ConstantAsMetadata in DIArgLists
(previously we would only search for them when directly wrapped in
MetadataAsValue), and secondly by enumerating all of a DIArgList's
arguments directly prior to enumerating the DIArgList itself.

This patch also adds a number of asserts, and no longer treats the
arguments to a DIArgList as optional fields when reading/writing to
bitcode.

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

3 years ago[Matrix] Support #pragma clang fp
Hamza Mahfooz [Thu, 22 Apr 2021 08:15:48 +0000 (09:15 +0100)]
[Matrix] Support #pragma clang fp

From https://bugs.llvm.org/show_bug.cgi?id=49739:

Currently, `#pragma clang fp` are ignored for matrix types.

For the code below, the `contract` fast-math flag should be added to the generated call to `llvm.matrix.multiply` and `fadd`

```
typedef float fx2x2_t __attribute__((matrix_type(2, 2)));

void foo(fx2x2_t &A, fx2x2_t &C, fx2x2_t &B) {
  #pragma clang fp contract(fast)
  C = A*B + C;
}
```

Reviewed By: fhahn, mibintc

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

3 years agoMipsSEFrameLowering.h - remove unused headers. NFCI.
Simon Pilgrim [Thu, 22 Apr 2021 10:11:09 +0000 (11:11 +0100)]
MipsSEFrameLowering.h - remove unused headers. NFCI.

3 years ago[X86][AVX] Add PR49971 test case
Simon Pilgrim [Thu, 22 Apr 2021 09:57:19 +0000 (10:57 +0100)]
[X86][AVX] Add PR49971 test case

This is a llvm12 only bug, and is already avoided in trunk, but we should keep track of it.

3 years ago[PowerPC] Add vec_roundc as alias for vec_rint in altivec.h
Nemanja Ivanovic [Thu, 22 Apr 2021 10:30:50 +0000 (05:30 -0500)]
[PowerPC] Add vec_roundc as alias for vec_rint in altivec.h

For compatibility with XLC, add these overloads.

3 years ago[AST] Add NestedNameSpecifierLoc accessors to node introspection
Stephen Kelly [Thu, 15 Apr 2021 20:02:10 +0000 (21:02 +0100)]
[AST] Add NestedNameSpecifierLoc accessors to node introspection

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

3 years ago[lldb][NFC] Fix unsigned/signed cmp warning in MainLoopTest
Raphael Isemann [Thu, 22 Apr 2021 10:19:15 +0000 (12:19 +0200)]
[lldb][NFC] Fix unsigned/signed cmp warning in MainLoopTest

The gtest checks compare all against unsigned int constants so this also needs
to be unsigned.

3 years ago[lldb] Add support for evaluating expressions in static member functions
Raphael Isemann [Mon, 19 Apr 2021 13:50:10 +0000 (15:50 +0200)]
[lldb] Add support for evaluating expressions in static member functions

At the moment the expression parser doesn't support evaluating expressions in
static member functions and just pretends the expression is evaluated within a
non-member function. This causes that all static members are inaccessible when
doing unqualified name lookup.

This patch adds support for evaluating in static member functions. It
essentially just does the same setup as what LLDB is already doing for
non-static member functions (i.e., wrapping the expression in a fake member
function) with the difference that we now mark the wrapping function as static
(to prevent access to non-static members).

Reviewed By: shafik, jarin

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

3 years ago[PowerPC] Improve codegen for vector fp to int widening conversions
Nemanja Ivanovic [Thu, 22 Apr 2021 03:16:35 +0000 (22:16 -0500)]
[PowerPC] Improve codegen for vector fp to int widening conversions

We currently do not utilize instructions that convert single
precision vectors to doubleword integer vectors. These conversions
come up in code occasionally and this improvement allows us to
open code some functions that need to be added to altivec.h.

3 years ago[mlir] Move memref-tests from standard to memref folder.
Thomas Schmeyer [Fri, 16 Apr 2021 15:33:06 +0000 (17:33 +0200)]
[mlir] Move memref-tests from standard to memref folder.

Split memref-test from standard test and move them to the folder MemRef.

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

3 years ago[AArch64] Fix calling windows varargs with floats in fixed args from non-windows...
Martin Storsjö [Tue, 20 Apr 2021 21:05:01 +0000 (00:05 +0300)]
[AArch64] Fix calling windows varargs with floats in fixed args from non-windows functions

When inspecting the calling convention, for calling windows functions
from a non-windows function, inspect the calling convention of
the called function, not the caller.

Also remove an unnecessary parameter to AArch64CallLowering
OutgoingArgHandler.

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

3 years ago[clang][deps] Include "-cc1" in the arguments
Jan Svoboda [Wed, 21 Apr 2021 11:25:31 +0000 (13:25 +0200)]
[clang][deps] Include "-cc1" in the arguments

To simplify tools consuming dependency scanning results, prepend the "-cc1" argument by default.

Reviewed By: Bigcheese

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

3 years ago[mlir][linalg] remove interchange option on linalg to loop lowering.
Tobias Gysi [Thu, 22 Apr 2021 08:22:37 +0000 (08:22 +0000)]
[mlir][linalg] remove interchange option on linalg to loop lowering.

The interchange option attached to the linalg to loop lowering affects only the loops and does not update the memory accesses generated in to body of the operation. Instead of performing the interchange during the loop lowering use the interchange pattern.

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

3 years agoclang-format: [JS] do not merge side-effect imports.
Martin Probst [Thu, 22 Apr 2021 05:54:11 +0000 (07:54 +0200)]
clang-format: [JS] do not merge side-effect imports.

The if condition was testing the current element, but
forgot to check the previous element (doh), so it
would fail depending on sort order of the imports.

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

3 years ago[AMDGPU] SIWholeQuadMode: don't add duplicate implicit $exec operands
Jay Foad [Wed, 21 Apr 2021 16:38:32 +0000 (17:38 +0100)]
[AMDGPU] SIWholeQuadMode: don't add duplicate implicit $exec operands

STRICT_WWM and STRICT_WQM are already defined with Uses = [EXEC], so
there is no need to add another implicit use of $exec when lowering them
to V_MOV_B32 instructions.

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

3 years ago[RISCV] Custom lowering of SET_ROUNDING
Serge Pavlov [Tue, 10 Nov 2020 16:51:34 +0000 (23:51 +0700)]
[RISCV] Custom lowering of SET_ROUNDING

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

3 years ago[LoopVectorize] Don't create unnecessary vscale intrinsic calls
David Sherwood [Mon, 19 Apr 2021 13:56:35 +0000 (14:56 +0100)]
[LoopVectorize] Don't create unnecessary vscale intrinsic calls

In quite a few cases in LoopVectorize.cpp we call createStepForVF
with a step value of 0, which leads to unnecessary generation of
llvm.vscale intrinsic calls. I've optimised IRBuilder::CreateVScale
and createStepForVF to return 0 when attempting to multiply
vscale by 0.

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

3 years ago[CSSPGO][llvm-profdata] Support trimming cold context when merging profiles
Wenlei He [Thu, 15 Apr 2021 05:53:40 +0000 (22:53 -0700)]
[CSSPGO][llvm-profdata] Support trimming cold context when merging profiles

The change adds support for triming and merging cold context when mergine CSSPGO profiles using llvm-profdata. This is similar to the context profile trimming in llvm-profgen, however the flexibility to trim cold context after profile is generated can be useful.

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

3 years ago[libcxx] [test] Fix testing on windows with c++experimental enabled
Martin Storsjö [Tue, 23 Mar 2021 08:55:26 +0000 (10:55 +0200)]
[libcxx] [test] Fix testing on windows with c++experimental enabled

The straightforward `AddLinkFlag('-lc++experimental')` approach doesn't
work on e.g. MSVC. For linking to libc++ itself, a more convoluted logic
is used (see configure_link_flags_cxx_library).

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

3 years ago[clang-tidy] Avoid bugprone-macro-parentheses warnings after goto argument
Georgy Komarov [Tue, 6 Apr 2021 04:57:47 +0000 (07:57 +0300)]
[clang-tidy] Avoid bugprone-macro-parentheses warnings after goto argument

clang-tidy should not generate warnings for the goto argument without
parentheses, because it would be a syntax error.

The only valid case where an argument can be enclosed in parentheses is
"Labels as Values" gcc extension: https://gcc.gnu.org/onlinedocs/gcc/Labels-as-Values.html.
This commit adds support for the label-as-values extension as implemented in clang.

Fixes bugzilla issue 49634.

Reviewed By: aaron.ballman

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

3 years ago[NewPM] Mark some more wrapper passes as ignored
Arthur Eubanks [Thu, 22 Apr 2021 06:51:51 +0000 (23:51 -0700)]
[NewPM] Mark some more wrapper passes as ignored

We shouldn't print IR when seeing these passes.

3 years ago[RISCV] Use TargetConstant for condition code of RISCVISD::SELECT_CC.
Craig Topper [Thu, 22 Apr 2021 06:05:26 +0000 (23:05 -0700)]
[RISCV] Use TargetConstant for condition code of RISCVISD::SELECT_CC.

The value is always an immediate and can never be in a register.
This the kind of thing TargetConstant is for.

Saves a step GenDAGISel to convert a Constant to a TargetConstant.

3 years ago[GVN] Introduce loop load PRE
Max Kazantsev [Thu, 22 Apr 2021 05:50:38 +0000 (12:50 +0700)]
[GVN] Introduce loop load PRE

This patch allows PRE of the following type of loads:

```
preheader:
  br label %loop

loop:
  br i1 ..., label %merge, label %clobber

clobber:
  call foo() // Clobbers %p
  br label %merge

merge:
  ...
  br i1 ..., label %loop, label %exit

```

Into
```
preheader:
  %x0 = load %p
  br label %loop

loop:
  %x.pre = phi(x0, x2)
  br i1 ..., label %merge, label %clobber

clobber:
  call foo() // Clobbers %p
  %x1 = load %p
  br label %merge

merge:
  x2 = phi(x.pre, x1)
  ...
  br i1 ..., label %loop, label %exit

```

So instead of loading from %p on every iteration, we load only when the actual clobber happens.
The typical pattern which it is trying to address is: hot loop, with all code inlined and
provably having no side effects, and some side-effecting calls on cold path.

The worst overhead from it is, if we always take clobber block, we make 1 more load
overall (in preheader). It only matters if loop has very few iteration. If clobber block is not taken
at least once, the transform is neutral or profitable.

There are several improvements prospect open up:
- We can sometimes be smarter in loop-exiting blocks via split of critical edges;
- If we have block frequency info, we can handle multiple clobbers. The only obstacle now is that
  we don't know if their sum is colder than the header.

Differential Revision: https://reviews.llvm.org/D99926
Reviewed By: reames

3 years ago[AMDGPU][OpenMP] Add amdgpu-arch tool to list AMD GPUs installed
Pushpinder Singh [Wed, 21 Apr 2021 14:04:44 +0000 (14:04 +0000)]
[AMDGPU][OpenMP] Add amdgpu-arch tool to list AMD GPUs installed

This patch adds new clang tool named amdgpu-arch which uses
HSA to detect installed AMDGPU and report back latter's march.
This tool is built only if system has HSA installed.

The value printed by amdgpu-arch is used to fill -march when
latter is not explicitly provided in -Xopenmp-target.

Reviewed By: JonChesterfield, gregrodgers

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

3 years ago[CodeGen] Do not split functions with attr "implicit-section-name".
Snehasish Kumar [Wed, 21 Apr 2021 21:41:12 +0000 (14:41 -0700)]
[CodeGen] Do not split functions with attr "implicit-section-name".

The #pragma clang section can be used at a coarse granularity to specify
the section used for bss/data/text/rodata for global objects. When split
functions is enabled, the function may be split into two parts violating
user expectations.

Reference:
https://clang.llvm.org/docs/LanguageExtensions.html#specifying-section-names-for-global-objects-pragma-clang-section

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

3 years agoscudo: Obtain tag from pointer instead of loading it from memory. NFCI.
Peter Collingbourne [Thu, 22 Apr 2021 02:13:36 +0000 (19:13 -0700)]
scudo: Obtain tag from pointer instead of loading it from memory. NFCI.

Since we already have a tagged pointer available to us, we can just
extract the tag from it and avoid an LDG instruction.

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

3 years ago[Debug-Info] implement -gstrict-dwarf
Chen Zheng [Tue, 20 Apr 2021 02:03:44 +0000 (22:03 -0400)]
[Debug-Info] implement -gstrict-dwarf

This patch implements -gstrict-dwarf option in clang FE.

Reviewed By: dblaikie, probinson, aprantl

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

3 years ago[RISCV] Custom lowering of FLT_ROUNDS_
Serge Pavlov [Thu, 5 Nov 2020 06:59:52 +0000 (13:59 +0700)]
[RISCV] Custom lowering of FLT_ROUNDS_

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

3 years ago[mlir][linalg] Add pattern to push reshape after elementwise operation
thomasraoux [Fri, 16 Apr 2021 20:38:15 +0000 (13:38 -0700)]
[mlir][linalg] Add pattern to push reshape after elementwise operation

This help expose more fusion opportunities.

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

3 years ago[RISCV] Teach lowerSPLAT_VECTOR_PARTS to detect cases where Hi is sign extended from Lo.
Craig Topper [Thu, 22 Apr 2021 03:15:39 +0000 (20:15 -0700)]
[RISCV] Teach lowerSPLAT_VECTOR_PARTS to detect cases where Hi is sign extended from Lo.

This recognizes the case when Hi is (sra Lo, 31). We can use
SPLAT_VECTOR_I64 rather than splatting the high bits and
combining them in the vector register.

3 years ago[Coroutine] Collect CoroBegin if all of terminators are dominated by one coro.destroy
Chuanqi Xu [Thu, 22 Apr 2021 03:20:20 +0000 (11:20 +0800)]
[Coroutine] Collect CoroBegin if all of terminators are dominated by one coro.destroy

Summary: The original logic seems to be we could collecting a CoroBegin
if one of the terminators could be dominated by one of coro.destroy,
which doesn't make sense.
This patch rewrites the logics to collect CoroBegin if all of
terminators are dominated by one coro.destroy. If there is no such
coro.destroy, we would call hasEscapePath to evaluate if we should
collect it.

Test Plan: check-llvm

Reviewed by: lxfind

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

3 years agoWordsmith the semantics of invariant.load
Evgeniy Brevnov [Thu, 22 Apr 2021 03:04:49 +0000 (10:04 +0700)]
Wordsmith the semantics of invariant.load

Don't phrase the semantics in terms of the optimizer.  Instead have a
more straightforward execution based semantic.

Reviewed By: ebrevnov

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

3 years ago[lldb] Disable TestSimulatorPlatform.py because it's causing a SIGHUP
Jonas Devlieghere [Thu, 22 Apr 2021 02:56:38 +0000 (19:56 -0700)]
[lldb] Disable TestSimulatorPlatform.py because it's causing a SIGHUP

Ever since Dave Zarzycki's patch to sort test start times based on prior
test timing data (https://reviews.llvm.org/D98179) the test suite aborts
with a SIGHUP. I don't believe his patch is to blame, but rather
uncovers an preexisting issue by making test runs more deterministic.

I was able to narrow down the issue to TestSimulatorPlatform.py. The
issue also manifests itself on the standalone bot on GreenDragon [1].
This patch disables the test until we can figure this out.

[1] http://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake-standalone/

rdar://76995109

3 years ago[mlir][tosa] Add tosa.avg_pool2d lowering
Rob Suderman [Mon, 19 Apr 2021 20:40:33 +0000 (13:40 -0700)]
[mlir][tosa] Add tosa.avg_pool2d lowering

Added the float lowerings for avg pool with corresponding tests.

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

3 years agoAMDGPU: Fix assert when trying to fold reg_sequence of physreg copies
Matt Arsenault [Tue, 20 Apr 2021 19:30:18 +0000 (15:30 -0400)]
AMDGPU: Fix assert when trying to fold reg_sequence of physreg copies

3 years ago[OpenMP] Simplify offloading parallel call codegen
Giorgis Georgakoudis [Wed, 21 Apr 2021 18:41:31 +0000 (11:41 -0700)]
[OpenMP] Simplify offloading parallel call codegen

This revision simplifies Clang codegen for parallel regions in OpenMP GPU target offloading and corresponding changes in libomptarget: SPMD/non-SPMD parallel calls are unified under a single `kmpc_parallel_51` runtime entry point for parallel regions (which will be commonized between target, host-side parallel regions), data sharing is internalized to the runtime. Tests have been auto-generated using `update_cc_test_checks.py`. Also, the revision contains changes to OpenMPOpt for remark creation on target offloading regions.

Reviewed By: jdoerfert, Meinersbur

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

3 years agoDelete le32/le64 targets
Fangrui Song [Thu, 22 Apr 2021 01:44:12 +0000 (18:44 -0700)]
Delete le32/le64 targets

They are unused now.

Note: NaCl is still used and is currently expected to be needed until 2022-06
(https://blog.chromium.org/2020/08/changes-to-chrome-app-support-timeline.html).

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

3 years ago[AArch64][GlobalISel] Fix regbankselect for G_FCMP with vector destinations
Jessica Paquette [Tue, 20 Apr 2021 20:10:30 +0000 (13:10 -0700)]
[AArch64][GlobalISel] Fix regbankselect for G_FCMP with vector destinations

These should always go to a FPR, since they always use the vector registers.

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

3 years ago[AArch64][GlobalISel] Mark some vector G_ABS cases as legal
Jessica Paquette [Wed, 21 Apr 2021 00:48:17 +0000 (17:48 -0700)]
[AArch64][GlobalISel] Mark some vector G_ABS cases as legal

Each of the cases marked as legal here have an imported pattern in
AArch64GenGlobalISel.inc. So, if we mark them as legal, we get selection for
free.

Technically this is only supposed to happen if we have NEON support. But, we
fall back if we don't have that in the legalizer right now. I suppose it'd be
better to have a FIXME so we can write the testcase when the time comes.

(Plus, it'd just fall back in selection if NEON isn't available, so it's not
*wrong*, I guess?)

This fixes some fallbacks in the test suite.

(Also use `isScalar` from LegalityPredicates.cpp while we're here just to tidy
things a little bit.)

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