platform/upstream/llvm.git
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

3 years ago[msan] Use non-transparent-huge-page at SetShadow
Jianzhou Zhao [Fri, 26 Feb 2021 23:34:02 +0000 (23:34 +0000)]
[msan] Use non-transparent-huge-page at SetShadow

This prevents from getting THP ranges more and more.

Did not see any issues in practice, just found this by code review.

Reviewed By: eugenis, vitalybuka

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

3 years ago[AArch64][GlobalISel] Import FMOV patterns rather than manually selecting it
Jessica Paquette [Thu, 25 Feb 2021 23:12:00 +0000 (15:12 -0800)]
[AArch64][GlobalISel] Import FMOV patterns rather than manually selecting it

There are existing patterns for FMOVHi, FMOVSi, and FMOVDi in
AArch64InstrFormats.td.

Importing these allows us to remove the manual selection code for FMOV.

It also allows us to select FMOVHi for non-zero constants when we have full
fp-16 support.

Refactor some of the code in AArch64InstrFormats.td so that we can create
equivalent custom renderers in GlobalISel.

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

3 years ago[test] Fix PGOProfile/comdat_internal.ll
Fangrui Song [Sat, 27 Feb 2021 00:27:23 +0000 (16:27 -0800)]
[test] Fix PGOProfile/comdat_internal.ll

3 years ago[mlir] Add regions to OpAdaptor
Jacques Pienaar [Sat, 27 Feb 2021 00:25:00 +0000 (16:25 -0800)]
[mlir] Add regions to OpAdaptor

Allows querying regions too via OpAdaptor's generated. This does not yet move region verification to adaptor nor require regions for ops where needed.

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

3 years agoReland "[builtins] Define fmax and scalbn inline"
Ryan Prichard [Thu, 25 Feb 2021 23:43:12 +0000 (15:43 -0800)]
Reland "[builtins] Define fmax and scalbn inline"

This reverts commit 680f836c2fa72166badd594a52b3f41b2ad074d2.

Disable the non-default-rounding-mode scalbn[f] tests when we're using
the MSVC libraries.

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

3 years ago[Driver] Print process statistics report on CC_PRINT_PROC_STAT env variable.
Vladimir Vereschaka [Sat, 27 Feb 2021 00:12:40 +0000 (16:12 -0800)]
[Driver] Print process statistics report on CC_PRINT_PROC_STAT env variable.

Added supporting CC_PRINT_PROC_STAT and CC_PRINT_PROC_STAT_FILE
environment variables to trigger clang driver reporting the process
statistics into specified file (alternate for -fproc-stat-report
option).

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

3 years ago[InstrProfiling] Use llvm.compiler.used instead of llvm.used for ELF
Fangrui Song [Sat, 27 Feb 2021 00:14:03 +0000 (16:14 -0800)]
[InstrProfiling] Use llvm.compiler.used instead of llvm.used for ELF

Many optimizers (e.g.  GlobalOpt/ConstantMerge) do not respect linker semantics
for comdat and may not discard the sections as a unit.

The interconnected `__llvm_prf_{cnts,data}` sections (in comdat for ELF)
are similar to D97432: `__profd_` is not directly referenced, so
`__profd_` may be discarded while `__profc_` is retained, breaking the
interconnection.  We currently conservatively add all such sections to
`llvm.used` and let the linker do GC for ELF.

In D97448, we will change GlobalObject's in the llvm.used list to use SHF_GNU_RETAIN,
causing the metadata sections to be unnecessarily retained (some `check-profile` tests check for GC).
Use `llvm.compiler.used` to retain the current GC behavior.

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

3 years ago[flang][fir][NFC] Removes deprecated messages in builds.
Eric Schweitz [Sat, 27 Feb 2021 00:12:49 +0000 (16:12 -0800)]
[flang][fir][NFC] Removes deprecated messages in builds.

3 years ago[clang] implicitly delete space ship operator with function pointers
Matheus Izvekov [Fri, 26 Feb 2021 23:19:15 +0000 (15:19 -0800)]
[clang] implicitly delete space ship operator with function pointers

See bug #48856

Definitions of classes with member function pointers and default
spaceship operator were getting accepted with no diagnostic on
release build, and triggering assert on builds with runtime checks
enabled. Diagnostics were only produced when actually comparing
instances of such classes.

