8 months ago[NFC] Fix call to lldb RegisterValue constructor
Jordan Rupprecht [Tue, 3 Nov 2020 21:24:06 +0000 (13:24 -0800)]
[NFC] Fix call to lldb RegisterValue constructor

8 months ago[mlir][Parser] Small optimization to parsing
River Riddle [Tue, 3 Nov 2020 20:31:24 +0000 (12:31 -0800)]
[mlir][Parser] Small optimization to parsing

* Use function_ref instead of std::function in several methods
* Use ::get instead of ::getChecked for IntegerType.
  - It is already fully verified and constructing a mlir::Location can be extremely costly during parsing.

8 months ago[PowerPC] Add MMA builtin decoding and definitions
Baptiste Saleil [Tue, 3 Nov 2020 21:08:00 +0000 (15:08 -0600)]
[PowerPC] Add MMA builtin decoding and definitions

Add MMA builtin decoding. These builtins use the new PowerPC-specific types __vector_pair and __vector_quad.
So to avoid pervasive changes, we use custom type descriptors and custom decoding for these builtins.
We also use custom code generation to expand builtin calls with pointers to simpler intrinsic calls with non-pointer types.

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

8 months ago[NFC] Inline wasm assertion-only variable
Jordan Rupprecht [Tue, 3 Nov 2020 21:06:52 +0000 (13:06 -0800)]
[NFC] Inline wasm assertion-only variable

8 months ago[libc++] Harden tests against executors not running tests in a shell
Louis Dionne [Tue, 3 Nov 2020 19:44:47 +0000 (14:44 -0500)]
[libc++] Harden tests against executors not running tests in a shell

Some executors do not run the tests in a shell, and so assuming that
they can understand shell builtins is wrong. Instead, call Bash
directly to do what we need to do.

This still requires the executor to be able to run Bash, but at least
it does not require it to interpret command lines in the Bash language.

8 months ago[lldb] [test] Update XFAILs/skips for FreeBSD
Michał Górny [Tue, 3 Nov 2020 18:25:48 +0000 (19:25 +0100)]
[lldb] [test] Update XFAILs/skips for FreeBSD

Update expected failures and test skips based on common results
for the old and new FreeBSD plugins.

8 months ago[lldb] [test/Shell] Pass -pthread to host toolchain on FreeBSD too
Michał Górny [Tue, 3 Nov 2020 18:25:16 +0000 (19:25 +0100)]
[lldb] [test/Shell] Pass -pthread to host toolchain on FreeBSD too

8 months ago[lldb] [test] Remove xfail from tests that pass on FreeBSD
Michał Górny [Tue, 3 Nov 2020 17:46:10 +0000 (18:46 +0100)]
[lldb] [test] Remove xfail from tests that pass on FreeBSD

8 months ago[OpenMP] Fixed an issue in the test case parallel_offloading_map
Shilei Tian [Tue, 3 Nov 2020 20:59:05 +0000 (15:59 -0500)]
[OpenMP] Fixed an issue in the test case parallel_offloading_map

There is a non-conforming use of variable-sized array in the test case `parallel_offloading_map.c`. This patch fixed it.

Reviewed By: protze.joachim

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

8 months ago[clangd] Fix missing override warnings in remote-index client
Kadir Cetinkaya [Tue, 3 Nov 2020 20:46:44 +0000 (21:46 +0100)]
[clangd] Fix missing override warnings in remote-index client

8 months ago[clangd] Handle absolute/relative path specifications in Config
Kadir Cetinkaya [Tue, 27 Oct 2020 22:03:41 +0000 (23:03 +0100)]
[clangd] Handle absolute/relative path specifications in Config

This introduces a mechanism for providers to interpret paths specified
in a fragment either as absolute or relative to fragment location.
This information should be used during compile stage to handle blocks correctly.

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

8 months ago[libc++] Remove support for .run.fail.cpp tests
Louis Dionne [Tue, 3 Nov 2020 20:24:00 +0000 (15:24 -0500)]
[libc++] Remove support for .run.fail.cpp tests

Unfortunately, executing these tests correctly on platforms that do not
support a shell is very challenging. Since the executor can't just negate
the result of the command, we'd have to ship a portable program capable
of running the actual test executable, and negating its result.

Doing this portably is challenging. Since we do not currently have strong
use cases for tests that fail at runtime (we effectively have no tests
using that capability right now), it is difficult to justify making them
work portably. Instead, it makes more sense to remove this feature until
we can implement it properly (i.e. without requiring shell support).

8 months ago[unittest][TrasnformerTest] Fix asan stack-use-after-return
Fangrui Song [Tue, 3 Nov 2020 20:34:45 +0000 (12:34 -0800)]
[unittest][TrasnformerTest] Fix asan stack-use-after-return

8 months ago[libc++] NFC: Simplify how we run config tests
Louis Dionne [Tue, 3 Nov 2020 19:37:42 +0000 (14:37 -0500)]
[libc++] NFC: Simplify how we run config tests

We can use the convenience substitutions provided by the format instead
of bootstrapping our own.

8 months ago[crashlog] Print the actual exception in the CommandReturnObject
Jonas Devlieghere [Tue, 3 Nov 2020 19:49:59 +0000 (11:49 -0800)]
[crashlog] Print the actual exception in the CommandReturnObject


  error: python exception <class 'AttributeError'>


  error: python exception: 'DarwinImage' object has no attribute 'debugger'

