platform/upstream/llvm.git
3 years ago[libc] Clean up Windows macros
Caitlyn Cano [Fri, 23 Jul 2021 20:39:09 +0000 (20:39 +0000)]
[libc] Clean up Windows macros

This clean-up removes checks for _WIN64, as the _WIN32 macro returns 1
whenever the compilation targe is 32- or 64-bit ARM.

Reviewed By: aeubanks

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

3 years ago[lld/mac] Fix start-stop.s test with expensive checks enabled
Nico Weber [Fri, 23 Jul 2021 20:54:19 +0000 (16:54 -0400)]
[lld/mac] Fix start-stop.s test with expensive checks enabled

See e.g. https://lab.llvm.org/buildbot/#/builders/16/builds/14317
Not 100% sure why this fails yet, but this fixes it. Let's get
the bots green again first :)

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

3 years ago[OpenMP] Fix bug 50022
Shilei Tian [Fri, 23 Jul 2021 20:53:56 +0000 (16:53 -0400)]
[OpenMP] Fix bug 50022

Bug 50022 [0] reports target nowait fails in certain case, which is added in this
patch. The root cause of the failure is, when the second task is created, its
parent's `td_incomplete_child_tasks` will not be incremented because there is no
parallel region here thus its team is serialized. Therefore, when the initial
thread is waiting for its unfinished children tasks, it thought there is only
one, the first task, because it is hidden helper task, so it is tracked. The
second task will only be pushed to the queue when the first task is finished.
However, when the first task finishes, it first decrements the counter of its
parent, and then release dependences. Once the counter is decremented, the thread
will move on because its counter is reset, but actually, the second task has not
been executed at all. As a result, since in this case, the main function finishes,
then `libomp` starts to destroy. When the second task is pushed somewhere, all
some of the structures might already have already been destroyed, then anything
could happen.

This patch simply moves `__kmp_release_deps` ahead of decrement of the counter.
In this way, we can make sure that the initial thread is aware of the existence
of another task(s) so it will not move on. In addition, in order to tackle
dependence chain starting with hidden helper thread, when hidden helper task is
encountered, we force the task to release dependences.

Reference:
[0] https://bugs.llvm.org/show_bug.cgi?id=50022

Reviewed By: AndreyChurbanov

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

3 years ago[Libomptarget] Add unroll flag to shared variables loop
Joseph Huber [Fri, 23 Jul 2021 18:50:25 +0000 (14:50 -0400)]
[Libomptarget] Add unroll flag to shared variables loop

Unrolling this loop provides better performance in practice because it is
executed on the device and is likely to be very small.

Reviewed By: tianshilei1992

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

3 years ago[compiler-rt][NFC] add debugging options to iossim_run
Emily Shi [Fri, 23 Jul 2021 19:21:17 +0000 (12:21 -0700)]
[compiler-rt][NFC] add debugging options to iossim_run

Add the ability to:
1. tell simctl to wait for debugger when spawning process
2. print the command that is called to launch the process

Reviewed By: delcypher

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

3 years ago[MLIR][NFC] Minor cleanup in liveness.
Rahul Joshi [Fri, 23 Jul 2021 20:12:31 +0000 (13:12 -0700)]
[MLIR][NFC] Minor cleanup in liveness.

- Rename isLastUse to isDeadAfter to reflect what the function does.
- Avoid a second walk over all operations in BlockInfoBuilder constructor.
- use std::move() to save the new in set.

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

3 years ago[NFC][compiler-rt] tidy up some whitespace in lit config
Emily Shi [Fri, 23 Jul 2021 20:19:54 +0000 (13:19 -0700)]
[NFC][compiler-rt] tidy up some whitespace in lit config

3 years ago[MergeICmps] Relax sinking check
Nikita Popov [Thu, 22 Jul 2021 20:20:25 +0000 (22:20 +0200)]
[MergeICmps] Relax sinking check

The check for sinking instructions past the load + cmp sequence
currently checks for side-effects, which includes writing to memory
and unwinding. However, I don't believe we care about sinking the
instructions past an unwind (as they don't have any side-effects
themselves).

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

3 years ago[OpenMP][Offloading] Fix data race in data mapping by using two locks
Shilei Tian [Fri, 23 Jul 2021 20:10:42 +0000 (16:10 -0400)]
[OpenMP][Offloading] Fix data race in data mapping by using two locks

This patch tries to partially fix one of the two data race issues reported in
[1] by introducing a per-entry mutex. Additional discussion can also be found in
D104418, which will also be refined to fix another data race problem.

Here is how it works. Like before, `DataMapMtx` is still being used for mapping
table lookup and update. In any case, we will get a table entry. If we need to
make a data transfer (update the data on the device), we need to lock the entry
right before releasing `DataMapMtx`, and the issue of data transfer should be
after releasing `DataMapMtx`, and the entry is unlocked afterwards. This can
guarantee that: 1) issue of data movement is not in critical region, which will
not affect performance too much, and also will not affect other threads that don't
touch the same entry; 2) if another thread accesses the same entry, the state of
data movement is consistent (which requires that a thread must first get the
update lock before getting data movement information).

For a target that doesn't support async data transfer, issue of data movement is
data transfer. This two-lock design can potentially improve concurrency compared
with the design that guards data movement with `DataMapMtx` as well. For a target
that supports async data movement, we could simply attach the event between the
issue of data movement and unlock the entry. For a thread that wants to get the
event, it must first get the lock. This can also get rid of the busy wait until
the event pointer is valid.

Reference:
[1] https://bugs.llvm.org/show_bug.cgi?id=49940

Reviewed By: grokos

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

3 years ago[CMake] Add version to libLLVM also on non-UNIX
Martin Storsjö [Fri, 23 Jul 2021 19:52:07 +0000 (22:52 +0300)]
[CMake] Add version to libLLVM also on non-UNIX

