platform/upstream/llvm.git
3 years agoSelectionDAGDumper.cpp - printrWithDepthHelper - remove dead code. NFCI.
Simon Pilgrim [Fri, 30 Jul 2021 16:32:01 +0000 (17:32 +0100)]
SelectionDAGDumper.cpp - printrWithDepthHelper - remove dead code. NFCI.

Fixes coverity warning - we have an early-out for unsigned depth == 0, so the depth < 1 early-out later on is dead code.

3 years ago[mlir][sparse] template the memory resident coordinate scheme storage
Aart Bik [Fri, 30 Jul 2021 16:48:41 +0000 (09:48 -0700)]
[mlir][sparse] template the memory resident coordinate scheme storage

Rationale:
External file formats always store the values as doubles, so this was
hard coded in the memory resident COO scheme used to pass data into the
final sparse storage scheme during setup. However, with alternative methods
on the horizon of setting up these temporary COO schemes, it is time to
properly template this data structure.

Reviewed By: gussmith23

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

3 years ago[lldb] Always codesign binaries on macOS
Jonas Devlieghere [Fri, 30 Jul 2021 18:14:19 +0000 (11:14 -0700)]
[lldb] Always codesign binaries on macOS

Always codesign binaries on macOS. Apple Silicon has stricter
codesigning requirements, for example requiring macCatalyst binaries to
be signed. Ad-hoc sign everything like we do for other Darwin platforms.

3 years ago[OpenMP] Fixing llvm-omp-device-info compilation with runtimes
Jose M Monsalve Diaz [Fri, 30 Jul 2021 16:26:26 +0000 (11:26 -0500)]
[OpenMP] Fixing llvm-omp-device-info compilation with runtimes

When using `-DLLVM_ENABLED_RUNTIMES` instead of `-DLLVM_ENABLED_PROJECTS`
the `llvm-omp-device-info` tool is not compiled or installed.
In general, no llvm tool would be build on runtimes, because the
-DLLVM_BUILD_TOOLS flag is removed by the way runtimes compilation calls
cmake again.

This patch is simple. Just forward the value of this flag to the
runtime cmake command.

I'm also removing an unnecessary comment in the compilation of the tool

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

3 years ago[gn build] Port 481ad59b9fa4
LLVM GN Syncbot [Fri, 30 Jul 2021 17:57:30 +0000 (17:57 +0000)]
[gn build] Port 481ad59b9fa4

3 years ago[nfc] improve a simple call
Walter Erquinigo [Fri, 30 Jul 2021 17:54:38 +0000 (10:54 -0700)]
[nfc] improve a simple call

@jingham correctly pointed out that this call can be simplified. So
let's better do it.

3 years ago[libcxx][ranges] Add `std::ranges::single_view`.
zoecarver [Tue, 27 Jul 2021 00:27:40 +0000 (17:27 -0700)]
[libcxx][ranges] Add `std::ranges::single_view`.

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

3 years agoTrim failing test
Paul Robinson [Fri, 30 Jul 2021 17:51:01 +0000 (10:51 -0700)]
Trim failing test

Don't try to run the non-integrated assembler; just verify that the
invocations look like what we expect.  Do verify that the integrated
assembler handles warnings as expected.

3 years ago[libc][NFC] Add dummy errno target to satisfy mixed mode builds.
Siva Chandra Reddy [Fri, 30 Jul 2021 17:38:04 +0000 (17:38 +0000)]
[libc][NFC] Add dummy errno target to satisfy mixed mode builds.

In mixed mode builds, we should not be including errno as part of
LLVM libc - errno from another library (or the system library) should be
used. But, other entrypoints which use errno list LLVM libc's errno as a
dep ta satisfy the full build mode. So, we add a dummy errno
implementation with empty files to make both mixed mode and full build
mode happy.

3 years agoGlobalISel: Have lowerLoad scalarize unaligned vectors
Matt Arsenault [Mon, 26 Jul 2021 18:10:26 +0000 (14:10 -0400)]
GlobalISel: Have lowerLoad scalarize unaligned vectors

This could be smarter by picking an ideal type, or at least splitting
the vector in half first. Also handles lower for non-power-of-2,
non-extending vector loads.

Currently this just avoids failing to legalize some odd vector AMDGPU
tests, but is a step towards removing the split logic from the
NarrowScalar logic.

3 years ago[SLP]Improve splats vectorization.
Alexey Bataev [Thu, 29 Jul 2021 20:47:57 +0000 (13:47 -0700)]
[SLP]Improve splats vectorization.

Replace insertelement instructions for splats with just single
insertelement + broadcast shuffle. Also, try to merge these instructions
if they come from the same/shuffled gather node.

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

3 years agoReland "[LV] Use lookThroughAnd with logical reductions"
Kerry McLaughlin [Fri, 30 Jul 2021 13:26:30 +0000 (14:26 +0100)]
Reland "[LV] Use lookThroughAnd with logical reductions"

If a reduction Phi has a single user which `AND`s the Phi with a type mask,
`lookThroughAnd` will return the user of the Phi and the narrower type represented
by the mask. Currently this is only used for arithmetic reductions, whereas loops
containing logical reductions will create a reduction intrinsic using the widened
type, for example:

  for.body:
    %phi = phi i32 [ %and, %for.body ], [ 255, %entry ]
    %mask = and i32 %phi, 255
    %gep = getelementptr inbounds i8, i8* %ptr, i32 %iv
    %load = load i8, i8* %gep
    %ext = zext i8 %load to i32
    %and = and i32 %mask, %ext
    ...

^ this will generate an and reduction intrinsic such as the following:
    call i32 @llvm.vector.reduce.and.v8i32(<8 x i32>...)

The same example for an add instruction would create an intrinsic of type i8:
    call i8 @llvm.vector.reduce.add.v8i8(<8 x i8>...)

This patch changes AddReductionVar to call lookThroughAnd for other integer
reductions, allowing loops similar to the example above with reductions such
as and, or & xor to vectorize.

Reviewed By: david-arm, dmgreen

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

3 years agoGlobalISel: Have load lowering handle some unaligned accesses
Matt Arsenault [Thu, 22 Jul 2021 12:11:14 +0000 (08:11 -0400)]
GlobalISel: Have load lowering handle some unaligned accesses

The code for splitting an unaligned access into 2 pieces is
essentially the same as for splitting a non-power-of-2 load for
scalars. It would be better to pick an optimal memory access size and
directly use it, but splitting in half is what the DAG does.

As-is this fixes handling of some unaligned sextload/zextloads for
AMDGPU. In the future this will help drop the ugly abuse of
narrowScalar to handle splitting unaligned accesses.

3 years agoXFAIL ppc => powerpc
Paul Robinson [Fri, 30 Jul 2021 16:39:44 +0000 (09:39 -0700)]
XFAIL ppc => powerpc

3 years agoAMDGPU/GlobalISel: Fix tests using illegal copies to physregs
Matt Arsenault [Tue, 27 Jul 2021 16:42:14 +0000 (12:42 -0400)]
AMDGPU/GlobalISel: Fix tests using illegal copies to physregs

These are unlegalizable and introduce spurious failures. Ideally the
verifier would reject them. Also avoid some weird G_INSERTs.

3 years agoAMDGPU/GlobalISel: Remove special case lowering for non-pow-2 stores
Matt Arsenault [Sun, 6 Jun 2021 16:44:24 +0000 (12:44 -0400)]
AMDGPU/GlobalISel: Remove special case lowering for non-pow-2 stores

We end up with extra copies from buildAnyExtOrTrunc if these are
lowered after the register types are legalized.

3 years ago[clang-tidy] Fix cppcoreguidelines-init-variables by removing the enum
Liuke Gehry [Wed, 21 Jul 2021 11:49:00 +0000 (11:49 +0000)]
[clang-tidy] Fix cppcoreguidelines-init-variables by removing the enum
FixIt, and add support for initialization check of scoped enum

