platform/upstream/llvm.git
3 years ago[RISCV] Return false from isShuffleMaskLegal except for splats.
Craig Topper [Fri, 12 Mar 2021 00:21:42 +0000 (16:21 -0800)]
[RISCV] Return false from isShuffleMaskLegal except for splats.

We don't support any other shuffles currently.

This changes the bswap/bitreverse tests that check for this in
their expansion code. Previously we expanded a byte swapping
shuffle through memory. Now we're scalarizing and doing bit
operations on scalars to swap bytes.

In the future we can probably use vrgather.vx to do a byte swap
shuffle.

3 years ago[libcxx] adds concept std::copyable
Christopher Di Bella [Fri, 12 Mar 2021 03:30:55 +0000 (19:30 -0800)]
[libcxx] adds concept std::copyable

Implements parts of:
    - P0898R3 Standard Library Concepts
    - P1754 Rename concepts to standard_case for C++20, while we still can

Depends on D97359

Reviewed By: EricWF, #libc, Quuxplusone, zoecarver

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

3 years ago[libcxx] adds concept std::movable
Christopher Di Bella [Fri, 12 Mar 2021 02:54:57 +0000 (18:54 -0800)]
[libcxx] adds concept std::movable

Implements parts of:
    - P0898R3 Standard Library Concepts
    - P1754 Rename concepts to standard_case for C++20, while we still can

Depends on D97162

Reviewed By: EricWF, #libc, Quuxplusone

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

3 years agoBPF: provide better error message for unsupported atomic operations
Yonghong Song [Thu, 11 Mar 2021 20:28:04 +0000 (12:28 -0800)]
BPF: provide better error message for unsupported atomic operations

Currently, BPF backend does not support all variants of
  atomic_load_{add,and,or,xor}, atomic_swap and atomic_cmp_swap
For example, it only supports 32bit (with alu32 mode) and 64bit
operations for atomic_load_{and,or,xor}, atomic_swap and
atomic_cmp_swap. Due to historical reason, atomic_load_add is
always supported with 32bit and 64bit.

If user used an unsupported atomic operation, currently,
codegen selectiondag cannot find bpf support and will issue
a fatal error. This is not user friendly as user may mistakenly
think this is a compiler bug.

This patch added Custom rule for unsupported atomic operations
and will emit better error message during ReplaceNodeResults()
callback. The following is an example output.

  $ cat t.c
  short sync(short *p) {
    return  __sync_val_compare_and_swap (p, 2, 3);
  }
  $ clang -target bpf -O2 -g -c t.c
  t.c:2:11: error: Unsupported atomic operations, please use 64 bit version
    return  __sync_val_compare_and_swap (p, 2, 3);
            ^
  fatal error: error in backend: Cannot select: t19: i64,ch =
    AtomicCmpSwap<(load store seq_cst seq_cst 2 on %ir.p)> t0, t2,
    Constant:i64<2>, Constant:i64<3>, t.c:2:11
    t2: i64,ch = CopyFromReg t0, Register:i64 %0
      t1: i64 = Register %0
    t11: i64 = Constant<2>
    t10: i64 = Constant<3>
  In function: sync
  PLEASE submit a bug report ...

Fatal error will still happen since we did not really do proper
lowering for these unsupported atomic operations. But we do get
a much better error message.

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

3 years agoRevert "[compiler-rt][asan] Make wild-pointer crash error more useful"
Vy Nguyen [Fri, 12 Mar 2021 03:06:37 +0000 (22:06 -0500)]
Revert "[compiler-rt][asan] Make wild-pointer crash error more useful"

This reverts commit f65e1aee4004c25fbeacd5024de1d17f0a7ebc5c.

3 years ago[libFuzzer] Add attribute noinline on Fuzzer::ExecuteCallback().
Jonas Paulsson [Thu, 4 Mar 2021 20:55:41 +0000 (14:55 -0600)]
[libFuzzer] Add attribute noinline on Fuzzer::ExecuteCallback().

The inlining of this function needs to be disabled as it is part of the
inpsected stack traces. It's string representation will look different
depending on if it was inlined or not which will cause it's string comparison
to fail.

When it was inlined in only one of the two execution stacks,
minimize_two_crashes.test failed on SystemZ. For details see
https://bugs.llvm.org/show_bug.cgi?id=49152.

Reviewers: Ulrich Weigand, Matt Morehouse, Arthur Eubanks

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

3 years ago[AMDGPU] Do not annotate an else branch if there is a kill
Carl Ritson [Fri, 12 Mar 2021 01:02:06 +0000 (10:02 +0900)]
[AMDGPU] Do not annotate an else branch if there is a kill

As llvm.amdgcn.kill is lowered to a terminator it can cause
else branch annotations to end up in the wrong block.
Do not annotate conditionals as else branches where there is
a kill to avoid this.

Reviewed By: arsenm

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

3 years ago[compiler-rt][asan] Make wild-pointer crash error more useful
Vy Nguyen [Tue, 9 Mar 2021 19:54:42 +0000 (14:54 -0500)]
[compiler-rt][asan] Make wild-pointer crash error more useful

Right now, when you have an invalid memory address, asan would just crash and does not offer much useful info.
This patch attempted to give a bit more detail on the access.

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

3 years agoRevert "[NPM][CGSCC] FunctionAnalysisManagerCGSCCProxy: do not clear immutable functi...
Mircea Trofin [Fri, 12 Mar 2021 02:29:01 +0000 (18:29 -0800)]
Revert "[NPM][CGSCC] FunctionAnalysisManagerCGSCCProxy: do not clear immutable function passes"

This reverts commit 5eaeb0fa67e57391f5584a3f67fdb131e93afda6.

It appears there are analyses that assume clearing - example:
https://lab.llvm.org/buildbot#builders/36/builds/5964

3 years ago[compiler-rt] PR#39514 Support versioned llvm-symbolizer binaries
Andrzej Hunt [Fri, 12 Mar 2021 02:11:56 +0000 (18:11 -0800)]
[compiler-rt] PR#39514 Support versioned llvm-symbolizer binaries

Some linux distributions produce versioned llvm-symbolizer binaries,
e.g. my llvm-11 installation puts the symbolizer binary at
/usr/bin/llvm-symbolizer-11.0.0 . However if you then try to run
a binary containing ASAN with
ASAN_SYMBOLIZER_PATH=..../llvm-symbolizer-FOO , it will fail on startup
with "isn't a known symbolizer".

Although it is possible to work around this by setting up symlinks,
that's kindof ugly - supporting versioned binaries is a nicer solution.
(There are now multiple stack overflow and blog posts talking about
 this exact issue :) .)

Originally added in:
https://reviews.llvm.org/D8285

Reviewed By: eugenis

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

3 years ago[mlir][Vector] Lowering of transfer_read/write to vector.load/store
Sergei Grechanik [Fri, 12 Mar 2021 02:07:07 +0000 (18:07 -0800)]
[mlir][Vector] Lowering of transfer_read/write to vector.load/store

This patch introduces progressive lowering patterns for rewriting
vector.transfer_read/write to vector.load/store and vector.broadcast
in certain supported cases.