As discussed in https://reviews.llvm.org/D87521

llvm-config expects versioned library regardless of platform.

Reviewed By: mstorsjo

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

3 years ago[llvm-rc] Allow dashes as part of resource name strings
Martin Storsjö [Thu, 22 Jul 2021 21:36:05 +0000 (00:36 +0300)]
[llvm-rc] Allow dashes as part of resource name strings

This matches what MS rc.exe allows in practice. I'm not aware of
any legal syntax case that are broken by allowing dashes as part
of what the tokenizer considers an Identifier - but I'm not
very well versed in the RC syntax either, can @amccarth think of
any case that would be broken by this?

This fixes downstream bug
https://github.com/msys2/MINGW-packages/issues/9180.

Additionally, rc.exe allows such resource name strings to be surrounded
by quotes, ending up with e.g.

    Resource name (string): "QUOTEDNAME"

(i.e., the quotes end up as part of the string), which llvm-rc doesn't
support yet either. (I'm not aware of such cases in the wild though,
but resource string names with dashes do exist.)

This also allows including files with unquoted paths, with filenames
containing dashes (which fixes
https://github.com/msys2/MINGW-packages/issues/9130, which has been
worked around differently so far).

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

3 years ago[lld/mac] Implement support for section$start and section$ end symbols
Nico Weber [Thu, 15 Jul 2021 16:54:42 +0000 (12:54 -0400)]
[lld/mac] Implement support for section$start and section$ end symbols

With this, libclang_rt.profile_osx.a can be linked, that is coverage
and PGO-instrumented builds should now work with lld.

section$start and section$end symbols can create non-existing sections.
They're also undefined symbols that are only magic if there isn't a
regular symbol with their name, which means the need to be handled
in treatUndefined() instead of just looping over all existing
sections and adding start and end symbols like the ELF port does.

To represent the actual symbols, this uses absolute symbols that
get their value updated once an output section is layed out.

segment$start and segment$end are still missing for now, but they produce a
nicer error message after this patch.

Main part of PR50760.

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

3 years ago[libunwind] Allow restoring SP while unwinding.
Marco Vanotti [Fri, 23 Jul 2021 00:58:23 +0000 (17:58 -0700)]
[libunwind] Allow restoring SP while unwinding.

This commit modifies stepWithDwarf allowing for CFI directives to
specify the value of the stack pointer.

Previously, the SP would be unconditionally set to the CFA, because it
(wrongly) stated that the CFA is the stack pointer at the call site of a
function, but that is not always true.

One situation in which that is false, is for example if you have
switched stacks. In that case if you set the CFA to the SP before
switching the stack, the CFA would be far away from where the current
call frame is located.

The CFA always points to the current call frame, and that call frame
could have a CFI directive that specifies how to restore the stack
pointer. If not, it is OK to fallback and set the SP = CFA.

This change sets SP = CFA before restoring the registers during
unwinding, allowing the stack frame to be restored with a value
different than the CFA.

Reviewed By: #libunwind, phosek

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

3 years agoRevert "[FPEnv][InstSimplify] Enable more folds for constrained fadd"
Kevin P. Neal [Fri, 23 Jul 2021 19:09:05 +0000 (15:09 -0400)]
Revert "[FPEnv][InstSimplify] Enable more folds for constrained fadd"

Build bots have started failing.

This reverts commit 64c2b2c69d61dbb6459037a7bfddf29e1f280c8f.

3 years ago[FPEnv][InstSimplify] Enable more folds for constrained fadd
Kevin P. Neal [Fri, 23 Jul 2021 18:56:41 +0000 (14:56 -0400)]
[FPEnv][InstSimplify] Enable more folds for constrained fadd

Precommit tests.

3 years ago[llvm][NFC] Fix typos in Errc.h description
Cyndy Ishida [Fri, 23 Jul 2021 18:54:49 +0000 (11:54 -0700)]
[llvm][NFC] Fix typos in Errc.h description

3 years agoRevert "Delete PrintingPolicy's copy constructor/operator."
Erich Keane [Fri, 23 Jul 2021 18:24:30 +0000 (11:24 -0700)]
Revert "Delete PrintingPolicy's copy constructor/operator."

My test that showed we don't copy it was wrong!

This reverts commit 68ef916659b9cd4127276f9502fc2870ca6cfdea.

3 years agoDelete PrintingPolicy's copy constructor/operator.
Erich Keane [Fri, 23 Jul 2021 18:22:52 +0000 (11:22 -0700)]
Delete PrintingPolicy's copy constructor/operator.

This type is 'fat' now thanks to the callbacks, so it should never be
copied as far as I know.  Delete the copy operations so that we don't do
so accidentially.

3 years ago[NFC][MLGO] Just use the underlying protobuf object for logging
Mircea Trofin [Thu, 22 Jul 2021 19:45:32 +0000 (12:45 -0700)]
[NFC][MLGO] Just use the underlying protobuf object for logging

Avoid buffering just to copy the buffered data, in 'development
mode', when logging. Instead, just populate the underlying protobuf.

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

3 years ago[mlir][linalg] Add pooling_nchw_max, conv_2d_nchw as yaml ops.
Yi Zhang [Fri, 23 Jul 2021 16:15:21 +0000 (16:15 +0000)]
[mlir][linalg] Add pooling_nchw_max, conv_2d_nchw as yaml ops.

- Add pooling_nchw_max.
- Move conv_2d_nchw to yaml ops and add strides and dilation attributes.

Reviewed By: gysit

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