In C++, the enumeration is never Integer, and the enumeration condition judgment is added to avoid compiling errors when it is initialized to an integer.
Add support for initialization check of scope enum.

As the following case show, clang-tidy will give a wrong automatic fix:

    enum Color {Red, Green, Blue};
    enum class Gender {Male, Female};
    void func() {
      Color color; // Color color = 0; <--- fix bug
      Gender gender; // <--- no warning
    }

Reviewd By: aaron.ballman, whisperity

Differential Revision: http://reviews.llvm.org/D106431

3 years ago[flang] Move External IO tests to use GTest
Asher Mancinelli [Wed, 28 Jul 2021 15:32:36 +0000 (09:32 -0600)]
[flang] Move External IO tests to use GTest

Port external-io test to use GTest. Remove Runtime tests directory.
Rename RuntimeGTest directory to Runtime.

This is the last in a series of patches which ported tests from the old
flang/unittests/Runtime test directory to use GTest in a temporary
unittest directory under flang/unittests/RuntimeGTest. Now that all the
tests in the old directory have been ported to use GTest, the old
directory has been removed and the GTest directory has been renamed to
flang/unittests/Runtime.

Differential Revision: https://reviews.llvm.org/D105315
Reviewed by: Meinersbur, awarzynski

3 years ago[mlir] Fully qualify MemoryEffects
Markus Böck [Fri, 30 Jul 2021 16:19:30 +0000 (18:19 +0200)]
[mlir] Fully qualify MemoryEffects

The effect name is used by tablegen when generating the getEffects method of the SideEffectInterfaces. It is currently unqualified even though the class is contained within the mlir namespace, leading to compiler errors when using namespace mlir; isn't used before including the generated cpp file.

This patch fixes that by simply fully qualifying the class name.

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

3 years agoXFAIL a test on ppc64
Paul Robinson [Fri, 30 Jul 2021 16:05:03 +0000 (09:05 -0700)]
XFAIL a test on ppc64

Buildbot failure:
https://lab.llvm.org/buildbot/#/builders/105/builds/13141
which provides no details about why it failed, but the only failure
reports are for ppc64 bots.

3 years ago[Transforms] Remove HasValueForBlock (NFC)
Kazu Hirata [Fri, 30 Jul 2021 15:56:49 +0000 (08:56 -0700)]
[Transforms] Remove HasValueForBlock (NFC)

The function seems to be unused for at least one year.

3 years ago[AIX] Pass the -b option to linker on AIX (with fix to build break)
Anjan Kumar [Fri, 30 Jul 2021 15:50:52 +0000 (15:50 +0000)]
[AIX] Pass the -b option to linker on AIX (with fix to build break)

This patch will re-enable the patch posted under https://reviews.llvm.org/D106688 originally which was reverted due to buildbreak that was caused by mismatched diagnostic message arguments.

Reviewed By: Zarko Todorovski

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

3 years ago[OpenMP][Offloading] Remove task wait in nowait interfaces
Shilei Tian [Fri, 30 Jul 2021 15:39:38 +0000 (11:39 -0400)]
[OpenMP][Offloading] Remove task wait in nowait interfaces

All `nowait` series of interfaces in `libomptarget` accept four more arguments (`int32_t depNum, void *depList, int32_t noAliasDepNum, void *noAliasDepList`) compared with their counterparts w/o `nowait`. These extra arguments were expected for dependence resolution, potentially lowered to device side. Current implementation calls `libomp` function `__kmpc_omp_taskwait`. However, the front end simply ignores them, that these four arguments are not emitted at all. As a consequence, the `depNum` and `noAliasDepNum` are garbage, which could lead to unnecessary task wait.

Reviewed By: grokos

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

3 years ago[Bazel] Typo fix
Shivam Gupta [Fri, 30 Jul 2021 15:36:14 +0000 (08:36 -0700)]
[Bazel] Typo fix

Reviewed By: GMNGeoffrey

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

3 years ago[X86] Add some initial tests for frozen constant folds
Simon Pilgrim [Fri, 30 Jul 2021 15:36:48 +0000 (16:36 +0100)]
[X86] Add some initial tests for frozen constant folds

We currently handle scalar but not vector cases

3 years agoAdd triples to try to fix a test
Paul Robinson [Fri, 30 Jul 2021 15:35:34 +0000 (08:35 -0700)]
Add triples to try to fix a test

Buildbot failure:
https://lab.llvm.org/buildbot/#/builders/105/builds/13139
which provides no details about why it failed.

3 years ago[OpenCL] Add support of __opencl_c_pipes feature macro.
Anton Zabaznov [Fri, 30 Jul 2021 11:08:59 +0000 (14:08 +0300)]
[OpenCL] Add support of __opencl_c_pipes feature macro.

'pipe' keyword is introduced in OpenCL C 2.0: so do checks for OpenCL C version while
parsing and then later on check for language options to construct actual pipe. This feature
requires support of __opencl_c_generic_address_space, so diagnostics for that is provided as well.

This is the same patch as in D106748 but with a tiny fix in checking of diagnostic messages.
Also added tests when program scope global variables are not supported.

Reviewed By: Anastasia

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

3 years ago[SVE] Add folds for sign and zero extends of vscale
Dylan Fleming [Fri, 30 Jul 2021 14:33:06 +0000 (15:33 +0100)]
[SVE] Add folds for sign and zero extends of vscale

Reviewed By: efriedma

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

3 years agoFix test that was never run.
Paul Robinson [Fri, 30 Jul 2021 14:22:56 +0000 (07:22 -0700)]
Fix test that was never run.

Commit 83df122 (r368334) added 'REQUIRES: linux' to this test, but
because triples are not respected by REQUIRES, that meant it was
invariably Unsupported.  The correct keyword would be 'system-linux'
(checking the host rather than the target).

Because the test was always skipped, commit 0cfd9e5 (r375439) did not
notice that the test modification was incorrect.

This patch corrects the REQUIRES clause and fixes the incorrect
previous patch.

Found after implementing https://reviews.llvm.org/D107162

3 years ago[OpenMP][AMDGCN] Initial math headers support
Pushpinder Singh [Fri, 30 Jul 2021 08:56:40 +0000 (08:56 +0000)]
[OpenMP][AMDGCN] Initial math headers support

With this patch, OpenMP on AMDGCN will use the math functions
provided by ROCm ocml library. Linking device code to the ocml will be
done in the next patch.

Reviewed By: JonChesterfield, jdoerfert, scchan

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

3 years ago[NFC] clang-format OptimizationLevel.h
Mircea Trofin [Fri, 30 Jul 2021 14:44:03 +0000 (07:44 -0700)]
[NFC] clang-format OptimizationLevel.h

3 years ago[PowerPC] Emit error for Altivec vector initializations when -faltivec-src-compat...
Amy Kwan [Fri, 30 Jul 2021 13:50:44 +0000 (08:50 -0500)]
[PowerPC] Emit error for Altivec vector initializations when -faltivec-src-compat=gcc is specified

Under the -faltivec-src-compat=gcc option, AltiVec vector initialization should
be treated as if they were compiled with gcc - which is, to emit an error when
the vectors are initialized in the parenthesized or non-parenthesized manner.
This patch implements this behaviour.

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

3 years ago[mlir][Vector] Add vector to outerproduct lowering for the [reduction, parallel]...
Nicolas Vasilache [Fri, 2 Jul 2021 20:09:29 +0000 (20:09 +0000)]
[mlir][Vector] Add vector to outerproduct lowering for the [reduction, parallel] case.

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

3 years ago[OpenMP][NFC] libomp: silence warnings on unused variables.
AndreyChurbanov [Fri, 30 Jul 2021 14:04:42 +0000 (17:04 +0300)]
[OpenMP][NFC] libomp: silence warnings on unused variables.

