platform/upstream/llvm.git
2 years ago[HWASan] deflake hwasan_symbolize test
Florian Mayer [Fri, 6 May 2022 23:13:58 +0000 (16:13 -0700)]
[HWASan] deflake hwasan_symbolize test

Also enable on X86_64.

The directory would change during the test execution. This should not
necessarily prevent us from indexing a directory (a user might
potentially do that if they specify a parent directory of the actual
symbols directory, and change unrelated files).

Reviewed By: eugenis

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

2 years ago[polly] Load NPM pass plugin for NPM test.
Michael Kruse [Mon, 9 May 2022 21:05:03 +0000 (16:05 -0500)]
[polly] Load NPM pass plugin for NPM test.

This fixes the polly-*-plugin buildbots.

2 years ago[flang] Fold intrinsic functions SPACING() and RRSPACING()
Peter Klausler [Fri, 29 Apr 2022 22:34:42 +0000 (15:34 -0700)]
[flang] Fold intrinsic functions SPACING() and RRSPACING()

The related real number system inquiry functions SPACING()
and RRSPACING() can be folded for constant arguments.
See 16.9.164 & 16.9.180 in Fortran 2018.

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

2 years agoRevert "[SLP]Further improvement of the cost model for scalars used in buildvectors."
Alexey Bataev [Mon, 9 May 2022 20:36:09 +0000 (13:36 -0700)]
Revert "[SLP]Further improvement of the cost model for scalars used in buildvectors."

This reverts commit 99f31acfce338417fea3c14983d6f8fedc8ed043 and several
others to fix detected crashes, reported in https://reviews.llvm.org/D115750

2 years ago[flang] Fold intrinsic inquiry functions SAME_TYPE_AS() and EXTENDS_TYPE_OF()
Peter Klausler [Fri, 29 Apr 2022 15:57:51 +0000 (08:57 -0700)]
[flang] Fold intrinsic inquiry functions SAME_TYPE_AS() and EXTENDS_TYPE_OF()

When the result can be known at compilation time, fold it.
Success depends on whether the operands are polymorphic.
When neither one is polymorphic, the result is known and can
be either .TRUE. or .FALSE.; when either one is polymorphic,
a .FALSE. result still can be discerned.

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

2 years ago[SLP]Adjust assertion check for scalars in several insertelements.
Alexey Bataev [Mon, 9 May 2022 20:06:30 +0000 (13:06 -0700)]
[SLP]Adjust assertion check for scalars in several insertelements.

If the same scalar is inserted several times into the same buildvector,
the mask index can be used already. In this case need to check, that
this scalar is already part of the vectorized buildvector.

2 years ago[flang][runtime] BACKSPACE after non-advancing I/O
Peter Klausler [Thu, 28 Apr 2022 23:54:40 +0000 (16:54 -0700)]
[flang][runtime] BACKSPACE after non-advancing I/O

A BACKSPACE statement on a unit after a READ or WRITE with ADVANCE="NO"
must reset the position to the beginning of the record, not to the
beginning of the previous one.

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

2 years ago[flang][runtime] (G0) for CHARACTER means (A), not (A0)
Peter Klausler [Thu, 28 Apr 2022 23:30:46 +0000 (16:30 -0700)]
[flang][runtime] (G0) for CHARACTER means (A), not (A0)

I'm emitting zero characters for (G0) formatting of CHARACTER values
instead of using their lengths to determine the output field width.

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

2 years ago[flang][runtime] Enforce restrictions on unlimited format repetition
Peter Klausler [Thu, 28 Apr 2022 21:23:31 +0000 (14:23 -0700)]
[flang][runtime] Enforce restrictions on unlimited format repetition

A repeated format item group with an unlimited ('*') repetition count
can appear only as the last item at the top level of a format; it can't
be nested in more parentheses and it can't be followed by anything
else.

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

2 years ago[flang][runtime] Don't pad CHARACTER input at end of record unless PAD='YES'
Peter Klausler [Wed, 27 Apr 2022 20:28:59 +0000 (13:28 -0700)]
[flang][runtime] Don't pad CHARACTER input at end of record unless PAD='YES'

When formatted CHARACTER input runs into the end of an input record,
the runtime usually fills the remainder of the variable with spaces,
but this should be conditional, and not done when PAD='NO'.

And while here, add some better comments to two members of connection.h
to make their non-obvious relationship more clear.

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

2 years ago[flang][runtime] Fix input of NAN(...) on non-fast path
Peter Klausler [Tue, 26 Apr 2022 23:49:29 +0000 (16:49 -0700)]
[flang][runtime] Fix input of NAN(...) on non-fast path

The closing parenthesis needs to be consumed when a NaN
with parenthesized (ignored) information is read on the
real input path that preprocesses input characters before
passing them to the decimal-to-binary converter.

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

2 years ago[mlir][nvvm] Add attribute to nvvm.cpAsyncOp to control l1 bypass
Thomas Raoux [Mon, 9 May 2022 15:46:28 +0000 (15:46 +0000)]
[mlir][nvvm] Add attribute to nvvm.cpAsyncOp to control l1 bypass

Add attribute to be able to generate the intrinsic version of async copy
generating a copy with l1 bypass. This correspond to
cp.async.cg.shared.global in ptx.

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

2 years agoRevert "Recommit "[VPlan] Remove uneeded needsVectorIV check.""
Florian Hahn [Mon, 9 May 2022 19:33:14 +0000 (20:33 +0100)]
Revert "Recommit "[VPlan] Remove uneeded needsVectorIV check.""

This reverts commit 8b48223447311af8b3022697dd58858e1ce6975f.

This triggers an assertion on a test case mentioned in D123720.
Revert while I investigate.

2 years ago[polly] Fix compiler warning. NFC.
Michael Kruse [Mon, 9 May 2022 18:59:49 +0000 (13:59 -0500)]
[polly] Fix compiler warning. NFC.