Reviewed By: dcaballe, nicolasvasilache

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

3 years ago[NPM][CGSCC] FunctionAnalysisManagerCGSCCProxy: do not clear immutable function passes
Mircea Trofin [Thu, 11 Mar 2021 18:43:16 +0000 (10:43 -0800)]
[NPM][CGSCC] FunctionAnalysisManagerCGSCCProxy: do not clear immutable function passes

Check with the analysis result by calling invalidate instead of clear on
the analysis manager.

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

3 years agovoid cast to suppress -Wunused-variable in non-asserts build
David Blaikie [Fri, 12 Mar 2021 01:51:31 +0000 (17:51 -0800)]
void cast to suppress -Wunused-variable in non-asserts build

3 years agoMove (llvm-original-di-preservation) test example output into the Inputs directory...
David Blaikie [Fri, 12 Mar 2021 01:35:10 +0000 (17:35 -0800)]
Move (llvm-original-di-preservation) test example output into the Inputs directory (since it's an input to the test execution)

The "Inputs" subdirectory is used for all files read by the test, not
only those used as input to the execution - so even though this file is
used as a golden reference for the output of the test, it's still an
input to the test execution (it is read in the process of executing the
test).

3 years ago[NFC] Test commit. Add empty lines.
Sergei Grechanik [Fri, 12 Mar 2021 00:56:26 +0000 (16:56 -0800)]
[NFC] Test commit. Add empty lines.

3 years ago[RuntimeDyld] Speedup resolution of relocations to external symbols
Maksim Panchenko [Fri, 12 Mar 2021 00:49:12 +0000 (16:49 -0800)]
[RuntimeDyld] Speedup resolution of relocations to external symbols

From what I can tell, the loop inside applyExternalSymbolRelocations()
used to call getSymbolAddress(). After the JITSymbolResolver interface
redesign, the functionality has changed, and the loop should no longer
trigger repopulation of ExternalSymbolRelocations. If that's the case,
there is no need to update the loop iterator manually, and
ExternalSymbolRelocations can be cleared at once. This way, when there
are many external symbols in the program, the function runs much faster.

Reviewed By: lhames

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

3 years ago[asan] disable no-fd test on darwin
Emily Shi [Thu, 11 Mar 2021 21:59:41 +0000 (13:59 -0800)]
[asan] disable no-fd test on darwin

If a log message is triggered between execv and child, this test fails.
In the meantime, disable the test to unblock CI

rdar://74992832

Reviewed By: delcypher

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

3 years ago[AMDGPU] Restrict image_msaa_load to MSAA dimension types
Carl Ritson [Fri, 12 Mar 2021 00:47:08 +0000 (09:47 +0900)]
[AMDGPU] Restrict image_msaa_load to MSAA dimension types

This instruction is only valid on 2D MSAA and 2D MSAA Array
surfaces.  Remove intrinsic support for other dimension types,
and block assembly for unsupported dimensions.

Reviewed By: foad

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

3 years agoReplace use of OperationState with builder::create in GPU Kernel Outlining (NFC)
Mehdi Amini [Fri, 12 Mar 2021 00:12:50 +0000 (00:12 +0000)]
Replace use of OperationState with builder::create in GPU Kernel Outlining (NFC)

OperationState is a low level API that is rarely indicated, the builder
API convenient wrapper is preferred when possible.

3 years ago[AMDGPU] Don't check hasStackObjects() when reserving VGPR
Ruiling Song [Tue, 9 Mar 2021 14:05:21 +0000 (22:05 +0800)]
[AMDGPU] Don't check hasStackObjects() when reserving VGPR

We have amdgpu_gfx functions that have high register pressure. If
we do not reserve VGPR for SGPR spill, we will fall into the path
to spill the SGPR to memory, which does not only have correctness issue,
but also have really bad performance.

I don't know why there is the check for hasStackObjects(), in our case,
we don't have stack objects at the time of finalizeLowering(). So just
remove the check that we always reserve a VGPR for possible SGPR spill
in non-entry functions.

Reviewed by: arsenm

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

3 years ago[AMDGPU] Free reserved VGPR if no SGPR spill
Ruiling Song [Wed, 10 Mar 2021 13:48:22 +0000 (21:48 +0800)]
[AMDGPU] Free reserved VGPR if no SGPR spill

I met some code generation behavior change when I tried to remove
the hasStackObject() check when reserving VGPR for SGPR spill.
For example, the function `callee_no_stack_no_fp_elim_all` in the lit
test file `callee-frame-setup.ll`.
The generated code changed from:
```
  s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
  s_mov_b32 s4, s33
  s_mov_b32 s33, s32
  s_mov_b32 s33, s4
  s_setpc_b64 s[30:31]
```

into something like:
```
  s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
  v_writelane_b32 v63, s33, 0
  s_mov_b32 s33, s32
  v_readlane_b32 s33, v63, 0
  s_setpc_b64 s[30:31]
```

I think we still prefer the old version where only scalar instructions are needed.
The idea here is free the reserved VGPR if no SGPR spills. So we will very likely
to use a free SGPR for fp/sp spill.

Reviewed by: arsenm

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

3 years ago[crt][fuzzer] Fix up various numeric conversions
Aaron Green [Fri, 12 Mar 2021 00:00:53 +0000 (16:00 -0800)]
[crt][fuzzer] Fix up various numeric conversions

Attempting to build a standalone libFuzzer in Fuchsia's default toolchain for the purpose of cross-compiling the unit tests  revealed a number of not-quite-proper type conversions. Fuchsia's toolchain include `-std=c++17` and `-Werror`, among others, leading to many errors like `-Wshorten-64-to-32`, `-Wimplicit-float-conversion`, etc.

Most of these have been addressed by simply making the conversion explicit with a `static_cast`. These typically fell into one of two categories: 1) conversions between types where high precision isn't critical, e.g. the "energy" calculations for `InputInfo`, and 2) conversions where the values will never reach the bits being truncated, e.g. `DftTimeInSeconds` is not going to exceed 136 years.

The major exception to this is the number of features: there are several places that treat features as `size_t`, and others as `uint32_t`. This change makes the decision to cap the features at 32 bits. The maximum value of a feature as produced by `TracePC::CollectFeatures` is roughly:
  (NumPCsInPCTables + ValueBitMap::kMapSizeInBits + ExtraCountersBegin() - ExtraCountersEnd() + log2(SIZE_MAX)) * 8

It's conceivable for extremely large targets and/or extra counters that this limit could be reached. This shouldn't break fuzzing, but it will cause certain features to collide and lower the fuzzers overall precision. To address this, this change adds a warning to TracePC::PrintModuleInfo about excessive feature size if it is detected, and recommends refactoring the fuzzer into several smaller ones.

Reviewed By: morehouse

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

3 years ago[RISCV] Add test cases for fixed vector bitreverse, bswap, ctlz, cttz, and ctpop.
Craig Topper [Thu, 11 Mar 2021 23:42:04 +0000 (15:42 -0800)]
[RISCV] Add test cases for fixed vector bitreverse, bswap, ctlz, cttz, and ctpop.

Codegen needs to be improved, but I wanted to check for crashes.

