platform/upstream/llvm.git
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

3 years ago[libc] Raise denormal exception if the libc defines __FE_DENORM.
Siva Chandra Reddy [Thu, 22 Jul 2021 22:05:34 +0000 (22:05 +0000)]
[libc] Raise denormal exception if the libc defines __FE_DENORM.

Reviewed By: michaelrj

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

3 years ago[OpenMP] Simplify the ThreadStackTy for globalization fallback
Johannes Doerfert [Thu, 22 Jul 2021 17:18:46 +0000 (12:18 -0500)]
[OpenMP] Simplify the ThreadStackTy for globalization fallback

With D106496 we can make the globalization fallback stack much simpler
and this version doesn't seem to experience the spurious failures and
deadlocks we have seen before.

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

3 years ago[Attributor] If provided, only look at simplification callbacks not IR
Johannes Doerfert [Thu, 22 Jul 2021 05:36:31 +0000 (00:36 -0500)]
[Attributor] If provided, only look at simplification callbacks not IR

A simplification callback can mean that the IR value is modified beyond
the apparent IR semantics. That is, a `i1 true` could be replaced by an
`i1 false` based on high-level domain-specific information. If a user
provides a simplification callback we will not look at the IR but
instead give up if the callback returns a nullptr.

3 years ago[RISCV] Add FrameSetup/FrameDestroy flag to prologue/epilog instructions.
Hsiangkai Wang [Tue, 29 Jun 2021 07:22:18 +0000 (15:22 +0800)]
[RISCV] Add FrameSetup/FrameDestroy flag to prologue/epilog instructions.

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

3 years ago[mlir] Fix comment typos
Jacques Pienaar [Fri, 23 Jul 2021 03:04:40 +0000 (20:04 -0700)]
[mlir] Fix comment typos

3 years agocmake: Remove unused property on some targets: LLVM_LINK_LIBS
Tom Stellard [Fri, 23 Jul 2021 02:58:05 +0000 (19:58 -0700)]
cmake: Remove unused property on some targets: LLVM_LINK_LIBS

This doesn't appear to be used anywhere.

Reviewed By: serge-sans-paille

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

3 years ago[lld-macho] Disambiguate bitcode files with the same name by archive name/offset...
Leonard Grey [Fri, 23 Jul 2021 02:47:22 +0000 (22:47 -0400)]
[lld-macho] Disambiguate bitcode files with the same name by archive name/offset in archive

Ported from COFF/ELF; test is adapted from
test/COFF/thinlto-archivecollision.ll

LTO expects every bitcode file to have a unique name. If given multiple bitcode
files with the same name, it errors with "Expected at most one ThinLTO module
per bitcode file".

This change incorporates the archive name, to disambiguate members with the
same name in different archives and the offset in archive to disambiguate
members with the same name in the same archive.

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

3 years ago[OpenMP][NFC] Fix formatting in CUDA plugin
Joseph Huber [Fri, 23 Jul 2021 01:50:09 +0000 (21:50 -0400)]
[OpenMP][NFC] Fix formatting in CUDA plugin

3 years ago[OpenMP] Add environment variables to change stack / heap size in the CUDA plugin
Joseph Huber [Fri, 23 Jul 2021 01:19:14 +0000 (21:19 -0400)]
[OpenMP] Add environment variables to change stack / heap size in the CUDA plugin

This patch adds support for two environment variables to configure the device.
``LIBOMPTARGET_STACK_SIZE`` sets the amount of memory in bytes that each thread
has for its stack. ``LIBOMPTARGET_HEAP_SIZE`` sets the amount of heap memory
that can be allocated using malloc / free on the device.

Reviewed By: jdoerfert

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

3 years ago[gn build] Allow use_asan=true on macOS
Nico Weber [Fri, 23 Jul 2021 01:38:00 +0000 (21:38 -0400)]
[gn build] Allow use_asan=true on macOS