Fix the warning

   warning: 'polly::ScopViewer' has virtual functions but non-virtual destructor [-Wnon-virtual-dtor]

and for several other classes by inserting virtual destructors.

2 years ago[polly] migrate -polly-show to the new pass manager
Michael Kruse [Mon, 9 May 2022 18:38:20 +0000 (13:38 -0500)]
[polly] migrate -polly-show to the new pass manager

Reviewed By: Meinersbur

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

2 years ago[PassManager] Implement DOTGraphTraitsViewer under NPM
Michael Kruse [Mon, 9 May 2022 18:38:16 +0000 (13:38 -0500)]
[PassManager] Implement DOTGraphTraitsViewer under NPM

Rename the legacy `DOTGraphTraits{Module,}{Viewer,Printer}` to the corresponding `DOTGraphTraits...WrapperPass`, and implement a new `DOTGraphTraitsViewer` with new pass manager.

Reviewed By: Meinersbur

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

2 years agoModify DXILPrepare to emit no-op bitcasts
Chris Bieneman [Thu, 14 Apr 2022 18:41:57 +0000 (13:41 -0500)]
Modify DXILPrepare to emit no-op bitcasts

In supporting opaque pointers we need to re-materialize typed pointers
in bitcode emission. Because of how the value-enumerator pre-allocates
types and instructions we need to insert some no-op bitcasts in the
places that we'll need bitcasts for the pointer types.

Reviewed By: kuhar

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

2 years agoMake lsan TestCases more consistent
Clemens Wasser [Mon, 9 May 2022 17:58:53 +0000 (10:58 -0700)]
Make lsan TestCases more consistent

Inlining `LSAN_BASE` makes the lsan TestCases more consistent to the other sanitizer TestCases.
It is also needed on Windows: https://reviews.llvm.org/D115103

Reviewed By: vitalybuka

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

2 years ago[mlir] Fix build & test of mlir python bindings on Windows
Stella Stamenova [Mon, 9 May 2022 18:10:17 +0000 (11:10 -0700)]
[mlir] Fix build & test of mlir python bindings on Windows

There are a couple of issues with the python bindings on Windows:
- `create_symlink` requires special permissions on Windows - using `copy_if_different` instead allows the build to complete and then be usable
- the path to the `python_executable` is likely to contain spaces if python is installed in Program Files. llvm's python substitution adds extra quotes in order to account for this case, but mlir's own python substitution does not
- the location of the shared libraries is different on windows
- if the type is not specified for numpy arrays, they appear to be treated as strings

I've implemented the smallest possible changes for each of these in the patch, but I would actually prefer a slightly more comprehensive fix for the python_executable and the shared libraries.

For the python substitution, I think it makes sense to leverage the existing %python instead of adding %PYTHON and instead add a new variable for the case when preloading is needed. This would also make it clearer which tests are which and should be skipped on platforms where the preloading won't work.

For the shared libraries, I think it would make sense to pass the correct path and extension (possibly even the names) to the python script since these are known by lit and don't have to be hardcoded in the test at all.

Reviewed By: stellaraccident

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

2 years ago[lldb/test] Remove superfluous -std=c++11 from tests
Pavel Labath [Mon, 9 May 2022 18:04:14 +0000 (20:04 +0200)]
[lldb/test] Remove superfluous -std=c++11 from tests

We default to that anyway. It does not work on windows, and since
ac7747e, the flag actually takes effect.

2 years ago[lldb/test] Append CXXFLAGS_EXTRAS last in Makefile.rules
Pavel Labath [Mon, 9 May 2022 17:24:57 +0000 (19:24 +0200)]
[lldb/test] Append CXXFLAGS_EXTRAS last in Makefile.rules

This matches what we do with CFLAGS, and it started to matter
8abfa5119ad, which added some -std=-apending code.

2 years ago[CodeGen] Clarify the semantics of ADDCARRY/SUBCARRY
Kazu Hirata [Mon, 9 May 2022 17:17:00 +0000 (10:17 -0700)]
[CodeGen] Clarify the semantics of ADDCARRY/SUBCARRY

This patch clarifies the semantics of ADDCARRY/SUBCARRY, specifically
stating that both the incoming and outgoing carries are active high.

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

2 years ago[SystemZ] Fix argument type of tdc instruction.
Kai Nacke [Mon, 9 May 2022 13:53:28 +0000 (09:53 -0400)]
[SystemZ] Fix argument type of tdc instruction.

The DAG node for the Test Data Class is defined using i64 as the second parameter.
However, the code to lower is_fpclass uses `i32` as type. This only works because no
type check is generated in the DAG matcher.
This PR changes the type of the mask constant to `i64`.

Reviewed By: uweigand

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

2 years ago[opt] Error on `opt -O# --foo-pass`
Arthur Eubanks [Mon, 9 May 2022 00:22:11 +0000 (17:22 -0700)]
[opt] Error on `opt -O# --foo-pass`

Matches the error message we emit with `-opt -O# --passes=foo`.
Otherwise we crash later on.

Makes #55320 much less confusing.

Reviewed By: MaskRay

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

2 years ago[SLP]Try partial store vectorization if supported by target.
Alexey Bataev [Fri, 22 Apr 2022 18:14:41 +0000 (11:14 -0700)]
[SLP]Try partial store vectorization if supported by target.

We can try to vectorize number of stores less than MinVecRegSize
/ scalar_value_size, if it is allowed by target. Gives an extra
opportunity for the vectorization.

Fixes PR54985.

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

2 years ago[Docs] Added my office hours.
Anastasia Stulova [Mon, 9 May 2022 16:39:03 +0000 (17:39 +0100)]
[Docs] Added my office hours.