3 years agoFix use of deprecated IRBuilder::CreateLoad in Kaleidoscope
David Blaikie [Thu, 11 Mar 2021 23:42:54 +0000 (15:42 -0800)]
Fix use of deprecated IRBuilder::CreateLoad in Kaleidoscope

3 years agoReland: [mlir][Affine][Vector] Add initial support for 'iter_args' to Affine vectorizer.
Diego Caballero [Wed, 10 Mar 2021 18:39:39 +0000 (20:39 +0200)]
Reland: [mlir][Affine][Vector] Add initial support for 'iter_args' to Affine vectorizer.

This patch adds support for vectorizing loops with 'iter_args' when those loops
are not a vector dimension. This allows vectorizing outer loops with an inner
'iter_args' loop (e.g., reductions). Vectorizing scenarios where 'iter_args'
loops are vector dimensions would require more work (e.g., analysis,
generating horizontal reduction, etc.) not included in this patch.

Reviewed By: nicolasvasilache

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

3 years ago[PDB] Improve warning for corrupt debug info
Reid Kleckner [Thu, 11 Mar 2021 21:53:14 +0000 (13:53 -0800)]
[PDB] Improve warning for corrupt debug info

The S_[GL]PROC32_ID symbol records are supposed to point to function ID
records. If they don't, they are corrupt. The warning message here was
very technical, but a user has encountered it in the wild. Add some more
information and some more testing.

3 years ago[Matrix] Add support for matrix-by-scalar division.
Florian Hahn [Thu, 11 Mar 2021 21:54:52 +0000 (21:54 +0000)]
[Matrix] Add support for matrix-by-scalar division.

This patch extends the matrix spec to allow matrix-by-scalar division.

Originally support for `/` was left out to avoid ambiguity for the
matrix-matrix version of `/`, which could either be elementwise or
specified as matrix multiplication M1 * (1/M2).

For the matrix-scalar version, no ambiguity exists; `*` is also
an elementwise operation in that case. Matrix-by-scalar division
is commonly supported by systems including Matlab, Mathematica
or NumPy.

Reviewed By: rjmccall

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

3 years agoReland: [mlir][Vector][Affine] Improve affine vectorizer algorithm
Diego Caballero [Wed, 10 Mar 2021 18:11:16 +0000 (20:11 +0200)]
Reland: [mlir][Vector][Affine] Improve affine vectorizer algorithm

This patch replaces the root-terminal vectorization approach implemented in the
Affine vectorizer with a topological order approach that vectorizes all the
operations within the target loop nest. These are the most important changes
introduced by the new algorithm:
  * Removed tracking of root and terminal ops. Existing vectorization
    functionality is preserved and extended so that loop nests without
    root-terminal chains can be vectorized.
  * Vectorizing a loop nest now only requires a single topological traversal.
  * A new vector loop nest is incrementally built along the vectorization
    process. The original scalar loop is kept intact. No cloning guard is needed
    to recover the scalar loop if vectorization fails. This approach also
    simplifies the challenging task of replacing a loop operation amid the
    vectorization process without invalidating the analysis information that
    depends on the original loop.
  * Vectorization of specific operations has been implemented as independent,
    preparing them to be moved to a potential vectorization interface.

Reviewed By: nicolasvasilache

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

3 years ago[AMDGPU] Remove dead MTBUF patterns
Stanislav Mekhanoshin [Thu, 11 Mar 2021 21:54:19 +0000 (13:54 -0800)]
[AMDGPU] Remove dead MTBUF patterns

These patterns are obviously dead, they are using format
operand which is not selected and we have no corresponding
SelectMUBUF() function.

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

3 years ago[dfsan] Disable testing origin tracking on non x86_64 arch
Jianzhou Zhao [Thu, 11 Mar 2021 20:02:58 +0000 (20:02 +0000)]
[dfsan] Disable testing origin tracking on non x86_64 arch

Fix test cases related to https://reviews.llvm.org/D95835.

3 years ago[compiler-rt] Partially revert 8bd2722f65cfd7883ed9769f7bad3ff50e4c6905
Martin Storsjö [Thu, 11 Mar 2021 20:35:20 +0000 (22:35 +0200)]
[compiler-rt] Partially revert 8bd2722f65cfd7883ed9769f7bad3ff50e4c6905

Don't normalize arm architecture names; doing that loses the ability
to pick the right implementation of builtins for each architecture
variant. When building compiler-rt builtins as part of a
runtimes build, builtins for multiple armv* variants could be built
in the same directory, and with the simplified architecture name,
they'd all be built in the same directory, overlapping each other.

3 years ago[Attributor] Don't access pointer elem type in constructPointer (NFC)
Nikita Popov [Thu, 11 Mar 2021 20:31:46 +0000 (21:31 +0100)]
[Attributor] Don't access pointer elem type in constructPointer (NFC)

Splitting this out as the change is non-trivial: The way this code
handled pointer types doesn't really make sense, as GEPs can only
apply an offset to the outermost pointer, but can't drill down
into interior pointer types (which would require dereferencing
memory).

Instead give special treatment to the first (pointer) index.
I've hardcoded it to zero as that's the only way the function is
used right now, but handling non-zero indexes would be
straightforward.

The original goal here was to have an element type for CreateGEP.

3 years ago[InstrProfiling] Generate runtime hook for ELF platforms
Petr Hosek [Fri, 5 Mar 2021 09:17:42 +0000 (01:17 -0800)]
[InstrProfiling] Generate runtime hook for ELF platforms

When using -fprofile-list to selectively apply instrumentation only
to certain files or functions, we may end up with a binary that doesn't
have any counters in the case where no files were selected. However,
because on Linux and Fuchsia, we pass -u__llvm_profile_runtime, the
runtime would still be pulled in and incur some non-trivial overhead,
especially in the case when the continuous or runtime counter relocation
mode is being used. A better way would be to pull in the profile runtime
only when needed by declaring the __llvm_profile_runtime symbol in the
translation unit only when needed.

This approach was already used prior to 9a041a75221ca, but we changed it
to always generate the __llvm_profile_runtime due to a TAPI limitation.
Since TAPI is only used on Mach-O platforms, we could use the early
emission of __llvm_profile_runtime there, and on other platforms we
could change back to the earlier approach where the symbol is generated
later only when needed. We can stop passing -u__llvm_profile_runtime to
the linker on Linux and Fuchsia since the generated undefined symbol in
each translation unit that needed it serves the same purpose.

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

3 years agoTest commit
Weiwei Li [Thu, 11 Mar 2021 20:03:25 +0000 (15:03 -0500)]
Test commit

3 years ago[SLP] Fix crash when matching associative reduction for integer min/max.
Valery N Dmitriev [Thu, 11 Mar 2021 19:16:29 +0000 (11:16 -0800)]
[SLP] Fix crash when matching associative reduction for integer min/max.

Associative reduction matcher in SLP begins with select instruction but when
it reached call to llvm.umax (or alike) via def-use chain the latter also matched
as UMax kind. The routine's later code assumes matched instruction to be a select
and thus it merely died on the first encountered cast that did not fit.

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

