platform/upstream/llvm.git
3 years agoAdapt lldb-instr to d47ee525f9e92898 APi change
serge-sans-paille [Fri, 29 Jan 2021 09:57:45 +0000 (10:57 +0100)]
Adapt lldb-instr to d47ee525f9e92898 APi change

3 years ago[mlir] Prevent segfault in Tensor canonicalization
Tres Popp [Wed, 27 Jan 2021 16:28:14 +0000 (17:28 +0100)]
[mlir] Prevent segfault in Tensor canonicalization

This segfault could occur from out of bounds accesses when simplifying
tensor.extract with a constant index and a tensor created by
tensor.from_elements.

This IR is not necesarilly invalid as it might conditionally be
never executed.

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

3 years ago[libc][Obvious] Fix typo
Cheng Wang [Fri, 29 Jan 2021 09:41:25 +0000 (17:41 +0800)]
[libc][Obvious] Fix typo

3 years ago[clang-tooling] Prevent llvm::fatal_error on invalid CLI option
serge-sans-paille [Mon, 11 Jan 2021 15:19:35 +0000 (16:19 +0100)]
[clang-tooling] Prevent llvm::fatal_error on invalid CLI option

Fail gracefully instead. Prevent further misuse by enforcing the factory builder
instead of the constructor.

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

3 years ago[llvm-jitlink] Replace use of deprecated gethostbyname by getaddrinfo.
Rafik Zurob [Fri, 22 Jan 2021 12:51:19 +0000 (06:51 -0600)]
[llvm-jitlink] Replace use of deprecated gethostbyname by getaddrinfo.

This patch replaces use of deprecated gethostbyname by getaddrinfo.

Author: Rafik Zurob

Reviewed By: lhames

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

3 years ago[libc][Obvious] Remove DEPS for unistd.h in CMake file of memmove.
Cheng Wang [Fri, 29 Jan 2021 08:43:44 +0000 (16:43 +0800)]
[libc][Obvious] Remove DEPS for unistd.h in CMake file of memmove.

3 years ago[llvm-readobj/elf] - Report "bitcode files are not supported" warning for bitcode...
Georgii Rymar [Thu, 28 Jan 2021 10:28:55 +0000 (13:28 +0300)]
[llvm-readobj/elf] - Report "bitcode files are not supported" warning for bitcode files.

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

Currently we report "The file was not recognized as a valid object file" for BC files.
Also, we terminate dumping.

Instead we could report a better warning and try to continue dumping other files.
This is what this patch implements.

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

3 years agoRevert "[clang-format] Add option to control the spaces in a line comment"
Björn Schäpers [Fri, 29 Jan 2021 08:28:03 +0000 (09:28 +0100)]
Revert "[clang-format] Add option to control the spaces in a line comment"

This reverts commit 078f30e04d1fcb5a05d8e340f3178f3478075541.

3 years ago[clangd] Add include-fixer fixit for field_incomplete_or_sizeless diagnostic.
Haojian Wu [Tue, 26 Jan 2021 10:50:33 +0000 (11:50 +0100)]
[clangd] Add include-fixer fixit for field_incomplete_or_sizeless diagnostic.

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

3 years ago[NFC][ScalarizeMaskedMemIntrin] Fix unused variable warning
Yang Fan [Fri, 29 Jan 2021 07:13:04 +0000 (15:13 +0800)]
[NFC][ScalarizeMaskedMemIntrin] Fix unused variable warning

GCC warning:
```
/llvm-project/llvm/lib/Transforms/Scalar/ScalarizeMaskedMemIntrin.cpp: In function ‘void scalarizeMaskedStore(llvm::CallInst*, llvm::DomTreeUpdater*, bool&)’:
/llvm-project/llvm/lib/Transforms/Scalar/ScalarizeMaskedMemIntrin.cpp:295:15: warning: variable ‘IfBlock’ set but not used [-Wunused-but-set-variable]
  295 |   BasicBlock *IfBlock = CI->getParent();
      |               ^~~~~~~
/llvm-project/llvm/lib/Transforms/Scalar/ScalarizeMaskedMemIntrin.cpp: In function ‘void scalarizeMaskedScatter(llvm::CallInst*, llvm::DomTreeUpdater*, bool&)’:
/llvm-project/llvm/lib/Transforms/Scalar/ScalarizeMaskedMemIntrin.cpp:555:15: warning: variable ‘IfBlock’ set but not used [-Wunused-but-set-variable]
  555 |   BasicBlock *IfBlock = CI->getParent();
      |               ^~~~~~~
```

3 years ago[clang-tidy] bugprone-assert-side-effect: Warn on NSAssert by default.
Artem Dergachev [Fri, 29 Jan 2021 05:41:57 +0000 (21:41 -0800)]
[clang-tidy] bugprone-assert-side-effect: Warn on NSAssert by default.

NSAssert and NSCAssert are Objective-C Foundation's standard assert macros.

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

3 years ago[clang-tidy] bugprone-assert-side-effect: Improve warning message.
Artem Dergachev [Fri, 29 Jan 2021 05:40:48 +0000 (21:40 -0800)]
[clang-tidy] bugprone-assert-side-effect: Improve warning message.

Drop redundant "found", specify what exactly is wrong with side effects
in assert conditions.

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

3 years ago[MustExecute] Use ListSeparator (NFC)
Kazu Hirata [Fri, 29 Jan 2021 06:21:16 +0000 (22:21 -0800)]
[MustExecute] Use ListSeparator (NFC)

3 years ago[llvm] Populate SmallVector at construction time (NFC)
Kazu Hirata [Fri, 29 Jan 2021 06:21:14 +0000 (22:21 -0800)]
[llvm] Populate SmallVector at construction time (NFC)

3 years ago[llvm] Forward-declare formatted_raw_ostream (NFC)
Kazu Hirata [Fri, 29 Jan 2021 06:21:12 +0000 (22:21 -0800)]
[llvm] Forward-declare formatted_raw_ostream (NFC)