Seems to work.

(I only tried macOS, not iOS, but need to allow both because
the iOS toolchain used to build compiler-rt asserts otherwise.)

3 years ago[gn build] Reformat all gn files
Nico Weber [Fri, 23 Jul 2021 01:35:35 +0000 (21:35 -0400)]
[gn build] Reformat all gn files

Ran `git ls-files '*.gn' '*.gni' | xargs llvm/utils/gn/gn.py format`.

3 years ago[lld/mac] Remove "else" after return
Nico Weber [Fri, 23 Jul 2021 01:31:32 +0000 (21:31 -0400)]
[lld/mac] Remove "else" after return

No behavior change

3 years ago[Attributor][Fix] Add overrides for AA2HS analysis
Giorgis Georgakoudis [Fri, 23 Jul 2021 01:20:14 +0000 (18:20 -0700)]
[Attributor][Fix] Add overrides for AA2HS analysis

3 years ago[PowerPC] Implement XL compatible behavior of __compare_and_swap
Kai Luo [Fri, 23 Jul 2021 00:57:53 +0000 (00:57 +0000)]
[PowerPC] Implement XL compatible behavior of __compare_and_swap

According to https://www.ibm.com/docs/en/xl-c-and-cpp-aix/16.1?topic=functions-compare-swap-compare-swaplp
XL's `__compare_and_swap` has a weird behavior that

> In either case, the contents of the memory location specified by addr are copied into the memory location specified by old_val_addr.

(unlike c11 `atomic_compare_exchange` specified in http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1548.pdf)

This patch let clang's implementation follow this behavior.

Reviewed By: jsji

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

3 years ago[OpenMP] Use AAHeapToStack/AAHeapToShared analysis in SPMDization
Giorgis Georgakoudis [Thu, 22 Jul 2021 01:36:17 +0000 (18:36 -0700)]
[OpenMP] Use AAHeapToStack/AAHeapToShared analysis in SPMDization

SPMDization D102307 detects incompatible OpenMP runtime calls to abort converting a target region to SPMD mode. Calls to memory allocation/de-allocation routines kmpc_alloc_shared, kmpc_free_shared are incompatible unless they are removed by AAHeapToStack/AAHeapToShared analysis. This patch extends SPMDization detection to include AAHeapToStack/AAHeapToShared analysis results for enlarging the scope of possible SPMDized regions detected.

Reviewed By: jdoerfert

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

3 years ago[compiler-rt] Fix lld dependency for sanitizers
Vitaly Buka [Fri, 23 Jul 2021 00:36:32 +0000 (17:36 -0700)]
[compiler-rt] Fix lld dependency for sanitizers

TARGET lld is always false there.

3 years ago[NFC][asan] Always pass Dominator Trees into forAllReachableExits
Vitaly Buka [Fri, 23 Jul 2021 00:07:44 +0000 (17:07 -0700)]
[NFC][asan] Always pass Dominator Trees into forAllReachableExits

3 years ago[mlir][tosa] Make tosa MakeBroadcastable pass handle unreanked tensors.
Rob Suderman [Fri, 23 Jul 2021 00:22:11 +0000 (17:22 -0700)]
[mlir][tosa] Make tosa MakeBroadcastable pass handle unreanked tensors.

If this pass executes without shape inference its possible for unranked tensors
to appear in the IR. This pass should gracefully handle unranked tensors.

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

3 years ago[ARC] Add tablegen definition for the Find Leading Set (FLS) instruction
Thomas Johnson [Thu, 22 Jul 2021 23:26:46 +0000 (16:26 -0700)]
[ARC] Add tablegen definition for the Find Leading Set (FLS) instruction

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

3 years ago[profile] Add binary id into profiles
Gulfem Savrun Yeniceri [Thu, 6 May 2021 16:09:12 +0000 (16:09 +0000)]
[profile] Add binary id into profiles

