platform/upstream/llvm.git
3 years ago[gn build] (semi-manually) port 702cb7afe9de
Nico Weber [Thu, 23 Sep 2021 13:26:18 +0000 (09:26 -0400)]
[gn build] (semi-manually) port 702cb7afe9de

3 years ago[CodeGen] update test file to not run the entire LLVM optimizer; NFC
Sanjay Patel [Thu, 23 Sep 2021 12:53:28 +0000 (08:53 -0400)]
[CodeGen] update test file to not run the entire LLVM optimizer; NFC

Clang regression tests should not break when changes are made to
the LLVM optimizer. This file broke on the 1st attempt at D110170,
so I'm trying to prevent that on another try.

Similar to other files in this directory, we make a compromise and
run -mem2reg to reduce noise by about 1000 lines out of 5000+ CHECK lines.

3 years ago[libc++] Remove uses of _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
Louis Dionne [Wed, 22 Sep 2021 13:46:19 +0000 (09:46 -0400)]
[libc++] Remove uses of _LIBCPP_HAS_NO_VARIABLE_TEMPLATES

All supported compilers provide support for variable templates now.

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

3 years agotsan: remove expected race leftover
Dmitry Vyukov [Thu, 23 Sep 2021 11:52:49 +0000 (13:52 +0200)]
tsan: remove expected race leftover

Remove nmissed_expected variable.
It's a leftover from removed "expected race" feature and is never incremented.

Reviewed By: melver

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

3 years ago[DSE] Track earliest escape, use for loads in isReadClobber.
Florian Hahn [Thu, 23 Sep 2021 07:54:46 +0000 (08:54 +0100)]
[DSE] Track earliest escape, use for loads in isReadClobber.

At the moment, DSE only considers whether a pointer may be captured at
all in a function. This leads to cases where we fail to remove stores to
local objects because we do not check if they escape before potential
read-clobbers or after.

Doing context-sensitive escape queries in isReadClobber has been removed
a while ago in d1a1cce5b130 to save compile-time. See PR50220 for more
context.

This patch introduces a new capture tracker, which keeps track of the
'earliest' capture. An instruction A is considered earlier than instruction
B, if A dominates B. If 2 escapes do not dominate each other, the
terminator of the common dominator is chosen. If not all uses cannot be
analyzed, the earliest escape is set to the first instruction in the
function entry block.

If the query instruction dominates the earliest escape and is not in a
cycle, then pointer does not escape before the query instruction.

This patch uses this information when checking if a load of a loaded
underlying object may alias a write to a stack object. If the stack
object does not escape before the load, they do not alias.

I will share a follow-up patch to also use the information for call
instructions to fix PR50220.

In terms of compile-time, the impact is low in general,
    NewPM-O3: +0.05%
    NewPM-ReleaseThinLTO: +0.05%
    NewPM-ReleaseLTO-g: +0.03

with the largest change being tramp3d-v4 (+0.30%)
http://llvm-compile-time-tracker.com/compare.php?from=1a3b3301d7aa9ab25a8bdf045c77298b087e3930&to=bc6c6899cae757c3480f4ad4874a76fc1eafb0be&stat=instructions

Compared to always computing the capture information on demand, we get
the following benefits from the caching:
NewPM-O3: -0.03%
NewPM-ReleaseThinLTO: -0.08%
NewPM-ReleaseLTO-g: -0.04%

The biggest speedup is tramp3d-v4 (-0.21%).
http://llvm-compile-time-tracker.com/compare.php?from=0b0c99177d1511469c633282ef67f20c851f58b1&to=bc6c6899cae757c3480f4ad4874a76fc1eafb0be&stat=instructions

Overall there is a small, but noticeable benefit from caching. I am not
entirely sure if the speedups warrant the extra complexity of caching.
The way the caching works also means that we might miss a few cases, as
it is less precise. Also, there may be a better way to cache things.

Reviewed By: nikic

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