Various *TargetStreamer.h need formatted_raw_ostream but rely on a
forward declaration of formatted_raw_ostream in MCStreamer.h.  This
patch adds forward declarations right in *TargetStreamer.h.

While we are at it, this patch removes the one in MCStreamer.h, where
it is unnecessary.

3 years ago[clang-format] Add option to control the spaces in a line comment
Björn Schäpers [Sat, 26 Dec 2020 21:04:30 +0000 (22:04 +0100)]
[clang-format] Add option to control the spaces in a line comment

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

3 years ago[LiveDebugVariables] Add cache for SkipPHIsLabelsAndDebug to prevent
Wei Mi [Sat, 16 Jan 2021 18:11:18 +0000 (10:11 -0800)]
[LiveDebugVariables] Add cache for SkipPHIsLabelsAndDebug to prevent
iterating the same PHI/LABEL/Debug instructions repeatedly.

We run into a compiling timeout problem when building a target after its
SampleFDO profile is updated. It is because some very large blocks with
a bunch of PHIs at the beginning. LiveDebugVariables::emitDebugValues
called during VirtRegRewriter phase searchs the insertion point for those
large BBs repeatedly in SkipPHIsLabelsAndDebug, and each time
SkipPHIsLabelsAndDebug needs to go through the same set of PHIs before it
can find the first non PHI/Label/Debug instruction. This patch adds a cache
to save the last position for the sequence which has been checked in the
previous call of SkipPHIsLabelsAndDebug.

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

3 years ago[SCEV] Do not cache comparison result upon reached max depth as "equivalence". PR48725
Max Kazantsev [Fri, 29 Jan 2021 05:08:34 +0000 (12:08 +0700)]
[SCEV] Do not cache comparison result upon reached max depth as "equivalence". PR48725

We use `EquivalenceClasses` to cache the notion that two SCEVs are equivalent,
so save time in situation when `A` is equivalent to `B` and `B` is equivalent to `C`,
making check "if `A` is equivalent to `C`?" cheaper.

We also return `0` in the comparator when we reach max analysis depth to save
compile time. After doing this, we also cache them as being equivalent.

Now, imagine the following situation:
- `A` is proved equivalent to `B`;
- `C` is proved equivalent to `D`;
- Comparison of `A` against `D` is proved non-zero;
- Comparison of `B` against `C` reaches max depth (and gets cached as equivalence).