This patch adds binary id into profiles to easily associate binaries
with the corresponding profiles. There is an RFC that discusses
the motivation, design and implementation in more detail:
https://lists.llvm.org/pipermail/llvm-dev/2021-June/151154.html

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

3 years ago[ELF] --gc-sections: allow GC on reserved sections in a group
Fangrui Song [Fri, 23 Jul 2021 00:09:23 +0000 (17:09 -0700)]
[ELF] --gc-sections: allow GC on reserved sections in a group

This generalizes D70146 (SHT_NOTE) to more reserved sections and makes our rules
more consistent. Now SHF_GROUP is more similar to SHF_LINK_ORDER.

For SHT_INIT_ARRAY/SHT_FINI_ARRAY, the rule will be closer to PE/COFF link.exe.

Previously sanitizers use llvm.global_ctors to make module_ctor a GC
root, which is considered an abuse.
https://groups.google.com/g/generic-abi/c/TpleUEkNoQI

We can squeak through on compatibility issues because compilers otherwise don't
use SHF_GROUP special sections.

3 years ago[ELF][test] Add a test about GCable SHF_LINK_ORDER SHT_INIT_ARRAY
Fangrui Song [Fri, 23 Jul 2021 00:04:54 +0000 (17:04 -0700)]
[ELF][test] Add a test about GCable SHF_LINK_ORDER SHT_INIT_ARRAY

3 years ago[CSSPGO] Fix a typo in SampleContextTracker
Hongtao Yu [Thu, 22 Jul 2021 21:41:55 +0000 (14:41 -0700)]
[CSSPGO] Fix a typo in SampleContextTracker

Fixing a typo in SampleContextTracker to use debug name when debug linkage name is no present. This should only affect C programs.

Saw 0.6% perf win on Cinder which is mostly C code.

Reviewed By: wenlei, wmi

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

3 years ago[lld/mac] Handle symbols from -U in treatUndefinedSymbol()
Nico Weber [Thu, 22 Jul 2021 15:20:36 +0000 (11:20 -0400)]
[lld/mac] Handle symbols from -U in treatUndefinedSymbol()

In ld64, `-U section$start$FOO$bar` handles `section$start$FOO$bar`
as a regular `section$start` symbol, that is section$start processing
happens before -U processing.

Likely, nobody uses that in practice so it doesn't seem very important
to be compatible with this, but it also moves the -U handling code next
to the `-undefined dynamic_lookup` handling code, which is nice because
they do the same thing. And, in fact, this did identify a bug in a corner
case in the intersection of `-undefined dynamic_lookup` and dead-stripping
(fix for that in D106565).

Vaguely related to PR50760.

No interesting behavior change.

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

3 years ago[gn build] (manually) port f8c6515554cc (libLLVMDWP)
Nico Weber [Thu, 22 Jul 2021 23:38:19 +0000 (19:38 -0400)]
[gn build] (manually) port f8c6515554cc (libLLVMDWP)

3 years agoAdd llvm-readobj and binutils symlinks to LLVM_TOOLCHAIN_TOOLS
Mara Sophie Grosch [Thu, 22 Jul 2021 23:33:20 +0000 (16:33 -0700)]
Add llvm-readobj and binutils symlinks to LLVM_TOOLCHAIN_TOOLS

This patch adds llvm-readobj and the binutils symlink for readelf to
LLVM_TOOLCHAIN_TOOLS.

Tvoid *thread, void *attr,hey are required by some (most?)
autoconf-built libraries, adding these allows me to build newlib with
the toolchain generated this way.

Also opened an issue for that some days ago, see
https://bugs.llvm.org/show_bug.cgi?id=50698

Reviewed By: sbc100

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

3 years ago[WebAssembly][NFC] Update test expectations labels after db7efcab7dd9
Thomas Lively [Thu, 22 Jul 2021 23:31:12 +0000 (16:31 -0700)]
[WebAssembly][NFC] Update test expectations labels after db7efcab7dd9

