platform/upstream/llvm.git
3 years ago[ModuleInlinerWrapperPass] Do some naive printing of wrapped pipeline with -print...
Bjorn Pettersson [Thu, 16 Sep 2021 11:38:50 +0000 (13:38 +0200)]
[ModuleInlinerWrapperPass] Do some naive printing of wrapped pipeline with -print-pipeline-passes

Bisecting and reducing opt pipelines that includes the
ModuleInlinerWrapperPass has turned out to be a bit problematic.
This is far from perfect (it still lacks information about inline
advisor params etc.), but it should give some kind of hint to what
the wrapped pipeline looks like when using -print-pipeline-passes.

Reviewed By: aeubanks, mtrofin

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

3 years ago[clangd] Ensure lambda init-capture gets semantic token
Nathan Ridge [Tue, 21 Sep 2021 07:44:31 +0000 (03:44 -0400)]
[clangd] Ensure lambda init-capture gets semantic token

Prior to this patch, CollectExtraHighlightings would incorrectly produce
a token for the init-capture's type which overlapped the name and
resulted in both being dropped.

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

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

3 years ago[NFC] Wrap MLIR addAffineForOpDomain warning with LLVM_DEBUG
Tharindu Rusira [Thu, 23 Sep 2021 07:24:24 +0000 (12:54 +0530)]
[NFC] Wrap MLIR addAffineForOpDomain warning with LLVM_DEBUG

Current warning message in method `addAffineForOpDomain` of mlir/lib/Analysis/AffineStructures.cpp is being printed to the stdout/stderr.
This patch redirects the warning with LLVM_DEBUG following standard llvm practice.

Reviewed By: bondhugula

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

3 years agoWrap xar/xar.h include in extern "C" block
Mike Hommey [Thu, 23 Sep 2021 07:25:36 +0000 (09:25 +0200)]
Wrap xar/xar.h include in extern "C" block

Without such wrapping, linking lld fails with missing symbols because of
C++ symbol mangling with older versions of the MacOSX SDK, in which
xar.h doesn't have an extern "C" block itself.

Reviewed By: #lld-macho, thakis

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

3 years ago[X86][FP16] Combine the FADD(A, FMA(B, C, 0)) to FMA(B, C, A)
Liu, Chen3 [Fri, 17 Sep 2021 07:11:20 +0000 (15:11 +0800)]
[X86][FP16] Combine the FADD(A, FMA(B, C, 0)) to FMA(B, C, A)

This patch is to support transform something like
_mm512_add_ph(acc, _mm512_fmadd_pch(a, b, _mm512_setzero_ph()))
to _mm512_fmadd_pch(a, b, acc).

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

3 years ago[clang][tooling] NFC: Refactor command-line diagnostic tests
Jan Svoboda [Tue, 21 Sep 2021 11:52:17 +0000 (13:52 +0200)]
[clang][tooling] NFC: Refactor command-line diagnostic tests

This patch uses a different command-line arguments to test `clang::tooling::ToolInvocation` that are not specific to Darwin.

Reviewed By: dexonsmith

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

3 years ago[mlir] Fix build on Windows on Arm
Diana Picus [Wed, 22 Sep 2021 07:07:33 +0000 (09:07 +0200)]
[mlir] Fix build on Windows on Arm

clang-cl errors out while handling the templated version of tgfmt. This
patch works around the issue by explicitly choosing the non-templated
version of tgfmt, which takes an ArrayRef<std::string>.

More details in this thread:
https://lists.llvm.org/pipermail/cfe-dev/2021-September/068936.html

Thanks @Mehdi Amini for suggesting the fix :)

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

3 years ago[AMDGPU] Fix gcc warnings about unused variables [NFC]
Mikael Holmen [Thu, 23 Sep 2021 06:07:45 +0000 (08:07 +0200)]
[AMDGPU] Fix gcc warnings about unused variables [NFC]

3 years ago[libc++][spaceship] Implement std::pair::operator<=>
Kent Ross [Thu, 23 Sep 2021 05:36:23 +0000 (22:36 -0700)]
[libc++][spaceship] Implement std::pair::operator<=>

Implements parts of P1614, including synth-three-way and three way comparison for std::pair.

Reviewed By: #libc, Quuxplusone, Mordante

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

3 years ago[OpenMP][FIX] Be more deliberate about invalidating the AAKernelInfo state
Johannes Doerfert [Wed, 8 Sep 2021 20:54:27 +0000 (15:54 -0500)]
[OpenMP][FIX] Be more deliberate about invalidating the AAKernelInfo state

This patch fixes a problem when the AAKernelInfo state was invalidated,
e.g., due to `optnone` for a kernel, but not all parts indicated the
invalidation properly. We further eliminate most full state
invalidations as they should never be necessary.

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

3 years ago[OpenMP][NFC] Repair test that contained nested kernels
Johannes Doerfert [Wed, 8 Sep 2021 20:55:57 +0000 (15:55 -0500)]
[OpenMP][NFC] Repair test that contained nested kernels

The benchmark contained (partially) nested kernels, something we do not
generate nor support.

3 years ago[OpenMP][NFC] Rerun the test check update script on all OpenMP-Opt tests
Johannes Doerfert [Wed, 8 Sep 2021 21:00:06 +0000 (16:00 -0500)]
[OpenMP][NFC] Rerun the test check update script on all OpenMP-Opt tests

3 years ago[OpenMP][NFC] Precommit test that exposes a bug in our optnone handling
Johannes Doerfert [Wed, 8 Sep 2021 17:59:44 +0000 (12:59 -0500)]
[OpenMP][NFC] Precommit test that exposes a bug in our optnone handling

3 years ago[OpenMP][NFC] Improve debug output
Johannes Doerfert [Wed, 8 Sep 2021 16:56:51 +0000 (11:56 -0500)]
[OpenMP][NFC] Improve debug output