2 years ago[mlir] Refactoring dialect and test code to use parseCommaSeparatedList
Jakub Tucholski [Mon, 2 May 2022 17:55:36 +0000 (13:55 -0400)]
[mlir] Refactoring dialect and test code to use parseCommaSeparatedList

Issue #55173

Reviewed By: lattner, rriddle

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

2 years ago[clang-fuzzer] Add a tiny tool to generate a fuzzing dictionary for clang
Sam McCall [Sat, 7 May 2022 13:10:51 +0000 (15:10 +0200)]
[clang-fuzzer] Add a tiny tool to generate a fuzzing dictionary for clang

It should be useful clang-fuzzer itself, though my own motivation is
to use this in fuzzing clang-pseudo. (clang-tools-extra/pseudo/fuzzer).

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

2 years agoRevert ""Re-apply 4b6c2cd642 "Deferred Concept Instantiation Implementation"""""
Erich Keane [Mon, 9 May 2022 16:04:17 +0000 (09:04 -0700)]
Revert ""Re-apply 4b6c2cd642 "Deferred Concept Instantiation Implementation"""""

This reverts commit a425cac31e2e4cee8e14b7b9a99c8ba17c1ebb52.

There is another libc++ test, that this time causes us to hit an
assertion. Reverting, likely for a while this time.

2 years ago[riscv] Add a few more vsetvli insertion tests
Philip Reames [Mon, 9 May 2022 15:49:40 +0000 (08:49 -0700)]
[riscv] Add a few more vsetvli insertion tests

These are aimed at a possible miscompile spotted in the vmv.s.x/f mutation case, but it appears this is a latent bug.  Or at least, I haven't been able to construct a case with compatible policy flags via intrinsics.

2 years ago[RISCV] Remove two unmasked RVV patterns
Fraser Cormack [Mon, 9 May 2022 15:10:17 +0000 (16:10 +0100)]
[RISCV] Remove two unmasked RVV patterns

These can be selected to unmasked from masked instructions by the
post-process DAG step.

Reviewed By: craig.topper

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

2 years ago[mlir][linalg] Fix padding size calculation for Conv2d ops.
Jerry Wu [Mon, 9 May 2022 15:43:40 +0000 (08:43 -0700)]
[mlir][linalg] Fix padding size calculation for Conv2d ops.

This patch fixed the padding size calculation for Conv2d ops when the stride > 1. It contains the changes below:

- Use addBound to add constraint for AffineApplyOp in getUpperBoundForIndex. So the result value can be mapped and retrieved later.

- Fixed the bound from AffineMinOp by adding as a closed bound. Originally the bound was added as an open upper bound, which results in the incorrect bounds when we multiply the values. For example:

```
%0 = affine.min affine_map<()[s0] -> (4, -s0 + 11)>()[iv0]
%1 = affine.apply affine_map<()[s0] -> (s0 * 2)>()[%0]

If we add the affine.min as an open bound, addBound will internally transform it into the close bound "%0 <= 3". The following sliceBounds will derive the bound of %1 as "%1 <= 6" and return the open bound "%1 < 7", while the correct bound should be "%1 <= 8".
```

- In addition to addBound, I also changed sliceBounds to support returning closed upper bound, since for the size computation, we usually care about the closed bounds.

- Change the getUpperBoundForIndex to favor constant bounds when required. The sliceBounds will return a tighter but non-constant bounds, which can't be used for padding. The constantRequired option requires getUpperBoundForIndex to get the constant bounds when possible.

Reviewed By: hanchung

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

2 years ago[mlir] Add translation from tensor.reshape to memref.reshape
Ashay Rane [Mon, 9 May 2022 15:41:21 +0000 (17:41 +0200)]
[mlir] Add translation from tensor.reshape to memref.reshape

This patch augments the `tensor-bufferize` pass by adding a conversion
rule to translate ReshapeOp from the `tensor` dialect to the `memref`
dialect, in addition to adding a unit test to validate the translation.

Reviewed By: springerm

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

2 years ago[lldb/test] Fix TestCppIncompleteTypeMembers.py
Pavel Labath [Mon, 9 May 2022 15:10:57 +0000 (17:10 +0200)]
[lldb/test] Fix TestCppIncompleteTypeMembers.py

modify the Makefile.rules line which was interfering with the
target-specific variable values.

2 years ago[LLVM][sancov] Inclusive language: Add -ignorelist option
Zarko Todorovski [Mon, 9 May 2022 15:05:13 +0000 (11:05 -0400)]
[LLVM][sancov] Inclusive language: Add -ignorelist option

Adding the `-ignorelist` option that may eventually replace `-blacklist`.
With this patch `sancov` accepts both options.

Reviewed By: quinnp

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

2 years ago[ELF] Support -plugin-opt=stats-file=
Alex Richardson [Mon, 9 May 2022 14:51:02 +0000 (14:51 +0000)]
[ELF] Support -plugin-opt=stats-file=

This flag is added by clang::driver::tools::addLTOOptions() and was causing
errors for me when building the llvm-test-suite repository with LTO and
-DTEST_SUITE_COLLECT_STATS=ON. This replaces the --stats-file= option
added in 1c04b52b2594d403f739ed919ef420b1e47ae343 since the flag is only
used for LTO and should therefore be in the -plugin-opt= namespace.

Additionally, this commit fixes the `REQUIRES: asserts` that was added in
948d05324a150a5a24e93bad07c9090d5b8bd129: the feature was never defined in
the lld test suite so it effectively disabled the test.

Reviewed By: MaskRay, MTC

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

2 years ago[X86] insertps-combine.ll - show address math in checks
Simon Pilgrim [Mon, 9 May 2022 14:59:59 +0000 (15:59 +0100)]
[X86] insertps-combine.ll - show address math in checks

