Commit Graph

386218 Commits

Author SHA1 Message Date
Roman Lebedev 5a654bfeab
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 1e6ca23ab8.
2021-04-21 01:11:15 +03:00
Roman Lebedev 1e68d338c1
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 41b71f718b.
2021-04-21 01:11:14 +03:00
Philip Reames d87b9b81cc 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
2021-04-20 15:03:49 -07:00
Mehdi Chinoune 080d48f279 [flang][msvc] Fix compilation of RuntimeGtest
Removes alternate spelling 'not' with '!'.

Reviewed by: ashermancinelli, awarzynski, Meinersbur

Differential revision: https://reviews.llvm.org/D100442
2021-04-20 15:36:38 -06:00
Roman Lebedev 41b71f718b
[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.
2021-04-21 00:31:46 +03:00
Roman Lebedev 0ea464824a
[NFC][InstCombine] Add tests for sext-of-trunc-nuw-of-lshr (PR49543) 2021-04-21 00:31:46 +03:00
Roman Lebedev ea1a0d7c9a
[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`.
2021-04-21 00:31:46 +03:00
Roman Lebedev 8cff391995
[NFC][InstSimplify] Add one more test for unneeded 'and' 2021-04-21 00:31:46 +03:00
Roman Lebedev 1e6ca23ab8
[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.
2021-04-21 00:31:45 +03:00
Roman Lebedev 4e2c4190be
[NFC][InstCombine] Add test for sign-extending NSW trunc (PR49543) 2021-04-21 00:31:45 +03:00
Sanjay Patel 1e202e8f39 [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
2021-04-20 17:10:16 -04:00
Sanjay Patel a2099d6542 [InstCombine] add tests for srem-by-2; NFC 2021-04-20 17:10:16 -04:00
Sam Clegg d2de2d1724 [WebAssembly] Remove unused known_gcc_test_failures.txt. NFC
Differential Revision: https://reviews.llvm.org/D100887
2021-04-20 14:07:25 -07:00
Zequan Wu aa80955f63 [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
2021-04-20 14:06:31 -07:00
Jez Ng bb62ef9943 [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
2021-04-20 16:58:57 -04:00
Jez Ng 1aa29dffce [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
2021-04-20 16:58:57 -04:00
Alexey Bataev 673e2f1b70 [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
2021-04-20 13:47:56 -07:00
Petr Hosek caff17e503 [Driver] Don't use capture for InstalledDir
This is another attempt to address the issue introduced in
ae8b2cab67.

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.
2021-04-20 13:43:56 -07:00
Petr Hosek f5efe0aa04 [Driver] Support both slashes
This addresses Windows breakage introduced by
ae8b2cab67.
2021-04-20 13:25:38 -07:00
Philip Reames 6792e26c0d Reapply "Look through invertible recurrences in isKnownNonEqual"
I'd reverted this in commit 3b6acb1797 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
2021-04-20 12:47:59 -07:00
Peter Steinfeld d667b96c98 [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
2021-04-20 12:41:52 -07:00
Jon Roelofs 167da6c9e8 [AArch64][GlobalISel] Clarify fallback debug print
... to only print when that fallback actually happens.
2021-04-20 12:41:14 -07:00
Thomas Lively 693d767c60 [WebAssembly] More codegen for f64x2.convert_low_i32x4_{s,u}
af7925b4dd 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
2021-04-20 12:37:13 -07:00
Petr Hosek ae8b2cab67 [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
2021-04-20 12:30:35 -07:00
Nico Weber 85a5360b96 [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
2021-04-20 15:29:07 -04:00
peter klausler 8d672c0b3e [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
2021-04-20 12:25:42 -07:00
Jason Molenda f2da1f68d8 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
2021-04-20 12:09:06 -07:00
Christopher Di Bella 9816d43cff [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
2021-04-20 19:02:07 +00:00
Dan Liew 6f4f0afaa8 [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 fd28517d87.

rdar://76870467
2021-04-20 11:57:20 -07:00
Philip Reames 3b6acb1797 Revert "Look through invertible recurrences in isKnownNonEqual"
This reverts commit be20eae25f.  It appears to have caused a crash on a buildbot (https://lab.llvm.org/buildbot#builders/77/builds/5653).  Reverting while investigating.
2021-04-20 11:47:10 -07:00
Philip Reames 9c1a145aeb 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.
2021-04-20 11:40:15 -07:00
Nathan Sidwell 057b6f5d0b clang: Update libstdc++ issue workaround
Add some specificity to libstdc++ hack, perhaps we can remove it at a
later date.
2021-04-20 11:34:12 -07:00
Philip Reames 1668ace948 [tests] Expand coverage for D99687 2021-04-20 11:31:39 -07:00
Roman Lebedev 13ec913bdf
[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
2021-04-20 21:29:43 +03:00
Roman Lebedev 632eb20ab4
[NFC][InstCombine] Add tests for signed mul overflow check via mul-sdiv pattern (PR48769) 2021-04-20 21:29:21 +03:00
Roman Lebedev 7186764884
[NFC][SCEV] Split getLosslessPtrToIntExpr out of getPtrToIntExpr() 2021-04-20 21:29:21 +03:00
Roman Lebedev a1d283b71e
[NFC][LoopVectorize] Autogenerate check lines in pr45259.ll
We might as well test all of the codegen here.
2021-04-20 21:29:21 +03:00
Fangrui Song 1c00530b30 [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
2021-04-20 11:23:10 -07:00
Alessandro Vergani 6e77a67171 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
2021-04-20 11:17:29 -07:00
Mathieu Fehr 98dceed64b [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
2021-04-20 10:56:00 -07:00
Philip Reames be20eae25f 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
2021-04-20 10:52:22 -07:00
Kristina Bessonova 4a292eda25 [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
2021-04-20 19:51:55 +02:00
Nicolás Alvarez b0322a4ed2 [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
2021-04-20 13:50:11 -04:00
Javier Setoain 9a64a5f72f [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
2021-04-20 10:48:07 -07:00
Nicolás Alvarez 2da4ceec93 [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
2021-04-20 13:47:16 -04:00
Alexey Bataev 683dc41695 Update tests checks, NFC. 2021-04-20 10:20:15 -07:00
Fangrui Song 29710c4412 [llvm-objdump] Prefer positive boolean Verbose instead of negative NonVerbose. NFC
Differential Revision: https://reviews.llvm.org/D100791
2021-04-20 10:15:58 -07:00
Philip Reames 72f3f67137 [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.
2021-04-20 10:08:50 -07:00
Alexey Bataev e7d8105373 [COST]Add a test for reverse shuffles cost on AArch64, NFC. 2021-04-20 10:01:14 -07:00
Philip Reames 07b004998a [test] Add a couple more tests for D99912 2021-04-20 09:56:57 -07:00