3 years ago[libc++] [docs] Add link to clang status page for C++2b and fix anchor for C++20.
Marek Kurdej [Thu, 11 Mar 2021 19:49:14 +0000 (20:49 +0100)]
[libc++] [docs] Add link to clang status page for C++2b and fix anchor for C++20.

3 years ago[mlir][StorageUniquer] Properly call the destructor on non-trivially destructible...
River Riddle [Thu, 11 Mar 2021 19:24:43 +0000 (11:24 -0800)]
[mlir][StorageUniquer] Properly call the destructor on non-trivially destructible storage instances

This allows for storage instances to store data that isn't uniqued in the context, or contain otherwise non-trivial logic, in the rare situations that they occur. Storage instances with trivial destructors will still have their destructor skipped. A consequence of this is that the storage instance definition must be visible from the place that registers the type.

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

3 years ago[clangd] Make ProjectAwareIndex optionally sync
Kadir Cetinkaya [Mon, 8 Mar 2021 09:23:56 +0000 (10:23 +0100)]
[clangd] Make ProjectAwareIndex optionally sync

Depends on D98029.

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

3 years ago[clangd] Add config block for Completion and option for AllScopes
Kadir Cetinkaya [Fri, 5 Mar 2021 12:57:04 +0000 (13:57 +0100)]
[clangd] Add config block for Completion and option for AllScopes

Depends on D98029

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

3 years ago[IndirectCallPromotion] Don't strip ".__uniq." suffix when it strips
Wei Mi [Thu, 11 Mar 2021 04:13:52 +0000 (20:13 -0800)]
[IndirectCallPromotion] Don't strip ".__uniq." suffix when it strips
".llvm." suffix.

Currently IndirectCallPromotion simply strip everything after the first "."
in LTO mode, in order to match the symbol name and the name with ".llvm."
suffix in the value profile. However, if -funique-internal-linkage-names
and thinlto are both enabled, the name may have both ".__uniq." suffix and
".llvm." suffix, and the current mechanism will strip them both, which is
unexpected. The patch fixes the problem.

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

3 years ago[libcxx] Test accessing a directory on windows that gives "access denied" errors
Martin Storsjö [Mon, 8 Mar 2021 10:03:30 +0000 (12:03 +0200)]
[libcxx] Test accessing a directory on windows that gives "access denied" errors

Fix handling of skip_permission_denied on windows; after converting
the return value of GetLastError() to a standard error_code, ec.value()
is in the standard errc range, not a native windows error code. This
was missed in 156180727d6c347eda3ba749730707acb8a48093.

The directory "C:\System Volume Information" does seem to exist and
have these properties on most relevant contempory setups.

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

3 years ago[SelectionDAG] Improve scalarization of irregular vector types
LemonBoy [Thu, 11 Mar 2021 18:56:48 +0000 (19:56 +0100)]
[SelectionDAG] Improve scalarization of irregular vector types

Use a more general strategy when splitting a vector into scalar parts (and vice-versa) to correctly handle vector types whose element size is not a power of 2 (and a multiple of 8).

Reviewed By: atanasyan

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

3 years ago[MIPS] Fix lowering of irregular vector arguments
LemonBoy [Thu, 11 Mar 2021 18:55:03 +0000 (19:55 +0100)]
[MIPS] Fix lowering of irregular vector arguments

The code deciding how to split the vector in register-sized integers used the integer division operator, thus rounding down the result.
Correct the computation for irregularly-sized types (non-power-of-two, non multiple of 8) by rounding the division result upwards.

Reviewed By: atanasyan

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

3 years ago[lldb] Fix the man page build
Raphael Isemann [Thu, 11 Mar 2021 18:51:22 +0000 (19:51 +0100)]
[lldb] Fix the man page build

In D94489 we changed the way we build the docs and now have some additional
dependencies to generate the Python API docs. As the same sphinx project is
generating the man pages for LLDB it should have in theory the same setup code
that sets up the mocked LLDB module.

However, as we don't have that setup code the man page generation just fails as
there is no mocked LLDB module and the Python API generation errors out.

The man page anyway doesn't cover the Python API so I don't think there is any
point of going through the whole process (and requiring the sphinx plugins) just
to generate the (eventually unused) Python docs.

This patch just skips the relevant Python API generation when we are building
the man page.

Reviewed By: JDevlieghere

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

3 years ago[mlir][Vector][Affine] Fix heap-use-after-free in vectorizer
Diego Caballero [Thu, 11 Mar 2021 00:44:06 +0000 (02:44 +0200)]
[mlir][Vector][Affine] Fix heap-use-after-free in vectorizer

This patch fixes a heap-use-after-free introduced by the recent changes
in the vectorizer: https://reviews.llvm.org/rG95db7b4aeaad590f37720898e339a6d54313422f
The problem is due to the way candidate loops are visited. All candidate loops
are pattern-matched beforehand using the 'NestedMatch' utility. These matches may
intersect with each other so it may happen that we try to vectorize a loop that
was previously vectorized. The new vectorization algorithm replaces the original
loops that are vectorized with new loops and, therefore, any reference to the
original loops in the pre-computed matches becomes invalid.

This patch fixes the problem by classifying the candidate matches into buckets
before vectorization. Each bucket contains all the matches that intersect. The
vectorizer uses these buckets to make sure that we only vectorize *one* match from
each bucket, at most.

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

3 years ago[gn build] Port 5433a79176a3
LLVM GN Syncbot [Thu, 11 Mar 2021 18:35:32 +0000 (18:35 +0000)]
[gn build] Port 5433a79176a3

3 years ago[lld-macho] Unbreak build breakage from rG1752f2850685
Jez Ng [Thu, 11 Mar 2021 18:35:00 +0000 (13:35 -0500)]
[lld-macho] Unbreak build breakage from rG1752f2850685

3 years ago[lld-macho] Avoid requiring shell in tests
Jez Ng [Thu, 11 Mar 2021 18:28:14 +0000 (13:28 -0500)]
[lld-macho] Avoid requiring shell in tests

There are 3 remaining tests that still have `REQUIRE: shell`:
* color-diagnostics.test -- seems necessary for ANSI escape sequence support
* stabs.s -- the shell part could be removed, but I don't think we can support
  the test on Windows anyway due to its reliance on `touch` to set the modtime
* framework.s -- uses symlinks, I'm not sure this works on Windows

Addresses PR49512.

Reviewed By: #lld-macho, alexshap

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

3 years ago[lld-macho][nfc] Refactor subtractor reloc handling
Jez Ng [Thu, 11 Mar 2021 18:28:13 +0000 (13:28 -0500)]
[lld-macho][nfc] Refactor subtractor reloc handling

SUBTRACTOR relocations are always paired with UNSIGNED
relocations to indicate a pair of symbols whose address difference we
want. Functionally they are like a single relocation: only one pointer
gets written / relocated. Previously, we would handle these pairs by
skipping over the SUBTRACTOR relocation and writing the pointer when
handling the UNSIGNED reloc. This diff reverses things, so we write
while handling SUBTRACTORs and skip over the UNSIGNED relocs instead.

