platform/upstream/llvm.git
3 years ago[lldb] Simplify check for nill value in breakpoint_function_callback.test
Jonas Devlieghere [Wed, 21 Apr 2021 04:53:09 +0000 (21:53 -0700)]
[lldb] Simplify check for nill value in breakpoint_function_callback.test

3 years ago[NFC][CSKY] Resort the instruction description in td
Zi Xuan Wu [Wed, 21 Apr 2021 04:36:07 +0000 (12:36 +0800)]
[NFC][CSKY] Resort the instruction description in td

Resort the instruction description in td to make it easy to upstream more instructions and add predicts later.

3 years ago[libc] Add hardware implementations of fma and fmaf for x86_64 and aarch64.
Siva Chandra [Tue, 20 Apr 2021 04:06:25 +0000 (04:06 +0000)]
[libc] Add hardware implementations of fma and fmaf for x86_64 and aarch64.

The current generic implementation of the fmaf function has been moved
to the FPUtil directory. This allows one use the fma operation from
implementations of other math functions like the trignometric functions
without depending on/requiring the fma/fmaf/fmal function targets. If
this pattern ends being convenient, we will switch all generic math
implementations to this pattern.

Reviewed By: lntue

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

3 years agoRevert "[Driver] Support default libc++ library location on Darwin"
Jonas Devlieghere [Wed, 21 Apr 2021 03:42:26 +0000 (20:42 -0700)]
Revert "[Driver] Support default libc++ library location on Darwin"

This reverts the following commits because it breaks
TestAppleSimulatorOSType.py on GreenDragon [1].

caff17e503fe81d69e90dd69b14f5149659f9db4
f5efe0aa048b2bd3363b3a53efe9ae7367244801
ae8b2cab67408a043a4fe964d16e4803553c4ee0

[1] http://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/31346/

3 years ago[X86] Support some missing intrinsics
Liu, Chen3 [Wed, 21 Apr 2021 02:50:33 +0000 (10:50 +0800)]
[X86] Support some missing intrinsics

Support for _mm512_i32logather_pd, _mm512_mask_i32logather_pd,
_mm512_i32logather_epi64, _mm512_mask_i32logather_epi64, _mm512_i32loscatter_pd,
_mm512_mask_i32loscatter_pd, _mm512_i32loscatter_epi64,
_mm512_mask_i32loscatter_epi64.

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

3 years ago[RISCV] Add missing SEW=64 tests to vmslt-rv32.ll. NFC
Craig Topper [Wed, 21 Apr 2021 01:31:12 +0000 (18:31 -0700)]
[RISCV] Add missing SEW=64 tests to vmslt-rv32.ll. NFC

3 years ago[mlir] Support hoisting whole affine for loops in LICM
Amy Zhuang [Wed, 21 Apr 2021 00:09:15 +0000 (17:09 -0700)]
[mlir] Support hoisting whole affine for loops in LICM

Reviewed By: bondhugula

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

3 years ago[dfsan] Enable origin tracking with fast8 mode
George Balatsouras [Tue, 20 Apr 2021 22:31:58 +0000 (15:31 -0700)]
[dfsan] Enable origin tracking with fast8 mode

All related instrumentation tests have been updated.

Reviewed By: stephan.yichao.zhao

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

3 years ago[sanitizer] Fix glibc sparc build and add GetTls support
Fangrui Song [Wed, 21 Apr 2021 00:42:41 +0000 (17:42 -0700)]
[sanitizer] Fix glibc sparc build and add GetTls support

sanitizer_linux_libcdep.cpp doesn't build for Linux sparc (with minimum support
but can build) after D98926. I wasn't aware because the file didn't mention
`__sparc__`.

While here, add the relevant support since it does not add complexity
(the D99566 approach).  Adds an explicit `#error` for unsupported
non-Android Linux and FreeBSD architectures.

ThreadDescriptorSize is only used by lsan to scan thread-specific data keys in
the thread control block.

On TLS Variant II architectures (i386/x86_64/s390/sparc), our dl_iterate_phdr
based approach can cover the region from the first byte of the static TLS block
(static TLS surplus) to the thread pointer.
We just need to extend the range to include the first few members of struct
pthread. offsetof(struct pthread, specific_used) satisfies the requirement and
has not changed since 2007-05-10. We don't need to update ThreadDescriptorSize
for each glibc version.

Technically we could use the 524/1552 for x86_64 as well but there is potential
risk that large applications with thousands of shared object dependency may
dislike the time complexity increase if there are many threads, so I don't make
the simplification for now.

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

3 years agoMake sure PHIElimination doesn't copy debug locations across basic blocks.
Adrian Prantl [Tue, 20 Apr 2021 20:26:40 +0000 (13:26 -0700)]
Make sure PHIElimination doesn't copy debug locations across basic blocks.

PHIElimination may insert copy instructions in multiple basic
blocks. Moving debug locations across basic block boundaries would be
misleading as illustrated by the test case.

rdar://75463656

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

3 years ago[WebAssembly] Update README. NFC.
Sam Clegg [Tue, 20 Apr 2021 20:47:02 +0000 (13:47 -0700)]
[WebAssembly] Update README. NFC.

This is just a cleanup of the very high level stuff.  I'm sure there is
more to update here but I'll leave that to others and/or a followup.

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

3 years ago[lld-macho] Skip platform checks for a few libSystem re-exports
Jez Ng [Tue, 20 Apr 2021 23:54:41 +0000 (19:54 -0400)]
[lld-macho] Skip platform checks for a few libSystem re-exports

XCode 12 ships with mismatched platforms for these libraries,
so this hack is necessary...