3 years ago[OpenMP][NFC] Clang format OMPIRBuilder
Johannes Doerfert [Thu, 2 Sep 2021 16:12:36 +0000 (11:12 -0500)]
[OpenMP][NFC] Clang format OMPIRBuilder

These files should be kept clang-formatted but diverge sometimes.

3 years ago[AArch64][SVE][InstCombine] Eliminate redundant chains of tuple get/set
Usman Nadeem [Tue, 14 Sep 2021 04:32:19 +0000 (21:32 -0700)]
[AArch64][SVE][InstCombine] Eliminate redundant chains of tuple get/set

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

Change-Id: I06a3c28e3658ecda109a3a1b73265828274ab2ea

3 years ago[demangle] Support for ISO/IEC TS 18661 binary floating point type
Pengfei Wang [Thu, 23 Sep 2021 03:02:25 +0000 (11:02 +0800)]
[demangle] Support for ISO/IEC TS 18661 binary floating point type

Reviewed By: #libc_abi, ldionne

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

3 years ago[X86][FP16] Change the order of the operands in complex FMA intrinsics to allow swap...
Wang, Pengfei [Thu, 23 Sep 2021 02:13:52 +0000 (10:13 +0800)]
[X86][FP16] Change the order of the operands in complex FMA intrinsics to allow swap between the mul operands.

Reviewed By: craig.topper

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

3 years ago[MLIR] [Python] Make Attribute and Type hashable
John Demme [Thu, 23 Sep 2021 02:50:22 +0000 (19:50 -0700)]
[MLIR] [Python] Make Attribute and Type hashable

Enables putting types and attributes in sets and in dicts as keys.

Reviewed By: stellaraccident

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

3 years ago[NFC] Remove redundant setOperationAction.
Freddy Ye [Thu, 23 Sep 2021 02:27:45 +0000 (10:27 +0800)]
[NFC] Remove redundant setOperationAction.

[FROUND,FROUNDEVEN][f32, f64, f128] are set Expand twice.

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

3 years ago[RISCV] Update mir tests.
Hsiangkai Wang [Wed, 22 Sep 2021 23:47:50 +0000 (07:47 +0800)]
[RISCV] Update mir tests.

3 years ago[llvm-profgen] Fix a dangling vector reference in CS line number based generator
wlei [Wed, 22 Sep 2021 18:14:46 +0000 (11:14 -0700)]
[llvm-profgen] Fix a dangling vector reference in CS line number based generator

It seems we missed one spot to persist `SampleContextFrameVector` into the global table (CSProfileGenerator::populateFunctionBoundarySamples:340) which causes a crash.

This change tried to fix it in a centralized way i. e. where we generate the `FunctionSamples`.

Reviewed By: hoy, wenlei

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

3 years ago[llvm-profgen] Fix an out-of-range error during unwinding
wlei [Wed, 22 Sep 2021 17:24:54 +0000 (10:24 -0700)]
[llvm-profgen] Fix an out-of-range error during unwinding

It happened that the LBR entry target can be the first address of text section which causes an out-of-range crash. So here add a boundary check.

Reviewed By: hoy, wenlei

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

3 years ago[llvm-profgen] Fix a bug of assertion
wlei [Wed, 22 Sep 2021 17:13:42 +0000 (10:13 -0700)]
[llvm-profgen] Fix a bug of assertion

The assertion should work on the entire context.

Reviewed By: hoy, wenlei

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

3 years ago[NFC][InstCombine] Fix inconsistent comments
hyeongyu kim [Thu, 23 Sep 2021 00:31:39 +0000 (09:31 +0900)]
[NFC][InstCombine] Fix inconsistent comments

3 years ago[libc++] Fix __wrap_iter to be a proper contiguous iterator.
Arthur O'Dwyer [Tue, 21 Sep 2021 20:35:16 +0000 (16:35 -0400)]
[libc++] Fix __wrap_iter to be a proper contiguous iterator.

Instead of overloading `__to_address`, let's specialize `pointer_traits`.
Function overloads need to be in scope at the point where they're called,
whereas template specializations do not. (User code can provide pointer_traits
specializations to be used by already-included library code, so obviously
`__wrap_iter` can do the same.)

`pointer_traits<__wrap_iter<It>>` cannot provide `pointer_to`, because
you generally cannot create a `__wrap_iter` without also knowing the
identity of the container into which you're trying to create an iterator.
I believe this is OK; contiguous iterators are required to provide
`to_address` but *not* necessarily `pointer_to`.

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

3 years ago[Polly] Dissolve Isl test directory. NFC.
Michael Kruse [Wed, 22 Sep 2021 22:45:07 +0000 (17:45 -0500)]
[Polly] Dissolve Isl test directory. NFC.

All tests use ISL, integrate its subfolder into the components they
belong to.

3 years ago[Polly] Implement user-directed loop distribution/fission.
Michael Kruse [Wed, 22 Sep 2021 22:27:16 +0000 (17:27 -0500)]
[Polly] Implement user-directed loop distribution/fission.

This is a simple version without the possibility to define distribute
points or followup-transformations. However, it is the first
transformation that has to check whether the transformation is correct.

It interprets the same metadata as the LoopDistribute pass.

3 years ago[compiler-rt][test] Add REQUIRES for checking static libc++abi
Leonard Chan [Wed, 22 Sep 2021 22:25:05 +0000 (15:25 -0700)]
[compiler-rt][test] Add REQUIRES for checking static libc++abi

intercept-rethrow-exception.cc fails when running runtimes tests if linking in
a hermetic libc++abi. This is because if libc++abi is used, then asan expects
to intercept __cxa_rethrow_primary_exception on linux, which should unpoison the
stack. If we statically link in libc++abi though, it will contain a strong
definition for __cxa_rethrow_primary_exception which wins over the weakly
defined interceptor provided by asan, causing the test to fail by not unpoisoning
the stack on the exception being thrown.