3 years ago[AbstractAttributor] Refine logic to indicate pessimistic fixed point when folding...
Shilei Tian [Fri, 23 Jul 2021 17:36:27 +0000 (13:36 -0400)]
[AbstractAttributor] Refine logic to indicate pessimistic fixed point when folding `__kmpc_is_spmd_exec_mode`

Since we are using assumed information now, the logic should be refined to avoid
unncessary assertion.

Reviewed By: jdoerfert

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

3 years ago[libc] add option to use SCUDO as the allocator
Michael Jones [Wed, 21 Jul 2021 22:17:15 +0000 (22:17 +0000)]
[libc] add option to use SCUDO as the allocator

This patch adds LLVM_LIBC_INCLUDE_SCUDO as a flag. When enabled it
should link in the standalone version of SCUDO as the allocator for LLVM
libc.

Reviewed By: sivachandra

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

3 years agoRevert "Update isl to isl-0.24-69-g54aac5ac"
Riccardo Mori [Fri, 23 Jul 2021 17:06:52 +0000 (19:06 +0200)]
Revert "Update isl to isl-0.24-69-g54aac5ac"

This reverts commit 13f95cc3d10d9884acd2dbfc112e3c7079403c0a.

The commit makes some polly tests failing

3 years agoRevert "[clang] -falign-loops="
Fangrui Song [Fri, 23 Jul 2021 16:58:35 +0000 (09:58 -0700)]
Revert "[clang] -falign-loops="

This reverts commit 42896eeed9e3d12e7e38217a0d7e35b9736451ac.

Unfinished. Accidentally pushed when reverting a clangd commit.

3 years agoRevert D106562 "[clangd] Get rid of arg adjusters in CommandMangler"
Fangrui Song [Fri, 23 Jul 2021 16:50:43 +0000 (09:50 -0700)]
Revert D106562 "[clangd] Get rid of arg adjusters in CommandMangler"

This reverts commit 1c0d0085bcaaf27cc8d9492eb3c5c05058e54b8e.

This commit made unittest BuildCompilerInvocation.DropsPlugins crash.

3 years ago[clang] -falign-loops=
Fangrui Song [Fri, 23 Jul 2021 16:38:18 +0000 (09:38 -0700)]
[clang] -falign-loops=

3 years agoUpdate isl to isl-0.24-69-g54aac5ac
Riccardo Mori [Fri, 23 Jul 2021 16:46:48 +0000 (18:46 +0200)]
Update isl to isl-0.24-69-g54aac5ac

This is needed for having the functions isl_{set,map}_n_basic_{set,map}
exported to the C++ interface

3 years ago[libcxx][nfc] Cleanup libc++ specific tests.
Mark de Wever [Fri, 23 Jul 2021 15:19:34 +0000 (17:19 +0200)]
[libcxx][nfc] Cleanup libc++ specific tests.

Move the tests to libcxx so they no longer need `REQUIRES: libc++`.
Verify tests don't need `REQUIRES: libc++`.

Reviewed By: #libc, ldionne

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

3 years ago[RISCV] Add a test showing an incorrect vsetvli insertion
Fraser Cormack [Fri, 23 Jul 2021 16:16:08 +0000 (09:16 -0700)]
[RISCV] Add a test showing an incorrect vsetvli insertion

This patch adds a reduced test case which identifies an illegal vsetvli
inserted by the compiler. The compiler emits a vsetvli which is intended
to preserve VL with the SEW/LMUL ratio e32/m1 when in fact the VL could
have been set by e64/m2 in a predecessor block.

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

3 years agoRevert "[clangd] Canonicalize compile flags before applying edits"
Kadir Cetinkaya [Fri, 23 Jul 2021 16:20:45 +0000 (18:20 +0200)]
Revert "[clangd] Canonicalize compile flags before applying edits"

This reverts commit 7cc8a8e3849dc4044cc799e2c1f6cc241b851b70.

3 years ago[gn build] Port e5d8b93e5a25
LLVM GN Syncbot [Fri, 23 Jul 2021 16:13:25 +0000 (16:13 +0000)]
[gn build] Port e5d8b93e5a25

3 years ago[gn build] Port 0ad562b48bfd
LLVM GN Syncbot [Fri, 23 Jul 2021 16:13:24 +0000 (16:13 +0000)]
[gn build] Port 0ad562b48bfd

3 years ago[RISCV] Avoid using x0,x0 vsetvli for vmv.x.s and vfmv.f.s unless we know the sew...
Craig Topper [Fri, 23 Jul 2021 16:05:23 +0000 (09:05 -0700)]
[RISCV] Avoid using x0,x0 vsetvli for vmv.x.s and vfmv.f.s unless we know the sew/lmul ratio is constant.

Since we're changing VTYPE, we may change VLMAX which could
invalidate the previous VL. If we can't tell if it is safe we
should use an AVL of 1 instead of keeping the old VL.

This is a quick fix. We may want to thread VL to the pseudo
instruction instead of making up a value. That will require ISD
opcode changes and changes to the C intrinsic interface.

This fixes the issue raised in D106286.

Reviewed By: frasercrmck

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

3 years ago[libcxx][nfc] Global `constexpr friend` -> `friend constexpr`.
zoecarver [Fri, 23 Jul 2021 16:08:18 +0000 (09:08 -0700)]
[libcxx][nfc] Global `constexpr friend` -> `friend constexpr`.

3 years ago[libcxx][ranges] Add `ranges::common_view`.
zoecarver [Fri, 9 Jul 2021 17:09:31 +0000 (10:09 -0700)]
[libcxx][ranges] Add `ranges::common_view`.

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

3 years ago[libc] Add option to run specific tests
Caitlyn Cano [Mon, 12 Jul 2021 20:32:51 +0000 (20:32 +0000)]
[libc] Add option to run specific tests