3 years ago[RISCV] Add missing op type OPERAND_UIMM2, OPERAND_UIMM3 and OPERAND_UIMM7 for verify...
Jim Lin [Thu, 23 Sep 2021 11:23:00 +0000 (19:23 +0800)]
[RISCV] Add missing op type OPERAND_UIMM2, OPERAND_UIMM3 and OPERAND_UIMM7 for verifyInstruction

Reviewed By: craig.topper

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

3 years ago[CodeGen] ProcessSDDbgValues - use const-ref value in for-range loop. NFCI.
Simon Pilgrim [Wed, 22 Sep 2021 17:40:22 +0000 (18:40 +0100)]
[CodeGen] ProcessSDDbgValues - use const-ref value in for-range loop. NFCI.

Avoid unnecessary copies, reported by MSVC static analyzer.

3 years ago[CodeGen] RegisterCoalescer::buildVRegToDbgValueMap - use const-ref value in for...
Simon Pilgrim [Wed, 22 Sep 2021 17:38:10 +0000 (18:38 +0100)]
[CodeGen] RegisterCoalescer::buildVRegToDbgValueMap - use const-ref value in for-range loop. NFCI.

Avoid unnecessary copies, reported by MSVC static analyzer.

3 years ago[BasicBlockUtils] Fixup of an assumed typo in MergeBlockIntoPredecessor
Bjorn Pettersson [Thu, 23 Sep 2021 10:13:28 +0000 (12:13 +0200)]
[BasicBlockUtils] Fixup of an assumed typo in MergeBlockIntoPredecessor

The NFC commit e5692a564a73ef63b7b changed the logic for
DomTreeUpdates to use the range [succ_begin, succ_begin) when
looking for SuccsOfPredBB rather than using [succ_begin, succ_end).

As the commit was NFC this is identified as a typo (it has been
discussed briefly in phabricator).

The typo was found when inspecting the code, so I've got no idea if
changing back to the old range has any significant impact (such as
solving any PR:s or causing some new problems). But at least this
restores the code to the originally indented behavior.

3 years ago[lldb] Fix DomainSocket::GetSocketName for unnamed sockets
Pavel Labath [Thu, 23 Sep 2021 09:31:33 +0000 (11:31 +0200)]
[lldb] Fix DomainSocket::GetSocketName for unnamed sockets

getpeername will return addrlen = 2 (sizeof sa_family_t) for unnamed
sockets (those not assigned a name with bind(2)). This is typically true
for client sockets as well as those created by socketpair(2).

This GetSocketName used to crash for sockets which were connected to
these kinds of sockets. Now it returns an empty string.

3 years ago[RISCV][VP] Add support for VP_REDUCE_* operations
Fraser Cormack [Thu, 5 Aug 2021 12:54:37 +0000 (13:54 +0100)]
[RISCV][VP] Add support for VP_REDUCE_* operations

This patch adds codegen support for lowering the vector-predicated
reduction intrinsics to RVV instructions. The process is similar to that
of the other reduction intrinsics, save for the fact that every VP
reduction has a start value. We reuse the existing custom "VL" nodes,
adding extra patterns where required to handle non-true masks.

To support these nodes, the `RISCVISD::VECREDUCE_*_VL` nodes have been
given an explicit "merge" operand. This is to faciliate the VP
reductions, where we must be careful to ensure that even if no operation
is performed (when VL=0) we still produce the start value. The RVV
reductions don't update the destination register under these conditions,
so we tie the splatted start value to the output register.

Reviewed By: craig.topper

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

3 years ago[fir][NFC] inline trival isa_<type> functions
Valentin Clement [Thu, 23 Sep 2021 09:08:26 +0000 (11:08 +0200)]
[fir][NFC] inline trival isa_<type> functions

This patch is part of the upstreaming effort from fir-dev branch and sync changes. Inline trival `isa_<type>` functions.

Co-authored-by: schweitzpgi
Reviewed By: kiranchandramohan

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

3 years agotsan: move shadow declaration into a separate header file (NFC)
Dmitry Vyukov [Wed, 22 Sep 2021 17:25:28 +0000 (19:25 +0200)]
tsan: move shadow declaration into a separate header file (NFC)

