platform/upstream/llvm.git
3 years agoUse the default seed value for djb hash for StringMap
serge-sans-paille [Wed, 24 Feb 2021 15:15:24 +0000 (16:15 +0100)]
Use the default seed value for djb hash for StringMap

See original comment in 560ce2c70fb1fe8e4b9b5e39c54e494a50373ba8
Baiscally the default seed value results in less collision, but changes the
iteration order, which matters for a few test cases.

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

3 years ago[RISCV] Support INSERT_SUBVECTOR on vector masks
Fraser Cormack [Fri, 26 Feb 2021 14:30:14 +0000 (14:30 +0000)]
[RISCV] Support INSERT_SUBVECTOR on vector masks

Like with EXTRACT_SUBVECTOR, INSERT_SUBVECTOR poses a problem
for vector masks as RVV isn't able to slide mask types around. We choose
instead to bitcast to equivalently-sized i8 types where we can, else we
zero-extend, perform the operation, and truncate back down.

One test was left disabled due to a crash in the legalizer.

Reviewed By: craig.topper

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

3 years ago[RISCV] Fix INSERT/EXTRACT_SUBVECTOR on fractional LMUL types
Fraser Cormack [Fri, 26 Feb 2021 14:46:23 +0000 (14:46 +0000)]
[RISCV] Fix INSERT/EXTRACT_SUBVECTOR on fractional LMUL types

This patch fixes a bug where the lowering for INSERT_SUBVECTOR and
EXTRACT_SUBVECTOR would insist on first extracting a register-aligned
LMUL1 vector type before perfoming the slide up/down. This was even if
the vector was a fractional LMUL type, in which case the aligned
EXTRACT_SUBVECTOR was invalid.

This issue only occurred for scalable vector types, but a variety of
tests for both scalable and fixed-length vectors have been added to
ensure this does not regress in the future.

Reviewed By: craig.topper

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

3 years ago[RISCV] Unify scalable- and fixed-vector INSERT_SUBVECTOR lowering
Fraser Cormack [Fri, 26 Feb 2021 12:42:52 +0000 (12:42 +0000)]
[RISCV] Unify scalable- and fixed-vector INSERT_SUBVECTOR lowering

This patch unifies the two disparate paths for lowering INSERT_SUBVECTOR
operations under one roof. Consequently, with this patch it is possible to
support any fixed-length subvector insertion, not just "cast-like" ones.

As before, support for the insertion of mask vectors will come in a
separate patch.

Reviewed By: craig.topper

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

3 years ago[RISCV] Support EXTRACT_SUBVECTOR on vector masks
Fraser Cormack [Thu, 25 Feb 2021 08:15:25 +0000 (08:15 +0000)]
[RISCV] Support EXTRACT_SUBVECTOR on vector masks

This patch adds support for extracting subvectors from vector masks.
This can be either extracting a scalable vector from another, or a fixed-length
vector from a fixed-length or scalable vector.

Since RVV lacks a way to slide vector masks down on an element-wise
basis and we don't know the true length of the vector registers, in many
cases we must resort to using equivalently-sized i8 vectors to perform
the operation. When this is not possible we fall back and extend to a
suitable i8 vector.

Support was also added for fixed-length truncation to mask types.

Reviewed By: craig.topper

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

3 years ago[SEH] capture 'this'
Olivier Goffart [Wed, 24 Feb 2021 10:57:38 +0000 (11:57 +0100)]
[SEH] capture 'this'

Simply make sure that the CodeGenFunction::CXXThisValue and CXXABIThisValue
are correctly initialized to the recovered value.
For lambda capture, we also need to make sure to fill the LambdaCaptureFields

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

3 years ago[LV] Generate RT checks up-front and remove them if required.
Florian Hahn [Mon, 1 Mar 2021 09:40:12 +0000 (09:40 +0000)]
[LV] Generate RT checks up-front and remove them if required.

This patch updates LV to generate the runtime checks just after cost
modeling, to allow a more precise estimate of the actual cost of the
checks. This information will be used in future patches to generate
larger runtime checks in cases where the checks only make up a small
fraction of the expected scalar loop execution time.

The runtime checks are created up-front in a temporary block to allow better
estimating the cost and un-linked from the existing IR. After deciding to
vectorize, the checks are moved backed. If deciding not to vectorize, the
temporary block is completely removed.

This patch is similar in spirit to D71053, but explores a different
direction: instead of delaying the decision on whether to vectorize in
the presence of runtime checks it instead optimistically creates the
runtime checks early and discards them later if decided to not
vectorize. This has the advantage that the cost-modeling decisions
can be kept together and can be done up-front and thus preserving the
general code structure. I think delaying (part) of the decision to
vectorize would also make the VPlan migration a bit harder.

One potential drawback of this patch is that we speculatively
generate IR which we might have to clean up later. However it seems like
the code required to do so is quite manageable.

Reviewed By: lebedev.ri, ebrevnov

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

3 years ago[DAG] visitVECTOR_SHUFFLE - attempt to match commuted shuffles with MergeInnerShuffle.
Simon Pilgrim [Mon, 1 Mar 2021 10:41:57 +0000 (10:41 +0000)]
[DAG] visitVECTOR_SHUFFLE - attempt to match commuted shuffles with MergeInnerShuffle.

Try to match "shuffle(C, shuffle(A, B, M0), M1) -> shuffle(A, B, M2)" etc. by using MergeInnerShuffle's commuted inner shuffle mode.