2 years ago[SLP]Fix a crash when preparing a mask for external scalars.
Alexey Bataev [Mon, 9 May 2022 14:31:33 +0000 (07:31 -0700)]
[SLP]Fix a crash when preparing a mask for external scalars.

Need to use actual index instead of the tree entry position, since the
insert index may be different than 0. It mean, that we vectorized part
of the buildvector starting from not initial insertelement instruction
beause of some reason.

2 years ago[SCEV] Fold umin_seq using known predicate
Nikita Popov [Mon, 9 May 2022 14:15:09 +0000 (16:15 +0200)]
[SCEV] Fold umin_seq using known predicate

Fold %x umin_seq %y to %x if %x ule %y. This also subsumes the
special handling for constant operands, as if %y is constant this
folds to umin via implied poison reasoning, and if %x is constant
then either %x is not zero and it folds to umin, or it is known
zero, in which case it is ule anything.

2 years ago[SCEV] Add more tests for umin_seq with known predicate (NFC)
Nikita Popov [Mon, 9 May 2022 14:17:16 +0000 (16:17 +0200)]
[SCEV] Add more tests for umin_seq with known predicate (NFC)

2 years agoEnum conversion warning when one signed and other unsigned.
Micah Weston [Mon, 9 May 2022 14:15:10 +0000 (10:15 -0400)]
Enum conversion warning when one signed and other unsigned.

Ensures an -Wenum-conversion warning happens when one of the enums is
signed and the other is unsigned. Also adds a test file to verify these
warnings.

This warning would not happen since the -Wsign-conversion would make a
diagnostic then return, never allowing the -Wenum-conversion checks.

For example:

C
enum PE { P = -1 };
enum NE { N };
enum NE conv(enum PE E) { return E; }
Before this would only create a diagnostic with -Wsign-conversion and
never on -Wenum-conversion. Now it will create a diagnostic for both
-Wsign-conversion and -Wenum-conversion.

I could change it to just warn on -Wenum-conversion as that was what I
initially did. Seeing PR35200 (or GitHub Issue 316268), I let both
diagnostics check so that the sign conversion could generate a warning.

2 years ago[clang] Recognize scope of thread local variables in CFGBuilder
Krzysztof Parzyszek [Mon, 9 May 2022 13:32:54 +0000 (06:32 -0700)]
[clang] Recognize scope of thread local variables in CFGBuilder

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

2 years ago[Frontend] when attaching a preamble, don't generate the long predefines buffer.
Sam McCall [Sat, 7 May 2022 22:50:10 +0000 (00:50 +0200)]
[Frontend] when attaching a preamble, don't generate the long predefines buffer.

We know we're going to overwrite it anyway.
It'd be a bit of work to coordinate not generating it at all, but setting this
flag avoids generating ~10k of the 13k string.

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

2 years ago[analyzer] Inline operator delete when MayInlineCXXAllocator is set.
Fred Tingaud [Mon, 9 May 2022 13:08:09 +0000 (15:08 +0200)]
[analyzer] Inline operator delete when MayInlineCXXAllocator is set.

This patch restores the symmetry between how operator new and operator delete
are handled by also inlining the content of operator delete when possible.

Patch by Fred Tingaud.

Reviewed By: martong

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

2 years ago[riscv, InsertVSETVLI] Rename InstrInfo to Require to more clearly indicate purpose...
Philip Reames [Mon, 9 May 2022 13:38:58 +0000 (06:38 -0700)]
[riscv, InsertVSETVLI] Rename InstrInfo to Require to more clearly indicate purpose [nfc]

2 years agoThread safety analysis: Handle compound assignment and ->* overloads
Aaron Puchert [Mon, 9 May 2022 13:34:09 +0000 (15:34 +0200)]
Thread safety analysis: Handle compound assignment and ->* overloads

Like regular assignment, compound assignment operators can be assumed to
write to their left-hand side operand. So we strengthen the requirements
there. (Previously only the default read access had been required.)

Just like operator->, operator->* can also be assumed to dereference the
left-hand side argument, so we require read access to the pointee. This
will generate new warnings if the left-hand side has a pt_guarded_by
attribute. This overload is rarely used, but it was trivial to add, so
why not. (Supporting the builtin operator requires changes to the TIL.)

Reviewed By: aaron.ballman

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

2 years ago[clangd] Skip (most) predefined macros when scanning for preamble patching.
Sam McCall [Sat, 7 May 2022 21:40:27 +0000 (23:40 +0200)]
[clangd] Skip (most) predefined macros when scanning for preamble patching.

This is unneccesary work.
With this change, we skip generating and lexing ~10k of predefines twice.

A dumb benchmark of building a preamble for an empty file in a loop shows:
 - before: 1.90ms/run
 - after: 1.36ms/run
So this should be worth 0.5ms for each AST build and code completion.

There can be a functional difference, but it's very minor.
If the preamble contains e.g. `#ifndef __llvm__ ... #endif` then before we would
not take it. After this change we will take the branch (single-file mode takes
all branches with unknown conditions) and so gather different directives.

However I think this is negligible:
 - this is already true of non-builtin macros (from included headers).
   We've had no complaints.
 - this affects the baseline and modified in the same way, so only makes a
   difference transiently when code guarded by such an #ifdef is being edited

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

2 years ago"Re-apply 4b6c2cd642 "Deferred Concept Instantiation Implementation""""
Erich Keane [Thu, 5 May 2022 15:35:13 +0000 (08:35 -0700)]
"Re-apply 4b6c2cd642 "Deferred Concept Instantiation Implementation""""

This includes a fix for the libc++ issue I ran across with friend
declarations not properly being identified as overloads.

This reverts commit 45c07db31cc76802a1a2e41bed1ce9c1b8198181.

2 years ago[flang] Fix windows bot after D125140
Jean Perier [Mon, 9 May 2022 13:23:46 +0000 (15:23 +0200)]
[flang] Fix windows bot after D125140