Being able to distinguish between SUBTRACTOR and UNSIGNED relocs in the
write phase (i.e. inside `relocateOne`) is useful for the upcoming range
check diff: we want to check that SUBTRACTOR relocs write signed values,
but UNSIGNED relocs (naturally) write unsigned values.

Reviewed By: #lld-macho, thakis

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

3 years ago[lld-macho] Fix handling of X86_64_RELOC_SIGNED_{1,2,4}
Jez Ng [Thu, 11 Mar 2021 18:28:11 +0000 (13:28 -0500)]
[lld-macho] Fix handling of X86_64_RELOC_SIGNED_{1,2,4}

The previous implementation miscalculated the addend, resulting
in an underflow. This meant that every SIGNED_N section relocation would
be associated with the last subsection (since the addend would now be a
huge number). We were "lucky" that this mistake was typically cancelled
out -- 64-to-32-bit-truncation meant that the final value was correct,
as long as subsections were not rearranged.

Reviewed By: #lld-macho, thakis

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

3 years ago[lld-macho][nfc] Create Relocations.{h,cpp} for relocation-specific code
Jez Ng [Thu, 11 Mar 2021 18:28:09 +0000 (13:28 -0500)]
[lld-macho][nfc] Create Relocations.{h,cpp} for relocation-specific code

This more closely mirrors the structure of lld-ELF.

Reviewed By: #lld-macho, thakis

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

3 years ago[lld-macho][nfc] Remove `MachO::` prefix where possible
Jez Ng [Thu, 11 Mar 2021 18:28:08 +0000 (13:28 -0500)]
[lld-macho][nfc] Remove `MachO::` prefix where possible

Previously, SyntheticSections.cpp did not have a top-level `using namespace
llvm::MachO` because it caused a naming conflict: `llvm::MachO::Symbol` would
collide with `lld::macho::Symbol`.

`MachO::Symbol` represents the symbols defined in InterfaceFiles (TBDs). By
moving the inclusion of InterfaceFile.h into our .cpp files, we can avoid this
name collision in other files where we are only dealing with LLD's own symbols.

Along the way, I removed all unnecessary "MachO::" prefixes in our code.

Cons of this approach: If TextAPI/MachO/Symbol.h gets included via some other
header file in the future, we could run into this collision again.

Alternative 1: Have either TextAPI/MachO or BinaryFormat/MachO.h use a different
namespace. Most of the benefit of `using namespace llvm::MachO` comes from being
able to use things in BinaryFormat/MachO.h conveniently; if TextAPI was under a
different (and fully-qualified) namespace like `llvm::tapi` that would solve our
problems. Cons: lots of files across llvm-project will need to be updated, and
folks who own the TextAPI code need to agree to the name change.

Alternative 2: Rename our Symbol to something like `LldSymbol`. I think this is
ugly.

Personally I think alternative #1 is ideal, but I'm not sure the effort to do it is
worthwhile, this diff's halfway solution seems good enough to me. Thoughts?

Reviewed By: #lld-macho, oontvoo, MaskRay

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

3 years ago[libcxx] [test] Disable a test regarding error behaviour for excessively long paths...
Martin Storsjö [Fri, 26 Feb 2021 12:42:17 +0000 (14:42 +0200)]
[libcxx] [test] Disable a test regarding error behaviour for excessively long paths on windows

Checking for the existence of an invalid long path name isn't
an error in itself on windows.

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

3 years ago[flang] Handle type-bound procedures with alternate returns
Peter Steinfeld [Thu, 11 Mar 2021 16:23:08 +0000 (08:23 -0800)]
[flang] Handle type-bound procedures with alternate returns

If you specify a type-bound procedure with an alternate return, there
will be no symbol associated with that dummy argument.  In such cases,
the compiler's list of dummy arguments will contain a nullptr.  In our
analysis of the PASS arguments of type-bound procedures, we were
assuming that all dummy arguments had non-null symbols associated with
them and were using that assumption to get the name of the dummy
argument.  This caused the compiler to try to dereference a nullptr.

I fixed this by explicitly checking for a nullptr and, in such cases, emitting
an error message.  I also added tests that contain type-bound procedures with
alternate returns in both legal and illegal constructs to ensure that semantic
analysis is working for them.

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

3 years ago[SamplePGO] Skip inlinee profile scaling for sample loader inlining
Wenlei He [Sun, 7 Mar 2021 17:21:09 +0000 (09:21 -0800)]
[SamplePGO] Skip inlinee profile scaling for sample loader inlining

For CGSCC inline, we need to scale down a function's branch weights and entry counts when thee it's inlined at a callsite. This is done through updateCallProfile. Additionally, we also scale the weigths for the inlined clone based on call site count in updateCallerBFI. Neither is needed for inlining during sample profile loader as it's using context profile that is separated from inlinee's own profile. This change skip the inlinee profile scaling for sample loader inlining.

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

3 years ago[Driver] Drop $sysroot/usr special case from Gentoo gcc-config detection
Fangrui Song [Thu, 11 Mar 2021 18:13:00 +0000 (10:13 -0800)]
[Driver] Drop $sysroot/usr special case from Gentoo gcc-config detection

If --gcc-toolchain is specified, we should detect GCC installation there, and suppress other directories for detection.

Reviewed By: mgorny, manojgupta

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

3 years ago[UnitTests] Remove uses of deprecated CreateLoad() API
Nikita Popov [Thu, 11 Mar 2021 18:04:28 +0000 (19:04 +0100)]
[UnitTests] Remove uses of deprecated CreateLoad() API

Missed this usage inside OpenMPIRBuilderTest.

3 years ago[RISCV] Support fixed vector copysign.
Craig Topper [Thu, 11 Mar 2021 17:41:39 +0000 (09:41 -0800)]
[RISCV] Support fixed vector copysign.

Reviewed By: frasercrmck

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

3 years ago[ARM] Move t2DoLoopStart reg alloc hint
David Green [Thu, 11 Mar 2021 17:56:19 +0000 (17:56 +0000)]
[ARM] Move t2DoLoopStart reg alloc hint

This adjusts the place that the t2DoLoopStart reg allocation hint is
inserted, adding it in the ARMTPAndVPTOptimizaionPass in a similar place
as other tail predicated loop optimizations. This removes the need for
doing so in a custom inserter, and should make the hint more accurate,
only adding it where we expect to create a DLS (not DLSTP or WLS).

3 years ago[ARM] Improve WLS lowering
David Green [Thu, 11 Mar 2021 14:06:04 +0000 (14:06 +0000)]
[ARM] Improve WLS lowering

Recently we improved the lowering of low overhead loops and tail
predicated loops, but concentrated first on the DLS do style loops. This
extends those improvements over to the WLS while loops, improving the
chance of lowering them successfully. To do this the lowering has to
change a little as the instructions are terminators that produce a value
- something that needs to be treated carefully.

Lowering starts at the Hardware Loop pass, inserting a new
llvm.test.start.loop.iterations that produces both an i1 to control the
loop entry and an i32 similar to the llvm.start.loop.iterations
intrinsic added for do loops. This feeds into the loop phi, properly
gluing the values together:

  %wls = call { i32, i1 } @llvm.test.start.loop.iterations.i32(i32 %div)
  %wls0 = extractvalue { i32, i1 } %wls, 0
  %wls1 = extractvalue { i32, i1 } %wls, 1
  br i1 %wls1, label %loop.ph, label %loop.exit
