platform/upstream/llvm.git
3 years ago[lld/mac] implement -compatibility_version, -current_version
Nico Weber [Mon, 14 Dec 2020 23:24:50 +0000 (18:24 -0500)]
[lld/mac] implement -compatibility_version, -current_version

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

3 years agoscudo: Remove positional template arguments for secondary cache. NFCI.
Peter Collingbourne [Mon, 14 Dec 2020 21:57:59 +0000 (13:57 -0800)]
scudo: Remove positional template arguments for secondary cache. NFCI.

Make these arguments named constants in the Config class instead
of being positional arguments to MapAllocatorCache. This makes the
configuration easier to follow.

Eventually we should follow suit with the other classes but this is
a start.

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

3 years ago[VectorCombine] add alignment test for gep load; NFC
Sanjay Patel [Mon, 14 Dec 2020 23:30:40 +0000 (18:30 -0500)]
[VectorCombine] add alignment test for gep load; NFC

3 years ago[gn build] (semi-manually) port 19d57b5c42b
Nico Weber [Mon, 14 Dec 2020 23:23:15 +0000 (18:23 -0500)]
[gn build] (semi-manually) port 19d57b5c42b

3 years ago[gn build] (semi-manually) port 7ad49aec125
Nico Weber [Mon, 14 Dec 2020 23:22:54 +0000 (18:22 -0500)]
[gn build] (semi-manually) port 7ad49aec125

3 years ago[mlir] Fix opaque struct typedef in AsyncRuntime header
Eugene Zhulenev [Mon, 14 Dec 2020 22:55:46 +0000 (14:55 -0800)]
[mlir] Fix opaque struct typedef in AsyncRuntime header

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

3 years ago[mlir] Add section page for Rationale docs.
Richard Uhler [Mon, 14 Dec 2020 22:48:57 +0000 (14:48 -0800)]
[mlir] Add section page for Rationale docs.

With a brief overview and summary of each of the Rationale docs.

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

3 years ago[clang][IR] Add support for leaf attribute
Gulfem Savrun Yeniceri [Mon, 14 Dec 2020 21:56:11 +0000 (13:56 -0800)]
[clang][IR] Add support for leaf attribute

This patch adds support for leaf attribute as an optimization hint
in Clang/LLVM.

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

3 years ago[libc++] Remove unnecessary static assertion in allocate_shared
Louis Dionne [Mon, 14 Dec 2020 21:58:52 +0000 (16:58 -0500)]
[libc++] Remove unnecessary static assertion in allocate_shared

Checking that `T` is constructible from `Args...` is technically not
required by the Standard, although any implementation will obviously
error out if that's not satisfied. However, this check is incompatible
with using Allocator construction in the control block (upcoming change
as part of implementing P0674), so I'm removing it now to reduce the
upcoming diff as much as possible.

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

3 years ago[libc++] NFCI: Return pointer instead of reference from __shared_ptr_emplace helper...
Louis Dionne [Mon, 14 Dec 2020 22:40:56 +0000 (17:40 -0500)]
[libc++] NFCI: Return pointer instead of reference from __shared_ptr_emplace helper method

This makes __get_alloc consistent with __get_elem, and will reduce the
diff required to implement P0674R1.

3 years ago[VectorCombine] make load transform poison-safe
Sanjay Patel [Mon, 14 Dec 2020 22:20:15 +0000 (17:20 -0500)]
[VectorCombine] make load transform poison-safe

As noted in D93229, the transform from scalar load to vector load
potentially leaks poison from the extra vector elements that are
being loaded.

We could use freeze here (and x86 codegen at least appears to be
the same either way), but we already have a shuffle in this logic
to optionally change the vector size, so let's allow that
instruction to serve both purposes.

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

3 years agoAdapt lldb to a40db5502b2515a6f2f1676b5d7a655ae0f41179
Duncan P. N. Exon Smith [Mon, 14 Dec 2020 22:41:12 +0000 (14:41 -0800)]
Adapt lldb to a40db5502b2515a6f2f1676b5d7a655ae0f41179

The bots just told me about a place in LLDB I missed in
a40db5502b2515a6f2f1676b5d7a655ae0f41179 when changing
`HeaderSearch::LoadedModuleMaps`, but I think this will fix it.

3 years agoAdd comment to closing brace of anonymous namespace, NFC
Duncan P. N. Exon Smith [Mon, 14 Dec 2020 22:28:59 +0000 (14:28 -0800)]
Add comment to closing brace of anonymous namespace, NFC

3 years agoAST: Silence an instance of -Wsign-compare, NFC
Duncan P. N. Exon Smith [Mon, 14 Dec 2020 22:36:59 +0000 (14:36 -0800)]
AST: Silence an instance of -Wsign-compare, NFC

Looks this this was added by 68f53960e17d93c3a2727164dac4e54140bd98ba.

3 years agoLex: Migrate HeaderSearch::LoadedModuleMaps to FileEntryRef
Duncan P. N. Exon Smith [Wed, 9 Dec 2020 22:46:34 +0000 (14:46 -0800)]
Lex: Migrate HeaderSearch::LoadedModuleMaps to FileEntryRef

Migrate `HeaderSearch::LoadedModuleMaps` and a number of APIs over to
`FileEntryRef`. This should have no functionality change. Note that two
`FileEntryRef`s hash the same if they point at the same `FileEntry`.

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

3 years ago[LoopIdiomRecognize] Teach detectShiftUntilZeroIdiom to recognize loops where the...
Craig Topper [Mon, 14 Dec 2020 21:51:00 +0000 (13:51 -0800)]
[LoopIdiomRecognize] Teach detectShiftUntilZeroIdiom to recognize loops where the counter is decrementing.

This adds support for loops like

unsigned clz(unsigned x) {
    unsigned w = sizeof (x) * CHAR_BIT;
    while (x) {
        w--;
        x >>= 1;
    }

    return w;
}

and