The ifdef is not required in the header, common::int128_t is always
defined. The function declaration must be available in lowering
regardless of the host int128_t support.

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

2 years ago[riscv] Fix state tracking bug on vsetvli (phi of vsetvli) peephole
Philip Reames [Mon, 9 May 2022 13:20:24 +0000 (06:20 -0700)]
[riscv] Fix state tracking bug on vsetvli (phi of vsetvli) peephole

This fixes the first of several cases where the state computed in phase 1 and 2 of the algorithm differs from the state computed during phase 3. Note that such differences can cause miscompiles by creating disagreements about contents of the VL and VTYPE registers at block boundaries.

In this particular case, we recognize that for the first vsetvli in a block, that if the AVL is a phi of GPR results from previous vsetvlis and the VTYPE field matches, we can avoid emitting a vsetvli as the register contents don't change. Unfortunately, the abstract state does change and that update was lost.

As noted in the test change, this can actually improve results by preserving information until later state transitions in the block. However, this minor codegen improvement is not the motivation for the patch. The motivation is to avoid cases a case where we break a key internal correctness invariant.

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

2 years ago[demangler] No need to space adjacent template closings
Nathan Sidwell [Mon, 28 Mar 2022 19:38:24 +0000 (12:38 -0700)]
[demangler] No need to space adjacent template closings

With the demangler parenthesizing 'a >> b' inside template parameters,
because C++11 parsing of >> there, we don't really need to add spaces
between adjacent template arg closing '>' chars.  In 2022, that just
looks odd.

Reviewed By: MaskRay

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

2 years ago[DAG] Use isAnyConstantBuildVector. NFC
David Green [Mon, 9 May 2022 13:13:03 +0000 (14:13 +0100)]
[DAG] Use isAnyConstantBuildVector. NFC

As suggested from 02f8519502447de, this uses the
isAnyConstantBuildVector method in lieu of separate
isBuildVectorOfConstantSDNodes calls. It should
otherwise be an NFC.

2 years ago[ScalarEvolution] Fold %x umin_seq %y if %x cannot be zero
Nikita Popov [Mon, 9 May 2022 13:01:27 +0000 (15:01 +0200)]
[ScalarEvolution] Fold %x umin_seq %y if %x cannot be zero

Fold %x umin_seq %y to %x umin %y if %x cannot be zero. They only
differ in semantics for %x==0.

More generally %x *_seq %y folds to %x * %y if %x cannot be the
saturation fold (though currently we only have umin_seq).

2 years ago[X86] Replace avx512f integer mul reduction builtins with generic builtin
Simon Pilgrim [Mon, 9 May 2022 13:10:17 +0000 (14:10 +0100)]
[X86] Replace avx512f integer mul reduction builtins with generic builtin

D117829 added the generic "__builtin_reduce_mul" which we can use to replace the x86 specific integer mul reduction builtins - internally these were mapping to the same intrinsic already so there are no test changes required.

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

2 years ago[ScalarEvolution] Add tests for umin_seq with non-zero operand (NFC)
Nikita Popov [Mon, 9 May 2022 13:02:41 +0000 (15:02 +0200)]
[ScalarEvolution] Add tests for umin_seq with non-zero operand (NFC)

2 years ago[AArch64][SVE] Improve codegen when extracting first lane of active lane mask
Rosie Sumpter [Mon, 9 May 2022 08:35:13 +0000 (09:35 +0100)]
[AArch64][SVE] Improve codegen when extracting first lane of active lane mask

When extracting the first lane of a predicate created using the
llvm.get.active.lane.mask intrinsic, it should give the same codegen as
when the predicate is created using the llvm.aarch64.sve.whilelo
intrinsic, since get.active.lane.mask is lowered to whilelo. This patch
ensures the codegen is the same by recognizing
llvm.get.active.lane.mask as a flag-setting operation in this case.

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

2 years ago[clangd] Rewrite TweakTesting helpers to avoid reparsing the same code. NFC
Sam McCall [Fri, 6 May 2022 17:51:59 +0000 (19:51 +0200)]
[clangd] Rewrite TweakTesting helpers to avoid reparsing the same code. NFC

Previously the EXPECT_AVAILABLE macros would rebuild the code at each marked
point, by expanding the cases textually.
There were often lots, and it's nice to have lots!

This reduces total unittest time by ~10% on my machine.
I did have to sacrifice a little apply() coverage in AddUsingTests (was calling
expandCases directly, which was otherwise unused), but we have
EXPECT_AVAILABLE tests covering that, I don't think there's real risk here.

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

2 years agoRecommit "[SimpleLoopUnswitch] Collect either logical ANDs/ORs but not both."
Florian Hahn [Mon, 9 May 2022 12:49:12 +0000 (13:49 +0100)]
Recommit "[SimpleLoopUnswitch] Collect either logical ANDs/ORs but not both."

This reverts commit 7211d5ce07830ebfa2cfc30818cd7155375f7e47.

This version fixes a crash that caused buildbot failures with the first
version.

2 years ago[SimpleLoopUnswitch] Add test case for crash with db7a87ed4fa7.
Florian Hahn [Mon, 9 May 2022 12:48:56 +0000 (13:48 +0100)]
[SimpleLoopUnswitch] Add test case for crash with db7a87ed4fa7.

2 years ago[clangd] Skip extra round-trip in parsing args in debug builds. NFC
Sam McCall [Sat, 7 May 2022 15:31:52 +0000 (17:31 +0200)]
[clangd] Skip extra round-trip in parsing args in debug builds. NFC

This is a clever cross-cutting sanity test for clang's arg parsing I suppose.
But clangd creates thousands of invocations, ~all with identical trivial
arguments, and problems with these would be caught by clang's tests.
This overhead accounts for 10% of total unittest time!

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