It's likely no one has encountered this before and possible that upstream tests
opt for dynamically linking where the interceptor can work properly. An ideal
long term solution would be to update the interceptor and libc++[abi] APIs to
work for this case, but that will likely take a long time to work out. In the
meantime, since the test isn't necessarily broken, we can just add another
REQUIRES check to make sure that it's only run if we aren't statically linking
in libc++abi.

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

3 years ago[NFC] Remove trailing spaces from some files
Shilei Tian [Wed, 22 Sep 2021 22:16:56 +0000 (18:16 -0400)]
[NFC] Remove trailing spaces from some files

3 years ago[llvm-profgen] Use hot threshold for context merging and trimming
Wenlei He [Wed, 22 Sep 2021 01:17:49 +0000 (18:17 -0700)]
[llvm-profgen] Use hot threshold for context merging and trimming

Without preinliner, we need to tune down the cold count cutoff to merge/trim more context to limit profile size for large components. However it doesn't make sense for cold threshold to be higher than hot threshold, so we now change to use hot threshold as merging/trimming cut off instead.

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

3 years ago[mlir][sparse] add sparse kernels test to sparse compiler test suite
Aart Bik [Mon, 20 Sep 2021 18:15:13 +0000 (11:15 -0700)]
[mlir][sparse] add sparse kernels test to sparse compiler test suite

This test makes sure kernels map to efficient sparse code, i.e. all
compressed for-loops, no co-iterating while loops.  In addition, this
revision removes the special constant folding inside the sparse
compiler in favor of Mahesh' new generic linalg folding. Thanks!

NOTE: relies on Mahesh fix, which needs to be rebased first

Reviewed By: bixia

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

3 years ago[WebAssembly] Add relaxed-simd feature
Zhi An Ng [Wed, 22 Sep 2021 21:52:50 +0000 (14:52 -0700)]
[WebAssembly] Add relaxed-simd feature