unsigned clz(unsigned x) {
    unsigned w = sizeof (x) * CHAR_BIT - 1;
    while (x >>= 1) {
        w--;
    }

    return w;
}

To support these we look for add x, -1 as well as add x, 1 that
we already matched. If the value was -1 we need to subtract from
the initial counter value instead of adding to it.

Fixes PR48404.

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

3 years ago[mlir][OpDefGen] Add support for generating local functions for shared utilities
River Riddle [Mon, 14 Dec 2020 22:14:22 +0000 (14:14 -0800)]
[mlir][OpDefGen] Add support for generating local functions for shared utilities

This revision adds a new `StaticVerifierFunctionEmitter` class that emits local static functions in the .cpp file for shared operation verification. This class deduplicates shared operation verification code by emitting static functions alongside the op definitions. These methods are local to the definition file, and are invoked within the operation verify methods. The first bit of shared verification is for the type constraints used when verifying operands and results. An example is shown below:

```
static LogicalResult localVerify(...) {
  ...
}

LogicalResult OpA::verify(...) {
  if (failed(localVerify(...)))
    return failure();
  ...
}

LogicalResult OpB::verify(...) {
  if (failed(localVerify(...)))
    return failure();
  ...
}
```

This allowed for saving >400kb of code size from a downstream TensorFlow project (~15% of MLIR code size).

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

3 years ago[AMDGPU] Use multi-dword flat scratch for spilling
Stanislav Mekhanoshin [Wed, 25 Nov 2020 23:27:49 +0000 (15:27 -0800)]
[AMDGPU] Use multi-dword flat scratch for spilling

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

3 years ago[libc++] Refactor allocate_shared to use an allocation guard
Louis Dionne [Fri, 11 Dec 2020 17:20:06 +0000 (12:20 -0500)]
[libc++] Refactor allocate_shared to use an allocation guard

This commit is a step towards making it easier to add support for arrays
in allocate_shared. Adding support for arrays will require writing multiple
functions, and the current complexity of writing allocate_shared is
prohibitive for understanding.

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

3 years agoRevert "[DDG] Data Dependence Graph - DOT printer"
Bardia Mahjour [Mon, 14 Dec 2020 21:54:20 +0000 (16:54 -0500)]
Revert "[DDG] Data Dependence Graph - DOT printer"

This reverts commit fd4a10732c8bd646ccc621c0a9af512be252f33a, to
investigate the failure on windows: http://lab.llvm.org:8011/#/builders/127/builds/3274

3 years agoRevert "[mlir] Remove methods from mlir::OpState that just forward to mlir::Operation."
Christian Sigg [Mon, 14 Dec 2020 21:45:37 +0000 (22:45 +0100)]
Revert "[mlir] Remove methods from mlir::OpState that just forward to mlir::Operation."

This reverts commit 6f271e921ba48f4c4fa54bbd2c7a4c548ca5e59e.

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

3 years agoSpeculative fix for build bot failures
Philip Reames [Mon, 14 Dec 2020 21:42:25 +0000 (13:42 -0800)]
Speculative fix for build bot failures

(The clang build fails for me locally, so this is based on built bot output and a guess as to root cause.)

f5fe849 made the execution of LAA conditional, so I'm guessing that's the root cause.

3 years ago[DDG] Data Dependence Graph - DOT printer
Bardia Mahjour [Mon, 14 Dec 2020 21:34:48 +0000 (16:34 -0500)]
[DDG] Data Dependence Graph - DOT printer

This patch implements a DDG printer pass that generates a graph in
the DOT description language, providing a more visually appealing
representation of the DDG. Similar to the CFG DOT printer, this
functionality is provided under an option called -dot-ddg and can
be generated in a less verbose mode under -dot-ddg-only option.

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

3 years ago[mlir][ArmSVE][RFC] Add an ArmSVE dialect
Javier Setoain [Mon, 14 Dec 2020 21:30:53 +0000 (21:30 +0000)]
[mlir][ArmSVE][RFC] Add an ArmSVE dialect

This revision starts an Arm-specific ArmSVE dialect discussed in the discourse RFC thread:

https://llvm.discourse.group/t/rfc-vector-dialects-neon-and-sve/2284

Reviewed By: rriddle

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

3 years agoOpaquePtr: Require byval on x86_intrcc parameter 0
Matt Arsenault [Thu, 19 Nov 2020 23:53:28 +0000 (18:53 -0500)]
OpaquePtr: Require byval on x86_intrcc parameter 0

Currently the backend special cases x86_intrcc and treats the first
parameter as byval. Make the IR require byval for this parameter to
remove this special case, and avoid the dependence on the pointee
element type.

Fixes bug 46672.

I'm not sure the IR is enforcing all the calling convention
constraints. clang seems to ignore the attribute for empty parameter
lists, but the IR tolerates it.

3 years agoclang: Add byval on x86_intrcc parameter 0
Matt Arsenault [Mon, 14 Dec 2020 21:13:29 +0000 (16:13 -0500)]
clang: Add byval on x86_intrcc parameter 0

This will allow removing the special case treatment of the parameter
and avoid depending on the pointer's element type.

3 years ago[libc++] Split allocator_traits and pointer_traits out of <memory>
Louis Dionne [Thu, 10 Dec 2020 23:28:13 +0000 (18:28 -0500)]
[libc++] Split allocator_traits and pointer_traits out of <memory>

In addition to making the code a lot easier to grasp by localizing many
helper functions to the only file where they are actually needed, this
will allow creating helper functions that depend on allocator_traits
outside of <memory>.

This is done as part of implementing array support in allocate_shared,
which requires non-trivial array initialization algorithms that would be
better to keep out of <memory> for sanity. It's also a first step towards
splitting up our monolithic headers into finer grained ones, which will
make it easier to reuse functionality across the library. For example,
it's just weird that we had to define `addressof` inside <type_traits>
to avoid circular dependencies -- instead it's better to implement those
in true helper headers.

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