...
loop:
  %lsr.iv = phi i32 [ %wls0, %loop.ph ], [ %iv.next, %loop ]
  ..
  %iv.next = call i32 @llvm.loop.decrement.reg.i32(i32 %lsr.iv, i32 1)
  %cmp = icmp ne i32 %iv.next, 0
  br i1 %cmp, label %loop, label %loop.exit

The llvm.test.start.loop.iterations need to be lowered through ISel
lowering as a pair of WLS and WLSSETUP nodes, which each get converted
to t2WhileLoopSetup and t2WhileLoopStart Pseudos. This helps prevent
t2WhileLoopStart from being a terminator that produces a value,
something difficult to control at that stage in the pipeline. Instead
the t2WhileLoopSetup produces the value of LR (essentially acting as a
lr = subs rn, 0), t2WhileLoopStart consumes that lr value (the Bcc).

These are then converted into a single t2WhileLoopStartLR at the same
point as t2DoLoopStartTP and t2LoopEndDec. Otherwise we revert the loop
to prevent them from progressing further in the pipeline. The
t2WhileLoopStartLR is a single instruction that takes a GPR and produces
LR, similar to the WLS instruction.

  %1:gprlr = t2WhileLoopStartLR %0:rgpr, %bb.3
  t2B %bb.1
...
bb.2.loop:
  %2:gprlr = PHI %1:gprlr, %bb.1, %3:gprlr, %bb.2
  ...
  %3:gprlr = t2LoopEndDec %2:gprlr, %bb.2
  t2B %bb.3

The t2WhileLoopStartLR can then be treated similar to the other low
overhead loop pseudos, eventually being lowered to a WLS providing the
branches are within range.

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

3 years ago[AArch64] Fix -Wunused-but-set-variable in GCC non-debug build
Simon Wallis [Thu, 11 Mar 2021 17:53:44 +0000 (17:53 +0000)]
[AArch64] Fix -Wunused-but-set-variable in GCC non-debug build

[AArch64] Fix -Wunused-but-set-variable in GCC -DLLVM_ENABLE_ASSERTIONS=off non-debug build.

Reviewed By: MaskRay

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

3 years ago[PGO] Fix two issues in PGOMemOPSizeOpt.
Hiroshi Yamauchi [Fri, 26 Feb 2021 22:44:20 +0000 (14:44 -0800)]
[PGO] Fix two issues in PGOMemOPSizeOpt.

1. PGOMemOPSizeOpt grabs only the first, up to five (by default) entries from
the value profile metadata and preserves the remaining entries for the fallback
memop call site. If there are more than five entries, the rest of the entries
would get dropped. This is fine for PGOMemOPSizeOpt itself as it only promotes
up to 3 (by default) values, but potentially not for other downstream passes
that may use the value profile metadata.

2. PGOMemOPSizeOpt originally assumed that only values 0 through 8 are kept
track of. When the range buckets were introduced, it was changed to skip the
range buckets, but since it does not grab all entries (only five), if some range
buckets exist in the first five entries, it could potentially cause fewer
promotion opportunities (eg. if 4 out of 5 were range buckets, it may be able to
promote up to one non-range bucket, as opposed to 3.) Also, combined with 1, it
means that wrong entries may be preserved, as it didn't correctly keep track of
which were entries were skipped.

To fix this, PGOMemOPSizeOpt now grabs all the entries (up to the maximum number
of value profile buckets), keeps track of which entries were skipped, and
preserves all the remaining entries.

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

3 years ago[IRBuilder] Deprecate CreateLoad APIs with implicit type
Nikita Popov [Thu, 11 Feb 2021 21:33:18 +0000 (22:33 +0100)]
[IRBuilder] Deprecate CreateLoad APIs with implicit type

These APIs are not compatible with opaque pointers. Deprecate them
to avoid the introduction of further uses.

3 years ago[RISCV] Handle vmv.x.s intrinsic for i64 vectors on RV32.
Craig Topper [Thu, 11 Mar 2021 17:34:00 +0000 (09:34 -0800)]
[RISCV] Handle vmv.x.s intrinsic for i64 vectors on RV32.

Reviewed By: frasercrmck

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

3 years ago[mlir] Remove uses of type-less CreateLoad() APIs (NFC)
Nikita Popov [Thu, 11 Mar 2021 17:29:13 +0000 (18:29 +0100)]
[mlir] Remove uses of type-less CreateLoad() APIs (NFC)

For the use in LLVMOps.td I used the getPointerElementType()
escape hatch, as it's not obvious to me how the load type
should be properly obtained here.

3 years ago[Polly] Remove uses of type-less CreateLoad() APIs (NFC)
Nikita Popov [Thu, 11 Mar 2021 16:01:48 +0000 (17:01 +0100)]
[Polly] Remove uses of type-less CreateLoad() APIs (NFC)

These are incompatible with opaque pointers and are going away.
Explicitly specify the loaded type instead.

3 years ago[ELF] Simplify isValidCIdentifier. NFC
Fangrui Song [Thu, 11 Mar 2021 17:38:15 +0000 (09:38 -0800)]
[ELF] Simplify isValidCIdentifier. NFC

3 years ago[libcxx] Avoid intermediate string objects for substrings in windows operator/=
Martin Storsjö [Thu, 11 Mar 2021 11:06:08 +0000 (13:06 +0200)]
[libcxx] Avoid intermediate string objects for substrings in windows operator/=

Check that appends with a path object doesn't do allocations, even
on windows.

Suggested by Marek in D98398. The patch might apply without D98398
(depending on how much of the diff context has to match), but doesn't
make much sense until after that patch has landed.

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

3 years ago[libcxx] [test] Use a string_view of the native path type in the concat test
Martin Storsjö [Thu, 11 Mar 2021 11:10:10 +0000 (13:10 +0200)]
[libcxx] [test] Use a string_view of the native path type in the concat test

This makes sure that no extra allocations happen on windows, fixing
earlier errors in the DisableAllocationGuard (in the second case that
is modified).

This is split out from D98398.

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

3 years ago[ELF] Support . and $ in symbol names in expressions
Fangrui Song [Thu, 11 Mar 2021 17:34:36 +0000 (09:34 -0800)]
[ELF] Support . and $ in symbol names in expressions

GNU ld supports `.` and `$` in symbol names while LLD doesn't support them in
`readPrimary` expressions. Using `.` can result in such an error:

```
https://github.com/ClangBuiltLinux/linux/issues/1318
ld.lld: error: ./arch/powerpc/kernel/vmlinux.lds:255: malformed number: .TOC.
>>>   __toc_ptr = (DEFINED (.TOC.) ? .TOC. : ADDR (.got)) + 0x8000;
```

Allow `.` (ppc64 special symbol `.TOC.`) and `$` (RISC-V special symbol `__global_pointer$`).

Change `diag[3-5].test` to use an invalid character `^`.