8 months ago[musttail] Unify musttail call preceding return checking
Xun Li [Tue, 3 Nov 2020 19:39:27 +0000 (11:39 -0800)]
[musttail] Unify musttail call preceding return checking

There is already an API in BasicBlock that checks and returns the musttail call if it precedes the return instruction.
Use it instead of manually checking in each place.

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

8 months ago[compiler-rt] Use empty SuspendedThreadsList for Fuchsia
Petr Hosek [Tue, 3 Nov 2020 18:41:17 +0000 (10:41 -0800)]
[compiler-rt] Use empty SuspendedThreadsList for Fuchsia

d48f2d7 made destructor of SuspendedThreadsList protected, so we need
an empty subclass to pass to the callback now.

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

8 months ago[memprof] Don't protect destructor in final
Vitaly Buka [Tue, 3 Nov 2020 19:27:04 +0000 (11:27 -0800)]
[memprof] Don't protect destructor in final

8 months ago[Reassociate] Convert `add`-like `or`'s into an `add`'s to allow reassociation
Roman Lebedev [Tue, 3 Nov 2020 19:01:22 +0000 (22:01 +0300)]
[Reassociate] Convert `add`-like `or`'s into an `add`'s to allow reassociation

InstCombine is quite aggressive in doing the opposite transform,
folding `add` of operands with no common bits set into an `or`,
and that not many things support that new pattern..

In this case, teaching Reassociate about it is easy,
there's preexisting art for `sub`/`shl`:
just convert such an `or` into an `add`:

8 months ago[NFC][Reassociate] Add tests with `add`-like `or` (w/ no common bits set)
Roman Lebedev [Tue, 3 Nov 2020 18:24:13 +0000 (21:24 +0300)]
[NFC][Reassociate] Add tests with `add`-like `or` (w/ no common bits set)

8 months ago[mlir][vector] Add canonicalization patterns for ExtractStride/ShapeCast + Splat...
Thomas Raoux [Tue, 3 Nov 2020 18:56:22 +0000 (10:56 -0800)]
[mlir][vector] Add canonicalization patterns for ExtractStride/ShapeCast + Splat constant

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

8 months agoRevert "Precommit LTO pipeline test"
Sanne Wouda [Tue, 3 Nov 2020 19:29:14 +0000 (19:29 +0000)]
Revert "Precommit LTO pipeline test"

This reverts commit 5a72a1623e4afd9365a13473079db1ec66af1f0e.

8 months agoRevert "Add loop distribution to the LTO pipeline"
Sanne Wouda [Tue, 3 Nov 2020 19:29:00 +0000 (19:29 +0000)]
Revert "Add loop distribution to the LTO pipeline"

This reverts commit 6e80318eecde2639faa1e72be045c78b8b8aedad.

8 months ago[AMDGPU] Add some missing tests for GFX10.3 subtargets
Jay Foad [Tue, 3 Nov 2020 19:17:27 +0000 (19:17 +0000)]
[AMDGPU] Add some missing tests for GFX10.3 subtargets

8 months agoFix - [Clang] Add the ability to map DLL storage class to visibility
Ben Dunbobbin [Tue, 3 Nov 2020 18:54:57 +0000 (18:54 +0000)]
Fix - [Clang] Add the ability to map DLL storage class to visibility

415f7ee883 had a silly typo introduced when I inlined some
code into a loop from its own function.

Original commit message:

For PlayStation we offer source code compatibility with
Microsoft's dllimport/export annotations; however, our file
format is based on ELF.

To support this we translate from DLL storage class to ELF
visibility at the end of codegen in Clang.

