platform/upstream/llvm.git
2 years ago[llvm] [Debuginfod] Remove `llvm-debuginfod-find` lit tests that used python http...
Noah Shutty [Tue, 30 Aug 2022 01:23:04 +0000 (01:23 +0000)]
[llvm] [Debuginfod] Remove `llvm-debuginfod-find` lit tests that used python http server.

These tests depend on `ThreadingHTTPServer` which was not introduced until python 3.7 so we might as well delete them to avoid issues. Most of their functionality is now covered by the llvm-debuginfod.test for the debuginfod server.

Reviewed By: mysterymath

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

2 years ago[test][msan] Don't ignore prefix of sanitizer_dtor_callback
Vitaly Buka [Tue, 30 Aug 2022 01:26:04 +0000 (18:26 -0700)]
[test][msan] Don't ignore prefix of sanitizer_dtor_callback

2 years ago[test][msan] Don't ignore the suffix if use-after-dtor callback
Vitaly Buka [Tue, 30 Aug 2022 01:07:06 +0000 (18:07 -0700)]
[test][msan] Don't ignore the suffix if use-after-dtor callback

2 years ago[libomptarget] Deprecate old method for setting the tripcount
Joseph Huber [Mon, 29 Aug 2022 20:38:20 +0000 (15:38 -0500)]
[libomptarget] Deprecate old method for setting the tripcount

Previously, the tripcount was set by a push call. We moved away from
this with the new interface that added the tripcount to the kernel
arguments struct, but kept around the old interface for legacy purposes
for the LLVM 15 release. This patch removes the support for the legacy
method.

This removes the support for the old method, but does not break
backwards compatibility. This will result in applications using the old
interface being slower when run on the device.

Reviewed By: jdoerfert

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

2 years ago[test][msan] Add more Debug Info use-after-dtor tests
Vitaly Buka [Tue, 30 Aug 2022 00:49:11 +0000 (17:49 -0700)]
[test][msan] Add more Debug Info use-after-dtor tests

2 years ago[test][msan] Remov unneeded CHECK-NOT
Vitaly Buka [Mon, 29 Aug 2022 15:08:42 +0000 (08:08 -0700)]
[test][msan] Remov unneeded CHECK-NOT

2 years ago[driver] Additional ignoring of module-map related flags, if modules are disabled
Argyrios Kyrtzidis [Sat, 27 Aug 2022 23:14:24 +0000 (16:14 -0700)]
[driver] Additional ignoring of module-map related flags, if modules are disabled

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

2 years ago[mlir][tosa] Add folder for tosa.cast
Rob Suderman [Tue, 30 Aug 2022 00:20:38 +0000 (17:20 -0700)]
[mlir][tosa] Add folder for tosa.cast

Tosa.cast should fold on splats as it is trivial to fold the operation
into the splatted value.

Reviewed By: NatashaKnk

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

2 years ago[mlir][tosa] Fold tosa.reshape with splat values
Rob Suderman [Tue, 30 Aug 2022 00:05:23 +0000 (17:05 -0700)]
[mlir][tosa] Fold tosa.reshape with splat values

Folding reshapes of splats is trivial and should be canonicalized
away.

Reviewed By: NatashaKnk

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

2 years agoApply clang-tidy fixes for readability-identifier-naming in BytecodeWriter.cpp (NFC)
Mehdi Amini [Mon, 29 Aug 2022 10:08:54 +0000 (10:08 +0000)]
Apply clang-tidy fixes for readability-identifier-naming in BytecodeWriter.cpp (NFC)

2 years agoApply clang-tidy fixes for modernize-use-emplace in BytecodeReader.cpp (NFC)
Mehdi Amini [Mon, 29 Aug 2022 10:08:17 +0000 (10:08 +0000)]
Apply clang-tidy fixes for modernize-use-emplace in BytecodeReader.cpp (NFC)

2 years ago[mlir][tosa] Added folders for tosa.div
Rob Suderman [Mon, 29 Aug 2022 23:46:48 +0000 (16:46 -0700)]
[mlir][tosa] Added folders for tosa.div

Added folders for tosa.sub that handles bypassing divide by one,
and a zero numerator.

Reviewed By: NatashaKnk

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

2 years agofix buildbot build error.
Rong Xu [Tue, 30 Aug 2022 00:01:27 +0000 (17:01 -0700)]
fix buildbot build error.

2 years ago[llvm-profdata] Improve profile supplementation
Rong Xu [Wed, 24 Aug 2022 18:54:06 +0000 (11:54 -0700)]
[llvm-profdata] Improve profile supplementation

Current implementation promotes a non-cold function in the SampleFDO profile
into a hot function in the FDO profile. This is too aggressive. This patch
promotes a hot functions in the SampleFDO profile into a hot function, and a
warm function in SampleFDO into a warm function in FDO.

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

2 years ago[mlir][tosa] Added folders for tosa.mul
Rob Suderman [Mon, 29 Aug 2022 23:24:27 +0000 (16:24 -0700)]
[mlir][tosa] Added folders for tosa.mul

Added folders for tosa.sub that handles bypassing sub-zero,
fold subtraction of two splat tensors.

Reviewed By: NatashaKnk

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

2 years ago[mlir][tosa] Added folders for tosa.sub
Rob Suderman [Mon, 29 Aug 2022 21:32:30 +0000 (14:32 -0700)]
[mlir][tosa] Added folders for tosa.sub

Added folders for tosa.sub that handles bypassing sub-zero,
fold subtraction of two splat tensors.

Reviewed By: NatashaKnk

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

