platform/upstream/llvm.git
3 years ago[IRBuilder] Add type argument to CreateMaskedLoad/Gather
Nikita Popov [Sat, 3 Jul 2021 12:57:41 +0000 (14:57 +0200)]
[IRBuilder] Add type argument to CreateMaskedLoad/Gather

Same as other CreateLoad-style APIs, these need an explicit type
argument to support opaque pointers.

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

3 years ago[llvm][iwyu] explicitly includes <functional> and <utility>
Christopher Di Bella [Sun, 4 Jul 2021 02:22:37 +0000 (02:22 +0000)]
[llvm][iwyu] explicitly includes <functional> and <utility>

Compiling LLVM with Clang modules and libc++ identified that
`Support/Printable.h` and `ADL/SmallVector.h` were using features that
live in these headers.

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

3 years ago[clangd][iwyu] explicitly includes `<atomic>`
Christopher Di Bella [Sun, 4 Jul 2021 02:17:43 +0000 (02:17 +0000)]
[clangd][iwyu] explicitly includes `<atomic>`

Compiling clangd with Clang modules and libc++ revealed that
`support/Threading.h` uses `std::atomic` but wasn't including the
correct header.

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

3 years ago[analyzer] Fix calculating offset for fields with an empty type
Georgy Komarov [Fri, 28 May 2021 08:58:50 +0000 (11:58 +0300)]
[analyzer] Fix calculating offset for fields with an empty type

Fix offset calculation routines in padding checker to avoid assertion
errors described in bugzilla issue 50426. The fields that are subojbects
of zero size, marked with [[no_unique_address]] or empty bitfields will
be excluded from padding calculation routines.

Reviewed By: NoQ

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

3 years ago[KnownBits] Merge const/non-const KnownBits::extractBits implementations. NFC.
Simon Pilgrim [Sat, 3 Jul 2021 18:00:25 +0000 (19:00 +0100)]
[KnownBits] Merge const/non-const KnownBits::extractBits implementations. NFC.

These are identical and can be just const.

3 years ago[X86][SSE] Add mulhu/mulhs constant folding tests
Simon Pilgrim [Sat, 3 Jul 2021 16:01:59 +0000 (17:01 +0100)]
[X86][SSE] Add mulhu/mulhs constant folding tests

These should be folded by D103323

3 years ago[SelectionDAG] Replace APInt.lshr().trunc() with APInt.extractBits() where possible...
Simon Pilgrim [Sat, 3 Jul 2021 15:32:41 +0000 (16:32 +0100)]
[SelectionDAG] Replace APInt.lshr().trunc() with APInt.extractBits() where possible. NFC.

This also allows us to use KnownBits::extractBits in one case.

3 years ago[SelectionDAG] Use KnownBits::insertBits instead of separate APInt::insertBits calls...
Simon Pilgrim [Sat, 3 Jul 2021 14:58:52 +0000 (15:58 +0100)]
[SelectionDAG] Use KnownBits::insertBits instead of separate APInt::insertBits calls. NFC.

3 years ago[IRBuilder] Avoid fetching pointer element type in some assertions
Nikita Popov [Sat, 3 Jul 2021 10:44:21 +0000 (12:44 +0200)]
[IRBuilder] Avoid fetching pointer element type in some assertions

Specifically the CreateMaskedStore and CreateMaskedScatter APIs.
The CreateMaskedLoad and CreateMaskedGather APIs will need an
additional type argument.

3 years ago[flang][driver] Add support for `--version` in the bash wrapper
Andrzej Warzynski [Fri, 2 Jul 2021 15:02:08 +0000 (16:02 +0100)]
[flang][driver] Add support for `--version` in the bash wrapper

The bash wrapper script, `flang`, calls `flang-new -fc1` under the hood,
which does not support `--version` (this is consistent with `clang -cc1
--version`). This change is needed for `flang --version` to work as
expected.

Note that `flang --version` (the Flang bash wrapper script for the
compiler driver) gives rather minimal output compared to `flang-new
--version` (the Flang compiler driver). As the wrapper script is just a
temporary solution for us, this should be sufficient.

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

3 years ago[SimplifyCFG] simplifyUnreachable(): erase instructions iff they are guaranteed to...
Roman Lebedev [Sat, 3 Jul 2021 07:45:44 +0000 (10:45 +0300)]
[SimplifyCFG] simplifyUnreachable(): erase instructions iff they are guaranteed to transfer execution to unreachable

This replaces the current ad-hoc implementation,
by syncing the code from InstCombine's implementation in `InstCombinerImpl::visitUnreachableInst()`,
with one exception that here in SimplifyCFG we are allowed to remove EH instructions.