2 years ago[clangd] Disable predefined macros in tests. NFC
Sam McCall [Sat, 7 May 2022 17:02:29 +0000 (19:02 +0200)]
[clangd] Disable predefined macros in tests. NFC

These aren't needed. With them the generated predefines buffer is 13KB.
For every TestTU, we must:
 - generate the buffer (3 times: parsing preamble, scanning preamble, main file)
 - parse the buffer (again 3 times)
 - serialize all the macros it defines in the PCH
 - compress the buffer itself to write it into the PCH
 - decompress it from the PCH

Avoiding this reduces unit test time by ~25%.

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

2 years ago[NFC][LoopVectorize] Add SVE test for tail-folding combined with interleaving
David Sherwood [Thu, 5 May 2022 08:48:31 +0000 (09:48 +0100)]
[NFC][LoopVectorize] Add SVE test for tail-folding combined with interleaving

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

2 years ago[demangler] Buffer peeking needs buffer
Nathan Sidwell [Mon, 28 Mar 2022 19:38:48 +0000 (12:38 -0700)]
[demangler] Buffer peeking needs buffer

The output buffer has a 'back' member, which returns NUL when you try
it with an empty buffer.  But there are no use cases that need that
additional functionality.  This makes the 'back' member behave more
like STL containers' back members.  (It still returns a value, not a
reference.)

Reviewed By: dblaikie

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

2 years ago[Clang] Add integer mul reduction builtin
Simon Pilgrim [Mon, 9 May 2022 10:53:27 +0000 (11:53 +0100)]
[Clang] Add integer mul reduction builtin

Similar to the existing bitwise reduction builtins, this lowers to a llvm.vector.reduce.mul intrinsic call.

For other reductions, we've tried to share builtins for float/integer vectors, but the fmul reduction intrinsic also take a starting value argument and can either do unordered or serialized, but not reduction-trees as specified for the builtins. However we address fmul support this shouldn't affect the integer case.

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

2 years ago[clang-tidy][NFC] Replace many instances of std::string where a StringRef would suffice.
Nathan James [Mon, 9 May 2022 11:01:45 +0000 (12:01 +0100)]
[clang-tidy][NFC] Replace many instances of std::string where a StringRef would suffice.

There's many instances in clang tidy checks where owning strings are used when we already have a stable string from the options, so using a StringRef makes much more sense.

Reviewed By: aaron.ballman

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

2 years agoFilter non-external static members from SBType::GetFieldAtIndex.
Sigurur sgeirsson [Mon, 9 May 2022 09:53:23 +0000 (11:53 +0200)]
Filter non-external static members from SBType::GetFieldAtIndex.