Note: GNU ld allows `~` in non-leading positions of a symbol name.  `~`
is not used in practice, conflicts with the unary operator, and can
cause some parsing difficulty, so this patch does not add it.

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

3 years ago[RISCV] Support extract_vector_elt for fixed and scalable masked registers.
Craig Topper [Thu, 11 Mar 2021 17:26:43 +0000 (09:26 -0800)]
[RISCV] Support extract_vector_elt for fixed and scalable masked registers.

This uses a really simple approach of converting to an i8 vector
and extracting. This is probably not the best approach especially
if you know the index is constant.

Other ideas:
-Store to stack temporary using vse1, load as scalar and shift.
-Sort of bitcast the vector to a vector of i8, slide down the
 appropriate 8 bit element, copy to scalar, shift down the
 correct bit within the 8 bits we extracted. Not exactly sure
 how to describe such a bitcast from i1 vector to i8 vector
 within the type system for elements less than 8.

Reviewed By: frasercrmck

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

3 years ago[ValueTypes][RISCV] Add MVT for v1f16.
Craig Topper [Thu, 11 Mar 2021 17:17:11 +0000 (09:17 -0800)]
[ValueTypes][RISCV] Add MVT for v1f16.

RISCV makes all fixed vector MVTs with size less than or equal
to a command line option legal.

This didn't include v1f16 because it was missing but did include v1f32 and v1f64.

One test is affected where we did test this type, but it is a horizontal
reduction so it is non-sensical. Perhaps we should canonicalize that
away somewhere.

I'm not sure if we should be making v1 types legal, but this will at
least make RISCV consistent across all types.

Reviewed By: frasercrmck

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

3 years ago[mlir] fix cmake build
Alex Zinenko [Thu, 11 Mar 2021 17:22:00 +0000 (18:22 +0100)]
[mlir] fix cmake build

3 years ago[mlir] Introduce data layout modeling subsystem
Alex Zinenko [Thu, 11 Mar 2021 13:33:44 +0000 (14:33 +0100)]
[mlir] Introduce data layout modeling subsystem

Data layout information allows to answer questions about the size and alignment
properties of a type. It enables, among others, the generation of various
linear memory addressing schemes for containers of abstract types and deeper
reasoning about vectors. This introduces the subsystem for modeling data
layouts in MLIR.

The data layout subsystem is designed to scale to MLIR's open type and
operation system. At the top level, it consists of attribute interfaces that
can be implemented by concrete data layout specifications; type interfaces that
should be implemented by types subject to data layout; operation interfaces
that must be implemented by operations that can serve as data layout scopes
(e.g., modules); and dialect interfaces for data layout properties unrelated to
specific types. Built-in types are handled specially to decrease the overall
query cost.

A concrete default implementation of these interfaces is provided in the new
Target dialect. Defaults for built-in types that match the current behavior are
also provided.

Reviewed By: rriddle

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

3 years ago[mlir] Add LLVM loop codegen options to control software pipelining
Arpith C. Jacob [Thu, 11 Mar 2021 15:42:56 +0000 (16:42 +0100)]
[mlir] Add LLVM loop codegen options to control software pipelining

Support specifying the II and disabling pipelining.

Reviewed By: ftynse

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

3 years agoAMDGPU/GlobalISel: Improve private addressing mode matching
Matt Arsenault [Thu, 4 Mar 2021 22:19:49 +0000 (17:19 -0500)]
AMDGPU/GlobalISel: Improve private addressing mode matching

This enables the look-through-copy to hack around not correctly
regbankselecting constants to match the use bank.

3 years agoGlobalISel: Fix off by one in finding explicit byval alignment
Matt Arsenault [Sat, 6 Mar 2021 16:00:23 +0000 (11:00 -0500)]
GlobalISel: Fix off by one in finding explicit byval alignment

For attribute sets, the return index is at 0, and arguments start at
1. getParamAlignment adds the offset of 1, so we need to convert from
attribute index back to IR index.

3 years agoAMDGPU/GlobalISel: Add more tests for byval arguments
Matt Arsenault [Sat, 6 Mar 2021 14:47:42 +0000 (09:47 -0500)]
AMDGPU/GlobalISel: Add more tests for byval arguments

3 years ago[flang][OpenMP] Add semantic check for occurrence of multiple list items in aligned...
Arnamoy Bhattacharyya [Thu, 11 Mar 2021 13:15:55 +0000 (08:15 -0500)]
[flang][OpenMP] Add semantic check for occurrence of multiple list items in aligned clause for simd directive

Reviewed By: kiranchandramohan, clementval

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

3 years ago[lldb] Add missing debugserver dependency to check-lldb
Raphael Isemann [Thu, 11 Mar 2021 13:34:20 +0000 (14:34 +0100)]
[lldb] Add missing debugserver dependency to check-lldb

D96202 removes the test dependency on debugserver which is causing a bunch of
tests to fail on a clean build.

This patch re-adds the dependency. I decided to not add the dependency in the
`test/API` folder as we actually need it in all kinds of tests (we have shell,
API and a few unit tests such as the LLDBServerTests that depend on the
debugserver binary). lldb-server is also handled in the same way.

Reviewed By: JDevlieghere, labath

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

3 years ago[OpenMP] Restore backwards compatibility for libomptarget
Joseph Huber [Wed, 10 Mar 2021 18:25:33 +0000 (13:25 -0500)]
[OpenMP] Restore backwards compatibility for libomptarget

Summary:
The changes introduced in D87946 changed the API for libomptarget
functions. `__kmpc_push_target_tripcount` was a function in Clang 11.x
but was not given a backward-compatible interface. This change will
require people using Clang 13.x or 12.x to recompile their offloading
programs.

Reviewed By: jdoerfert cchen

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

3 years ago[Sema] Use castAs<> instead getAs<> for dereferenced pointer casts. NFCI.
Simon Pilgrim [Thu, 11 Mar 2021 14:51:09 +0000 (14:51 +0000)]
[Sema] Use castAs<> instead getAs<> for dereferenced pointer casts. NFCI.

getAs<> returns null for missed casts, resulting in null dereferences - use castAs<> instead which will assert the cast is correct.

3 years agoRevert "[DebugInfo] Use variadic debug values to salvage BinOps and GEP instrs with...
Stephen Tozer [Thu, 11 Mar 2021 14:46:17 +0000 (14:46 +0000)]
Revert "[DebugInfo] Use variadic debug values to salvage BinOps and GEP instrs with non-const operands"

This reverts commit c0f3dfb9f119bb5f22dd8846f5502b6abaf026d3.

Reverted due to an error on the clang-x64-windows-msvc buildbot.

3 years ago[llvm-mca] Fix uninitialized variable in InOrderIssueStage constructor warning. NFCI.
Simon Pilgrim [Thu, 11 Mar 2021 14:40:00 +0000 (14:40 +0000)]
[llvm-mca] Fix uninitialized variable in InOrderIssueStage constructor warning. NFCI.

3 years ago[PowerPC] Exploit paddi instruction on Power 10 for constant materialization
Stefan Pintilie [Thu, 11 Mar 2021 11:44:55 +0000 (05:44 -0600)]
[PowerPC] Exploit paddi instruction on Power 10 for constant materialization