This addition reads command line input to run specific single tests
within a larger call to run all the tests for a particular function.
When the user adds a second argument to the command line, the code skips
all the tests that don't match the user's specified binary. If the user
doesn't specify a test correctly and/or no tests are run, a failure
message prints.

Reviewed By: sivachandra, aeubanks

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

3 years ago[X86] Fix a bug in TEST with immediate creation
Craig Topper [Fri, 23 Jul 2021 06:25:33 +0000 (23:25 -0700)]
[X86] Fix a bug in TEST with immediate creation

This code tries to form a TEST from CMP+AND with an optional
truncate in between. If we looked through the truncate, we may
have extra bits in the AND mask that shouldn't participate in
the checks. Normally SimplifyDemendedBits takes care of this, but
the AND may have another user. So manually mask out any extra bits.

Fixes PR51175.

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

3 years agoRevert "[clangd] Adjust compile flags to contain only the requested file as input"
Kadir Cetinkaya [Fri, 23 Jul 2021 15:57:52 +0000 (17:57 +0200)]
Revert "[clangd] Adjust compile flags to contain only the requested file as input"

This reverts commit ba5dd945ad9124f24452987be64040a6ea6cd25e.

3 years ago[JITLink] Add riscv.cpp
luxufan [Fri, 23 Jul 2021 15:52:59 +0000 (23:52 +0800)]
[JITLink] Add riscv.cpp

3 years ago[lld-macho][nfc] Add test for resolution of bitcode symbols
Jez Ng [Fri, 23 Jul 2021 15:33:33 +0000 (11:33 -0400)]
[lld-macho][nfc] Add test for resolution of bitcode symbols

We lacked a test for bitcode symbol precedence. We assumed that
they followed the same rules as their regular symbol counterparts, but
never had a test to verify that we were matching ld64's behavior. It
turns out that we were largely correct, though we deviate from ld64 when
there are bitcode and non-bitcode symbols of the same name. The test
added in this diff both verifies our behavior and documents the
differences.

Reviewed By: #lld-macho, thakis

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

3 years ago[lld-macho][nfc] Fix test to reflect that symbol attributes don't matter within an...
Jez Ng [Fri, 23 Jul 2021 15:33:30 +0000 (11:33 -0400)]
[lld-macho][nfc] Fix test to reflect that symbol attributes don't matter within an archive

We had a comment that claimed that defined symbols had priority
over common symbols if they occurred in the same archive. In fact, they
appear to have equal precedence. Our implementation already does this,
so I'm just updating the test comment. Also added a few other test
comments along the way for readability.

Reviewed By: #lld-macho, thakis

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

3 years ago[lld-macho] ICF: Do more work in equalsConstant, less in equalsVariable
Jez Ng [Fri, 23 Jul 2021 15:33:28 +0000 (11:33 -0400)]
[lld-macho] ICF: Do more work in equalsConstant, less in equalsVariable

In particular, relocations to absolute symbols or literal sections can
be handled in equalsConstant(), since their output addresses will not
change across each iteration of ICF. Offsets and addends can also be
dealt with entirely in equalsConstant(), making the code somewhat easier
to reason about. Only ConcatInputSections need to be handled in
equalsVariable().

LLD-ELF's implementation takes a similar approach.

Although this should make ICF do less work, in practice it seems like
there is no stat sig difference in time taken when linking
chromium_framework.

This refactor is motivated by an upcoming diff which improves ICF's handling of
addends.

Reviewed By: #lld-macho, gkm

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

3 years ago[lld-macho] Reorganize + extend ICF test
Jez Ng [Fri, 23 Jul 2021 15:33:26 +0000 (11:33 -0400)]
[lld-macho] Reorganize + extend ICF test

I found icf.s a bit hard to work with as it was not possible to
extend any of the functions `_a` ... `_k` to test new relocation /
referent types without modifying every single one of them. Additionally,
their one-letter names were not descriptive (though the comments
helped).

I've renamed all the functions to reflect the feature they are testing,
and shrunk them so that they contain just enough to test that one
feature.

I've also added tests for non-zero addends (via the
`_abs1a_ref_with_addend` and `_defined_ref_with_addend_1` functions).

Reviewed By: #lld-macho, gkm

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

3 years ago[JITLink][RISCV] Initial Support RISCV64 in JITLink
luxufan [Mon, 5 Jul 2021 12:04:17 +0000 (20:04 +0800)]
[JITLink][RISCV] Initial Support RISCV64 in JITLink

This patch is the initial support, it implements translation from object file to JIT link graph, and very few relocations were supported. Currently, the test file ELF_pc_indirect.s is passed, the HelloWorld program(compiled with mno-relax flag) can be linked correctly and run on instruction emulator correctly.

In the downstream implementation, I have implemented the GOT, PLT function, and EHFrame and some optimization will be implement soon. I will organize the code in to patches, then gradually send it to upstream.

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

3 years ago[lld/mac] Let OutputSegment store its start address
Nico Weber [Fri, 23 Jul 2021 14:19:06 +0000 (10:19 -0400)]
[lld/mac] Let OutputSegment store its start address

segment$start$/segment$end$ symbols allow creating segments without
sections, so getting the segment address off the first section
won't work there. Storing the address on the segment is arguably a
bit simpler too.

No behavior change, part of PR50760.

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

3 years ago[mlir][linalg] Fix bug in contraction op vectorization with output perm
thomasraoux [Wed, 21 Jul 2021 18:05:14 +0000 (11:05 -0700)]
[mlir][linalg] Fix bug in contraction op vectorization with output perm

When the output indexing map has a permutation we need to consider in
the contraction vector type.

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

3 years ago[llvm-symbolizer] Remove one-dash long options
Fangrui Song [Fri, 23 Jul 2021 15:35:45 +0000 (08:35 -0700)]
[llvm-symbolizer] Remove one-dash long options

