platform/upstream/llvm.git
2 years ago[libc++][NFC] Move concepts to a subheader.
Mark de Wever [Wed, 1 Sep 2021 17:46:22 +0000 (19:46 +0200)]
[libc++][NFC] Move concepts to a subheader.

D103357 added some new concepts. Since the header `<concepts>` has moved
all its concepts to a separate header these new concepts feel out of
place. Move them to the appropriate header.

Reviewed By: #libc, Quuxplusone, ldionne

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

2 years ago[RISCV] Improve shrink wrap test (NFC)
Evandro Menezes [Thu, 2 Sep 2021 15:28:51 +0000 (10:28 -0500)]
[RISCV] Improve shrink wrap test (NFC)

Restore test for shrink wrapping disabled.

2 years ago[libomptarget][amdgpu] Add gfx90a to build list
Jon Chesterfield [Thu, 2 Sep 2021 17:10:40 +0000 (18:10 +0100)]
[libomptarget][amdgpu] Add gfx90a to build list

2 years ago[Bazel] Update for Cpp emitter (2f0750dd2e)
Geoffrey Martin-Noble [Thu, 2 Sep 2021 17:04:48 +0000 (10:04 -0700)]
[Bazel] Update for Cpp emitter (2f0750dd2e)

Update the Bazel build for
https://github.com/llvm/llvm-project/commit/2f0750dd2e.

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

2 years ago[libc++][docs] Remove "Last Updated" entries from the docs
Louis Dionne [Wed, 1 Sep 2021 20:41:42 +0000 (16:41 -0400)]
[libc++][docs] Remove "Last Updated" entries from the docs

Those don't provide a lot of value, and they can easily be wrong anyway.

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

2 years ago[libc++][NFC] Replace uses of stdr:: by just std::ranges::
Louis Dionne [Thu, 2 Sep 2021 01:48:24 +0000 (21:48 -0400)]
[libc++][NFC] Replace uses of stdr:: by just std::ranges::

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

2 years ago[Unwind] Cast exception class pointer for strcpy
Hans Wennborg [Thu, 2 Sep 2021 16:43:26 +0000 (18:43 +0200)]
[Unwind] Cast exception class pointer for strcpy

Follow-up to f5b997e6b706, see comment on
https://reviews.llvm.org/D109047

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

2 years ago[mlir] Add missing dep on MLIRTranslation
Marius Brehler [Thu, 2 Sep 2021 16:53:53 +0000 (16:53 +0000)]
[mlir] Add missing dep on MLIRTranslation

2 years ago[AMDGPU] Use S_BITCMP0_* to replace AND in optimizeCompareInstr
Stanislav Mekhanoshin [Wed, 1 Sep 2021 20:38:31 +0000 (13:38 -0700)]
[AMDGPU] Use S_BITCMP0_* to replace AND in optimizeCompareInstr

These can be used for reversed conditions if result of the AND
is unused except in the compare:

s_cmp_eq_u32 (s_and_b32 $src, 1), 0 => s_bitcmp0_b32 $src, 0
s_cmp_eq_i32 (s_and_b32 $src, 1), 0 => s_bitcmp0_b32 $src, 0
s_cmp_eq_u64 (s_and_b64 $src, 1), 0 => s_bitcmp0_b64 $src, 0
s_cmp_lg_u32 (s_and_b32 $src, 1), 1 => s_bitcmp0_b32 $src, 0
s_cmp_lg_i32 (s_and_b32 $src, 1), 1 => s_bitcmp0_b32 $src, 0
s_cmp_lg_u64 (s_and_b64 $src, 1), 1 => s_bitcmp0_b64 $src, 0

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

2 years ago[X86][SSE] combineMulToPMADDWD - improve recognition of sign/zero extended upper...
Simon Pilgrim [Thu, 2 Sep 2021 15:46:58 +0000 (16:46 +0100)]
[X86][SSE] combineMulToPMADDWD - improve recognition of sign/zero extended upper bits

PMADDWD(v8i16 x, v8i16 y) == (v4i32) { (int)x[0]*y[0] + (int)x[1]*y[1], ..., (int)x[6]*y[6] + (int)x[7]*y[7] }

Currently combineMulToPMADDWD only folds cases where the upper 17 bits of both vXi32 inputs are known zero (i.e. the first half is positive and the second half of the pair is zero in each 2xi16 pair), this can be relaxed to only require one zero-extended input if the other input has at least 17 sign bits.

That way the sign of the result is still preserved, and the second half is still zero.

Noticed while investigating PR47437.

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

2 years agoclang/win: Add __readfsdword to intrin.h
Nico Weber [Wed, 1 Sep 2021 20:17:19 +0000 (16:17 -0400)]
clang/win: Add __readfsdword to intrin.h

When using __readfsdword(), clang used to warn that one has
to include <intrin.h> -- no matter if that was already included
or not.

Now it only warns if it's not yet included.

To verify that this was the only intrin with this problem, I ran:

    $ for f in $(grep intrin.h clang/include/clang/Basic/BuiltinsX86* |
                 egrep -o '\([^,]+,' | egrep -o '[^(,]*'); do
        if ! grep -q $f clang/lib/Headers/intrin.h; then echo $f; fi;
      done

This printed 9 more functions, but those are all in emmintrin.h,
xsaveintrin.h (which are included by intrin.h based on /arch: flags).
So this is indeed the only built-in that was missing in intrin.h.

Fixes PR51188.

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

2 years ago[llvm-profgen] Deduplicate and improve warning for truncated context
Wenlei He [Thu, 2 Sep 2021 00:31:07 +0000 (17:31 -0700)]
[llvm-profgen] Deduplicate and improve warning for truncated context

This change improves the warning for truncated context by: 1) deduplicate them as one call without probe can appear in many different context leading to duplicated warnings , 2) rephrase the message to make it easier to understand. The term "untracked frame" can be confusing.

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

2 years ago[clangd, llvm] Remove redundant calls to c_str() (NFC)
Kazu Hirata [Thu, 2 Sep 2021 16:07:13 +0000 (09:07 -0700)]
[clangd, llvm] Remove redundant calls to c_str() (NFC)

Identified with readability-redundant-string-cstr.

2 years agoTry to unbreak Win build after 973519826edb76
Nico Weber [Thu, 2 Sep 2021 16:03:25 +0000 (12:03 -0400)]
Try to unbreak Win build after 973519826edb76

Apparently some versions of the MS STL don't like constructing a
vector from a StringMapKeyIterator<>: http://45.33.8.238/win/44999/step_4.txt
It builds fine with the MS STL on my Windows box, so just sidestep the issue.