tsan_rtl.h is very huge and contains too many things.
Move FastState and Shadow types into a new tsan_shadow.h file.
This also allows to use FastState/Shadow in other header files
without creating circular dependencies (which most likely will
happen today).

Reviewed By: melver

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

3 years agotsan: use RawShadow instead of u64 more
Dmitry Vyukov [Wed, 22 Sep 2021 16:41:03 +0000 (18:41 +0200)]
tsan: use RawShadow instead of u64 more

Fix few remaining cases where we use u64 instead of the new RawShadow type.

Depends on D110265.

Reviewed By: melver

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

3 years agotsan: add another deep stack test
Dmitry Vyukov [Wed, 22 Sep 2021 15:56:52 +0000 (17:56 +0200)]
tsan: add another deep stack test

Add a test for a trace corner case that lead to a bug
in experimental runtime replacement.
Since it passes with the current runtime it makes sense
to submit it on its own.

Depends on D110264.

Reviewed By: melver

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

3 years agotsan: remove DontDumpShadow from Go build
Dmitry Vyukov [Wed, 22 Sep 2021 15:50:54 +0000 (17:50 +0200)]
tsan: remove DontDumpShadow from Go build

DontDumpShadow is used only in InitializeShadowMemory which is Go-only.

Depends on D110263.

Reviewed By: melver

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

3 years agotsan: remove unnecessary enum values (NFC)
Dmitry Vyukov [Wed, 22 Sep 2021 15:48:11 +0000 (17:48 +0200)]
tsan: remove unnecessary enum values (NFC)

Remove unnecessary enum values in the memory profiler.
There is no point in spelling them, it can only lead to bugs
and larger diffs when values are added/removed.

Reviewed By: melver

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

3 years ago[InstSimplify] Don't lose inbounds when simplifying a GEP
Alex Richardson [Thu, 23 Sep 2021 08:02:23 +0000 (09:02 +0100)]
[InstSimplify] Don't lose inbounds when simplifying a GEP

I noticed this while working on a (ptrtoint (gep null, x)) -> x fold.

Reviewed By: nikic

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

3 years ago[libc] Add optimized memset for AArch64
Andre Vieira [Thu, 23 Sep 2021 08:19:47 +0000 (09:19 +0100)]
[libc] Add optimized memset for AArch64

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

3 years agoRevert "[Driver] Correctly handle static C++ standard library"
Petr Hosek [Thu, 23 Sep 2021 08:13:10 +0000 (01:13 -0700)]
Revert "[Driver] Correctly handle static C++ standard library"

This reverts commit 5e28c892d06f95600f8b6290ad4de38bfe142637 as
the linker on the clang-ppc64le-rhel bot doesn't seem to support
--push-state/--pop-state.

3 years ago[Driver] Correctly handle static C++ standard library
Petr Hosek [Tue, 21 Sep 2021 06:25:21 +0000 (23:25 -0700)]
[Driver] Correctly handle static C++ standard library

When statically linking C++ standard library, we shouldn't add -Bdynamic
after including the library on the link line because that might override
user settings like -static and -static-pie. Rather, we should surround
the library with --push-state/--pop-state to make sure that -Bstatic
only applies to C++ standard library and nothing else. This has been
supported since GNU ld 2.25 (2014) so backwards compatibility should
no longer be a concern.

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

3 years ago[TII] Remove the MFI argument to convertToThreeAddress. NFC.
Jay Foad [Wed, 22 Sep 2021 09:24:56 +0000 (10:24 +0100)]
[TII] Remove the MFI argument to convertToThreeAddress. NFC.

This simplifies the API and addresses a FIXME in
TwoAddressInstructionPass::convertInstTo3Addr.

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

3 years ago[DAGCombiner] Rename isAlias as mayAlias. NFC
Bjorn Pettersson [Fri, 17 Sep 2021 17:48:20 +0000 (19:48 +0200)]
[DAGCombiner] Rename isAlias as mayAlias. NFC

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

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".