Starting with Power 10 the instruction paddi is available to use.
The instruction allows for immediates that are 34 bits.

This patch adds exploitation of the paddi instruction to allow us
to materialize constants.

Reviewed By: lei, amyk

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

3 years ago[lld-macho] minimal TimeTrace support
Thorsten Schütt [Thu, 11 Mar 2021 14:04:27 +0000 (15:04 +0100)]
[lld-macho] minimal TimeTrace support

This is the minimal port from ELF. Any extension should easy from here

Test plan: ninja check-all-macho

Reviewed By: #lld-macho, thakis

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

3 years ago[OpenCL][Docs] Add guidelines for new extensions and features.
Anastasia Stulova [Thu, 11 Mar 2021 14:05:15 +0000 (14:05 +0000)]
[OpenCL][Docs] Add guidelines for new extensions and features.

Add documentation that explains how to extend clang with the new
extensions/features. The guidelines also detail clang's position
about the extension pragmas for the new functionality.

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

3 years ago[Orc] Deallocate debug objects explicitly when destroying the DebugObjectManagerPlugin
Stefan Gränitz [Wed, 10 Mar 2021 22:45:22 +0000 (23:45 +0100)]
[Orc] Deallocate debug objects explicitly when destroying the DebugObjectManagerPlugin

3 years ago[Transforms] SampleProfileLoaderBaseImpl<BT>::getFunctionLoc - fix Wdocumentation...
Simon Pilgrim [Thu, 11 Mar 2021 14:03:52 +0000 (14:03 +0000)]
[Transforms] SampleProfileLoaderBaseImpl<BT>::getFunctionLoc - fix Wdocumentation warnings. NFCI.

3 years ago[PowerPC] Fix multi-use case for swap reduction
Qiu Chaofan [Thu, 11 Mar 2021 13:58:33 +0000 (21:58 +0800)]
[PowerPC] Fix multi-use case for swap reduction

4c973ae implemented reduction of vector swap for lane-insensitive
operations. This commit fixes it for checking number of uses of the
vector operation.

3 years ago[Sema] Add some basic lambda capture fix-its
Nathan James [Thu, 11 Mar 2021 13:46:24 +0000 (13:46 +0000)]
[Sema] Add some basic lambda capture fix-its

Adds fix-its when users forget to explicitly capture variables or this in lambdas

Addresses https://github.com/clangd/clangd/issues/697

Reviewed By: kbobyrev

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

3 years ago[OpaquePtrs] Remove some uses of type-less CreateLoad APIs (NFC)
Nikita Popov [Thu, 11 Feb 2021 23:07:23 +0000 (00:07 +0100)]
[OpaquePtrs] Remove some uses of type-less CreateLoad APIs (NFC)

Explicitly pass loaded type when creating loads, in preparation
for the deprecation of these APIs.

There are still a couple of uses left.

3 years ago[AArch64][SVE] Add fixed/scalable lowering of FMAXIMUM/FMINIMUM ISD nodes
Bradley Smith [Wed, 10 Mar 2021 10:30:42 +0000 (10:30 +0000)]
[AArch64][SVE] Add fixed/scalable lowering of FMAXIMUM/FMINIMUM ISD nodes

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

3 years ago[DebugInfo] Use variadic debug values to salvage BinOps and GEP instrs with non-const...
gbtozers [Wed, 30 Sep 2020 18:15:44 +0000 (19:15 +0100)]
[DebugInfo] Use variadic debug values to salvage BinOps and GEP instrs with non-const operands

This patch improves salvageDebugInfoImpl by allowing it to salvage arithmetic
operations with two or more non-const operands; this includes the GetElementPtr
instruction, and most Binary Operator instructions. These salvages produce
DIArgList locations and are only valid for dbg.values, as currently variadic
DIExpressions must use DW_OP_stack_value. This functionality is also only added
for salvageDebugInfoForDbgValues; other functions that directly call
salvageDebugInfoImpl (such as in ISel or Coroutine frame building) can be
updated in a later patch.

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

3 years agoRevert "[AArch64][SVE] Allow accesses to SVE stack objects to use frame pointer"
Bradley Smith [Wed, 10 Mar 2021 15:03:53 +0000 (15:03 +0000)]
Revert "[AArch64][SVE] Allow accesses to SVE stack objects to use frame pointer"

This patch introduced codegen faults.  An attempt to fix this was done
in https://reviews.llvm.org/D97193, but ultimately it was decided to
approach this differently.

This reverts commit 42635856ed3c9a05957640f9deb50cf865c03825.

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

3 years ago[PowerPC] Fix infinite loop in peephole CR optimization (PR49509)
Nikita Popov [Wed, 10 Mar 2021 13:37:09 +0000 (14:37 +0100)]
[PowerPC] Fix infinite loop in peephole CR optimization (PR49509)

If we encounter a degenerate select node where both operands are
the same, then we can continue negating the condition while swapping
operands, resulting in an infinite loop. Avoid this by bailing out
if both operands are the same.

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

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

3 years ago[compiler-rt] Set CMAKE_TRY_COMPILE_TARGET_TYPE to STATIC_LIBRARY when building built...
Martin Storsjö [Thu, 12 Nov 2020 09:09:38 +0000 (11:09 +0200)]
[compiler-rt] Set CMAKE_TRY_COMPILE_TARGET_TYPE to STATIC_LIBRARY when building builtins standalone

When building builtins, the toolchain might not yet be at a stage
when linking a test application works yet, as builtins aren't
available. Therefore set CMAKE_TRY_COMPILE_TARGET_TYPE to STATIC_LIBRARY,
to avoid failing the compiler sanity check.

Setting CMAKE_TRY_COMPILE_TARGET_TYPE to STATIC_LIBRARY has the risk
of making checks for library availability succeed falsely (e.g.
indicating that libs would be available that really aren't, as the
tests don't do any linking), but the builtins library doesn't try to
link against any external libraries (and only produces static libraries
anyway), so it should be safe here.

This avoids having to set CMAKE_C_COMPILER_WORKS when bootstrapping a
cross toolchain, when building the builtins.

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

3 years agoRevert rGcd938ab162b0ac560dd0e9fee290980c7e0e47e5 "[X86] canonicalizeShuffleWithBinOp...
Simon Pilgrim [Thu, 11 Mar 2021 13:02:14 +0000 (13:02 +0000)]
Revert rGcd938ab162b0ac560dd0e9fee290980c7e0e47e5 "[X86] canonicalizeShuffleWithBinOps - add X86ISD::PSHUFB handling."

Investigating an issue reported by @bkramer, possibly when the PSHUFB mask generates zero elements.

3 years ago[flang][driver] Add -fdebug-module-writer option
Arnamoy Bhattacharyya [Thu, 11 Mar 2021 12:35:45 +0000 (07:35 -0500)]
[flang][driver] Add -fdebug-module-writer option

3 years ago[clangd] Fix buildbots without grpc enabled
Kadir Cetinkaya [Thu, 11 Mar 2021 12:46:52 +0000 (13:46 +0100)]
[clangd] Fix buildbots without grpc enabled