platform/upstream/llvm.git
3 years ago[Flang] Changes to mangling code
Eric Schweitz [Mon, 5 Apr 2021 16:09:10 +0000 (17:09 +0100)]
[Flang] Changes to mangling code

Call static functions using the class name (fir::NameUniquer).
Add function for mangling derivedTypes.

All the name mangling functions that are ultimately called are
tested in unittests/Optimizer/InternalNamesTest.cpp.

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

3 years ago[InstCombine] Regenerate 2010-11-23-Distributed.ll tests
Simon Pilgrim [Fri, 9 Apr 2021 15:38:57 +0000 (16:38 +0100)]
[InstCombine] Regenerate 2010-11-23-Distributed.ll tests

3 years ago[clang] tests: cleanup, update and add some new ones
Matheus Izvekov [Tue, 23 Mar 2021 20:20:07 +0000 (21:20 +0100)]
[clang] tests: cleanup, update and add some new ones

This reworks a small set of tests, as preparatory work for implementing
P2266.
* Run for more standard versions, including c++2b.
* Normalize file names and run commands.
* Adds some extra tests.

New Coroutine tests taken from Aaron Puchert's D68845.

Signed-off-by: Matheus Izvekov <mizvekov@gmail.com>
Reviewed By: thakis

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

3 years ago[X86] Fold cmpeq/ne(or(X,Y),X) --> cmpeq/ne(and(~X,Y),0) on non-BMI targets (PR44136)
Simon Pilgrim [Fri, 9 Apr 2021 15:10:57 +0000 (16:10 +0100)]
[X86] Fold cmpeq/ne(or(X,Y),X) --> cmpeq/ne(and(~X,Y),0) on non-BMI targets (PR44136)

Followup to D100177, enable the fold for non-BMI targets as well.

3 years ago[RGT] Tweak test so assertion is always executed
Paul Robinson [Fri, 9 Apr 2021 15:03:44 +0000 (08:03 -0700)]
[RGT] Tweak test so assertion is always executed

Any given Windows system will have only one "system" encoding for
UTF-16 (BE or LE), so the assert for the other one would always
show up as rotten.  Use a common assertion for both paths to avoid
this.

3 years ago[MLIR][Shape] Combine `cstr_eq` only if they share shape operands
Frederik Gossen [Fri, 9 Apr 2021 14:51:34 +0000 (16:51 +0200)]
[MLIR][Shape] Combine `cstr_eq` only if they share shape operands

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

3 years ago[X86][BMI] Fold cmpeq/ne(or(X,Y),X) --> cmpeq/ne(and(~X,Y),0) (PR44136)
Simon Pilgrim [Fri, 9 Apr 2021 14:51:53 +0000 (15:51 +0100)]
[X86][BMI] Fold cmpeq/ne(or(X,Y),X) --> cmpeq/ne(and(~X,Y),0) (PR44136)