Full error for posterity:

    VC\Tools\MSVC\14.14.26428\include\xmemory(218,75):
      error: indirection requires pointer operand ('const llvm::StringMapKeyIterator<llvm::StringRef>' invalid)
          _Uses_default_construct_t<_Alloc, decltype(_Unfancy(_UDest)), decltype(*_UFirst)>())));
    VC\Tools\MSVC\14.14.26428\include\vector(1922,11):
      note: in instantiation of function template specialization 'std::_Uninitialized_copy<...>' requested here
                    return (_Uninitialized_copy(_First, _Last, _Dest, this->_Getal()));
    VC\Tools\MSVC\14.14.26428\include\vector(757,22):
      note: in instantiation of function template specialization
            'std::vector<llvm::StringRef>::_Ucopy<llvm::StringMapKeyIterator<llvm::StringRef>>' requested here
                            this->_Mylast() = _Ucopy(_First, _Last, this->_Myfirst());
    VC\Tools\MSVC\14.14.26428\include\vector(772,3):
      note: in instantiation of function template specialization
            'std::vector<llvm::StringRef>::_Range_construct_or_tidy<llvm::StringMapKeyIterator<llvm::StringRef>>' requested here
                    _Range_construct_or_tidy(_Unchecked(_First), _Unchecked(_Last), _Iter_cat_t<_Iter>{});
    ../../clang/lib/Driver/ToolChains/Arch/X86.cpp(62,30):
      note: in instantiation of function template specialization
            'std::vector<llvm::StringRef>::vector<llvm::StringMapKeyIterator<llvm::StringRef>, void>' requested here
          std::vector<StringRef> ValidArchs{ArchMap.keys().begin(),

2 years ago[RISCV] Add Zba command line to rv64i-exhaustive-w-insts.ll
Craig Topper [Thu, 2 Sep 2021 15:26:39 +0000 (08:26 -0700)]
[RISCV] Add Zba command line to rv64i-exhaustive-w-insts.ll

Zba adds a zext.w pseudoinstruction using ADDUW. This can simplify
the generated code for many of these tests.

There are at least 2 suboptimal cases in this config that I've marked
with TODOs.

2 years ago[RISCV] Remove stale TODOs from test. NFC
Craig Topper [Thu, 2 Sep 2021 15:01:40 +0000 (08:01 -0700)]
[RISCV] Remove stale TODOs from test. NFC

These were fixed by D106230.

2 years agoTry to unbreak lldb build after 973519826edb76
Nico Weber [Thu, 2 Sep 2021 15:32:08 +0000 (11:32 -0400)]
Try to unbreak lldb build after 973519826edb76

2 years ago[CSSPGO] Honor preinliner decision for ThinLTO importing
Wenlei He [Wed, 1 Sep 2021 20:47:19 +0000 (13:47 -0700)]
[CSSPGO] Honor preinliner decision for ThinLTO importing

When pre-inliner decision is used for CSSPGO, we should take that into account for ThinLTO importing as well, so post-link sample loader inliner can favor that decision. This is handled by a small tweak in this patch. It also includes a change to transfer preinliner decision when merging context.

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

2 years agoRevert "[analyzer][NFCI] Allow clients of NoStateChangeFuncVisitor to check entire...
Kristóf Umann [Thu, 2 Sep 2021 15:19:32 +0000 (17:19 +0200)]
Revert "[analyzer][NFCI] Allow clients of NoStateChangeFuncVisitor to check entire function calls, rather than each ExplodedNode in it"

This reverts commit 7d0e62bfb773c68d2bc8831fddcc8536f4613190.

2 years ago[flang] Fix non-deterministic line output function
Ivan Zhechev [Thu, 2 Sep 2021 15:07:05 +0000 (15:07 +0000)]
[flang] Fix non-deterministic line output function

The evaluation order for the `|` operator is undefined
(in contrast to the short-circuiting `||` operator). The arguments are
stored in variables to force a specific evaluation order.

A test in D107575 relies on this change.

Reviewed By: kiranchandramohan, klausler

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

2 years ago[AArch64][SVE] Workaround incorrect types when lowering fixed length gather/scatter
Bradley Smith [Thu, 2 Sep 2021 11:06:29 +0000 (11:06 +0000)]
[AArch64][SVE] Workaround incorrect types when lowering fixed length gather/scatter

When lowering a fixed length gather/scatter the index type is assumed to
be the same as the memory type, this is incorrect in cases where the
extension of the index has been folded into the addressing mode.

For now add a temporary workaround to fix the codegen faults caused by
this by preventing the removal of this extension. At a later date the
lowering for SVE gather/scatters will be redesigned to improve the way
addressing modes are handled.

As a short term side effect of this change, the addressing modes
generated for fixed length gather/scatters will not be optimal.

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

2 years ago[InstrProfiling] Add one missing XCOFF line to profiling.ll
Jinsong Ji [Thu, 2 Sep 2021 14:49:35 +0000 (14:49 +0000)]
[InstrProfiling] Add one missing XCOFF line to profiling.ll

2 years ago[analyzer][NFCI] Allow clients of NoStateChangeFuncVisitor to check entire function...
Kristóf Umann [Thu, 19 Aug 2021 13:37:02 +0000 (15:37 +0200)]
[analyzer][NFCI] Allow clients of NoStateChangeFuncVisitor to check entire function calls, rather than each ExplodedNode in it

D105553 added NoStateChangeFuncVisitor, an abstract class to aid in creating
notes such as "Returning without writing to 'x'", or "Returning without changing
the ownership status of allocated memory". Its clients need to define, among
other things, what a change of state is.

For code like this:

f() {
  g();
}

foo() {
  f();
  h();
}

We'd have a path in the ExplodedGraph that looks like this:

             -- <g> -->
            /          \
         ---     <f>    -------->        --- <h> --->
        /                        \      /            \
--------        <foo>             ------    <foo>     -->

When we're interested in whether f neglected to change some property,
NoStateChangeFuncVisitor asks these questions:

                       ÷×~
                -- <g> -->
           ß   /          \$    @&#*
            ---     <f>    -------->        --- <h> --->
           /                        \      /            \
   --------        <foo>             ------    <foo>     -->

Has anything changed in between # and *?
Has anything changed in between & and *?
Has anything changed in between @ and *?
...
Has anything changed in between $ and *?
Has anything changed in between × and ~?
Has anything changed in between ÷ and ~?
...
Has anything changed in between ß and *?
...
This is a rather thorough line of questioning, which is why in D105819, I was
only interested in whether state *right before* and *right after* a function
call changed, and early returned to the CallEnter location:

if (!CurrN->getLocationAs<CallEnter>())
  return;
Except that I made a typo, and forgot to negate the condition. So, in this
patch, I'm fixing that, and under the same hood allow all clients to decide to
do this whole-function check instead of the thorough one.

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

2 years ago[RISCV] Teach instruction selection to elide sext.w in some cases.
Craig Topper [Thu, 2 Sep 2021 14:45:59 +0000 (07:45 -0700)]
[RISCV] Teach instruction selection to elide sext.w in some cases.

If a sext_inreg is up for isel, and all its users are W instructions,
we can skip emitting the sext_inreg. This helpful if the producing
instruction can't become a W instruction.

Reviewed By: asb

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

2 years ago[RISCV] Enable shrink wrap by default
Evandro Menezes [Tue, 10 Aug 2021 00:58:31 +0000 (19:58 -0500)]
[RISCV] Enable shrink wrap by default

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

2 years ago[RISCV] Split PseudoVSETVLI into 2 instructions to allow different register classes...
Craig Topper [Wed, 1 Sep 2021 23:20:40 +0000 (16:20 -0700)]
[RISCV] Split PseudoVSETVLI into 2 instructions to allow different register classes for rs1.

X0 has special meaning for vsetvli, we need to make sure we never
create it a vsetvli that uses it by accident. This could happen
if the register coalescer coalesces a copy from X0 into this
instruction.

This patch splits the instruction so that we can have GPRNoX0
register class to use for the cases where we don't want the source
to be X0. The verifier won't let us explicitly use X0 on a GPRNoX0
operand so we need a separate pseudo for those cases.

I don't currently have a failing example for this. There was a
failure in D107957, but the coalescable copy from that example
should have been optimized away much earlier so I've fixed that.

This is not a complete fix. We still need to prevent the same
possible issue on the AVL operand of all of the vector instruction
pseudos. I don't want to make two versions of all of those so we
need to find a different solution for those. I have an idea I'm
going to try.

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

2 years ago[clang-cl] Emit nicer warning on unknown /arch: arguments
Nico Weber [Wed, 1 Sep 2021 22:40:05 +0000 (18:40 -0400)]
[clang-cl] Emit nicer warning on unknown /arch: arguments

Now prints the list of known archs. This requires plumbing a Driver
arg through a few functions.

Also add two more convenience insert() overlods to StringMap.

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

2 years ago[MLIR][OpenMP] Add support for declaring critical construct names
Kiran Chandramohan [Thu, 2 Sep 2021 14:17:07 +0000 (14:17 +0000)]
[MLIR][OpenMP] Add support for declaring critical construct names

Add an operation omp.critical.declare to declare names/symbols of
critical sections. Named omp.critical operations should use symbols
declared by omp.critical.declare. Having a declare operation ensures
that the names of critical sections are global and unique. In the
lowering flow to LLVM IR, the OpenMP IRBuilder creates unique names
for critical sections.

Reviewed By: ftynse, jeanPerier

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

2 years ago[AMDGPU] Add merging into S_BUFFER_LOAD_DWORDX8_IMM
Piotr Sobczak [Mon, 30 Aug 2021 08:41:19 +0000 (10:41 +0200)]
[AMDGPU] Add merging into S_BUFFER_LOAD_DWORDX8_IMM

Extend SILoadStoreOptimizer to merge into DWORDX8 variant of S_BUFFER_LOAD.

Merging into DWORDX2 and DWORDX4 variants is handled already.

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

2 years ago[mlir] Add Cpp emitter
Marius Brehler [Mon, 21 Jun 2021 10:44:20 +0000 (10:44 +0000)]
[mlir] Add Cpp emitter

This upstreams the Cpp emitter, initially presented with [1], from [2]
to MLIR core. Together with the previously upstreamed EmitC dialect [3],
the target allows to translate MLIR to C/C++.

[1] https://reviews.llvm.org/D76571
[2] https://github.com/iml130/mlir-emitc
[3] https://reviews.llvm.org/D103969

Co-authored-by: Jacques Pienaar <jpienaar@google.com>
Co-authored-by: Simon Camphausen <simon.camphausen@iml.fraunhofer.de>
Co-authored-by: Oliver Scherf <oliver.scherf@iml.fraunhofer.de>
Reviewed By: jpienaar

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

2 years ago[mlir] support translating OpenMP loops with reductions
Alex Zinenko [Tue, 24 Aug 2021 15:53:42 +0000 (17:53 +0200)]
[mlir] support translating OpenMP loops with reductions

Use the recently introduced OpenMPIRBuilder facility to transate OpenMP
workshare loops with reductions to LLVM IR calling OpenMP runtime. Most of the
heavy lifting is done at the OpenMPIRBuilder. When other OpenMP dialect
constructs grow support for reductions, the translation can be updated to
operate on, e.g., an operation interface for all reduction containers instead
of workshare loops specifically. Designing such a generic translation for the
single operation that currently supports reductions is premature since we don't
know how the reduction modeling itself will be generalized.

Reviewed By: kiranchandramohan

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

2 years agoRevert "[lldb server] Tidy up LLDB server return codes and associated tests"
Raphael Isemann [Thu, 2 Sep 2021 13:27:39 +0000 (15:27 +0200)]
Revert "[lldb server] Tidy up LLDB server return codes and associated tests"

This reverts commit e387c8c413e2127bc93950fb6d786290237b4a9f. The
TestErrorMessages.test is failing on the Linux bots.

2 years ago[ARM] Add a tail-predication loop predicate register
David Green [Thu, 2 Sep 2021 12:42:58 +0000 (13:42 +0100)]
[ARM] Add a tail-predication loop predicate register

The semantics of tail predication loops means that the value of LR as an
instruction is executed determines the predicate. In other words:

mov r3, #3
DLSTP lr, r3        // Start tail predication, lr==3
VADD.s32 q0, q1, q2 // Lanes 0,1 and 2 are updated in q0.
mov lr, #1
VADD.s32 q0, q1, q2 // Only first lane is updated.

This means that the value of lr cannot be spilled and re-used in tail
predication regions without potentially altering the behaviour of the
program. More lanes than required could be stored, for example, and in
the case of a gather those lanes might not have been setup, leading to
alignment exceptions.

This patch adds a new lr predicate operand to MVE instructions in order
to keep a reference to the lr that they use as a tail predicate. It will
usually hold the zeroreg meaning not predicated, being set to the LR phi
value in the MVETPAndVPTOptimisationsPass. This will prevent it from
being spilled anywhere that it needs to be used.

A lot of tests needed updating.

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

2 years ago[clang] NFC: Extract DiagnosticOptions parsing
Jan Svoboda [Mon, 30 Aug 2021 13:41:53 +0000 (15:41 +0200)]
[clang] NFC: Extract DiagnosticOptions parsing

The way we parse `DiagnosticOptions` is a bit involved.

`DiagnosticOptions` are parsed as part of the cc1-parsing function `CompilerInvocation::CreateFromArgs` which takes `DiagnosticsEngine` as an argument to be able to report errors in command-line arguments. But to create `DiagnosticsEngine`, `DiagnosticOptions` are needed. This is solved by exposing the `ParseDiagnosticArgs` to clients and making its `DiagnosticsEngine` argument optional, essentially breaking the dependency cycle.

The `ParseDiagnosticArgs` function takes `llvm::opt::ArgList &`, which each client needs to create from the command-line (typically represented as `std::vector<const char *>`). Creating this data structure in this context is somewhat particular. This code pattern is copy-pasted in some places across the upstream code base and also in downstream repos. To make things a bit more uniform, this patch extracts the code into a new reusable function: `CreateAndPopulateDiagOpts`.

Reviewed By: dexonsmith

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

2 years agoRevert @llvm.isnan intrinsic patchset.
Roman Lebedev [Thu, 2 Sep 2021 10:03:31 +0000 (13:03 +0300)]
Revert @llvm.isnan intrinsic patchset.

Please refer to
https://lists.llvm.org/pipermail/llvm-dev/2021-September/152440.html
(and that whole thread.)

TLDR: the original patch had no prior RFC, yet it had some changes that
really need a proper RFC discussion. It won't be productive to discuss
such an RFC, once it's actually posted, while said patch is already
committed, because that introduces bias towards already-committed stuff,
and the tree is potentially in broken state meanwhile.

While the end result of discussion may lead back to the current design,
it may also not lead to the current design.

Therefore i take it upon myself
to revert the tree back to last known good state.

This reverts commit 4c4093e6e39fe6601f9c95a95a6bc242ef648cd5.
This reverts commit 0a2b1ba33ae6dcaedb81417f7c4cc714f72a5968.
This reverts commit d9873711cb03ac7aedcaadcba42f82c66e962e6e.
This reverts commit 791006fb8c6fff4f33c33cb513a96b1d3f94c767.
This reverts commit c22b64ef66f7518abb6f022fcdfd86d16c764caf.
This reverts commit 72ebcd3198327da12804305bda13d9b7088772a8.
This reverts commit 5fa6039a5fc1b6392a3c9a3326a76604e0cb1001.
This reverts commit 9efda541bfbd145de90f7db38d935db6246dc45a.
This reverts commit 94d3ff09cfa8d7aecf480e54da9a5334e262e76b.

2 years ago[clang] NFC: Remove duplicate DependentSizedMatrixType methods
Cullen Rhodes [Thu, 2 Sep 2021 08:47:42 +0000 (08:47 +0000)]
[clang] NFC: Remove duplicate DependentSizedMatrixType methods

Inherited from MatrixType.

Reviewed By: fhahn

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

2 years ago[lldb] [client] Implement follow-fork-mode
Michał Górny [Mon, 12 Apr 2021 22:15:51 +0000 (00:15 +0200)]
[lldb] [client] Implement follow-fork-mode

Implement a new target.process.follow-fork-mode setting to control
LLDB's behavior on fork.  If set to 'parent', the forked child is
detached and parent continues being traced.  If set to 'child',
the parent is detached and child becomes traced instead.

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

2 years ago[libomptarget][amdgpu] Drop env variables
Jon Chesterfield [Thu, 2 Sep 2021 10:02:37 +0000 (11:02 +0100)]
[libomptarget][amdgpu] Drop env variables

Use the same debug print as the rest of libomptarget plugins with
the same environment control. Also drop the max queue size debugging hook as
I don't believe it is still in use, can bring it back near the rest of the env
handling in rtl.cpp if someone objects.

That makes most of rt.h and all of utils.cpp unused. Clean that up and simplify
control flow in a couple of places.

Behaviour change is that debug prints that used to use the old environment
variable now use the new one and print in slightly different format, and the
removal of the max queue size variable.

Reviewed By: pdhaliwal

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

2 years ago[X86] Fold PMADD(x,0) or PMADD(0,x) -> 0
Simon Pilgrim [Thu, 2 Sep 2021 09:10:08 +0000 (10:10 +0100)]
[X86] Fold PMADD(x,0) or PMADD(0,x) -> 0

Pulled out of D108522 - handle zero-operand cases for PMADDWD/VPMADDUBSW ops

2 years ago[X86][SSE] Add combine-pmadd.ll for PMADDWD/VPMADDUBSW combines
Simon Pilgrim [Wed, 1 Sep 2021 16:42:21 +0000 (17:42 +0100)]
[X86][SSE] Add combine-pmadd.ll for PMADDWD/VPMADDUBSW combines

Pre-commit for D108522 to show failure to fold multiply by zero operands

2 years ago[libunwind] Compile with -Wunused-but-set-variable
Daniel Kiss [Thu, 2 Sep 2021 09:37:09 +0000 (11:37 +0200)]
[libunwind] Compile with -Wunused-but-set-variable

-Wunused-but-set-variable triggers a warning even the block of code is effectively dead.

Reviewed By: MaskRay

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

2 years agoRevert "[OpenMP][OpenMPIRBuilder] Implement loop unrolling."
Roman Lebedev [Thu, 2 Sep 2021 09:40:22 +0000 (12:40 +0300)]
Revert "[OpenMP][OpenMPIRBuilder] Implement loop unrolling."

Breaks build with -DBUILD_SHARED_LIBS=ON
```
CMake Error: The inter-target dependency graph contains the following strongly connected component (cycle):
  "LLVMFrontendOpenMP" of type SHARED_LIBRARY
    depends on "LLVMPasses" (weak)
  "LLVMipo" of type SHARED_LIBRARY
    depends on "LLVMFrontendOpenMP" (weak)
  "LLVMCoroutines" of type SHARED_LIBRARY
    depends on "LLVMipo" (weak)
  "LLVMPasses" of type SHARED_LIBRARY
    depends on "LLVMCoroutines" (weak)
    depends on "LLVMipo" (weak)
At least one of these targets is not a STATIC_LIBRARY.  Cyclic dependencies are allowed only among static libraries.
CMake Generate step failed.  Build files cannot be regenerated correctly.
```

This reverts commit 707ce34b06190e275572c3c46843036db1bab6d1.

2 years ago[Unwind] Harmonise exception class for EHABI spec.
Daniel Kiss [Thu, 2 Sep 2021 09:30:26 +0000 (11:30 +0200)]
[Unwind] Harmonise exception class for EHABI spec.

EHABI defines the exception class as char[8] instead of uint64_t [1].
For ABI compatibility the ABI the definition needs to be updated.

[1] https://github.com/ARM-software/abi-aa/blob/main/ehabi32/ehabi32.rst#82language-independent-unwinding-types-and-functions

Reviewed By: manojgupta, MaskRay, #libunwind

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

2 years ago[RISCV][test] Add more tests for (mul (add x, c1), c2)
Ben Shi [Mon, 23 Aug 2021 13:09:12 +0000 (21:09 +0800)]
[RISCV][test] Add more tests for (mul (add x, c1), c2)

Reviewed By: asb

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

2 years ago[RISCV][test] Add tests for optimization with SH*ADD in the zba extension
Ben Shi [Mon, 30 Aug 2021 03:47:22 +0000 (11:47 +0800)]
[RISCV][test] Add tests for optimization with SH*ADD in the zba extension

Reviewed By: asb

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

2 years ago[LegalizeTypes][VP] Add splitting support for binary VP ops
Fraser Cormack [Wed, 11 Aug 2021 15:47:12 +0000 (16:47 +0100)]
[LegalizeTypes][VP] Add splitting support for binary VP ops

This patch extends D107904's introduction of vector-predicated (VP)
operation legalization to include vector splitting.

When the result of a binary VP operation needs splitting, all of its
operands are split in kind. The two operands and the mask are split as
usual, and the vector-length parameter EVL is "split" such that the low
and high halves each execute the correct number of elements.

Tests have been added to the RISC-V target to show splitting several
scenarios for fixed- and scalable-vector types. Without support for
`umax` (e.g. in the `B` extension) the generated code starts to branch.
Ideally a cost model would prevent their insertion in the first place.

Through these tests many opportunities for better codegen can be seen:
combining known-undef VP operations and for constant-folding operations
on `ISD::VSCALE`, to name but a few.

Reviewed By: RKSimon

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

2 years ago[VP] Declaration and docs for vp.select intrinsic
Simon Moll [Thu, 2 Sep 2021 07:53:53 +0000 (09:53 +0200)]
[VP] Declaration and docs for vp.select intrinsic

llvm.vp.select extends the regular select instruction with an explicit
vector length (%evl).

All lanes with indexes at and above %evl are
undefined. Lanes below %evl are taken from the first input where the
mask is true and from the second input otherwise.

Reviewed By: rogfer01

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

2 years ago[lldb server] Tidy up LLDB server return codes and associated tests
Sebastian Schwartz [Thu, 2 Sep 2021 09:14:49 +0000 (11:14 +0200)]
[lldb server] Tidy up LLDB server return codes and associated tests

This diff modifies the LLDB server return codes to more accurately reflect usage
error paths. Specifically we always propagate the return codes from the main
entrypoints into GDB remote LLDB server, and platform LLDB server. This way, the
top-level caller of LLDB server will be able to correctly check whether the
executable exited with or without an error.

We additionally modify and extend the associated shell unit tests to expect
nonzero return codes on error conditions.

Test Plan:
LLDB tests pass:

```
ninja check-lldb
```

Reviewed By: teemperor

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

2 years ago[mlir][linalg] Expose function to create op on buffers during bufferization.
Alexander Belyaev [Thu, 2 Sep 2021 09:06:49 +0000 (11:06 +0200)]
[mlir][linalg] Expose function to create op on buffers during bufferization.

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

2 years ago[SVE] Fix the FP arithmetic instruction costs for SVE
David Sherwood [Tue, 31 Aug 2021 13:07:50 +0000 (14:07 +0100)]
[SVE] Fix the FP arithmetic instruction costs for SVE

Several FP instructions (fadd, fsub, etc.) were incorrectly assigned
a higher cost for SVE because they have custom lowering, however we
know they are legal. This patch explicitly assigns a cost of 2 to
these opcodes.

Tests added here:

  Analysis/CostModel/AArch64/arith-fp-sve.ll

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

2 years ago[MC] Set SHF_INFO_LINK on SHT_REL/SHT_RELA sections
Fangrui Song [Thu, 2 Sep 2021 08:00:51 +0000 (01:00 -0700)]
[MC] Set SHF_INFO_LINK on SHT_REL/SHT_RELA sections

sh_info links to a section, therefore SHF_INFO_LINK should be set as GNU as
does. The issue has been benign because linkers kindly combines relocation
sections w/ and w/o the flag.

2 years ago[SelectionDAG][VP] Fix VP memory ops' EVL/Mask indices
Fraser Cormack [Wed, 1 Sep 2021 14:32:58 +0000 (15:32 +0100)]
[SelectionDAG][VP] Fix VP memory ops' EVL/Mask indices

This patch corrects the auto-generated EVL and Mask index positions of
the `VP_LOAD`/`VP_STORE`/`VP_GATHER`/`VP_SCATTER` nodes.

Reviewed By: simoll

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

2 years ago[OpenMP][OpenMPIRBuilder] Implement loop unrolling.
Michael Kruse [Thu, 2 Sep 2021 06:08:55 +0000 (01:08 -0500)]
[OpenMP][OpenMPIRBuilder] Implement loop unrolling.

Add methods for loop unrolling to the OpenMPIRBuilder class and use them in Clang if `-fopenmp-enable-irbuilder` is enabled. The unrolling methods are:

 * `unrollLoopFull`
 * `unrollLoopPartial`
 * `unrollLoopHeuristic`

`unrollLoopPartial` and `unrollLoopHeuristic` can use compiler heuristics to automatically determine the unroll factor. If possible, that is if no CanonicalLoopInfo is required to pass to another method, metadata for LLVM's LoopUnrollPass is added. Otherwise the unroll factor is determined using the same heurstics as user by LoopUnrollPass. Not requiring a CanonicalLoopInfo, especially with `unrollLoopHeuristic` allows greater flexibility.

With full unrolling and partial unrolling with known unroll factor, instead of duplicating instructions by the OpenMPIRBuilder, the full unroll is still delegated to the LoopUnrollPass. In case of partial unrolling the loop is first tiled using the existing `tileLoops` methods, then the inner loop fully unrolled using the same mechanism.

Reviewed By: jdoerfert, kiranchandramohan

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

2 years ago[LoopDistribute] Add tests inspired by PR50296, PR50288.
Florian Hahn [Wed, 1 Sep 2021 13:32:59 +0000 (15:32 +0200)]
[LoopDistribute] Add tests inspired by PR50296, PR50288.

2 years ago[CSSPGO] Use preinliner decision by default when available
Wenlei He [Wed, 1 Sep 2021 23:25:59 +0000 (16:25 -0700)]
[CSSPGO] Use preinliner decision by default when available

For CSSPGO, turn on `sample-profile-use-preinliner` by default. This simplifies the use of llvm-profgen preinliner as it's now simply driven by ContextShouldBeInlined flag for each context profile without needing extra compiler switch.

Note that llvm-profgen's preinliner is still off by default, under switch `csspgo-preinliner`.

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

2 years ago[docs] Mention that the legacy PM is deprecated and will be removed after 14
Arthur Eubanks [Wed, 1 Sep 2021 18:53:53 +0000 (11:53 -0700)]
[docs] Mention that the legacy PM is deprecated and will be removed after 14

Per https://lists.llvm.org/pipermail/llvm-dev/2021-August/152305.html.

Reviewed By: MaskRay, fhahn

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

2 years ago[NPM] Added opt option -print-pipeline-passes.
Markus Lavin [Thu, 2 Sep 2021 06:23:33 +0000 (08:23 +0200)]
[NPM] Added opt option -print-pipeline-passes.

Added opt option -print-pipeline-passes to print a -passes compatible
string describing the built pass pipeline.

As an example:
$ opt -enable-new-pm=1 -adce -licm -simplifycfg -o /dev/null /dev/null -print-pipeline-passes
verify,function(adce),function(loop-mssa(licm)),function(simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts>),verify,BitcodeWriterPass

At the moment this is best-effort only and there are some known
limitations:
- Not all passes accepting parameters will print their parameters
  (currently only implemented for simplifycfg).
- Some ClassName to pass-name mappings are not unique.
- Some ClassName to pass-name mappings are missing (e.g.
  BitcodeWriterPass).

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

2 years agoRevert "[NPM] Added opt option -print-pipeline-passes."
Markus Lavin [Thu, 2 Sep 2021 06:22:17 +0000 (08:22 +0200)]
Revert "[NPM] Added opt option -print-pipeline-passes."

This reverts commit c71869ed4c24b3d4d13e2f83ee2c0104013ca129.

2 years ago[NPM] Added opt option -print-pipeline-passes.
Markus Lavin [Thu, 2 Sep 2021 05:47:23 +0000 (07:47 +0200)]
[NPM] Added opt option -print-pipeline-passes.

Added opt option -print-pipeline-passes to print a -passes compatible
string describing the built pass pipeline.

As an example:
$ opt -enable-new-pm=1 -adce -licm -simplifycfg -o /dev/null /dev/null -print-pipeline-passes
verify,function(adce),function(loop-mssa(licm)),function(simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts>),verify,BitcodeWriterPass

At the moment this is best-effort only and there are some known
limitations:
- Not all passes accepting parameters will print their parameters
  (currently only implemented for simplifycfg).
- Some ClassName to pass-name mappings are not unique.
- Some ClassName to pass-name mappings are missing (e.g.
  BitcodeWriterPass).

2 years ago[libc++][nfc] Fixes ppc64le-sanitizer build issue.
Mark de Wever [Thu, 2 Sep 2021 06:09:10 +0000 (08:09 +0200)]
[libc++][nfc] Fixes ppc64le-sanitizer build issue.

After landing D103357 the worker ppc64le-sanitizer fails on `__bool`.
This replaces all occurrences with `__boolean`.

2 years ago[DAGCombine] Add node level checks for fp-contract and fp-ninf in visitFMULForFMADist...
Abinav Puthan Purayil [Mon, 2 Aug 2021 11:12:23 +0000 (16:42 +0530)]
[DAGCombine] Add node level checks for fp-contract and fp-ninf in visitFMULForFMADistributiveCombine().

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

2 years agoFix missing argument introduced by D108788
Arthur Eubanks [Thu, 2 Sep 2021 06:00:58 +0000 (23:00 -0700)]
Fix missing argument introduced by D108788

Reviewed By: aeubanks

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

2 years ago[test] Precommit/fix up existing test for MemorySSA/invariant.group
Arthur Eubanks [Thu, 2 Sep 2021 02:28:22 +0000 (19:28 -0700)]
[test] Precommit/fix up existing test for MemorySSA/invariant.group

2 years ago[libomptarget] Move HostDataToTargetTy states into StatesTy
Ye Luo [Thu, 2 Sep 2021 04:36:05 +0000 (23:36 -0500)]
[libomptarget] Move HostDataToTargetTy states into StatesTy

Use unique_ptr to achieve the effect of mutable.

Remove mutable keyword of DynRefCount and HoldRefCount
Remove std::shared_ptr from UpdateMtx

Reviewed By: tianshilei1992, grokos

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

2 years ago[NFC][PowerPC] Small code refactor in LoopInstrFormPrep
Jinsong Ji [Thu, 2 Sep 2021 03:15:27 +0000 (03:15 +0000)]
[NFC][PowerPC] Small code refactor in LoopInstrFormPrep

Avoid some duplicate code.

Reviewed By: #powerpc, shchenz

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

2 years ago[CSSPGO] Add stats for pre-inliner
Wenlei He [Wed, 1 Sep 2021 21:57:09 +0000 (14:57 -0700)]
[CSSPGO] Add stats for pre-inliner

Add some stats to help tuning pre-inliner.

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

2 years ago[InstrProfiling] Add AIX triple to more tests
Jinsong Ji [Thu, 2 Sep 2021 02:39:51 +0000 (02:39 +0000)]
[InstrProfiling] Add AIX triple to more tests

Following patch of https://reviews.llvm.org/D108490.
Add AIX triples to tests in /Instrumentation/InstrProfiling/ to make
sure we can catch regressions earlier.

Reviewed By: MaskRay

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

2 years ago[AArch64][test] Add new tests for (mul (add x, c0), c1)
Ben Shi [Fri, 27 Aug 2021 12:47:12 +0000 (20:47 +0800)]
[AArch64][test] Add new tests for (mul (add x, c0), c1)

Reviewed By: dmgreen

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

2 years agoReland [MemorySSA] Add pass to print results of MemorySSA walker
Arthur Eubanks [Tue, 31 Aug 2021 21:43:21 +0000 (14:43 -0700)]
Reland [MemorySSA] Add pass to print results of MemorySSA walker

Reviewed By: asbirlea

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

2 years agoRevert "[MemorySSA] Add pass to print results of MemorySSA walker"
Arthur Eubanks [Thu, 2 Sep 2021 01:45:19 +0000 (18:45 -0700)]
Revert "[MemorySSA] Add pass to print results of MemorySSA walker"

This reverts commit 8f98477c2d2bcbf5b6aa36278b59bf2a861426a1.

Breaks bots

2 years ago[PowerPC] small code format refactor ; NFC
Chen Zheng [Thu, 2 Sep 2021 01:37:38 +0000 (01:37 +0000)]
[PowerPC] small code format refactor ; NFC

address the code review comments in patch https://reviews.llvm.org/D105872

2 years ago[MemorySSA] Add pass to print results of MemorySSA walker
Arthur Eubanks [Tue, 31 Aug 2021 21:43:21 +0000 (14:43 -0700)]
[MemorySSA] Add pass to print results of MemorySSA walker

Reviewed By: asbirlea

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

2 years agoPR50294: Fix a performance regression from 2c9dbcd.
Richard Smith [Thu, 2 Sep 2021 00:57:48 +0000 (17:57 -0700)]
PR50294: Fix a performance regression from 2c9dbcd.

Per the contract of ReadLateParsedTemplates, we should not be returning
the same results multiple times. No functionality change intended, other
than to runtime.

Thanks to Luboš Luňák for identifying the cause of the regression!

2 years ago[OpenMP] Fix -Wunused-but-set-parameter in -DLLVM_ENABLE_ASSERTIONS=off builds. NFC
Fangrui Song [Thu, 2 Sep 2021 00:55:13 +0000 (17:55 -0700)]
[OpenMP] Fix -Wunused-but-set-parameter in -DLLVM_ENABLE_ASSERTIONS=off builds. NFC

2 years ago[HeaderSearch] Use `isImport` only for imported headers and not for `#pragma once`.
Volodymyr Sapsai [Wed, 16 Jun 2021 01:44:38 +0000 (18:44 -0700)]
[HeaderSearch] Use `isImport` only for imported headers and not for `#pragma once`.

There is a separate field `isPragmaOnce` and when `isImport` combines
both, it complicates HeaderFileInfo serialization as `#pragma once` is
the inherent property of the header while `isImport` reflects how other
headers use it. The usage of the header can be different in different
contexts, that's why `isImport` requires tracking separate from `#pragma once`.

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

2 years agoRevert "snapshot - do not push"
Philip Reames [Wed, 1 Sep 2021 23:59:23 +0000 (16:59 -0700)]
Revert "snapshot - do not push"

This reverts commit 91f4655d9273ecefab1b7f0ea26d44f5de6fd0af.

This wasn't intented to be pushed, sorry.

2 years agoFix a missing MemorySSA update in breakLoopBackedge
Philip Reames [Wed, 1 Sep 2021 23:58:04 +0000 (16:58 -0700)]
Fix a missing MemorySSA update in breakLoopBackedge

This is a case I'd missed in 6a8237. The odd bit here is that missing the edge removal update seems to produce MemorySSA which verifies, but is still corrupt in a way which bothers following passes. I wasn't able to reduce a single pass test case, which is why the reported test case is taken as is.

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

2 years agosnapshot - do not push
Philip Reames [Wed, 1 Sep 2021 21:13:11 +0000 (14:13 -0700)]
snapshot - do not push

2 years ago[mlir][sparse] sparse runtime support library improvements
Aart Bik [Wed, 1 Sep 2021 01:21:23 +0000 (18:21 -0700)]
[mlir][sparse] sparse runtime support library improvements

(1) renamed SparseTensor to SparseTensorCOO, the other one remains SparseTensorStorage to focus on contrast

(2) documents difference between public API exclusively for compiler-generated code and methods that could be used by other runtimes (TBD) that want to interact with MLIR

Reviewed By: bixia

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

2 years agoRevert "[AArch64][GlobalISel] Legalize bswap <2 x i16>"
Jon Roelofs [Wed, 1 Sep 2021 23:49:20 +0000 (16:49 -0700)]
Revert "[AArch64][GlobalISel] Legalize bswap <2 x i16>"

This reverts commit 5cd63e9ec2a385de2682949c0bbe928afaf35c91.

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

The sequence feeding in/out of the rev32/ushr isn't quite right:

 _swap:
         ldr     h0, [x0]
         ldr     h1, [x0, #2]
-        mov     v0.h[1], v1.h[0]
+        mov     v0.s[1], v1.s[0]
         rev32   v0.8b, v0.8b
         ushr    v0.2s, v0.2s, #16
-        mov     h1, v0.h[1]
+        mov     s1, v0.s[1]
         str     h0, [x0]
         str     h1, [x0, #2]
         ret

2 years ago[mlir][capi] Add NameLoc
Jacques Pienaar [Wed, 1 Sep 2021 23:16:35 +0000 (16:16 -0700)]
[mlir][capi] Add NameLoc

Add method to get NameLoc. Treat null child location as unknown to avoid
needing to create UnknownLoc in C API where child loc is not needed.

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

2 years ago[AMDGPU] Use S_BITCMP1_* to replace AND in optimizeCompareInstr
Stanislav Mekhanoshin [Wed, 1 Sep 2021 18:40:53 +0000 (11:40 -0700)]
[AMDGPU] Use S_BITCMP1_* to replace AND in optimizeCompareInstr

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

2 years ago[AMDGPU] Introduce optimizeCompareInstr
Stanislav Mekhanoshin [Tue, 31 Aug 2021 22:10:59 +0000 (15:10 -0700)]
[AMDGPU] Introduce optimizeCompareInstr

The following patterns are currently handled:

s_cmp_eq_u32 (s_and_b32 $src, 1), 1 => s_and_b32 $src, 1
s_cmp_eq_i32 (s_and_b32 $src, 1), 1 => s_and_b32 $src, 1
s_cmp_eq_u64 (s_and_b64 $src, 1), 1 => s_and_b64 $src, 1
s_cmp_ge_u32 (s_and_b32 $src, 1), 1 => s_and_b32 $src, 1
s_cmp_ge_i32 (s_and_b32 $src, 1), 1 => s_and_b32 $src, 1
s_cmp_lg_u32 (s_and_b32 $src, 1), 0 => s_and_b32 $src, 1
s_cmp_lg_i32 (s_and_b32 $src, 1), 0 => s_and_b32 $src, 1
s_cmp_lg_u64 (s_and_b64 $src, 1), 0 => s_and_b64 $src, 1
s_cmp_gt_u32 (s_and_b32 $src, 1), 0 => s_and_b32 $src, 1
s_cmp_gt_i32 (s_and_b32 $src, 1), 0 => s_and_b32 $src, 1

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

2 years ago[MemorySSAUpdater] Simplify updates when only deleting edges.
Alina Sbirlea [Wed, 1 Sep 2021 21:38:53 +0000 (14:38 -0700)]
[MemorySSAUpdater] Simplify updates when only deleting edges.

When performing only edge deletion, we don't need to do the DT updates
back and forth. Check for the existance of insert updates to simplify
this.

2 years ago[OpenMP][AMDGPU] Remove unneeded XFAILs
Joel E. Denny [Wed, 1 Sep 2021 21:59:40 +0000 (17:59 -0400)]
[OpenMP][AMDGPU] Remove unneeded XFAILs

2 years ago[Codegen][TLI][X86] SimplifyMultipleUseDemandedBits(): 0'th vec subreg widening is...
Roman Lebedev [Wed, 1 Sep 2021 21:42:09 +0000 (00:42 +0300)]
[Codegen][TLI][X86] SimplifyMultipleUseDemandedBits(): 0'th vec subreg widening is free, try to perform it earlier

I believe, the profitability reasoning here is correct
"sub"reg is already located within the 0'th subreg of wider reg,
so if we have suvector insertion at index 0 into undef,
then it's always free do to.

After this, D109065 finally avoids the regression in D108382.

Reviewed By: RKSimon

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

2 years ago[InstrProfiling] Use llvm.compiler.used if applicable for Mach-O
Fangrui Song [Wed, 1 Sep 2021 21:46:51 +0000 (14:46 -0700)]
[InstrProfiling] Use llvm.compiler.used if applicable for Mach-O

Similar to D97585.

D25456 used `S_ATTR_LIVE_SUPPORT` to ensure the data variable will be retained
or discarded as a unit with the counter variable, so llvm.compiler.used is
sufficient. It allows ld to dead strip unneeded profc and profd variables.

Reviewed By: vsk

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

2 years ago[llvm-profdata] Fix assertion from invalid iterator
Wenlei He [Wed, 1 Sep 2021 21:37:18 +0000 (14:37 -0700)]
[llvm-profdata] Fix assertion from invalid iterator

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

2 years ago[RISCV] Fix typo in RISCVSchedSiFive7.td
Alexander Pivovarov [Wed, 1 Sep 2021 21:26:51 +0000 (16:26 -0500)]
[RISCV] Fix typo in RISCVSchedSiFive7.td

Fix typo in "microarchitecure".

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

2 years ago[ARM] Add MVE lowering for fptosi.sat
David Green [Wed, 1 Sep 2021 21:38:47 +0000 (22:38 +0100)]
[ARM] Add MVE lowering for fptosi.sat

This adds lowering of the llvm.fptosi.sat and llvm.fptoui.sat intinsics,
selecting a VCVT instruction which under MVE will inherently perform the
saturate.

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

2 years ago[OpenMP] Use IsHostPtr where needed in rest of omptarget.cpp
Joel E. Denny [Wed, 1 Sep 2021 20:24:39 +0000 (16:24 -0400)]
[OpenMP] Use IsHostPtr where needed in rest of omptarget.cpp

As started in D107925, this patch replaces the remaining occurrences
of `UNIFIED_SHARED_MEMORY && TgtPtrBegin == HstPtrBegin` in
`omptarget.cpp` with `IsHostPtr`.  The former condition is broken in
the rare case that the device and host happen to use the same address
for their mapped allocations.  I don't know how to write a test that's
likely to reveal this case.

Reviewed By: grokos

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

2 years ago[OpenMP] Use IsHostPtr where needed for targetDataBegin
Joel E. Denny [Wed, 1 Sep 2021 20:24:34 +0000 (16:24 -0400)]
[OpenMP] Use IsHostPtr where needed for targetDataBegin

As discussed in D105990, without this patch, `targetDataBegin`
determines whether to transfer data (as opposed to assuming it's in
shared memory) using the condition `!UseUSM || HasCloseModifier`.
However, this condition is broken if use of discrete memory was forced
by `omp_target_associate_ptr`.  This patch extends
`unified_shared_memory/associate_ptr.c` to reveal this case, and it
fixes it using `!IsHostPtr` in `DeviceTy::getTargetPointer` to replace
this condition.

Reviewed By: grokos

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

2 years ago[OpenMP][NFC] Eliminate CopyMember from targetDataEnd
Joel E. Denny [Wed, 1 Sep 2021 20:24:28 +0000 (16:24 -0400)]
[OpenMP][NFC] Eliminate CopyMember from targetDataEnd

This patch is based on comments in D105990.  It is NFC according to
the following observations:

1. `CopyMember` is computed as `!IsHostPtr && IsLast`.
2. `DelEntry` is true only if `IsLast` is true.

We apply those observations in order:

```
if ((DelEntry || Always || CopyMember) && !IsHostPtr)

if ((DelEntry || Always || IsLast) && !IsHostPtr)

if ((Always || IsLast) && !IsHostPtr)
```

Reviewed By: grokos

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

2 years ago[OpenMP] Use IsHostPtr where needed for targetDataEnd
Joel E. Denny [Wed, 1 Sep 2021 20:24:14 +0000 (16:24 -0400)]
[OpenMP] Use IsHostPtr where needed for targetDataEnd

As discussed in D105990, without this patch, `targetDataEnd`
determines whether to transfer data or delete a device mapping (as
opposed to assuming it's in shared memory) using two different
conditions, each of which is broken for some cases:

1. `!(UNIFIED_SHARED_MEMORY && TgtPtrBegin == HstPtrBegin)`: The
   broken case is rare: the device and host might happen to use the
   same address for their mapped allocations.  I don't know how to
   write a test that's likely to reveal this case, but this patch does
   fix it, as discussed below.
2. `!UNIFIED_SHARED_MEMORY || HasCloseModifier`: There are at least
   two broken cases:
    1. The `close` modifier might have been specified on an `omp
      target enter data` but not the corresponding `omp target exit
      data`, which thus might falsely assume a mapping is in shared
      memory.  The test `unified_shared_memory/close_enter_exit.c`
      already has a missing deletion as a result, and this patch adds
      a check for that.  This patch also adds the new test
      `close_member.c` to reveal a missing transfer and deletion.
    2. Use of discrete memory might have been forced by
      `omp_target_associate_ptr`, as in the test
      `unified_shared_memory/api.c`.  In the current `targetDataEnd`
      implementation, this condition turns out not be used for this
      case: because the reference count is infinite, a transfer is
      possible only with an `always` modifier, and this condition is
      never used in that case.  To ensure it's never used for that
      case in the future, this patch adds the test
      `unified_shared_memory/associate_ptr.c`.

Fortunately, `DeviceTy::getTgtPtrBegin` already has a solution: it
reports whether the allocation was found in shared memory via the
variable `IsHostPtr`.

After this patch, `HasCloseModifier` is no longer used in
`targetDataEnd`, and I wonder if the `close` modifier is ever useful
on an `omp target data end`.

Reviewed By: grokos

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

2 years ago[OpaquePtr] Cleanup some uses of getPointerElementType() in TailRecursionElimination
Arthur Eubanks [Wed, 1 Sep 2021 21:21:58 +0000 (14:21 -0700)]
[OpaquePtr] Cleanup some uses of getPointerElementType() in TailRecursionElimination

2 years ago[InstrProfiling][test] Combine profiling.ll and linkage.ll
Fangrui Song [Wed, 1 Sep 2021 21:21:42 +0000 (14:21 -0700)]
[InstrProfiling][test] Combine profiling.ll and linkage.ll

The latter mostly covers the former.

2 years ago[SCEV] Clarify requirements for zero-stride to be UB
Philip Reames [Wed, 1 Sep 2021 20:56:25 +0000 (13:56 -0700)]
[SCEV] Clarify requirements for zero-stride to be UB

There's a silent bug in our reasoning about zero strides. We assume that having a single static exit implies that if that exit is not taken, then the loop must be infinite. This ignores the potential for abnormal exits via exceptions. Consider the following example:

for (uint_8 i = 0; i < 1; i += 0) {
  throw_on_thousandth_call();
}

Our reasoning is such that we'd conclude this loop can't take the backedge as that would lead to a (presumed) infinite loop.

In practice, this is a silent bug because the loopIsFiniteByAssumption returns false strictly more often than the loopHaNoAbnormalExits property. We could reasonable want to change that in the future, so fixing the codeflow now is worthwhile.

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

2 years ago[openmp] Drop test from D109057, disproportionately difficult to run on windows
Jon Chesterfield [Wed, 1 Sep 2021 20:51:51 +0000 (21:51 +0100)]
[openmp] Drop test from D109057, disproportionately difficult to run on windows

2 years ago [AMDGPU] enable scalar compare in truncate selection
alex-t [Wed, 1 Sep 2021 20:31:33 +0000 (23:31 +0300)]
 [AMDGPU] enable scalar compare in truncate selection

Currently, the truncate selection dag node is expanded as a bitwise AND plus compare to 1.  This change enables scalar comparison in the pattern if the truncate node is uniform.

Reviewed By: rampitec

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

2 years ago[LoopDeletion] Separate logic in breakBackedgeIfNotTaken using symboic max trip count...
Philip Reames [Wed, 1 Sep 2021 20:29:10 +0000 (13:29 -0700)]
[LoopDeletion] Separate logic in breakBackedgeIfNotTaken using symboic max trip count [nfc]

As mentioned in D108833, the logic for figuring out if a backedge is dead was somewhat interwoven with the SCEV based logic and the symbolic eval logic. This is my attempt at making the code easier to follow.

Note that this is only NFC after the work done in 29fa37ec.  Thanks to Nikita for catching that case.

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