Commit db7efcab7dd9 changed the implementations of the wasm_*_extract_lane and
wasm_*_replace_lane intrinsics from using builtin functions to using the
standard vector extensions. This did not change the resulting IR, but it changes
how update_cc_test_checks.py labels values in the IR. This commit simply updates
those labels.

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

3 years ago[lld/mac] Fix bug in interaction of -dead_strip and -undefined dynamic_lookup
Nico Weber [Thu, 22 Jul 2021 15:37:29 +0000 (11:37 -0400)]
[lld/mac] Fix bug in interaction of -dead_strip and -undefined dynamic_lookup

We lost the `used` bit on the Undefined when we replaced it with a DylibSymbol
in treatUndefined().

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

3 years ago[libcxx][modularisation] properly modularises advance, next, and prev
Christopher Di Bella [Tue, 29 Jun 2021 03:53:44 +0000 (03:53 +0000)]
[libcxx][modularisation] properly modularises advance, next, and prev

`__function_like` wasn't being exported, so certain properties of the
`ranges` functions weren't being propagated in modules land.

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

3 years ago[MLGO] Strip TF_PIP cmake variable
Mircea Trofin [Thu, 22 Jul 2021 23:26:46 +0000 (16:26 -0700)]
[MLGO] Strip TF_PIP cmake variable

This should fix build breaks for 'development' mode. The other modes
were unaffected - 'release' because it doesn't use TFUtils.cpp, and the
mixed mode because the AOT compiled code brings in the necessary include
dirs anyway.

3 years ago[OpenMP] Refined the logic to give a regular task from a hidden helper task
Shilei Tian [Thu, 22 Jul 2021 23:20:57 +0000 (19:20 -0400)]
[OpenMP] Refined the logic to give a regular task from a hidden helper task

In current implementation, if a regular task depends on a hidden helper task,
and when the hidden helper task is releasing its dependences, it directly calls
`__kmp_omp_task`. This could cause a problem that if `__kmp_push_task` returns
`TASK_NOT_PUSHED`, the task will be executed immediately. However, the hidden
helper threads are assumed to only execute hidden helper tasks. This could cause
problems because when calling `__kmp_omp_task`, the encountering gtid, which is
not the real one of the thread, is passed.

This patch uses `__kmp_give_task`, but because it is a static function, a new
wrapper `__kmpc_give_task` is added.

Reviewed By: AndreyChurbanov

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

3 years ago[hwasan] Use stack safety analysis.
Florian Mayer [Thu, 22 Jul 2021 21:19:21 +0000 (14:19 -0700)]
[hwasan] Use stack safety analysis.

This avoids unnecessary instrumentation.

Reviewed By: eugenis, vitalybuka

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

3 years ago[Bazel] Rename LLVMDWP to DWP
Geoffrey Martin-Noble [Thu, 22 Jul 2021 23:05:40 +0000 (16:05 -0700)]
[Bazel] Rename LLVMDWP to DWP

Since Bazel has packages, we don't prefix target names with LLVM. I
forgot when translating the CMake.

3 years ago[docs] Add the compiler-rt requirement to the test suite doc
Mircea Trofin [Wed, 28 Apr 2021 16:09:01 +0000 (09:09 -0700)]
[docs] Add the compiler-rt requirement to the test suite doc

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

3 years ago[Bazel] Change external_zlib attribute to string
Michael McLoughlin [Thu, 22 Jul 2021 23:01:49 +0000 (16:01 -0700)]
[Bazel] Change external_zlib attribute to string

When using `llvm_zlib_external` rule with `external_zlib` attribute set to a
label referring to the main repository, like `@//third_party/zlib`, it will be
replaced with `//third_party/zlib` after template substitution. This will then
attempt to find `//third_party/zlib` within the local repository
`@llvm_zlib//third_party/zlib`, which does not exist, rather than the intended
reference back to the main repository. The issue appears to be that the
conversion of `Label` type to string with
`str(repository_ctx.attr.external_zlib)`, which is causing the main repository
qualifier to be lost.