3 years ago[NFC] cleanup cg-profile emission on TargetLowerinng
Zequan Wu [Sat, 12 Dec 2020 01:21:23 +0000 (17:21 -0800)]
[NFC] cleanup cg-profile emission on TargetLowerinng

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

3 years agoAdd initial support for multilibs in Baremetal toolchain.
Hafiz Abid Qadeer [Mon, 14 Dec 2020 19:11:51 +0000 (19:11 +0000)]
Add initial support for multilibs in Baremetal toolchain.

This patch add support of riscv multilibs in the Baremetal toolchain. It is
a bit different to what is done in GNU.cpp as we are not iterating a
GNU sysroot to find the multilibs. This is intended for an llvm only
toolchain. We are not checking for the presence of any runtime bits to
enable a specific multilib.

I have structured the patch so that other targets for which
there is no multilibs support yet in Baremetal.cpp (e.g. arm-none-eabi)
will not be affected. Patch also allows some multilibs reuse.

Long term, I would like to go in the direction of data-driven specification of
multilib directories and flags.

Reviewed By: jroelofs

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

3 years ago[MBP] Prevent rotating a chain contains entry block
Guozhi Wei [Mon, 14 Dec 2020 20:48:55 +0000 (12:48 -0800)]
[MBP] Prevent rotating a chain contains entry block

The entry block should always be the first BB in a function.
So we should not rotate a chain contains the entry block.

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

3 years ago[LAA] Relax restrictions on early exits in loop structure
Philip Reames [Mon, 14 Dec 2020 20:42:19 +0000 (12:42 -0800)]
[LAA] Relax restrictions on early exits in loop structure