2 years ago[llvm-profdata] Handle internal linkage functions in profile supplementation
Rong Xu [Wed, 24 Aug 2022 19:20:46 +0000 (12:20 -0700)]
[llvm-profdata] Handle internal linkage functions in profile supplementation

This patch has the following changes:
(1) Handling of internal linkage functions (static functions)
Static functions in FDO have a prefix of source file name, while they do not
have one in SampleFDO. Current implementation does not handle this and we are
not updating the profile for static functions. This patch fixes this.

(2) Handling of -funique-internal-linakge-symbols
Again this is for the internal linkage functions. Option
-funique-internal-linakge-symbols can now be applied to both FDO and SampleFDO
compilation. When it is used, it demangles internal linkage function names and
adds a hash value as the postfix.

When both SampleFDO and FDO profiles use this option, or both
not use this option, changes in (1) should handle this.

Here we also handle when the SampleFDO profile using this option while FDO
profile not using this option, or vice versa.

There is one case where this patch won't work: If one of the profiles used
mangled name and the other does not. For example, if the SampleFDO profile
uses clang c-compiler and without -funique-internal-linakge-symbols, while
the FDO profile uses -funique-internal-linakge-symbols. The SampleFDO profile
contains unmangled names while the FDO profile contains mangled names. If
both profiles use c++ compiler, this won't happen. We think this use case
is rare and does not justify the effort to fix.

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

2 years ago[mlir] Remove a not very useful `eraseArguments` overload
Jeff Niu [Mon, 29 Aug 2022 22:59:04 +0000 (15:59 -0700)]
[mlir] Remove a not very useful `eraseArguments` overload

This overload just wraps a bitvector, and in most cases a bitvector
could be used directly instead of a list.

Reviewed By: rriddle

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

2 years ago[RISCV] Enable (srl (and X, C2), C) to form SRLIW in more cases.
Craig Topper [Mon, 29 Aug 2022 22:45:30 +0000 (15:45 -0700)]
[RISCV] Enable (srl (and X, C2), C) to form SRLIW in more cases.

Don't require the AND has one use and don't depend on
targetShrinkDemandedConstant turning C2 into 0xffffffff. Instead,
check that the constant is 0xffffffff after replacing any bits
that will be shifted out with 1s.

Another way to fix this might be to prevent SimplifyDemandedBits
from destroying the ANDI after type legalization using
targetShrinkDemandedBits. That would prevent the CSE that created
this mess. targetShrinkDemandedBits is currently only enable after
legalize ops. Quick experiment shows we can't just change when it
runs, we would need to try a different heuristic for post type
legalization.

2 years ago[RISCV] Add test for failure to use ANDI and SRLIW due to SimplifyDemandedBits.
Craig Topper [Mon, 29 Aug 2022 22:39:25 +0000 (15:39 -0700)]
[RISCV] Add test for failure to use ANDI and SRLIW due to SimplifyDemandedBits.

2 years ago[mlir] Add `Block::eraseArguments` that erases a subrange
Jeff Niu [Mon, 29 Aug 2022 21:32:14 +0000 (14:32 -0700)]
[mlir] Add `Block::eraseArguments` that erases a subrange

This patch adds a an `eraseArguments` function that erases a subrange of
a block's arguments. This can be used inplace of the terrible pattern

```
block->eraseArguments(llvm::to_vector(llvm::seq(...)));
```

Reviewed By: rriddle

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

2 years ago[LV] Add debug output for force scalar tracing [nfc]
Philip Reames [Mon, 29 Aug 2022 22:16:47 +0000 (15:16 -0700)]
[LV] Add debug output for force scalar tracing [nfc]

I keep finding myself needing to rule this out as a possible source of scalarization, so add debug output like we have for other instructions we decide to scalarize.

2 years ago[Driver] Fix & re-enable DriverKit test
Julian Lettner [Mon, 29 Aug 2022 19:06:53 +0000 (12:06 -0700)]
[Driver] Fix & re-enable DriverKit test

This reverts commit ce6989fd8a9fb2608f670de023fdd4611f47b811.

2 years ago[ORC-RT] unit tests do not need access to LLVM headers.
Lang Hames [Mon, 29 Aug 2022 21:05:51 +0000 (14:05 -0700)]
[ORC-RT] unit tests do not need access to LLVM headers.

Also delete trailing whitespace in lib/orc/CMakeLists.txt

2 years ago[llvm-profdata] Adjust profile supplementation heuristics
Rong Xu [Wed, 24 Aug 2022 18:28:02 +0000 (11:28 -0700)]
[llvm-profdata] Adjust profile supplementation heuristics

1) We now use the count size in FDO as the main factor to deal with pre-inliner.
Currently we use the number of sample records in the SampleFDO profile. But
that only counts the top-level body sample records (not including the nested
call-sites). We are seeing some big functions not being updated because of
this. I think using the count size in FDO profile is more reasonable to judge if
the function is likely to be inlined to the callers in pre-inliner.

(2) We use getMaxCount in SampleFDO rather the HeadSample to determine if
if the function is hot in SampleFDO. This is in-sync with the logic
in the compiler (also HeadSample can be 0).

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

2 years ago[LV] Refresh autogen tests to reflect naming changes [nfc]
Philip Reames [Mon, 29 Aug 2022 21:04:30 +0000 (14:04 -0700)]
[LV] Refresh autogen tests to reflect naming changes [nfc]

Purely so that these can be easily autogened without spurious diffs

2 years ago[RISCV] Use hasAllWUsers to recover ANDI.
Craig Topper [Mon, 29 Aug 2022 20:29:16 +0000 (13:29 -0700)]
[RISCV] Use hasAllWUsers to recover ANDI.

SimplifyDemandedBits can 0 the upper bits and targetShrinkDemandedConstant
isn't alway able to recover it.