Most modern tools only accept two-dash long options. Remove one-dash
long options which are not recognized by GNU style `getopt_long`.
This ensures long options cannot collide with grouped short options.

Note: llvm-symbolizer has `-demangle={true,false}` for pprof compatibility
(for a while). They are kept.

Reviewed By: jhenderson

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

3 years ago[lld/mac] Don't crash on absolute symbols in order files
Nico Weber [Fri, 23 Jul 2021 01:46:47 +0000 (21:46 -0400)]
[lld/mac] Don't crash on absolute symbols in order files

Absolute symbols have a nullptr isec. buildInputSectionPriorities()
would defer isec, causing crashes. Ordering absolute symbols doesn't
make sense, so just ignore them. This seems to match ld64.

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

3 years ago[clangd] Adjust compile flags to contain only the requested file as input
Kadir Cetinkaya [Fri, 23 Jul 2021 09:10:31 +0000 (11:10 +0200)]
[clangd] Adjust compile flags to contain only the requested file as input

Depends on D106527.

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

3 years ago[clangd] Canonicalize compile flags before applying edits
Kadir Cetinkaya [Thu, 22 Jul 2021 07:35:23 +0000 (09:35 +0200)]
[clangd] Canonicalize compile flags before applying edits

Pushes input for the compile action to the end while separating with a
`--` before applying other manglings. This ensures edits that effect only the
arguments that come after them works, like changing parse language via -x.

Fixes https://github.com/clangd/clangd/issues/555.

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

3 years ago[clangd] Get rid of arg adjusters in CommandMangler
Kadir Cetinkaya [Thu, 22 Jul 2021 15:20:53 +0000 (17:20 +0200)]
[clangd] Get rid of arg adjusters in CommandMangler

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

3 years ago[clangd] Use CommandMangler in TestTU
Kadir Cetinkaya [Thu, 22 Jul 2021 10:05:27 +0000 (12:05 +0200)]
[clangd] Use CommandMangler in TestTU

This makes testing setup look closer to production.

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

3 years ago[libc++] Avoid triggering warnings for implicit conversion
Louis Dionne [Tue, 20 Jul 2021 15:46:05 +0000 (11:46 -0400)]
[libc++] Avoid triggering warnings for implicit conversion

This started as fixing a typo in a ADDITIONAL_COMPILE_FLAGS directive
which turned out to uncover a few places where we warned about signedness
changes.

As a fly-by fix, this updates the various __advance overloads
for style consistency.

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

3 years ago[ARM] Remove getHWDivName (NFC)
Kazu Hirata [Fri, 23 Jul 2021 14:44:23 +0000 (07:44 -0700)]
[ARM] Remove getHWDivName (NFC)

This function seems to be unused for at least 5 years.

3 years ago[lld/mac] Add missing REQUIRES line to new test
Nico Weber [Fri, 23 Jul 2021 14:40:14 +0000 (10:40 -0400)]
[lld/mac] Add missing REQUIRES line to new test

3 years ago[HIP] Preserve ASAN bitcode library functions
Yaxun (Sam) Liu [Mon, 19 Jul 2021 21:15:38 +0000 (17:15 -0400)]
[HIP] Preserve ASAN bitcode library functions

Address sanitizer passes may generate call of ASAN bitcode library
functions after bitcode linking in lld, therefore lld cannot add
those symbols since it does not know they will be used later.

To solve this issue, clang emits a reference to a bicode library
function which calls all ASAN functions which need to be
preserved. This basically force all ASAN functions to be
linked in.

Reviewed by: Artem Belevich

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

3 years ago[llvm][sve] Silence unused variable warning in Release builds. NFC
Benjamin Kramer [Fri, 23 Jul 2021 14:16:15 +0000 (16:16 +0200)]
[llvm][sve] Silence unused variable warning in Release builds. NFC

3 years agoFix __hip_fabin visibility
Yaxun (Sam) Liu [Thu, 22 Jul 2021 16:36:46 +0000 (12:36 -0400)]
Fix __hip_fabin visibility

In -fgpu-rdc case, fat binary is embedded as global variable __hip_fatbin.
It needs to have protected visibility to avoid conflict between shared
libraries.

Reviewed by: Siu Chi Chan

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

Fixes: SWDEV-292290

3 years ago[ORC] Work around AIX build compiler: Replace lambda; NFC
Hubert Tong [Fri, 23 Jul 2021 04:40:54 +0000 (00:40 -0400)]
[ORC] Work around AIX build compiler: Replace lambda; NFC

By replacing a lambda expression with a functor class instance, this
patch works around an issue encountered on AIX where the IBM XL compiler
appears to make no progress for many hours.

Reviewed By: jsji

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

3 years ago[x86] improve CMOV codegen by pushing add into operands
Sanjay Patel [Fri, 23 Jul 2021 13:01:26 +0000 (09:01 -0400)]
[x86] improve CMOV codegen by pushing add into operands

This is not the transform direction we want in general,
but by the time we have a CMOV, we've already tried
everything else that could be better.
The transform increases the uses of the other add operand,
but that is safe according to Alive2:
https://alive2.llvm.org/ce/z/Yn6p-A

We could probably extend this to other binops (not just add).
This is the motivating pattern discussed in:
https://llvm.org/PR51069

The test with i8 shows a missed fold because there's a trunc
sitting in front of the add. That can be handled with a small
follow-up.

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

3 years ago[x86] add tests for add X, (cmov constants); NFC
Sanjay Patel [Thu, 22 Jul 2021 20:50:38 +0000 (16:50 -0400)]
[x86] add tests for add X, (cmov constants); NFC