I've initially just enabled this for BMI which has the ANDN instruction for i32/i64 - the i16/i8 cases give an idea of what'd we get when we enable it in all cases (I'll do this as a later commit).

Additionally, the i16/i8 cases could be freely promoted to i32 (as the args are already zeroext) and we could then make use of ANDN + the free cmp0 there as well - this has come up in PR48768 and PR49028 so I'm going to look at this soon.

https://alive2.llvm.org/ce/z/QVWHP_
https://alive2.llvm.org/ce/z/pLngT-

Vector cases do not appear to benefit from this as we end up with having to generate the zero vector as well - this is one of the reasons I didn't try to tie this into hasAndNot/hasAndNotCompare.

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

3 years ago[libc++] Fix abs and div overload issue for compilers on AIX
jasonliu [Thu, 8 Apr 2021 21:48:42 +0000 (21:48 +0000)]
[libc++] Fix abs and div overload issue for compilers on AIX

Summary:
AIX system's stdlib.h provide different overload of abs and div
depending on compiler versions.

For example, std::div(long, long) and std::abs(long) are not available
from OS's stdlib.h when building with clang, but they are available
when building with xlclang compiler.

Therefore, we need to provide those extra overloads in libc++'s stdlib.h
when OS's stdlib.h does not.

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

3 years ago[HIP] Workaround ICE compiling SemaChecking.cpp with gcc 5
Yaxun (Sam) Liu [Fri, 9 Apr 2021 14:39:23 +0000 (10:39 -0400)]
[HIP] Workaround ICE compiling SemaChecking.cpp with gcc 5

Change-Id: I6c6213bc6b90365bfb78636ce7fb0700a58807cf

3 years ago[InstCombine] try to eliminate an instruction in min/max -> abs fold
Sanjay Patel [Fri, 9 Apr 2021 13:58:16 +0000 (09:58 -0400)]
[InstCombine] try to eliminate an instruction in min/max -> abs fold

As suggested in the review thread for 5094e12 and seen in the
motivating example from https://llvm.org/PR49885, it's not
clear if we have a way to create the optimal code without
this heuristic.

3 years ago[InstCombine] add test with multiple uses of min/max negated operand; NFC
Sanjay Patel [Fri, 9 Apr 2021 13:47:00 +0000 (09:47 -0400)]
[InstCombine] add test with multiple uses of min/max negated operand; NFC

3 years agoRISCVABIInfo::classifyArgumentType: Fix static analyzer warnings with uninitialized...
Soumi Manna [Fri, 9 Apr 2021 14:23:32 +0000 (15:23 +0100)]
RISCVABIInfo::classifyArgumentType: Fix static analyzer warnings with uninitialized variables warnings - NFCI

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

3 years ago[X86] Add zeroext attributes to i8/i16 and/or/xor overflow tests
Simon Pilgrim [Fri, 9 Apr 2021 14:00:56 +0000 (15:00 +0100)]
[X86] Add zeroext attributes to i8/i16 and/or/xor overflow tests

Matches original c/c++ test cases

3 years ago[clangd] Log a message when gRPC support is off, but remote-index is configured
Kadir Cetinkaya [Thu, 8 Apr 2021 13:37:32 +0000 (15:37 +0200)]
[clangd] Log a message when gRPC support is off, but remote-index is configured

Before this change clangd would emit a diagnostic whenever remote-index
was configured but binary didn't have grpc support.

This can be annoying when projects are configuring remote-index through their
configs but developers have a clangd binary without the support.

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

3 years ago[TableGen] [docs] Change title of tblgen.rst to fix man page filename
Paul C. Anagnostopoulos [Fri, 9 Apr 2021 13:35:52 +0000 (09:35 -0400)]
[TableGen] [docs] Change title of tblgen.rst to fix man page filename

3 years ago[AMDGPU] Allow relaxed/consume memory order for atomic inc/dec
Yaxun (Sam) Liu [Thu, 8 Apr 2021 21:44:29 +0000 (17:44 -0400)]
[AMDGPU] Allow relaxed/consume memory order for atomic inc/dec

Reviewed by: Jon Chesterfield

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

3 years agoFor non-null pointer checks, do not descend through out-of-bounds GEPs
Momchil Velikov [Fri, 9 Apr 2021 12:54:39 +0000 (13:54 +0100)]
For non-null pointer checks, do not descend through out-of-bounds GEPs

In LazyValueInfoImpl::isNonNullAtEndOfBlock we populate a set of
pointers, known to be non-null at the end of a block (e.g. because we
did a load through them). We then infer that any pointer, based on an
element of this set is non-null as well ("based" here meaning a
non-null pointer is the underlying object). This is incorrect, even if
the base pointer was non-null, the value of a GEP, that lacks the
inbounds` attribute, may be null.

This issue appeared as miscompilation of the following test case:

int puts(const char *);

typedef struct iter {
  int *val;
} iter_t;

static long distance(iter_t first, iter_t last) {
  long r = 0;
  for (; first.val != last.val; first.val++)
    ++r;
  return r;
}

int main() {
  int arr[2] = {0};
  iter_t i, j;
  i.val = arr;
  j.val = arr + 1;
  if (distance(i, j) >= 2)
    puts("failed");
  else
    puts("passed");
}

This fixes PR49662.

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

3 years ago[AMDGPU] SIFoldOperands: eagerly delete dead copies
Jay Foad [Thu, 8 Apr 2021 15:07:49 +0000 (16:07 +0100)]
[AMDGPU] SIFoldOperands: eagerly delete dead copies

This is cheap to implement, means less work for future passes like
MachineDCE, and slightly improves the folding in some cases.

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

3 years ago[X86] Adjust PR44136 tests to add cmpne coverage as well
Simon Pilgrim [Fri, 9 Apr 2021 12:42:18 +0000 (13:42 +0100)]
[X86] Adjust PR44136 tests to add cmpne coverage as well

Alive2: https://alive2.llvm.org/ce/z/pLngT-

3 years ago[clang] Tiny format fix
Nathan Sidwell [Thu, 8 Apr 2021 17:17:14 +0000 (10:17 -0700)]
[clang] Tiny format fix

Misindented close brace.

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

3 years ago[PowerPC, test] Fix use of undef FileCheck var
Thomas Preud'homme [Mon, 5 Apr 2021 10:28:35 +0000 (11:28 +0100)]
[PowerPC, test] Fix use of undef FileCheck var

LLVM test CodeGen/PowerPC/ctrloops-softfloat.ll tries to check for the
absence of sequences of instructions with several CHECK-NOT with one of
those directives using a variable defined in another. However CHECK-NOT
are checked independently so that is using a variable defined in a
pattern that should not occur in the input.

This commit changes occurence of the variable for the regex used in its
definition, thereby making each CHECK-NOT independent.

Reviewed By: nemanjai

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

3 years ago[PowerPC, test] Fix use of undef FileCheck var
Thomas Preud'homme [Sun, 4 Apr 2021 23:07:35 +0000 (00:07 +0100)]
[PowerPC, test] Fix use of undef FileCheck var

Commit 6ad3d05b681b36f6ecc98523257d154053e4116d disables the definition
of CSR that a follow-up CHECK-NOT directive depends on. This commit
replaces the undefined CSR variable use by the regex used to define it.

Reviewed By: nemanjai

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

3 years ago[clangd] Add --check-lines to restrict --check to specific lines
Adam Czachorowski [Thu, 18 Mar 2021 20:14:02 +0000 (21:14 +0100)]
[clangd] Add --check-lines to restrict --check to specific lines

This will allow us to add code completion, which is too expensive at
every token, to --check too.

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

3 years ago[PowerPC, test] Fix use of undef FileCheck var
Thomas Preud'homme [Sun, 4 Apr 2021 22:58:18 +0000 (23:58 +0100)]
[PowerPC, test] Fix use of undef FileCheck var

Commit 6646033e6e759657b6122fde64844fd28a2c9635 removed the definition
of variable RESULT used in two CHECK-NOT directives in LLVM test
CodeGen/PowerPC/ppc64-i128-abi.ll. This commit replaces the uses by the
regex that was used to define that variable.

Reviewed By: nemanjai

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

3 years ago[OpenCL] Simplify InsertOCLBuiltinDeclarationsFromTable
Sven van Haastregt [Fri, 9 Apr 2021 10:54:15 +0000 (11:54 +0100)]
[OpenCL] Simplify InsertOCLBuiltinDeclarationsFromTable

 - Use a range-based for loop.  This will help a later patch to skip
   prototypes that use an unavailable return type or argument type.

 - Replace a dyn_cast with a cast, as we are only dealing with
   FunctionProtoType Types here.

3 years ago[X86] Add PR44136 test coverage
Simon Pilgrim [Fri, 9 Apr 2021 10:31:29 +0000 (11:31 +0100)]
[X86] Add PR44136 test coverage

3 years ago[AMDGPU] Use SIInstrFlags for flat variants. NFC
Sebastian Neubauer [Tue, 30 Mar 2021 12:38:07 +0000 (14:38 +0200)]
[AMDGPU] Use SIInstrFlags for flat variants. NFC

Use SIInstrFlags to differentiate between the different
variants of flat instructions (flat, global and scratch).
This should make it easier to bundle the immediate offset logic in a
single place and implement restrictions and bug workarounds.

Fixed version of D99587, which does not rely on the address space.

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

3 years ago[AA][NFC] Convert AliasResult to class containing offset for PartialAlias case.
dfukalov [Tue, 16 Mar 2021 13:36:17 +0000 (16:36 +0300)]
[AA][NFC] Convert AliasResult to class containing offset for PartialAlias case.

Add an ability to store `Offset` between partially aliased location. Use this
storage within returned `ResultAlias` instead of caching it in `AAQueryInfo`.

Reviewed By: asbirlea

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

3 years ago[MLIR][Shape] Add convenience builder for `shape.assuming_all`
Frederik Gossen [Fri, 9 Apr 2021 10:13:10 +0000 (12:13 +0200)]
[MLIR][Shape] Add convenience builder for `shape.assuming_all`

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

3 years ago[NFC][AA] Prepare to convert AliasResult to class with PartialAlias offset.
dfukalov [Fri, 5 Mar 2021 10:58:13 +0000 (13:58 +0300)]
[NFC][AA] Prepare to convert AliasResult to class with PartialAlias offset.

Main reason is preparation to transform AliasResult to class that contains
offset for PartialAlias case.

Reviewed By: asbirlea

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

3 years ago[X86] combineHorizOpWithShuffle - peek through one use bitcasts when decoding shuffles.
Simon Pilgrim [Thu, 8 Apr 2021 13:49:31 +0000 (14:49 +0100)]
[X86] combineHorizOpWithShuffle - peek through one use bitcasts when decoding shuffles.

Checking for one use, peek through bitcasts of the horizop args to allows us to merge shuffles of different widths through the horizop.

3 years ago[MLIR][Shape] Canonicalize `assuming_all` when all operands are `cstr_eq` ops
Frederik Gossen [Fri, 9 Apr 2021 09:00:01 +0000 (11:00 +0200)]
[MLIR][Shape] Canonicalize `assuming_all` when all operands are `cstr_eq` ops

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

3 years ago[FunctionAttrs] Force old pm in test so it doens't behave differently depending on...
Benjamin Kramer [Fri, 9 Apr 2021 09:46:19 +0000 (11:46 +0200)]
[FunctionAttrs] Force old pm in test so it doens't behave differently depending on the configuration setting for this flag

3 years ago[NFC] Move statictic increment out of helper
Max Kazantsev [Fri, 9 Apr 2021 09:32:01 +0000 (16:32 +0700)]
[NFC] Move statictic increment out of helper

3 years ago[RegisterScavenging] Add asserts for better errors
Sebastian Neubauer [Thu, 8 Apr 2021 14:27:46 +0000 (16:27 +0200)]
[RegisterScavenging] Add asserts for better errors

These cases were failing before, but with cryptic asserts.
Add asserts in the RegScavenger that fail earlier with better
messages. NFC

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

3 years ago[AMDGPU] IsFlatScratch/Global -> FlatScratch/Global
Sebastian Neubauer [Fri, 9 Apr 2021 09:20:15 +0000 (11:20 +0200)]
[AMDGPU] IsFlatScratch/Global -> FlatScratch/Global

Remove 'Is' from IsFlatScratch/Global. NFC

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

3 years ago[GVN][NFC] Factor out load elimination logic via PRE for reuse
Max Kazantsev [Fri, 9 Apr 2021 08:22:47 +0000 (15:22 +0700)]
[GVN][NFC] Factor out load elimination logic via PRE for reuse

3 years ago[MLIR] Do not yield values from an assuming op that are never used
Frederik Gossen [Thu, 8 Apr 2021 09:21:50 +0000 (11:21 +0200)]
[MLIR] Do not yield values from an assuming op that are never used

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

3 years ago[RISCV][NFC] Replace explicit type i64 with riscv customized SDTypeProfile.
Jim Lin [Fri, 9 Apr 2021 09:01:48 +0000 (17:01 +0800)]
[RISCV][NFC] Replace explicit type i64 with riscv customized SDTypeProfile.

New SDTypeProfile can be reused for other word operation patterns without explicit i64 type in the future.

Reviewed By: craig.topper

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

3 years ago[test, LoopVectorize] Fix use of var defined in CHECK-NOT
Thomas Preud'homme [Sun, 28 Mar 2021 00:03:37 +0000 (00:03 +0000)]
[test, LoopVectorize] Fix use of var defined in CHECK-NOT

LLVM test Transforms/LoopVectorize/pr34681.ll tries to check for the
absence of a sequence of instructions with several CHECK-NOT with one of
those directives using a variable defined in another. However CHECK-NOT
are checked independently so that is using a variable defined in a
pattern that should not occur in the input.

This commit only checks for the absence of icmp ne 1 which rules out the
presence of the whole sequence and does not involve an undefined
variable.

Reviewed By: fhahn

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

3 years ago[lldb] Update object.test after 'nosync' inference was enabled.
Alexander Belyaev [Fri, 9 Apr 2021 08:02:24 +0000 (10:02 +0200)]
[lldb] Update object.test after 'nosync' inference was enabled.

https://reviews.llvm.org/D99769

3 years ago[lldb] Update UUID after https://reviews.llvm.org/D99978.
Alexander Belyaev [Fri, 9 Apr 2021 08:01:50 +0000 (10:01 +0200)]
[lldb] Update UUID after https://reviews.llvm.org/D99978.

3 years ago[NFC][PowerPC] add test cases for reverse memory op transformation
Chen Zheng [Fri, 9 Apr 2021 07:21:24 +0000 (03:21 -0400)]
[NFC][PowerPC] add test cases for reverse memory op transformation

3 years ago[RISCV][NFC] Fix formatting
Jim Lin [Fri, 9 Apr 2021 05:20:07 +0000 (13:20 +0800)]
[RISCV][NFC] Fix formatting

3 years ago[Test] Add two more tests on PRE with guards
Max Kazantsev [Fri, 9 Apr 2021 06:19:52 +0000 (13:19 +0700)]
[Test] Add two more tests on PRE with guards

3 years ago[GreedyRA ORE] Re-factor computeNumberOfSplillsReloads.
Serguei Katkov [Fri, 9 Apr 2021 04:29:35 +0000 (11:29 +0700)]
[GreedyRA ORE] Re-factor computeNumberOfSplillsReloads.

Replace if-else to if-continue usage.
This simplifies further extension of the collected stats.

3 years ago[mlir][Linalg] Drop unit-trip loops of reductions only if other reduction loops exists.
MaheshRavishankar [Fri, 9 Apr 2021 05:30:49 +0000 (22:30 -0700)]
[mlir][Linalg] Drop unit-trip loops of reductions only if other reduction loops exists.

Recent change enable dropping unit-trip loops of "reduction" iterator
type as well. This is fine as long as there is one other "reduction"
iterator in the operation. Without this the initialized value (value
of `out`) is not read which leads to a correctness issue.

Also fix a bug in the `fill` -> `tensor_reshape` folding. The `out`
operand of the `fill` needs to be reshaped to get the `out` operand of
the generated `fill` operation.

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

3 years ago[libcxx] Allow shared_ptr's unique_ptr converting constructor to support array types.
zoecarver [Fri, 9 Apr 2021 05:01:35 +0000 (22:01 -0700)]
[libcxx] Allow shared_ptr's unique_ptr converting constructor to support array types.

Refs: https://bugs.llvm.org/show_bug.cgi?id=32147

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

3 years ago[LICM] Hoist loads with invariant.group metadata
Arthur Eubanks [Fri, 2 Apr 2021 03:22:29 +0000 (20:22 -0700)]
[LICM] Hoist loads with invariant.group metadata

Previously loading the vtable used in calling a virtual method in a loop
was not hoisted out of the loop. This fixes that.

canSinkOrHoistInst() itself doesn't check that the load operands are
loop invariant, callers also check that separately.

Reviewed By: rnk

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

3 years ago[debug-info][NFC] Set -mtriple to avoid the test failure under other targets.
Esme-Yi [Fri, 9 Apr 2021 04:53:59 +0000 (04:53 +0000)]
[debug-info][NFC] Set -mtriple to avoid the test failure under other targets.

3 years ago[RS4GC] Cleanup meetBDVState. NFC.
Serguei Katkov [Fri, 9 Apr 2021 03:20:25 +0000 (10:20 +0700)]
[RS4GC] Cleanup meetBDVState. NFC.

meetBDVState looks pretty difficult to read and follow.
This is purely NFC but doing several things:

1) Combine meet and meetBDVState
2) Move the function to be a member of BDVState
3) Make BDVState be a mutable object
4) Convert switch to sequence of ifs
5) Adds comments.

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

3 years ago[clang][SourceManager] Fix -Wparentheses warning (NFC)
Yang Fan [Fri, 9 Apr 2021 02:22:56 +0000 (10:22 +0800)]
[clang][SourceManager] Fix -Wparentheses warning (NFC)

GCC warning:
```
/llvm-project/clang/lib/Basic/SourceManager.cpp: In instantiation of ‘constexpr T likelyhasbetween(T, unsigned char, unsigned char) [with T = long unsigned int]’:
/llvm-project/clang/lib/Basic/SourceManager.cpp:1292:52:   required from here
/llvm-project/clang/lib/Basic/SourceManager.cpp:1264:48: warning: suggest parentheses around ‘+’ in operand of ‘&’ [-Wparentheses]
 1264 |           (x & ~static_cast<T>(0) / 255 * 127) +
      |           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
 1265 |               (~static_cast<T>(0) / 255 * (127 - (m - 1)))) &
      |               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```

3 years ago[RISCV][NFC] Add explicit type i64 to RV64 only patterns.
Jim Lin [Fri, 9 Apr 2021 01:36:33 +0000 (09:36 +0800)]
[RISCV][NFC] Add explicit type i64 to RV64 only patterns.

Add explicit type i64 to RV64 only patterns to stop emitting unneeded i32 patterns.

It can reduce the isel table size.

Reviewed By: craig.topper

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

3 years ago[lld] Fixed CodeView GuidAdapter::format to handle GUID bytes in the right order.
Alex Orlov [Fri, 9 Apr 2021 01:29:14 +0000 (05:29 +0400)]
[lld] Fixed CodeView GuidAdapter::format to handle GUID bytes in the right order.

This fixes https://bugs.llvm.org/show_bug.cgi?id=41712 bug.

Reviewed By: aganea

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

3 years ago[mlir][tosa] Add tosa.max_pool2d lowering to linalg int max pooling additions
Rob Suderman [Thu, 1 Apr 2021 23:39:25 +0000 (16:39 -0700)]
[mlir][tosa] Add tosa.max_pool2d lowering to linalg int max pooling additions

Lowerings tosa.max_pool2d to linalg equivalent operations. Includes
adding max pooling operations for linalg, with corresponding tests.

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

3 years agoADT: Sink the guts of StringMapEntry::Create into StringMapEntryBase
Duncan P. N. Exon Smith [Thu, 28 Jan 2021 23:43:04 +0000 (15:43 -0800)]
ADT: Sink the guts of StringMapEntry::Create into StringMapEntryBase

Sink the interesting parts of StringMapEntry::Create into a new function
StringMapEntryBase::allocateWithKey that's only templated on the
allocator, taking the entry size and alignment as parameters.

As dblaikie pointed out in the review, it'd be interesting as a
follow-up to make this more generic and maybe sink at least some of it
into a source file; I haven't done that yet myself, but I left behind an
encouraging comment.

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

3 years agoDebugInfo: Include inline namespaces in template specialization parameter names
David Blaikie [Fri, 9 Apr 2021 00:36:41 +0000 (17:36 -0700)]
DebugInfo: Include inline namespaces in template specialization parameter names

This ensures these types have distinct names if they are distinct types
(eg: if one is an instantiation with a type in one inline namespace, and
another from a type with the same simple name, but in a different inline
namespace).

3 years agoUse default ref capture to avoid unused capture warning on assert-used variable
David Blaikie [Thu, 8 Apr 2021 23:56:27 +0000 (16:56 -0700)]
Use default ref capture to avoid unused capture warning on assert-used variable

3 years ago[mlir][spirv] Define spv.ImageDrefGather operation
Weiwei Li [Thu, 8 Apr 2021 23:22:25 +0000 (19:22 -0400)]
[mlir][spirv] Define spv.ImageDrefGather operation

This patch doesn't support the optional operands of ImageDrefGather. The support of optional operands will be implemented later.

co-authered-by: Alan Liu <alanliu.yf@gmail.com>

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

3 years agoSupport: Use std::unique_ptr for SignpostEmitter::Impl, NFC, 3rd attempt
Duncan P. N. Exon Smith [Fri, 9 Apr 2021 00:00:43 +0000 (17:00 -0700)]
Support: Use std::unique_ptr for SignpostEmitter::Impl, NFC, 3rd attempt

This reverts commit e35afbe535f96086141f57a5ce7d679429b4405f, reapplying
022ccedde8877e877b45e49641544b5e4fff0b42 and
e7ed5c920db3f537a85d962c1c918a1bb6de99fd.

- The first attempt missed defining `SignpostEmitterImpl`.
- The second attempt missed defining `llvm::SignpostEmitterImpl`.

Not sure how I failed to test both versions locally before; I thought
I'd turned the feature off via rerunning `cmake` but it must have been
stuck in place. This time I confirmed via `clang -E` that I was testing
both build configurations.

Original commit message:

    Replace some manual memory management with std::unique_ptr.

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

3 years agoRevert "Revert "Revert "Support: Use std::unique_ptr for SignpostEmitter::Impl, NFC"""
Duncan P. N. Exon Smith [Thu, 8 Apr 2021 23:58:12 +0000 (16:58 -0700)]
Revert "Revert "Revert "Support: Use std::unique_ptr for SignpostEmitter::Impl, NFC"""

This reverts commit e7ed5c920db3f537a85d962c1c918a1bb6de99fd again, due
to more buildbot failures:
https://lab.llvm.org/buildbot/#/builders/131/builds/8191

3 years agoRevert "Revert "Support: Use std::unique_ptr for SignpostEmitter::Impl, NFC""
Duncan P. N. Exon Smith [Thu, 8 Apr 2021 23:41:40 +0000 (16:41 -0700)]
Revert "Revert "Support: Use std::unique_ptr for SignpostEmitter::Impl, NFC""

This reverts commit 078072285d3fbdaa94f9a91140eb5c1223b548af, reapplying
022ccedde8877e877b45e49641544b5e4fff0b42.

I figured out why this was failing in other environments: it's not a
problem with std::unique_ptr, but that SignpostEmitterImpl only has a
forward declaration. Adding an empty definition should do the trick.

Original commit message:

    Replace some manual memory management with std::unique_ptr.

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

3 years agoRevert "Support: Use std::unique_ptr for SignpostEmitter::Impl, NFC"
Duncan P. N. Exon Smith [Thu, 8 Apr 2021 23:36:42 +0000 (16:36 -0700)]
Revert "Support: Use std::unique_ptr for SignpostEmitter::Impl, NFC"

This reverts commit 022ccedde8877e877b45e49641544b5e4fff0b42. Looks like
some hosts need a definition of SignpostEmitterImpl to put it in a
unique_ptr:
https://lab.llvm.org/buildbot/#/builders/92/builds/7733

3 years agoSupport: Avoid unnecessary std::function for SignpostEmitterImpl::SignpostLog
Duncan P. N. Exon Smith [Thu, 8 Apr 2021 23:20:31 +0000 (16:20 -0700)]
Support: Avoid unnecessary std::function for SignpostEmitterImpl::SignpostLog

The destructor for SignPostEmitterImpl::SignpostLog is known statically. Avoid
the unnecessary vtable indirection through std::function in the std::unique_ptr
by turning LogDeleter into a struct. No real functionality change here.

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

3 years agoSupport: Drop the no-op initializer for SignpostEmitterImpl::Signposts, NFC
Duncan P. N. Exon Smith [Thu, 8 Apr 2021 23:14:16 +0000 (16:14 -0700)]
Support: Drop the no-op initializer for SignpostEmitterImpl::Signposts, NFC

This is a DenseMap, which has its own initializer; we don't need to explicitly
call the default constructor here.

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

3 years agoSupport: Use std::unique_ptr for SignpostEmitter::Impl, NFC
Duncan P. N. Exon Smith [Thu, 8 Apr 2021 23:04:55 +0000 (16:04 -0700)]
Support: Use std::unique_ptr for SignpostEmitter::Impl, NFC

Replace some manual memory management with std::unique_ptr.

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

3 years agoSupport: Extract fs::resize_file_before_mapping_readwrite from FileOutputBuffer
Duncan P. N. Exon Smith [Wed, 27 Jan 2021 00:01:36 +0000 (16:01 -0800)]
Support: Extract fs::resize_file_before_mapping_readwrite from FileOutputBuffer

Add a variant of `fs::resize_file` for use immediately before opening a
file with `mapped_file_region::readwrite`. On Windows, `_chsize`
(`ftruncate`) is slow, but `CreateFileMapping` (`mmap`) automatically
extends the file so the call to `fs::resize_file` can be skipped.

This optimization was added to `FileOutputBuffer` in
da9bc2e56d5a5c6332a9def1a0065eb399182b93; this commit just extracts the
logic out and adds a unit test.

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

3 years agoImprove error message when tring to export to LLVM IR with a dialect missing the...
Mehdi Amini [Thu, 8 Apr 2021 22:15:39 +0000 (22:15 +0000)]
Improve error message when tring to export to LLVM IR with a dialect missing the interface

Dialects can be translated to LLVM IR when they have the
LLVMTranslationDialectInterface interface registered. In case the
interface isn't explicitly registered, even the LLVM dialect can't be
exported to LLVM IR. This make the error message more explicit on this.

Reviewed By: ftynse

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

3 years ago[ASTMatchers] Add `cxxBaseSpecifier` matcher (non-top-level)
Nikita Kniazev [Thu, 8 Apr 2021 22:55:22 +0000 (23:55 +0100)]
[ASTMatchers] Add `cxxBaseSpecifier` matcher (non-top-level)

Required for capturing base specifier in matchers:
  `cxxRecordDecl(hasDirectBase(cxxBaseSpecifier().bind("base")))`

Reviewed By: steveire, aaron.ballman

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

3 years ago[compiler-rt][hwasan] Add C++17 new/delete operators with alignment
Leonard Chan [Thu, 25 Mar 2021 19:32:21 +0000 (12:32 -0700)]
[compiler-rt][hwasan] Add C++17 new/delete operators with alignment

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

3 years ago[RISCV] Use multiclass inheritance where possible for the VPat* multiclasses in RISVI...
Craig Topper [Thu, 8 Apr 2021 22:02:57 +0000 (15:02 -0700)]
[RISCV] Use multiclass inheritance where possible for the VPat* multiclasses in RISVInstrInfoVPseudos. NFCI

Instead of instantiating multiclasses inside multiclasses, just
inherit from them.

We can do the same for the VPseudo* multiclasses, but that may
interfere with the scheduler class work.

3 years ago[RISCV] Remove empty string after 'defm' at top level of vector .td files. NFC
Craig Topper [Thu, 8 Apr 2021 21:47:41 +0000 (14:47 -0700)]
[RISCV] Remove empty string after 'defm' at top level of vector .td files. NFC

This doesn't do anything so it's just wasted characters. I have
other plans for the ones in multiclasses.

3 years ago[lldb] (Temporarily) disable vfork-follow-parent-wp.test on Darwin
Jonas Devlieghere [Thu, 8 Apr 2021 22:05:26 +0000 (15:05 -0700)]
[lldb] (Temporarily) disable vfork-follow-parent-wp.test on Darwin

The test is failing on GreenDragon. Pinged Michał in D98822.

3 years ago[SLP]Fix PR49898: Infinite loop in SLP vectorizer.
Alexey Bataev [Thu, 8 Apr 2021 18:33:57 +0000 (11:33 -0700)]
[SLP]Fix PR49898: Infinite loop in SLP vectorizer.

We should not re-try attempt of finding of the consecutive store chain
if it was tried before.

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

3 years ago[funcattrs] Infer nosync from instruction walk
Philip Reames [Thu, 8 Apr 2021 21:02:39 +0000 (14:02 -0700)]
[funcattrs] Infer nosync from instruction walk

Pretty straightforward use of existing infrastructure and port of the attributor inference rules for nosync.

A couple points of interest:
* I deliberately switched from "monotonic or better" to "unordered or better". This is simply me being conservative and is better in line with the rest of the optimizer. We treat monotonic conservatively pretty much everywhere.
* The operand bundle test change is suspicious. It looks like we might have missed something here, but if so, it's an issue with the existing nofree inference as well. I'm going to take a closer look at that separately.
* I needed to keep the previous inference from readnone. This surprised me, but made sense once I realized readonly inference goes to lengths to reason about local vs non-local memory and that writes to local memory are okay. This is fine for the purpose of nosync, but would e.g. prevent us from inferring nofree from readnone - which is slightly surprising.

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

3 years ago[GVN] Properly invalidate ICF cache when we simplify a value
Arthur Eubanks [Thu, 8 Apr 2021 18:44:23 +0000 (11:44 -0700)]
[GVN] Properly invalidate ICF cache when we simplify a value

This fixes a "Cached first special instruction is wrong!" assert.

The assert fires because replacing a value with another can cause an
instruction to no longer be "special" to ICF. In this case,
devirtualization happened, turning an indirect call to a
call to a willreturn function which is no longer special.

Reviewed By: nikic, rnk

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

3 years agoInclude `count` in AppleClang toolchains.
Dan Liew [Thu, 8 Apr 2021 04:33:24 +0000 (21:33 -0700)]
Include `count` in AppleClang toolchains.

The motivation here is so we can run the compiler-rt tests
from a standalone build against AppleClang.

In particular the `Posix/halt_on_error-torture.cpp` and
`Posix/halt_on_error_suppress_equal_pcs.cpp` ASan test cases currently
require this binary for the tests to pass.

rdar://76366784

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

3 years ago[FileCheck, test] Rename checkWildcardRegexCharMatchFailure
Thomas Preud'homme [Wed, 10 Mar 2021 13:53:40 +0000 (13:53 +0000)]
[FileCheck, test] Rename checkWildcardRegexCharMatchFailure

Proposed edit https://reviews.llvm.org/D97845#inline-922769 in D97845
suggests the checkWildcardRegexCharMatchFailure function name is
misleading because it is not clear it checks for a match failure on each
character in the string parameter. This commit renames it to an
hopefully clearer name.

Reviewed By: jdenny

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

3 years agoAMDGPU: Add gfx90c support to code object v2 for backwards compatibility
Konstantin Zhuravlyov [Thu, 8 Apr 2021 20:42:05 +0000 (16:42 -0400)]
AMDGPU: Add gfx90c support to code object v2 for backwards compatibility

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

3 years ago[AMDGPU] Check for all meta instrs in GCNRegBankReassign
Stanislav Mekhanoshin [Thu, 8 Apr 2021 20:24:46 +0000 (13:24 -0700)]
[AMDGPU] Check for all meta instrs in GCNRegBankReassign

It used to work correctly even with a KILL, but there is
no reason to consider meta instructions since they do not
create real HW uses.

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

3 years agoAdd setting to disable LanguageRuntime UnwindPlans
Jason Molenda [Thu, 8 Apr 2021 20:28:59 +0000 (13:28 -0700)]
Add setting to disable LanguageRuntime UnwindPlans

When debugging LanguageRuntime unwindplans, it can be
helpful to disable their use and see the normal
stack walk.  Add a setting for this.

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

3 years ago[LoopRotate] Don't split loop pass manager
Nikita Popov [Sat, 3 Apr 2021 13:57:58 +0000 (15:57 +0200)]
[LoopRotate] Don't split loop pass manager

After D99249 we use three different loop pass managers for LICM,
LoopRotate and LICM+LoopUnswitch. This happens because LazyBFI
and LazyBPI are not preserved by LoopRotate (note that D74640
is no longer needed). Avoid this by marking them as preserved.

My understanding of D86156 is that it is okay to simply preserve
them (which LoopUnswitch already does for the same reason) and
rely on callbacks to deal with deleted blocks.

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

3 years ago[AMDGPU] Allow -amdgpu-unsafe-fp-atomics to ignore denorm mode
Stanislav Mekhanoshin [Wed, 7 Apr 2021 22:22:48 +0000 (15:22 -0700)]
[AMDGPU] Allow -amdgpu-unsafe-fp-atomics to ignore denorm mode

Fixes: SWDEV-274276

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

3 years ago[AIX] Support init priority attribute
Xiangling Liao [Thu, 8 Apr 2021 17:40:27 +0000 (13:40 -0400)]
[AIX] Support init priority attribute

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

3 years ago[flang][OpenMP] Add functionality to check "close nesting" of regions, which can...
Arnamoy Bhattacharyya [Thu, 8 Apr 2021 18:33:04 +0000 (14:33 -0400)]
[flang][OpenMP] Add functionality to check "close nesting" of regions, which can be used for Semantic checks.  Also adding more test cases.

Reviewed By: kiranchandramohan

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

3 years ago[mlir][StandardToSPIRV] Handle i1 case for lowering memref.load/store op
Hanhan Wang [Thu, 8 Apr 2021 19:15:15 +0000 (12:15 -0700)]
[mlir][StandardToSPIRV] Handle i1 case for lowering memref.load/store op

This patch unconditionally converts i1 types to i8 types on memrefs. If the
extensions or capabilities are not met, they will be converted to i32. Hence the
logic in IntLoadPattern and IntStorePattern are also updated.

Also added the implementation of SPIRVTypeConverter::getOptions().

Reviewed By: antiagainst

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

3 years ago[WebAssembly] Fix for PIC external symbol ISEL
Wouter van Oortmerssen [Thu, 25 Mar 2021 23:04:10 +0000 (16:04 -0700)]
[WebAssembly] Fix for PIC external symbol ISEL

wasm64 was missing DAG ISEL patterns for external symbol based global.get, but simply adding these analogous to the existing 32-bit versions doesn't work.
This is because we are conflating the 32-bit global index with the pointer represented by the external symbol, which for wasm32 happened to work.
The simplest fix is to pretend we have a 64-bit global index. This sounds incorrect, but is immaterial since once this index is stored as a MachineOperand it becomes 64-bit anyway (and has been all along). As such, the EmitInstrWithCustomInserter based implementation I experimented with become a no-op and no further changes in the C++ code are required.

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

3 years ago[LoopInterchange] Fix transformation bugs in loop interchange
Congzhe Cao [Thu, 8 Apr 2021 18:53:09 +0000 (14:53 -0400)]
[LoopInterchange] Fix transformation bugs in loop interchange

After loop interchange, the (old) outer loop header should not jump to
the `LoopExit`. Note that the old outer loop becomes the new inner loop
after interchange. If we branched to `LoopExit` then after interchange
we would jump directly from the (new) inner loop header to `LoopExit`
without executing the rest of outer loop.

This patch modifies adjustLoopBranches() such that the old outer
loop header (which becomes the new inner loop header) jumps to the
old inner loop latch which becomes the new outer loop latch after
interchange.

Reviewed By: bmahjour

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

3 years ago[RISCV] Add InstAlias for Zbb Zbp and Zbs extension
Levy Hsu [Thu, 8 Apr 2021 18:40:49 +0000 (11:40 -0700)]
[RISCV] Add InstAlias for Zbb Zbp and Zbs extension

Add InstAlias that allows the last operand to be an imm for following instructions:

1. Zbb or Zbp:
    - ror
    - rorw (RV64 Only)

2. Zbs
    - best
    - bclr
    - binv
    - bext

Reviewed By: craig.topper, jrtc27

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

3 years ago[InstCombine] fold min/max intrinsic with negated operand to abs
Sanjay Patel [Thu, 8 Apr 2021 18:29:33 +0000 (14:29 -0400)]
[InstCombine] fold min/max intrinsic with negated operand to abs

The smax case shows up in https://llvm.org/PR49885 .
The others seem unlikely, but we might as well try
for uniformity (although that could mean an extra
instruction to create "nabs").

smax -- https://alive2.llvm.org/ce/z/8yYaGy
smin -- https://alive2.llvm.org/ce/z/0_7zc_
umax -- https://alive2.llvm.org/ce/z/EcsZWs
umin -- https://alive2.llvm.org/ce/z/Xw6WvB

3 years ago[InstCombine] add tests for min/max with negated operand; NFC
Sanjay Patel [Thu, 8 Apr 2021 17:47:48 +0000 (13:47 -0400)]
[InstCombine] add tests for min/max with negated operand; NFC

3 years ago[RISCV] Prevent __builtin_riscv_orc_b_64 from being compiled RV32 target.
Craig Topper [Thu, 8 Apr 2021 16:12:57 +0000 (09:12 -0700)]
[RISCV] Prevent __builtin_riscv_orc_b_64 from being compiled RV32 target.

The backend can't handle this and will throw a fatal error from
type legalization. It's easy enough to fix that for this intrinsic
by just splitting the IR intrinsic since it works on individual bytes.

There will be other intrinsics in the future that would be harder
to support through splitting, for example grev, gorc, and shfl. Those
would require a compare and a select be inserted to check the MSB of
their control input.

This patch adds support for preventing this in the frontend with
a nice diagnostic.

Reviewed By: frasercrmck

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

3 years agoSet IgnoreLLVMUsed to false in CallGraph::addToCallGraph()
Stanislav Mekhanoshin [Mon, 5 Apr 2021 20:01:44 +0000 (13:01 -0700)]
Set IgnoreLLVMUsed to false in CallGraph::addToCallGraph()

clang++ uses llvm.compiler.used in certain cases to preserve
symbol which is fully inlined. D96087 has resulted in undefined
symbols in such cases. Set it to false by default to preserve
old behavior but keep the option for specific uses where we
want to ignore these (e.g. to detect a potential indirect call
to a function).

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

3 years ago[lld-macho][nfc] Use varargs form of hasArg()
Jez Ng [Thu, 8 Apr 2021 18:11:45 +0000 (14:11 -0400)]
[lld-macho][nfc] Use varargs form of hasArg()

3 years ago[lld-macho] Support -add_ast_path
Jez Ng [Thu, 8 Apr 2021 18:12:20 +0000 (14:12 -0400)]
[lld-macho] Support -add_ast_path

Swift builds seem to use it. All it requires is emitting the
corresponding paths as STABS.

Fixes llvm.org/PR49385.

Reviewed By: clayborg

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

3 years ago[lldb] [test] Skip clone() tests on Linux/aarch64
Michał Górny [Thu, 8 Apr 2021 18:03:21 +0000 (20:03 +0200)]
[lldb] [test] Skip clone() tests on Linux/aarch64

3 years agoRevert "[TableGen] Add support for the 'assert' statement in multiclasses"
Paul C. Anagnostopoulos [Thu, 8 Apr 2021 17:55:16 +0000 (13:55 -0400)]
Revert "[TableGen] Add support for the 'assert' statement in multiclasses"

This reverts commit 3b9a15d910a8c748b1444333a4a3905a996528bc.

3 years ago[lldb] Improve the documentation (#42017)
Sushma Unnibhavi [Thu, 8 Apr 2021 17:55:55 +0000 (10:55 -0700)]
[lldb] Improve the documentation (#42017)

Added punctuation and changed "So for instance" to "For instance".

Fixes https://llvm.org/PR42017

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

3 years ago[mlir][linalg] Fix loop upper bounds in conv fusion test
Lei Zhang [Thu, 8 Apr 2021 17:40:35 +0000 (13:40 -0400)]
[mlir][linalg] Fix loop upper bounds in conv fusion test

Reviewed By: mravishankar

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

3 years ago[analyzer] Fix false positives in inner pointer checker (PR49628)
Valeriy Savchenko [Wed, 24 Mar 2021 13:15:04 +0000 (16:15 +0300)]
[analyzer] Fix false positives in inner pointer checker (PR49628)

This patch supports std::data and std::addressof functions.

rdar://73463300

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