Fixes PR49799.

Reviewed By: #lld-macho, gkm, smeenai

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

3 years ago[FuncAttrs] Always preserve FunctionAnalysisManagerCGSCCProxy
Arthur Eubanks [Tue, 20 Apr 2021 22:04:41 +0000 (15:04 -0700)]
[FuncAttrs] Always preserve FunctionAnalysisManagerCGSCCProxy

FunctionAnalysisManagerCGSCCProxy should not be preserved if any of its
keys may be invalid. Since we are not removing/adding functions in
FuncAttrs, it's fine to preserve it.

Reviewed By: asbirlea

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

3 years ago[CMake][llvm] avoid changing global flags (may be used outside of llvm)
Jim Radford [Tue, 20 Apr 2021 23:03:53 +0000 (16:03 -0700)]
[CMake][llvm] avoid changing global flags (may be used outside of llvm)

Changing global flags can break builds of projects that include/build
llvm as a sub-project, as the effect is global. Ideally we would
disable this warning at the directory level instead, but the obvious
way (disabling warning D9025) isn't supported. At least we can limit
the effect to only MSVC.

Patch by Jim Radford.

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

3 years agoRevert "[InstCombine] Recognize `((x * y) s/ x) !=/== y` as an signed multiplication...
Reid Kleckner [Tue, 20 Apr 2021 22:53:34 +0000 (15:53 -0700)]
Revert "[InstCombine] Recognize `((x * y) s/ x) !=/== y` as an signed multiplication overflow check (PR48769)"

This reverts commit 13ec913bdf500e2354cc55bf29e2f5d99e0c709e.

This commit introduces new uses of the overflow checking intrinsics that
depend on implementations in compiler-rt, which Windows users generally
do not link against. I filed an issue (somewhere) to make clang
auto-link the builtins library to resolve this situation, but until that
happens, it isn't reasonable for the optimizer to introduce new link
time dependencies.

3 years ago[mlir] Disallow broadcast dimensions on TransferWriteOp.
Matthias Springer [Tue, 20 Apr 2021 11:36:55 +0000 (20:36 +0900)]
[mlir] Disallow broadcast dimensions on TransferWriteOp.

The current implementation allows for TransferWriteOps with broadcasts that do not make sense. E.g., a broadcast could write a vector into a single (scalar) memory location, which is effectively the same as writing only the last element of the vector.

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

3 years agoRevert "Allow invokable sub-classes of IntrinsicInst"
Philip Reames [Tue, 20 Apr 2021 22:37:49 +0000 (15:37 -0700)]
Revert "Allow invokable sub-classes of IntrinsicInst"

This reverts commit d87b9b81ccb95217181ce75515c6c68bbb408ca4.

Post commit review raised concerns, reverting while discussion happens.

3 years ago[Clang, builtins] Added aligned_alloc, memalign support
Dávid Bolvanský [Tue, 20 Apr 2021 22:10:52 +0000 (00:10 +0200)]
[Clang, builtins] Added aligned_alloc, memalign support

3 years agoRevert "[InstCombine] `sext(trunc(x)) --> sext(x)` iff trunc is NSW (PR49543)"
Roman Lebedev [Tue, 20 Apr 2021 22:10:10 +0000 (01:10 +0300)]
Revert "[InstCombine] `sext(trunc(x)) --> sext(x)` iff trunc is NSW (PR49543)"

I forgot about the case where we sign-extend to width smaller than the original.

This reverts commit 1e6ca23ab8e350c7bab5d7f93e4d3dee18d180cc.

3 years agoRevert "[InstCombine] "Bypass" NUW trunc of lshr if we are going to sext the result...
Roman Lebedev [Tue, 20 Apr 2021 22:08:59 +0000 (01:08 +0300)]
Revert "[InstCombine] "Bypass" NUW trunc of lshr if we are going to sext the result (PR49543)"

I forgot about the case where we sign-extend to width smaller than the original.

This reverts commit 41b71f718b94c6f12bbaa670e97cabb070308ed2.

3 years agoAllow invokable sub-classes of IntrinsicInst
Philip Reames [Tue, 20 Apr 2021 22:01:55 +0000 (15:01 -0700)]
Allow invokable sub-classes of IntrinsicInst

It used to be that all of our intrinsics were call instructions, but over time, we've added more and more invokable intrinsics. According to the verifier, we're up to 8 right now. As IntrinsicInst is a sub-class of CallInst, this puts us in an awkward spot where the idiomatic means to check for intrinsic has a false negative if the intrinsic is invoked.

This change switches IntrinsicInst from being a sub-class of CallInst to being a subclass of CallBase. This allows invoked intrinsics to be instances of IntrinsicInst, at the cost of requiring a few more casts to CallInst in places where the intrinsic really is known to be a call, not an invoke.

After this lands and has baked for a couple days, planned cleanups:
    Make GCStatepointInst a IntrinsicInst subclass.
    Merge intrinsic handling in InstCombine and use idiomatic visitIntrinsicInst entry point for InstVisitor.
    Do the same in SelectionDAG.
    Do the same in FastISEL.

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

3 years ago[flang][msvc] Fix compilation of RuntimeGtest
Mehdi Chinoune [Tue, 20 Apr 2021 18:52:47 +0000 (12:52 -0600)]
[flang][msvc] Fix compilation of RuntimeGtest

Removes alternate spelling 'not' with '!'.

Reviewed by: ashermancinelli, awarzynski, Meinersbur

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