Effectively, this now allows SimplifyCFG to remove calls (iff they won't throw and will return),
arithmetic/logic operations, etc.

Reviewed By: nikic

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

3 years ago[AArch64] Add S/UQXTRN tablegen patterns.
David Green [Sat, 3 Jul 2021 06:57:19 +0000 (07:57 +0100)]
[AArch64] Add S/UQXTRN tablegen patterns.

This adds simple patterns for signed and unsigned saturating extract
narrow instructions. They combine a min/max/truncate into a single
instruction, providing that the immediates on the min/max are correct
for the saturation type. This is just handled in tablegen with some
extra patterns.

v2i64->v2i32 is not handled here as the min/max nodes are not legal,
making the lowering quite different.

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

3 years ago[AIX] Adjust CSR order to avoid breaking ABI regarding traceback
Kai Luo [Sat, 3 Jul 2021 04:45:11 +0000 (04:45 +0000)]
[AIX] Adjust CSR order to avoid breaking ABI regarding traceback

Allocate non-volatile registers in order to be compatible with ABI, regarding gpr_save.

Quoted from https://www.ibm.com/docs/en/ssw_aix_72/assembler/assembler_pdf.pdf page55,
> The preferred method of using GPRs is to use the volatile registers first. Next, use the nonvolatile registers
> in descending order, starting with GPR31.

This patch is based on @jsji 's initial draft.

Tested on test-suite and SPEC, found no degradation.

Reviewed By: jsji, ZarkoCA, xingxue

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

3 years ago[SelectionDAG] Rename memory VT argument for getMaskedGather/getMaskedScatter from...
Craig Topper [Sat, 3 Jul 2021 00:36:27 +0000 (17:36 -0700)]
[SelectionDAG] Rename memory VT argument for getMaskedGather/getMaskedScatter from VT to MemVT.

Use getMemoryVT() in MGATHER/MSCATTER DAG combines instead of
using the passthru or store value VT for this argument.

3 years ago[ThinLTO] Respect ClearDSOLocalOnDeclarations for unimported functions
Fangrui Song [Sat, 3 Jul 2021 00:08:25 +0000 (17:08 -0700)]
[ThinLTO] Respect ClearDSOLocalOnDeclarations for unimported functions

D74751 added `ClearDSOLocalOnDeclarations` and dropped dso_local for
isDeclarationForLinker `GlobalValue`s. It missed a case for imported
declarations (`doImportAsDefinition` is false while `isPerformingImport` is
true). This can lead to a linker error for a default visibility symbol in
`ld.lld -shared`.

When `ClearDSOLocalOnDeclarations` is true, we check
`isPerformingImport() && !doImportAsDefinition(&GV)` along with
`GV.isDeclarationForLinker()`. The new condition checks an imported declaration.

This patch fixes a `LLVMPolly.so` link error using a trunk clang -DLLVM_ENABLE_LTO=Thin.

Reviewed By: tejohnson

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

3 years agoRevert "Create synthetic symbol names on demand to improve memory consumption and...
Jonas Devlieghere [Fri, 2 Jul 2021 23:17:25 +0000 (16:17 -0700)]
Revert "Create synthetic symbol names on demand to improve memory consumption and startup times."

This reverts commit c8164d0276b97679e80db01adc860271ab4a5d11 and
43f6dad2344247976d5777f56a1fc29e39c6c717 because it breaks
TestDyldTrieSymbols.py on GreenDragon.

3 years agoRevert "[DebugInfo] Enforce implicit constraints on `distinct` MDNodes"
Jonas Devlieghere [Fri, 2 Jul 2021 22:45:15 +0000 (15:45 -0700)]
Revert "[DebugInfo] Enforce implicit constraints on `distinct` MDNodes"

This reverts commit 8cd35ad854ab4458fd509447359066ea3578b494.

It breaks `TestMembersAndLocalsWithSameName.py` on GreenDragon and
Mikael Holmén points out in D104827 that bitcode files created with the
patch cannot be parsed with binaries built before it.

3 years ago[mlir][sparse] support for negation and subtractions
Aart Bik [Fri, 2 Jul 2021 19:26:18 +0000 (12:26 -0700)]
[mlir][sparse] support for negation and subtractions

This revision extends the sparse compiler support from fp/int addition and multiplication to fp/int negation and subtraction, thereby increasing the scope of sparse kernels that can be compiled.

Reviewed By: gussmith23

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

3 years agoLex: add a callback for `#pragma mark`
Saleem Abdulrasool [Fri, 2 Jul 2021 19:43:01 +0000 (19:43 +0000)]
Lex: add a callback for `#pragma mark`

Allow a preprocessor observer to be notified of mark pragmas.  Although
this does not impact code generation in any way, it is useful for other
clients, such as clangd, to be able to identify any marked regions.

Reviewed By: dgoldman

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

3 years ago[lldb] Update shebang in heap.py and crashlog.py
Jonas Devlieghere [Fri, 2 Jul 2021 22:33:46 +0000 (15:33 -0700)]
[lldb] Update shebang in heap.py and crashlog.py

3 years agoFix test so it doesn't try to write to the test directory, only to %t
David Blaikie [Fri, 2 Jul 2021 21:59:50 +0000 (14:59 -0700)]
Fix test so it doesn't try to write to the test directory, only to %t

3 years ago[mlir][Vector] NFC - Compress vector to outerproduct lowering.
Nicolas Vasilache [Fri, 2 Jul 2021 15:32:53 +0000 (15:32 +0000)]
[mlir][Vector] NFC - Compress vector to outerproduct lowering.

The implementation has become too unwieldy and cognitive overhead wins.
Instead compress the implementation in preparation for additional lowering paths.

This is a resubmit of https://reviews.llvm.org/D105359 without ordering ambiguities.

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

3 years agoName all DEATH tests using 'DeathTest' suffix.
Mitch Phillips [Fri, 2 Jul 2021 20:50:52 +0000 (13:50 -0700)]
Name all DEATH tests using 'DeathTest' suffix.

gtest highly recommends this prefix, and runs death tests first
(https://github.com/google/googletest/blob/master/docs/advanced.md#death-test-naming).
This may help with some spurious bot failures like
https://lab.llvm.org/buildbot/#/builders/169/builds/1290/steps/25/logs/stdio.

Reviewed By: cryptoad, vitalybuka

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

3 years ago[NFC][Codegen] Autogenerate check lines in PowerPC/2007-11-16-landingpad-split.ll
Roman Lebedev [Fri, 2 Jul 2021 20:29:18 +0000 (23:29 +0300)]
[NFC][Codegen] Autogenerate check lines in PowerPC/2007-11-16-landingpad-split.ll

It is being affected by an upcoming SimplifyCFG change.

3 years ago[NFC][Codegen] Tune a few tests to not end with a naked `unreachable` terminator
Roman Lebedev [Fri, 2 Jul 2021 20:14:21 +0000 (23:14 +0300)]
[NFC][Codegen] Tune a few tests to not end with a naked `unreachable` terminator

These rely on the fact that currently simplifycfg won't really propagate
said `unreachable`, but that is about to change.

3 years ago[lldb/test] Fix failure caused by synthetic symbol name refactoring
Med Ismail Bennani [Fri, 2 Jul 2021 20:01:21 +0000 (20:01 +0000)]
[lldb/test] Fix failure caused by synthetic symbol name refactoring

This patch fixes a failure in `TestFunctionStarts.py` that appeared
following a change of implementation for synthetic symbol names:

https://reviews.llvm.org/D105160

The failure is caused because the previously mentioned patch removes the
object file basename from the generated synthetic symbol names to allow
them to be shared in the constant string pool.

Hence, that last check is not necessary anymore.

rdar://80092322

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

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
3 years ago[GlobalISel] Clean up CombinerHelper::apply* functions to return void.
Amara Emerson [Fri, 2 Jul 2021 20:07:00 +0000 (13:07 -0700)]
[GlobalISel] Clean up CombinerHelper::apply* functions to return void.

For some reason we/I started writing these as returning bool when the return value
is actually ignored by the combiner.

3 years ago[NFC][CUDA] Fix order of round(f) definition in __clang_cuda_math.h for non-LP64.
Joachim Meyer [Fri, 2 Jul 2021 19:54:39 +0000 (21:54 +0200)]
[NFC][CUDA] Fix order of round(f) definition in __clang_cuda_math.h for non-LP64.

This broke ARM builds e.g.: https://lab.llvm.org/buildbot/#/builders/187/builds/212

3 years ago[NFC][SimplifyCFG] Autogenerate checklines in a few tests
Roman Lebedev [Fri, 2 Jul 2021 19:35:14 +0000 (22:35 +0300)]
[NFC][SimplifyCFG] Autogenerate checklines in a few tests

3 years ago[lldb] [gdb-remote client] Support switching PID along with TID
Michał Górny [Sun, 11 Apr 2021 11:04:54 +0000 (13:04 +0200)]
[lldb] [gdb-remote client] Support switching PID along with TID

Extend the SetCurrentThread() method to support specifying an alternate
PID to switch to.  This makes it possible to issue requests to forked
processes.

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

3 years ago[GlobalISel] Add re-association combine for G_PTR_ADD to allow better addressing...
Amara Emerson [Sun, 27 Jun 2021 06:36:46 +0000 (23:36 -0700)]
[GlobalISel] Add re-association combine for G_PTR_ADD to allow better addressing mode usage.

We're trying to match a few pointer computation patterns here for
re-association opportunities.
1) Isolating a constant operand to be on the RHS, e.g.:
   G_PTR_ADD(BASE, G_ADD(X, C)) -> G_PTR_ADD(G_PTR_ADD(BASE, X), C)

2) Folding two constants in each sub-tree as long as such folding
   doesn't break a legal addressing mode.
   G_PTR_ADD(G_PTR_ADD(BASE, C1), C2) -> G_PTR_ADD(BASE, C1+C2)