Put declarations/definitions of unused variables under corresponding macros
to silence clang build warnings.

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

3 years ago[clang][patch][FPEnv] Fix syntax errors in pragma float_control test
Melanie Blower [Fri, 30 Jul 2021 13:59:26 +0000 (09:59 -0400)]
[clang][patch][FPEnv] Fix syntax errors in pragma float_control test

In a post-commit message to https://reviews.llvm.org/D102343
@MaskRay pointed out syntax errors in one of the test cases. This
patch fixes those problems, I had forgotten the colon after the CHECK- strings.

3 years ago[AMDGPU][OpenMP] Support linking of math libraries
Pushpinder Singh [Wed, 14 Jul 2021 14:07:04 +0000 (14:07 +0000)]
[AMDGPU][OpenMP] Support linking of math libraries

Math libraries are linked only when -lm is specified. This is because
host system could be missing rocm-device-libs.

Reviewed By: JonChesterfield, yaxunl

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

3 years ago[libc++][NFC] Fix copy-paste error in the transform_view tests
Louis Dionne [Fri, 30 Jul 2021 13:51:51 +0000 (09:51 -0400)]
[libc++][NFC] Fix copy-paste error in the transform_view tests

3 years ago[ARM] Attempt to distribute reductions
David Green [Fri, 30 Jul 2021 13:48:31 +0000 (14:48 +0100)]
[ARM] Attempt to distribute reductions

This adds a combine for adds of reductions, distributing them so that
they occur sequentially to enable better use of accumulating VADDVA
instructions. It combines:
  add(X, add(vecreduce(Y), vecreduce(Z))) ->
    add(add(X, vecreduce(Y)), vecreduce(Z))
and
  add(add(A, reduce(B)), add(C, reduce(D))) ->
    add(add(add(A, C), reduce(B)), reduce(D))

These together distribute the add's so that more reductions can be
selected to VADDVA.

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

3 years ago[libomptarget][amdcgn] Add build dependency for opt
Joachim Protze [Fri, 30 Jul 2021 13:43:30 +0000 (15:43 +0200)]
[libomptarget][amdcgn] Add build dependency for opt

This patch should fix the build we observe when building LLVM from scratch.

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

3 years ago[libc++] Handle arrays in std::destroy_at
Louis Dionne [Tue, 27 Jul 2021 19:45:09 +0000 (15:45 -0400)]
[libc++] Handle arrays in std::destroy_at

Also, improve tests for std::destroy and std::destroy_n so that they
check for array support.

These changes are part of http://wg21.link/p0896 (the One Ranges proposal).

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

3 years ago[clangd] Record remote index usage
Kadir Cetinkaya [Mon, 26 Jul 2021 15:08:03 +0000 (17:08 +0200)]
[clangd] Record remote index usage

This is a gauage metric that sets particular remote-index instances as
used. It should enable accumulation of multiple streams to see number of clangd
processes making use of remote index, broken down by remote index address.

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

3 years ago[clangd] Unify compiler invocation creation
Kadir Cetinkaya [Fri, 23 Jul 2021 14:57:33 +0000 (16:57 +0200)]
[clangd] Unify compiler invocation creation

Background-indexing is fine, because it uses GlobalCompilationDatabase
to fetch the compile commands (hence uses CommandMangler), and creates
invocation through buildCompilerInvocation.

Depends on D106639.

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

3 years ago[X86][AVX] Add test case for PR51281
Simon Pilgrim [Fri, 30 Jul 2021 13:10:29 +0000 (14:10 +0100)]
[X86][AVX] Add test case for PR51281

3 years ago[clangd] Make use of diagnostic tags for some clang diags
Kadir Cetinkaya [Tue, 27 Jul 2021 12:25:29 +0000 (14:25 +0200)]
[clangd] Make use of diagnostic tags for some clang diags

It is not great to list diag ids by hand, but I don't see any other
solution unless diagnostics are annotated with these explicitly, which is a
bigger change in clang and I am not sure if would be worth it.

Diagnostics handled by this patch is by no means exhaustive, there might be
other checks that don't mention "unused"/"deprecated" in their names. But it
feels like this should be enough to catch common diagnostics and can be extended
over time.

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

3 years ago[hwasan] Detect use after scope within function.
Florian Mayer [Tue, 27 Jul 2021 08:43:59 +0000 (09:43 +0100)]
[hwasan] Detect use after scope within function.

Reviewed By: vitalybuka

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

3 years agoRevert "[lldb] [DWARF-5] Be lazier about loading .dwo files"
Jan Kratochvil [Fri, 30 Jul 2021 12:54:27 +0000 (14:54 +0200)]
Revert "[lldb] [DWARF-5] Be lazier about loading .dwo files"

This reverts commit e7b8ba103a8411fb25237727c3822d4c431e4814.

It broke 32-bit ARM - lldb-arm-ubuntu, reported by omjavaid:
  https://lab.llvm.org/buildbot/#/builders/17/builds/9595

3 years ago[SLP]Fix an assertion for the size of user nodes.
Alexey Bataev [Thu, 29 Jul 2021 14:12:15 +0000 (07:12 -0700)]
[SLP]Fix an assertion for the size of user nodes.

For the nodes with reused scalars the user may be not only of the size
of the final shuffle but also of the size of the scalars themselves,
need to check for this. It is safe to just modify the check here, since
the order of the scalars themselves is preserved, only indeces of the
reused scalars are changed. So, the users with the same size as the
number of scalars in the node, will not be affected, they still will get
the operands in the required order.

Reported by @mstorsjo in D105020.

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

3 years ago[SLP]Do not consider deleted instruction as external users.
Alexey Bataev [Thu, 29 Jul 2021 21:29:08 +0000 (14:29 -0700)]
[SLP]Do not consider deleted instruction as external users.

If the instruction was previously deleted, it should not be treated as
an external user. This fixes cost estimation and removes dead
extractelement instructions.

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

3 years ago[clangd] Enable relative configs in check mode
Kadir Cetinkaya [Fri, 30 Jul 2021 05:39:46 +0000 (07:39 +0200)]
[clangd] Enable relative configs in check mode

See https://github.com/clangd/clangd/issues/649#issuecomment-885903316.
Also disables config support in lit tests to make sure tests are not affected by
clangd config files lying around.

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

3 years ago[SLP]Fix a crash in gathered loads analysis.
Alexey Bataev [Thu, 29 Jul 2021 12:05:29 +0000 (05:05 -0700)]
[SLP]Fix a crash in gathered loads analysis.

Need to check that the minimum acceptable vector factor is at least 2,
not 0, to avoid compiler crash during gathered loads analysis.

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

3 years ago[OMPIRBuilder] add minimalist reduction support
Alex Zinenko [Fri, 30 Jul 2021 09:46:26 +0000 (11:46 +0200)]
[OMPIRBuilder] add minimalist reduction support

This introduces a builder function for emitting IR performing reductions in
OpenMP. Reduction variable privatization and initialization to the
reduction-neutral value is expected to be handled separately. The caller
provides the reduction functions. Further commits can provide implementation of
reduction functions for the reduction operators defined in the OpenMP
specification.

This implementation was tested on an MLIR fork targeting OpenMP from C and
produced correct executable code.

Reviewed By: Meinersbur

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

3 years ago[lldb] [DWARF-5] Be lazier about loading .dwo files
Eric Leese [Fri, 30 Jul 2021 11:08:00 +0000 (13:08 +0200)]
[lldb] [DWARF-5] Be lazier about loading .dwo files

This change makes sure that DwarfUnit does not load a .dwo file until
necessary. I also take advantage of DWARF 5's guarantee that the first
support file is also the primary file to make it possible to create
a compile unit without loading the .dwo file.

Review By: jankratochvil, dblaikie

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