This currently only defines a constant, but it the future will be used
to gate builtins for experimenting and prototyping relaxed-simd proposal
(https://github.com/WebAssembly/relaxed-simd/).

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

3 years ago[flang] Catch error: base of DATA statement object can't be a pointer
peter klausler [Tue, 14 Sep 2021 20:37:11 +0000 (13:37 -0700)]
[flang] Catch error: base of DATA statement object can't be a pointer

A pointer with subscripts, substring indices, or components cannot
be initialized by a DATA statement (although of course a whole pointer
can be so).  Catch the missing cases.

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

3 years agoDiagnose -Wunused-value based on CFG reachability
Yuanfang Chen [Thu, 24 Jun 2021 06:46:42 +0000 (23:46 -0700)]
Diagnose -Wunused-value based on CFG reachability

While at it, add the diagnosis message "left operand of comma operator has no effect" (used by GCC) for comma operator.

This also makes Clang diagnose in the constant evaluation context which aligns with GCC/MSVC behavior. (https://godbolt.org/z/7zxb8Tx96)

Reviewed By: aaron.ballman

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

3 years ago[RISCV] Remove stale FIXMEs from float-convert.ll and double-convert.ll. NFC
Craig Topper [Wed, 22 Sep 2021 21:25:40 +0000 (14:25 -0700)]
[RISCV] Remove stale FIXMEs from float-convert.ll and double-convert.ll. NFC

3 years ago[RISCV] Add fcvt.s.w(u)/fcvt.d.w(u)/fcvt.h.w(u) to hasAllNBitUsers
Craig Topper [Wed, 22 Sep 2021 21:21:03 +0000 (14:21 -0700)]
[RISCV] Add fcvt.s.w(u)/fcvt.d.w(u)/fcvt.h.w(u) to hasAllNBitUsers

These instructions only read the lower 32 bits of their input.

3 years ago[RISCV] Add test cases showing failure to use ADDIW before fcvt.s.w/fcvt.d.w/fcvt...
Craig Topper [Wed, 22 Sep 2021 21:16:30 +0000 (14:16 -0700)]
[RISCV] Add test cases showing failure to use ADDIW before fcvt.s.w/fcvt.d.w/fcvt.h.w. NFC

By not using ADDIW we can cause both an ADDIW and ADDI to be emitted
when the add has multiple users.

These instructions needed be added to the list of instructions that
only use the lower 32 bits of input.

I've also added tests for the wu versions, but I'm having trouble
showing bad codegen from it.

3 years agoFix bug for Ops with default valued attributes and successors/variadic regions.
Tyler Augustine [Wed, 22 Sep 2021 20:44:02 +0000 (20:44 +0000)]
Fix bug for Ops with default valued attributes and successors/variadic regions.

When both a DefaultValuedAttr and a successor or variadic region was specified, this would generate invalid C++ declaration. There would be the parameter with a default value, followed by the successors/regions, which don't have a default, which is invalid.

Reviewed By: mehdi_amini

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

3 years ago[OpenMP][Offloading] Change `bool IsSPMD` to `int8_t Mode` in `__kmpc_target_init...
Shilei Tian [Wed, 22 Sep 2021 21:16:28 +0000 (17:16 -0400)]
[OpenMP][Offloading] Change `bool IsSPMD` to `int8_t Mode` in `__kmpc_target_init` and `__kmpc_target_deinit`

This is a follow-up of D110029, which uses bitset to indicate execution mode. This patches makes the changes in the function call.

Reviewed By: jdoerfert

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

3 years ago[Clang] Ignore BTFTag attr if used as a type attribute
Yonghong Song [Mon, 20 Sep 2021 23:23:46 +0000 (16:23 -0700)]
[Clang] Ignore BTFTag attr if used as a type attribute

Currently, linux kernel has a __user attribute ([1]) defined as
   __attribute__((noderef, address_space(__user)))
which is used by sparse tool ([2]) to do some
type checking of pointers to user space memory.
During normal compilation, __user will be defined
to nothing so it won't have an impact on compilation.

The btf_tag attribute, which is motivated by
carrying linux kernel annotations into dwarf/BTF,
is introduced in [3]. We intended to define __user as
   __attribute__((btf_tag("user")))
so such information will be encoded in dwarf/BTF
and can be used later by bpf verification or other
tracing tools.

But linux kernel __user attribute is also used during
type conversion which btf_tag doesn't support ([4]) since
such type conversion is only used for compiler analysis
and not encoded in dwarf/btf. Theoretically, it is
possible for clang to understand these tags and
do a sparse-like type checking work. But I would like
to leave that to future work and for now suggest simply
ignore these btf_tag attributes if they are used
as type attributes.

  [1] https://github.com/torvalds/linux/blob/master/include/linux/compiler_types.h#L10
  [2] https://sparse.docs.kernel.org/en/latest/
  [3] https://reviews.llvm.org/D106614
  [4] https://github.com/torvalds/linux/blob/master/fs/binfmt_flat.c#L135

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

3 years ago[mlir][Linalg] Teach constant -> generic op fusion to handle scalar constants.
MaheshRavishankar [Wed, 22 Sep 2021 18:14:19 +0000 (11:14 -0700)]
[mlir][Linalg] Teach constant -> generic op fusion to handle scalar constants.

The current folder of constant -> generic op only handles splat
constants. The same logic holds for scalar constants. Teach the
pattern to handle such cases.

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

3 years ago[libc++][NFC] Add missing whitespace in <compare>
Louis Dionne [Wed, 22 Sep 2021 20:41:11 +0000 (16:41 -0400)]
[libc++][NFC] Add missing whitespace in <compare>

3 years ago[InstCombine] add one-use check to shift-shift transform
Sanjay Patel [Wed, 22 Sep 2021 20:16:49 +0000 (16:16 -0400)]
[InstCombine] add one-use check to shift-shift transform

We don't want to create extra instructions, and this
could infinite loop with the proposed transform in D110170.

3 years ago[InstCombine] add test for shift-shift with extra use; NFC
Sanjay Patel [Wed, 22 Sep 2021 20:15:47 +0000 (16:15 -0400)]
[InstCombine] add test for shift-shift with extra use; NFC

3 years ago[JumpThreading] Add test with free instructions (NFC)
Nikita Popov [Wed, 22 Sep 2021 20:28:58 +0000 (22:28 +0200)]
[JumpThreading] Add test with free instructions (NFC)

Which demonstrates that "free" instructions can prevent jump
threading.

3 years ago[mlir:DataFlowAnalysis] Reprocess the arguments of already executable edges
River Riddle [Wed, 22 Sep 2021 20:07:05 +0000 (20:07 +0000)]
[mlir:DataFlowAnalysis] Reprocess the arguments of already executable edges

This fixes a bug where we discover new information about the arguments of an
already executable edge, but don't visit the arguments. We only visit the arguments, and not the block itself, so this commit shouldn't really affect performance at all.

Fixes PR#51871

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

3 years agoReset operation when canceling root update transaction
Yi Zhang [Wed, 22 Sep 2021 20:02:05 +0000 (16:02 -0400)]
Reset operation when canceling root update transaction

Should reset the operation to original state when canceling the updates.

Reviewed By: rriddle, ftynse

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

3 years ago[libc++][NFCI] Remove uses of _LIBCPP_INLINE_VAR
Louis Dionne [Wed, 22 Sep 2021 13:35:32 +0000 (09:35 -0400)]
[libc++][NFCI] Remove uses of _LIBCPP_INLINE_VAR

All supported compilers provide support for inline variables in C++17 now.
Also, as a fly-by fix, replace some uses of _LIBCPP_CONSTEXPR by just
constexpr.

The only exception in this patch is `std::ignore`, which is provided
prior to C++17. Since it is defined in an anonymous namespace, it always
has internal linkage anyway, so using an inline variable there doesn't
provide any benefit. Instead, `inline` was removed entirely on `std::ignore`.

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

3 years ago[libc++][test] Remove disable_missing_braces_warning.h from tests
Joe Loser [Wed, 22 Sep 2021 20:00:16 +0000 (16:00 -0400)]
[libc++][test] Remove disable_missing_braces_warning.h from tests

Several tests include `disable_missing_braces_warning.h` but do not need
to. Remove the include.

Inspired from discussion at https://reviews.llvm.org/D109668

Reviewed By: ldionne, #libc, Mordante

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

3 years ago[mlir][sparse] generalize reduction support in sparse compiler
Aart Bik [Tue, 21 Sep 2021 21:48:49 +0000 (14:48 -0700)]
[mlir][sparse] generalize reduction support in sparse compiler

Now not just SUM, but also PRODUCT, AND, OR, XOR. The reductions
MIN and MAX are still to be done (also depends on recognizing
these operations in cmp-select constructs).

Reviewed By: bixia

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

3 years ago[ValueTracking] fix isOnlyUsedInZeroEqualityComparison with no users
Sanjay Patel [Wed, 22 Sep 2021 19:01:53 +0000 (15:01 -0400)]
[ValueTracking] fix isOnlyUsedInZeroEqualityComparison with no users

This is another problem exposed by:
https://bugs.llvm.org/PR50836

3 years ago[Analysis] reduce code for isOnlyUsedInZeroEqualityComparison; NFC
Sanjay Patel [Wed, 22 Sep 2021 18:56:27 +0000 (14:56 -0400)]
[Analysis] reduce code for isOnlyUsedInZeroEqualityComparison; NFC

There's a bug here noted by the FIXME and visible in variations of PR50836.

3 years ago[ELF][AArch64] Refine and fix the condition when BTI/PAC PLT needs bti c
Fangrui Song [Wed, 22 Sep 2021 18:51:09 +0000 (11:51 -0700)]
[ELF][AArch64] Refine and fix the condition when BTI/PAC PLT needs bti c

(As I mentioned in https://reviews.llvm.org/D62609#1534158 ,
the condition for using bti c for executable can be loosened.)

In two cases the address of a PLT may escape:

* canonical PLT entry for a STT_FUNC
* non-preemptible STT_GNU_IFUNC which is converted to STT_FUNC

The first case can be detected with `needsPltAddr`.

The second case is not straightforward to detect because for the Relocations.cpp
created `directSym`, it's difficult to know whether the associated `sym` has
exercised the `!needsPlt(expr)` code path. Just use the conservative `isInIplt`
condition. A non-preemptible ifunc not referenced by non-GOT-generating
non-PLT-generating relocations will have an unneeded `bti c`, but the cost is acceptable.

The second case fixes a bug as well: a -shared link may have non-preemptible ifunc.
Before the patch we did not emit `bti c` and could be wrong if the PLT address escaped.
GNU ld doesn't handle the case: `relocation R_AARCH64_ADR_PREL_PG_HI21 against STT_GNU_IFUNC symbol 'ifunc2' isn't handled by elf64_aarch64_final_link_relocate` (https://sourceware.org/bugzilla/show_bug.cgi?id=28370)

For -shared, if BTI is enabled but PAC is disabled, the PLT entry size increases
from 16 to 24 because we have to select the PLT scheme early, but the cost is
acceptable.

Reviewed By: peter.smith

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

3 years ago[OpenMP] Fix KeepAlive usage
Joseph Huber [Wed, 22 Sep 2021 18:37:33 +0000 (14:37 -0400)]
[OpenMP] Fix KeepAlive usage

Summary:
Functions were called the wrong way around, this didn't keep the symbol
alive.

3 years agoDebugInfo: Add (initially no-op) -gsimple-template-names={simple,mangled}
David Blaikie [Wed, 22 Sep 2021 03:25:13 +0000 (20:25 -0700)]
DebugInfo: Add (initially no-op) -gsimple-template-names={simple,mangled}

This is to build the foundation of a new debug info feature to use only
the base name of template as its debug info name (eg: "t1" instead of
the full "t1<int>"). The intent being that a consumer can still retrieve
all that information from the DW_TAG_template_*_parameters.

So gno-simple-template-names is business as usual/previously ("t1<int>")
   =simple is the simplified name ("t1")
   =mangled is a special mode to communicate the full information, but
   also indicate that the name should be able to be simplified. The data
   is encoded as "_STNt1|<int>" which will be matched with an
   llvm-dwarfdump --verify feature to deconstruct this name, rebuild the
   original name, and then try to rebuild the simple name via the DWARF
   tags - then compare the latter and the former to ensure that all the
   data necessary to fully rebuild the name is present.

3 years ago[lldb] Remove IRExecutionUnit::CollectFallbackNames
Alex Langford [Wed, 15 Sep 2021 21:36:49 +0000 (14:36 -0700)]
[lldb] Remove IRExecutionUnit::CollectFallbackNames

The work that IRExecutionUnit::CollectFallbackNames is basically the
work that `CPlusPlusLanguage::GetDemangledFunctionNameWithoutArguments`
does already. It's also (at time or writing) specific to C++, so it can
be folded into `IRExecutionUnit::CollectCandidateCPlusPlusNames`.

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

3 years agoMark CFG as preserved in TypePromotion and InterleaveAccess passes
David Green [Wed, 22 Sep 2021 17:58:00 +0000 (18:58 +0100)]
Mark CFG as preserved in TypePromotion and InterleaveAccess passes

Neither of these passes modify the CFG, allowing us to preserve DomTree
and LoopInfo across them by using setPreservesCFG.

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

3 years agoChange error for storage-class to mean linkage, fix lang-linkage diag
Erich Keane [Wed, 22 Sep 2021 14:25:50 +0000 (07:25 -0700)]
Change error for storage-class to mean linkage, fix lang-linkage diag

Allow multiversioning declarations to match when the actual formal
linkage matches, not just when the storage class is identical.
Additionally, change the ambiguous 'linkage' mismatch to be more
specific and say 'language linkage'.

3 years ago[Analysis] improve function matching for strlen libcall
Sanjay Patel [Wed, 22 Sep 2021 17:24:51 +0000 (13:24 -0400)]
[Analysis] improve function matching for strlen libcall

The return type of strlen is size_t, not just any integer.

This is a partial fix for an example based on:
https://llvm.org/PR50836

There's another bug here because we can still crash
processing a real strlen or something that looks like it.

3 years agoDon't diagnose unused but set when the Cleanup attribute is used.
Michael Benfield [Wed, 15 Sep 2021 22:57:41 +0000 (22:57 +0000)]
Don't diagnose unused but set when the Cleanup attribute is used.

This applies to -Wunused-but-set-variable and
-Wunused-but-set-parameter.

This addresses bug 51865.

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

3 years ago[mlir][linalg] Fix interchange initialization in fusion on tensors.
Tobias Gysi [Wed, 22 Sep 2021 17:27:10 +0000 (17:27 +0000)]
[mlir][linalg] Fix interchange initialization in fusion on tensors.

If no interchange vector is given initialize it with the identity permutation from 0 to number of loops.

Reviewed By: mravishankar

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

3 years ago[llvm-profgen] An option to dump disasm of specified symbols
Hongtao Yu [Wed, 22 Sep 2021 16:11:53 +0000 (09:11 -0700)]
[llvm-profgen] An option to dump disasm of specified symbols

For large app, dumping disasm of the whole program can be slow and result in gianant output. Adding a switch to dump specific symbols only.

Reviewed By: wlei

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

3 years ago[NFCI][CodeGen, AArch64] Fix inconsistent TargetCostKind types.
Daniil Fukalov [Mon, 20 Sep 2021 19:33:38 +0000 (22:33 +0300)]
[NFCI][CodeGen, AArch64] Fix inconsistent TargetCostKind types.

The pass uses different cost kinds to estimate "old" and "interleaved" costs:
default cost kind for all targets override `getInterleavedMemoryOpCost()` is
`TCK_SizeAndLatency`. Although at the moment estimated `TCK_Latency` costs are
equal to `TCK_SizeAndLatency`, (so the change is NFC) it may change in future.

Reviewed By: RKSimon

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

3 years agoAdd document numbers for the C99 status page.
Aaron Ballman [Wed, 22 Sep 2021 17:00:13 +0000 (13:00 -0400)]
Add document numbers for the C99 status page.

This doesn't add all of the document numbers, but it adds a bunch of
them. Not all of the documents are available on the committee page
(they're old enough that they come from a time when the mailing was
comprised of physical pieces of paper), so some of the documents listed
are assumed to be correct based on my reading of editor's reports.

3 years ago[SimplifyCFG] Ignore free instructions when computing cost for folding branch to...
Arthur Eubanks [Fri, 27 Aug 2021 19:32:59 +0000 (12:32 -0700)]
[SimplifyCFG] Ignore free instructions when computing cost for folding branch to common dest

When determining whether to fold branches to a common destination by
merging two blocks, SimplifyCFG will count the number of instructions to
be moved into the first basic block. However, there's no reason to count
free instructions like bitcasts and other similar instructions.

This resolves missed branch foldings with -fstrict-vtable-pointers in
llvm-test-suite's lambda benchmark.

Reviewed By: spatel

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

3 years ago[libc] Add an implementation of bsearch.
Siva Chandra Reddy [Tue, 21 Sep 2021 23:53:30 +0000 (23:53 +0000)]
[libc] Add an implementation of bsearch.

Reviewed By: michaelrj

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

3 years ago[HWASan] Use a single .weak binding in asm.
Matt Morehouse [Wed, 22 Sep 2021 16:34:49 +0000 (09:34 -0700)]
[HWASan] Use a single .weak binding in asm.

Specifying .global and .weak causes a compiler warning:

  warning: __sigsetjmp changed binding to STB_WEAK

Specifying only .weak should have the same effect without causing a
warning.

Reviewed By: eugenis

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

3 years ago[ORC] DebugObjectManagerPlugin tests can use lli in ORC greedy mode
Stefan Gränitz [Wed, 22 Sep 2021 15:46:08 +0000 (17:46 +0200)]
[ORC] DebugObjectManagerPlugin tests can use lli in ORC greedy mode

Initially, lli only supported lazy mode for ORC. Greedy mode was added with e1579894d205 and it's the default setting now. DebugObjectManagerPlugin tests don't rely on laziness, so we can switch them to greedy in order to avoid some unnecessary complexity.

3 years ago[OpenMP] Add function tracing debugging to device RTL
Joseph Huber [Tue, 21 Sep 2021 21:34:11 +0000 (17:34 -0400)]
[OpenMP] Add function tracing debugging to device RTL

This patch adds support for an RAII struct that will print function
traces when placed inside of a function declaration. Each successive
call will increase the indentation to make it easier to visually
inspect.

Reviewed By: jdoerfert

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

3 years ago[mlir][sparse] replace ad-hoc MemRef struct with CRunnerUtils definition
Aart Bik [Wed, 22 Sep 2021 05:56:00 +0000 (22:56 -0700)]
[mlir][sparse] replace ad-hoc MemRef struct with CRunnerUtils definition

This revision removes the ad-hoc MemRefs that were needed using the old
ABI (when we still passed by value) and replaces them with the shared
StridedMemRef definitions of CRunnerUtils (possible now that we pass by
pointer). This avoids code duplication and makes sure we have a consistent
view of strided memory references in all our support libraries.

Reviewed By: jsetoain

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

3 years ago[RISCV] Optimize vp.store with an all ones mask to avoid a vmset.
Craig Topper [Wed, 22 Sep 2021 16:12:45 +0000 (09:12 -0700)]
[RISCV] Optimize vp.store with an all ones mask to avoid a vmset.

We can use riscv_vse intrinsic instead of riscv_vse_mask. The code here
is based on similar code for handling masked.scatter and vp.scatter.

Reviewed By: frasercrmck

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

3 years ago[NFC] clang-format -i llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
Shilei Tian [Wed, 22 Sep 2021 16:10:02 +0000 (12:10 -0400)]
[NFC] clang-format -i llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp

3 years ago[CSSPGO] Set PseudoProbeInserter as a default pass.
Hongtao Yu [Wed, 22 Sep 2021 00:16:45 +0000 (17:16 -0700)]
[CSSPGO] Set PseudoProbeInserter as a default pass.

Currenlty PseudoProbeInserter is a pass conditioned on a target switch. It works well with a single clang invocation. It doesn't work so well when the backend is called separately (i.e, through the linker or llc), where user has always to pass -pseudo-probe-for-profiling explictly. I'm making the pass a default pass that requires no command line arg to trigger, but will be actually run depending on whether the CU comes with `llvm.pseudo_probe_desc` metadata.

Reviewed By: wenlei

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

3 years ago[SLP][NFC]Add a test to show an issue with incorrectly extracted
Alexey Bataev [Wed, 22 Sep 2021 15:08:40 +0000 (08:08 -0700)]
[SLP][NFC]Add a test to show an issue with incorrectly extracted
pointers.

3 years ago[CodeGen] Remove redundant declaration MIRCanonicalizerID (NFC)
Kazu Hirata [Wed, 22 Sep 2021 15:58:26 +0000 (08:58 -0700)]
[CodeGen] Remove redundant declaration MIRCanonicalizerID (NFC)

Note that MIRCanonicalizerID is declared in
llvm/include/llvm/CodeGen/Passes.h, which MIRCanonicalizerPass.cpp
includes.

Identified with readability-redundant-declaration.

3 years ago[ORC] Re-enable ELF DebugObjectManagerPlugin tests
Stefan Gränitz [Wed, 22 Sep 2021 15:35:26 +0000 (17:35 +0200)]
[ORC] Re-enable ELF DebugObjectManagerPlugin tests

These tests were disabled by accident after D107640. Actually, REQUIRES lines don't support `x86_64` and so these tests stopped running on all targets.
`native && target-x86_64` should be the correct term to express "x86_64 host targeting native arch".

3 years ago[SLP] getReductionCost - use explicit TTI::TCK_RecipThroughput CostKind. NFCI.
Simon Pilgrim [Wed, 22 Sep 2021 15:48:01 +0000 (16:48 +0100)]
[SLP] getReductionCost - use explicit TTI::TCK_RecipThroughput CostKind. NFCI.

Avoid relying on the default cost kinds in TTI calls (we already do this in other places in SLP) - noticed while trying to see how much work it'd be to extend D110242 and remove all remaining uses of default CostKind arguments.

3 years ago[InstCombine] Update InstCombine to use poison instead of undef for shufflevector...
hyeongyu kim [Wed, 22 Sep 2021 15:23:31 +0000 (00:23 +0900)]
[InstCombine] Update InstCombine to use poison instead of undef for shufflevector's placeholder (3/3)

This patch is for fixing potential shufflevector-related bugs like D93818.
As D93818, this patch change shufflevector's default placeholder to poison.
To reduce risk, it was divided into several patches, and this patch is for InstCombineVectorOps.

Reviewed By: spatel

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

3 years ago[libc++] Disallow volatile types in std::allocator
Joe Loser [Wed, 22 Sep 2021 15:46:21 +0000 (11:46 -0400)]
[libc++] Disallow volatile types in std::allocator

LWG 2447 is marked as `Complete`, but there is no `static_assert` to
reject volatile types in `std::allocator`. See the discussion at
https://reviews.llvm.org/D108856.

Add `static_assert` in `std::allocator` to disallow volatile types. Since this
is an implementation choice, mark the binding test as `libc++` only.

Remove tests that use containers backed by `std::allocator` that test
the container when used with a volatile type.

Reviewed By: ldionne, #libc

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

3 years ago[OpenMP][Offloading] Use bitset to indicate execution mode instead of value
Shilei Tian [Wed, 22 Sep 2021 15:40:37 +0000 (11:40 -0400)]
[OpenMP][Offloading] Use bitset to indicate execution mode instead of value

The execution mode of a kernel is stored in a global variable, whose value means:
- 0 - SPMD mode
- 1 - indicates generic mode
- 2 - SPMD mode execution with generic mode semantics

We are going to add support for SIMD execution mode. It will be come with another
execution mode, such as SIMD-generic mode. As a result, this value-based indicator
is not flexible.

This patch changes to bitset based solution to encode execution mode. Each
position is:
[0] - generic mode
[1] - SPMD mode
[2] - SIMD mode (will be added later)

In this way, `0x1` is generic mode, `0x2` is SPMD mode, and `0x3` is SPMD mode
execution with generic mode semantics. In the future after we add the support for
SIMD mode, `0b1xx` will be in SIMD mode.

Reviewed By: jdoerfert

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

3 years ago[InstCombine] Update InstCombine to use poison instead of undef for shufflevector...
hyeongyu kim [Wed, 22 Sep 2021 14:30:33 +0000 (23:30 +0900)]
[InstCombine] Update InstCombine to use poison instead of undef for shufflevector's placeholder (2/3)

This patch is for fixing potential shufflevector-related bugs like D93818.
As D93818, this patch change shufflevector's default placeholder to poison.
To reduce risk, it was divided into several patches, and this patch is for InstCombineCompares and InstructionCombining.

Reviewed By: spatel

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

3 years ago[libc++][NFC] Add link to Discord channel from documentation
Louis Dionne [Wed, 22 Sep 2021 15:13:47 +0000 (11:13 -0400)]
[libc++][NFC] Add link to Discord channel from documentation

3 years ago[Sanitizer] Add Windows header for _mkdir
Teresa Johnson [Wed, 22 Sep 2021 15:04:08 +0000 (08:04 -0700)]
[Sanitizer] Add Windows header for _mkdir

This will hopefully fix the sanitizer_windows bot failure after D109794:
https://lab.llvm.org/buildbot/#/builders/127/builds/17222

3 years ago[Target][CodeGen] Remove default CostKind arguments on inner/impl TTI overrides
Simon Pilgrim [Wed, 22 Sep 2021 13:40:29 +0000 (14:40 +0100)]
[Target][CodeGen] Remove default CostKind arguments on inner/impl TTI overrides

Based off a discussion on D110100, we should be avoiding default CostKinds whenever possible.

This initial patch removes them from the 'inner' target implementation callbacks - these should only be used by the main TTI calls, so this should guarantee that we don't cause changes in CostKind by missing it in an inner call. This exposed a few missing arguments in getGEPCost and reduction cost calls that I've cleaned up.

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

3 years ago[InstCombine] Update InstCombine to use poison instead of undef for shufflevector...
hyeongyu kim [Wed, 22 Sep 2021 13:39:54 +0000 (22:39 +0900)]
[InstCombine] Update InstCombine to use poison instead of undef for shufflevector's placeholder (1/3)

This patch is for fixing potential shufflevector-related bugs like D93818.
As D93818, this patch change shufflevector's default placeholder to poison.
To reduce risk, it was divided into several patches, and this patch is for InstCombineCasts.

Reviewed By: spatel

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

3 years ago[AArch64][SVE] NFC: Move extract_subvector tests around.
Sander de Smalen [Fri, 17 Sep 2021 14:14:24 +0000 (15:14 +0100)]
[AArch64][SVE] NFC: Move extract_subvector tests around.

This patch splits up sve-extract-vector.ll into
  * sve-extract-fixed-vector.ll
  * sve-extract-scalable-vector.ll

For testing extracts of a fixed-width or scalable sub-vector from a
scalable source vector, respectively.

3 years ago[OpenMP] Make sure the Thread ID function is not removed
Joseph Huber [Wed, 22 Sep 2021 13:20:49 +0000 (09:20 -0400)]
[OpenMP] Make sure the Thread ID function is not removed

Summary:
The thread ID function was reintroduced in D110195, but could
potentially be removed by the optimizer. Make the function noinline to
preserve the call sites and add it to the externalization RAII so its
definition is not removed by the attributor.

3 years ago[mailmap] Add entry for myself
Joseph Tremoulet [Wed, 22 Sep 2021 14:12:16 +0000 (10:12 -0400)]
[mailmap] Add entry for myself

3 years ago[AArch64][SVE] Add extract_subvector patterns for unpacked fp16 and bfloat types.
Sander de Smalen [Wed, 22 Sep 2021 13:25:14 +0000 (14:25 +0100)]
[AArch64][SVE] Add extract_subvector patterns for unpacked fp16 and bfloat types.

Reviewed By: david-arm

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

3 years ago[SelectionDAG] Remove PromoteIntOp_EXTRACT_SUBVECTOR.
Sander de Smalen [Wed, 22 Sep 2021 12:34:00 +0000 (13:34 +0100)]
[SelectionDAG] Remove PromoteIntOp_EXTRACT_SUBVECTOR.

This code seems untested and is likely obsolete, because this case
should already be handled by the code that legalizes the result type
of EXTRACT_SUBVECTOR.

Reviewed By: craig.topper

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

3 years agoAArch64: use indivisible cmpxchg for 128-bit atomic loads at O0
Tim Northover [Wed, 22 Sep 2021 12:06:55 +0000 (13:06 +0100)]
AArch64: use indivisible cmpxchg for 128-bit atomic loads at O0

Like normal atomicrmw operations, at -O0 the simple register-allocator can
insert spills into the LL/SC loop if it's expanded and visible when regalloc
runs. This can cause the operation to never succeed by repeatedly clearing the
monitor. Instead expand to a cmpxchg, which has a pseudo-instruction for -O0.

3 years ago[ELF][test] Restore important part of ICF alignment test
Andrew Ng [Mon, 20 Sep 2021 18:13:30 +0000 (19:13 +0100)]
[ELF][test] Restore important part of ICF alignment test

Restore the checking of addresses in ICF test which was testing the
behaviour of ICF with regards to different alignments of otherwise
identical sections. Also make the test more robust to layout changes.

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

3 years ago[SLP][NFC]Rename function in the test for better matching of the
Alexey Bataev [Wed, 22 Sep 2021 12:50:14 +0000 (05:50 -0700)]
[SLP][NFC]Rename function in the test for better matching of the
transformation.

3 years ago[lldb] JITLoaderGDB tests can use lli in ORC greedy mode
Stefan Gränitz [Wed, 22 Sep 2021 11:54:26 +0000 (13:54 +0200)]
[lldb] JITLoaderGDB tests can use lli in ORC greedy mode

At first, lli only supported lazy mode for ORC. Greedy mode was added with e1579894d205 and is the default settings now. JITLoaderGDB tests don't rely on laziness, so we can switch them to greedy and remove some complexity.

3 years ago[SelectionDAG] Add PromoteIntOp_INSERT_SUBVECTOR.
Sander de Smalen [Wed, 22 Sep 2021 09:59:21 +0000 (10:59 +0100)]
[SelectionDAG] Add PromoteIntOp_INSERT_SUBVECTOR.

This is required to codegen something like:
  <vscale x 8 x i16> @llvm.experimental.vector.insert(<vscale x 8 x i16> %vec,
                                                      <vscale x 2 x i16> %subvec,
                                                      i64 %idx)
where the output vector is legal, but the input vector needs promoting.

It implements this by performing the whole operation on the promoted type,
and then truncating the result.

Reviewed By: david-arm, craig.topper

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

3 years ago[gn build] Port 7a320b279d07
LLVM GN Syncbot [Wed, 22 Sep 2021 12:20:22 +0000 (12:20 +0000)]
[gn build] Port 7a320b279d07

3 years ago[gn build] (manually) port f8b1cc365786
Nico Weber [Wed, 22 Sep 2021 12:20:12 +0000 (08:20 -0400)]
[gn build] (manually) port f8b1cc365786

3 years ago[Passes] Run vector-combine early with -fenable-matrix.
Florian Hahn [Wed, 22 Sep 2021 11:29:48 +0000 (12:29 +0100)]
[Passes] Run vector-combine early with -fenable-matrix.

IR with matrix intrinsics is likely to also contain large vector
operations, which can benefit from early simplifications.

This is the last step in a series of changes to improve code-gen for
code using matrix subscript operators with the C/C++ matrix extension in
CLang, like

    using matrix_t = double __attribute__((matrix_type(15, 15)));

    void foo(unsigned i, matrix_t &A, matrix_t &B) {
      for (unsigned j = 0; j < 4; ++j)
        for (unsigned k = 0; k < i; k++)
          B[k][j] -= A[k][j] * B[i][j];
    }

https://clang.godbolt.org/z/6dKxK1Ed7

Reviewed By: spatel

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

3 years agoRevert "[InstCombine] fold cast of right-shift if high bits are not demanded"
Sanjay Patel [Wed, 22 Sep 2021 11:44:17 +0000 (07:44 -0400)]
Revert "[InstCombine] fold cast of right-shift if high bits are not demanded"

This reverts commit 2f6b07316f560a1f6d225919019dff2e5d6346e5.

This caused several bots to hit an infinite loop at stage 2,
so it needs to be reverted while figuring out how to fix that.