3 years agoRevert "[flang] Detect circularly defined interfaces of procedures"
Andrzej Warzynski [Mon, 1 Mar 2021 10:18:36 +0000 (10:18 +0000)]
Revert "[flang] Detect circularly defined interfaces of procedures"

This reverts commit 07de0846a5055015b55dc2b8faa2143f9902e549.

The original patch has caused 6 out 8 of Flang's public buildbots to
fail. As I'm not sure what the fix should be, I'm reverting this for
now. Please see https://reviews.llvm.org/D97201 for more context and
discussion.

3 years ago[CodeGen] Fix issues with subvector intrinsic index types
Fraser Cormack [Thu, 25 Feb 2021 09:50:20 +0000 (09:50 +0000)]
[CodeGen] Fix issues with subvector intrinsic index types

This patch addresses issues arising from the fact that the index type
used for subvector insertion/extraction is inconsistent between the
intrinsics and SDNodes. The intrinsic forms require i64 whereas the
SDNodes use the type returned by SelectionDAG::getVectorIdxTy.

Rather than update the intrinsic definitions to use an overloaded index
type, this patch fixes the issue by transforming the index to the
correct type as required. Any loss of index bits going from i64 to a
smaller type is unexpected, and will be caught by an assertion in
SelectionDAG::getVectorIdxConstant.

The patch also updates the documentation for INSERT_SUBVECTOR and adds
an assertion to its creation to bring it in line with EXTRACT_SUBVECTOR.
This necessitated changes to AArch64 which was using i64 for
EXTRACT_SUBVECTOR but i32 for INSERT_SUBVECTOR. Only one test changed
its codegen after updating the backend accordingly.

Reviewed By: sdesmalen

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

3 years ago[Statepoint Lowering] Consider dead deopt gc values together with other gc values
Serguei Katkov [Thu, 25 Feb 2021 09:28:50 +0000 (16:28 +0700)]
[Statepoint Lowering] Consider dead deopt gc values together with other gc values

Currently dead gc value mentioned in the deopt section are not listed in gc section
and so are processed separately.
With this CL all deopt gc values are considered as base pointers and processed in the
same way as other gc values.

The fact that deopt gc pointer is a base pointer was used all the time but
it is explicitly documented here by putting the value in SI.Base.

The idea of the patch comes from Philip Reames.

Reviewers: reames, dantrushin
Reviewed By: reames
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D97554

3 years ago[lldb/Interpreter] Pacify -Wnon-virtual-dtor
Benjamin Kramer [Mon, 1 Mar 2021 10:19:22 +0000 (11:19 +0100)]
[lldb/Interpreter] Pacify -Wnon-virtual-dtor

3 years ago[Driver] Don't litter the source directory in test
Benjamin Kramer [Mon, 1 Mar 2021 10:18:21 +0000 (11:18 +0100)]
[Driver] Don't litter the source directory in test

3 years ago[libc++] [docs] [C++2b] Update status page with issues (and forgotten papers) adopted...
Marek Kurdej [Mon, 1 Mar 2021 09:31:29 +0000 (10:31 +0100)]
[libc++] [docs] [C++2b] Update status page with issues (and forgotten papers) adopted in November 2020 and February 2021 virtual meetings.

Sources:
* https://github.com/cplusplus/draft/pull/4380 (November 2020)
* https://github.com/cplusplus/draft/pull/4523 (February 2021)
* https://github.com/cplusplus/draft/issues?q=is%3Aissue+LWG+Motion

3 years ago[DAG] visitVECTOR_SHUFFLE - move shuffle canonicalization/merges all under the same...
Simon Pilgrim [Mon, 1 Mar 2021 09:40:43 +0000 (09:40 +0000)]
[DAG] visitVECTOR_SHUFFLE - move shuffle canonicalization/merges all under the same legality test. NFCI.

Minor cleanup to move related combines closer together to make it more coherent, without changing the ordering.

3 years agoUse a fast path when initializing LineOffsetMapping
serge-sans-paille [Tue, 23 Feb 2021 19:46:35 +0000 (20:46 +0100)]
Use a fast path when initializing LineOffsetMapping

Use the fact that the number of line break is lower than printable characters to
guide the optimization process. Also use a fuzzy test that catches both \n and
\r in a single check to speedup the computation.

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

3 years ago[clangd] Use flags from open files when opening headers they include
Sam McCall [Wed, 24 Feb 2021 01:43:53 +0000 (02:43 +0100)]
[clangd] Use flags from open files when opening headers they include

Currently our strategy for getting header compile flags is something like:

A) look for flags for the header in compile_commands.json
   This basically never works, build systems don't generate this info.
B) try to match to an impl file in compile_commands.json and use its flags
   This only (mostly) works if the headers are in the same project.
C) give up and use fallback flags
   This kind of works for stdlib in the default configuration, and
   otherwise doesn't.

Obviously there are big gaps here.

This patch inserts a new attempt between A and B: if the header is
transitively included by any open file (whether same project or not),
then we use its compile command.

This doesn't make any attempt to solve some related problems:
 - parsing non-self-contained header files in context (importing PP state)
 - using the compile flags of non-opened candidate files found in the index

Fixes https://github.com/clangd/clangd/issues/123
Fixes https://github.com/clangd/clangd/issues/695
See https://github.com/clangd/clangd/issues/519

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

3 years ago[NFC] Detect IV increment expressed as uadd_with_overflow and usub_with_overflow
Max Kazantsev [Mon, 1 Mar 2021 06:22:42 +0000 (13:22 +0700)]
[NFC] Detect IV increment expressed as uadd_with_overflow and usub_with_overflow