This patch makes it so Spaceship and Less operators are not considered
as builtin operator candidates for function pointers, producing
equivalent diagnostics for the cases where pointers to member function
and pointers to data members are used instead.

Reviewed By: rsmith

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

3 years ago[MLIR][TOSA] Lower tosa.identity and tosa.identitiyn to linalg
Rob Suderman [Fri, 26 Feb 2021 01:46:23 +0000 (17:46 -0800)]
[MLIR][TOSA] Lower tosa.identity and tosa.identitiyn to linalg

Both identity ops can be loweried by replacing their results with their
inputs. We keep this as a linalg lowering as other backends may choose to
create copies.

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

3 years ago[docs] Add documentation on using the new pass manager
Arthur Eubanks [Fri, 26 Feb 2021 01:21:35 +0000 (17:21 -0800)]
[docs] Add documentation on using the new pass manager

And clarify in the "writing a pass" docs that both the legacy and new
PMs are being used for the codegen/optimization pipelines.

Reviewed By: ychen, asbirlea

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

3 years agoAMDGPU: Use kill instruction to hint soft clause live ranges
Matt Arsenault [Fri, 12 Feb 2021 22:47:30 +0000 (17:47 -0500)]
AMDGPU: Use kill instruction to hint soft clause live ranges

Previously we would use a bundle to hint the register allocator to not
overwrite the pointers in a sequence of loads to avoid breaking soft
clauses. This bundling was based on a fuzzy register pressure
heuristic, so we could not guarantee using more registers than are
really available. This would result in register allocator failing on
unsatisfiable bundles. Use a kill to artificially extend the live
ranges, so we can always succeed at register allocation even if it
means extra spills in the worst case.

This seems to capture most of the benefit of the bundle while avoiding
most of the risk presented by the bundle. However the lit tests do
show a handful of regressions. In some cases with sequences of
volatile loads, unused load components end up getting reallocated to
the next load which forces a wait between. There are also a few small
scheduling regressions where a hazard used to be avoided, and one
spill torture test which for some reason nearly doubles the stack
usage. There is also a bit of noise from leftover kills (it may make
sense for post-RA pseudos to strip all of these out).

3 years ago[DAGCombiner] Optimize SMULO/UMULO if we can prove that overflow is impossible.
Craig Topper [Fri, 26 Feb 2021 22:50:01 +0000 (14:50 -0800)]
[DAGCombiner] Optimize SMULO/UMULO if we can prove that overflow is impossible.

Using ComputeNumSignBits or computeKnownBits we might be able
to determine that overflow is impossible.

This especially helps after type legalization if the type was
promoted from a type with half the bits or more. Type legalization
conservatively creates a promoted smulo/umulo and an overflow
check for the promoted bits. The overflow from the promoted
smulo/umulo is ORed with the result of the promoted bits
overflow check. Proving that the promoted smulo/umulo can never
overflow will leave us with just the promoted bits overflow check.

Reviewed By: RKSimon

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

3 years ago[flang] Detect circularly defined interfaces of procedures
Peter Steinfeld [Mon, 22 Feb 2021 16:59:15 +0000 (08:59 -0800)]
[flang] Detect circularly defined interfaces of procedures

It's possible to define a procedure whose interface depends on a procedure
which has an interface that depends on the original procedure.  Such a circular
definition was causing the compiler to fall into an infinite loop when
resolving the name of the second procedure.  It's also possible to create
circular dependency chains of more than two procedures.

I fixed this by adding the function HasCycle() to the class DeclarationVisitor
and calling it from DeclareProcEntity() to detect procedures with such
circularly defined interfaces.  I marked the associated symbols of such
procedures by calling SetError() on them.  When processing subsequent
procedures, I called HasError() before attempting to analyze their interfaces.
Unfortunately, this did not work.

With help from Tim, we determined that the SymbolSet used to track the
erroneous symbols was instantiated using a "<" operator which was
defined using the name of the procedure.  But the procedure name was
being changed by a call to ReplaceName() between the times that the
calls to SetError() and HasError() were made.  This caused HasError() to
incorrectly report that a symbol was not in the set of erroneous
symbols.  I fixed this by making SymbolSet be an ordered set, which does
not use the "<" operator.