3 years ago[clangd] Avoid range-loop init-list lifetime subtleties.
Sam McCall [Fri, 23 Jul 2021 12:26:45 +0000 (14:26 +0200)]
[clangd] Avoid range-loop init-list lifetime subtleties.

The original code appears to be OK per the spec, but we've had 3 reports of
crashes with certain unofficial builds of clangd that look a lot like old
compilers (GCC 5.4?) getting lifetime rules wrong.

Fixes https://github.com/clangd/clangd/issues/800

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

3 years ago[clangd] Improve performance of dex by 45-60%
Kirill Bobyrev [Fri, 23 Jul 2021 13:28:31 +0000 (15:28 +0200)]
[clangd] Improve performance of dex by 45-60%

Take full advantage of AND's iterator children size estimation: use early reset
in sync() and prevent large overhead. The idea is that the children at the
beginning of the list are smaller and cheaper to advance. Very large children
negate the effect of this performance optimisation and hence should be
advanced only when absolutely necessary. By reducing the number of large
iterators' updates, we increase the performance by a large margin.

This change was tested on a comprehensive query dataset. The performance
boost increases with the average length of the query, on small queries it is
close to 45% but the longer they go the closer it gets to 60% and beyond.

Reviewed By: sammccall

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

3 years ago[llvm][sve] Lowering for VLS truncating stores
David Truby [Mon, 12 Jul 2021 09:55:11 +0000 (10:55 +0100)]
[llvm][sve] Lowering for VLS truncating stores

This adds custom lowering for truncating stores when operating on
fixed length vectors in SVE. It also includes a DAG combine to
fold extends followed by truncating stores into non-truncating
stores in order to prevent this pattern appearing once truncating
stores are supported.

Currently truncating stores are not used in certain cases where
the size of the vector is larger than the target vector width.

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

3 years ago[OpenMPOpt] Move dedup runtime calls after init for target regions
Giorgis Georgakoudis [Thu, 22 Jul 2021 15:14:55 +0000 (08:14 -0700)]
[OpenMPOpt] Move dedup runtime calls after init for target regions

Deduplication in OpenMPOpt finds redundant OpenMP runtime calls and replaces them with a single call placed in the earliest safe location in the IR. When deduplication happens in a target region this patch makes sure replacement calls are put after target_init.

Reviewed By: jdoerfert

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

3 years agoThread safety analysis: Mock getter for private mutexes can be undefined
Aaron Puchert [Fri, 23 Jul 2021 12:45:56 +0000 (14:45 +0200)]
Thread safety analysis: Mock getter for private mutexes can be undefined

Usage in an annotation is no odr-use, so I think there needs to be no
definition. Upside is that in practice one will get linker errors if it
is actually odr-used instead of calling a function that returns 0.

Reviewed By: aaron.ballman

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

3 years ago[Analyzer][solver] Fix inconsistent equivalence class data
Gabor Marton [Mon, 19 Jul 2021 15:37:57 +0000 (17:37 +0200)]
[Analyzer][solver] Fix inconsistent equivalence class data

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

When we merged two classes, `*this` became an obsolete representation of
the new `State`. This is b/c the member relations had changed during the
previous merge of another member of the same class in a way that `*this`
had no longer any members. (`mergeImpl` might keep the member relations
to `Other` and could dissolve `*this`.)

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

3 years ago[libc] optimize bzero/memset for x86
Guillaume Chatelet [Fri, 23 Jul 2021 12:19:55 +0000 (12:19 +0000)]
[libc] optimize bzero/memset for x86

This is simpy using the x86 optimized elements when targetting x86 cpus.

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

3 years ago[X86][AVX] lowerV2X128Shuffle - attempt to recognise broadcastf128 subvector load
Simon Pilgrim [Fri, 23 Jul 2021 12:07:36 +0000 (13:07 +0100)]
[X86][AVX] lowerV2X128Shuffle - attempt to recognise broadcastf128 subvector load

As noticed on PR50053 we were failing to recognise when a shuffle of a load was really a subvector broadcast load

3 years ago[NFC][SimplifyCFG] Add test for `SpeculativelyExecuteBB()` with prof md
Roman Lebedev [Fri, 23 Jul 2021 10:11:45 +0000 (13:11 +0300)]
[NFC][SimplifyCFG] Add test for `SpeculativelyExecuteBB()` with prof md

3 years ago[OpenCL] Add NULL to standards prior to v2.0.
Anastasia Stulova [Fri, 23 Jul 2021 10:50:39 +0000 (11:50 +0100)]
[OpenCL] Add NULL to standards prior to v2.0.

NULL was undefined in OpenCL prior to version 2.0. However, the
language specification states that "macro names defined by the C99
specification but not currently supported by OpenCL are reserved
for future use". Therefore, application developers cannot redefine
NULL.

The change is supposed to resolve inconsistency between language
versions. Currently there is no apparent reason why NULL should
be kept undefined.

Patch by Topotuna (Justas Janickas)!

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

3 years ago[mlir][Complex]: Add lowerings for AddOp and SubOp from Complex dialect to
Adrian Kuegel [Wed, 21 Jul 2021 10:44:34 +0000 (12:44 +0200)]
[mlir][Complex]: Add lowerings for AddOp and SubOp from Complex dialect to
Standard.

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

3 years ago[SVE][IR] Fix Binary op matching in PatternMatch::m_VScale
Dylan Fleming [Fri, 23 Jul 2021 09:51:54 +0000 (10:51 +0100)]
[SVE][IR] Fix Binary op matching in PatternMatch::m_VScale

Reviewed By: sdesmalen

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

3 years ago[AMDGPU][MC][GFX9][NFC][DOC] Updated AMD GPU assembler syntax description.
Dmitry Preobrazhensky [Fri, 23 Jul 2021 09:51:37 +0000 (12:51 +0300)]
[AMDGPU][MC][GFX9][NFC][DOC] Updated AMD GPU assembler syntax description.