See [[ https://github.com/llvm/llvm-project/issues/55040 | issue 55040 ]] where static members of classes declared in the anonymous namespace are incorrectly returned as member fields from lldb::SBType::GetFieldAtIndex(). It appears that attrs.member_byte_offset contains a sentinel value for members that don't have a DW_AT_data_member_location.

Reviewed By: labath

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

2 years ago[SVE] Optimize new cases for lowerConvertToSVBool
Alban Bridonneau [Mon, 9 May 2022 10:15:54 +0000 (10:15 +0000)]
[SVE] Optimize new cases for lowerConvertToSVBool

Converts to SVBool are already considered as a nop, if they
are converting an operand from a ptrue or a cmp, because
they zero the extra predicate lanes by construction.

This patch adds 2 similar cases:
- The wide cmp, which were not directly recognized by the test
for other forms of cmp
- Splats of 1, which will be generated as ptrue, and as such
will also zero the extra predicate lines.

Reviewed By: paulwalker-arm, peterwaller-arm

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

2 years ago[mlir][math] Promote (b)f16 to f32 when lowering to libm calls
Benjamin Kramer [Fri, 6 May 2022 13:34:44 +0000 (15:34 +0200)]
[mlir][math] Promote (b)f16 to f32 when lowering to libm calls

libm doesn't have overloads for the small types, so promote them to a
bigger type and use the f32 function.

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

2 years ago[lldb/DWARF] Fix linking direction in CopyUniqueClassMethodTypes
Pavel Labath [Mon, 25 Apr 2022 09:24:45 +0000 (11:24 +0200)]
[lldb/DWARF] Fix linking direction in CopyUniqueClassMethodTypes

IIUC, the purpose of CopyUniqueClassMethodTypes is to link together
class definitions in two compile units so that we only have a single
definition of a class. It does this by adding entries to the die_to_type
and die_to_decl_ctx maps.

However, the direction of the linking seems to be reversed. It is taking
entries from the class that has not yet been parsed, and copying them to
the class which has been parsed already -- i.e., it is a very
complicated no-op.

Changing the linking order allows us to revert the changes in D13224
(while keeping the associated test case passing), and is sufficient to
fix PR54761, which was caused by an undesired interaction with that
patch.

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

2 years ago[libcxx] [test] Fix the nasty_macros test on Windows on ARM/ARM64
Martin Storsjö [Wed, 4 May 2022 18:59:40 +0000 (21:59 +0300)]
[libcxx] [test] Fix the nasty_macros test on Windows on ARM/ARM64

This isn't a configuration that we unfortunately can add to
the CI practically at the moment, but I do run the tests
sporadically offline in this configuration.

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

2 years ago[clang-format] Correctly handle SpaceBeforeParens for builtins.
Marek Kurdej [Fri, 6 May 2022 09:27:14 +0000 (11:27 +0200)]
[clang-format] Correctly handle SpaceBeforeParens for builtins.

That's a partial fix for https://github.com/llvm/llvm-project/issues/55292.

Before, known builtins behaved differently from other identifiers:
```
void f () { return F (__builtin_LINE() + __builtin_FOO ()); }
```
After:
```
void f () { return F (__builtin_LINE () + __builtin_FOO ()); }
```

Reviewed By: owenpan

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

2 years ago[AArch64] Ampere1 does not support MTE
Philipp Tomsich [Sun, 8 May 2022 19:40:28 +0000 (21:40 +0200)]
[AArch64] Ampere1 does not support MTE

The initial support for the Ampere1 mistakenly signalled support for
the MTE feature.  However, the core does not include the optional MTE
functionality.

Update the target parser to not include MTE for Ampere1.

Reviewed By: dmgreen

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

2 years ago[AArch64] Generate AND in place of CSEL for predicated CTTZ
Rahul Anand R [Mon, 9 May 2022 09:28:20 +0000 (10:28 +0100)]
[AArch64] Generate AND in place of CSEL for predicated CTTZ

This patch implements a for a target specific optimization that replaces
the cmp and csel from cttz with an and mask.

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

2 years agoRevert "[lldb] parallelize calling of Module::PreloadSymbols()"
Pavel Labath [Mon, 9 May 2022 09:07:03 +0000 (11:07 +0200)]
Revert "[lldb] parallelize calling of Module::PreloadSymbols()"

This reverts commit b7d807dbcff0d9df466e0312b4fef57178d207be -- it
breaks TestMultipleDebuggers.py.

2 years ago[ConstraintElimination] Add initial ssub.with.overflow tests.
Florian Hahn [Mon, 9 May 2022 09:02:59 +0000 (10:02 +0100)]
[ConstraintElimination] Add initial ssub.with.overflow tests.

2 years ago[clang-format] Fix WhitespaceSensitiveMacros not being honoured when macro closing...
Marek Kurdej [Wed, 13 Apr 2022 12:06:57 +0000 (14:06 +0200)]
[clang-format] Fix WhitespaceSensitiveMacros not being honoured when macro closing parenthesis is followed by a newline.

Fixes https://github.com/llvm/llvm-project/issues/54522.

This fixes regression introduced in https://github.com/llvm/llvm-project/commit/5e5efd8a91f2e340e79a73bedbc6ab66ad4a4281.

Before the culprit commit, macros in WhitespaceSensitiveMacros were correctly formatted even if their closing parenthesis weren't followed by semicolon (or, to be precise, when they were followed by a newline).
That commit changed the type of the macro token type from TT_UntouchableMacroFunc to TT_FunctionLikeOrFreestandingMacro.

Correct formatting (with `WhitespaceSensitiveMacros = ['FOO']`):
```
FOO(1+2)
FOO(1+2);
```

Regressed formatting:
```
FOO(1 + 2)
FOO(1+2);
```

Reviewed By: HazardyKnusperkeks, owenpan, ksyx

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

2 years ago[DAG] Prevent infinite loop combining bitcast shuffle
David Green [Mon, 9 May 2022 08:36:22 +0000 (09:36 +0100)]
[DAG] Prevent infinite loop combining bitcast shuffle

This prevents an infinite loop from D123801, where code trying to reduce
the total number of bitcasts, but also handling constants, could create
the opposite transform. Prevent the transform in these case to let the
bitcast of a constant transform naturally.

Fixes #55345

2 years ago[AVR] Add PrintMethod for operand memspi
Ben Shi [Mon, 9 May 2022 08:31:24 +0000 (08:31 +0000)]
[AVR] Add PrintMethod for operand memspi

Reviewed By: Patryk27

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

2 years ago[AMDGPU] Regenerate checks in a mir test
Abinav Puthan Purayil [Sun, 8 May 2022 18:16:43 +0000 (23:46 +0530)]
[AMDGPU] Regenerate checks in a mir test

2 years ago[flang] retain binding label of entry subprograms
Jean Perier [Mon, 9 May 2022 07:49:11 +0000 (09:49 +0200)]
[flang] retain binding label of entry subprograms

When processing an entry-stmt in name resolution, attrs_ was
reset before SetBindNameOn was called, causing the symbol to lose
the binding label information.

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

2 years ago[CSSPGO][Preinliner] Use linear threshold to drive inline decision.
Hongtao Yu [Mon, 9 May 2022 05:05:54 +0000 (22:05 -0700)]
[CSSPGO][Preinliner] Use linear threshold to drive inline decision.

The per-callsite size threshold used today to drive preinline decision is based on hotness/coldness cutoff. The default setup is for callsites with a sample count above the hotness cutoff (99%), a 1500 size threshold is used. Any callsite below 99.99% coldness cutoff uses a zero threshold. This has a couple issues:

1. While both cutoffs and size thoresholds are configurable, different applications may need different setups, making a universal setup impractical.

2. The callsites between hotness cutoff and coldness cutoff are not considered as inline candidates, which could be a missing opportunity.

3. Hot callsites always use the same threshold. In reality we may want a bigger threshold for hotter callsites.

In this change we are introducing a linear threshold regardless of hot/cold cutoffs. Given a sample space, a threshold is computed for a callsite based on the position of that callsite sample in the whole space. With that we no longer need to define what's hot or cold. Callsites with different hotness will get a different threshold. This should overcome the above three issues.

I have seen good results with a universal default setup for two of our internal services.

For one service, 0.2% to 0.5% perf improvement over a baseline with a previous default setup, on-par code size.
For the second service, 0.5% to 0.8% perf improvement over a baseline with a previous default setup, 0.2% code size increase; on-par performance and code size with a baseline that is with a carefully tuned cutoff to cover enough hot functions.

Reviewed By: wenlei

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

2 years ago[mlir][NvGpu] Fix nvgpu.mma.sync lowering to NVVM for f32, tf32 types
Christopher Bate [Thu, 5 May 2022 17:35:48 +0000 (11:35 -0600)]
[mlir][NvGpu] Fix nvgpu.mma.sync lowering to NVVM for f32, tf32 types

Adds missing logic in the lowering from NvGPU to NVVM to support fp32
(in an accumulator operand) and tf32 (in multiplicand operand) types.
Fixes logic in one of the helper functions for converting the result
of a mma.sync operation with multiple 8x256bit output tiles, which is
the case for f32 outputs.

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

2 years ago[flang] Enforce a program not including more than one main program
Peixin-Qiao [Mon, 9 May 2022 02:47:47 +0000 (10:47 +0800)]
[flang] Enforce a program not including more than one main program

As Fortran 2018 5.2.2 states, a program shall consist of exactly one
main program. Add this semantic check.

Reviewed By: klausler

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

2 years ago[lld] Fix typo for processAux; NFC
Xiaodong Liu [Mon, 9 May 2022 02:19:38 +0000 (10:19 +0800)]
[lld] Fix typo for processAux; NFC

Reviewed By: MaskRay

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

2 years ago[BOLT][DWARF] Fix assert for split dwarf.
Alexander Yermolovich [Sun, 8 May 2022 00:56:48 +0000 (17:56 -0700)]
[BOLT][DWARF] Fix assert for split dwarf.

Fixing a small bug where it would assert if CU does not modify .debug_addr section.

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

2 years ago[SLP][X86] Add test coverage for PR50392 / Issue #49736
Simon Pilgrim [Sun, 8 May 2022 18:39:57 +0000 (19:39 +0100)]
[SLP][X86] Add test coverage for PR50392 / Issue #49736

2 years ago[libc][Obvious] Fix cmake usage of list PREPEND (unavailable pre-3.15).
Tue Ly [Sun, 8 May 2022 17:58:05 +0000 (13:58 -0400)]
[libc][Obvious] Fix cmake usage of list PREPEND (unavailable pre-3.15).

2 years ago[libc] Add LINK_LIBRARIES option to add_fp_unittest and add_libc_unittest.
Tue Ly [Thu, 5 May 2022 22:58:24 +0000 (22:58 +0000)]
[libc] Add LINK_LIBRARIES option to add_fp_unittest and add_libc_unittest.

This is needed to prepare for adding FLAGS option.

Reviewed By: sivachandra

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

2 years ago[X86] Add test coverage for PR26515 / Issue #26889
Simon Pilgrim [Sun, 8 May 2022 17:19:04 +0000 (18:19 +0100)]
[X86] Add test coverage for PR26515 / Issue #26889

2 years ago[docs] Add Office Hours for Tobias Grosser
Groverkss [Sun, 8 May 2022 15:44:31 +0000 (21:14 +0530)]
[docs] Add Office Hours for Tobias Grosser

2 years ago[X86] Set some more plausible latencies for horizontal add/subs on znver1
Simon Pilgrim [Sun, 8 May 2022 14:48:42 +0000 (15:48 +0100)]
[X86] Set some more plausible latencies for horizontal add/subs on znver1

These are all microcoded/multi-pipe nightmares on Ryzen, but we shouldn't just be using the WriteMicrocoded class which is for REALLY bad microcoded nightmares - instead use the same approximate latencies as znver2 (Agner and uops.info both suggest similar values) - and make sure we use the FPU defs for both

Fixes #53242

2 years ago[DAG] Only perform the fold (A-B)+(C-D) --> (A+C)-(B+D) when both inner subs have...
Simon Pilgrim [Sun, 8 May 2022 12:51:58 +0000 (13:51 +0100)]
[DAG] Only perform the fold (A-B)+(C-D) --> (A+C)-(B+D) when both inner subs have one use

Fixes #51381

2 years ago[X86] combine-add.ll - add test case for PR52039 / Issue #51381
Simon Pilgrim [Sun, 8 May 2022 12:45:19 +0000 (13:45 +0100)]
[X86] combine-add.ll - add test case for PR52039 / Issue #51381

Also split AVX1/AVX2 test coverage

2 years ago[X86][AMX] Simplify AMX test case.
Luo, Yuanke [Sun, 8 May 2022 11:10:24 +0000 (19:10 +0800)]
[X86][AMX] Simplify AMX test case.

Extract test for zero tile configure into a small test case.

2 years ago[SLP][X86] Add test coverage for PR42652 / Issue #41997
Simon Pilgrim [Sun, 8 May 2022 11:09:14 +0000 (12:09 +0100)]
[SLP][X86] Add test coverage for PR42652 / Issue #41997

2 years ago[SLP][X86] Add test coverage for PR41892 / Issue #41237
Simon Pilgrim [Sun, 8 May 2022 10:40:53 +0000 (11:40 +0100)]
[SLP][X86] Add test coverage for PR41892 / Issue #41237

2 years ago[SLP][X86] Add test coverage for PR49934 / Issue #49278
Simon Pilgrim [Sun, 8 May 2022 10:33:01 +0000 (11:33 +0100)]
[SLP][X86] Add test coverage for PR49934 / Issue #49278

D124284 should help us vectorize the sub-128-bit vector cases

2 years ago[SLP][X86] Add test coverage for PR47491 / Issue #46835
Simon Pilgrim [Sun, 8 May 2022 10:24:46 +0000 (11:24 +0100)]
[SLP][X86] Add test coverage for PR47491 / Issue #46835

D124284 should help us vectorize the sub-128-bit vector cases

2 years ago[InstCombine] Add test coverage for PR43261 / Issue #42606
Simon Pilgrim [Sun, 8 May 2022 10:10:49 +0000 (11:10 +0100)]
[InstCombine] Add test coverage for PR43261 / Issue #42606

2 years ago[Headers][X86] Enable basic Wdocumentation testing on X86 headers
Simon Pilgrim [Sun, 8 May 2022 09:53:28 +0000 (10:53 +0100)]
[Headers][X86] Enable basic Wdocumentation testing on X86 headers

First part of Issue #35297 - we want to enable Wdocumentation-pedantic as well, but need '\n' support first which Issue #55319 is addressing