3 years agotsan: fix another latent race size bug in test
Dmitry Vyukov [Fri, 30 Jul 2021 10:42:35 +0000 (12:42 +0200)]
tsan: fix another latent race size bug in test

The test contains a race in memset.
The size of reported race depends on how the accessed
memory range split into granules inside of tsan runtime.
The test used to report access of size 8, because presumably
the buffer ended up being aligned to 8 bytes. But after
some unrelated changes this test started to report accesses
of size 1 (presumably .data layout changed), which makes
the test fail.
Guarantee alignment of the buf object explicitly.

Reviewed By: melver

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

3 years agotsan: Support constructor arguments via New
Marco Elver [Fri, 30 Jul 2021 10:22:07 +0000 (12:22 +0200)]
tsan: Support constructor arguments via New

Make New<>() a variadic function template and forward any arguments to
the constructor. std::forward<>() is inlined to avoid including
<utility>.

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

3 years ago[lldb][AArch64] Mark mismatched tags in tag read output
David Spickett [Mon, 12 Apr 2021 10:42:26 +0000 (11:42 +0100)]
[lldb][AArch64] Mark mismatched tags in tag read output

The "memory tag read" command will now tell you
when the allocation tag read does not match the logical
tag.

(lldb) memory tag read mte_buf+(8*16) mte_buf+(8*16)+48
Logical tag: 0x9
Allocation tags:
[0xfffff7ff7080, 0xfffff7ff7090): 0x8 (mismatch)
[0xfffff7ff7090, 0xfffff7ff70a0): 0x9
[0xfffff7ff70a0, 0xfffff7ff70b0): 0xa (mismatch)

The logical tag will be taken from the start address
so the end could have a different tag. You could for example
read from ptr_to_array_1 to ptr_to_array_2. Where the latter
is tagged differently to prevent buffer overflow.

The existing command will read 1 granule if you leave
off the end address. So you can also use it as a quick way
to check a single location.

(lldb) memory tag read mte_buf
Logical tag: 0x9
Allocation tags:
[0xfffff7ff7000, 0xfffff7ff7010): 0x0 (mismatch)

This avoids the need for a seperate "memory tag check" command.

Reviewed By: omjavaid

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

3 years ago[lldb] Correct format of qMemTags type field
David Spickett [Fri, 25 Jun 2021 13:29:12 +0000 (14:29 +0100)]
[lldb] Correct format of qMemTags type field