3 years ago[InstCombine] "Bypass" NUW trunc of lshr if we are going to sext the result (PR49543)
Roman Lebedev [Tue, 20 Apr 2021 21:19:51 +0000 (00:19 +0300)]
[InstCombine] "Bypass" NUW trunc of lshr if we are going to sext the result (PR49543)

This is a more convoluted form of the same pattern "sext of NSW trunc",
but in this case the operand of trunc was a right-shift,
and the truncation chops off just the zero bits that were shifted-in.

3 years ago[NFC][InstCombine] Add tests for sext-of-trunc-nuw-of-lshr (PR49543)
Roman Lebedev [Tue, 20 Apr 2021 21:17:23 +0000 (00:17 +0300)]
[NFC][InstCombine] Add tests for sext-of-trunc-nuw-of-lshr (PR49543)

3 years ago[InstSimplify] Bypass no-op `and`-mask, using known bits (PR49543)
Roman Lebedev [Tue, 20 Apr 2021 19:54:10 +0000 (22:54 +0300)]
[InstSimplify] Bypass no-op `and`-mask, using known bits (PR49543)

We already special-cased a few interesting patterns,
but that is strictly less powerful than using KnownBits.

So instead get the known bits for the operand of `and`,
and iff all the unset bits of the `and`-mask are known to be zeros
in the operand, we can omit said `and`.

3 years ago[NFC][InstSimplify] Add one more test for unneeded 'and'
Roman Lebedev [Tue, 20 Apr 2021 19:47:03 +0000 (22:47 +0300)]
[NFC][InstSimplify] Add one more test for unneeded 'and'

3 years ago[InstCombine] `sext(trunc(x)) --> sext(x)` iff trunc is NSW (PR49543)
Roman Lebedev [Tue, 20 Apr 2021 19:16:11 +0000 (22:16 +0300)]
[InstCombine] `sext(trunc(x)) --> sext(x)` iff trunc is NSW (PR49543)

If we can tell that trunc only chops off sign bits, and not all of them,
then we can simply sign-extend the trunc's source.

3 years ago[NFC][InstCombine] Add test for sign-extending NSW trunc (PR49543)
Roman Lebedev [Tue, 20 Apr 2021 19:11:41 +0000 (22:11 +0300)]
[NFC][InstCombine] Add test for sign-extending NSW trunc (PR49543)

3 years ago[InstCombine] fold shift-of-srem-by-2 to mask+shift
Sanjay Patel [Tue, 20 Apr 2021 20:56:34 +0000 (16:56 -0400)]
[InstCombine] fold shift-of-srem-by-2 to mask+shift

There are several potential srem-by-2 folds
because the result is known {-1,0,1}.

https://alive2.llvm.org/ce/z/LuVyeK

3 years ago[InstCombine] add tests for srem-by-2; NFC
Sanjay Patel [Tue, 20 Apr 2021 20:42:52 +0000 (16:42 -0400)]
[InstCombine] add tests for srem-by-2; NFC

3 years ago[WebAssembly] Remove unused known_gcc_test_failures.txt. NFC
Sam Clegg [Tue, 20 Apr 2021 20:18:21 +0000 (13:18 -0700)]
[WebAssembly] Remove unused known_gcc_test_failures.txt. NFC

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

3 years ago[lld-link] Warn on exported deleting dtor
Zequan Wu [Thu, 15 Apr 2021 23:23:33 +0000 (16:23 -0700)]
[lld-link] Warn on exported deleting dtor