Current callers do not call it with such argument, so this is NFC.
But for further changes, it can be very useful to detect such cases.

3 years ago[NFC] Introduce function getIVStep for further reuse
Max Kazantsev [Mon, 1 Mar 2021 06:04:17 +0000 (13:04 +0700)]
[NFC] Introduce function getIVStep for further reuse

3 years ago[NFC] Whitespace fix
Max Kazantsev [Mon, 1 Mar 2021 05:14:03 +0000 (12:14 +0700)]
[NFC] Whitespace fix

3 years ago[NFC] Factor out IV detector function for further reuse
Max Kazantsev [Mon, 1 Mar 2021 05:07:46 +0000 (12:07 +0700)]
[NFC] Factor out IV detector function for further reuse

3 years ago[profile] Delete zero-size dummy sections
Fangrui Song [Mon, 1 Mar 2021 05:07:30 +0000 (21:07 -0800)]
[profile] Delete zero-size dummy sections

They were added so that if no metadata section is present,
`__start_llvm_prf_*` references would not cause "undefined symbol"
errors.  By switching to undefined weak symbols in D96936, the dummy
sections are not needed.

This patch is also needed to work around
https://sourceware.org/bugzilla/show_bug.cgi?id=27490

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

3 years ago[SimplifyCFG] Update FoldTwoEntryPHINode to handle and/or of select and binop equally
Juneyoung Lee [Mon, 1 Mar 2021 04:28:18 +0000 (13:28 +0900)]
[SimplifyCFG] Update FoldTwoEntryPHINode to handle and/or of select and binop equally

This is a minor change that fixes FoldTwoEntryPHINode to handle
phis with and/ors of select form and binop form equally.

3 years ago[Statepoint lowering] Require spill of deopt value in case its type is not legal
Serguei Katkov [Fri, 26 Feb 2021 10:27:03 +0000 (17:27 +0700)]
[Statepoint lowering] Require spill of deopt value in case its type is not legal

If the type of the deopt operand has an illegal type and we want to use
register for it then it needs to be legalized.
This is not supported currently by legalizer and it is not actually clear how to
legalize this type of values.

Instead we just spill such values and use spill slot location in statepoint.

Originally tests were created by Philip Reames.

Reviewers: reames, dantrushin
Reviewed By: reames
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D97541

3 years ago[lld][ELF] Removing redundant cast. NFC.
Sam Clegg [Mon, 1 Mar 2021 00:42:49 +0000 (16:42 -0800)]
[lld][ELF] Removing redundant cast. NFC.