Fixed bugs 48639, 49447, 49448, 49449.

3 years agoRevert "[DSE] Transform memset + malloc --> calloc (PR25892)"
Dawid Jurczak [Fri, 23 Jul 2021 09:51:59 +0000 (11:51 +0200)]
Revert "[DSE] Transform memset + malloc --> calloc (PR25892)"

This reverts commit 43234b1595125ba2b5c23e7b28f5a67041c77673.

Reason: We should detect that we are implementing 'calloc' and bail out.

3 years ago[hwasan] Fix uninitialized DisableOptimization
Vitaly Buka [Fri, 23 Jul 2021 09:25:33 +0000 (02:25 -0700)]
[hwasan] Fix uninitialized DisableOptimization

3 years ago[OpenCL] Add cl_khr_integer_dot_product
Sven van Haastregt [Fri, 23 Jul 2021 09:10:16 +0000 (10:10 +0100)]
[OpenCL] Add cl_khr_integer_dot_product

Add the builtins defined by Section 42 "Integer dot product" in
the OpenCL Extension Specification.

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

3 years agotsan: fix SANITIZER_DEBUG build
Dmitry Vyukov [Fri, 23 Jul 2021 08:52:08 +0000 (10:52 +0200)]
tsan: fix SANITIZER_DEBUG build

Remove left-over debug field after moving tsan
deadlock detector into sanitizer_common.

Reviewed By: melver

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

3 years agosanitizer_common: don't use [[no_unique_address]]
Dmitry Vyukov [Fri, 23 Jul 2021 08:41:40 +0000 (10:41 +0200)]
sanitizer_common: don't use [[no_unique_address]]

https://lab.llvm.org/buildbot#builders/112/builds/7881
https://lab.llvm.org/buildbot#builders/121/builds/9907
https://lab.llvm.org/buildbot#builders/105/builds/12770
../../sanitizer_common/sanitizer_mutex.h:288:38: error:
'no_unique_address' attribute directive ignored [-Werror=attributes]
   [[no_unique_address]] CheckedMutex checked_;

Reviewed By: melver

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

3 years ago[OpenMP] Fix CUDA plugin build after 3817ba13aea3.
Abhinav Gaba [Fri, 23 Jul 2021 06:43:05 +0000 (14:43 +0800)]
[OpenMP] Fix CUDA plugin build after 3817ba13aea3.

The build was broken on machines that don't have Cuda SDK installed.

See https://reviews.llvm.org/D106627 for the original discussion.

3 years ago[MS] Preserve base register %esi around movs[bwl]
namazso [Fri, 23 Jul 2021 07:53:48 +0000 (15:53 +0800)]
[MS] Preserve base register %esi around movs[bwl]

fix for behavior reported in https://bugs.llvm.org/show_bug.cgi?id=51100 workaround for root cause https://bugs.llvm.org/show_bug.cgi?id=16830

similar to https://reviews.llvm.org/D101338

Reviewed By: craig.topper

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

3 years ago[clang-tidy] Improve "common type" diagnostic output in 'bugprone-easily-swappable...
Whisperity [Wed, 21 Jul 2021 14:09:39 +0000 (16:09 +0200)]
[clang-tidy] Improve "common type" diagnostic output in 'bugprone-easily-swappable-parameters'

Make the check handle cases of the "common type" involved in the mix
being non-trivial, e.g. pointers, references, attributes, these things
coming from typedefs, etc.

This results in clearer diagnostics that have more coverage in their
explanation, such as saying `const int &` as common type instead of
`int`.

Reviewed By: aaron.ballman

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

3 years ago[mlir] Async: special handling for parallel loops with zero iterations
Eugene Zhulenev [Fri, 23 Jul 2021 00:05:32 +0000 (17:05 -0700)]
[mlir] Async: special handling for parallel loops with zero iterations

Reviewed By: mehdi_amini

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

3 years ago[libc++][doc] Update the LWG issues.
Mark de Wever [Thu, 22 Jul 2021 06:04:48 +0000 (08:04 +0200)]
[libc++][doc] Update the LWG issues.

Updates the status pages with the LWG issues accepted in the Standard
during the June 2021 plenary session. The LWG papers for this meeting
have been added in D105103.

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

3 years ago[AArch64] Add worst case shuffle costs
David Green [Fri, 23 Jul 2021 08:01:58 +0000 (09:01 +0100)]
[AArch64] Add worst case shuffle costs

This adds some missing single source shuffle costs for AArch64, of i16
and i8 vectors. v4i16 are the same as v4i32 with a worse case cost of 3
coming from the perfect shuffle tables. The larger vector sizes expand
into a constant pool, plus a load (and adrp) and a tbl. I arbitrarily
chose 8 for the cost to be expensive but not too expensive.

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

3 years ago[mlir][Linalg] Fix a missing copy when source of insert_slice is not inplace.
Nicolas Vasilache [Fri, 23 Jul 2021 07:14:11 +0000 (07:14 +0000)]
[mlir][Linalg] Fix a missing copy when source of insert_slice is not inplace.

When the source tensor of a tensor.insert_slice is not equivalent to an inplace buffer an extra copy is necessary. This revision adds the missing copy.

Reviewed By: gysit

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

3 years ago[ConstantFolding] Fold constrained arithmetic intrinsics
Serge Pavlov [Tue, 4 May 2021 13:43:56 +0000 (20:43 +0700)]
[ConstantFolding] Fold constrained arithmetic intrinsics

Constfold constrained variants of operations fadd, fsub, fmul, fdiv,
frem, fma and fmuladd.