MSVC linker has this [[ https://docs.microsoft.com/en-us/cpp/error-messages/tool-errors/linker-tools-warning-lnk4102?view=msvc-160 | warning]], so lld-link should also warn on this.

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

3 years ago[lld-macho] Ensure segments are laid out contiguously
Jez Ng [Tue, 20 Apr 2021 20:58:07 +0000 (16:58 -0400)]
[lld-macho] Ensure segments are laid out contiguously

codesign/libstuff checks that the `__LLVM` segment is directly
before `__LINKEDIT` by checking that `fileOff + fileSize == next segment
fileOff`. Previously, there would be gaps between the segments due to
the fact that their fileOffs are page-aligned but their fileSizes
aren't. In order to satisfy codesign, we page-align fileOff *before*
calculating fileSize. (I don't think codesign checks for the relative
ordering of other segments, so in theory we could do this just for
`__LLVM`, but ld64 seems to do it for all segments.)

Note that we *don't* round up the fileSize of the `__LINKEDIT` segment.
Since it's the last segment, it doesn't need to worry about contiguity;
in addition, codesign checks that the last (hidden) section in
`__LINKEDIT` covers the last byte of the segment, so if we rounded up
`__LINKEDIT`'s size we would have to do the same for its last section,
which is a bother.

While at it, I also addressed a FIXME in the linkedit-contiguity.s test
to cover more `__LINKEDIT` sections.

Reviewed By: #lld-macho, thakis, alexshap

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

3 years ago[lld-macho] Support subtractor relocations that reference sections
Jez Ng [Tue, 20 Apr 2021 20:58:06 +0000 (16:58 -0400)]
[lld-macho] Support subtractor relocations that reference sections

The minuend (but not the subtrahend) can reference a section.

Note that we do not yet properly validate that the subtrahend isn't
referencing a section; I've filed PR50034 to track that.

I've also extended the reloc-subtractor.s test to reorder symbols, to
make sure that the addends are being associated with the minuend (and not
the subtrahend) relocation.

Fixes PR49999.

Reviewed By: #lld-macho, thakis

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

3 years ago[COST][AARCH64] Improve cost of reverse shuffles for AArch64.
Alexey Bataev [Tue, 20 Apr 2021 16:49:58 +0000 (09:49 -0700)]
[COST][AARCH64] Improve cost of reverse shuffles for AArch64.

Introduced the cost of thre reverse shuffles for AArch64, currently just
copied the costs for PermuteSingleSrc.

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

3 years ago[Driver] Don't use capture for InstalledDir
Petr Hosek [Tue, 20 Apr 2021 20:42:18 +0000 (13:42 -0700)]
[Driver] Don't use capture for InstalledDir

This is another attempt to address the issue introduced in
ae8b2cab67408a043a4fe964d16e4803553c4ee0.

We cannot capture InstalledDir because FileCheck doesn't handle
the backslashes correctly, so instead we just consume the entire
path prefix which is what other tests are doing.

3 years ago[Driver] Support both slashes
Petr Hosek [Tue, 20 Apr 2021 19:58:54 +0000 (12:58 -0700)]
[Driver] Support both slashes

This addresses Windows breakage introduced by
ae8b2cab67408a043a4fe964d16e4803553c4ee0.

3 years agoReapply "Look through invertible recurrences in isKnownNonEqual"
Philip Reames [Tue, 20 Apr 2021 18:51:00 +0000 (11:51 -0700)]
Reapply "Look through invertible recurrences in isKnownNonEqual"

I'd reverted this in commit 3b6acb179708ea2f3caf95ace0f134fcbc460333 due to buildbot failures.  This patch contains the fix for said issue.  I'd forgotten to handle the case where two phis in the same block have different operand order.  We canonicalize away from this, but it's still valid IR.  The tests included in this change (as opposed to simply having test output changed), crashed without the fix.

Original commit message follows...

This extends the phi handling in isKnownNonEqual with a special case based on invertible recurrences. If we can prove the recurrence is invertible (which many common ones are), we can recurse through the start operands of the recurrence skipping the phi cycle.

(Side note: Instcombine currently does not push back through these cases. I will implement that in a follow up change w/separate review.)

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

3 years ago[flang] Fix assignment of parameterized derived types
Peter Steinfeld [Tue, 20 Apr 2021 17:11:03 +0000 (10:11 -0700)]
[flang] Fix assignment of parameterized derived types

We were erroneously emitting error messages for assignments of derived types
where the associated objects were instantiated with non-constant LEN type
parameters.

I fixed this by adding the member function MightBeAssignmentCompatibleWith() to
the class DerivedTypeSpec and calling it to determine whether it's possible
that objects of parameterized derived types can be assigned to each other.  Its
implementation first compares the uninstantiated values of the types.  If they
are equal, it then compares the values of the constant instantiated type
parameters.

I added tests to assign04.f90 to exercise this new code.

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

3 years ago[AArch64][GlobalISel] Clarify fallback debug print
Jon Roelofs [Tue, 20 Apr 2021 19:39:24 +0000 (12:39 -0700)]
[AArch64][GlobalISel] Clarify fallback debug print

... to only print when that fallback actually happens.

3 years ago[WebAssembly] More codegen for f64x2.convert_low_i32x4_{s,u}
Thomas Lively [Tue, 20 Apr 2021 19:37:13 +0000 (12:37 -0700)]
[WebAssembly] More codegen for f64x2.convert_low_i32x4_{s,u}

af7925b4dd65 added a custom DAG combine for recognizing fp-to-ints of
extract_subvectors that could be lowered to f64x2.convert_low_i32x4_{s,u}
instructions. This commit extends the combines to recognize equivalent
extract_subvectors of fp-to-ints as well.

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

3 years ago[Driver] Support default libc++ library location on Darwin
Petr Hosek [Tue, 10 Nov 2020 22:39:25 +0000 (14:39 -0800)]
[Driver] Support default libc++ library location on Darwin

Darwin driver currently uses libc++ headers that are part of Clang
toolchain when available (by default ../include/c++/v1 relative to
executable), but it completely ignores the libc++ library itself
because it doesn't pass the location of libc++ library that's part
of Clang (by default ../lib relative to the exceutable) to the linker
always using the system copy of libc++.

This may lead to subtle issues when the compilation fails because the
headers that are part of Clang toolchain are incompatible with the
system library. Either the driver should ignore both headers as well as
the library, or it should always try to use both when available.

This patch changes the driver behavior to do the latter which seems more
reasonable, it makes it easy to test and use custom libc++ build on
Darwin while still allowing the use of system version. This also matches
the Clang driver behavior on other systems.

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

3 years ago[llvm-objdump] Remove "No" prefixes on variables
Nico Weber [Tue, 20 Apr 2021 13:01:04 +0000 (09:01 -0400)]
[llvm-objdump] Remove "No" prefixes on variables

...to remove double negation in the code. Requested in D100583.

No behavior change.

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

3 years ago[flang] Implement IPARITY, PARITY, and FINDLOC reductions
peter klausler [Tue, 20 Apr 2021 16:19:21 +0000 (09:19 -0700)]
[flang] Implement IPARITY, PARITY, and FINDLOC reductions

Define APIs for, and implement, these three more recently-introduced
standard reduction transformational intrinsic functions to the runtime.

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

3 years agoGet Section from resolved_addr in Target::ReadMemory
Jason Molenda [Tue, 20 Apr 2021 19:07:24 +0000 (12:07 -0700)]
Get Section from resolved_addr in Target::ReadMemory

Landing this fix for Augusto Noronha.  The code is getting the
Section from 'addr' passed in, but it may have been expressed as
a load address when it was created and Target::ReadMemory tries to
convert it to a Section+offset if that's now possible; use the
Section found from that cleanup if it exists.

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

3 years ago[libcxx] adds `iter_difference_t` and `iter_value_t`
Christopher Di Bella [Tue, 20 Apr 2021 18:56:08 +0000 (18:56 +0000)]
[libcxx] adds `iter_difference_t` and `iter_value_t`

Implements parts of:
    * P0896R4 The One Ranges Proposal

Depends on D99855.

Reviewed By: ldionne, #libc

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

3 years ago[Compiler-rt] Fix bug when considering CMake path returned by llvm-config.
Dan Liew [Tue, 20 Apr 2021 18:54:04 +0000 (11:54 -0700)]
[Compiler-rt] Fix bug when considering CMake path returned by llvm-config.

The previous check was wrong because it only checks that the LLVM CMake
directory exists. However, it's possible that the directory exists but
the `LLVMConfig.cmake` file does not. When this happens we would
incorectly try to include the non-existant file.

To fix this we make the check stricter by checking that the file
we want to include actually exists.

This is a follow up to fd28517d878e1d3d14f492ab659aabdf729fd331.

rdar://76870467

3 years agoRevert "Look through invertible recurrences in isKnownNonEqual"
Philip Reames [Tue, 20 Apr 2021 18:47:10 +0000 (11:47 -0700)]
Revert "Look through invertible recurrences in isKnownNonEqual"

This reverts commit be20eae25f50f5ef648aeefa1143e1c31e4410fc.  It appears to have caused a crash on a buildbot (https://lab.llvm.org/buildbot#builders/77/builds/5653).  Reverting while investigating.

3 years agoRearrange code to reduce diff for D99687 [nfc]
Philip Reames [Tue, 20 Apr 2021 18:38:56 +0000 (11:38 -0700)]
Rearrange code to reduce diff for D99687 [nfc]

Adding the switches to reduce diffs.  I'm about to split that into an lshr part and an ashr part, doing the NFC part first makes it easier to maintain both diffs.

3 years agoclang: Update libstdc++ issue workaround
Nathan Sidwell [Fri, 16 Apr 2021 19:34:30 +0000 (12:34 -0700)]
clang: Update libstdc++ issue workaround

Add some specificity to libstdc++ hack, perhaps we can remove it at a
later date.

3 years ago[tests] Expand coverage for D99687
Philip Reames [Tue, 20 Apr 2021 18:31:30 +0000 (11:31 -0700)]
[tests] Expand coverage for D99687

3 years ago[InstCombine] Recognize `((x * y) s/ x) !=/== y` as an signed multiplication overflow...
Roman Lebedev [Tue, 20 Apr 2021 18:18:26 +0000 (21:18 +0300)]
[InstCombine] Recognize `((x * y) s/ x) !=/== y` as an signed multiplication overflow check (PR48769)

We already had support for it's unsigned variant, so simply extend it
to also handle the signed variant.

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

3 years ago[NFC][InstCombine] Add tests for signed mul overflow check via mul-sdiv pattern ...
Roman Lebedev [Tue, 20 Apr 2021 18:06:55 +0000 (21:06 +0300)]
[NFC][InstCombine] Add tests for signed mul overflow check via mul-sdiv pattern (PR48769)

3 years ago[NFC][SCEV] Split getLosslessPtrToIntExpr out of getPtrToIntExpr()
Roman Lebedev [Tue, 20 Apr 2021 14:03:10 +0000 (17:03 +0300)]
[NFC][SCEV] Split getLosslessPtrToIntExpr out of getPtrToIntExpr()

3 years ago[NFC][LoopVectorize] Autogenerate check lines in pr45259.ll
Roman Lebedev [Mon, 19 Apr 2021 19:29:31 +0000 (22:29 +0300)]
[NFC][LoopVectorize] Autogenerate check lines in pr45259.ll

We might as well test all of the codegen here.

3 years ago[ELF] Don't set versionId on undefined weak lazy symbols
Fangrui Song [Tue, 20 Apr 2021 18:23:10 +0000 (11:23 -0700)]
[ELF] Don't set versionId on undefined weak lazy symbols

An unfetched lazy symbol (undefined weak) should be considered to have its
original versionId which is VER_NDX_GLOBAL, instead of the lazy symbol's
versionId. (The original versionId cannot be non-VER_NDX_GLOBAL because a
undefined versioned symbol is an error.)

The regression was introduced in D77280 when making version scripts work
with lazy symbols fetched by LTO calls.

Fix PR49915

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

3 years agoFix clang Visual Studio build instructions
Alessandro Vergani [Tue, 20 Apr 2021 18:02:48 +0000 (11:02 -0700)]
Fix clang Visual Studio build instructions

Change cd ..\.. to cd llvm-project (the former is probably a leftover
of the old svn instructions)

Committer: Adrian McCarthy <amccarth@google.com>

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

3 years ago[mlir] Make some functions public to use custom TypeIDs
Mathieu Fehr [Tue, 20 Apr 2021 17:49:30 +0000 (10:49 -0700)]
[mlir] Make some functions public to use custom TypeIDs

Currently, it is only possible to register an operation or a type
when the TypeID is defined at compile time. Same with InterfaceMaps
which can only be defined with compile-time defined interfaces.

With those changes, it is now possible to register types/operations
with custom TypeIDs. This is necessary to define new operations/types
at runtime.

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

3 years agoLook through invertible recurrences in isKnownNonEqual
Philip Reames [Tue, 20 Apr 2021 17:51:25 +0000 (10:51 -0700)]
Look through invertible recurrences in isKnownNonEqual

This extends the phi handling in isKnownNonEqual with a special case based on invertible recurrences. If we can prove the recurrence is invertible (which many common ones are), we can recurse through the start operands of the recurrence skipping the phi cycle.

(Side note: Instcombine currently does not push back through these cases. I will implement that in a follow up change w/separate review.)

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

3 years ago[libcxx][test] Construct non-empty containers in iterator's debug mode tests
Kristina Bessonova [Tue, 20 Apr 2021 17:50:29 +0000 (19:50 +0200)]
[libcxx][test] Construct non-empty containers in iterator's debug mode tests

The debug mode tests for map/set's iterators construct empty
containers, making the code after the first increment meaningless.
It's never executed since the tests exit earlier.

It doesn't seem to be intentional, so the patch makes the tests
to construct containers that include at least one element.

Reviewed By: curdeius, Quuxplusone

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

3 years ago[docs] Fix doxygen comments wrongly attached to the clang namespace
Nicolás Alvarez [Tue, 20 Apr 2021 17:49:27 +0000 (13:49 -0400)]
[docs] Fix doxygen comments wrongly attached to the clang namespace

Looking at the Doxygen-generated documentation for the clang namespace
currently shows several random comments from different parts of the
codebase. These are caused by:

- File doc comments that aren't marked with \file, so they're attached to
  the next declaration, which is usually "namespace clang {".
- Class doc comments placed before the namespace rather than before the
  class.

This commit fixes these comments. The generated doxygen documentation now
has proper docs for several classes and files, and the docs for the clang
namespace is now empty.

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

3 years ago[mlir][Standard][NFC] Fix op documentation
Javier Setoain [Tue, 20 Apr 2021 17:46:41 +0000 (10:46 -0700)]
[mlir][Standard][NFC] Fix op documentation

A couple of standard op examples that use an outdated syntax need an
update.

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

3 years ago[docs] Use make_unique in FrontendAction example
Nicolás Alvarez [Tue, 20 Apr 2021 17:47:16 +0000 (13:47 -0400)]
[docs] Use make_unique in FrontendAction example

The code example for "RecursiveASTVisitor based ASTFrontendActions"
was using unique_ptr<X>(new X) when creating the AST consumer; change
it to use make_unique instead. The main function of the same example
already used make_unique.

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

3 years agoUpdate tests checks, NFC.
Alexey Bataev [Tue, 20 Apr 2021 17:20:15 +0000 (10:20 -0700)]
Update tests checks, NFC.

3 years ago[llvm-objdump] Prefer positive boolean Verbose instead of negative NonVerbose. NFC
Fangrui Song [Tue, 20 Apr 2021 17:15:57 +0000 (10:15 -0700)]
[llvm-objdump] Prefer positive boolean Verbose instead of negative NonVerbose. NFC

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

3 years ago[test] Add a couple extra tests for recurrence matching in unreachable code
Philip Reames [Tue, 20 Apr 2021 17:07:58 +0000 (10:07 -0700)]
[test] Add a couple extra tests for recurrence matching in unreachable code

These are salvaged from D100004 as we took a different approach to the fix.

3 years ago[COST]Add a test for reverse shuffles cost on AArch64, NFC.
Alexey Bataev [Tue, 20 Apr 2021 17:00:05 +0000 (10:00 -0700)]
[COST]Add a test for reverse shuffles cost on AArch64, NFC.

3 years ago[test] Add a couple more tests for D99912
Philip Reames [Tue, 20 Apr 2021 16:56:47 +0000 (09:56 -0700)]
[test] Add a couple more tests for D99912

3 years agoTolerate missing debug info in the shared_ptr pretty printer.
Sterling Augustine [Fri, 16 Apr 2021 01:03:01 +0000 (18:03 -0700)]
Tolerate missing debug info in the shared_ptr pretty printer.

Certain fields of shared ptr have virtual functions and therefore
have their debug info homed in libc++. But if libc++ wasn't built
with debug info, the pretty printer would fail.

This patch makes the pretty printer tolerate such conditions and
updates the test harness.

This patch significantly reworks a previous attempt.

This addresses https://bugs.llvm.org/show_bug.cgi?id=48937

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

3 years ago[tests] Update per review comment on D99912
Philip Reames [Tue, 20 Apr 2021 16:41:41 +0000 (09:41 -0700)]
[tests] Update per review comment on D99912

(I'd copy and pasted the wrong test before tweaking, as a result, it wasn't a very good negative test.)

3 years ago[libcxx][doc] Use Phabricator links.
Mark de Wever [Tue, 20 Apr 2021 16:26:14 +0000 (18:26 +0200)]
[libcxx][doc] Use Phabricator links.

Use a link to the Phabricator review in the patch column.

Reviewed By: zoecarver, cjdb, #libc

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

3 years ago[OpenMP] Add OpenMPOpt as a Module pass
Joseph Huber [Wed, 24 Mar 2021 14:11:32 +0000 (10:11 -0400)]
[OpenMP] Add OpenMPOpt as a Module pass

Summary:
This patch registers OpenMPOpt as a Module pass in addition to a CGSCC
pass. This is so certain optimzations that are sensitive to intact
call-sites can happen before inlining. The old `openmpopt` pass name is
changed to `openmp-opt-cgscc` and `openmp-opt` calls the Module pass.
The current module pass only runs a single check but will be expanded in
the future.

Reviewed By: jdoerfert

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

3 years ago[PhaseOrdering] Add second test case for PR36760
Simon Pilgrim [Tue, 20 Apr 2021 16:27:24 +0000 (17:27 +0100)]
[PhaseOrdering] Add second test case for PR36760

3 years agoSilence MSVC signed/unsigned comparison warning. NFCI.
Simon Pilgrim [Tue, 20 Apr 2021 16:19:15 +0000 (17:19 +0100)]
Silence MSVC signed/unsigned comparison warning. NFCI.

3 years ago[mlir] Pass AnalysisManager as optional parameter to analysis ctor, so it can request...
Butygin [Sat, 10 Apr 2021 16:38:11 +0000 (19:38 +0300)]
[mlir] Pass AnalysisManager as optional parameter to analysis ctor, so it can request any other analysis as dependency

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

3 years ago[clangd] Use dirty filesystem when performing cross file tweaks
Nathan James [Tue, 20 Apr 2021 16:13:44 +0000 (17:13 +0100)]
[clangd] Use dirty filesystem when performing cross file tweaks

Cross file tweaks can now use the dirty buffer contents easily when performing cross file effects.
This can be noted on the DefineOutline tweak, now working when the target file is unsaved

Reviewed By: sammccall

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

3 years ago[mlir][spirv] Support conversion of extract op from vector<1xT> type
thomasraoux [Tue, 20 Apr 2021 04:24:06 +0000 (21:24 -0700)]
[mlir][spirv] Support conversion of extract op from vector<1xT> type

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

3 years ago[PhaseOrdering] Add test case for PR36760
Simon Pilgrim [Tue, 20 Apr 2021 16:07:12 +0000 (17:07 +0100)]
[PhaseOrdering] Add test case for PR36760

Ensures that the correct sequence of simplifycfg/instcombine/sroa reduce the IR to just a icmp+select

3 years ago[X86][SSE] combineX86ShuffleChain - check if we're blending with zero into already...
Simon Pilgrim [Tue, 20 Apr 2021 15:50:02 +0000 (16:50 +0100)]
[X86][SSE] combineX86ShuffleChain - check if we're blending with zero into already zero elements

Add a SelectionDAG::MaskedElementsAreZero helper that wraps SelectionDAG::MaskedValueIsZero testing for entirely zero vector elements

3 years ago[SLP] Add detection of shuffled/perfect matching of tree entries.
Alexey Bataev [Tue, 20 Apr 2021 15:30:09 +0000 (08:30 -0700)]
[SLP] Add detection of shuffled/perfect matching of tree entries.

SLP supports perfect diamond matching for the vectorized tree entries
but do not support it for gathered entries and does not support
non-perfect (shuffled) matching with 1 or 2 tree entries. Patch adds
support for this matching to improve cost of the vectorized tree.

Reviewed By: RKSimon

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

3 years agofree(nullptr) does not violate the nofree specification
Philip Reames [Tue, 20 Apr 2021 16:06:28 +0000 (09:06 -0700)]
free(nullptr) does not violate the nofree specification

This fixes a subtle and nasty bug in my 86664638. The problem is that free(nullptr) is well defined (and common).

The specification for the nofree attributes talks about memory objects, and doesn't explicitly address null, but I think it's reasonable to assume that nofree doesn't disallow a call to free(nullptr). If it did, we'd have to prove nonnull on an argument to ever infer nofree which doesn't seem to be the intent.

This was found by Nuno and Alive2 over in https://reviews.llvm.org/D100141#2697374.

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

3 years ago[libc++] NFC: Normalize `#endif //` comment indentation
Louis Dionne [Tue, 20 Apr 2021 16:03:32 +0000 (12:03 -0400)]
[libc++] NFC: Normalize `#endif //` comment indentation

3 years agoGlobalISel: Defer register creation in handleAssignments
Matt Arsenault [Tue, 13 Apr 2021 01:40:23 +0000 (21:40 -0400)]
GlobalISel: Defer register creation in handleAssignments

This is currently built on top of the SelectionDAG call lowering, but
does not use it the same way. SelectionDAG passes legalized types to
the assignment functions, and the tablegenerated assignment functions
may change the value types expected for registers. This does not
change the types used, just moves the register creation to help fix
this in the future.

Defer the register creation until after all of the assignment
decisions have been made. This will also help have correct tail call
compatibility checking in a future change. Currently it does not work
as expected for any arguments split across multiple registers.

3 years ago[AMDGPU] Allow multiple uses of the same literal
Jay Foad [Thu, 8 Apr 2021 11:58:49 +0000 (12:58 +0100)]
[AMDGPU] Allow multiple uses of the same literal

In GFX10 VOP3 can have a literal, which opens up the possibility of two
operands using the same literal value, which is allowed and only counts
as one use of the constant bus.

AMDGPUAsmParser::validateConstantBusLimitations already knew about this
but SIInstrInfo::verifyInstruction did not.

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

3 years ago[AArch64] Bump apple-latest CPU alias to apple-a14.
Ahmed Bougacha [Fri, 16 Apr 2021 20:54:13 +0000 (13:54 -0700)]
[AArch64] Bump apple-latest CPU alias to apple-a14.

3 years ago[AArch64] Don't always override CPU for arm64e.
Ahmed Bougacha [Fri, 16 Apr 2021 20:59:08 +0000 (13:59 -0700)]
[AArch64] Don't always override CPU for arm64e.

This demotes the apple-a12 CPU selection for arm64e to just be the
last-resort default.  Concretely, this means:
- an explicitly-specified -mcpu will override the arm64e default;
  a user could potentially pick an invalid CPU that doesn't have
  v8.3a support, but that's not a major problem anymore
- arm64e-apple-macos (and variants) will pick apple-m1 instead of
  being forced to apple-a12.

3 years ago[AArch64] Add apple-m1 CPU, and default to it for macOS.
Ahmed Bougacha [Thu, 15 Apr 2021 02:34:55 +0000 (19:34 -0700)]
[AArch64] Add apple-m1 CPU, and default to it for macOS.

apple-m1 has the same level of ISA support as apple-a14,
so this is a straightforward mechanical change.  However, that
also means this inherits apple-a14's v8.5a+nobti quirkiness.

rdar://68287159

3 years ago[gn build] Port 120fa8293e22
LLVM GN Syncbot [Tue, 20 Apr 2021 15:33:43 +0000 (15:33 +0000)]
[gn build] Port 120fa8293e22

3 years ago[libc++][nfc] Move iterator_traits and related into __iterator/iterator_traits.h.
zoecarver [Mon, 19 Apr 2021 21:44:42 +0000 (14:44 -0700)]
[libc++][nfc] Move iterator_traits and related into __iterator/iterator_traits.h.

Based on D100682 and D99855.

(Note: I originally was going to just make this part of D99855, but I decided not to because this patch moves lots of unrelated code around, and I didn't want to make D99855 harder to review because of unrelated code-changes/moves.)

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

3 years agoGlobalISel: Check for powers of 2 for inverse funnel shift lowering
Matt Arsenault [Mon, 29 Mar 2021 21:26:49 +0000 (17:26 -0400)]
GlobalISel: Check for powers of 2 for inverse funnel shift lowering

This doesn't make a practical difference since it would only be broken
if a target actually had a legal non-power-of-2 inverse shift.

3 years ago[libcxx] makes `iterator_traits` C++20-aware
zoecarver [Tue, 20 Apr 2021 12:50:11 +0000 (08:50 -0400)]
[libcxx] makes `iterator_traits` C++20-aware

* adds `iterator_traits` specialisation that supports all expected
  member aliases except for `pointer`
* adds `iterator_traits` specialisations for iterators that meet the
  legacy iterator requirements but might lack multiple member aliases
* makes pointer `iterator_traits` specialisation require objects

Depends on D99854.

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

3 years agoRevert "[SLP] Add detection of shuffled/perfect matching of tree entries."
Alexey Bataev [Tue, 20 Apr 2021 15:29:07 +0000 (08:29 -0700)]
Revert "[SLP] Add detection of shuffled/perfect matching of tree entries."

This reverts commit daf6e18c55c2ac56bbf0f9de233fb2a1150ee331 to fix the
compiler crash.

3 years ago[ARM] Limit PerformExtractEltToVMOVRRD to when f64 is legal.
David Green [Tue, 20 Apr 2021 15:24:36 +0000 (16:24 +0100)]
[ARM] Limit PerformExtractEltToVMOVRRD to when f64 is legal.

The generic SoftFloatVectorExtract.ll test was failing when run on arm
machines, as it tries to create a f64 under soft float. Limit the
transform to when f64 is legal.

Also add a missing override, as reported in D100244.

3 years agoAMDGPU/GlobalISel: Fix uitofp/sitofp with non-power-of-2 integers
Matt Arsenault [Sat, 27 Mar 2021 15:14:15 +0000 (11:14 -0400)]
AMDGPU/GlobalISel: Fix uitofp/sitofp with non-power-of-2 integers

3 years agoEnsure target-multiversioning emits deferred declarations
Erich Keane [Tue, 20 Apr 2021 14:35:57 +0000 (07:35 -0700)]
Ensure target-multiversioning emits deferred declarations

As reported in PR50025, sometimes we would end up not emitting functions
needed by inline multiversioned variants. This is because we typically
use the 'deferred decl' mechanism to emit these.  However, the variants
are emitted after that typically happens.  This fixes that by ensuring
we re-run deferred decls after this happens. Also, the multiversion
emission is done recursively to ensure that MV functions that require
other MV functions to be emitted get emitted.

3 years agoGlobalISel: Restrict narrow scalar for fptoui/fptosi results
Matt Arsenault [Fri, 26 Mar 2021 21:29:36 +0000 (17:29 -0400)]
GlobalISel: Restrict narrow scalar for fptoui/fptosi results

This practically only works for the f16 case AMDGPU uses, not wider
types.

Fixes bug 49710 by failing legalization.

3 years agoMachineVerifier: Continue reporting errors for copies
Matt Arsenault [Wed, 31 Mar 2021 20:45:19 +0000 (16:45 -0400)]
MachineVerifier: Continue reporting errors for copies

This was skipping verification of later copies, but generally the
verifier tries to report as many things wrong as possible in the
function.

3 years ago[SLP] Add detection of shuffled/perfect matching of tree entries.
Alexey Bataev [Tue, 20 Apr 2021 14:27:32 +0000 (07:27 -0700)]
[SLP] Add detection of shuffled/perfect matching of tree entries.

SLP supports perfect diamond matching for the vectorized tree entries
but do not support it for gathered entries and does not support
non-perfect (shuffled) matching with 1 or 2 tree entries. Patch adds
support for this matching to improve cost of the vectorized tree.

Reviewed By: RKSimon

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

3 years ago[mlir][StandardToSPIRV] Add support for lowering std.xor on bool to SPIR-V
Hanhan Wang [Tue, 20 Apr 2021 14:34:32 +0000 (07:34 -0700)]
[mlir][StandardToSPIRV] Add support for lowering std.xor on bool to SPIR-V

std.xor ops on bool are lowered to spv.LogicalNotEqual. For Boolean values, xor
and not-equal are the same thing.

Reviewed By: antiagainst

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

3 years ago[gn build] reformat all gn files
Nico Weber [Tue, 20 Apr 2021 14:33:35 +0000 (10:33 -0400)]
[gn build] reformat all gn files

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

(and manually wrap two comments)