AArch64 code size improvements on CTMark with -Os:
Program              before  after   diff
 pairlocalalign      251048  251044 -0.0%
 consumer-typeset    421820  421812 -0.0%
 kc                  431348  431320 -0.0%
 SPASS               413404  413300 -0.0%
 clamscan            384396  384220 -0.0%
 tramp3d-v4          370640  370412 -0.1%
 lencod              432096  431772 -0.1%
 bullet              479400  478796 -0.1%
 sqlite3             288504  288072 -0.1%
 7zip-benchmark      573796  570768 -0.5%
 Geomean difference                 -0.1%

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

3 years ago[NFCI][SimplifyCFG] simplifyUnreachable(): Use poison constant to represent the resul...
Roman Lebedev [Fri, 2 Jul 2021 18:57:49 +0000 (21:57 +0300)]
[NFCI][SimplifyCFG] simplifyUnreachable(): Use poison constant to represent the result of unreachable instrs

Mimics similar change for InstCombine:
  ce192ced2b901be67444c481ab5ca0d731e6d982 / D104602

All these uses are in blocks that aren't reachable from function's entry,
and said blocks are removed by SimplifyCFG itself,
so we can't really test this change.

3 years ago[InstCombine] Don't combine PHI before catchswitch
Heejin Ahn [Thu, 1 Jul 2021 19:22:41 +0000 (12:22 -0700)]
[InstCombine] Don't combine PHI before catchswitch

This tries to bail out if the PHI is in a `catchswitch` BB in
InstCombine. A PHI cannot be combined into a non-PHI instruction if it
is in a `catchswitch` BB, because `catchswitch` BB cannot have any
non-PHI instruction other than `catchswitch` itself.

The given test case started crashing after D98058.

Reviewed By: lebedev.ri, rnk

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

3 years agoAdd C API files for the LLVM dialect
Adam Paszke [Fri, 2 Jul 2021 17:03:46 +0000 (10:03 -0700)]
Add C API files for the LLVM dialect

For now only expose a builder for the LLVM pointer type.

Reviewed By: jpienaar, ftynse

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

3 years ago[SimplifyCFG] Volatile memory operations do not trap
Roman Lebedev [Fri, 2 Jul 2021 18:47:12 +0000 (21:47 +0300)]
[SimplifyCFG] Volatile memory operations do not trap

Somewhat related to D105338.
While it is up for discussion whether or not volatile store traps,
so far there has been no complaints that volatile load/cmpxchg/atomicrmw also may trap.
And even if simplifycfg currently concervatively believes that to be the case,
instcombine does not: https://godbolt.org/z/5vhv4K5b8

Reviewed By: nikic

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

3 years ago[lldb] Replace default bodies of special member functions with = default;
Jonas Devlieghere [Fri, 2 Jul 2021 18:27:37 +0000 (11:27 -0700)]
[lldb] Replace default bodies of special member functions with = default;