Other toolchains have used similar strategies (e.g. see the
documentation for this ARM toolchain:


This patch adds the ability to perform this translation. Options
are provided to support customizing the mapping behaviour.

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

8 months agoAdd loop distribution to the LTO pipeline
Sanne Wouda [Wed, 21 Oct 2020 11:01:59 +0000 (11:01 +0000)]
Add loop distribution to the LTO pipeline

The LoopDistribute pass is missing from the LTO pipeline, so
-enable-loop-distribute has no effect during post-link. The pre-link
loop distribution doesn't seem to survive the LTO pipeline either.

With this patch (and -flto -mllvm -enable-loop-distribute) we see a 43%
uplift on SPEC 2006 hmmer for AArch64. The rest of SPECINT 2006 is

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

8 months agoPrecommit LTO pipeline test
Sanne Wouda [Wed, 21 Oct 2020 19:27:47 +0000 (19:27 +0000)]
Precommit LTO pipeline test

8 months agoReturn actual type from SBType::GetArrayElementType
Andy Yankovsky [Tue, 3 Nov 2020 18:32:42 +0000 (10:32 -0800)]
Return actual type from SBType::GetArrayElementType

SBType::GetArrayElementType should return the actual type, not the
canonical type (e.g. int32_t, not the underlying int).

Added a test case to validate the new behavior. I also ran all other
tests on Linux (ninja check-lldb), they all pass.

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

8 months ago[WebAssembly] Implement ref.null
Andy Wingo [Tue, 3 Nov 2020 18:46:23 +0000 (10:46 -0800)]
[WebAssembly] Implement ref.null

This patch adds a new "heap type" operand kind to the WebAssembly MC
layer, used by ref.null. Currently the possible values are "extern" and
"func"; when typed function references come, though, this operand may be
a type index.

Note that the "heap type" production is still known as "refedtype" in
the draft proposal; changing its name in the spec is
ongoing (https://github.com/WebAssembly/reference-types/issues/123).

The register form of ref.null is still untested.

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

8 months ago[HIP] Math Headers to use type promotion
Aaron En Ye Shi [Wed, 28 Oct 2020 17:51:55 +0000 (17:51 +0000)]
[HIP] Math Headers to use type promotion

Similar to libcxx implementation of cmath function
overloads, use type promotion templates to determine
return types of multi-argument math functions.

Fixes: SWDEV-256825

Reviewed By: tra, yaxunl

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

8 months ago[HIP] Use argv[0] as the default choice for the Executable name.
Artem Belevich [Thu, 29 Oct 2020 22:19:06 +0000 (15:19 -0700)]
[HIP] Use argv[0] as the default choice for the Executable name.

The path produced by getMainExecutable() may not be the right one when the files are installed in
a symlinked tree and when the real location of llvm-objdump is in a different directory.

Given that clang-offload-bundler is invoked by clang, the driver already does the job figuring out
the right path (e.g. it pays attention to -no-canonical-prefixes).
Offload bundler should use it, instead of trying to figure out the path on its

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

8 months ago[CUDA] Allow local static variables with target attributes.
Artem Belevich [Fri, 25 Sep 2020 23:25:27 +0000 (16:25 -0700)]
[CUDA] Allow local static variables with target attributes.

While CUDA documentation claims that such variables are not allowed[1], NVCC has
been accepting them since CUDA-10.0[2] and some headers in CUDA-11 rely on this

1. https://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#static-variables-function
2. https://godbolt.org/z/zsodzc

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

8 months ago[GVN] small improvements to comments
Jameson Nash [Tue, 3 Nov 2020 18:17:52 +0000 (13:17 -0500)]
[GVN] small improvements to comments

8 months ago[crashlog] Modularize parser
Jonas Devlieghere [Tue, 3 Nov 2020 18:21:00 +0000 (10:21 -0800)]
[crashlog] Modularize parser

Instead of parsing the crashlog in one big loop, use methods that
correspond to the different parsing modes.

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

8 months agoCleanup namespace comment to fix clang-tidy warning. NFCI.
Simon Pilgrim [Tue, 3 Nov 2020 18:13:21 +0000 (18:13 +0000)]
Cleanup namespace comment to fix clang-tidy warning. NFCI.

8 months ago[DAG] computeKnownBits - Move ISD::SRA handling into KnownBits::ashr
Simon Pilgrim [Tue, 3 Nov 2020 18:09:15 +0000 (18:09 +0000)]
[DAG] computeKnownBits - Move ISD::SRA handling into KnownBits::ashr

As discussed on D90527, we should be trying to move shift handling functionality into KnownBits to avoid code duplication in SelectionDAG/GlobalISel/ValueTracking.

8 months ago[RISCV] Add missing patterns for rotr with immediate for Zbb/Zbp extensions.
Craig Topper [Tue, 3 Nov 2020 17:33:06 +0000 (09:33 -0800)]
[RISCV] Add missing patterns for rotr with immediate for Zbb/Zbp extensions.

DAGCombine doesn't canonicalize rotl/rotr with immediate so we
need patterns for both.

Remove the custom matcher for rotl to RORI and just use a SDNodeXForm
to convert the immediate instead. Doing this gives priority to the
rev32/rev16 versions of grevi over rori since an explicit immediate
is more precise than any immediate. I also added rotr patterns for
rev32/rev16. And removed the (or (shl), (shr)) patterns that should be
combined to rotl by DAG combine.

There is at least one other grev pattern that probably needs a
another rotr pattern, but we need more test coverage first.

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

8 months ago[DAG] computeKnownBits - Move (most) ISD::SRL handling into KnownBits::lshr
Simon Pilgrim [Tue, 3 Nov 2020 17:30:17 +0000 (17:30 +0000)]
[DAG] computeKnownBits - Move (most) ISD::SRL handling into KnownBits::lshr

As discussed on D90527, we should be be trying to move shift handling functionality into KnownBits to avoid code duplication in SelectionDAG/GlobalISel/ValueTracking.

The refactor to use the KnownBits fixed/min/max constant helpers allows us to hit a couple of cases that we were missing before.

We still need the getValidMinimumShiftAmountConstant case as KnownBits doesn't handle per-element vector cases.

8 months ago[AMDGPU] Regenerate load i16 tests to use update_llc_test_checks.py script. NFCI.
Simon Pilgrim [Tue, 3 Nov 2020 16:50:18 +0000 (16:50 +0000)]
[AMDGPU] Regenerate load i16 tests to use update_llc_test_checks.py script. NFCI.

Necessary for upcoming KnownBits::lshr support.

8 months ago[libc++] Move <memory> helpers outside of std::allocator_traits
Louis Dionne [Tue, 3 Nov 2020 17:05:55 +0000 (12:05 -0500)]
[libc++] Move <memory> helpers outside of std::allocator_traits

They don't really belong as members of allocator_traits.

8 months ago[crashlog] Move crash log parsing into its own class
Jonas Devlieghere [Tue, 3 Nov 2020 04:29:32 +0000 (20:29 -0800)]
[crashlog] Move crash log parsing into its own class

Move crash log parsing out of the CrashLog class and into its own class
and add more tests.

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

8 months agoMake test/tools/llvm-dlltool/tool-name.test pass, and make it run
Nico Weber [Tue, 3 Nov 2020 16:55:22 +0000 (11:55 -0500)]
Make test/tools/llvm-dlltool/tool-name.test pass, and make it run

The test hasn't run since it was added in D71302.

8 months ago[NFC][AMDGPU] Minor editorial improvements to AMDGPUUsage.rst
Tony [Tue, 3 Nov 2020 02:14:45 +0000 (02:14 +0000)]
[NFC][AMDGPU] Minor editorial improvements to AMDGPUUsage.rst

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

8 months ago[compiler-rt][profile][AIX]: Enable compiler-rt profile build on AIX
etiotto [Tue, 3 Nov 2020 16:44:18 +0000 (11:44 -0500)]
[compiler-rt][profile][AIX]: Enable compiler-rt profile build on AIX

This patch adds support for building the compiler-rt profile library on AIX.

Reviewed by: phosek

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

8 months agoRevert "[PowerPC] Extend folding RLWINM + RLWINM to post-RA."
Esme-Yi [Tue, 3 Nov 2020 16:34:02 +0000 (16:34 +0000)]
Revert "[PowerPC] Extend folding RLWINM + RLWINM to post-RA."

This reverts commit 119ab2181e6ed823849c93d55af8e989c28c9f3c.

8 months ago[AMDGPU] Add gfx1033 target
Tim Renouf [Fri, 30 Oct 2020 08:21:12 +0000 (08:21 +0000)]
[AMDGPU] Add gfx1033 target

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

Change-Id: If2650fc7f31bbdd49c76e74a9ca8e3734d769761

8 months ago[AMDGPU] Add gfx90c target
Tim Renouf [Tue, 6 Oct 2020 17:23:59 +0000 (18:23 +0100)]
[AMDGPU] Add gfx90c target

This differentiates the Ryzen 4000/4300/4500/4700 series APUs that were
previously included in gfx909.

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

Change-Id: Ia901a7157eb2f73ccd9f25dbacec38427312377d

8 months ago[lldb] [Process/FreeBSDRemote] Fix "Fix attaching via lldb-server"
Michał Górny [Tue, 3 Nov 2020 14:00:58 +0000 (15:00 +0100)]
[lldb] [Process/FreeBSDRemote] Fix "Fix attaching via lldb-server"

One of the changes seems to have been lost in rebase.  Reapply.

8 months ago[openmp][openacc][NFC] Simplify access and validation of DirectiveBase information
Valentin Clement [Tue, 3 Nov 2020 16:12:14 +0000 (11:12 -0500)]
[openmp][openacc][NFC] Simplify access and validation of DirectiveBase information

This patch adds some helper in the DirectiveLanguage wrapper to initialize it from
the RecordKeeper and validate the records. This simplify arguments in lots of function
since only the DirectiveLanguge is passed.

Reviewed By: kiranchandramohan

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

8 months ago[CostModel] fix cost calc bug for sadd/ssub with overflow
Sanjay Patel [Tue, 3 Nov 2020 15:41:52 +0000 (10:41 -0500)]
[CostModel] fix cost calc bug for sadd/ssub with overflow

As noted in D90554, there's an opcode typo in using an easily
misused cost model API: getCmpSelInstrCost(). Beyond that, the
assumed sequence of ops is questionable, but that would be
another patch.

My guess is that the x86 test diffs show that we are probably
wrong both before and after this change, so there will be no
practical difference.
As an example, I tried this test which shows a cost of '7'
either way:

  define <4 x i32> @sadd(<4 x i32> %va, <4 x i32> %vb) {
    %V4I32  = call {<4 x i32>, <4 x i1>}  @llvm.sadd.with.overflow.v4i32(<4 x i32> %va, <4 x i32> %vb)
    %ov = extractvalue {<4 x i32>, <4 x i1>} %V4I32, 1
    %r = extractvalue {<4 x i32>, <4 x i1>} %V4I32, 0
    %z = select <4 x i1> %ov, <4 x i32> <i32 42, i32 42, i32 42, i32 42>, <4 x i32> %r
    ret <4 x i32> %z

  $ llc -o - sadd.ll -mattr=avx
        vpaddd  %xmm1, %xmm0, %xmm2
        vpcmpgtd        %xmm2, %xmm0, %xmm0
        vpxor   %xmm0, %xmm1, %xmm0
        vblendvps       %xmm0, LCPI0_0(%rip), %xmm2, %xmm0a

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

8 months agoFix GCC error: specialization of 'template<class LeafTy> struct llvm::LinearPolyBaseT...
Hans Wennborg [Tue, 3 Nov 2020 15:55:12 +0000 (16:55 +0100)]
Fix GCC error: specialization of 'template<class LeafTy> struct llvm::LinearPolyBaseTypeTraits' in different namespace

8 months ago[OpenMP][Tools] clang-format Archer (NFC)
Joachim Protze [Tue, 3 Nov 2020 15:31:50 +0000 (16:31 +0100)]
[OpenMP][Tools] clang-format Archer (NFC)

8 months ago[SVE][InstCombine] Improve specificity of InstCombine TypeSize test
Joe Ellis [Tue, 3 Nov 2020 15:24:41 +0000 (15:24 +0000)]
[SVE][InstCombine] Improve specificity of InstCombine TypeSize test

The test was using -O2, where -instcombine will suffice.

Reviewed By: sdesmalen

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

8 months ago[AMDGPU] Fix ds_read2/write2 with unaligned offsets
Jay Foad [Mon, 2 Nov 2020 13:05:15 +0000 (13:05 +0000)]
[AMDGPU] Fix ds_read2/write2 with unaligned offsets

These instructions use a scaled offset. We were wrongly selecting them
even when the required offset was not a multiple of the scale factor.

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

8 months ago[libcxx] Error out if __libcpp_mbsrtowcs_l fails in __time_get_storage
Martin Storsjö [Mon, 28 Oct 2019 21:46:34 +0000 (23:46 +0200)]
[libcxx] Error out if __libcpp_mbsrtowcs_l fails in __time_get_storage

If __libcpp_mbsrtowcs_l outputs zero wchar_t's for week days or
month names (due to errors in the locale function setup), these are
matched all the time in __time_get_storage::__analyze, ending up in
an infinite loop, allocating more memory until killed.

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

8 months ago[libcxx] [libcxxabi] Set flags for visibility when statically linking libcxxabi into...
Martin Storsjö [Fri, 23 Oct 2020 07:54:02 +0000 (10:54 +0300)]
[libcxx] [libcxxabi] Set flags for visibility when statically linking libcxxabi into libcxx for windows

Previously, these had to be set manually when building each of the
projects standalone, in order to get proper symbol visibility when
combining the two libraries.

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

8 months ago[lldb/Utility] Add unit tests for RegisterValue::GetScalarValue
Pavel Labath [Mon, 7 Sep 2020 07:33:58 +0000 (09:33 +0200)]
[lldb/Utility] Add unit tests for RegisterValue::GetScalarValue

Buggy cases are commented out.

Also sneak in a modernization of a RegisterValue constructor.

8 months ago[Docs][FileCheck] Small fix.
Mircea Trofin [Tue, 3 Nov 2020 15:08:51 +0000 (07:08 -0800)]
[Docs][FileCheck] Small fix.

8 months agomake the AsmPrinterHandler array public
Jameson Nash [Tue, 3 Nov 2020 13:54:51 +0000 (08:54 -0500)]
make the AsmPrinterHandler array public

This lets external consumers customize the output, similar to how
AssemblyAnnotationWriter lets the caller define callbacks when printing
IR. The array of handlers already existed, this just cleans up the code
so that it can be exposed publically.

Replaces https://reviews.llvm.org/D74158

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

8 months ago[ADT] Add SmallVector::pop_back_n
Nathan James [Tue, 3 Nov 2020 14:57:08 +0000 (14:57 +0000)]
[ADT] Add SmallVector::pop_back_n

Adds a method called pop_back_n to SmallVector.
This is more readable and less error prone than the alternatives of using
Vector.resize(Vector.size() - N);
Vector.erase(Vector.end() - N, Vector.end());
for (unsigned I = 0;I<N;++I) Vector.pop_back();

Reviewed By: dblaikie

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

8 months ago[SLP][X86][Test] Extend test coverage for PR47629
Anton Afanasyev [Tue, 3 Nov 2020 14:40:41 +0000 (17:40 +0300)]
[SLP][X86][Test] Extend test coverage for PR47629

Add two cases for `<i32 x 8>`. Precommit for PR47629 and D90445. NFC

8 months ago[AMDGPU] Precommit globalisel tests for ds_read2_b64 with large offset
Jay Foad [Tue, 3 Nov 2020 14:24:44 +0000 (14:24 +0000)]
[AMDGPU] Precommit globalisel tests for ds_read2_b64 with large offset

8 months ago[ASTMatchers] Made isExpandedFromMacro Polymorphic
Nathan James [Tue, 3 Nov 2020 14:36:50 +0000 (14:36 +0000)]
[ASTMatchers] Made isExpandedFromMacro Polymorphic

Made the isExpandedFromMacro matcher work on Stmt's, TypeLocs and Decls in line with the other macro expansion matchers.
Also tweaked it to take a `std::string` instead of a `StringRef`.
This prevents potential use-after-free bugs if the matcher is created with a string thats destroyed before the matcher finishes matching.

Reviewed By: aaron.ballman

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

8 months ago[DAG] computeKnownBits - Move (most) ISD::SHL handling into KnownBits::shl
Simon Pilgrim [Tue, 3 Nov 2020 13:49:00 +0000 (13:49 +0000)]
[DAG] computeKnownBits - Move (most) ISD::SHL handling into KnownBits::shl

As discussed on D90527, we should be be trying to move shift handling functionality into KnownBits to avoid code duplication in SelectionDAG/GlobalISel/ValueTracking.

The refactor to use the KnownBits fixed/min/max constant helpers allows us to hit a couple of cases that we were missing before.

We still need the getValidMinimumShiftAmountConstant case as KnownBits doesn't handle per-element vector cases.

8 months ago[gn build] Port 1667d23e585
LLVM GN Syncbot [Tue, 3 Nov 2020 13:58:51 +0000 (13:58 +0000)]
[gn build] Port 1667d23e585

8 months ago[gn build] (manually) port 1af3cb5424d
Nico Weber [Tue, 3 Nov 2020 13:58:23 +0000 (08:58 -0500)]
[gn build] (manually) port 1af3cb5424d

8 months ago[AMDGPU] Specify a triple to avoid codegen changes depending on host OS
Jay Foad [Tue, 3 Nov 2020 13:31:59 +0000 (13:31 +0000)]
[AMDGPU] Specify a triple to avoid codegen changes depending on host OS

8 months ago[mlir][spirv] Support for a few more decorations in (de)serialization
Lei Zhang [Tue, 3 Nov 2020 13:10:56 +0000 (08:10 -0500)]
[mlir][spirv] Support for a few more decorations in (de)serialization

Reviewed By: mravishankar

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

8 months ago[x86] update cost table comments for maxnum; NFC
Sanjay Patel [Tue, 3 Nov 2020 12:55:55 +0000 (07:55 -0500)]
[x86] update cost table comments for maxnum; NFC

Follow-up suggested in D90613.

8 months ago[CUDA][HIP] Fix linkage for -fgpu-rdc
Yaxun (Sam) Liu [Wed, 28 Oct 2020 14:44:21 +0000 (10:44 -0400)]
[CUDA][HIP] Fix linkage for -fgpu-rdc

Currently for explicit template function instantiation in CUDA/HIP device
compilation clang emits instantiated kernel with external linkage
and instantiated device function with internal linkage.

This is fine for -fno-gpu-rdc since there is only one TU.

However this causes duplicate symbols for kernels for -fgpu-rdc if
the same instantiation happen in multiple TU. Or missing symbols
if a device function calls an explicitly instantiated template function
in a different TU.

To make explicit template function instantiation work for
-fgpu-rdc we need to follow the C++ linkage paradigm, i.e.
use weak_odr linkage.

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

8 months ago[InstCombine] Perform C-(X+C2) --> (C-C2)-X transform before using Negator
Roman Lebedev [Tue, 3 Nov 2020 12:32:31 +0000 (15:32 +0300)]
[InstCombine] Perform  C-(X+C2) --> (C-C2)-X  transform before using Negator

In particular, it makes it fire for C=0, because negator doesn't want
to perform that fold since in general it's not beneficial.

8 months ago[InstCombine] Negator: - (C - %x) --> %x - C (PR47997)
Roman Lebedev [Tue, 3 Nov 2020 10:34:38 +0000 (13:34 +0300)]
[InstCombine] Negator: - (C - %x) --> %x - C (PR47997)

This relaxes one-use restriction on that `sub` fold,
since apparently the addition of Negator broke
preexisting `C-(C2-X) --> X+(C-C2)` (with C=0) fold.

8 months ago[NFC][InstCombine] Negator: add test coverage for `(?? - (%y + C))` pattern (PR47997)
Roman Lebedev [Tue, 3 Nov 2020 11:06:42 +0000 (14:06 +0300)]
[NFC][InstCombine] Negator: add test coverage for `(?? - (%y + C))` pattern (PR47997)

8 months ago[NFC][InstCombine] Negator: add test coverage for `(?? - (C - %y))` pattern (PR47997)
Roman Lebedev [Tue, 3 Nov 2020 11:04:36 +0000 (14:04 +0300)]
[NFC][InstCombine] Negator: add test coverage for `(?? - (C - %y))` pattern (PR47997)

8 months ago[NFC][InstCombine] Add test coverage for PR47997
Roman Lebedev [Tue, 3 Nov 2020 10:18:20 +0000 (13:18 +0300)]
[NFC][InstCombine] Add test coverage for PR47997

8 months ago[SCCP] Handle bitcast of vector constants.
Florian Hahn [Tue, 3 Nov 2020 10:32:38 +0000 (10:32 +0000)]
[SCCP] Handle bitcast of vector constants.

Vectors where all elements have the same known constant range are treated as a
single constant range in the lattice. When bitcasting such vectors, there is a
mis-match between the width of the lattice value (single constant range) and
the original operands (vector). Go to overdefined in that case.

Fixes PR47991.

8 months ago[ARM] Remove unused variable. NFC
David Green [Tue, 3 Nov 2020 12:58:10 +0000 (12:58 +0000)]
[ARM] Remove unused variable. NFC

8 months ago[OpenMP][libomptarget][Tests] fix failing test
Joachim Protze [Tue, 3 Nov 2020 11:31:05 +0000 (12:31 +0100)]
[OpenMP][libomptarget][Tests] fix failing test

D88149 updated `omp_get_initial_device` behavior to conform with OpenMP 5.1.
omp_get_initial_device() == omp_get_num_devices()

8 months ago[OpenMP][OMPT][NFC] Fix flaky test
Joachim Protze [Mon, 2 Nov 2020 15:43:12 +0000 (16:43 +0100)]
[OpenMP][OMPT][NFC] Fix flaky test

As reported by @ronlieb, the test shows intermittent fails.
The test failed, if the dependent task was already finished, when the depending
task was to be created. We have other tests to check for the dependences pair.

8 months ago[OpenMP][Tool] Handle detached tasks in Archer
Joachim Protze [Fri, 30 Oct 2020 08:36:07 +0000 (09:36 +0100)]
[OpenMP][Tool] Handle detached tasks in Archer

Since detached tasks are supported by clang and the OpenMP runtime, Archer
must expect to receive the corresponding callbacks.

This patch adds support to interpret the synchronization semantics of
omp_fulfill_event and cleans up the handling of task switches.

8 months agoRevert "[CodeGen] [WinException] Only produce handler data at the end of the function...
Hans Wennborg [Tue, 3 Nov 2020 12:01:55 +0000 (13:01 +0100)]
Revert "[CodeGen] [WinException] Only produce handler data at the end of the function if needed"

This caused an explosion in ICF times during linking on Windows when libfuzzer
instrumentation is enabled. For a small binary we see ICF time go from ~0 to
~10 s. For a large binary it goes from ~1 s to forevert (I gave up after 30

See comment on the code review.

> If we are going to write handler data (that is written as variable
> length data following after the unwind info in .xdata), we need to
> emit the handler data immediately, but for cases where no such
> info is going to be written, skip emitting it right away. (Unwind
> info for all remaining functions that hasn't gotten it emitted
> directly is emitted at the end.)
> This does slightly change the ordering of sections (triggering a
> bunch of updates to DebugInfo/COFF tests), but the change should be
> benign.
> This also matches GCC's assembly output, which doesn't output
> .seh_handlerdata unless it actually is needed.
> For ARM64, the unwind info can be packed into the runtime function
> entry itself (leaving no data in the .xdata section at all), but
> that can only be done if there's no follow-on data in the .xdata
> section. If emission of the unwind info is triggered via
> EmitWinEHHandlerData (or the .seh_handlerdata directive), which
> implicitly switches to the .xdata section, there's a chance of the
> caller wanting to pass further data there, so the packed format
> can't be used in that case.
> Differential Revision: https://reviews.llvm.org/D87448

This reverts commit 36c64af9d7f97414d48681b74352c9684077259b.

8 months ago[JITLink][ELF] Implement R_X86_64_PLT32 relocations
Stefan Gränitz [Tue, 3 Nov 2020 12:05:38 +0000 (12:05 +0000)]
[JITLink][ELF] Implement R_X86_64_PLT32 relocations

Basic implementation for call and jmp branches with 32 bit offset. Branches to local targets produce
Branch32 edges that are resolved like a regular PCRel32 relocations. Branches to external (undefined)
targets produce Branch32ToStub edges and go through a PLT entry by default. If the target happens to
get resolved within the 32 bit range from the callsite, the edge is relaxed during post-allocation
optimization. There is a test for each of these cases.

Reviewed By: lhames

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

8 months ago[clang-tidy] adding "--config-file=<file-path>" to specify custom config file.
Hiral Oza [Tue, 3 Nov 2020 10:11:44 +0000 (10:11 +0000)]
[clang-tidy] adding "--config-file=<file-path>" to specify custom config file.

Let clang-tidy to read config from specified file.
$ clang-tidy --config-file=/some/path/myTidyConfig --list-checks --
...this will read config from '/some/path/myTidyConfig'.

ClangTidyMain.cpp reads ConfigFile into string and then assigned read data to 'Config' i.e. makes like '--config' code flow internally.

May speed-up tidy runtime since now it will just look-up <file-path>
instead of searching ".clang-tidy" in parent-dir(s).

Directly specifying config path helps setting build dependencies.

Thanks to @DmitryPolukhin for valuable suggestion. This patch now propose
change only in ClangTidyMain.cpp.

Reviewed By: DmitryPolukhin

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

8 months agoFix 'default label in switch which covers all enumeration values' warning
serge-sans-paille [Tue, 3 Nov 2020 11:57:44 +0000 (12:57 +0100)]
Fix 'default label in switch which covers all enumeration values' warning

8 months ago[ARM] Treat memcpy/memset/memmove as call instructions for low overhead loops
David Green [Tue, 3 Nov 2020 11:53:09 +0000 (11:53 +0000)]
[ARM] Treat memcpy/memset/memmove as call instructions for low overhead loops

If an instruction will be lowered to a call there is no advantage of
using a low overhead loop as the LR register will need to be spilled and
reloaded around the call, and the low overhead will end up being
reverted. This teaches our hardware loop lowering that these memory
intrinsics will be calls under certain situations.

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

8 months ago[ARM] Low overhead loop memcpy lowering test. NFC
David Green [Tue, 3 Nov 2020 11:44:50 +0000 (11:44 +0000)]
[ARM] Low overhead loop memcpy lowering test. NFC

8 months ago[AArch64][SVE] NFC: Guard all SVE tests for TypeSize warnings.
Sander de Smalen [Tue, 3 Nov 2020 10:25:06 +0000 (10:25 +0000)]
[AArch64][SVE] NFC: Guard all SVE tests for TypeSize warnings.

This patch adds a bunch of CHECK lines to guard against implicit
conversions of TypeSize -> uint64_t occuring in code-paths that previously
were safe for scalable vectors.

8 months ago[MLIR] Added test operations to replace linalg dependency for
Alexander Bosch [Tue, 13 Oct 2020 14:02:21 +0000 (16:02 +0200)]
[MLIR] Added test operations to replace linalg dependency for

Added test operations to replace the LinalgDialect dependency in tests
which use the buffer-deallocation, buffer-hoisting,
buffer-loop-hoisting, promote-buffers-to-stack,
buffer-placement-preparation-allowed-memref-resutls and
buffer-placement-preparation pass. Adapted the corresponding tests cases
and TestBufferPlacement.cpp.

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

8 months agoMake the implicit nesting behavior of the PassManager user-controllable and default...
Mehdi Amini [Tue, 3 Nov 2020 11:17:39 +0000 (11:17 +0000)]
Make the implicit nesting behavior of the PassManager user-controllable and default to false

This is an error prone behavior, I frequently have ~20 min debugging sessions when I hit
an unexpected implicit nesting. This default makes the C++ API safer for users.

Depends On D90669

Reviewed By: rriddle

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

8 months agoHandle the verifier at run() time in the PassManager instead of build time
Mehdi Amini [Tue, 3 Nov 2020 11:17:01 +0000 (11:17 +0000)]
Handle the verifier at run() time in the PassManager instead of build time

This simplifies a few parts of the pass manager, but in particular we don't add as many
verifierpass as there are passes in the pipeline, and we can now enable/disable the
verifier after the fact on an already built PassManager.

Reviewed By: rriddle

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

8 months agoChange the PrintOpStatsPass to operate on any operation instead of just ModuleOp
Mehdi Amini [Tue, 3 Nov 2020 05:00:43 +0000 (05:00 +0000)]
Change the PrintOpStatsPass to operate on any operation instead of just ModuleOp

This allows to use it on other operation, like a GPUModule for example.

8 months agoRemove mlir-c/Core.h which is superseded by the new API in mlir-c/IR.h
Mehdi Amini [Mon, 2 Nov 2020 21:27:28 +0000 (21:27 +0000)]
Remove mlir-c/Core.h which is superseded by the new API in mlir-c/IR.h

This header was an initial early attempt at a crude C API for bindings,
but it isn't used and redundant with the new API. At this point it only
contributes to more confusion.

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

8 months agoAdd test missing from previous commit
Stephen Kelly [Mon, 2 Nov 2020 23:30:52 +0000 (23:30 +0000)]
Add test missing from previous commit

8 months ago[AggressiveInstCombine] Generalize foldGuardedRotateToFunnelShift to generic funnel...
Simon Pilgrim [Tue, 3 Nov 2020 10:49:33 +0000 (10:49 +0000)]
[AggressiveInstCombine] Generalize foldGuardedRotateToFunnelShift to generic funnel shifts

The fold currently only handles rotation patterns, but with the maturation of backend funnel shift handling we can now realistically handle all funnel shift patterns.

This should allow us to begin resolving PR46896 et al.

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

8 months ago[mlir] Convert `memref_reshape` to LLVM.
Alexander Belyaev [Tue, 3 Nov 2020 10:36:14 +0000 (11:36 +0100)]
[mlir] Convert `memref_reshape` to LLVM.


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

8 months ago[SLP] Pass VecPred argument to getCmpSelInstrCost.
Florian Hahn [Tue, 3 Nov 2020 09:55:47 +0000 (09:55 +0000)]
[SLP] Pass VecPred argument to getCmpSelInstrCost.

Check if all compares in VL have the same predicate and pass it to
getCmpSelInstrCost, to improve cost-modeling on targets that only
support compare/select combinations for certain uniform predicates.

This leads to additional vectorization in some cases

Same hash: 217 (filtered out)
Remaining: 19
Metric: SLP.NumVectorInstructions

Program                                        base    slp2    diff
 test-suite...marks/SciMark2-C/scimark2.test    11.00   26.00  136.4%
 test-suite...T2006/445.gobmk/445.gobmk.test    79.00  135.00  70.9%
 test-suite...ediabench/gsm/toast/toast.test    54.00   71.00  31.5%
 test-suite...telecomm-gsm/telecomm-gsm.test    54.00   71.00  31.5%
 test-suite...CI_Purple/SMG2000/smg2000.test   426.00  542.00  27.2%
 test-suite...ch/g721/g721encode/encode.test    30.00   24.00  -20.0%
 test-suite...000/186.crafty/186.crafty.test   116.00  138.00  19.0%
 test-suite...ications/JM/ldecod/ldecod.test   697.00  765.00   9.8%
 test-suite...6/464.h264ref/464.h264ref.test   822.00  886.00   7.8%
 test-suite...chmarks/MallocBench/gs/gs.test   154.00  162.00   5.2%
 test-suite...nsumer-lame/consumer-lame.test   621.00  651.00   4.8%
 test-suite...lications/ClamAV/clamscan.test   223.00  231.00   3.6%
 test-suite...marks/7zip/7zip-benchmark.test   680.00  695.00   2.2%
 test-suite...CFP2000/177.mesa/177.mesa.test   2121.00 2129.00  0.4%
 test-suite...:: External/Povray/povray.test   2406.00 2412.00  0.2%
 test-suite...TimberWolfMC/timberwolfmc.test   634.00  634.00   0.0%
 test-suite...CFP2006/433.milc/433.milc.test   1036.00 1036.00  0.0%
 test-suite.../Benchmarks/nbench/nbench.test   321.00  321.00   0.0%
 test-suite...ctions-flt/Reductions-flt.test    NaN      5.00   nan%

Reviewed By: RKSimon

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

8 months ago[lld] missing doc entry for error handling script
serge-sans-paille [Tue, 3 Nov 2020 10:14:38 +0000 (11:14 +0100)]
[lld] missing doc entry for error handling script

Fix http://lab.llvm.org:8011/#/builders/69/builds/67

8 months ago[AArch64] Redundant masks in downcast long multiply
Nicholas Guy [Thu, 22 Oct 2020 12:41:05 +0000 (13:41 +0100)]
[AArch64] Redundant masks in downcast long multiply

Adds patterns to catch masks preceeding a long multiply,
and generating a single umull/smull instruction instead.

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

8 months agoProvide a hook to customize missing library error handling
serge-sans-paille [Mon, 19 Oct 2020 11:19:52 +0000 (13:19 +0200)]
Provide a hook to customize missing library error handling

Make it possible for lld users to provide a custom script that would help to
find missing libraries. A possible scenario could be:

    % clang /tmp/a.c -fuse-ld=lld -loauth -Wl,--error-handling-script=/tmp/addLibrary.py
    unable to find library -loauth
    looking for relevant packages to provides that library


Where addLibrary would be called with the missing library name as first argument
(in that case addLibrary.py oauth)

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

8 months ago[CostModel] Make target intrinsics cheap by default
David Green [Tue, 3 Nov 2020 09:58:28 +0000 (09:58 +0000)]
[CostModel] Make target intrinsics cheap by default

This patch changes the intrinsics cost model to assume that by default
target intrinsics are cheap. This didn't seem to be the case for all
intrinsics, and is potentially an MVE problem due to our scalarization
overheads. Cheap seems to be a good default in general though.

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