I also added tests that will crash the compiler without this change.
And I fixed the formatting on an error message from a previous update.

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

3 years ago[dfsan] Record dfsan metadata in globals
George Balatsouras [Wed, 24 Feb 2021 19:42:30 +0000 (11:42 -0800)]
[dfsan] Record dfsan metadata in globals

This will allow identifying exactly how many shadow bytes were used
during compilation, for when fast8 mode is introduced.

Also, it will provide a consistent matching point for instrumentation
tests so that the exact llvm type used (i8 or i16) for the shadow can
be replaced by a pattern substitution. This is handy for tests with
multiple prefixes.

Reviewed by: stephan.yichao.zhao, morehouse

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

3 years ago[sanitizers][NFC] Change typesto avoid warnings
Vitaly Buka [Fri, 26 Feb 2021 22:32:01 +0000 (14:32 -0800)]
[sanitizers][NFC] Change typesto avoid warnings

Warning was enabled by D94640

3 years ago[NFC][libc++] Suppress "warning: ignoring return value"
Vitaly Buka [Fri, 26 Feb 2021 22:29:06 +0000 (14:29 -0800)]
[NFC][libc++] Suppress "warning: ignoring return value"

According to the comment on the next line
it's expected behaviour.

3 years ago[NFC] Suppress "warning: ignoring return value"
Vitaly Buka [Fri, 26 Feb 2021 22:27:24 +0000 (14:27 -0800)]
[NFC] Suppress "warning: ignoring return value"

3 years ago[mlir][vector] add higher dimensional support to gather/scatter
Aart Bik [Fri, 26 Feb 2021 02:04:39 +0000 (18:04 -0800)]
[mlir][vector] add higher dimensional support to gather/scatter

Similar to mask-load/store and compress/expand, the gather and
scatter operation now allow for higher dimension uses. Note that
to support the mixed-type index, the new syntax is:
   vector.gather %base [%i,%j] [%kvector] ....
The first client of this generalization is the sparse compiler,
which needs to define scatter and gathers on dense operands
of higher dimensions too.

Reviewed By: bixia

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

3 years ago[WebAssembly] Avoid `bit_cast` when printing f32 and f64 immediates
Dan Gohman [Fri, 26 Feb 2021 22:17:51 +0000 (14:17 -0800)]
[WebAssembly] Avoid `bit_cast` when printing f32 and f64 immediates

Use `APInt` to convert a 32-bit or 64-bit immediate to an `APFloat` rather than
`bit_cast` to a `float` or `double` to avoid going through host floating-point and
potentially changing the bit pattern of NaNs.

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

3 years ago[lld/mac] Add some support for dynamic lookup symbols, and implement -U
Nico Weber [Fri, 26 Feb 2021 00:56:31 +0000 (19:56 -0500)]
[lld/mac] Add some support for dynamic lookup symbols, and implement -U

Dynamic lookup symbols are symbols that work like dynamic symbols
in ELF: They're not bound to a dylib like normal Mach-O twolevel lookup
symbols, but they live in a global pool and dyld resolves them against
exported symbols from all loaded dylibs.

This adds support for dynamical lookup symbols to lld/mac. They are
represented as DylibSymbols with file set to nullptr.

This also uses this support to implement the -U flag, which makes
a specific symbol that's undefined at the end of the link a
dynamic lookup symbol.

For -U, it'd be sufficient to just to a pass over remaining undefined symbols
at the end of the link and to replace them with dynamic lookup symbols then.
But I'd like to use this code to implement flat_namespace too, and that will
require real support for resolving dynamic lookup symbols in SymbolTable. So
this patch adds this now already.

While writing tests for this, I noticed that we didn't set N_WEAK_DEF in the
symbol table for DylibSymbols, so this fixes that too.

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

3 years ago[libcxx][test] Don't require Container<cv T> extension on non-libc++
Casey Carter [Fri, 26 Feb 2021 21:39:22 +0000 (13:39 -0800)]
[libcxx][test] Don't require Container<cv T> extension on non-libc++

... when testing `default_initializable`. Also, include `<memory>` for `unique_ptr`.