Replace default bodies of special member functions with = default;

$ run-clang-tidy.py -header-filter='lldb' -checks='-*,modernize-use-equals-default' -fix ,

https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-equals-default.html

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

3 years ago[ms] [llvm-ml] Standardize blocking of lexical substitution
Eric Astor [Fri, 2 Jul 2021 18:17:15 +0000 (14:17 -0400)]
[ms] [llvm-ml] Standardize blocking of lexical substitution

In MASM, the ifdef family of directives treats its argument literally, without expanding it as a text macro. Add support for this, and also replace the special handling that was previously used for echo.

Reviewed By: thakis

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

3 years ago[mlir][Linalg] Fix incorrect logic in deciding when to fuse reshapes by linearization.
MaheshRavishankar [Fri, 2 Jul 2021 17:43:29 +0000 (10:43 -0700)]
[mlir][Linalg] Fix incorrect logic in deciding when to fuse reshapes by linearization.

Fusion by linearization should not happen when
- The reshape is expanding and it is a consumer
- The reshape is collapsing and is a producer.

The bug introduced in this logic by some recent refactoring resulted
in a crash.
To enforce this (negetive) use case, add a test that reproduces the
error and verifies the fix.

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

3 years ago[OpaquePtr] Add type parameter to emitLoadLinked
Krzysztof Parzyszek [Fri, 2 Jul 2021 15:20:41 +0000 (10:20 -0500)]
[OpaquePtr] Add type parameter to emitLoadLinked

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

3 years ago[Hexagon] Handle opaque pointers in vector combine
Krzysztof Parzyszek [Fri, 2 Jul 2021 14:39:56 +0000 (09:39 -0500)]
[Hexagon] Handle opaque pointers in vector combine

3 years ago[clang][emscripten] Reduce alignof long double from 16 to 8 bytes
Sam Clegg [Wed, 23 Jun 2021 19:02:32 +0000 (12:02 -0700)]
[clang][emscripten] Reduce alignof long double from 16 to 8 bytes

This means `max_align_t` is 8 bytes which also sets the alignment
malloc.  Since this is technically and ABI breaking change we have
limited to just the emscripten OS target.  It is also relatively low
import breakage since it will only effect the alignement of struct that
contai `long double`s (extremerly rare I imagine).

Emscripten's malloc implementation already use 8 byte alignement
(dlmalloc uses and alignement of 2*sizeof(void*) == 8 rather than
checking max_align_t) so will not be effected by this change.  By
bringing the ABI in line with the current malloc code this will fix
several issue we have seen in the wild.

See: https://github.com/emscripten-core/emscripten/pull/14456

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

3 years agoRevert "[clang-repl] Allow passing in code as positional arguments."
Mitch Phillips [Fri, 2 Jul 2021 17:54:20 +0000 (10:54 -0700)]
Revert "[clang-repl] Allow passing in code as positional arguments."

This reverts commit e386871e1d21cf206a1287356e88c5853563fc77.