At least part of that may be because targetShrinkDemandedConstant
only runs in the last DAGCombine. Might be worth seeing what happens
if we move it post type legalization.

2 years ago[RISCV] Add test case for missed opportunity to use ANDI.
Craig Topper [Mon, 29 Aug 2022 20:12:38 +0000 (13:12 -0700)]
[RISCV] Add test case for missed opportunity to use ANDI.

Immediate was messed up by SimplfyDemandedBits.

2 years ago[SLP] Try to match reductions before trying to vectorize a vector build sequence.
Valery N Dmitriev [Thu, 25 Aug 2022 23:58:56 +0000 (16:58 -0700)]
[SLP] Try to match reductions before trying to vectorize a vector build sequence.

This patch changes order of searching for reductions vs other vectorization possibilities.
The idea is if we do not match a reduction it won't be harmful for further attempts to
find vectorizable operations on a vector build sequences. But doing it in the opposite
order we have good chance to ruin opportunity to match a reduction later.
We also don't want to try vectorizing binary operations too early as 2-way vectorization
may effectively prohibit wider ones leading to producing less effective code.

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

2 years ago[mlir][tosa] Added folders for tosa.greater
Rob Suderman [Mon, 29 Aug 2022 19:03:25 +0000 (12:03 -0700)]
[mlir][tosa] Added folders for tosa.greater

Added folders for tosa.greater fold splat values.

Reviewed By: NatashaKnk

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

2 years ago[mlir][math] Set llvm readnone attribute for libm functions.
Slava Zakharin [Tue, 2 Aug 2022 23:26:55 +0000 (16:26 -0700)]
[mlir][math] Set llvm readnone attribute for libm functions.

Math dialect operations currently do not limit transformations
applied to them, which means that they potentially behave like
clang's -ffast-math mathematics. Clang marks math functions with
readnone attribute enabling more optimizations.

This change does the same for functions used by MathToLibm convertor.
In particular, this enables LLVM LICM for tan() call in
Polyhedron/mp_prop_design_11 compiled with flang.

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

2 years ago[libomptarget] Always enable time tracing in libomptarget
Joseph Huber [Mon, 29 Aug 2022 14:43:45 +0000 (09:43 -0500)]
[libomptarget] Always enable time tracing in libomptarget

Previously time tracing features were hidden behind an optional CMake
option. This was because `libomptarget` was not based on the LLVM
libraries at that time. Now that `libomptarget` is an LLVM library we
should be able to freely use the `LLVMSupport` library whenever we want
and do not need to guard it in this way.

Reviewed By: jdoerfert

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

2 years ago[LV] Minor code restructure of isUniformAfterVectorization [nfc]
Philip Reames [Mon, 29 Aug 2022 19:47:56 +0000 (12:47 -0700)]
[LV] Minor code restructure of isUniformAfterVectorization [nfc]

Mostly just to make a future patch easier to review.

2 years agoMark compiler-rt/test/profile/instrprof-merging.cpp unsupported on Windows
Hans Wennborg [Mon, 29 Aug 2022 19:35:49 +0000 (21:35 +0200)]
Mark compiler-rt/test/profile/instrprof-merging.cpp unsupported on Windows

It is not reliable. See #57430.

2 years ago[RISCV] Add more invertible setccs to tryDemorganOfBooleanCondition.
Craig Topper [Mon, 29 Aug 2022 19:23:03 +0000 (12:23 -0700)]
[RISCV] Add more invertible setccs to tryDemorganOfBooleanCondition.

This builds on D132771 to invert (setlt 0, X) to (setlt X, 1) and
vice versa.

Reviewed By: reames

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

2 years ago[RISCV] Pre-commit tests for D132798. NFC
Craig Topper [Mon, 29 Aug 2022 19:20:36 +0000 (12:20 -0700)]
[RISCV] Pre-commit tests for D132798. NFC

2 years ago[RISCV] Apply DeMorgan to (beqz (and/or (seteq), (xor Z, 1))) to remove the xor.
Craig Topper [Mon, 29 Aug 2022 19:03:17 +0000 (12:03 -0700)]
[RISCV] Apply DeMorgan to (beqz (and/or (seteq), (xor Z, 1))) to remove the xor.