The change also sets up some means to support for removal of unused
constrained intrinsics. They are declared as accessing memory to model
interaction with floating point environment, so they were not removed,
as they have side effect. Now constrained intrinsics that have
"fpexcept.ignore" as exception behavior are removed if they have no uses.
As for intrinsics that have exception behavior other than "fpexcept.ignore",
they can be removed if it is known that they do not raise floating point
exceptions. It happens when doing constant folding, attributes of such
intrinsic are changed so that the intrinsic is not claimed as accessing
memory.

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

3 years ago[AMDGPU] Fix running ResourceUsageAnalysis
Sebastian Neubauer [Wed, 21 Jul 2021 17:14:12 +0000 (19:14 +0200)]
[AMDGPU] Fix running ResourceUsageAnalysis

Clear the map when running the analysis multiple times.
The assertion that should ensure that every function is only
analyzed once triggered sometimes (once every ~70 compiles of some
graphics pipelines) when two functions of subsequent runs were allocated
at the same address.

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

3 years ago[gn build] Port 0118a649348b
LLVM GN Syncbot [Fri, 23 Jul 2021 07:19:25 +0000 (07:19 +0000)]
[gn build] Port 0118a649348b

3 years ago[AMDGPU] Add maximum NSA size limit ISA feature
Carl Ritson [Thu, 22 Jul 2021 01:43:25 +0000 (10:43 +0900)]
[AMDGPU] Add maximum NSA size limit ISA feature

Add maximum NSA size limit as an ISA feature.
Use this to reduce NSA usage on GFX10.1 to avoid stability issues
with 4 and 5 dwords NSA instructions.
Maintain use of longer NSA instructions on GFX10.3.

Note: this also contains some minor fixes for GlobalISel which
did not work correctly with non-NSA form instructions on GFX10.

Reviewed By: foad

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

3 years agotsan: switch atexit mutex to the normal Mutex
Dmitry Vyukov [Thu, 22 Jul 2021 14:40:47 +0000 (16:40 +0200)]
tsan: switch atexit mutex to the normal Mutex

Now that Mutex is blocking there is no point in using BlockingMutex.
Switch to Mutex.

Depends on D106379.

Reviewed By: vitalybuka

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

3 years agotsan: switch to the new sanitizer_common mutex
Dmitry Vyukov [Tue, 20 Jul 2021 11:31:10 +0000 (13:31 +0200)]
tsan: switch to the new sanitizer_common mutex

Now that sanitizer_common mutex has feature-parity with tsan mutex,
switch tsan to the sanitizer_common mutex and remove tsan's custom mutex.

Reviewed By: vitalybuka, melver

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

3 years agotsan: disable thread safety analysis in more functions
Dmitry Vyukov [Wed, 21 Jul 2021 07:28:48 +0000 (09:28 +0200)]
tsan: disable thread safety analysis in more functions

In preparation for replacing tsan Mutex with sanitizer_common Mutex,
which has thread-safety annotations. Thread safety analysis does not
understand MetaMap::GetAndLock which returns a locked sync object.

Reviewed By: vitalybuka, melver

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

3 years agotsan: ignore interceptors in few more places
Dmitry Vyukov [Thu, 22 Jul 2021 14:32:55 +0000 (16:32 +0200)]
tsan: ignore interceptors in few more places

This is preparation to switching to the sanitizer_common Mutex.
Without this change after the switch we will start failing
on existing from the runtime with runtime mutexes held.
Previously it worked because CheckNoLocks did not see sanitizer_common mutexes.

Depends on D106547.

Reviewed By: vitalybuka, melver

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

3 years agotsan: rename test Mutex to UserMutex
Dmitry Vyukov [Tue, 20 Jul 2021 13:20:29 +0000 (15:20 +0200)]
tsan: rename test Mutex to UserMutex

Rename Mutex class in tests to avoid conflicts with sanitizer_common Mutex.

Reviewed By: vitalybuka, melver

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

3 years agosanitizer_common: add deadlock detection to the Mutex2
Dmitry Vyukov [Tue, 20 Jul 2021 09:17:00 +0000 (11:17 +0200)]
sanitizer_common: add deadlock detection to the Mutex2

    Copy internal deadlock detector from tsan to sanitizer_common
    (with some cosmetic changes).
    Tsan version will be deleted in subsequent changes.
    This allows us to switch tsan to the sanitizer_common mutex
    and remove tsan's mutex.

Reviewed By: vitalybuka, melver

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

3 years ago[AArch64][AsmParser] NFC: when creating a token IsSuffix=false should be default
Cullen Rhodes [Fri, 23 Jul 2021 06:10:38 +0000 (06:10 +0000)]
[AArch64][AsmParser] NFC: when creating a token IsSuffix=false should be default

Reviewed By: david-arm

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

3 years ago[NFC] Fix early line-break in doxygen comment
Fraser Cormack [Fri, 23 Jul 2021 06:15:27 +0000 (07:15 +0100)]
[NFC] Fix early line-break in doxygen comment

3 years ago[X86] Add test case simplified from PR51175. NFC
Craig Topper [Fri, 23 Jul 2021 06:20:54 +0000 (23:20 -0700)]
[X86] Add test case simplified from PR51175. NFC

3 years ago[SelectionDAG][RISCV] Add tests showing missed scalable-splat optimizations
Fraser Cormack [Thu, 22 Jul 2021 16:06:51 +0000 (17:06 +0100)]
[SelectionDAG][RISCV] Add tests showing missed scalable-splat optimizations

These tests show missed opportunities in the SelectionDAG layer when
dealing with scalable-vector splats. All of these are handled for the
equivalent `ISD::BUILD_VECTOR` code, and the tests have largely been
translated from the equivalent X86 tests.

Reviewed By: craig.topper

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