Reason: Broke the ASan buildbots
(https://lab.llvm.org/buildbot/#/builders/5/builds/9291). See comments
on https://reviews.llvm.org/D104898 for more information.

3 years agoRevert "[mlir][Vector] NFC - Compress vector to outerproduct lowering."
Mehdi Amini [Fri, 2 Jul 2021 17:55:06 +0000 (17:55 +0000)]
Revert "[mlir][Vector] NFC - Compress vector to outerproduct lowering."

This reverts commit db188adfb12f6783c5419d5165a1123b9f5b56b0.

Breaks the GCC tests, likely because of some order of evaluation
difference between clang and gcc.

3 years ago[lld-macho] Ignore debug symbols while preparing relocations.
Vy Nguyen [Wed, 30 Jun 2021 16:50:24 +0000 (12:50 -0400)]
[lld-macho] Ignore debug symbols while preparing relocations.

Details: see https://bugs.llvm.org/show_bug.cgi?id=50812

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

3 years ago[X86] Modify LOOP*, HLT control flow attributes
Amir Ayupov [Fri, 2 Jul 2021 17:26:22 +0000 (10:26 -0700)]
[X86] Modify LOOP*, HLT control flow attributes

Add missing control flow attributes:
- LOOP*: isBranch, isTerminator
- HLT: isTerminator

This helps downstream disassemblers (such as BOLT) reconstruct the control
flow graph more accurately.

Reviewed By: craig.topper

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

3 years ago[SLP][NFC]Refactor findLaneForValue and make it static member, NFC, by
Alexey Bataev [Fri, 2 Jul 2021 17:12:41 +0000 (10:12 -0700)]
[SLP][NFC]Refactor findLaneForValue and make it static member, NFC, by
V.Dmitriev.

Reduces number of arguments

3 years ago[MLGO] Update Oz model url.
Jacob Hegna [Fri, 2 Jul 2021 17:28:25 +0000 (17:28 +0000)]
[MLGO] Update Oz model url.

3 years ago[Intrinsics] Make MemCpyInlineInst a MemCpyInst
Jon Roelofs [Wed, 30 Jun 2021 23:49:48 +0000 (16:49 -0700)]
[Intrinsics] Make MemCpyInlineInst a MemCpyInst

This opens up more optimization opportunities in passes that already handle MemCpyInst's.

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

3 years ago[libcxx][type_traits] remove `std::is_literal_type` and `std::result_of` for C++20
wmbat [Fri, 2 Jul 2021 17:08:36 +0000 (17:08 +0000)]
[libcxx][type_traits] remove `std::is_literal_type` and `std::result_of` for C++20

C++17 deprecated `std::is_literal_type` and `std::result_of`, C++20 removed them.

Implements parts of:
    * P0174R2 'Deprecating Vestigial Library Parts in C++17'.
    * P0619R4 'Reviewing Deprecated Facilities of C++17 for C++20'.

Reviewed By: ldionne, Mordante, Quuxplusone, #libc

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

3 years ago[gn build] Port 99f00635d7ac
LLVM GN Syncbot [Fri, 2 Jul 2021 17:03:49 +0000 (17:03 +0000)]
[gn build] Port 99f00635d7ac

3 years ago[NFC][OpenMP][CUDA] Add test for using `-x cuda -fopenmp`
Joachim Meyer [Thu, 1 Jul 2021 23:24:29 +0000 (01:24 +0200)]
[NFC][OpenMP][CUDA] Add test for using `-x cuda -fopenmp`

This adds a very basic test in `cuda_with_openmp.cu` that just checks whether the CUDA & OpenMP integrated headers do compile, when a CUDA file is compiled with OpenMP (CPU) enabled.
Thus this basically adds the missing test for https://reviews.llvm.org/D90415.

Reviewed By: jdoerfert

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

3 years agoUnpack the CostEstimate feature in ML inlining models.
Jacob Hegna [Thu, 10 Jun 2021 02:16:04 +0000 (02:16 +0000)]
Unpack the CostEstimate feature in ML inlining models.

This change yields an additional 2% size reduction on an internal search
binary, and an additional 0.5% size reduction on fuchsia.

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

3 years ago[libc] Make ULP error reflect the bit distance more closely.
Siva Chandra Reddy [Thu, 1 Jul 2021 20:41:05 +0000 (20:41 +0000)]
[libc] Make ULP error reflect the bit distance more closely.

Reviewed By: lntue

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

3 years agoRevert "Refactor mutation strategies into a standalone library"
Marco Vanotti [Fri, 2 Jul 2021 16:44:54 +0000 (09:44 -0700)]
Revert "Refactor mutation strategies into a standalone library"

This reverts commit 361f742f168de0f0f256802a329c19d081615d0d.

3 years ago[mlir][Vector] NFC - Compress vector to outerproduct lowering.
Nicolas Vasilache [Fri, 2 Jul 2021 15:32:53 +0000 (15:32 +0000)]
[mlir][Vector] NFC - Compress vector to outerproduct lowering.

The implementation has become too unwieldy and cognitive overhead wins.
Instead compress the implementation in preparation for additional lowering paths.

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

3 years ago[Libomptarget] Experimental Remote Plugin Fixes
Atmn Patel [Fri, 2 Jul 2021 00:00:02 +0000 (20:00 -0400)]
[Libomptarget] Experimental Remote Plugin Fixes

D97883 introduced a compile-time error in the experimental remote offloading
libomptarget plugin, this patch fixes it and resolves a number of
inconsistencies in the plugin as well:

1. Non-functional Asynchronous API
2. Unnecessarily verbose debug printing
3. Misc. code clean ups

This is not intended to make any functional changes to the plugin.

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

3 years ago[mlir][linalg][python] Add min operation in OpDSL.
Tobias Gysi [Fri, 2 Jul 2021 16:08:22 +0000 (16:08 +0000)]
[mlir][linalg][python] Add min operation in OpDSL.

Add the min operation to OpDSL and introduce a min pooling operation to test the implementation. The patch is a sibling of the max operation patch https://reviews.llvm.org/D105203 and the min operation is again lowered to a compare and select pair.

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

3 years ago[Bazel] Fix build for c0a6318d96
Geoffrey Martin-Noble [Fri, 2 Jul 2021 16:09:59 +0000 (09:09 -0700)]
[Bazel] Fix build for c0a6318d96

This adds explicit deps to satisfy layering_check

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

3 years agoRefactor mutation strategies into a standalone library
Aaron Green [Fri, 2 Jul 2021 16:15:17 +0000 (09:15 -0700)]
Refactor mutation strategies into a standalone library

This change introduces libMutagen/libclang_rt.mutagen.a as a subset of libFuzzer/libclang_rt.fuzzer.a. This library contains only the fuzzing strategies used by libFuzzer to produce new test inputs from provided inputs, dictionaries, and SanitizerCoverage feedback.

Most of this change is simply moving sections of code to one side or the other of the library boundary. The only meaningful new code is:

* The Mutagen.h interface and its implementation in Mutagen.cpp.
* The following methods in MutagenDispatcher.cpp:
  * UseCmp
  * UseMemmem
  * SetCustomMutator
  * SetCustomCrossOver
  * LateInitialize (similar to the MutationDispatcher's original constructor)
  * Mutate_AddWordFromTORC (uses callbacks instead of accessing TPC directly)
  * StartMutationSequence
  * MutationSequence
  * DictionaryEntrySequence
  * RecommendDictionary
  * RecommendDictionaryEntry
* FuzzerMutate.cpp (which now justs sets callbacks and handles printing)
* MutagenUnittest.cpp (which adds tests of Mutagen.h)

A note on performance: This change was tested with a 100 passes of test/fuzzer/LargeTest.cpp with 1000 runs per pass, both with and without the change. The running time distribution was qualitatively similar both with and without the change, and the average difference was within 30 microseconds (2.240 ms/run vs 2.212 ms/run, respectively). Both times were much higher than observed with the fully optimized system clang (~0.38 ms/run), most likely due to the combination of CMake "dev mode" settings (e.g. CMAKE_BUILD_TYPE="Debug", LLVM_ENABLE_LTO=OFF, etc.). The difference between the two versions built similarly seems to be "in the noise" and suggests no meaningful performance degradation.

Reviewed By: morehouse

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

3 years ago[gn build] Port bf64210fd88f
LLVM GN Syncbot [Fri, 2 Jul 2021 16:12:54 +0000 (16:12 +0000)]
[gn build] Port bf64210fd88f

3 years ago[AIX] Use AsmParser to do inline asm parsing
Jinsong Ji [Fri, 2 Jul 2021 15:46:49 +0000 (15:46 +0000)]
[AIX] Use AsmParser to do inline asm parsing

Add a flag so that target can choose to use AsmParser for parsing inline asm.
And set the flag by default for AIX.

-no-intergrated-as will override this default if specified explicitly.

Reviewed By: #powerpc, shchenz

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

3 years ago[AIX] Add dummy XCOFF MCAsmParserExtension
Jinsong Ji [Fri, 2 Jul 2021 15:46:26 +0000 (15:46 +0000)]
[AIX] Add dummy XCOFF MCAsmParserExtension

Implement XCOFFMCAsmParser so that we can use MC to parse inline asm.

The directives and storage mapping classes will be added later
iteratively.

Reviewed By: xgupta

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

3 years ago[AArch64] Neon saturated truncate tests. NFC
David Green [Fri, 2 Jul 2021 16:03:49 +0000 (17:03 +0100)]
[AArch64] Neon saturated truncate tests. NFC

3 years agoRefactor TensorExp parameters into a union
Gus Smith [Thu, 1 Jul 2021 21:45:18 +0000 (21:45 +0000)]
Refactor TensorExp parameters into a union

To make TensorExp clearer, this change refactors the e0/e1 fields into a union: e0/e1 for a binary op tensor expression, and tensor_num for a tensor-kinded tensor expression.

Reviewed By: aartbik

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

3 years agoReapply [clangd] Fix possible assertion fail in TUScheduler
Sam McCall [Fri, 2 Jul 2021 14:30:19 +0000 (16:30 +0200)]
Reapply [clangd] Fix possible assertion fail in TUScheduler

This reverts commit fff966b6855aee6fc0d0d4cd401cdd525a838572.

Seems I managed to delete a critical ! after running the tests :-\

3 years ago[NFC][InstCombine] visitUnreachableInst(): enhance comments somewhat
Roman Lebedev [Fri, 2 Jul 2021 14:28:33 +0000 (17:28 +0300)]
[NFC][InstCombine] visitUnreachableInst(): enhance comments somewhat

3 years agoRevert "[clangd] Unbreak mac build differently 0c96a92d8666b8"
Sam McCall [Fri, 2 Jul 2021 14:26:01 +0000 (16:26 +0200)]
Revert "[clangd] Unbreak mac build differently 0c96a92d8666b8"

This reverts commit 2f79acb7b701c41494abff588b5f03a74ea2e11d.

Should no longer be needed after 26e1553a107f52667be879e99739a4153f8799d8

3 years ago[mlir][Linalg] Add comprehensive bufferization support for TiledLoopOp (14/n)
Nicolas Vasilache [Fri, 2 Jul 2021 07:41:22 +0000 (07:41 +0000)]
[mlir][Linalg] Add comprehensive bufferization support for TiledLoopOp (14/n)

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

3 years ago[InstCombine] visitUnreachableInst(): iteratively erase instructions leading to unrea...
Roman Lebedev [Fri, 2 Jul 2021 14:18:48 +0000 (17:18 +0300)]
[InstCombine] visitUnreachableInst(): iteratively erase instructions leading to unreachable

In the original review D87149 it was mentioned that this approach was tried,
and it lead to infinite combine loops, but i'm not seeing anything like that now,
neither in the `check-llvm`, nor on some codebases i tried.

This is a recommit of d9d65527c289fb27a9f92f150723bbb3c58e413f,
which i immediately reverted because i have messed up something
during branch switch, and 597ccc92ce4b0f90883406d1f78d9d776f602804
accidentally ended up being pushed, which was very much not the intention.

Reviewed By: spatel

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

3 years agoRevert "https://godbolt.org/z/5vhv4K5b8"
Roman Lebedev [Fri, 2 Jul 2021 14:17:55 +0000 (17:17 +0300)]
Revert "https://godbolt.org/z/5vhv4K5b8"

This reverts commit 597ccc92ce4b0f90883406d1f78d9d776f602804.

3 years agoRevert "[NFCI][InstCombine] visitUnreachableInst(): iteratively erase instructions...
Roman Lebedev [Fri, 2 Jul 2021 14:17:47 +0000 (17:17 +0300)]
Revert "[NFCI][InstCombine] visitUnreachableInst(): iteratively erase instructions leading to unreachable"

This reverts commit d9d65527c289fb27a9f92f150723bbb3c58e413f.

3 years ago[NFCI][InstCombine] visitUnreachableInst(): iteratively erase instructions leading...
Roman Lebedev [Fri, 2 Jul 2021 14:16:33 +0000 (17:16 +0300)]
[NFCI][InstCombine] visitUnreachableInst(): iteratively erase instructions leading to unreachable

In the original review D87149 it was mentioned that this approach was tried,
and it lead to infinite combine loops, but i'm not seeing anything like that now,
neither in the `check-llvm`, nor on some codebases i tried.

Reviewed By: spatel

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

3 years agohttps://godbolt.org/z/5vhv4K5b8
Roman Lebedev [Fri, 2 Jul 2021 10:06:37 +0000 (13:06 +0300)]
https://godbolt.org/z/5vhv4K5b8

3 years agoRevert "[clangd] Fix possible assertion fail in TUScheduler"
Sam McCall [Fri, 2 Jul 2021 14:07:11 +0000 (16:07 +0200)]
Revert "[clangd] Fix possible assertion fail in TUScheduler"

This reverts commit 50566947e98ea845030cfa3b4c199fb9a2052d53.

3 years ago[clangd] Fix possible assertion fail in TUScheduler
Sam McCall [Fri, 2 Jul 2021 13:55:43 +0000 (15:55 +0200)]
[clangd] Fix possible assertion fail in TUScheduler

BlockUntilIdle is supposed to return false if it fails.
If an intermediate step fails to clear the queue, we shouldn't
charge ahead and assert on the state of the queue.

3 years ago[llvm-dwarfdump] Add comment saying where DumpDebugFrame comes from
Nico Weber [Fri, 2 Jul 2021 13:56:21 +0000 (09:56 -0400)]
[llvm-dwarfdump] Add comment saying where DumpDebugFrame comes from

3 years ago[X86][SLM] Keep similar scheduler costs types together. NFCI.
Simon Pilgrim [Fri, 2 Jul 2021 13:50:24 +0000 (14:50 +0100)]
[X86][SLM] Keep similar scheduler costs types together. NFCI.

The SLM model is inconsistent about where it kept its 'unsupported' schedule classes - better to keep them close to similar classes.

I'm not sure why some ymm classes are defined and others are unsupported though (but I haven't altered them) - the only SLM-like CPU supporting any ymm is KNL and that currently uses the HSW model.

3 years ago[CostModel][X86] Update comment describing source of costs - we now use llvm-mca...
Simon Pilgrim [Fri, 2 Jul 2021 13:29:18 +0000 (14:29 +0100)]
[CostModel][X86] Update comment describing source of costs - we now use llvm-mca more than IACA

3 years ago[CostModel][X86] Drop some hard coded fp<->int scalarization costs
Simon Pilgrim [Fri, 2 Jul 2021 13:27:27 +0000 (14:27 +0100)]
[CostModel][X86] Drop some hard coded fp<->int scalarization costs

Scalarization costs handling is a lot better now, and the hard coded costs were higher than the worse case numbers from the script in D103695

3 years ago[gn build] Port a92964779cb5
LLVM GN Syncbot [Fri, 2 Jul 2021 13:05:44 +0000 (13:05 +0000)]
[gn build] Port a92964779cb5

3 years agoRevert "[InstrProfiling] Use external weak reference for bias variable"
Nico Weber [Fri, 2 Jul 2021 13:05:12 +0000 (09:05 -0400)]
Revert "[InstrProfiling] Use external weak reference for bias variable"

This reverts commit 33a7b4d9d8e6a113108aa71ed78ca32a83c68523.
Breaks check-profile on macOS, see comments on https://reviews.llvm.org/D105176

3 years ago[Matrix] Fix crash during fusion if the same load is re-used.
Florian Hahn [Fri, 2 Jul 2021 12:48:05 +0000 (13:48 +0100)]
[Matrix] Fix crash during fusion if the same load is re-used.

This patch fixes a crash when the same load is used for both operands of
a fuseable multiply.

3 years ago[CostModel][X86] Find AVX conversion costs using legalized types if custom types...
Simon Pilgrim [Fri, 2 Jul 2021 12:41:27 +0000 (13:41 +0100)]
[CostModel][X86] Find AVX conversion costs using legalized types if custom types didn't match

Building on rG2a1ef8784ad9a, fallback to attempting to match against legalized types like we do for SSE targets.

3 years ago[lldb] [gdb-remote client] Refactor SetCurrentThread*()
Michał Górny [Wed, 14 Apr 2021 09:56:09 +0000 (11:56 +0200)]
[lldb] [gdb-remote client] Refactor SetCurrentThread*()

Refactor SetCurrentThread() and SetCurrentThreadForRun() to reduce code
duplication and simplify it.  Both methods now call common
SendSetCurrentThreadPacket() that implements the common protocol
exchange part (the only variable is sending `Hg` vs `Hc`) and returns
the selected TID.  The logic is rewritten to use a StreamString
instead of snprintf().

A side effect of the change is that thread-id sent is now zero-padded.
However, this should not have practical impact on the server as both
forms are equivalent.

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

3 years ago[CostModel][X86] Adjust uitofp(vXi64) SSE/AVX legalized costs based on llvm-mca reports.
Simon Pilgrim [Fri, 2 Jul 2021 12:07:07 +0000 (13:07 +0100)]
[CostModel][X86] Adjust uitofp(vXi64) SSE/AVX legalized costs based on llvm-mca reports.

Update v4i64 -> v4f32/v4f64 uitofp costs based on the worst case costs from the script in D103695.

Fixes a few regressions before we start adding AVX costs for legalized types.

3 years ago[SLP]Fix gathering of the scalars by not ignoring UndefValues.
Alexey Bataev [Thu, 1 Jul 2021 12:14:24 +0000 (05:14 -0700)]
[SLP]Fix gathering of the scalars by not ignoring UndefValues.

The compiler should not ignore UndefValue when gathering the scalars,
otherwise the resulting code may be less defined than the original one.
Also, grouped scalars to insert them at first to reduce the analysis in
further passes.

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

3 years ago[MachineCopyPropagation] Fix differences in code gen when compiling with -g
Alexandru Octavian Butiu [Fri, 2 Jul 2021 10:50:07 +0000 (18:50 +0800)]
[MachineCopyPropagation] Fix differences in code gen when compiling with -g

Fixes bugs [[ https://bugs.llvm.org/show_bug.cgi?id=50580 | 50580 ]] and [[ https://bugs.llvm.org/show_bug.cgi?id=49446 | 49446  ]]

When compiling with -g "DBG_VALUE <reg>"  instructions are added in the MIR, if such a instruction is inserted between instructions that use <reg> then MachineCopyPropagation invalidates <reg> , this causes some copies  to not be propagated and causes differences in code generation (ex bugs 50580 and 49446 ).  DBG_VALUE instructions should be ignored  since they don't actually modify the register.

Reviewed By: lkail

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

3 years agoPlace the BlockAddress type in the address space of the containing function
Alex Richardson [Fri, 2 Jul 2021 10:25:43 +0000 (11:25 +0100)]
Place the BlockAddress type in the address space of the containing function

While this should not matter for most architectures (where the program
address space is 0), it is important for CHERI (and therefore Arm Morello).
We use address space 200 for all of our code pointers and without this
change we assert in the SelectionDAG handling of BlockAddress nodes.

It is also useful for AVR: previously programs targeting
AVR that attempt to read their own machine code
via a pointer to a label would instead read from RAM
using a pointer relative to the the start of program flash.

Reviewed By: dylanmckay, theraven
Differential Revision: https://reviews.llvm.org/D48803

3 years agoAdd LogOp to Complex dialect.
Adrian Kuegel [Fri, 2 Jul 2021 09:03:19 +0000 (11:03 +0200)]
Add LogOp to Complex dialect.

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

3 years ago[NFC] Fix typo in comment
Sven van Haastregt [Fri, 2 Jul 2021 10:39:17 +0000 (11:39 +0100)]
[NFC] Fix typo in comment

Reported-by: Marco Cali <marco.cali@arm.com>
3 years ago[AArch64] Use custom lowering for fp16 vector copysign.
Florian Hahn [Fri, 2 Jul 2021 09:03:22 +0000 (10:03 +0100)]
[AArch64] Use custom lowering for fp16 vector copysign.

The custom copysign lowering already supports fp16. Use it.

Reviewed By: dmgreen

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

3 years ago[NFC][SimplifyCFG] Autogenerate checklines in trapping-load-unreachable.ll test
Roman Lebedev [Fri, 2 Jul 2021 09:59:01 +0000 (12:59 +0300)]
[NFC][SimplifyCFG] Autogenerate checklines in trapping-load-unreachable.ll test

3 years ago[lldb] [test] Add missing category to test_detach_current
Michał Górny [Fri, 2 Jul 2021 09:44:41 +0000 (11:44 +0200)]
[lldb] [test] Add missing category to test_detach_current

3 years ago[Matrix] Hoist address computation before multiply to enable fusion.
Florian Hahn [Fri, 2 Jul 2021 08:42:47 +0000 (09:42 +0100)]
[Matrix] Hoist address computation before multiply to enable fusion.

If the store address does not dominate the matrix multiply, try to hoist
address computation instructions without side-effects and/or memory
reads before the multiply, to allow fusion.

Reviewed By: thegameg

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

3 years agoRevert "[WebAssembly] Implementation of global.get/set for reftypes in LLVM IR"
Roman Lebedev [Fri, 2 Jul 2021 08:48:44 +0000 (11:48 +0300)]
Revert "[WebAssembly] Implementation of global.get/set for reftypes in LLVM IR"

This reverts commit 4facbf213c51e4add2e8c19b08d5e58ad71c72de.

```
********************
FAIL: LLVM :: CodeGen/WebAssembly/funcref-call.ll (44466 of 44468)
******************** TEST 'LLVM :: CodeGen/WebAssembly/funcref-call.ll' FAILED ********************
Script:
--
: 'RUN: at line 1';   /builddirs/llvm-project/build-Clang12/bin/llc < /repositories/llvm-project/llvm/test/CodeGen/WebAssembly/funcref-call.ll --mtriple=wasm32-unknown-unknown -asm-verbose=false -mattr=+reference-types | /builddirs/llvm-project/build-Clang12/bin/FileCheck /repositories/llvm-project/llvm/test/CodeGen/WebAssembly/funcref-call.ll
--
Exit Code: 2

Command Output (stderr):
--
llc: /repositories/llvm-project/llvm/include/llvm/Support/LowLevelTypeImpl.h:44: static llvm::LLT llvm::LLT::scalar(unsigned int): Assertion `SizeInBits > 0 && "invalid scalar size"' failed.

```

3 years ago[lldb] [gdb-remote server] Support selecting process via Hg
Michał Górny [Sun, 11 Apr 2021 10:31:06 +0000 (12:31 +0200)]
[lldb] [gdb-remote server] Support selecting process via Hg

Support using the extended thread-id syntax with Hg packet to select
a subprocess.  This makes it possible to start providing support for
running some of the debugger packets against another subprocesses.

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

3 years ago[clang][AST] Add support for BindingDecl to ASTImporter.
Balázs Kéri [Fri, 2 Jul 2021 07:08:54 +0000 (09:08 +0200)]
[clang][AST] Add support for BindingDecl to ASTImporter.

Reviewed By: martong

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

3 years ago[clangd] CMake: express -Iclangd/ at top level and inherit
Sam McCall [Fri, 2 Jul 2021 07:48:58 +0000 (09:48 +0200)]
[clangd] CMake: express -Iclangd/ at top level and inherit

For files directly under clangd/, -Iclang-tools-extra/clangd (and the
equivalent for generated files) are not required, as CMake/the compiler puts
these directories on the include path by default.

However this means each subdirectory needs to
include_directories(.. ${CMAKE_CURRENT_BINARY_DIR}/..) etc, and this
proved annoying and error-prone to maintain and debug.

Since include_directories is inherited by subdirectories, we just
configure this explicitly at the top level instead.

3 years ago[WebAssembly] Implementation of global.get/set for reftypes in LLVM IR
Paulo Matos [Thu, 10 Jun 2021 08:02:10 +0000 (10:02 +0200)]
[WebAssembly] Implementation of global.get/set for reftypes in LLVM IR

Reland of 31859f896.

This change implements new DAG notes GLOBAL_GET/GLOBAL_SET, and
lowering methods for load and stores of reference types from IR
globals. Once the lowering creates the new nodes, tablegen pattern
matches those and converts them to Wasm global.get/set.

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

3 years ago[mlir][linalg][python] Introduce python integration test folder.
Tobias Gysi [Fri, 2 Jul 2021 07:20:09 +0000 (07:20 +0000)]
[mlir][linalg][python] Introduce python integration test folder.

Introduce an integration test folder in the test/python subfolder and move the opsrun.py test into the newly created folder. The test verifies named operations end-to-end using both the yaml and the python path.

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