Now, before the invocation of compare(`B`, `C`), `A` and `D` belonged
to different equivalence classes, and their comparison returned non-zero.
After the the invocation of compare(`B`, `C`), equivalence classes get merged
and `A`, `B`, `C` and `D` all fall into the same equivalence class. So the comparator
will change its behavior for couple `A` and `D`, with weird consequences following it.
This comparator is finally used in `std::stable_sort`, and this behavior change
makes it crash (looks like it's causing a memory corruption).

Solution: this patch changes `CompareSCEVComplexity` to return `None`
when the max depth is reached. So in this case, we do not cache these SCEVs
(and their parents in the tree) as being equivalent.

Differential Revision: https://reviews.llvm.org/D94654
Reviewed By: lebedev.ri

3 years agoSupport a list of CostPerUse values
Christudasan Devadasan [Wed, 23 Dec 2020 05:21:13 +0000 (10:51 +0530)]
Support a list of CostPerUse values

This patch allows targets to define multiple cost
values for each register so that the cost model
can be more flexible and better used during the
register allocation as per the target requirements.

For AMDGPU the VGPR allocation will be more efficient
if the register cost can be associated dynamically
based on the calling convention.

Reviewed By: qcolombet

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

3 years ago[lldb] Use `foo is None` instead of `not foo` in darwin.py
Jonas Devlieghere [Fri, 29 Jan 2021 03:56:16 +0000 (19:56 -0800)]
[lldb] Use `foo is None` instead of `not foo` in darwin.py

Explicitly compare to None when checking the triple's components so we
don't bail out when one of them is the empty string.

3 years ago[NFC][DebugInfo] Fix Wreturn-type gcc warning
Yang Fan [Fri, 29 Jan 2021 02:44:44 +0000 (10:44 +0800)]
[NFC][DebugInfo] Fix Wreturn-type gcc warning

GCC warning:
```
/llvm-project/llvm/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp: In member function ‘llvm::Expected<long unsigned int> llvm::dwarf::CFIProgram::Instruction::getOperandAsUnsigned(const llvm::dwarf::CFIProgram&, uint32_t) const’:
/llvm-project/llvm/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp:425:1: warning: control reaches end of non-void function [-Wreturn-type]
  425 | }
      | ^
/llvm-project/llvm/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp: In member function ‘llvm::Expected<long int> llvm::dwarf::CFIProgram::Instruction::getOperandAsSigned(const llvm::dwarf::CFIProgram&, uint32_t) const’:
/llvm-project/llvm/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp:477:1: warning: control reaches end of non-void function [-Wreturn-type]
  477 | }
      | ^
```

3 years ago[NFC][llvm-nm] Fix unused variable warning
Yang Fan [Fri, 29 Jan 2021 02:27:43 +0000 (10:27 +0800)]
[NFC][llvm-nm] Fix unused variable warning

3 years agoFix typo in "[DebugInfo][CodeView] Use <lambda_n> as the display name for lambdas."
Amy Huang [Fri, 29 Jan 2021 03:02:51 +0000 (19:02 -0800)]
Fix typo in "[DebugInfo][CodeView] Use <lambda_n> as the display name for lambdas."
(Commited in d5f5deee9ee996f078fb40ee20795539409523e4)

3 years agoReland "[DebugInfo][CodeView] Use <lambda_n> as the display name for lambdas"
Amy Huang [Fri, 29 Jan 2021 00:46:26 +0000 (16:46 -0800)]
Reland "[DebugInfo][CodeView] Use <lambda_n> as the display name for lambdas"
with fix to test case and stringrefs.

Currently (for codeview) lambdas have a string like `<lambda_0>` in
their mangled name, and don't have any display name. This change uses the
`<lambda_0>` as the display name, which helps distinguish between lambdas
in -gline-tables-only, since there are no linkage names there.
It also changes how we display lambda names; previously we used
`<unnamed-tag>`; now it will show `<lambda_0>`.

I added a function to the mangling context code to create this string;
for Itanium it just returns an empty string.

Bug: https://bugs.llvm.org/show_bug.cgi?id=48432

Reviewed By: rnk

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

This reverts 9b21d4b9434d2d4796b0d60d64f6ded9bac95441

3 years ago[libcxx][test] move libc++-specific tests into the libcxx tree
Casey Carter [Fri, 29 Jan 2021 02:01:48 +0000 (18:01 -0800)]
[libcxx][test] move libc++-specific tests into the libcxx tree

...and rename from `version.pass.cpp` to `version.compile.pass.cpp` to follow the new convention.

3 years ago[libc][NFC] Add a few casts to suppress loss of precision warnings
Michael Jones [Thu, 28 Jan 2021 23:53:27 +0000 (23:53 +0000)]
[libc][NFC] Add a few casts to suppress loss of precision warnings

Reviewed By: sivachandra

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

3 years ago[libcxx][test] MoveOnly's comparisons are non-member
Casey Carter [Thu, 28 Jan 2021 22:24:31 +0000 (14:24 -0800)]
[libcxx][test] MoveOnly's comparisons are non-member

... so that comparisons with an `int` LHS and `MoveOnly` RHS are valid, as is necessary for the `partial_sort_copy` test to pass with an implementation that doesn't force a conversion to the type of the RHS as libc++ does.

3 years ago[AMDGPU] Fix WMM Entry SCC preservation
Carl Ritson [Wed, 27 Jan 2021 03:48:19 +0000 (12:48 +0900)]
[AMDGPU] Fix WMM Entry SCC preservation

SCC was not correctly preserved when entering WWM.
Current lit test was unable to detect this as entry block is
handled differently.
Additionally fix an issue where SCC was unnecessarily preserved
when exiting from WWM to Exact mode.

Reviewed By: foad

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

3 years ago[GlobalISel] Implement regbankselect for G_ASSERT_ZEXT
Jessica Paquette [Thu, 28 Jan 2021 18:16:44 +0000 (10:16 -0800)]
[GlobalISel] Implement regbankselect for G_ASSERT_ZEXT

This adds generic regbankselect support for G_ASSERT_ZEXT.

It inherits whatever register bank the source was given, always, on all targets.

I think that at the point where we run into these, the source register bank
should be decided.

This also adds some AArch64-specific code which makes sure we can handle
G_ASSERT_ZEXT when deciding on register banks for G_STORE, G_PHI, ... etc.

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

3 years agoEnsure that we traverse non-op() method bodys of lambdas
Stephen Kelly [Thu, 28 Jan 2021 23:40:16 +0000 (23:40 +0000)]
Ensure that we traverse non-op() method bodys of lambdas

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

3 years ago[AMDGPU] Mark V_SET_INACTIVE as defining SCC
Carl Ritson [Wed, 27 Jan 2021 04:55:33 +0000 (13:55 +0900)]
[AMDGPU] Mark V_SET_INACTIVE as defining SCC

V_SET_INACTIVE is implemented with S_NOT which clobbers SCC.
Mark sure it is marked appropriately.

Reviewed By: piotr

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

3 years agoRevert "[DebugInfo][CodeView] Use <lambda_n> as the display name for lambdas."
Amy Huang [Fri, 29 Jan 2021 00:41:26 +0000 (16:41 -0800)]
Revert "[DebugInfo][CodeView] Use <lambda_n> as the display name for lambdas."
for test failures.

This reverts commit d73564c510036b2d4f5858effdcd23fe54fc1063.

3 years ago[AArch64][GlobalISel] Enable CSE for the prelegalizer combiner.
Amara Emerson [Fri, 29 Jan 2021 00:08:47 +0000 (16:08 -0800)]
[AArch64][GlobalISel] Enable CSE for the prelegalizer combiner.

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

3 years ago[GlobalISel] Implement computeKnownBits for G_ASSERT_ZEXT
Jessica Paquette [Wed, 27 Jan 2021 22:01:38 +0000 (14:01 -0800)]
[GlobalISel] Implement computeKnownBits for G_ASSERT_ZEXT

It's the same as the ZEXT/TRUNC case, except SrcBitWidth is given by the
immediate operand.

Update KnownBitsTest.cpp and a MIR test for a concrete example.

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

3 years ago[DebugInfo][CodeView] Use <lambda_n> as the display name for lambdas.
Amy Huang [Thu, 28 Jan 2021 23:28:16 +0000 (15:28 -0800)]
[DebugInfo][CodeView] Use <lambda_n> as the display name for lambdas.

Currently (for codeview) lambdas have a string like `<lambda_0>` in
their mangled name, and don't have any display name. This change uses the
`<lambda_0>` as the display name, which helps distinguish between lambdas
in -gline-tables-only, since there are no linkage names there.
It also changes how we display lambda names; previously we used
`<unnamed-tag>`; now it will show `<lambda_0>`.

I added a function to the mangling context code to create this string;
for Itanium it just returns an empty string.

Bug: https://bugs.llvm.org/show_bug.cgi?id=48432

Reviewed By: rnk

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

3 years ago[AArch64][GlobalISel] Add a combine to fold away truncate in: G_ICMP EQ/NE (G_TRUNC...
Amara Emerson [Wed, 27 Jan 2021 07:39:56 +0000 (23:39 -0800)]
[AArch64][GlobalISel] Add a combine to fold away truncate in: G_ICMP EQ/NE (G_TRUNC(v), 0)

We try to do this optimization if we can determine that testing for the
truncated bits with an eq/ne predicate results in the same thing as testing
the lower bits.

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

3 years agoIntroduce a new DialectIdentifier structure, extending Identifier with a Dialect...
Mehdi Amini [Fri, 29 Jan 2021 00:05:26 +0000 (00:05 +0000)]
Introduce a new DialectIdentifier structure, extending Identifier with a Dialect information

This class is looking up a dialect prefix on the identifier on initialization
and keeping a pointer to the Dialect when found.

The NamedAttribute key is now a DialectIdentifier.

Reviewed By: rriddle, jpienaar

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

3 years ago[clang-tidy] Applied clang-tidy fixes. NFC
Alexander Kornienko [Thu, 28 Jan 2021 23:49:53 +0000 (00:49 +0100)]
[clang-tidy] Applied clang-tidy fixes. NFC

Applied fixes enabled by the LLVM's .clang-tidy configs. Reverted files where
fixes introduced compile errors:
  clang-tools-extra/clang-tidy/hicpp/NoAssemblerCheck.cpp
  clang-tools-extra/clang-tidy/misc/ThrowByValueCatchByReferenceCheck.cpp

$ clang-tools-extra/clang-tidy/tool/run-clang-tidy.py -fix clang-tools-extra/clang-tidy/
Enabled checks:
    llvm-else-after-return
    llvm-header-guard
    llvm-include-order
    llvm-namespace-comment
    llvm-prefer-isa-or-dyn-cast-in-conditionals
    llvm-prefer-register-over-unsigned
    llvm-qualified-auto
    llvm-twine-local
    misc-definitions-in-headers
    misc-misplaced-const
    misc-new-delete-overloads
    misc-no-recursion
    misc-non-copyable-objects
    misc-redundant-expression
    misc-static-assert
    misc-throw-by-value-catch-by-reference
    misc-unconventional-assign-operator
    misc-uniqueptr-reset-release
    misc-unused-alias-decls
    misc-unused-using-decls
    readability-identifier-naming

Reviewed By: aaron.ballman

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

3 years agoFix windows buildbot build errors from D89845.
Greg Clayton [Thu, 28 Jan 2021 23:23:22 +0000 (15:23 -0800)]
Fix windows buildbot build errors from D89845.

3 years ago[mlir][Linalg] Fix SFINAE check to actually check the value.
Richard Smith [Thu, 28 Jan 2021 23:12:03 +0000 (15:12 -0800)]
[mlir][Linalg] Fix SFINAE check to actually check the value.

No internal functionality change intended, but this fixes out-of-tree
uses.

3 years agoADT: Fix typo in static assert message from 17c584551d573f1693990773e29fbe6b4b6fa4f4
Duncan P. N. Exon Smith [Thu, 28 Jan 2021 23:14:46 +0000 (15:14 -0800)]
ADT: Fix typo in static assert message from 17c584551d573f1693990773e29fbe6b4b6fa4f4

3 years agoADT: Add SFINAE to the generic IntrusiveRefCntPtr constructors
Duncan P. N. Exon Smith [Wed, 27 Jan 2021 03:51:22 +0000 (19:51 -0800)]
ADT: Add SFINAE to the generic IntrusiveRefCntPtr constructors

Add an `enable_if` to the generic `IntrusiveRefCntPtr` constructors so
that std::is_convertible gives an honest answer when the underlying
pointers cannot be converted. Added `static_assert`s to the test suite
to verify.

Also combine generic constructors from `IntrusiveRefCntPtr<X>&&` and
`const IntrusiveRefCntPtr<X>&`. At first glance this appears to be an
infinite loop, but the real copy/move constructors are spelled out
separately above. Added a unit test to verify.

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

3 years ago[sanitizer] Fix msan test build on FreeBSD after 7afdc89c2054
Dimitry Andric [Thu, 28 Jan 2021 22:53:45 +0000 (23:53 +0100)]
[sanitizer] Fix msan test build on FreeBSD after 7afdc89c2054

This commit accidentally enabled fgetgrent_r() in the msan tests under
FreeBSD, but this function is not supported. Also remove FreeBSD from
the SANITIZER_INTERCEPT_FGETGRENT_R macro.

3 years agoRecommit "[GlobalISel] Walk through hints in getDefIgnoringCopies et al"
Jessica Paquette [Thu, 28 Jan 2021 22:39:42 +0000 (14:39 -0800)]
Recommit "[GlobalISel] Walk through hints in getDefIgnoringCopies et al"

Recommit of 4580acf6752ea3cc884657b5aa3e174bed86fc8c

`Opc = DefMI->getOpcode()` was in the wrong place.

3 years agoRevert "[GlobalISel] Walk through hints in getDefIgnoringCopies et al"
Jessica Paquette [Thu, 28 Jan 2021 22:37:57 +0000 (14:37 -0800)]
Revert "[GlobalISel] Walk through hints in getDefIgnoringCopies et al"

This reverts commit 4580acf6752ea3cc884657b5aa3e174bed86fc8c.

Reverting while looking into some test failures.

3 years ago[GlobalISel] Walk through hints in getDefIgnoringCopies et al
Jessica Paquette [Thu, 28 Jan 2021 00:06:19 +0000 (16:06 -0800)]
[GlobalISel] Walk through hints in getDefIgnoringCopies et al

Treat hint instructions like G_ASSERT_ZEXT like COPY instructions in helpers
which walk through copies.

This ensures that instructions like G_ASSERT_ZEXT won't impact any optimizations
that rely on these helpers.

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

3 years ago[NFC][AMDGPU] Correct name of DWARF CFA extensions
Tony Tye [Thu, 28 Jan 2021 22:09:29 +0000 (22:09 +0000)]
[NFC][AMDGPU] Correct name of DWARF CFA extensions

Add LLVM to the DW_CFA_LLVM_def_aspace_cfa and
DW_CFA_LLVM_def_aspace_cfa_sf DWARF extensions.

Reviewed By: scott.linder

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

3 years ago[mlir][Linalg] Enable TileAndFusePattern to work with tensors.
MaheshRavishankar [Thu, 28 Jan 2021 18:51:01 +0000 (10:51 -0800)]
[mlir][Linalg] Enable TileAndFusePattern to work with tensors.

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

3 years ago[ScalarizeMaskedMemIntrin] Preserve Dominator Tree, if avaliable
Roman Lebedev [Thu, 28 Jan 2021 15:13:17 +0000 (18:13 +0300)]
[ScalarizeMaskedMemIntrin] Preserve Dominator Tree, if avaliable

This de-pessimizes the arguably more usual case of no masked mem intrinsics,
and gets rid of one more Dominator Tree recalculation.

As per llvm/test/CodeGen/X86/opt-pipeline.ll,
there's one more Dominator Tree recalculation left, we could get rid of.

3 years ago[PartiallyInlineLibCalls] Preserve Dominator Tree, if avaliable
Roman Lebedev [Thu, 28 Jan 2021 13:49:08 +0000 (16:49 +0300)]
[PartiallyInlineLibCalls] Preserve Dominator Tree, if avaliable

This doesn't get rid of any Dominator Tree recalculations just yet,
there is one more pass to update..

3 years ago[NFC][ScalarizeMaskedMemIntrin] scalarizeMaskedCompressStore(): port to SplitBlockAnd...
Roman Lebedev [Thu, 28 Jan 2021 19:59:15 +0000 (22:59 +0300)]
[NFC][ScalarizeMaskedMemIntrin] scalarizeMaskedCompressStore(): port to SplitBlockAndInsertIfThen()

Makes Dominator Tree preservation in a followup patch somewhat easier.

3 years ago[NFC][ScalarizeMaskedMemIntrin] scalarizeMaskedExpandLoad(): port to SplitBlockAndIns...
Roman Lebedev [Thu, 28 Jan 2021 19:39:19 +0000 (22:39 +0300)]
[NFC][ScalarizeMaskedMemIntrin] scalarizeMaskedExpandLoad(): port to SplitBlockAndInsertIfThen()

Makes Dominator Tree preservation in a followup patch somewhat easier.

3 years ago[NFC][ScalarizeMaskedMemIntrin] scalarizeMaskedScatter(): port to SplitBlockAndInsert...
Roman Lebedev [Thu, 28 Jan 2021 19:15:34 +0000 (22:15 +0300)]
[NFC][ScalarizeMaskedMemIntrin] scalarizeMaskedScatter(): port to SplitBlockAndInsertIfThen()

Makes Dominator Tree preservation in a followup patch somewhat easier.

3 years ago[NFC][ScalarizeMaskedMemIntrin] scalarizeMaskedGather(): port to SplitBlockAndInsertI...
Roman Lebedev [Thu, 28 Jan 2021 18:58:29 +0000 (21:58 +0300)]
[NFC][ScalarizeMaskedMemIntrin] scalarizeMaskedGather(): port to SplitBlockAndInsertIfThen()

Makes Dominator Tree preservation in a followup patch somewhat easier.

3 years ago[NFC][ScalarizeMaskedMemIntrin] scalarizeMaskedStore(): port to SplitBlockAndInsertIf...
Roman Lebedev [Thu, 28 Jan 2021 18:39:28 +0000 (21:39 +0300)]
[NFC][ScalarizeMaskedMemIntrin] scalarizeMaskedStore(): port to SplitBlockAndInsertIfThen()

Makes Dominator Tree preservation in a followup patch somewhat easier.

3 years ago[NFC][ScalarizeMaskedMemIntrin] scalarizeMaskedLoad(): port to SplitBlockAndInsertIfT...
Roman Lebedev [Thu, 28 Jan 2021 18:28:36 +0000 (21:28 +0300)]
[NFC][ScalarizeMaskedMemIntrin] scalarizeMaskedLoad(): port to SplitBlockAndInsertIfThen()

Makes Dominator Tree preservation in a followup patch somewhat easier.

3 years ago[NFC][PartiallyInlineLibCalls] Port to SplitBlockAndInsertIfThen()
Roman Lebedev [Thu, 28 Jan 2021 13:01:41 +0000 (16:01 +0300)]
[NFC][PartiallyInlineLibCalls] Port to SplitBlockAndInsertIfThen()

This makes follow-up patch for Dominator Tree preservation
somewhat more straight-forward.

3 years ago[NFC][EntryExitInstrumenter] Mark Dominator Tree as preserved in legacy-PM too
Roman Lebedev [Thu, 28 Jan 2021 21:45:04 +0000 (00:45 +0300)]
[NFC][EntryExitInstrumenter] Mark Dominator Tree as preserved in legacy-PM too

This is correctly handled in new-PM wrappers, but not in old-PM.

3 years ago[GlobalISel] Implement widenScalar for carry-in add/sub
Cassie Jones [Thu, 28 Jan 2021 18:20:35 +0000 (13:20 -0500)]
[GlobalISel] Implement widenScalar for carry-in add/sub

These are widened to a wider UADDE/USUBE, with the overflow value
unused, and with the same synthesis of a new overflow value as for the
O operations.

Reviewed By: paquette

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

3 years ago[GlobalISel] Add G_ASSERT_ZEXT
Jessica Paquette [Wed, 27 Jan 2021 20:09:05 +0000 (12:09 -0800)]
[GlobalISel] Add G_ASSERT_ZEXT

This adds a generic opcode which communicates that a type has already been
zero-extended from a narrower type.

This is intended to be similar to AssertZext in SelectionDAG.

For example,

```
%x_was_extended:_(s64) = G_ASSERT_ZEXT %x, 16
```

Signifies that the top 48 bits of %x are known to be 0.

This is useful in cases like this:

```
define i1 @zeroext_param(i8 zeroext %x) {
  %cmp = icmp ult i8 %x, -20
  ret i1 %cmp
}
```

In AArch64, `%x` must use a 32-bit register, which is then truncated to a 8-bit
value.

If we know that `%x` is already zero-ed out in the relevant high bits, we can
avoid the truncate.

Currently, in GISel, this looks like this:

```
_zeroext_param:
  and w8, w0, #0xff ; We don't actually need this!
  cmp w8, #236
  cset w0, lo
  ret
```

While SDAG does not produce the truncation, since it knows that it's
unnecessary:

```
_zeroext_param:
  cmp w0, #236
  cset w0, lo
  ret
```

This patch

- Adds G_ASSERT_ZEXT
- Adds MIRBuilder support for it
- Adds MachineVerifier support for it
- Documents it

It also puts G_ASSERT_ZEXT into its own class of "hint instruction." (There
should be a G_ASSERT_SEXT in the future, maybe a G_ASSERT_ALIGN as well.)

This allows us to skip over hints in the legalizer etc. These can then later
be selected like COPY instructions or removed.

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

3 years ago[OpenMP] NFC: disabled two flakey tests as the bug in libomp not fixed yet
AndreyChurbanov [Thu, 28 Jan 2021 21:54:13 +0000 (00:54 +0300)]
[OpenMP] NFC: disabled two flakey tests as the bug in libomp not fixed yet

3 years agoAdd the ability to extract the unwind rows from DWARF Call Frame Information.
Greg Clayton [Mon, 7 Dec 2020 23:36:45 +0000 (15:36 -0800)]
Add the ability to extract the unwind rows from DWARF Call Frame Information.

This patch adds the ability to evaluate the state machine for CIE and FDE unwind objects and produce a UnwindTable with all UnwindRow objects needed to unwind registers. It will also dump the UnwindTable for each CIE and FDE when dumping DWARF .debug_frame or .eh_frame sections in llvm-dwarfdump or llvm-objdump. This allows users to see what the unwind rows actually look like for a given CIE or FDE instead of just seeing a list of opcodes.

This patch adds new classes: UnwindLocation, RegisterLocations, UnwindRow, and UnwindTable.

UnwindLocation is a class that describes how to unwind a register or Call Frame Address (CFA).

RegisterLocations is a class that tracks registers and their UnwindLocations. It gets populated when parsing the DWARF call frame instruction opcodes for a unwind row. The registers are mapped from their register numbers to the UnwindLocation in a map.

UnwindRow contains the result of evaluating a row of DWARF call frame instructions for the CIE, or a row from a FDE. The CIE can produce a set of initial instructions that each FDE that points to that CIE will use as the seed for the state machine when parsing FDE opcodes. A UnwindRow for a CIE will not have a valid address, whille a UnwindRow for a FDE will have a valid address.

The UnwindTable is a class that contains a sorted (by address) vector of UnwindRow objects and is the result of parsing all opcodes in a CIE, or FDE. Parsing a CIE should produce a UnwindTable with a single row. Parsing a FDE will produce a UnwindTable with one or more UnwindRow objects where all UnwindRow objects have valid addresses. The rows in the UnwindTable will be sorted from lowest Address to highest after parsing the state machine, or an error will be returned if the table isn't sorted. To parse a UnwindTable clients can use the following methods:

    static Expected<UnwindTable> UnwindTable::create(const CIE *Cie);
    static Expected<UnwindTable> UnwindTable::create(const FDE *Fde);

A valid table will be returned if the DWARF call frame instruction opcodes have no encoding errors. There are a few things that can go wrong during the evaluation of the state machine and these create functions will catch and return them.

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

3 years agoRevert "[PDB] Defer relocating .debug$S until commit time and parallelize it"
Reid Kleckner [Thu, 28 Jan 2021 21:17:27 +0000 (13:17 -0800)]
Revert "[PDB] Defer relocating .debug$S until commit time and parallelize it"

This reverts commit 1a9bd5b81328adf0dd5a8b4f3ad5949463e66da3.

I suspect that this patch may have caused https://crbug.com/1171438.

3 years ago[CMake][libc] Support cross-compiling libc-hdrgen
Petr Hosek [Fri, 22 Jan 2021 06:55:12 +0000 (22:55 -0800)]
[CMake][libc] Support cross-compiling libc-hdrgen

This is useful when cross-compiling libc to another target in which
case we first need to compile libc-hdrgen for host. We rely on the
existing LLVM CMake infrastructure for that.

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

3 years ago[CMake][libc] Don't do CPU feature detection when cross-compiling
Petr Hosek [Fri, 22 Jan 2021 05:21:48 +0000 (21:21 -0800)]
[CMake][libc] Don't do CPU feature detection when cross-compiling

We won't be able to run the compiled program since it will be compiled
for different system. We instead allow passing the CPU features via
CMake option in that case.

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

3 years ago[ASTMatchers] Add invocation matcher
Stephen Kelly [Sat, 16 Jan 2021 14:26:32 +0000 (14:26 +0000)]
[ASTMatchers] Add invocation matcher

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

3 years ago[ASTMatchers] Avoid pathological traversal over nested lambdas
Stephen Kelly [Wed, 27 Jan 2021 23:47:05 +0000 (23:47 +0000)]
[ASTMatchers] Avoid pathological traversal over nested lambdas

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

3 years agoSupport: Simplify __HAIKU__ #ifdef in llvm::sys::Wait, NFC
Duncan P. N. Exon Smith [Thu, 28 Jan 2021 20:25:53 +0000 (12:25 -0800)]
Support: Simplify __HAIKU__ #ifdef in llvm::sys::Wait, NFC

This just reduces the amount of code in the `#ifndef` block as a
follow-up to 5c1cea6f406366b85f3c200a1c48f713da4450ba.

3 years agoRemoving the main to master sync GitHub workflow.
Mike Edwards [Thu, 28 Jan 2021 20:18:13 +0000 (12:18 -0800)]
Removing the main to master sync GitHub workflow.

3 years ago[PowerPC][Power10] Fix XXSPLI32DX not correctly exploiting specific cases
Albion Fung [Thu, 28 Jan 2021 20:17:18 +0000 (15:17 -0500)]
[PowerPC][Power10] Fix XXSPLI32DX not correctly exploiting specific cases

Some cases may be transformed into 32 bit splats before hitting the boolean statement, which may cause incorrect behaviour and provide XXSPLTI32DX with the incorrect values of splat. The condition was reversed so that the shortcut prevents this problem.

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

3 years agoFix memory leak in 4318028cd2d7633a0cdeb0b5d4d2ed81fab87864
David Blaikie [Thu, 28 Jan 2021 20:07:31 +0000 (12:07 -0800)]
Fix memory leak in 4318028cd2d7633a0cdeb0b5d4d2ed81fab87864

3 years agoRevert "[mlir][Linalg] Replace SimplePad with PadTensor in hoist-padding"
Hanhan Wang [Thu, 28 Jan 2021 19:24:57 +0000 (11:24 -0800)]
Revert "[mlir][Linalg] Replace SimplePad with PadTensor in hoist-padding"

This reverts commit 1e790b745d7e3b0c79deec2de202a4de7e7a66c3.

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

3 years ago[mlir][Linalg] Replace SimplePad with PadTensor in hoist-padding
Hanhan Wang [Thu, 28 Jan 2021 18:56:49 +0000 (10:56 -0800)]
[mlir][Linalg] Replace SimplePad with PadTensor in hoist-padding

This is the last revision to migrate using SimplePadOp to PadTensorOp, and the
SimplePadOp is removed in the patch. Update a bit in SliceAnalysis because the
PadTensorOp takes a region different from SimplePadOp. This is not covered by
LinalgOp because it is not a structured op.

Also, remove a duplicated comment from cpp file, which is already described in a
header file. And update the pseudo-mlir in the comment.

Reviewed By: nicolasvasilache

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

3 years ago[WebAssembly] Prototype i8x16 to i32x4 widening instructions
Thomas Lively [Thu, 28 Jan 2021 18:59:32 +0000 (10:59 -0800)]
[WebAssembly] Prototype i8x16 to i32x4 widening instructions

As proposed in https://github.com/WebAssembly/simd/pull/395 and matching the
opcodes used in V8:
https://chromium-review.googlesource.com/c/v8/v8/+/2617385/4/src/wasm/wasm-opcodes.h

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

3 years agoAdd convenience function for checking arrays of shapes compatible.
Jacques Pienaar [Thu, 28 Jan 2021 18:47:07 +0000 (10:47 -0800)]
Add convenience function for checking arrays of shapes compatible.

Expand existing one to handle the common case for verifying compatible
is existing and inferred. This considers arrays equivalent if they they
have the same size and pairwise compatible elements.

3 years ago[sparse][mlir] give all sparse kernels an explicit "output" tensor
Aart Bik [Thu, 28 Jan 2021 18:24:33 +0000 (10:24 -0800)]
[sparse][mlir] give all sparse kernels an explicit "output" tensor

Rationale:
Providing an output tensor, even if one is not used as input to
the kernel provides the right pattern for using lingalg sparse
kernels (in contrast with reusing a tensor just to provide the shape).
This prepares proper bufferization that will follow.

Reviewed By: bixia

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

3 years ago[gn build] (manually) port 081c1db02dd2 more
Nico Weber [Thu, 28 Jan 2021 18:32:00 +0000 (13:32 -0500)]
[gn build] (manually) port 081c1db02dd2 more

3 years ago[gn build] (manually) port 3b625060fc915
Nico Weber [Thu, 28 Jan 2021 18:26:23 +0000 (13:26 -0500)]
[gn build] (manually) port 3b625060fc915

3 years agoDebugInfo: Add a DWARF FORM extension for addrx+offset references to reduce relocations
David Blaikie [Thu, 28 Jan 2021 02:09:31 +0000 (18:09 -0800)]
DebugInfo: Add a DWARF FORM extension for addrx+offset references to reduce relocations

This is an alternative to the use of complex DWARF expressions for
addresses - shaving off a few extra bytes of expression overhead.

3 years ago[mlir] turn complex-to-llvm into a partial conversion
Alex Zinenko [Thu, 28 Jan 2021 16:42:41 +0000 (17:42 +0100)]
[mlir] turn complex-to-llvm into a partial conversion

It is no longer necessary to also convert other "standard" ops along with the
complex dialect: the element types are now built-in integers or floating point
types, and the top-level cast between complex and struct is automatically
inserted and removed in progressive lowering.

Reviewed By: herhut

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

3 years ago[WebAssembly] Fix Fast ISEL not lowering 64-bit function pointers
Wouter van Oortmerssen [Tue, 26 Jan 2021 00:49:09 +0000 (16:49 -0800)]
[WebAssembly] Fix Fast ISEL not lowering 64-bit function pointers

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

3 years ago[gn build] (semi-manually) port 081c1db02dd2
Nico Weber [Thu, 28 Jan 2021 18:05:10 +0000 (13:05 -0500)]
[gn build] (semi-manually) port 081c1db02dd2

3 years ago[AMDGPU] Simplify some RUN lines. NFC.
Jay Foad [Thu, 28 Jan 2021 17:52:06 +0000 (17:52 +0000)]
[AMDGPU] Simplify some RUN lines. NFC.

3 years ago[mlir] NFC: split --shared-libs option into multiple lines.
Christian Sigg [Thu, 28 Jan 2021 15:26:22 +0000 (16:26 +0100)]
[mlir] NFC: split --shared-libs option into multiple lines.

3 years agoBetter document the limitations of coro::salvageDebugInfo()
Adrian Prantl [Thu, 28 Jan 2021 17:49:28 +0000 (09:49 -0800)]
Better document the limitations of coro::salvageDebugInfo()

and fix a few edge cases that show up in the Swift compiler but
weren't caught by the existing tests. Most notably the old code wasn't
salvaging load operations correctly. The patch also gets rid of the
LoadFromFramePtr argument and replaces it with a more generalized
mechanism.

3 years ago[NFC] Disallow unused prefixes under clang/test/CodeGenCXX
Mircea Trofin [Wed, 27 Jan 2021 04:03:33 +0000 (20:03 -0800)]
[NFC] Disallow unused prefixes under clang/test/CodeGenCXX

The only test that needed change had 'QUAL' as an unused prefix. The
rest of the changes are to simplify the prefix lists.

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

3 years ago[llvm-nm] Display defined weak STT_GNU_IFUNC symbols as 'i'
Fangrui Song [Thu, 28 Jan 2021 17:46:05 +0000 (09:46 -0800)]
[llvm-nm] Display defined weak STT_GNU_IFUNC symbols as 'i'

This patch makes the behavior match GNU nm.
Note: undefined STT_GNU_IFUNC symbols use 'U'.

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

3 years ago[libcxx][test] Update directory_entry test for C++20
Casey Carter [Thu, 28 Jan 2021 17:35:48 +0000 (09:35 -0800)]
[libcxx][test] Update directory_entry test for C++20

P1614R2 removes most of `directory_entry`'s member comparison operators, leaving only `operator==` and `operator<=>`. This test should require the comparison expressions to be valid rather than require the member functions to be present so it is correct in both C++17 and C++20 modes.

3 years agoFix lldb-vscode builds on Windows targeting POSIX
Walter Erquinigo [Thu, 28 Jan 2021 17:24:30 +0000 (09:24 -0800)]
Fix lldb-vscode builds on Windows targeting POSIX

@stella.stamenova found out that lldb-vscode's Win32 macros were failing
when building on windows targetings POSIX platforms.

I'm changing these macros for LLVM_ON_UNIX, which should be more
accurate.

3 years ago[mlir] Fix test by adapting to C util functions moving to libmlir_c_runner_utils
Nicolas Vasilache [Thu, 28 Jan 2021 17:35:39 +0000 (17:35 +0000)]
[mlir] Fix test by adapting to C util functions moving to libmlir_c_runner_utils

3 years ago[RISCV] Remove isel patterns for Zbs *W instructions.
Craig Topper [Thu, 28 Jan 2021 17:13:00 +0000 (09:13 -0800)]
[RISCV] Remove isel patterns for Zbs *W instructions.

These instructions have been removed from the 0.94 bitmanip spec.
We should focus on optimizing the codegen without using them.

Reviewed By: asb

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

3 years ago[libc++] Implements concept constructible_from
Mark de Wever [Thu, 17 Dec 2020 05:53:00 +0000 (06:53 +0100)]
[libc++] Implements concept constructible_from

Implements parts of:
- P0898R3 Standard Library Concepts
- P1754 Rename concepts to standard_case for C++20, while we still can

Depends on: D91004

Reviewed By: ldionne, cjdb, #libc

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

3 years ago[mlir][sparse] use typenames for opaque pointers
Aart Bik [Thu, 28 Jan 2021 06:56:07 +0000 (22:56 -0800)]
[mlir][sparse] use typenames for opaque pointers

Makes intent more readable

Reviewed By: ftynse

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

3 years ago[RISCV] Add support for scalable vector fneg using vfsgnjn.vv
Craig Topper [Thu, 28 Jan 2021 16:47:25 +0000 (08:47 -0800)]
[RISCV] Add support for scalable vector fneg using vfsgnjn.vv

Reviewed By: frasercrmck

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

3 years ago[libc++] Implement format_error.
Mark de Wever [Thu, 26 Nov 2020 18:12:18 +0000 (19:12 +0100)]
[libc++] Implement format_error.

This is the first step at implementing <format>. It adds the <format> header
and implements the `format_error`. class.

Implemnts parts of:
-P0645 Text Formatting

Reviewed By: ldionne, #libc, miscco, curdeius

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

3 years ago[libc++] [P0879] constexpr std::nth_element, and rewrite its tests.
Arthur O'Dwyer [Thu, 17 Dec 2020 05:40:02 +0000 (00:40 -0500)]
[libc++] [P0879] constexpr std::nth_element, and rewrite its tests.

This patch is more than just adding the `constexpr` keyword, because
the old code relied on `goto`, and `goto` is not constexpr-friendly.
Refactor to eliminate `goto`, and then mark it as constexpr in C++20.

I freely admit that the name `__nth_element_partloop` is bad;
I couldn't find any better name because I don't really know
what this loop is doing, conceptually. Vice versa, I think
`__nth_element_find_guard` has a decent name.

Now the only one we're still missing from P0879 is `sort`.

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

3 years ago[mlir] Fix integration tests
Nicolas Vasilache [Thu, 28 Jan 2021 16:52:10 +0000 (16:52 +0000)]
[mlir] Fix integration tests

3 years ago[lld][WebAssembly] Update comments mentioning legacy function names. NFC
Sam Clegg [Thu, 28 Jan 2021 16:20:42 +0000 (08:20 -0800)]
[lld][WebAssembly] Update comments mentioning legacy function names. NFC

The __wasm_apply_relocs function was split into two separate
functions as part of https://reviews.llvm.org/D93066 but these
comments were not correctly updated at the time.

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

3 years agoRevert "[DWARF] Create subprogram's DIE in DISubprogram's unit"
Shaurya Gupta [Thu, 28 Jan 2021 16:19:30 +0000 (16:19 +0000)]
Revert "[DWARF] Create subprogram's DIE in DISubprogram's unit"

This reverts commit ef0dcb506300dc9644e8000c6028d14214be9d97.

This change is causing a lot of compiler crashes inside, sorry I don't have a
small repro/stacktrace with symbols to share right now.

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

3 years ago[X86][AVX] combineHorizOpWithShuffle - fix valuetype comparison typo.
Simon Pilgrim [Thu, 28 Jan 2021 16:24:40 +0000 (16:24 +0000)]
[X86][AVX] combineHorizOpWithShuffle - fix valuetype comparison typo.

Ensure we check the valuetypes of all the HOP(SHUFFLE(X,Y),SHUFFLE(X,Y)) shuffle input ops - there was a copy+paste typo (noticed by MSVC analyzer) that meant we were checking the same input from one of the shuffles twice.

I haven't been able to create a test case for this yet - I don't think its currently possible to create a target/faux binary shuffle that scales to a 2x128 shuffle mask from two different value types.