The type field is a signed integer.
(https://sourceware.org/gdb/current/onlinedocs/gdb/General-Query-Packets.html)

However it's not packed in the packet in the way
you might think. For example the type -1 should be:
qMemTags:<addr>,<len>:ffffffff
Instead of:
qMemTags:<addr>,<len>:-1

This change makes lldb-server's parsing more strict
and adds more tests to check that we handle negative types
correctly in lldb and lldb-server.

We only support one tag type value at this point,
for AArch64 MTE, which is positive. So this doesn't change
any of those interactions. It just brings us in line with GDB.

Also check that the test target has MTE. Previously
we just checked that we were AArch64 with a toolchain
that supports MTE.

Finally, update the tag type check for QMemTags to use
the same conversion steps that qMemTags now does.
Using static_cast can invoke UB and though we do do a limit
check to avoid this, I think it's clearer with the new method.

Reviewed By: omjavaid

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

3 years ago[mlir][affine-loop-fusion] Fix a bug that AffineIfOp prevents fusion of the other...
Tung D. Le [Fri, 30 Jul 2021 09:52:21 +0000 (15:22 +0530)]
[mlir][affine-loop-fusion] Fix a bug that AffineIfOp prevents fusion of the other loops

The presence of AffineIfOp inside AffineFor prevents fusion of the other loops to happen. For example:

```
  affine.for %i0 = 0 to 10 {
    affine.store %cf7, %a[%i0] : memref<10xf32>
  }
  affine.for %i1 = 0 to 10 {
    %v0 = affine.load %a[%i1] : memref<10xf32>
    affine.store %v0, %b[%i1] : memref<10xf32>
  }
  affine.for %i2 = 0 to 10 {
    affine.if #set(%i2) {
      %v0 = affine.load %b[%i2] : memref<10xf32>
    }
  }
```

The first two loops were not be fused because of `affine.if` inside the last `affine.for`.

The issue seems to come from a conservative constraint that does not allow fusion if there are ops whose number of regions != 0 (affine.if is one of them).

This patch just removes such a constraint when`affine.if` is inside `affine.for`.  The existing `canFuseLoops` method is able to handle `affine.if` correctly.

Reviewed By: bondhugula, vinayaka-polymage

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

3 years agotsan: introduce New/Alloc/Free helpers
Dmitry Vyukov [Thu, 29 Jul 2021 16:14:22 +0000 (18:14 +0200)]
tsan: introduce New/Alloc/Free helpers

We frequenty allocate sizeof(T) memory and call T ctor on that memory
(C++ new keyword effectively). Currently it's quite verbose and
usually takes 2 lines of code.
Add New<T>() helper that does it much more concisely.

Rename internal_free to Free that also sets the pointer to nullptr.
Shorter and safer.

Rename internal_alloc to Alloc, just shorter.

Reviewed By: vitalybuka, melver

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

3 years ago[mlir][spirv] Fix crash in convert-gpu-to-spirv pass with memrefs with affine maps
Butygin [Wed, 28 Jul 2021 19:31:26 +0000 (22:31 +0300)]
[mlir][spirv] Fix crash in convert-gpu-to-spirv pass with memrefs with affine maps

spirv::getElementPtr can return null (for memrefs with affine map) but patterns didn't handle this.

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

3 years ago[clang] SIGSEGV at DeduceTemplateArgumentsByTypeMatch
Ivan Murashko [Fri, 30 Jul 2021 06:20:38 +0000 (09:20 +0300)]
[clang] SIGSEGV at DeduceTemplateArgumentsByTypeMatch

There is a SIGSEGV at `DeduceTemplateArgumentsByTypeMatch`. The bug [#51171](https://bugs.llvm.org/show_bug.cgi?id=51171) was filled. The reproducer can be found at the bug description.

LIT test for the issue was added:
```
./bin/llvm-lit -v ../clang/test/SemaCXX/pr51171-crash.cpp
```

The debug stack trace is below:
```
 #0 0x00000000055afcb9 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /home/ivanmurashko/local/llvm-project/llvm/lib/Support/Unix/Signals.inc:565:22
 #1 0x00000000055afd70 PrintStackTraceSignalHandler(void*) /home/ivanmurashko/local/llvm-project/llvm/lib/Support/Unix/Signals.inc:632:1
 #2 0x00000000055add2d llvm::sys::RunSignalHandlers() /home/ivanmurashko/local/llvm-project/llvm/lib/Support/Signals.cpp:97:20
 #3 0x00000000055af701 SignalHandler(int) /home/ivanmurashko/local/llvm-project/llvm/lib/Support/Unix/Signals.inc:407:1
 #4 0x00007ffff7bc2b20 __restore_rt sigaction.c:0:0
 #5 0x00007ffff66a337f raise (/lib64/libc.so.6+0x3737f)
 #6 0x00007ffff668ddb5 abort (/lib64/libc.so.6+0x21db5)
 #7 0x00007ffff668dc89 _nl_load_domain.cold.0 loadmsgcat.c:0:0
 #8 0x00007ffff669ba76 .annobin___GI___assert_fail.end assert.c:0:0
 #9 0x000000000594b210 clang::QualType::getCommonPtr() const /home/ivanmurashko/local/llvm-project/clang/include/clang/AST/Type.h:684:5
#10 0x0000000005a12ca6 clang::QualType::getCanonicalType() const /home/ivanmurashko/local/llvm-project/clang/include/clang/AST/Type.h:6467:36
#11 0x0000000005a137a6 clang::ASTContext::getCanonicalType(clang::QualType) const /home/ivanmurashko/local/llvm-project/clang/include/clang/AST/ASTContext.h:2433:58
#12 0x0000000009204584 DeduceTemplateArgumentsByTypeMatch(clang::Sema&, clang::TemplateParameterList*, clang::QualType, clang::QualType, clang::sema::TemplateDeductionInfo&, llvm::SmallVectorImpl<clang::DeducedTemplateArgument>&, unsigned int, bool, bool) /home/ivanmurashko/local/llvm-project/clang/lib/Sema/SemaTemplateDeduction.cpp:1355:54
#13 0x000000000920df0d clang::Sema::DeduceTemplateArguments(clang::FunctionTemplateDecl*, clang::TemplateArgumentListInfo*, clang::QualType, clang::FunctionDecl*&, clang::sema::TemplateDeductionInfo&, bool) /home/ivanmurashko/local/llvm-project/clang/lib/Sema/SemaTemplateDeduction.cpp:4354:47
#14 0x0000000009012b09 (anonymous namespace)::AddressOfFunctionResolver::AddMatchingTemplateFunction(clang::FunctionTemplateDecl*, clang::DeclAccessPair const&) /home/ivanmurashko/local/llvm-project/clang/lib/Sema/SemaOverload.cpp:12026:38
#15 0x0000000009013030 (anonymous namespace)::AddressOfFunctionResolver::FindAllFunctionsThatMatchTargetTypeExactly() /home/ivanmurashko/local/llvm-project/clang/lib/Sema/SemaOverload.cpp:12119:9
#16 0x0000000009012679 (anonymous namespace)::AddressOfFunctionResolver::AddressOfFunctionResolver(clang::Sema&, clang::Expr*, clang::QualType const&, bool) /home/ivanmurashko/local/llvm-project/clang/lib/Sema/SemaOverload.cpp:11931:5
#17 0x0000000009013c91 clang::Sema::ResolveAddressOfOverloadedFunction(clang::Expr*, clang::QualType, bool, clang::DeclAccessPair&, bool*) /home/ivanmurashko/local/llvm-project/clang/lib/Sema/SemaOverload.cpp:12286:42
#18 0x0000000008fed85d IsStandardConversion(clang::Sema&, clang::Expr*, clang::QualType, bool, clang::StandardConversionSequence&, bool, bool) /home/ivanmurashko/local/llvm-project/clang/lib/Sema/SemaOverload.cpp:1712:49
#19 0x0000000008fec8ea TryImplicitConversion(clang::Sema&, clang::Expr*, clang::QualType, bool, clang::Sema::AllowedExplicit, bool, bool, bool, bool) /home/ivanmurashko/local/llvm-project/clang/lib/Sema/SemaOverload.cpp:1433:27
#20 0x0000000008ff90ba TryCopyInitialization(clang::Sema&, clang::Expr*, clang::QualType, bool, bool, bool, bool) /home/ivanmurashko/local/llvm-project/clang/lib/Sema/SemaOverload.cpp:5273:71
#21 0x00000000090024fb clang::Sema::AddBuiltinCandidate(clang::QualType*, llvm::ArrayRef<clang::Expr*>, clang::OverloadCandidateSet&, bool, unsigned int) /home/ivanmurashko/local/llvm-project/clang/lib/Sema/SemaOverload.cpp:7755:32
#22 0x000000000900513f (anonymous namespace)::BuiltinOperatorOverloadBuilder::addGenericBinaryArithmeticOverloads() /home/ivanmurashko/local/llvm-project/clang/lib/Sema/SemaOverload.cpp:8633:30
#23 0x0000000009007624 clang::Sema::AddBuiltinOperatorCandidates(clang::OverloadedOperatorKind, clang::SourceLocation, llvm::ArrayRef<clang::Expr*>, clang::OverloadCandidateSet&) /home/ivanmurashko/local/llvm-project/clang/lib/Sema/SemaOverload.cpp:9205:51
#24 0x0000000009018734 clang::Sema::LookupOverloadedBinOp(clang::OverloadCandidateSet&, clang::OverloadedOperatorKind, clang::UnresolvedSetImpl const&, llvm::ArrayRef<clang::Expr*>, bool) /home/ivanmurashko/local/llvm-project/clang/lib/Sema/SemaOverload.cpp:13469:1
#25 0x0000000009018d56 clang::Sema::CreateOverloadedBinOp(clang::SourceLocation, clang::BinaryOperatorKind, clang::UnresolvedSetImpl const&, clang::Expr*, clang::Expr*, bool, bool, clang::FunctionDecl*) /home/ivanmurashko/local/llvm-project/clang/lib/Sema/SemaOverload.cpp:13568:24
#26 0x0000000008b24797 BuildOverloadedBinOp(clang::Sema&, clang::Scope*, clang::SourceLocation, clang::BinaryOperatorKind, clang::Expr*, clang::Expr*) /home/ivanmurashko/local/llvm-project/clang/lib/Sema/SemaExpr.cpp:14606:65
#27 0x0000000008b24ed5 clang::Sema::BuildBinOp(clang::Scope*, clang::SourceLocation, clang::BinaryOperatorKind, clang::Expr*, clang::Expr*) /home/ivanmurashko/local/llvm-project/clang/lib/Sema/SemaExpr.cpp:14691:73
#28 0x0000000008b245d4 clang::Sema::ActOnBinOp(clang::Scope*, clang::SourceLocation, clang::tok::TokenKind, clang::Expr*, clang::Expr*) /home/ivanmurashko/local/llvm-project/clang/lib/Sema/SemaExpr.cpp:14566:1
#29 0x00000000085bfafb clang::Parser::ParseRHSOfBinaryExpression(clang::ActionResult<clang::Expr*, true>, clang::prec::Level) /home/ivanmurashko/local/llvm-project/clang/lib/Parse/ParseExpr.cpp:630:71
#30 0x00000000085bd922 clang::Parser::ParseAssignmentExpression(clang::Parser::TypeCastState) /home/ivanmurashko/local/llvm-project/clang/lib/Parse/ParseExpr.cpp:177:1
#31 0x00000000085cbbcd clang::Parser::ParseExpressionList(llvm::SmallVectorImpl<clang::Expr*>&, llvm::SmallVectorImpl<clang::SourceLocation>&, llvm::function_ref<void ()>) /home/ivanmurashko/local/llvm-project/clang/lib/Parse/ParseExpr.cpp:3368:40
#32 0x000000000857f49c clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::ForRangeInit*) /home/ivanmurashko/local/llvm-project/clang/lib/Parse/ParseDecl.cpp:2416:5
#33 0x000000000857df16 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::SourceLocation*, clang::Parser::ForRangeInit*) /home/ivanmurashko/local/llvm-project/clang/lib/Parse/ParseDecl.cpp:2092:65
#34 0x000000000855f07b clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributesWithRange&, clang::ParsingDeclSpec&, clang::AccessSpecifier) /home/ivanmurashko/local/llvm-project/clang/lib/Parse/Parser.cpp:1138:1
#35 0x000000000855f136 clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributesWithRange&, clang::ParsingDeclSpec*, clang::AccessSpecifier) /home/ivanmurashko/local/llvm-project/clang/lib/Parse/Parser.cpp:1153:57
#36 0x000000000855e644 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributesWithRange&, clang::ParsingDeclSpec*) /home/ivanmurashko/local/llvm-project/clang/lib/Parse/Parser.cpp:975:58
#37 0x000000000855d717 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, bool) /home/ivanmurashko/local/llvm-project/clang/lib/Parse/Parser.cpp:720:42
#38 0x0000000008558e01 clang::ParseAST(clang::Sema&, bool, bool) /home/ivanmurashko/local/llvm-project/clang/lib/Parse/ParseAST.cpp:158:37
#39 0x000000000627a221 clang::ASTFrontendAction::ExecuteAction() /home/ivanmurashko/local/llvm-project/clang/lib/Frontend/FrontendAction.cpp:1058:11
#40 0x0000000006bdcc31 clang::CodeGenAction::ExecuteAction() /home/ivanmurashko/local/llvm-project/clang/lib/CodeGen/CodeGenAction.cpp:1045:5
#41 0x0000000006279b4d clang::FrontendAction::Execute() /home/ivanmurashko/local/llvm-project/clang/lib/Frontend/FrontendAction.cpp:955:38
#42 0x00000000061c3fe9 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) /home/ivanmurashko/local/llvm-project/clang/lib/Frontend/CompilerInstance.cpp:974:42
#43 0x00000000063f9c5e clang::ExecuteCompilerInvocation(clang::CompilerInstance*) /home/ivanmurashko/local/llvm-project/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:278:38
#44 0x0000000002603a03 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) /home/ivanmurashko/local/llvm-project/clang/tools/driver/cc1_main.cpp:246:40
#45 0x00000000025f8a39 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&) /home/ivanmurashko/local/llvm-project/clang/tools/driver/driver.cpp:338:20
#46 0x00000000025f9107 main /home/ivanmurashko/local/llvm-project/clang/tools/driver/driver.cpp:415:26
#47 0x00007ffff668f493 __libc_start_main (/lib64/libc.so.6+0x23493)
#48 0x00000000025f729e _start (/data/users/ivanmurashko/llvm-project/build/bin/clang-13+0x25f729e)
```

Reviewed By: erichkeane

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

3 years agotsan: optimize test-only barrier
Dmitry Vyukov [Fri, 30 Jul 2021 06:35:11 +0000 (08:35 +0200)]
tsan: optimize test-only barrier

The updated lots_of_threads.c test with 300 threads
started running for too long on machines with low
hardware parallelism (e.g. taskset -c 0-1).
On lots of CPUs it finishes in ~2 secs. But with
taskset -c 0-1 it runs for hundreds of seconds
effectively spinning in the barrier in the sleep loop.

We now have the handy futex API in sanitizer_common.
Use it instead of the passive spin loop.
It makes the test run only faster with taskset -c 0-1,
it runs for ~1.5 secs, while with full parallelism
it still runs for ~2 secs (but consumes less CPU time).

Depends on D107131.

Reviewed By: vitalybuka

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

3 years agotsan: fix latent race size bug in test
Dmitry Vyukov [Fri, 30 Jul 2021 06:45:16 +0000 (08:45 +0200)]
tsan: fix latent race size bug in test

The test contains a race in read/write syscalls.
The size of reported race depends on how the accessed
memory range split into granules inside of tsan runtime.
The test used to report access of size 8, because presumably
the buffer ended up being aligned to 8 bytes. But after
some unrelated changes this test started to report accesses
of size 1 (presumably .data layout changed), which makes
the test fail.
Guarantee alignment of the buf object explicitly.

Reviewed By: vitalybuka, melver

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

3 years ago[ARM] Turn vecreduce_add(add(x, y)) into vecreduce(x) + vecreduce(y)
David Green [Fri, 30 Jul 2021 09:10:41 +0000 (10:10 +0100)]
[ARM] Turn vecreduce_add(add(x, y)) into vecreduce(x) + vecreduce(y)

Under MVE we can use VADDV/VADDVA's to perform integer add reductions,
so it can be beneficial to use more reductions than summing subvectors
and reducing once. Especially for VMLAV/VMLAVA the mul can be
incorporated into the reduction, producing less instructions.

Some of the test cases currently get larger due to extra integer adds,
but will be improved in a followup patch.

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

3 years ago[ARM] MVE SLP'd reduction tests. NFC
David Green [Fri, 30 Jul 2021 08:43:29 +0000 (09:43 +0100)]
[ARM] MVE SLP'd reduction tests. NFC

These are generated from SLP vectorization, for example
https://godbolt.org/z/ebxdPh1Kz. These backend tests
show cases that we can produce better code for.

3 years agoRevert "[LLDB][GUI] Expand selected thread tree item by default"
Muhammad Omair Javaid [Thu, 29 Jul 2021 11:15:27 +0000 (16:15 +0500)]
Revert "[LLDB][GUI] Expand selected thread tree item by default"

This reverts commit fed25ddc1c3de59aa1de27e95b349f86896ccb79.

There has been sporadic failures in LLDB AArch64/Arm 32 buildbots since
this commit. I am temporarily reverting it see if it fixes the issue.

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

3 years ago[OpenCL] Add std flag aliases clc++1.0 and CLC++1.0
Anastasia Stulova [Thu, 29 Jul 2021 14:10:13 +0000 (15:10 +0100)]
[OpenCL] Add std flag aliases clc++1.0 and CLC++1.0

Renamed language standard from openclcpp to openclcpp10.
Added new std values i.e. '-cl-std=clc++1.0' and
'-cl-std=CLC++1.0'.

Patch by Topotuna (Justas Janickas)!

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

3 years ago[flang] Fix `flang` (the bash wrapper script for the Flang driver)
Andrzej Warzynski [Fri, 30 Jul 2021 07:59:13 +0000 (08:59 +0100)]
[flang] Fix `flang` (the bash wrapper script for the Flang driver)

Remove erroneous `||` at the end of an `if` condition. This was
introduced in https://reviews.llvm.org/D106871.

3 years ago[AArch64][SME] Introduce feature for streaming mode
Cullen Rhodes [Fri, 30 Jul 2021 07:30:45 +0000 (07:30 +0000)]
[AArch64][SME] Introduce feature for streaming mode

The Scalable Matrix Extension (SME) introduces a new execution mode
called Streaming SVE mode. In streaming mode a substantial subset of the
SVE and SVE2 instruction set is available, along with new outer product,
load, store, extract and insert instructions that operate on the new
architectural register state for the matrix.

To support streaming mode this patch introduces a new subtarget feature
+streaming-sve. If enabled, the subset of SVE(2) instructions are
available. The existing behaviour for SVE(2) remains unchanged, the
subset of instructions that are legal in streaming mode are enabled if
either +sve[2] or +streaming-sve is specified. Instructions that are
illegal in streaming mode remain predicated on +sve[2].

The SME target feature has been updated to imply +streaming-sve rather
than +sve.

The following changes are made to the SVE(2) tests:
  * For instructions that are legal in streaming mode:
    - added RUN line to verify +streaming-sve enables the instruction.
    - updated diagnostic to 'instruction requires: streaming-sve or sve'.
  * For instructions that are illegal in streaming-mode:
    - added RUN line to verify +streaming-sve does not enable the
      instruction.

SVE(2) instructions that are legal in streaming mode have:

  if !HaveSVE[2]() && !HaveSME() then UNDEFINED;

at the top of the pseudocode in the XML.

The reference can be found here:
https://developer.arm.com/documentation/ddi0602/2021-06/SVE-Instructions

Reviewed By: sdesmalen, david-arm

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

3 years ago[JITLink][ELF][x86-64] Include relocation name in missing relocation errors.
Lang Hames [Fri, 30 Jul 2021 04:26:07 +0000 (14:26 +1000)]
[JITLink][ELF][x86-64] Include relocation name in missing relocation errors.

This saves a level of manual table lookup for those of us who don't remember
ELF relocation numbers off the top of our heads.

3 years agoTake OptimizationLevel class out of Pass Builder
Tarindu Jayatilaka [Fri, 30 Jul 2021 04:42:05 +0000 (21:42 -0700)]
Take OptimizationLevel class out of Pass Builder

Pulled out the OptimizationLevel class from PassBuilder in order to be able to access it from within the PassManager and avoid include conflicts.

Reviewed By: mtrofin

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

3 years ago[OpenCL] opencl-c.h: add CL 3.0 non-generic address space atomics
Dave Airlie [Fri, 30 Jul 2021 04:46:47 +0000 (14:46 +1000)]
[OpenCL] opencl-c.h: add CL 3.0 non-generic address space atomics

CL 2.0 introduced atomics and generic address space so there were
only one set of APIs for doing atomics, however since CL 3.0
makes generic address space optional, there has to be new sets
of atomic interfaces to handle that cases.

Reviewed By: Anastasia

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

3 years agoFix scalar unit tests for all, any, maxloc, etc. that caused the ARM build
Mark Leair [Fri, 30 Jul 2021 04:13:46 +0000 (21:13 -0700)]
Fix scalar unit tests for all, any, maxloc, etc. that caused the ARM build
to fail due to warnings as errors. Note that I could not reproduce the
problem locally, but based on the messages, I think this change will fix
the errors.

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

3 years agoRevert "[OpenCL] Add support of __opencl_c_pipes feature macro."
Anton Zabaznov [Fri, 30 Jul 2021 03:34:17 +0000 (06:34 +0300)]
Revert "[OpenCL] Add support of __opencl_c_pipes feature macro."

This reverts commit d1e4b25756730576996457ba7324e9bf210e3693.

3 years ago[OpenCL] Add support of __opencl_c_pipes feature macro.
Anton Zabaznov [Fri, 30 Jul 2021 01:56:21 +0000 (04:56 +0300)]
[OpenCL] Add support of __opencl_c_pipes feature macro.

'pipe' keyword is introduced in OpenCL C 2.0: so do checks for OpenCL C version while
parsing and then later on check for language options to construct actual pipe. This feature
requires support of __opencl_c_generic_address_space, so diagnostics for that is provided as well.

Reviewed By: Anastasia

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

3 years ago[PowerPC] Fix issue where hint was providing the incorrect regsiter class.
Stefan Pintilie [Thu, 29 Jul 2021 20:06:13 +0000 (15:06 -0500)]
[PowerPC] Fix issue where hint was providing the incorrect regsiter class.

Regsier hints when copying to a UACC register do not always produce VSRp
registers. This patch makes sure that we do not produce hints in cases
where the subregsiter of the UACC is not a VSRp.

Reviewed By: nemanjai, #powerpc

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

3 years ago[yaml2obj] Enable support for parsing 64-bit XCOFF.
Esme-Yi [Fri, 30 Jul 2021 02:06:04 +0000 (02:06 +0000)]
[yaml2obj] Enable support for parsing 64-bit XCOFF.

Summary: Add support for yaml2obj to parse 64-bit XCOFF.

Reviewed By: shchenz

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

3 years ago[nfc][trace] use formatv instead of the old Printf
Walter Erquinigo [Fri, 30 Jul 2021 02:04:27 +0000 (19:04 -0700)]
[nfc][trace] use formatv instead of the old Printf

It was suggested in https://reviews.llvm.org/D105741 and it makes sense.

3 years ago[OpenCL] Add support of __opencl_c_3d_image_writes feature macro
Anton Zabaznov [Fri, 30 Jul 2021 01:19:17 +0000 (04:19 +0300)]
[OpenCL] Add support of __opencl_c_3d_image_writes feature macro

This feature requires support of __opencl_c_images, so diagnostics for that is provided as well.
Also, ensure that cl_khr_3d_image_writes feature macro is set to the same value.

Reviewed By: Anastasia

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

3 years agotsan: Fix the improper argument type in tsan_ilist_test.cpp
Victor Huang [Fri, 30 Jul 2021 01:44:01 +0000 (20:44 -0500)]
tsan: Fix the improper argument type in tsan_ilist_test.cpp

- clang-ppc64le-rhel bot LIT failure: https://lab.llvm.org/buildbot/#/builders/57/builds/8932
- culprit change: https://reviews.llvm.org/D107050

3 years ago[AIX] Include symbol alias in extract_symbols.py
Jinsong Ji [Fri, 30 Jul 2021 01:16:48 +0000 (01:16 +0000)]
[AIX] Include symbol alias in extract_symbols.py

nm does not show size for aliased symbols,
we should still extract them if they are external.

Reviewed By: hubert.reinterpretcast

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

3 years ago[source map] fix relative path breakpoints
Walter Erquinigo [Fri, 30 Jul 2021 01:14:34 +0000 (18:14 -0700)]
[source map] fix relative path breakpoints

https://reviews.llvm.org/D45592 added a nice feature to be able to specify a breakpoint by a relative path. E.g. passing foo.cpp or bar/foo.cpp or zaz/bar/foo.cpp is fine. However, https://reviews.llvm.org/D68671 by mistake disabled the test that ensured this functionality works. With time, someone made a small mistake and fully broke the functionality.

So, I'm making a very simple fix and the test passes.

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

3 years ago[Bazel] Make td_library usable as data
Geoffrey Martin-Noble [Wed, 28 Jul 2021 00:01:19 +0000 (17:01 -0700)]
[Bazel] Make td_library usable as data

This patch makes it possible to list a td_library as a rule's data
attribute and get its source files and all its transitive dependencies
at runtime. This is useful for, e.g. shell tests running tblgen.

Note that this is a bit different from how a "normal" (e.g. C++) library
rule would work because those have actual library outputs and the
td_library rule just bundles some source files and includes. If someone
wanted to make use of the includes, they would have to access the TdInfo
provider, but this keeps simple things simple.

Reviewed By: jpienaar

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

3 years ago[Bazel] Unconditionally define STDC LIMIT/CONSTANT/FORMAT
Geoffrey Martin-Noble [Fri, 30 Jul 2021 00:41:43 +0000 (17:41 -0700)]
[Bazel] Unconditionally define STDC LIMIT/CONSTANT/FORMAT

These are unconditionally included in the CMake build as well and
necessary for some odd platforms (even though the C++11 standard says
they shouldn't be).

Reviewed By: chandlerc

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

3 years ago[Bazel] Derive targets from file presence as in CMake build
Geoffrey Martin-Noble [Thu, 29 Jul 2021 01:39:51 +0000 (18:39 -0700)]
[Bazel] Derive targets from file presence as in CMake build

This makes the logic used to determine if targets have the given
features the same as is used in CMake. Incidentally, it enables these
features for the targets added in https://reviews.llvm.org/D106921
which were missing because this was previously a hardcoded list.

Reviewed By: chandlerc

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

3 years ago[ARC] Add norm/normh instructions with disassembly tests
Mark Schimmel [Fri, 30 Jul 2021 00:51:47 +0000 (17:51 -0700)]
[ARC] Add norm/normh instructions with disassembly tests
Add disassembler support for the NORM and NORMH instructions. These instructions
only exist when the ARC processor is configured with the "norm" extension.

fferential Revision: https://reviews.llvm.org/D107118

3 years ago[MLIR][python] Disable SONAME on extensions.
Stella Laurenzo [Thu, 29 Jul 2021 22:23:32 +0000 (22:23 +0000)]
[MLIR][python] Disable SONAME on extensions.

* Broken out of https://reviews.llvm.org/D106419
* Otherwise, same named modules will conflict with each other.

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

3 years agoOptimize mul in the zba extension with SH*ADD
Ben Shi [Thu, 29 Jul 2021 12:39:54 +0000 (20:39 +0800)]
Optimize mul in the zba extension with SH*ADD

This patch does the following optimization of mul with a constant.

(mul x, 11) -> (SH1ADD (SH2ADD x, x), x)
(mul x, 19) -> (SH1ADD (SH3ADD x, x), x)
(mul x, 13) -> (SH2ADD (SH1ADD x, x), x)
(mul x, 21) -> (SH2ADD (SH2ADD x, x), x)
(mul x, 37) -> (SH2ADD (SH3ADD x, x), x)
(mul x, 25) -> (SH3ADD (SH1ADD x, x), x)
(mul x, 41) -> (SH3ADD (SH2ADD x, x), x)
(mul x, 73) -> (SH3ADD (SH3ADD x, x), x)
(mul x, 27) -> (SH1ADD (SH3ADD x, x), (SH3ADD x, x))
(mul x, 45) -> (SH2ADD (SH3ADD x, x), (SH3ADD x, x))
(mul x, 81) -> (SH3ADD (SH3ADD x, x), (SH3ADD x, x))

Reviewed By: craig.topper

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

3 years ago[RISCV][test] Add new tests for mul optimization in the zba extension with SH*ADD
Ben Shi [Thu, 29 Jul 2021 11:48:09 +0000 (19:48 +0800)]
[RISCV][test] Add new tests for mul optimization in the zba extension with SH*ADD

Reviewed By: craig.topper

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

3 years ago[AVR][clang] Pass '--start-group' and '--end-group' options to avr-ld
Matt Jacobson [Fri, 30 Jul 2021 00:22:53 +0000 (08:22 +0800)]
[AVR][clang] Pass '--start-group' and '--end-group' options to avr-ld

Reviewed By: Ben Shi

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

3 years ago[GlobalISel] Refactor the unmerge artifact value finder code.
Amara Emerson [Fri, 30 Jul 2021 00:07:19 +0000 (17:07 -0700)]
[GlobalISel] Refactor the unmerge artifact value finder code.

I moved the code that tries to combine away each unmerge def into a method in
ArtifactValueFinder class itself. This removes a logically messy lambda and
makes it easier to use the value-finder in more places in future.

3 years ago[compiler-rt] Fix COMPILER_RT_OS_DIR for Android
Shoaib Meenai [Thu, 29 Jul 2021 23:46:38 +0000 (16:46 -0700)]
[compiler-rt] Fix COMPILER_RT_OS_DIR for Android

Android has its own CMAKE_SYSTEM_NAME, but the OS is Linux (Android
target triples look like aarch64-none-linux-android21). The driver will
therefore search for compiler-rt libraries in the "linux" directory and
not the "android" directory, so the default placement of Android
compiler-rt libraries was incorrect. You could fix it by specifying
COMPILER_RT_OS_DIR manually, but it also makes sense to fix the default,
to save others from having to discover and fix the issue for themselves.

3 years ago[ARC] Add additional mov immediate instruction formats with a fix for u6 decoding
Thomas Johnson [Thu, 29 Jul 2021 22:25:48 +0000 (22:25 +0000)]
[ARC] Add additional mov immediate instruction formats with a fix for u6 decoding

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

3 years ago[OpenMP] Adding flags for disabling the following optimizations: Deglobalization...
Joseph Huber [Thu, 29 Jul 2021 19:27:58 +0000 (15:27 -0400)]
[OpenMP] Adding flags for disabling the following optimizations: Deglobalization SPMDization State machine rewrites Folding

This work provides four flags to disable four different sets of OpenMP optimizations. These flags take effect in llvm/lib/Transforms/IPO/OpenMPOpt.cpp and include the following:
 - openmp-opt-disable-deglobalization: Defaults to false, adding this flag sets the variable DisableOpenMPOptDeglobalization to true. This prevents AA registration for HeapToStack and HeapToShared.
 - openmp-opt-disable-spmdization: Defaults to false, adding this flag sets the variable DisableOpenMPOptSPMDization to true. This indicates a pessimistic fixpoint in changeToSPMDMode.
 - openmp-opt-disable-folding: Defaults to false, adding this flag sets the variable DisableOpenMPOptFolding to true. This indicates a pessimistic fixpoint in the attributor init for AAFoldRuntimeCall.
 - openmp-opt-disable-state-machine-rewrite: Defaults to false, adding this flag sets the variable DisableOpenMPOptStateMachineRewrite to true. This first prevents changes to the state machine in rewriteDeviceCodeStateMachine by returning before changes are made, and if a custom state machine is built in buildCustomStateMachine, stops by returning a pessimistic fixpoint.

Reviewed By: jhuber6

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

3 years agoMake testcase more robust against codegen changes
Adrian Prantl [Thu, 29 Jul 2021 23:23:00 +0000 (16:23 -0700)]
Make testcase more robust against codegen changes

3 years agoFix typo
Adrian Prantl [Thu, 29 Jul 2021 23:21:33 +0000 (16:21 -0700)]
Fix typo

3 years ago[InstCombine] add tests for vector cmp-bitcast; NFC
Sanjay Patel [Thu, 29 Jul 2021 21:30:42 +0000 (17:30 -0400)]
[InstCombine] add tests for vector cmp-bitcast; NFC

3 years agoGlobalISel/AArch64: don't optimize away redundant branches at -O0
Adrian Prantl [Wed, 30 Jun 2021 22:40:45 +0000 (15:40 -0700)]
GlobalISel/AArch64: don't optimize away redundant branches at -O0

This patch prevents GlobalISel from optimizing out redundant branch
instructions when compiling without optimizations.

The motivating example is code like the following common pattern in
Swift, where users expect to be able to set a breakpoint on the early
exit:

public func f(b: Bool) {
  guard b else {
    return // I would like to set a breakpoint here.
  }
  ...
}

The patch modifies two places in GlobalISEL: The first one is in
IRTranslator.cpp where the removal of redundant branches is made
conditional on the optimization level. The second one is in
AArch64InstructionSelector.cpp where an -O0 *only* optimization is
being removed.

Disabling these optimizations increases code size at -O0 by
~8%. However, doing so improves debuggability, and debug builds are
the primary reason why developers compile without optimizations. We
thus concluded that this is the right trade-off.

rdar://79515454

This tenatively reapplies the patch without modifications, the LLDB
test that has blocked this from landing previously has since been
modified to hopefully no longer be sensitive to this change.

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

3 years ago[mlir] Set insertion point of vector constant to the top of the vectorized loop body
Amy Zhuang [Thu, 29 Jul 2021 22:39:49 +0000 (15:39 -0700)]
[mlir] Set insertion point of vector constant to the top of the vectorized loop body

When we vectorize a scalar constant, the vector constant is inserted before its
first user if the scalar constant is defined outside the loops to be vectorized.
It is possible that the vector constant does not dominate all its users. To fix
the problem, we find the innermost vectorized loop that encloses that first user
and insert the vector constant at the top of the loop body.

Reviewed By: nicolasvasilache

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

3 years agosecurity: highlight phab accounts; recommend phab for nominations
George Burgess IV [Thu, 29 Jul 2021 22:25:48 +0000 (22:25 +0000)]
security: highlight phab accounts; recommend phab for nominations

This commit contains two mildly separate concepts.

First, sending out reviews for things like this is a bit of a
complicated endeavor, since the reviewer list is relatively long, and I
generally rely on prior CLs in this area to find an authoritative list.
Life's quite a bit easier if phab usernames are readily available on the
doc. So part 1 is making those available.

Second, it seems to me that, at the moment, Phabricator makes the most
sense for membership changes (incl. security group nominations). My
reasoning for this is detailed in the diff, and to some extent in
comment #1 of this bug
<https://bugs.chromium.org/p/llvm/issues/detail?id=12#c1>. This change
adds prose to recommend the use of Phabricator for nominations as a
result.

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

3 years ago[mlir][tosa] Fix tosa.reshape failures due to implicit broadcasting
Rob Suderman [Thu, 29 Jul 2021 21:38:30 +0000 (14:38 -0700)]
[mlir][tosa] Fix tosa.reshape failures due to implicit broadcasting

Make broadcastable needs the output shape to determine whether the operation
includes additional broadcasting. Include some canonicalizations for TOSA
to remove unneeded reshape.

Reviewed By: NatashaKnk

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