his is a preparation patch for supporting multiple exits in the loop vectorizer, by itself it should be mostly NFC. This patch moves the loop structure checks from LAA to their respective consumers (where duplicates don't already exist).  Moving the checks does end up changing some of the optimization warnings and debug output slightly, but nothing that appears to be a regression.

Why do this? Well, after auditing the code, I can't actually find anything in LAA itself which relies on having all instructions within a loop execute an equal number of times. This patch simply makes this explicit so that if one consumer - say LV in the near future (hopefully) - wants to handle a broader class of loops, it can do so.

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

3 years ago[mlir] Change the internal representation of FrozenRewritePatternList to use shared_ptr
River Riddle [Mon, 14 Dec 2020 20:32:21 +0000 (12:32 -0800)]
[mlir] Change the internal representation of FrozenRewritePatternList to use shared_ptr

This will allow for caching pattern lists across multiple pass instances, such as when multithreading. This is an extremely important invariant for PDL patterns, which are compiled at runtime when the FrozenRewritePatternList is built.

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

3 years ago[mlir] Remove methods from mlir::OpState that just forward to mlir::Operation.
Christian Sigg [Mon, 14 Dec 2020 07:34:39 +0000 (08:34 +0100)]
[mlir] Remove methods from mlir::OpState that just forward to mlir::Operation.

All call sites have been converted in previous changes.

Reviewed By: mehdi_amini

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

3 years ago[flang] Fix copy elision assumption.
Michael Kruse [Mon, 14 Dec 2020 17:05:51 +0000 (11:05 -0600)]
[flang] Fix copy elision assumption.

Before this patch, the Restorer depended on copy elision to happen.
Without copy elision, the function ScopedSet calls the move constructor
before its dtor. The dtor will prematurely restore the reference to the
original value.

Instead of relying the compiler to not use the Restorer's copy
constructor, delete its copy and assign operators. Hence, callers cannot
move or copy a Restorer object anymore, and have to explicitly provide
the reset state. ScopedSet avoids calling move/copy operations by
relying on unnamed return value optimization, which is mandatory in
C++17.

Reviewed By: klausler

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

3 years ago[mlir][OpAsmParser] Add support for parsing integer literals without going through...
River Riddle [Mon, 14 Dec 2020 19:53:43 +0000 (11:53 -0800)]
[mlir][OpAsmParser] Add support for parsing integer literals without going through IntegerAttr

Some operations use integer literals as part of their custom format that don't necessarily map to an internal IntegerAttr. This revision exposes the same `parseInteger` functions as the DialectAsmParser to allow for these operations to parse integer literals without incurring the otherwise unnecessary roundtrip through IntegerAttr.

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

3 years ago[mlir][OpFormat] Add support for emitting newlines from the custom format of an operation
River Riddle [Mon, 14 Dec 2020 19:53:34 +0000 (11:53 -0800)]
[mlir][OpFormat] Add support for emitting newlines from the custom format of an operation

This revision adds a new `printNewline` hook to OpAsmPrinter that allows for printing a newline within the custom format of an operation, that is then indented to the start of the operation. Support for the declarative assembly format is also added, in the form of a `\n` literal.

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

3 years ago[CUDA] Do not diagnose host/device variable access in dependent types.
Artem Belevich [Tue, 8 Dec 2020 23:05:33 +0000 (15:05 -0800)]
[CUDA] Do not diagnose host/device variable access in dependent types.

`isCUDADeviceBuiltinSurfaceType()`/`isCUDADeviceBuiltinTextureType()` do not
work on dependent types as they rely on specific type attributes.

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

3 years ago[VectorCombine] add test for load with offset; NFC
Sanjay Patel [Mon, 14 Dec 2020 15:59:26 +0000 (10:59 -0500)]
[VectorCombine] add test for load with offset; NFC

3 years ago[Hexagon] Tweak _MSC_VER workaround version
Reid Kleckner [Mon, 14 Dec 2020 19:22:57 +0000 (11:22 -0800)]
[Hexagon] Tweak _MSC_VER workaround version

My bot runs VS 2019, but it could not compile this code.

Message:
[55/2465] Building CXX object lib\Target\Hexagon\CMakeFiles\LLVMHexagonCodeGen.dir\HexagonVectorCombine.cpp.obj
FAILED: lib/Target/Hexagon/CMakeFiles/LLVMHexagonCodeGen.dir/HexagonVectorCombine.cpp.obj
...
C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.23.28105\include\map(71): error C2976: 'std::map': too few template arguments
C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.23.28105\include\map(71): note: see declaration of 'std::map'

The version in the path, 14.23, corresponds to _MSC_VER 1923, so raise
the version floor to 1924.

I have not tested with versions between 1924 and 1928 (latest), but the
latest works with the variadic version.

3 years ago[NFC] Remove stray comment.
Alina Sbirlea [Mon, 14 Dec 2020 19:19:01 +0000 (11:19 -0800)]
[NFC] Remove stray comment.

3 years ago[flang] Use mlir::OpState::operator->() to get to methods of mlir::Operation.
Christian Sigg [Mon, 14 Dec 2020 07:32:31 +0000 (08:32 +0100)]
[flang] Use mlir::OpState::operator->() to get to methods of mlir::Operation.

This is a preparation step to remove those methods from OpState.

Reviewed By: ftynse

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

3 years ago[RISCV] Move vtype decoding and printing from RISCVInstPrinter to RISCVBaseInfo....
Craig Topper [Mon, 14 Dec 2020 18:04:44 +0000 (10:04 -0800)]
[RISCV] Move vtype decoding and printing from RISCVInstPrinter to RISCVBaseInfo. Share with the assembly parser's debug output

This moves the vtype decoding and printing to RISCVBaseInfo. This keeps all of
the decoding code in the same area as the encoding code. This will make it
easier to change the decoding for the 1.0 spec in the future.

We're now sharing the printing with the debug output for operands in the
assembler. This also fixes that debug output to include the tail and mask
agnostic bits. Since the printing code works on the vtype immediate value, we
now encode the immediate during parsing and store just the immediate in the
operand.

3 years ago[sanitizer] Restrict querying VM size on Darwin only to iOS devices
Kuba Mracek [Mon, 14 Dec 2020 18:48:48 +0000 (10:48 -0800)]
[sanitizer] Restrict querying VM size on Darwin only to iOS devices

We currently do this for SANITIZER_IOS, which includes devices *and* simulators. This change opts out the check for simulators to unify the behavior with macOS, because VM size is really a property of the host OS, and not the simulator.

<rdar://problem/72129387>

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

3 years ago[mlir][linalg] Fix bug in elementwise vectorization
Thomas Raoux [Fri, 11 Dec 2020 15:03:30 +0000 (07:03 -0800)]
[mlir][linalg] Fix bug in elementwise vectorization

Fix a bug causing to pick the wrong vector size to broadcast to when the source
vectors have different ranks.

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

3 years ago[SystemZ] Improve handling of backchain offset.
Jonas Paulsson [Sat, 12 Dec 2020 02:22:08 +0000 (03:22 +0100)]
[SystemZ] Improve handling of backchain offset.

- New function SDValue getBackchainAddress() used by
  lowerDYNAMIC_STACKALLOC() and lowerSTACKRESTORE() to properly handle the
  backchain offset also with packed-stack.

- Make a common function getBackchainOffset() for the computation of the
  backchain offset and use in some places (NFC).

Review: Ulrich Weigand

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

3 years agoRevert "[clang-scan-deps] Support clang-cl"
Sylvain Audi [Mon, 14 Dec 2020 18:32:38 +0000 (13:32 -0500)]
Revert "[clang-scan-deps] Support clang-cl"

Reverting, as it breaks build on mac.

This reverts commit 640ad769110f76d3391667249478ece88c835529.

3 years ago[Wasm][LTO][NPM] Use NPM for LTO with ENABLE_EXPERIMENTAL_NEW_PASS_MANAGER
Arthur Eubanks [Mon, 14 Dec 2020 17:56:22 +0000 (09:56 -0800)]
[Wasm][LTO][NPM] Use NPM for LTO with ENABLE_EXPERIMENTAL_NEW_PASS_MANAGER

Reviewed By: MaskRay

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

3 years ago[amdgpu] Fix a crash case when `V_CNDMASK` could be simplified.
Michael Liao [Sun, 13 Dec 2020 04:49:26 +0000 (23:49 -0500)]
[amdgpu] Fix a crash case when `V_CNDMASK` could be simplified.

- Once an instruction is simplified, foldable candidates from it should
  be invalidated or skipped as the operand index is no longer valid.

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

3 years ago[NFCI][Thumb2] Regenerate MVE tests i missed in 59560e85897afc50090b6c3d920bacfd28b49d06
Roman Lebedev [Mon, 14 Dec 2020 18:00:34 +0000 (21:00 +0300)]
[NFCI][Thumb2] Regenerate MVE tests i missed in 59560e85897afc50090b6c3d920bacfd28b49d06

3 years ago[NFC] Remove trailing whitespace in llvm/CMakeLists.txt
Tony [Mon, 14 Dec 2020 17:45:44 +0000 (17:45 +0000)]
[NFC] Remove trailing whitespace in llvm/CMakeLists.txt

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

3 years ago[TableGen] Fixed 64-bit filters being sliced to 32 bits in FixedLenDecoderEmitter
Cameron Desrochers [Mon, 14 Dec 2020 17:34:55 +0000 (12:34 -0500)]
[TableGen] Fixed 64-bit filters being sliced to 32 bits in FixedLenDecoderEmitter

When using the FixedLenDecoderEmitter, llvm-tblgen emits tables with (OPC_ExtractField, OPC_ExtractFilterValue) opcode sequences to match the contiguous fixed bits of a given instruction's encoding. This encoding is represented in a 64-bit integer. However, the filter values were represented in a 32-bit integer. As such, instructions with fixed 64-bit encodings resulted in a table with an OPC_ExtractField for all 64 bits, followed by an OPC_ExtractFilterValue containing just the low 32 bits of their encoding, causing the filter never to match.

The exact point at which the slicing occurred was during the map insertion at line 630.

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

3 years agolld/ELF: Parse MSP430 BFD/emulation names
LemonBoy [Mon, 14 Dec 2020 17:38:12 +0000 (09:38 -0800)]
lld/ELF: Parse MSP430 BFD/emulation names

Follow the naming set by TI's own GCC-based toolchain.
Also, force the `osabi` field to `ELFOSABI_STANDALONE`, this matches GNU LD's output (the patching is done in `elf32_msp430_post_process_headers`).

Reviewed By: MaskRay

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

3 years ago[PowerPC] Restore stack ptr from frame ptr with setjmp
Nemanja Ivanovic [Mon, 14 Dec 2020 17:33:46 +0000 (11:33 -0600)]
[PowerPC] Restore stack ptr from frame ptr with setjmp

If a function happens to:

- call setjmp
- do a 16-byte stack allocation
- call a function that sets up a stack frame and longjmp's back

The stack pointer that is restores by setjmp will no longer point to a valid
back chain. According to the ABI, stack accesses in such a function are to be
frame pointer based - so it is an error (quite obviously) to restore the stack
from the back chain.
We already restore the stack from the frame pointer when there are calls to
fast_cc functions. We just need to also do that when there are calls to setjmp.
This patch simply does that.

This was pointed out by the Julia team.

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

3 years ago[MLIR][SPIRV] Refactoring serialization and deserialization
ergawy [Mon, 14 Dec 2020 16:40:34 +0000 (11:40 -0500)]
[MLIR][SPIRV] Refactoring serialization and deserialization

This commit splits SPIR-V's serialization and deserialization code
into separate libraries. The motiviation being that the serializer
is used more often the deserializer and therefore lumping them
together unnecessarily increases binary size for the most common
case.

This commit also moves these libraries into the Target/ directory
to follow MLIR convention.

Reviewed By: antiagainst

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

3 years ago[ASTImporter] Fix import of a typedef that has an attribute
Gabor Marton [Wed, 9 Dec 2020 20:40:53 +0000 (21:40 +0100)]
[ASTImporter] Fix import of a typedef that has an attribute

The import of a typedefs with an attribute uses clang::Decl::setAttrs().
But that needs the ASTContext which we can get only from the
TranslationUnitDecl. But we can get the TUDecl only thourgh the
DeclContext, which is not set by the time of the setAttrs call.

Fix: import the attributes only after the DC is surely imported.
Btw, having the attribute import initiated from GetImportedOrCreateDecl was
fundamentally flawed. Now that is implicitly fixed.

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

3 years ago[SimplifyCFG] FoldBranchToCommonDest(): temporairly put back restrictions on liveout...
Roman Lebedev [Mon, 14 Dec 2020 14:44:17 +0000 (17:44 +0300)]
[SimplifyCFG] FoldBranchToCommonDest(): temporairly put back restrictions on liveout uses of bonus instructions (PR48450)

Even though d38205144febf4dc42c9270c6aa3d978f1ef65e1 was mostly a correct
fix for the external non-PHI users, it's not a *generally* correct fix,
because the 'placeholder' values in those trivial PHI's we create
shouldn't be *always* 'undef', but the PHI itself for the backedges,
else we end up with wrong value, as the `@pr48450_2` test shows.

But we can't just do that, because we can't check that the PHI
can be it's own incoming value when coming from certain predecessor,
because we don't have a dominator tree.

So until we can address this correctness problem properly,
ensure that we don't perform the transformation
if there are such problematic external uses.

Making dominator tree available there is going to be involved,
since `-simplifycfg` pass currently does not preserve/update domtree...

3 years ago[NFC][SimplifyCFG] FoldBranchToCommonDest(): pull out 'common successor' into a variable
Roman Lebedev [Mon, 14 Dec 2020 13:37:43 +0000 (16:37 +0300)]
[NFC][SimplifyCFG] FoldBranchToCommonDest(): pull out 'common successor' into a variable

Makes it easier to use it elsewhere

3 years ago[NFC][SimplifyCFG] Add another miscompiled test for PR48450
Roman Lebedev [Mon, 14 Dec 2020 12:30:38 +0000 (15:30 +0300)]
[NFC][SimplifyCFG] Add another miscompiled test for PR48450

3 years ago[libc++] ADL-proof <functional> by adding _VSTD:: qualification on calls.
Arthur O'Dwyer [Tue, 8 Dec 2020 21:15:01 +0000 (16:15 -0500)]
[libc++] ADL-proof <functional> by adding _VSTD:: qualification on calls.

- std::reference_wrapper
- std::function
- std::mem_fn

While I'm here, remove _VSTD:: qualification from calls to `declval`
because it takes no arguments and thus isn't susceptible to ADL.

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

3 years ago[libc++] Consistently replace `::new(__p) T` with `::new ((void*)__p) T`. NFCI.
Arthur O'Dwyer [Sat, 12 Dec 2020 01:30:28 +0000 (20:30 -0500)]
[libc++] Consistently replace `::new(__p) T` with `::new ((void*)__p) T`. NFCI.

Everywhere, normalize the whitespace to `::new (EXPR) T`.
Everywhere, normalize the spelling of the cast to `(void*)EXPR`.

Without the cast to `(void*)`, the expression triggers ADL on GCC.
(I think this is a GCC bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98249)
Even if it doesn't trigger ADL, it still seems incorrect to use any argument
that's not exactly `(void*)` because that opens the possibility of overload
resolution picking a user-defined overload of `operator new`, which would be
wrong.

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

3 years ago[clang-scan-deps] Support clang-cl
Sylvain Audi [Fri, 30 Oct 2020 15:21:58 +0000 (11:21 -0400)]
[clang-scan-deps] Support clang-cl

clang-scan-deps contains some command line parsing and modifications.
This patch adds support for clang-cl command options.

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

3 years ago[libc][Obvious] Include <fenv.h> from DummyFenv.h.
Siva Chandra Reddy [Mon, 14 Dec 2020 16:42:42 +0000 (08:42 -0800)]
[libc][Obvious] Include <fenv.h> from DummyFenv.h.

3 years ago[SLP] Control maximum vectorization factor from TTI
Stanislav Mekhanoshin [Tue, 24 Nov 2020 18:42:43 +0000 (10:42 -0800)]
[SLP] Control maximum vectorization factor from TTI

D82227 has added a proper check to limit PHI vectorization to the
maximum vector register size. That unfortunately resulted in at
least a couple of regressions on SystemZ and x86.

This change reverts PHI handling from D82227 and replaces it with
a more general check in SLPVectorizerPass::tryToVectorizeList().
Moved to tryToVectorizeList() it allows to restart vectorization
if initial chunk fails.

However, this function is more general and handles not only PHI
but everything which SLP handles. If vectorization factor would
be limited to maximum vector register size it would limit much
more vectorization than before leading to further regressions.
Therefore a new TTI callback getMaximumVF() is added with the
default 0 to preserve current behavior and limit nothing. Then
targets can decide what is better for them.

The callback gets ElementSize just like a similar getMinimumVF()
function and the main opcode of the chain. The latter is to avoid
regressions at least on the AMDGPU. We can have loads and stores
up to 128 bit wide, and <2 x 16> bit vector math on some
subtargets, where the rest shall not be vectorized. I.e. we need
to differentiate based on the element size and operation itself.

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

3 years agoRevert "Re-apply "[CMake][compiler-rt][AArch64] Avoid preprocessing LSE builtins...
Raul Tambre [Mon, 14 Dec 2020 16:41:30 +0000 (18:41 +0200)]
Revert "Re-apply "[CMake][compiler-rt][AArch64] Avoid preprocessing LSE builtins separately""

This reverts commit 03ebe1937192c247c4a7b8ec19dde2cf9845c914.

It's still breaking bots, e.g. http://green.lab.llvm.org/green/job/clang-stage1-RA/17027/console although it doesn't change any actual code.
The compile errors don't make much sense either. Revert for now.

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

3 years ago[AMDGPU] Make use of HasSMemRealTime predicate. NFC.
Jay Foad [Thu, 10 Dec 2020 16:49:48 +0000 (16:49 +0000)]
[AMDGPU] Make use of HasSMemRealTime predicate. NFC.

We have this subtarget feature so it makes sense to use it here. This is
NFC because it's always defined by default on GFX8+.

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

3 years ago[VE] Add logical mask intrinsic instructions
Kazushi (Jam) Marukawa [Mon, 7 Dec 2020 11:44:05 +0000 (20:44 +0900)]
[VE] Add logical mask intrinsic instructions

Add andm, orm, xorm, eqvm, nndm, negm, pcvm, lzvm, and tovm intrinsic
instructions, a few pseudo instructions to expand logical intrinsic
using VM512, a mechnism to expand such pseudo instructions, and
regression tests.  Also, assign vector mask types and vector mask
register classes correctly.  This is required to use VM512 registers
as function arguments.

Reviewed By: simoll

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

3 years ago[X86] LowerBUILD_VECTOR - track zero/nonzero elements with APInt masks. NFCI.
Simon Pilgrim [Mon, 14 Dec 2020 14:23:27 +0000 (14:23 +0000)]
[X86] LowerBUILD_VECTOR - track zero/nonzero elements with APInt masks. NFCI.

Prep work for undef/zero 'upper elements' handling as proposed in D92645.

3 years ago[libc++] [P1164] Add tests for create_directories. NFC.
Marek Kurdej [Mon, 14 Dec 2020 16:26:29 +0000 (17:26 +0100)]
[libc++] [P1164] Add tests for create_directories. NFC.

That's a follow-up patch after D92769.

Reviewed By: ldionne, #libc

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

3 years ago[VE] Correct addRegisterClass calls
Kazushi (Jam) Marukawa [Mon, 14 Dec 2020 14:59:16 +0000 (23:59 +0900)]
[VE] Correct addRegisterClass calls

Correct addRegisterClass calls for vector mask registers.

Reviewed By: simoll

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

3 years ago[flang][driver] Fix a small bug (auto vs auto&)
Andrzej Warzynski [Mon, 14 Dec 2020 16:07:24 +0000 (16:07 +0000)]
[flang][driver] Fix a small bug (auto vs auto&)

This bug hasn't affected us yet as our usage is too basic, i.e. we don't
rely on the defaults provided by `SetDefaultFortranOpts` just yet. This
will change shortly.

3 years ago[AIX] Fixed "comparison of unsigned expression >= 0 is always true" gcc warnings.
diggerlin [Mon, 14 Dec 2020 16:08:40 +0000 (11:08 -0500)]
[AIX] Fixed "comparison of unsigned expression >= 0 is always true" gcc warnings.

Summary:

fixed a  Fixed "comparison of unsigned expression >= 0 is always true" gcc warnings.
http://lab.llvm.org:8011/#/builders/5/builds/2407/steps/2/logs/stdio

the error caused by patch https://reviews.llvm.org/D92398

3 years agoReland [DebugInfo] Improve dbg preservation in LSR.
Markus Lavin [Mon, 14 Dec 2020 14:37:34 +0000 (15:37 +0100)]
Reland [DebugInfo] Improve dbg preservation in LSR.

Use SCEV to salvage additional @llvm.dbg.value that have turned into
referencing undef after transformation (and traditional
salvageDebugInfo).  Before rewrite (but after introduction of new
induction variables) use SCEV to compute an equivalent set of values for
each @llvm.dbg.value in the loop body (among the loop header PHI-nodes).
After rewrite (and dead PHI elimination) update those @llvm.dbg.value
now referencing undef by picking a remaining value from its equivalence
set.  Allow match with offset by inserting compensation code in the
DIExpression.

Fixes : PR38815

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

3 years agogenerate_header_tests.py: Sort the header files ASCIIbetically.
Arthur O'Dwyer [Fri, 11 Dec 2020 19:31:54 +0000 (14:31 -0500)]
generate_header_tests.py: Sort the header files ASCIIbetically.

Otherwise they come out in random (inode?) order.

Also `chmod +x` the generator, and re-run it. Somehow on Marek's
machine it produced \r\n line endings?! Open all files with
`newline='\n'` so that (if the Python3 docs are correct)
that won't happen again.

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

3 years ago[libc++] Fix some one-off typos in comments. NFCI.
Arthur O'Dwyer [Sat, 12 Dec 2020 16:57:32 +0000 (11:57 -0500)]
[libc++] Fix some one-off typos in comments. NFCI.

3 years ago[libc++] Remove __is_construct::__nat. NFCI.
Arthur O'Dwyer [Sat, 12 Dec 2020 16:58:26 +0000 (11:58 -0500)]
[libc++] Remove __is_construct::__nat. NFCI.

This type has been unused since commit 5b4cc84b87232e67afb63e2bad429b3211b26964.

3 years ago[libc++] s/insertible/insertable/g. NFCI.
Arthur O'Dwyer [Sat, 12 Dec 2020 16:43:15 +0000 (11:43 -0500)]
[libc++] s/insertible/insertable/g. NFCI.

3 years ago[libc++] s/Birdirectional/Bidirectional/g. NFCI.
Arthur O'Dwyer [Sat, 12 Dec 2020 16:37:36 +0000 (11:37 -0500)]
[libc++] s/Birdirectional/Bidirectional/g. NFCI.

3 years agoRe-apply "[CMake][compiler-rt][AArch64] Avoid preprocessing LSE builtins separately"
Raul Tambre [Mon, 14 Dec 2020 14:40:20 +0000 (16:40 +0200)]
Re-apply "[CMake][compiler-rt][AArch64] Avoid preprocessing LSE builtins separately"

aa772fc85e0f526615c78b9c3979c2be945a754c (D92530) has landed fixing Apple builds.
Previous quick-fix d9697c2e6b153ac7dc40a69450d9b672f71b1029 (D93198) included in this commit.

Invoking the preprocessor ourselves is fragile and would require us to replicate CMake's handling of definitions, compiler flags, etc for proper compatibility.
In my toolchain builds this notably resulted in a bunch of warnings from unused flags as my CMAKE_C_FLAGS includes CPU-specific optimization options.
Notably this part was already duplicating the logic for VISIBILITY_HIDDEN define.

Instead, symlink the files and set the proper set of defines on each.
This should also be faster as we avoid invoking the compiler multiple times.

Fixes https://llvm.org/PR48494

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

3 years ago[compiler-rt] [builtins] Make lse.S compile on Darwin
Kuba Mracek [Mon, 14 Dec 2020 14:36:41 +0000 (16:36 +0200)]
[compiler-rt] [builtins] Make lse.S compile on Darwin

Reviewed By: ilinpv

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

3 years ago[VPlan] Make VPWidenMemoryInstructionRecipe a VPDef.
Florian Hahn [Mon, 14 Dec 2020 14:13:59 +0000 (14:13 +0000)]
[VPlan] Make VPWidenMemoryInstructionRecipe a VPDef.

This patch updates VPWidenMemoryInstructionRecipe to use VPDef
to manage the value it produces instead of inheriting from VPValue.

Reviewed By: gilr

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

3 years ago[llvm-objdump] Use "--" for long options in --help text
David Spickett [Mon, 30 Nov 2020 11:32:46 +0000 (11:32 +0000)]
[llvm-objdump] Use "--" for long options in --help text

Single dash for these options is not recognised.

Changes found by running this on the --help output
and the user guide:
grep -e ' -[a-zA-Z]\{2,\}'

The user guide was updated in https://reviews.llvm.org/D92305
so no change there.

Reviewed By: jhenderson, MaskRay

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

3 years agoRevert "Consider reference, pointer, and pointer-to-member TemplateArguments to be...
Raphael Isemann [Mon, 14 Dec 2020 13:03:38 +0000 (14:03 +0100)]
Revert "Consider reference, pointer, and pointer-to-member TemplateArguments to be different if they have different types."

This reverts commit 05cdf4acf42acce9ddcff646a5d6ac666710fe6d. It breaks stage-2
compilation of LLVM, see https://reviews.llvm.org/D91488#2451534

3 years ago[SLP] Fix vector element size for the store chains
Anton Afanasyev [Sun, 13 Dec 2020 11:42:25 +0000 (14:42 +0300)]
[SLP] Fix vector element size for the store chains

Vector element size could be different for different store chains.
This patch prevents wrong computation of maximum number of elements
for that case.

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

3 years ago[TableGen] Don't dereference from dyn_cast<> - use cast<> instead. NFCI.
Simon Pilgrim [Mon, 14 Dec 2020 12:12:08 +0000 (12:12 +0000)]
[TableGen] Don't dereference from dyn_cast<> - use cast<> instead. NFCI.

dyn_cast<> can return null if the cast fails, resulting in null dereferences and static analyzer warnings. We should use cast<> instead.

3 years ago[IRCE] Add test case for PR48051
Simon Pilgrim [Mon, 14 Dec 2020 11:39:43 +0000 (11:39 +0000)]
[IRCE] Add test case for PR48051

3 years ago[SVE][CodeGen] Lower scalable floating-point vector reductions
Kerry McLaughlin [Mon, 14 Dec 2020 10:46:32 +0000 (10:46 +0000)]
[SVE][CodeGen] Lower scalable floating-point vector reductions

Changes in this patch:
-  Minor changes to the LowerVECREDUCE_SEQ_FADD function added by @cameron.mcinally
   to also work for scalable types
- Added TableGen patterns for FP reductions with unpacked types (nxv2f16, nxv4f16 & nxv2f32)
- Asserts added to expandFMINNUM_FMAXNUM & expandVecReduceSeq for scalable types

Reviewed By: cameron.mcinally

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

3 years ago[ARM] Improve handling of empty VPT blocks in tail predicated loops
David Green [Mon, 14 Dec 2020 11:17:01 +0000 (11:17 +0000)]
[ARM] Improve handling of empty VPT blocks in tail predicated loops

A vpt block that just contains either VPST;VCTP or VPT;VCTP, once the
VCTP is removed will become invalid. This fixed the first by removing
the now empty block and bails out for the second, as we have no simple
way of converting a VPT to a VCMP.

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

3 years ago[AMDGPU][NFC] Rename opsel/opsel_hi/neg_lo/neg_hi with suffix 0
Carl Ritson [Mon, 14 Dec 2020 11:01:49 +0000 (20:01 +0900)]
[AMDGPU][NFC] Rename opsel/opsel_hi/neg_lo/neg_hi with suffix 0

These parameters set a default value of 0, so I believe they
should include a 0 suffix. This allows for versions which do not
set a default value in future.

Reviewed By: foad

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

3 years ago[AMDGPU][NFC] Remove unused VOP3Mods0Clamp
Carl Ritson [Mon, 14 Dec 2020 11:00:53 +0000 (20:00 +0900)]
[AMDGPU][NFC] Remove unused VOP3Mods0Clamp

This is unused and the selection function does not exist.

Reviewed By: foad

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

3 years ago[XRay] Remove unnecessary <x86intrin.h> include
Raul Tambre [Mon, 14 Dec 2020 09:07:31 +0000 (11:07 +0200)]
[XRay] Remove unnecessary <x86intrin.h> include

It hasn't been necessary since commit 4d4ed0e288bf1f3a90fba6e5b56bc25e2fe961c3 (D43278).

Reviewed By: dberris

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

3 years ago[MLIR] Add atan and atan2 lowerings to CUDA intrinsics
Frederik Gossen [Fri, 11 Dec 2020 16:54:53 +0000 (17:54 +0100)]
[MLIR] Add atan and atan2 lowerings to CUDA intrinsics

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

3 years ago[AMDGPU] Mark amdgpu_gfx functions as module entry function
Sebastian Neubauer [Wed, 9 Dec 2020 16:25:53 +0000 (17:25 +0100)]
[AMDGPU] Mark amdgpu_gfx functions as module entry function

- Allows lds allocations
- Writes resource usage into COMPUTE_PGM_RSRC1 registers in PAL metadata

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

3 years ago[MLIR] Add lowerings for atan and atan2 to ROCDL intrinsics
Frederik Gossen [Fri, 11 Dec 2020 17:00:17 +0000 (18:00 +0100)]
[MLIR] Add lowerings for atan and atan2 to ROCDL intrinsics

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

3 years agoRevert "[CMake][compiler-rt][AArch64] Avoid preprocessing LSE builtins separately"
Raul Tambre [Mon, 14 Dec 2020 09:40:24 +0000 (11:40 +0200)]
Revert "[CMake][compiler-rt][AArch64] Avoid preprocessing LSE builtins separately"

Causing issues on Apple buildbots.
http://green.lab.llvm.org/green/job/clang-stage1-RA/17019/console

This reverts commit 33b740f8dc3496237619a7bc6722f23655cb1f94.
This reverts commit d9697c2e6b153ac7dc40a69450d9b672f71b1029.

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

3 years ago[compiler-rt][CMake] Define HAS_ASM_LSE on Apple if available
Raul Tambre [Mon, 14 Dec 2020 09:24:02 +0000 (11:24 +0200)]
[compiler-rt][CMake] Define HAS_ASM_LSE on Apple if available

Should hopefully fix 33b740f8dc3496237619a7bc6722f23655cb1f94 (D93178) failing on bots.

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

3 years ago[clang][cli] Port FileSystem options to new option parsing system
Jan Svoboda [Mon, 14 Dec 2020 09:03:18 +0000 (10:03 +0100)]
[clang][cli] Port FileSystem options to new option parsing system

Depends on D84187

Reviewed By: dexonsmith

Original patch by Daniel Grumberg.

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

3 years ago[llvm-readobj] - For SHT_REL relocations, don't display an addend.
Georgii Rymar [Thu, 10 Dec 2020 13:12:26 +0000 (16:12 +0300)]
[llvm-readobj] - For SHT_REL relocations, don't display an addend.

This is https://bugs.llvm.org/show_bug.cgi?id=44257.

In LLVM style we always print `0` as addend when dumping
SHT_REL relocations. It is confusing, this patch stops
printing it as the first comment on the bug page suggests.

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

3 years ago[clang][cli] Better defaults for MarshallingInfoString
Jan Svoboda [Mon, 14 Dec 2020 08:49:55 +0000 (09:49 +0100)]
[clang][cli] Better defaults for MarshallingInfoString

Depends on D84018

Reviewed By: Bigcheese

Original patch by Daniel Grumberg.

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

3 years ago[llvm-readelf] - Improve ELF type field dumping.
Georgii Rymar [Fri, 11 Dec 2020 09:46:30 +0000 (12:46 +0300)]
[llvm-readelf] - Improve ELF type field dumping.

This is related to https://bugs.llvm.org/show_bug.cgi?id=40868.

Currently we don't print `OS Specific`/``Processor Specific`/`<unknown>`
prefixes when dumping the ELF file type. This is not consistent
with GNU readelf. The patch fixes it.

Also, this patch removes the `types.test`, because we already have
`file-types.test`, which tests more cases and this patch revealed that
we have such a duplicate.

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

3 years ago[clang][cli] Port Preprocessor and PreprocessorOutput option flags to new option...
Jan Svoboda [Fri, 11 Dec 2020 15:19:03 +0000 (16:19 +0100)]
[clang][cli] Port Preprocessor and PreprocessorOutput option flags to new option parsing system

Depends on D83979

Reviewed By: dexonsmith

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