We can rewrite to (bnez (or/and (setne), Z) is Z is 0/1.

Alternatively, we could canonicalize to (xor (or/and (setne), Z), 1)
even if there is no branch. The xor would not always get removed,
but it might enable other DeMorgan combines. I decided to be
conservative for this first patch and require the xor to be removed.

I have a couple other invertible setccs I will add in a follow up
patch.

Reviewed By: reames

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

2 years ago[PS4][driver] make -fjmc work with LTO driver linking stage
Yuanfang Chen [Mon, 29 Aug 2022 17:52:00 +0000 (10:52 -0700)]
[PS4][driver] make -fjmc work with LTO driver linking stage

Reviewed By: probinson

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

2 years ago[Clang] Implement function attribute nouwtable
Yuanfang Chen [Wed, 24 Aug 2022 19:24:54 +0000 (12:24 -0700)]
[Clang] Implement function attribute nouwtable

To have finer control of IR uwtable attribute generation. For target code generation,
IR nounwind and uwtable may have some interaction. However, for frontend, there are
no semantic interactions so the this new `nouwtable` is marked "SimpleHandler = 1".

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

2 years agoRevert "[Driver] Fix & re-enable DriverKit test"
Julian Lettner [Mon, 29 Aug 2022 18:57:57 +0000 (11:57 -0700)]
Revert "[Driver] Fix & re-enable DriverKit test"

This reverts commit 2d66571729a2ffcd88398a77508b0d6432ed7ba0 due to
test failure:

http://45.33.8.238/win/65224/step_7.txt

2 years ago[MLIR] Fix autogenerated pass constructors linkage
Michele Scuttari [Mon, 29 Aug 2022 08:57:58 +0000 (10:57 +0200)]
[MLIR] Fix autogenerated pass constructors linkage

The patch addresses the linkage of the new autogenerated pass constructors, which, being declared as friend functions, resulted in having an inline nature and thus their implementations not being exported.

Reviewd By: mehdi_amini, rriddle

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

2 years ago[RLEV] Pick a correct insert point when incoming instruction is itself a phi node
Philip Reames [Mon, 29 Aug 2022 18:37:42 +0000 (11:37 -0700)]
[RLEV] Pick a correct insert point when incoming instruction is itself a phi node

This fixes https://github.com/llvm/llvm-project/issues/57336. It was exposed by a recent SCEV change, but appears to have been a long standing issue.

Note that the whole insert into the loop instead of a split exit edge is slightly contrived to begin with; it's there solely because IndVarSimplify preserves the CFG.

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

2 years agoRevert "[runtimes] Use a response file for runtimes test suites"
Arthur Eubanks [Mon, 29 Aug 2022 18:25:29 +0000 (11:25 -0700)]
Revert "[runtimes] Use a response file for runtimes test suites"

This reverts commit 992e10a3fce41255e4b11782f51d0f4b26dca14d.

Breaks builds with LLVM_INCLUDE_TESTS=OFF, see comments in D132438.

2 years ago[clang-tidy] Fixing a bug in `InfiniteLoopCheck` that raises false alarms on finite...
ziqingluo-90 [Fri, 26 Aug 2022 20:51:10 +0000 (13:51 -0700)]
[clang-tidy] Fixing a bug in `InfiniteLoopCheck` that raises false alarms on finite loops

A loop can recursively increase/decrease a function local static
variable and make itself finite.  For example,

```
void f() {
  static int i = 0;
  i++;
  while (i < 10)
     f();
}

```

Such cases are not considered by `InfiniteLoopCheck`.  This commit
fixes this problem by detecting usages of static local variables
and recursions.

Reviewed by: NoQ, njames93
Differential Revision: https://reviews.llvm.org/D128401

2 years ago[SLP]Fix PR57322: vectorize constant float stores.
Alexey Bataev [Fri, 26 Aug 2022 17:23:43 +0000 (10:23 -0700)]
[SLP]Fix PR57322: vectorize constant float stores.

Stores for constant floats must be vectorized, improve analysis in SLP
vectorizer for stores.

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

2 years ago[SLP] Add tests showing over-eager SLP when scalar fma can be used.
Florian Hahn [Mon, 29 Aug 2022 17:58:56 +0000 (18:58 +0100)]
[SLP] Add tests showing over-eager SLP when scalar fma can be used.

Add test cases for AArch64 that show over-eager SLP vectorization on
AArch64, where keeping the things scalar allows efficient lowering using
scalar fmas.

2 years ago[flang] Don't construct TBP bindings for abstract derived types
Peter Klausler [Sat, 27 Aug 2022 00:34:26 +0000 (17:34 -0700)]
[flang] Don't construct TBP bindings for abstract derived types

The tables constructed by semantics that describe derived types to
the runtime support library must not include "vtable" entries for
the deferred type-bound procedures of abstract derived types;
these can turn out to be unsatisfiable external references to
procedures whose interfaces were used in the definitions of those
bindings.

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

2 years ago[Driver] Fix & re-enable DriverKit test
Julian Lettner [Sat, 27 Aug 2022 01:43:13 +0000 (18:43 -0700)]
[Driver] Fix & re-enable DriverKit test

2 years ago[lldb] Quietly source lit-lldb-init
Dave Lee [Thu, 25 Aug 2022 18:28:44 +0000 (11:28 -0700)]
[lldb] Quietly source lit-lldb-init

Improve utility of `FileCheck` output when a shell test fails.

The conflict is from:

1. On failure, `FileCheck` prints 5 lines of context
2. Shell tests first source `lit-lldb-init`, having the effect of printing its contents

If a `FileCheck` failure happens at the beginning of the input, then the
context shown is the `lit-lldb-init`, as it's over 5 lines and is the first
thing printed. As the init contents are fairly static, and presumably
uninteresting to most test failures, it seems reasonable to not print it.

Unfortunately it's not possible to use the `--source-quietly` flag in the lldb
invocation, because it will quiet all other `--source` flags on the command
line, making many tests fail.

This fix is a level of indirection, where a new sibling file named
`lit-lldb-init-quiet` is created, and its static contents are:

```
command source -C --silent-run true lit-lldb-init
```

This achieves the result of loading `lit-lldb-init` quietly. The `-C` flag
loads the path relatively.

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

2 years ago[lldb] Remove mention of dotest.pl
Dave Lee [Sat, 27 Aug 2022 17:28:23 +0000 (10:28 -0700)]
[lldb] Remove mention of dotest.pl

2 years ago[lldb][test] Speed up lldb arch determination (NFC)
Dave Lee [Sat, 27 Aug 2022 23:33:43 +0000 (16:33 -0700)]
[lldb][test] Speed up lldb arch determination (NFC)

While investigation slow tests, I looked into why `TestMultithreaded.py`. One
of the reasons is that it determines the architecture of lldb by running:

```
lldb -o 'file path/to/lldb' -o 'quit'
```

On my fairly fast machine, this takes 24 seconds, and `TestMultithreaded.py`
calls this function 4 times.

With this change, this command now takes less than 0.2s on the same machine.

The reason it's slow is symbol table and debug info loading, as indicated by
the new progress events printed to the console. One setting reduced the time in
half:

```
settings set target.preload-symbols false
```

Further investigation, by profiling with Instruments on macOS, showed that
loading time was also caused by looking for scripts. The setting that
eliminates this time is:

```
settings set target.load-script-from-symbol-file false
```

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

2 years agoFoldingRanges: Handle LineFoldingsOnly clients.
Utkarsh Saxena [Thu, 4 Aug 2022 10:41:15 +0000 (12:41 +0200)]
FoldingRanges: Handle LineFoldingsOnly clients.

Do not fold the endline which contains tokens after the end of range.

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

2 years ago[mlir][MemRef] Canonicalize reinterpret_cast(extract_strided_metadata)
Quentin Colombet [Sat, 27 Aug 2022 01:14:23 +0000 (01:14 +0000)]
[mlir][MemRef] Canonicalize reinterpret_cast(extract_strided_metadata)

Add a canonicalizetion step for
reinterpret_cast(extract_strided_metadata).
This step replaces this sequence of operations by either:
- A noop, i.e., the original memref is directly used, or
- A plain cast of the original memref

The choice is ultimately made based on whether the original memref type
is equal to what the reinterpret_cast iss producing. For instance, the
reinterpret_cast could be changing some dimensions from static to
dynamic and in such case, we need to keep a cast.

The transformation is currently only performed when the reinterpret_cast
uses exactly the same arguments as what the extract_strided_metadata
produces. It may be possible to be more aggressive here but I wanted to
start with a relatively simple MLIR patch for my first one!

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

2 years ago[clangd] Fail more gracefully if QueryDriverDatabase cannot determine file type
Nathan Ridge [Mon, 29 Aug 2022 08:24:24 +0000 (04:24 -0400)]
[clangd] Fail more gracefully if QueryDriverDatabase cannot determine file type

Currently, QueryDriverDatabase returns an empty compile command
if it could not determine the file type.

This failure mode is unnecessarily destructive; it's better to
just return the incoming compiler command, which is still more
likely to be useful than an empty command.

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

2 years ago[mlir][sparse] start a sparse codegen conversion pass
Aart Bik [Fri, 26 Aug 2022 20:49:07 +0000 (13:49 -0700)]
[mlir][sparse] start a sparse codegen conversion pass

This new pass provides an alternative to the current conversion pass
that converts sparse tensor types and sparse primitives to opaque pointers
and calls into a runtime support library. This pass will map sparse tensor
types to actual data structures and primitives to actual code. In the long
run, this new pass will remove our dependence on the support library, avoid
the need to link in fully templated and expanded code, and provide much better
opportunities for optimization on the generated code.

Reviewed By: Peiming

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

2 years ago[VP][RISCV] Add vp.fabs intrinsic and RISC-V support.
Craig Topper [Mon, 29 Aug 2022 16:32:02 +0000 (09:32 -0700)]
[VP][RISCV] Add vp.fabs intrinsic and RISC-V support.

Mostly just modeled after vp.fneg except there is a
"functional instruction" for fneg while fabs is always an
intrinsic.

Reviewed By: fakepaper56

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

2 years ago[mlir][ods] OpFormat: fix type inference issues
Jeff Niu [Wed, 10 Aug 2022 22:20:41 +0000 (18:20 -0400)]
[mlir][ods] OpFormat: fix type inference issues

This patch fixes issues with generating assembly format parsers for
operations that use the `operands` directive or which have unnamed
arguments or results.

This patch also fixes a function in `OpAsmParser` that always produced
an error when trying to resolve variadic operands with the same type.

Fixes #51841

Reviewed By: rriddle

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

2 years ago[RISCV] Add Uses=[FRM] and mayRaiseFPException to VF(N/W)CVT instructions.
Craig Topper [Mon, 29 Aug 2022 16:06:18 +0000 (09:06 -0700)]
[RISCV] Add Uses=[FRM] and mayRaiseFPException to VF(N/W)CVT instructions.

Reviewed By: arcbbb, kito-cheng

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

2 years ago[NFC][libc++][format] Use ranges in the output.
Mark de Wever [Sun, 28 Aug 2022 18:35:53 +0000 (20:35 +0200)]
[NFC][libc++][format] Use ranges in the output.

This should avoid some copies of the output iterator.

Reviewed By: #libc, Mordante

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

2 years ago[RISCV] Use analyzeBranch in RISCVRedundantCopyElimination.
Craig Topper [Fri, 26 Aug 2022 23:56:32 +0000 (16:56 -0700)]
[RISCV] Use analyzeBranch in RISCVRedundantCopyElimination.

The existing code was incorrect if we had more than one conditional
branch instruction in a basic block. Though I don't think that will
occur, using analyzeBranch detects that as an unsupported case.

Overall this results in simpler code in RISCVRedundantCopyElimination.

Reviewed By: reames, kito-cheng

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

2 years ago[mlir][dataflow] Consolidate AbstractSparseLattice::markPessimisticFixpoint() and...
Zhixun Tan [Mon, 29 Aug 2022 15:52:46 +0000 (08:52 -0700)]
[mlir][dataflow] Consolidate AbstractSparseLattice::markPessimisticFixpoint() and AbstractDenseLattice::reset() into Abstract{Sparse,Dense}DataFlowAnalysis::setToEntryState().

### Rationale

For a program point where we cannot reason about incoming dataflow (e.g. an argument of an entry block), the framework needs to initialize the state.

Currently, `AbstractSparseDataFlowAnalysis` initializes such state to the "pessimistic fixpoint", and `AbstractDenseDataFlowAnalysis` calls the state's `reset()` function.

However, entry states aren't necessarily the pessimistic fixpoint. Example: in reaching definition, the pessimistic fixpoint is `{all definitions}`, but the entry state is `{}`.

This awkwardness might be why the dense analysis API currently uses `reset()` instead of `markPessimisticFixpoint()`.

This patch consolidates entry point initialization into a single function `setToEntryState()`.

### API Location

Note that `setToEntryState()` is defined in the analysis rather than the lattice, so that we allow different analyses to use the same lattice but different entry states.

### Removal of the concept of optimistic/known value

The concept of optimistic/known value is too specific to SCCP.

Furthermore, the known value is not really used: In the current SCCP implementation, the known value (pessimistic fixpoint) is always `Attribute{}` (non-constant). This means there's no point storing a `knownValue` in each state.

If we do need to re-introduce optimistic/known value, we should put it in the SCCP analysis, not the sparse analysis API.

### Terminology

Please let me know if "entry state" is a good terminology.

I chose "entry" from Wikipedia (https://en.wikipedia.org/wiki/Data-flow_analysis#Basic_principles).

Another term I can think of is "boundary" (https://suif.stanford.edu/~courses/cs243/lectures/L3-DFA2-revised.pdf) which might be better since it also makes sense for backward analysis.

Reviewed By: Mogball

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

2 years ago[DSE] Add extra test for loop invariant store in loop, update comments.
Florian Hahn [Mon, 29 Aug 2022 15:59:59 +0000 (16:59 +0100)]
[DSE] Add extra test for loop invariant store in loop, update comments.

Add extra test coverage and updates some slightly stale comments as
pointed out in D132365.

2 years ago[AMDGPU][NFC] Allow separate RC for VOP3 DPP Dst
Joe Nash [Thu, 25 Aug 2022 14:37:30 +0000 (10:37 -0400)]
[AMDGPU][NFC] Allow separate RC for VOP3 DPP Dst

Create a field in VOPProfile called DstRCVOP3DPP to allow the VOP3
versions of DPP instructions to have a different destination register
class than the non-VOP3 encoding. NFC for current instructions, but
planned to be functional in upcoming ones.

Reviewed By: rampitec

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

2 years ago[clang] Fix ambiguous use of `report_fatal_error`.
Wei Yi Tee [Mon, 29 Aug 2022 15:15:44 +0000 (15:15 +0000)]
[clang] Fix ambiguous use of `report_fatal_error`.

`report_fatal_error` is overloaded on `StringRef` and `Twine &`, therefore passing a `std::string` argument leads to ambiguity as it is convertible to either type.

Reviewed By: gribozavr2, sgatev

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

2 years ago[SLP]Improve lookup of the buildvector top insertelement instruction.
Alexey Bataev [Fri, 26 Aug 2022 13:10:43 +0000 (06:10 -0700)]
[SLP]Improve lookup of the buildvector top insertelement instruction.

When estimating the cost of the in-tree vectorized scalars in
buildvector sequences, need to take into account the vectorized
insertelement instruction. The top of the buildvector seuences is the
topmost vectorized insertelement instruction, because it will have
> than 1 use after the vectorization.

For the affected test case improves througput from 21 to 16 (per
llvm-mca).

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

2 years ago[flang] Allow compiler directives for collapsed loops in OpenACC
Daniil Dudkin [Mon, 29 Aug 2022 15:00:02 +0000 (18:00 +0300)]
[flang] Allow compiler directives for collapsed loops in OpenACC

If one tries to compile the attached test case code with flan,
the one will get an internal compiler error on `CHECK(level == 0)`
at the end of `PrivatizeAssociatedLoopIndex` function.
Other compilers (gfortran and nvfortran) build this code just fine.
This change fixes the ICE.

Reviewed By: clementval

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

2 years ago[flang][OpenMP] Support lowering of threadprivate directive for non global variables
Peixin Qiao [Mon, 29 Aug 2022 14:33:46 +0000 (22:33 +0800)]
[flang][OpenMP] Support lowering of threadprivate directive for non global variables

Non-global variable which can be in threadprivate directive must be one
variable in main program, and it has implicit SAVE attribute. Take it as
with SAVE attribute, so to create GlobalOp for it to simplify the
translation to LLVM IR.

Reviewed By: NimishMishra

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

2 years ago[flang] Support lowering of C_PTR and C_FUNPTR argument with VALUE attribute
Peixin Qiao [Mon, 29 Aug 2022 14:29:34 +0000 (22:29 +0800)]
[flang] Support lowering of C_PTR and C_FUNPTR argument with VALUE attribute

As Fortran 2018 18.3.2, C_PTR is interoperable with any C object pointer
type. C_FUNPTR is interoperable with any C function pointer type. As
18.3.6, a C pointer can correspond to a Fortran dummy argument of type
C_PTR with the VALUE attribute.

The interface for type(C_PTR)/type(C_FUNPTR) argument with value
attribute is different from the the usual derived type. For type(C_PTR)
or type(C_FUNPTR), the component is the address, and the interface is
a pointer even with VALUE attribute. For a usual derived type such as
the drived type with the component of integer 64, the interface is a i64
value when it has VALUE attribute on aarch64 linux.

To lower the type(C_PTR)/type(C_FUNPTR) argument with value attribute,
get the value of the component of the type(C_PTR)/type(C_FUNPTR), which
is the address, and then convert it to the pointer and pass it.

Reviewed By: Jean Perier

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

2 years ago[InstCombine] fold not-shift of signbit to icmp+zext
Sanjay Patel [Mon, 29 Aug 2022 13:12:49 +0000 (09:12 -0400)]
[InstCombine] fold not-shift of signbit to icmp+zext

https://alive2.llvm.org/ce/z/j_8Wz9

The arithmetic shift was converted to logical shift with:
246078604c871d43

That does not seem to uncover any other missing/conflicting folds,
so convert directly to signbit test + cast.

We still need to fold the pattern with logical shift to test + cast.

This allows reducing patterns where the output type is not
the same as the input value:
https://alive2.llvm.org/ce/z/nydwFV

Fixes #57394

2 years agoMake this test slightly less fragile; NFC
Aaron Ballman [Mon, 29 Aug 2022 13:39:23 +0000 (09:39 -0400)]
Make this test slightly less fragile; NFC

The rule IDs are not stable, so this uses a regex for the rule ids
instead of concrete values. It also moves the CHECK lines below the
code so that it's easier to modify the test in the future. It also
breaks the CHECK lines into multiple lines to improve the performance
of the test and aid in debugging failures. Finally, it adds a comment
to the top of the test explaining that things are still rather fragile.

2 years ago[Libomptarget] Do not check for valid binaries twice.
Joseph Huber [Mon, 8 Aug 2022 21:28:02 +0000 (17:28 -0400)]
[Libomptarget] Do not check for valid binaries twice.

The only RTLs that get added to the `UsedRTLs` list have already been
checked is they were valid binaries. We shouldn't need to do this again
when we unregister all the used binaries as they wouldn't have been used
if they were invalid anyway. Let me know if I'm incorrect in this
assumption.

Reviewed By: jdoerfert

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

2 years ago[InstCombine] fold inc-of-signbit-splat to not+lshr
Sanjay Patel [Mon, 29 Aug 2022 12:13:38 +0000 (08:13 -0400)]
[InstCombine] fold inc-of-signbit-splat to not+lshr

(iN X s>> (N - 1)) + 1 --> (~X) u>> (N - 1)

https://alive2.llvm.org/ce/z/wzS474

2 years ago[InstCombine] add tests for increment-of-ashr; NFC
Sanjay Patel [Mon, 29 Aug 2022 11:51:36 +0000 (07:51 -0400)]
[InstCombine] add tests for increment-of-ashr; NFC

2 years agoApply clang-tidy fixes for performance-unnecessary-value-param in IRAttributes.cpp...
Mehdi Amini [Mon, 29 Aug 2022 10:06:17 +0000 (10:06 +0000)]
Apply clang-tidy fixes for performance-unnecessary-value-param in IRAttributes.cpp (NFC)

2 years agoApply clang-tidy fixes for llvm-else-after-return in Parser.cpp (NFC)
Mehdi Amini [Mon, 29 Aug 2022 10:04:06 +0000 (10:04 +0000)]
Apply clang-tidy fixes for llvm-else-after-return in Parser.cpp (NFC)

2 years agoExpose QualType::getUnqualifiedType in libclang
Luca Di Sera [Mon, 29 Aug 2022 12:16:18 +0000 (08:16 -0400)]
Expose QualType::getUnqualifiedType in libclang

The method is now wrapped by clang_getUnqualifiedType.

A declaration for clang_getUnqualifiedType was added to
clang-c/Index.h to expose it to user of the library.

An implementation for clang_getUnqualifiedType was introduced in
CXType.cpp that wraps the equivalent method of the underlying
QualType of a CXType.

An export symbol was added to libclang.map under the new version entry
LLVM_16.

A test was added to LibclangTest.cpp that tests the removal of
qualifiers for some CXTypes.

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

2 years ago[mlir][Vector] Fix unused variable warning in release builds. NFCI.
Benjamin Kramer [Mon, 29 Aug 2022 12:02:31 +0000 (14:02 +0200)]
[mlir][Vector] Fix unused variable warning in release builds. NFCI.

2 years ago[mlir] Delete MemRefType::Builder::setMemorySpace(unsigned)
Tres Popp [Tue, 23 Aug 2022 12:47:47 +0000 (14:47 +0200)]
[mlir] Delete MemRefType::Builder::setMemorySpace(unsigned)

This operation has been deprecated for a very long time now, so remove
it completely.

https://llvm.discourse.group/t/rfc-memref-memory-shape-as-attribute/2229

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

2 years ago[analyzer] Silence GCC warnings about unused variables. NFC.
Martin Storsjö [Mon, 29 Aug 2022 09:10:07 +0000 (12:10 +0300)]
[analyzer] Silence GCC warnings about unused variables. NFC.

Use `isa<T>()` instead of `Type *Var = dyn_cast<T>()`
when the result of the cast isn't used.

2 years ago[lldb] Fix warnings about unused variables when building without asserts. NFC.
Martin Storsjö [Mon, 29 Aug 2022 09:32:10 +0000 (12:32 +0300)]
[lldb] Fix warnings about unused variables when building without asserts. NFC.

2 years ago[mlir][Linalg] Move verification of block arguments back.
Adrian Kuegel [Mon, 29 Aug 2022 08:55:10 +0000 (10:55 +0200)]
[mlir][Linalg] Move verification of block arguments back.

DestinationStyleOpInterface should be possible to use for ops that don't
have regions. Therefore the check for block arguments should be done in
verifyStructedOpInterface.

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

2 years ago[LV] Add test where either a libfunc or intrinsic is chosen.
Florian Hahn [Mon, 29 Aug 2022 09:51:19 +0000 (10:51 +0100)]
[LV] Add test where either a libfunc or intrinsic is chosen.

In the newly added test either a libfunc (VF=2) or a intrinsic (VF=4)
can be chosen.

Test coverage for D132585.

2 years ago[docs] improve documentation for misc-const-correctness
Jonas Toth [Mon, 29 Aug 2022 09:19:16 +0000 (11:19 +0200)]
[docs] improve documentation for misc-const-correctness

Improve the documentation for 'misc-const-correctness' to:

- include better examples
- improve the english
- fix links to other checks that were broken due to the directory-layout changes
- mention the limitation that the check does not run on `C` code.

Addresses #56749, #56958

Reviewed By: njames93

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

2 years ago[LV] Remove unneeded getVectorIntrinsicIDForCall call (NFC).
Florian Hahn [Mon, 29 Aug 2022 09:19:46 +0000 (10:19 +0100)]
[LV] Remove unneeded getVectorIntrinsicIDForCall call (NFC).

Suggested as independent fix during the review of D132585.

2 years ago[Flang] Use find_program() to find clang-tblgen
Nikita Popov [Mon, 8 Aug 2022 10:40:49 +0000 (12:40 +0200)]
[Flang] Use find_program() to find clang-tblgen

There are two scenarios here:

1. Standalone flang build, where we use an installed clang-tblgen
   binary. We need to use find_package() to find it.
2. Combined build of clang and flang, where we want to use the
   path specified in CLANG_TABLEGEN_EXE during the clang build --
   however, this variable was previously not exported.

The new implementation matches what is done for mlir-tblgen.

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

2 years ago[clang] Make guard(nocf) attribute available only for Windows
Alvin Wong [Mon, 29 Aug 2022 08:27:27 +0000 (11:27 +0300)]
[clang] Make guard(nocf) attribute available only for Windows

Control Flow Guard is only supported on Windows target, therefore there
is no point to make it an accepted attribute for other targets.

Reviewed By: rnk, aaron.ballman

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

2 years ago[X86][BF16] Add type mangling for Windows
Phoebe Wang [Mon, 29 Aug 2022 07:39:04 +0000 (15:39 +0800)]
[X86][BF16] Add type mangling for Windows

Reviewed By: FreddyYe

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

2 years ago[mlir][Vector] Support 0-D vectors in ShuffleOp
Nicolas Vasilache [Fri, 26 Aug 2022 11:08:13 +0000 (04:08 -0700)]
[mlir][Vector] Support 0-D vectors in ShuffleOp

Co-authored-by: Michal Terepeta <michalt@google.com>
Reviewed-by: nicolasvasilache
Differential Revision: https://reviews.llvm.org/D115744

2 years ago[Fuchsia][CMake] Disable LLVM plugin support
Petr Hosek [Mon, 29 Aug 2022 07:23:36 +0000 (07:23 +0000)]
[Fuchsia][CMake] Disable LLVM plugin support

We already disable plugin support in Clang, disable LLVM side as well
since we don't support plugins in Fuchsia toolchain.

2 years ago[mlir] Apply ClangTidy performance finding (NFC).
Adrian Kuegel [Mon, 29 Aug 2022 07:15:35 +0000 (09:15 +0200)]
[mlir] Apply ClangTidy performance finding (NFC).

2 years ago[llvm][ADT] Fix formatting for files relevant to `StringMap`.
Wei Yi Tee [Mon, 29 Aug 2022 06:55:54 +0000 (06:55 +0000)]
[llvm][ADT] Fix formatting for files relevant to `StringMap`.

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

2 years ago[docs] Expand lit documentation on response files
Petr Hosek [Mon, 29 Aug 2022 06:50:10 +0000 (06:50 +0000)]
[docs] Expand lit documentation on response files

This was requested in https://reviews.llvm.org/D132437.

2 years agoRevert "[llvm][ADT] Fix formatting for files relevant to `StringMap`."
Wei Yi Tee [Mon, 29 Aug 2022 06:43:48 +0000 (06:43 +0000)]
Revert "[llvm][ADT] Fix formatting for files relevant to `StringMap`."

This reverts commit d23df9c9e81e186c3218bd924976fbd646f3bad1.
Revert due to missing review link.

2 years ago[llvm][ADT] Fix formatting for files relevant to `StringMap`.
Wei Yi Tee [Fri, 26 Aug 2022 18:21:29 +0000 (18:21 +0000)]
[llvm][ADT] Fix formatting for files relevant to `StringMap`.

2 years agoUse StringRef::contains (NFC)
Kazu Hirata [Mon, 29 Aug 2022 06:29:02 +0000 (23:29 -0700)]
Use StringRef::contains (NFC)

2 years ago[llvm] Qualify auto in range-based for loops (NFC)
Kazu Hirata [Mon, 29 Aug 2022 06:29:00 +0000 (23:29 -0700)]
[llvm] Qualify auto in range-based for loops (NFC)

2 years ago[llvm] Use range-based for loops (NFC)
Kazu Hirata [Mon, 29 Aug 2022 06:28:58 +0000 (23:28 -0700)]
[llvm] Use range-based for loops (NFC)

2 years ago[Instrumentation] Use std::clamp (NFC)
Kazu Hirata [Mon, 29 Aug 2022 06:28:57 +0000 (23:28 -0700)]
[Instrumentation] Use std::clamp (NFC)

The use of std::clamp should be safe here.  MinRZ is at most 32, while
kMaxRZ is 1 << 18, so we have MinRZ <= kMaxRZ, avoiding the undefind
behavior of std::clamp.

2 years ago[tests] precommit tests for D132658
zhongyunde [Mon, 29 Aug 2022 06:17:06 +0000 (14:17 +0800)]
[tests] precommit tests for D132658

Reviewed By: bcl5980
Differential Revision: https://reviews.llvm.org/D132820

2 years ago[MC][test] Test FreeBSD after D131162
Fangrui Song [Mon, 29 Aug 2022 06:13:46 +0000 (23:13 -0700)]
[MC][test] Test FreeBSD after D131162