This diff fixes the issue by changing the `external_zlib` attribute to
`attr.string` type rather than `attr.label`.

In future a more elegant solution may be possible that preserves use of the
`Label` type, depending on resolution of the issue
https://github.com/bazelbuild/bazel/issues/13731.

Ported from Github PR https://github.com/google/llvm-bazel/pull/236.

Reviewed By: GMNGeoffrey

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

3 years ago[mlir][tosa] Quantized Conv2DOp lowering to linalg added.
Rob Suderman [Tue, 20 Jul 2021 21:41:37 +0000 (14:41 -0700)]
[mlir][tosa] Quantized Conv2DOp lowering to linalg added.

Includes a version of a quantized conv2D operations with a lowering from TOSA
to linalg with corresponding test. We keep the quantized and quantized variants
as separate named ops to avoid the additional operations for non-quantized
convolutions.

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

3 years ago[dfsan] Add wrappers for v*printf functions
George Balatsouras [Fri, 16 Jul 2021 21:53:32 +0000 (14:53 -0700)]
[dfsan] Add wrappers for v*printf functions

Functions `vsnprintf`, `vsprintf` and `vfprintf` commonly occur in DFSan warnings.

Reviewed By: stephan.yichao.zhao

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

3 years ago[OpenMP] Renaming RT functions `GetNumberOfBlocksInKernel` and `GetNumberOfThreadsInB...
Jose M Monsalve Diaz [Thu, 22 Jul 2021 22:17:09 +0000 (18:17 -0400)]
[OpenMP] Renaming RT functions `GetNumberOfBlocksInKernel` and `GetNumberOfThreadsInBlock`

These functions should follow the camel case convention. These are really easy to change
and are needed for D106033.

Reviewed By: JonChesterfield

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

3 years agoFix the logic so stop-hooks get run after a breakpoint that ran an expression
Jim Ingham [Thu, 22 Jul 2021 19:03:12 +0000 (12:03 -0700)]
Fix the logic so stop-hooks get run after a breakpoint that ran an expression

Code was added to Target::RunStopHook to make sure that we don't run stop hooks when
you stop after an expression evaluation. But the way it was done was to check that we
hadn't run an expression since the last natural stop. That failed in the case where you
stopped for a breakpoint which had run an expression, because the stop-hooks get run
after the breakpoint actions, and so by the time we got to running the stop-hooks,
we had already run a user expression.

I fixed this by adding a target ivar tracking the last natural stop ID at which we had
run a stop-hook. Then we keep track of this and make sure we run the stop-hooks only
once per natural stop.

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

3 years ago[AArch64] Regenerate test arm64-ccmp.ll
Eli Friedman [Thu, 22 Jul 2021 22:03:05 +0000 (15:03 -0700)]
[AArch64] Regenerate test arm64-ccmp.ll

3 years ago[Bazel] Update for f8c6515554
Geoffrey Martin-Noble [Thu, 22 Jul 2021 21:51:04 +0000 (14:51 -0700)]
[Bazel] Update for f8c6515554

Update Bazel for
https://github.com/llvm/llvm-project/commit/f8c6515554 by splitting out
an LLVMDWP library target.

3 years ago[DebugInfo] Add -fno-ctor-homing for as counterpart to -fuse-ctor-homing
Amy Huang [Thu, 22 Jul 2021 18:26:03 +0000 (11:26 -0700)]
[DebugInfo] Add -fno-ctor-homing for as counterpart to -fuse-ctor-homing

Add an opt out flag for constructor homing.

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

3 years agoPR51158: Don't emit -Wswitch or -Wcovered-switch-default for empty enums
David Blaikie [Thu, 22 Jul 2021 21:23:32 +0000 (14:23 -0700)]
PR51158: Don't emit -Wswitch or -Wcovered-switch-default for empty enums

An empty enum is used to implement C++'s new-ish "byte" type (to make
sure it's a separate type for overloading, etc - compared to a typedef)
- without any enumerators. Some clang warnings don't make sense in this
sort of situation, so let's skip them for empty enums.

It's arguable that possibly some situations of enumerations without
enumerators might want the previous-to-this-patch behavior (if the enum
is autogenerated and in some cases comes up empty, then maybe a default
in an empty switch would still be considered problematic - so that when
you add the first enumeration you do get a -Wswitch warning). But I
think that's niche enough & this std::byte case is mainstream enough
that we should prioritize the latter over the former.

If someone's got a middle ground proposal to account for both of those
situations, I'm open to patches/suggestions/etc.

3 years ago[dfsan] Make warn_unimplemented off by default
Jianzhou Zhao [Thu, 22 Jul 2021 21:00:45 +0000 (21:00 +0000)]
[dfsan] Make warn_unimplemented off by default

Because almost all internal use cases need to turn warn_unimplemented off.

3 years ago[SimplifyCFG] SimplifyCondBranchToTwoReturns(): really only deal with different ret...
Roman Lebedev [Thu, 22 Jul 2021 21:13:46 +0000 (00:13 +0300)]
[SimplifyCFG] SimplifyCondBranchToTwoReturns(): really only deal with different ret blocks

This function is called when some predecessor of an empty return block
ends with a conditional branch, with both successors being empty ret blocks.

Now, because of the way SimplifyCFG works, it might happen to simplify
one of the blocks in a way that makes a conditional branch
into an unconditional one, since it's destinations are now identical,
but it might not have actually simplified said conditional branch
into an unconditional one yet.

So, we have to check that ourselves first,
especially now that SimplifyCFG aggressively tail-merges
all ret and resume blocks.

Even if it was an unconditional branch already,
`SimplifyCFGOpt::simplifyReturn()` doesn't call `FoldReturnIntoUncondBranch()`
by default.

3 years ago[NFC][LoopDeletion] Autogenerate checlines in simplify-then-delete.ll test
Roman Lebedev [Thu, 22 Jul 2021 21:28:43 +0000 (00:28 +0300)]
[NFC][LoopDeletion] Autogenerate checlines in simplify-then-delete.ll test

3 years ago[NFC][SimplifyCFG] Add test for SimplifyCondBranchToTwoReturns() mishandling
Roman Lebedev [Thu, 22 Jul 2021 21:09:44 +0000 (00:09 +0300)]
[NFC][SimplifyCFG] Add test for SimplifyCondBranchToTwoReturns() mishandling

3 years ago[DWP] Refactoring llvm-dwp in to a library part 2
Alexander Yermolovich [Thu, 22 Jul 2021 21:11:49 +0000 (14:11 -0700)]
[DWP] Refactoring llvm-dwp in to a library part 2

This is follow up to https://reviews.llvm.org/D106198 where llvm-dwp was refactored in to multiple files.
In this patch moving them in to lib/include directories.

Reviewed By: dblaikie

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

3 years ago[asan] Modified ASAN_MEMORY_ACCESS_CALLBACK to use a function call to ReportGenericEr...
Kirill Stoimenov [Wed, 21 Jul 2021 16:20:35 +0000 (16:20 +0000)]
[asan] Modified ASAN_MEMORY_ACCESS_CALLBACK to use a function call to ReportGenericErrorWrapper.

This change eliminate the stack frame for the fast path and improves runtime performance.

Reviewed By: vitalybuka

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

3 years ago[NFC] Fix test build breakage on Darwin
Shu-Chun Weng [Thu, 22 Jul 2021 21:17:58 +0000 (14:17 -0700)]
[NFC] Fix test build breakage on Darwin