Also a couple of minor cleanups in merge-string.s:
- fix inconsistent use of tabs
- use `.p2align` rather than `.align` since `.p2align` works the
  same on all platforms (the meaning of align seems to differ
  between platforms according to `AlignmentIsInBytes`.

I noticed these potential cleanups while porting SHF_STRINGS support to
wasm-ld.

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

3 years agoAdd tests which include brace initialization
Stephen Kelly [Mon, 1 Mar 2021 00:33:03 +0000 (00:33 +0000)]
Add tests which include brace initialization

3 years ago[DAGCombiner][X86] Don't peek through ANDs on the shift amount in matchRotateSub...
Craig Topper [Sun, 28 Feb 2021 19:23:46 +0000 (11:23 -0800)]
[DAGCombiner][X86] Don't peek through ANDs on the shift amount in matchRotateSub when called from MatchFunnelPosNeg.

Peeking through AND is only valid if the input to both shifts is
the same. If the inputs are different, then the original pattern
ORs the two values when the masked shift amount is 0. This is ok
if the values are the same since the OR would be a NOP which is
why its ok for rotate.

Fixes PR49365 and reverts PR34641

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

3 years ago[IR] Use range-based for loops (NFC)
Kazu Hirata [Sun, 28 Feb 2021 18:59:23 +0000 (10:59 -0800)]
[IR] Use range-based for loops (NFC)

3 years ago[TableGen] Use ListSeparator (NFC)
Kazu Hirata [Sun, 28 Feb 2021 18:59:21 +0000 (10:59 -0800)]
[TableGen] Use ListSeparator (NFC)

3 years ago[llvm] Use set_is_subset (NFC)
Kazu Hirata [Sun, 28 Feb 2021 18:59:20 +0000 (10:59 -0800)]
[llvm] Use set_is_subset (NFC)

3 years ago[DAGCombiner] Don't skip no overflow check on UMULO if the first computeKnownBits...
Craig Topper [Sun, 28 Feb 2021 16:20:57 +0000 (08:20 -0800)]
[DAGCombiner] Don't skip no overflow check on UMULO if the first computeKnownBits call doesn't return any 0 bits.

Even if the first computeKnownBits call doesn't have any zero
bits it is possible the other operand has bitwidth-1 leading zero.
In that case overflow is still impossible. So always call computeKnownBits
for both operands.

3 years ago[lldb/Target] Remove outdated code
Tatyana Krasnukha [Fri, 19 Feb 2021 22:21:05 +0000 (01:21 +0300)]
[lldb/Target] Remove outdated code

Arg0 callback does work.

3 years ago[lldb/Interpreter] Fix deep copying for OptionValue classes
Tatyana Krasnukha [Fri, 19 Feb 2021 21:49:42 +0000 (00:49 +0300)]
[lldb/Interpreter] Fix deep copying for OptionValue classes

Some implementations of the DeepCopy function called the copy constructor that copied m_parent member instead of setting a new parent. Others just leaved the base class's members (m_parent, m_callback, m_was_set) empty.
One more problem is that not all classes override this function, e.g. OptionValueArgs::DeepCopy produces OptionValueArray instance, and Target[Process/Thread]ValueProperty::DeepCopy produces OptionValueProperty. This makes downcasting via static_cast invalid.

The patch implements idiom "virtual constructor" to fix these issues.
Add a test that checks DeepCopy for correct copying/setting all data members of the base class.

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

3 years ago[lldb] OptionValueProperties::Get[Set]PropertyAtIndexAsArgs should handle OptionValueArgs
Tatyana Krasnukha [Fri, 19 Feb 2021 21:33:47 +0000 (00:33 +0300)]
[lldb] OptionValueProperties::Get[Set]PropertyAtIndexAsArgs should handle OptionValueArgs

3 years ago[lldb][NFC] Make OptionValueArgs::GetArgs constant
Tatyana Krasnukha [Fri, 19 Feb 2021 21:08:18 +0000 (00:08 +0300)]
[lldb][NFC] Make OptionValueArgs::GetArgs constant

3 years ago[lldb/Interpreter][NFC] Remove explicit default initialization of members and base...
Tatyana Krasnukha [Fri, 19 Feb 2021 20:42:42 +0000 (23:42 +0300)]
[lldb/Interpreter][NFC] Remove explicit default initialization of members and base classes

According to clang-tidy's readability-redundant-member-init.

3 years ago[lldb/Interpreter][NFC] Replace default constructors/destructors bodies with "=default"
Tatyana Krasnukha [Thu, 18 Feb 2021 09:32:22 +0000 (12:32 +0300)]
[lldb/Interpreter][NFC] Replace default constructors/destructors bodies with "=default"

3 years ago[lldb/Interpreter][NFC] Remove more deleted const char* overloads
Tatyana Krasnukha [Thu, 18 Feb 2021 08:54:33 +0000 (11:54 +0300)]
[lldb/Interpreter][NFC] Remove more deleted const char* overloads

A follow-up commit to D96861.

3 years agoAMDGPU/GlobalISel: Add subtarget to a test
Matt Arsenault [Sat, 27 Feb 2021 19:41:45 +0000 (14:41 -0500)]
AMDGPU/GlobalISel: Add subtarget to a test

SelectionDAG forces us to have a weird ABI for 16-bit values without
legal 16-bit operations, but currently GlobalISel bypasses this and
sometimes ends up using the gfx8+ ABI in some contexts. Make sure
we're testing the normal ABI to avoid a test change in a future patch.

3 years ago[InstCombine] avoid infinite loop in demanded bits for select
Sanjay Patel [Sun, 28 Feb 2021 15:17:10 +0000 (10:17 -0500)]
[InstCombine] avoid infinite loop in demanded bits for select

https://llvm.org/PR49205

3 years ago[ARM] VMOVN undef folding
David Green [Sun, 28 Feb 2021 14:44:45 +0000 (14:44 +0000)]
[ARM] VMOVN undef folding

If we insert undef using a VMOVN, we can just use the original value in
three out of the four possible combinations. Using VMOVT into a undef
vector will still require the lanes to be moved, but otherwise the
non-undef value can be used.

3 years ago[lld/mac] Simplify encodeDylibOrdinal() a bit
Nico Weber [Sat, 27 Feb 2021 00:13:48 +0000 (19:13 -0500)]
[lld/mac] Simplify encodeDylibOrdinal() a bit

Only one of the two callers used the lastBinding parameter, so
do that work at that one call site. Extract a ordinalForDylibSymbol()
helper to make this tidy.

No behavior change.

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

3 years ago[X86][AVX] Reuse existing VBROADCAST(x) for SCALAR_TO_VECTOR(x)
Simon Pilgrim [Sun, 28 Feb 2021 11:37:27 +0000 (11:37 +0000)]
[X86][AVX] Reuse existing VBROADCAST(x) for SCALAR_TO_VECTOR(x)

Similar to what we already do for BROADCASTs of different vector sizes - if we're going to broadcast it anyway might as well reuse it.

3 years ago[ARM] VECTOR_REG_CAST undef -> undef
David Green [Sun, 28 Feb 2021 11:13:49 +0000 (11:13 +0000)]
[ARM] VECTOR_REG_CAST undef -> undef

Propagate undef through VECTOR_REG_CAST nodes, allowing extra
simplification in some patterns.

3 years ago[SampleFDO] Add a cutoff flag to control how many symbols will be included
Wei Mi [Sun, 28 Feb 2021 05:44:28 +0000 (21:44 -0800)]
[SampleFDO] Add a cutoff flag to control how many symbols will be included
into profile symbol list.

When test is unrepresentative to production behavior, sample profile
collected from production can cause unexpected performance behavior
in test. To triage such issue, it is useful to have a cutoff flag
to control how many symbols will be included into profile symbol list
in order to do binary search.

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

3 years ago[X86] Add avx512f command lines to vec_smulo and vec_umulo.
Craig Topper [Sun, 28 Feb 2021 03:48:01 +0000 (19:48 -0800)]
[X86] Add avx512f command lines to vec_smulo and vec_umulo.

3 years ago[Debug-Info][NFC] use emitDwarfUnitLength for debug line section
Chen Zheng [Sun, 28 Feb 2021 03:33:49 +0000 (22:33 -0500)]
[Debug-Info][NFC] use emitDwarfUnitLength for debug line section

Use emitDwarfUnitLength for debug line, so we can benefit from
overriding of emitDwarfUnitLength inside different streamers.

Reviewed By: ikudrin, dblaikie

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

3 years ago[Attributor] Conditinoally delete fns
William S. Moses [Mon, 22 Feb 2021 20:38:23 +0000 (15:38 -0500)]
[Attributor] Conditinoally delete fns

Allow the attributor to delete functions only if requested

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

3 years ago[mlir][sparse] fixed inaccury in maintaining universal index
Aart Bik [Fri, 26 Feb 2021 22:59:32 +0000 (14:59 -0800)]
[mlir][sparse] fixed inaccury in maintaining universal index

The universal index was maintained if dense indices were still
in place, and lattice points followed. However, it should only
be kept if any of those following lattice points actually
consumes the universal index. This change also fixes an
inaccuracy with a missing broadcast around vector invariant.

Reviewed By: bixia

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

3 years ago[X86] Fix a couple comments that said LHS where they meant RHS. NFC
Craig Topper [Sun, 28 Feb 2021 01:14:11 +0000 (17:14 -0800)]
[X86] Fix a couple comments that said LHS where they meant RHS. NFC

3 years agoNFC: Adds labels to a linalg test and extend a missing case.
Stella Laurenzo [Sat, 27 Feb 2021 23:59:34 +0000 (15:59 -0800)]
NFC: Adds labels to a linalg test and extend a missing case.

3 years ago[mlir][linalg] Add symbolic type conversion to linalg named ops.
Stella Laurenzo [Sat, 27 Feb 2021 02:01:15 +0000 (18:01 -0800)]
[mlir][linalg] Add symbolic type conversion to linalg named ops.

This enables this kind of construct in the DSL to generate a named op that is polymorphic over numeric type variables `T` and `U`, generating the correct arithmetic casts at construction time:

```
@tc_def_op
def polymorphic_matmul(A=TensorDef(T1, S.M, S.K),
                       B=TensorDef(T2, S.K, S.N),
                       C=TensorDef(U, S.M, S.N, output=True)):
  implements(ContractionOpInterface)
  C[D.m, D.n] += cast(U, A[D.m, D.k]) * cast(U, B[D.k, D.n])
```

Presently, this only supports type variables that are bound to the element type of one of the arguments, although a further extension that allows binding a type variable to an attribute would allow some more expressiveness and may be useful for some formulations. This is left to a future patch. In addition, this patch does not yet materialize the verifier support which ensures that types are bound correctly (for such simple examples, failing to do so will yield IR that fails verification, it just won't yet fail with a precise error).

Note that the full grid of extensions/truncation/int<->float conversions are supported, but many of them are lossy and higher level code needs to be mindful of numerics (it is not the job of this level).

As-is, this should be sufficient for most integer matmul scenarios we work with in typical quantization schemes.

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

3 years ago[mlir][linalg] Generate additional interfaces for named ops.
Stella Laurenzo [Fri, 26 Feb 2021 21:01:03 +0000 (13:01 -0800)]
[mlir][linalg] Generate additional interfaces for named ops.

* Adds ContractionOpInterface to polymorphic_matmul.

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

3 years ago[X86] Add back SSE check prefix for vec-umulo.ll. Regenerate vec-smulo.ll. NFC
Craig Topper [Sat, 27 Feb 2021 22:08:56 +0000 (14:08 -0800)]
[X86] Add back SSE check prefix for vec-umulo.ll. Regenerate vec-smulo.ll. NFC

Simon modified the check prefixes in these tests while D97160
was pending review. When D97160 was commited it wasn't updated
it merge cleanly, but didn't comprehend the check prefix changes.

3 years ago[lld-macho] check minimum header length when opening linkable input files
Greg McGary [Sat, 27 Feb 2021 07:28:52 +0000 (23:28 -0800)]
[lld-macho] check minimum header length when opening linkable input files

Bifurcate the `readFile()` API into ...
* `readRawFile()` which performs no checks, and
* `readLinkableFile()` which enforces minimum length of 20 bytes, same as ld64

There are no new tests because tweaks to existing tests are sufficient.

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

3 years ago[clang-format] Fix AlignConsecutiveDeclarations handling of pointers
Darwin Xu [Sat, 27 Feb 2021 21:40:57 +0000 (22:40 +0100)]
[clang-format] Fix AlignConsecutiveDeclarations handling of pointers

This is a bug fix of https://bugs.llvm.org/show_bug.cgi?id=49175

The expected code format:

unsigned int*       a;
int*                b;
unsigned int Const* c;

The actual code after formatting (without this patch):

unsigned int* a;
int*          b;
unsigned int Const* c;

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

3 years ago[lld-macho] Implement options -rename_section -rename_segment
Greg McGary [Fri, 26 Feb 2021 23:36:49 +0000 (15:36 -0800)]
[lld-macho] Implement options -rename_section -rename_segment

Implement command-line options to rename output sections & segments.

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

3 years agoRevert "[clang-itdy] Simplify virtual near-miss check"
Stephen Kelly [Sat, 27 Feb 2021 19:30:38 +0000 (19:30 +0000)]
Revert "[clang-itdy] Simplify virtual near-miss check"

This reverts commit 9a4b574dd6a07d6811356529ebb8a3f15d6e40a2.

3 years agoFix Block::eraseArguments: keep track the first removed element while removing
Mehdi Amini [Sat, 27 Feb 2021 19:18:09 +0000 (19:18 +0000)]
Fix Block::eraseArguments: keep track the first removed element while removing

Not only this is likely more efficient than BitVector::find_first(), but
also if the BitVector is empty find_first() returns -1, which
llvm::drop_begin isn't robust against.

3 years agoFix Block::eraseArguments to properly update the cached positions
Mehdi Amini [Sat, 27 Feb 2021 19:04:12 +0000 (19:04 +0000)]
Fix Block::eraseArguments to properly update the cached positions

This is fixing correctness and ASAN failure post-ee90bb3486948.

3 years agoChange the error message when `-split-input-file` is used with mlir-opt to make it...
Mehdi Amini [Sat, 27 Feb 2021 18:32:21 +0000 (18:32 +0000)]
Change the error message when `-split-input-file` is used with mlir-opt to make it recognizable by IDEs

By adding the line number of the split point immediately after the file
name (separated by `:`) this is recognized by various tool as a proper
location.

Ideally we would want to point to the line of the error, but that would
require some very invasive changes I suspect.

Reviewed By: jpienaar

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

3 years ago[NFC][AMDGPU] Document the AMDGPU target feature defaults
Tony Tye [Sat, 27 Feb 2021 00:39:29 +0000 (00:39 +0000)]
[NFC][AMDGPU] Document the AMDGPU target feature defaults

Document the default for the XNACK and SRAMECC target features for code object V2-V3 and V4.

Reviewed By: kzhuravl

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

3 years ago[mlir] Improve test coverage for print-op-graph
Jacques Pienaar [Sat, 27 Feb 2021 18:18:38 +0000 (10:18 -0800)]
[mlir] Improve test coverage for print-op-graph

3 years ago[IR] Use range-based for loops (NFC)
Kazu Hirata [Sat, 27 Feb 2021 18:09:25 +0000 (10:09 -0800)]
[IR] Use range-based for loops (NFC)

3 years ago[llvm] Fix typos in documentation (NFC)
Kazu Hirata [Sat, 27 Feb 2021 18:09:23 +0000 (10:09 -0800)]
[llvm] Fix typos in documentation (NFC)

3 years ago[llvm-readobj] Use ListSeparator (NFC)
Kazu Hirata [Sat, 27 Feb 2021 18:09:21 +0000 (10:09 -0800)]
[llvm-readobj] Use ListSeparator (NFC)

3 years ago[lld-macho] Extract embedded addends for arm64 UNSIGNED relocations
Jez Ng [Sat, 27 Feb 2021 17:30:19 +0000 (12:30 -0500)]
[lld-macho] Extract embedded addends for arm64 UNSIGNED relocations

On arm64, UNSIGNED relocs are the only ones that use embedded addends
instead of the ADDEND relocation.

Also ensure that the addend works when UNSIGNED is part of a SUBTRACTOR
pair.

Reviewed By: #lld-macho, alexshap

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

3 years ago[lld-macho] Add test for a variety of arm64 relocations
Jez Ng [Sat, 27 Feb 2021 17:30:17 +0000 (12:30 -0500)]
[lld-macho] Add test for a variety of arm64 relocations

Reviewed By: #lld-macho, smeenai

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

3 years ago[lld-macho] Don't emit rebase opcodes for subtractor minuend relocs
Jez Ng [Sat, 27 Feb 2021 17:30:16 +0000 (12:30 -0500)]
[lld-macho] Don't emit rebase opcodes for subtractor minuend relocs

Also add a few asserts to verify that we are indeed handling an
UNSIGNED relocation as the minued. I haven't made it an actual
user-facing error since I don't think llvm-mc is capable of generating
SUBTRACTOR relocations without an associated UNSIGNED.

Reviewed By: #lld-macho, smeenai

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

3 years ago[lld-macho] Properly test subtractor relocations & fix their attributes
Jez Ng [Sat, 27 Feb 2021 17:30:15 +0000 (12:30 -0500)]
[lld-macho] Properly test subtractor relocations & fix their attributes

`llvm-mc` doesn't generate any relocations for subtractions
between local symbols -- they must be global -- so the previous test
wasn't actually testing any relocation logic. I've fixed that and
extended the test to cover r_length=3 relocations as well as both x86_64
and arm64.

Reviewed By: #lld-macho, smeenai

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

3 years agoStore (cache) the Argument number (index in the argument list) inside the BlockArgume...
Mehdi Amini [Sat, 27 Feb 2021 17:20:28 +0000 (17:20 +0000)]
Store (cache) the Argument number (index in the argument list) inside the BlockArgumentImpl

This avoids linear search in BlockArgument::getArgNumber().

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

3 years ago[clang][Lifetimes] Fix false positive warning from BUG 49342
Gabor Horvath [Sat, 27 Feb 2021 16:08:24 +0000 (08:08 -0800)]
[clang][Lifetimes] Fix false positive warning from BUG 49342

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

3 years ago[SimplifyCFG] avoid illegal phi with both poison and undef
Sanjay Patel [Sat, 27 Feb 2021 14:09:03 +0000 (09:09 -0500)]
[SimplifyCFG] avoid illegal phi with both poison and undef

In the example based on:
https://llvm.org/PR49218
...we are crashing because poison is a subclass of undef, so we merge blocks and create:

PHI node has multiple entries for the same basic block with different incoming values!
  %k3 = phi i64 [ poison, %entry ], [ %k3, %g ], [ undef, %entry ]

If both poison and undef values are incoming, we soften the poison values to undef.

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

3 years ago[X86] Disable rematerializion for PTILELOADDV
Wang, Pengfei [Sat, 27 Feb 2021 13:03:53 +0000 (21:03 +0800)]
[X86] Disable rematerializion for PTILELOADDV

Per the discussion in D97453. We currently disable it due to it's not a
common scenario and has some problem in implementation.

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

3 years ago[clang-tidy] Simplify suspicious memset usage check
Stephen Kelly [Tue, 29 Dec 2020 23:24:49 +0000 (23:24 +0000)]
[clang-tidy] Simplify suspicious memset usage check

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

3 years ago[clang-tidy] Simplify boolean expr check
Stephen Kelly [Tue, 29 Dec 2020 23:31:09 +0000 (23:31 +0000)]
[clang-tidy] Simplify boolean expr check

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

3 years ago[clang-tidy] Simplify special member functions check
Stephen Kelly [Tue, 29 Dec 2020 23:29:46 +0000 (23:29 +0000)]
[clang-tidy] Simplify special member functions check

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

3 years ago[clang-tidy] Simplify redundant branch condition check
Stephen Kelly [Tue, 29 Dec 2020 23:28:28 +0000 (23:28 +0000)]
[clang-tidy] Simplify redundant branch condition check

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

3 years ago[clang-tidy] Simplify suspicious enum usage check
Stephen Kelly [Tue, 29 Dec 2020 23:24:38 +0000 (23:24 +0000)]
[clang-tidy] Simplify suspicious enum usage check

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

3 years ago[clang-tidy] Simplify redundant member init check
Stephen Kelly [Tue, 29 Dec 2020 15:50:19 +0000 (15:50 +0000)]
[clang-tidy] Simplify redundant member init check

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

3 years ago[clang-tidy] Simplify default member init check
Stephen Kelly [Tue, 29 Dec 2020 13:43:34 +0000 (13:43 +0000)]
[clang-tidy] Simplify default member init check

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

3 years ago[clang-tidy] Simplify shrink to fit check
Stephen Kelly [Tue, 29 Dec 2020 13:43:06 +0000 (13:43 +0000)]
[clang-tidy] Simplify shrink to fit check

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

3 years ago[clang-tidy] Handle uninstantiated templates in redundant get check
Stephen Kelly [Tue, 29 Dec 2020 13:44:35 +0000 (13:44 +0000)]
[clang-tidy] Handle uninstantiated templates in redundant get check

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

3 years ago[llvm] Add assertions for the smart pointers with the possibility to be null in DWARF...
Ella Ma [Fri, 26 Feb 2021 18:42:23 +0000 (21:42 +0300)]
[llvm] Add assertions for the smart pointers with the possibility to be null in DWARFLinker::loadClangModule

Split from D91844.

The local variable `Unit` in function `DWARFLinker::loadClangModule`
in file `llvm/lib/DWARFLinker/DWARFLinker.cpp`. If the variable is not set
in the loop below its definition, it will trigger a null pointer dereference
after the loop.

Patch By: OikawaKirie

Reviewed By: avl

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

3 years ago[Transforms/Utils] Use range-based for loops (NFC)
Kazu Hirata [Sat, 27 Feb 2021 06:36:40 +0000 (22:36 -0800)]
[Transforms/Utils] Use range-based for loops (NFC)

3 years ago[TableGen] Use ListSeparator (NFC)
Kazu Hirata [Sat, 27 Feb 2021 06:36:38 +0000 (22:36 -0800)]
[TableGen] Use ListSeparator (NFC)

3 years ago[NFC] Remove tab from the source
Vitaly Buka [Sat, 27 Feb 2021 03:40:10 +0000 (19:40 -0800)]
[NFC] Remove tab from the source

3 years ago[test] Add -triple x86_64 to attr-retain.cpp
Fangrui Song [Sat, 27 Feb 2021 03:35:53 +0000 (19:35 -0800)]
[test] Add -triple x86_64 to attr-retain.cpp

3 years ago[flang][fir] Upstream utility function valueHasFirAttribute()
Eric Schweitz [Thu, 25 Feb 2021 22:16:23 +0000 (14:16 -0800)]
[flang][fir] Upstream utility function valueHasFirAttribute()

This function will be used in subsequent upstreaming merges.

Author: Jean Perier

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

3 years ago[mlir] Simplify various pieces of code now that Identifier has access to the Context...
River Riddle [Sat, 27 Feb 2021 01:57:03 +0000 (17:57 -0800)]
[mlir] Simplify various pieces of code now that Identifier has access to the Context/Dialect

This also exposed a bug in Dialect loading where it was not correctly identifying identifiers that had the dialect namespace as a prefix.

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

3 years ago[MLIR][TOSA] Resubmit Tosa to Standard/SCF Lowerings (const, if, while)"
Rob Suderman [Fri, 26 Feb 2021 02:08:29 +0000 (18:08 -0800)]
[MLIR][TOSA] Resubmit Tosa to Standard/SCF Lowerings (const, if, while)"

Includes a lowering for tosa.const, tosa.if, and tosa.while to Standard/SCF dialects. TosaToStandard is
used for constant lowerings and TosaToSCF handles the if/while ops.

Resubmission of https://reviews.llvm.org/D97518 with ASAN fixes.

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

3 years ago[clang][NFC] Clean up whitespace in ClangOpcodesEmitter output
Jessica Clarke [Sat, 27 Feb 2021 01:26:26 +0000 (01:26 +0000)]
[clang][NFC] Clean up whitespace in ClangOpcodesEmitter output

This should now be about as style-conforming as TableGen'ed code ever
can reasonably be.

3 years ago[test] Add -triple x86_64 to attr-retain.c
Fangrui Song [Sat, 27 Feb 2021 01:26:26 +0000 (17:26 -0800)]
[test] Add -triple x86_64 to attr-retain.c

3 years ago[flang][fir] Add remaining Ops. Updates to pre-existing Ops.
Eric Schweitz [Thu, 25 Feb 2021 22:01:45 +0000 (14:01 -0800)]
[flang][fir] Add remaining Ops. Updates to pre-existing Ops.

  - add ops: rebox, insert_on_range, absent, is_present
  - embox, coordinate_of: replace old hand-written parser/pretty-printer with assembly format
  - remove dead floating point ops, since buitlins work for all types
  - update call op
  - update documentation
  - misc. NFC to formatting
  - add op round trip tests

Authors: Eric Schweitz, Jean Perier, Zachary Selk, Kiran Chandramohan, et.al.

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

3 years ago[WebAssembly] Fix reverse mapping in WasmEHFuncInfo
Heejin Ahn [Fri, 26 Feb 2021 20:23:24 +0000 (12:23 -0800)]
[WebAssembly] Fix reverse mapping in WasmEHFuncInfo

D97247 added the reverse mapping from unwind destination to their
source, but it had a critical bug; sources can be multiple, because
multiple BBs can have a single BB as their unwind destination.

This changes `WasmEHFuncInfo::getUnwindSrc` to `getUnwindSrcs` and makes
it return a vector rather than a single BB. It does not return the const
reference to the existing vector but creates a new vector because
`WasmEHFuncInfo` stores not `BasicBlock*` or `MachineBasicBlock*` but
`PointerUnion` of them. Also I hoped to unify those methods for
`BasicBlock` and `MachineBasicBlock` into one using templates to reduce
duplication, but failed because various usages require `BasicBlock*` to
be `const` but it's hard to make it `const` for `MachineBasicBlock`
usages.

Fixes https://github.com/emscripten-core/emscripten/issues/13514.
(More precisely, fixes
https://github.com/emscripten-core/emscripten/issues/13514#issuecomment-784708744)

Reviewed By: dschuff, tlively

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

3 years ago[lld][WebAssembly] Rename methods/members to match ELF backend. NFC.
Sam Clegg [Fri, 26 Feb 2021 23:22:23 +0000 (15:22 -0800)]
[lld][WebAssembly] Rename methods/members to match ELF backend. NFC.

Specifically:

- InputChunk::outputOffset -> outSecOffset
- Symbol::get/setVirtualAddress -> get/setVA
- add InputChunk::getOffset helper that takes an offset

These are mostly in preparation for adding support for
SHF_MERGE/SHF_STRINGS but its also good to align with ELF where
possible.

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

3 years ago[Polly] Refactoring IsInnermostParallel() in ISL to take the C++ wrapper object. NFC
Kevin Zhou [Fri, 26 Feb 2021 23:12:32 +0000 (17:12 -0600)]
[Polly] Refactoring IsInnermostParallel() in ISL to take the C++ wrapper object. NFC

Currently, the IslAst library is a C library that would be incompatible with the rest of the LLVM because LLVM is written in C++.
I took one function, IsInnermostParallel(), and refactored it so that it would take the C++ wrapper object instead of using reference counters with the C ISL library. As well, all the references that use IsInnermostParallel() will use manage_copy() since they are still expecting the C object.

Reviewed By: Meinersbur

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

3 years agoELF: Create unique SHF_GNU_RETAIN sections for llvm.used global objects
Fangrui Song [Sat, 27 Feb 2021 00:38:44 +0000 (16:38 -0800)]
ELF: Create unique SHF_GNU_RETAIN sections for llvm.used global objects

If a global object is listed in `@llvm.used`, place it in a unique section with
the `SHF_GNU_RETAIN` flag. The section is a GC root under `ld --gc-sections`
with LLD>=13 or GNU ld>=2.36.

For front ends which do not expect to see multiple sections of the same name,
consider emitting `@llvm.compiler.used` instead of `@llvm.used`.

SHF_GNU_RETAIN is restricted to ELFOSABI_GNU and ELFOSABI_FREEBSD in
binutils. We don't do the restriction - see the rationale in D95749.

The integrated assembler has supported SHF_GNU_RETAIN since D95730.
GNU as>=2.36 supports section flag 'R'.
We don't need to worry about GNU ld support because older GNU ld just ignores
the unknown SHF_GNU_RETAIN.

With this change, `__attribute__((retain))` functions/variables emitted
by clang will get the SHF_GNU_RETAIN flag.

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

3 years agoAdd GNU attribute 'retain'
Fangrui Song [Fri, 26 Feb 2021 19:59:53 +0000 (11:59 -0800)]
Add GNU attribute 'retain'

For ELF targets, GCC 11 will set SHF_GNU_RETAIN on the section of a
`__attribute__((retain))` function/variable to prevent linker garbage
collection. (See AttrDocs.td for the linker support).

This patch adds `retain` functions/variables to the `llvm.used` list, which has
the desired linker GC semantics. Note: `retain` does not imply `used`,
so an unused function/variable can be dropped by Sema.

Before 'retain' was introduced, previous ELF solutions require inline asm or
linker tricks, e.g.  `asm volatile(".reloc 0, R_X86_64_NONE, target");`
(architecture dependent) or define a non-local symbol in the section and use
`ld -u`. There was no elegant source-level solution.

With D97448, `__attribute__((retain))` will set `SHF_GNU_RETAIN` on ELF targets.

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

3 years ago[Driver] Fix a warning about the the initialization order
Kazu Hirata [Sat, 27 Feb 2021 00:32:30 +0000 (16:32 -0800)]
[Driver] Fix a warning about the the initialization order