platform/upstream/llvm.git
2 years ago[mlir][NFC] Move Translation.h to a Tools/mlir-translate directory
River Riddle [Sat, 5 Mar 2022 20:27:00 +0000 (12:27 -0800)]
[mlir][NFC] Move Translation.h to a Tools/mlir-translate directory

Translation.h is currently awkwardly shoved into the top-level mlir, even though it is
specific to the mlir-translate tool. This commit moves it to a new Tools/mlir-translate
directory, which is intended for libraries used to implement tools. It also splits the
translate registry from the main entry point, to more closely mirror what mlir-opt
does.

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

2 years ago[mlir][NFC] Move MlirOptMain to the Tools/ directory
River Riddle [Fri, 4 Mar 2022 21:49:30 +0000 (13:49 -0800)]
[mlir][NFC] Move MlirOptMain to the Tools/ directory

MlirOptMain is currently awkwardly shoved into mlir/Support. This commit
moves it to the Tools/ directory, which is intended for libraries used to
implement tools.

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

2 years ago[mlir][NFC] Move Parser.h to Parser/
River Riddle [Fri, 4 Mar 2022 20:53:22 +0000 (12:53 -0800)]
[mlir][NFC] Move Parser.h to Parser/

There is no reason for this file to be at the top-level, and
its current placement predates the Parser/ folder's existence.

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

2 years ago[ConstraintElimination] Remove dead variables when dropping constraints.
Florian Hahn [Mon, 7 Mar 2022 09:03:48 +0000 (09:03 +0000)]
[ConstraintElimination] Remove dead variables when dropping constraints.

This patch extends ConstraintElimination to also remove dead variables
when removing a constraint. When a constraint is removed because it is
out of scope, all new variables added for this constraint can also be
removed.

This keeps the total size of the systems much smaller, because it
reduces the number of variables drastically.

It also fixes a bug where variables where removed incorrectly.

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

2 years ago[ConstraintElimination] Add test from PR54228.
Florian Hahn [Mon, 7 Mar 2022 09:03:42 +0000 (09:03 +0000)]
[ConstraintElimination] Add test from PR54228.

Test for https://github.com/llvm/llvm-project/issues/54228

2 years ago[X86] Update some of the AVX512 intrinsic tests to avoid adds.
Luo, Yuanke [Mon, 7 Mar 2022 08:51:42 +0000 (16:51 +0800)]
[X86] Update some of the AVX512 intrinsic tests to avoid adds.

As noticed in D119654, by adding the masked intrinsics results together
we can end up with the selects being canonicalized away from the
intrinsic - this isn't what we want to test here so replace with a
insertvalue chain into a aggregate instead to retain all the results.

2 years ago[VP] Introducing VectorBuilder, the VP intrinsic builder
Simon Moll [Mon, 7 Mar 2022 09:01:31 +0000 (10:01 +0100)]
[VP] Introducing VectorBuilder, the VP intrinsic builder

VectorBuilder wraps around an IRBuilder and
VectorBuilder::createVectorInstructions emits VP intrinsics as if they
were regular instructions.

Reviewed By: craig.topper

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

2 years ago[Attributor] Remove function pointer restriction for AAAlign
Nikita Popov [Thu, 3 Mar 2022 14:41:06 +0000 (15:41 +0100)]
[Attributor] Remove function pointer restriction for AAAlign

This check is not compatible with opaque pointers. We can avoid
it by adjusting the getPointerAlignment() implementation to avoid
creating unnecessary ptrtoint expressions for bitcasted pointers.
The code already uses OnlyIfReduced to not create an expression
if it does not simplify, and this makes sure that folding a
bitcast and ptrtoint into a ptrtoint doesn't count as a
simplification.

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

2 years ago[AArch64] Use NPM for cost model tests. NFC
David Green [Mon, 7 Mar 2022 08:57:50 +0000 (08:57 +0000)]
[AArch64] Use NPM for cost model tests. NFC

As per the other tests, this switches the run lines back to using the
NPM via
-passes='print<cost-model>' -cost-kind=throughput 2>&1 -disable-output

2 years ago[SCEV] Enable verification under EXPENSIVE_CHECKS
Nikita Popov [Mon, 28 Feb 2022 10:18:18 +0000 (11:18 +0100)]
[SCEV] Enable verification under EXPENSIVE_CHECKS

SCEV verification should no longer affect results of subsequent
queries, and our lit tests as well as llvm-test-suite pass with
SCEV verification enabled, so I think we can enable it by default
under EXPENSIVE_CHECKS now.

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

2 years ago[LoongArch] Add EncoderMethods for transformed immediate operands
Weining Lu [Mon, 7 Mar 2022 08:38:30 +0000 (16:38 +0800)]
[LoongArch] Add EncoderMethods for transformed immediate operands

This is a split patch of D120476 and thanks to myhsu.

'Transformed' means the encoding of an immediate is not the same as
its binary representation. For example, the `bl` instruction
requires a signed 28-bits integer as its operand and the low 2 bits
must be 0. So only the upper 26 bits are needed to get encoded into
the instruction.

Based on the above reason this kind of immediate needs a customed
`EncoderMethod` to get the real value getting encoded into the
instruction.

Currently these immediate includes:
```
  uimm2_plus1
  simm14_lsl2
  simm16_lsl2
  simm21_lsl2
  simm26_lsl2
```

This patch adds those `EncoderMethod`s and revises related .mir test
in previous patch.

Reviewed By: xen0n, MaskRay

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

2 years ago[SCEV] Enable verification in LoopPM
Nikita Popov [Fri, 25 Feb 2022 10:30:01 +0000 (11:30 +0100)]
[SCEV] Enable verification in LoopPM

Currently, we hardly ever actually run SCEV verification, even in
tests with -verify-scev. This is because the NewPM LPM does not
verify SCEV. The reason for this is that SCEV verification can
actually change the result of subsequent SCEV queries, which means
that you see different transformations depending on whether
verification is enabled or not.

To allow verification in the LPM, this limits verification to
BECounts that have actually been cached. It will not calculate
new BECounts.

BackedgeTakenInfo::getExact() is still not entirely readonly,
it still calls getUMinFromMismatchedTypes(). But I hope that this
is not problematic in the same way. (This could be avoided by
performing the umin in the other SCEV instance, but this would
require duplicating some of the code.)

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

2 years ago[mlir] Use empty() instead of checking size() == 0 (NFC)
Adrian Kuegel [Mon, 7 Mar 2022 08:40:49 +0000 (09:40 +0100)]
[mlir] Use empty() instead of checking size() == 0 (NFC)

2 years ago[SCEV] Fully invalidate SCEVUnknown on RAUW
Nikita Popov [Thu, 17 Feb 2022 09:03:58 +0000 (10:03 +0100)]
[SCEV] Fully invalidate SCEVUnknown on RAUW

When a SCEVUnknown gets RAUWd, we currently drop it from the folding
set, but don't forget memoized values. I believe we should be
treating RAUW the same way as deletion here and invalidate all
caches and dependent expressions.

I don't have any specific cases where this causes issues right now,
but it does address the FIXME in https://reviews.llvm.org/D119488.

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

2 years ago[clang][parser] Stop dragging an EndLoc around when parsing attributes
Timm Bäder [Thu, 3 Mar 2022 11:13:48 +0000 (12:13 +0100)]
[clang][parser] Stop dragging an EndLoc around when parsing attributes

It's almost always entirely unused and if it is used, the end of the
attribute range can be used instead.

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

2 years ago[MLIR] Change call sites from deprecated `parseSourceFile()` to `parseSourceFile...
Christian Sigg [Sun, 6 Mar 2022 19:55:59 +0000 (20:55 +0100)]
[MLIR] Change call sites from deprecated `parseSourceFile()` to `parseSourceFile<ModuleOp>()`.

Mark `parseSourceFile()` deprecated. The functions will be removed two weeks after landing this change.

Reviewed By: rriddle

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

2 years ago[Attributor] Determine potentially loaded values through memory
Johannes Doerfert [Sun, 6 Mar 2022 23:37:47 +0000 (17:37 -0600)]
[Attributor] Determine potentially loaded values through memory

We already look through memory to determine where a value that is stored
might pop up again (potential copies). This patch introduces the other
direction with similar logic. If a value is loaded, we can follow all
the accesses to the pointer (or better object) and try to determine what
value might have been stored.

2 years ago[Attributor] Handle undef and null in AAAlignFloating
Johannes Doerfert [Mon, 7 Mar 2022 01:16:35 +0000 (19:16 -0600)]
[Attributor] Handle undef and null in AAAlignFloating

Both `undef` and `nullptr` are maximally aligned. This is especially
important as we often see `undef` until a proper value has been
identified during simplification.

2 years ago[Attributor] Use CFG reasoning also for read accesses
Johannes Doerfert [Tue, 1 Mar 2022 21:22:53 +0000 (15:22 -0600)]
[Attributor] Use CFG reasoning also for read accesses

With D106397 we used CFG reasoning to filter out writes that will not
interfere with a given load instruction. With this patch we use the
same logic (modulo the reversal in reachability check order) for store
instructions. As an example, we can now proof stores to shared memory
are dead if all the loads of the shared memory are not reachable from
them.

2 years ago[Attributor] Improve isValidAtPosition (mostly for old PM)
Johannes Doerfert [Fri, 25 Feb 2022 22:44:24 +0000 (16:44 -0600)]
[Attributor] Improve isValidAtPosition (mostly for old PM)

To minimize the test difference between old and new PM we perform some
local dominance check if no dominator tree is available.

2 years ago[PowerPC] Add generic fnmsub intrinsic
Qiu Chaofan [Mon, 7 Mar 2022 05:00:06 +0000 (13:00 +0800)]
[PowerPC] Add generic fnmsub intrinsic

Currently in Clang, we have two types of builtins for fnmsub operation:
one for float/double vector, they'll be transformed into IR operations;
one for float/double scalar, they'll generate corresponding intrinsics.

But for the vector version of builtin, the 3 op chain may be recognized
as expensive by some passes (like early cse). We need some way to keep
the fnmsub form until code generation.

This patch introduces ppc.fnmsub.* intrinsic to unify four fnmsub
intrinsics.

Reviewed By: shchenz

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

2 years ago[Attributor][NFCI] Introduce fine-grained anonymous namespaces
Johannes Doerfert [Fri, 25 Feb 2022 00:52:21 +0000 (18:52 -0600)]
[Attributor][NFCI] Introduce fine-grained anonymous namespaces

2 years ago[Attributor][OpenMPOpt][FIX] Register simplification callbacks
Johannes Doerfert [Fri, 25 Feb 2022 00:45:52 +0000 (18:45 -0600)]
[Attributor][OpenMPOpt][FIX] Register simplification callbacks

Heap-2-stack and heap-2-shared can replace an allocation call with
something else. To avoid us deriving information from the allocator
implementation we register a simplification callback now that will
force us to stop at the call site. We probably should create the
replacement memory eagerly and return that instead though.

2 years ago[Attributor][FIX] Use maximal access for dereferenceability deduction
Johannes Doerfert [Thu, 24 Feb 2022 23:29:31 +0000 (17:29 -0600)]
[Attributor][FIX] Use maximal access for dereferenceability deduction

While we can use range information when we derive dereferenceability we
must make sure to pick he right end of the range. Before we always went
with the minimal offset, which is not correct if we want to combine
the base dereferenceability with some offset. In that case it's the
maximum that gives the correct result.

2 years ago[Attributor][FIX] Initialize stack variable
Johannes Doerfert [Thu, 24 Feb 2022 23:27:11 +0000 (17:27 -0600)]
[Attributor][FIX] Initialize stack variable

2 years agoRevert "[OpenMP][NFCI] Use RAII lock guards in libomptarget where possible"
Johannes Doerfert [Mon, 7 Mar 2022 03:27:41 +0000 (21:27 -0600)]
Revert "[OpenMP][NFCI] Use RAII lock guards in libomptarget where possible"

This reverts commit ff50e81b500800708db927cbccca2ab52ec11884 as it broke
the buildbots, see https://reviews.llvm.org/D121060#3362737.

2 years ago[RISCV] Fix incorrect optimization for masked vmsgeu.vi with 0 immediate.
Zakk Chen [Sun, 6 Mar 2022 23:05:13 +0000 (15:05 -0800)]
[RISCV] Fix incorrect optimization for masked vmsgeu.vi with 0 immediate.

vmsgeu.vi with 0 is always true, but in the masked with mask undisturbed
policy, we still need to keep inactive elelemt which come from maskedoff.

We could return mask directly if it's mask agnostic policy in the future.

Reviewed By: craig.topper

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

2 years ago[OpenMP][NFCI] Use RAII lock guards in libomptarget where possible
Johannes Doerfert [Wed, 2 Mar 2022 19:34:24 +0000 (13:34 -0600)]
[OpenMP][NFCI] Use RAII lock guards in libomptarget where possible

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

2 years ago[Attributor][NFCI] No repeated manifest of AAValueSimplifyReturned (CGSCC)
Johannes Doerfert [Mon, 7 Feb 2022 23:04:39 +0000 (17:04 -0600)]
[Attributor][NFCI] No repeated manifest of AAValueSimplifyReturned (CGSCC)

2 years ago[Attributor][NFC] Expose helper with more generic interface
Johannes Doerfert [Mon, 7 Feb 2022 22:13:02 +0000 (16:13 -0600)]
[Attributor][NFC] Expose helper with more generic interface

This simply makes the function argument of the
`Attributor::checkForAllInstructions` helper explicit so one can iterate
over instructions in other functions.

2 years ago[Attributor][NFC] Improve debug messages
Johannes Doerfert [Mon, 7 Feb 2022 21:24:59 +0000 (15:24 -0600)]
[Attributor][NFC] Improve debug messages

2 years ago[OpenMPIRBuilder] Allocate temporary at the correct block in a nested parallel
William S. Moses [Sat, 5 Mar 2022 23:04:19 +0000 (18:04 -0500)]
[OpenMPIRBuilder] Allocate temporary at the correct block in a nested parallel

The OpenMPIRBuilder has a bug. Specifically, suppose you have two nested openmp parallel regions (writing with MLIR for ease)

```
omp.parallel {
  %a = ...
  omp.parallel {
    use(%a)
  }
}
```

As OpenMP only permits pointer-like inputs, the builder will wrap all of the inputs into a stack allocation, and then pass this
allocation to the inner parallel. For example, we would want to get something like the following:

```
omp.parallel {
  %a = ...
  %tmp = alloc
  store %tmp[] = %a
  kmpc_fork(outlined, %tmp)
}
```

However, in practice, this is not what currently occurs in the context of nested parallel regions. Specifically to the OpenMPIRBuilder,
the entirety of the function (at the LLVM level) is currently inlined with blocks marking the corresponding start and end of each
region.

```
entry:
  ...

parallel1:
  %a = ...
  ...

parallel2:
  use(%a)
  ...

endparallel2:
  ...

endparallel1:
  ...
```

When the allocation is inserted, it presently inserted into the parent of the entire function (e.g. entry) rather than the parent
allocation scope to the function being outlined. If we were outlining parallel2, the corresponding alloca location would be parallel1.

This causes a variety of bugs, including https://github.com/llvm/llvm-project/issues/54165 as one example.

This PR allows the stack allocation to be created at the correct allocation block, and thus remedies such issues.

Reviewed By: jdoerfert

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

2 years ago[mlir][support] Fix msvc build.
Michael Kruse [Sun, 6 Mar 2022 22:22:09 +0000 (16:22 -0600)]
[mlir][support] Fix msvc build.

Add typename keyword to help the C++ parser to disambiguate dependent
qualified name after D120852/1c941d. Fixes the msvc build.

2 years ago[clang-format] NFC update LLVM overall clang-formatted status
mydeveloperday [Sun, 6 Mar 2022 20:02:11 +0000 (20:02 +0000)]
[clang-format] NFC update LLVM overall clang-formatted status

A 1% increase in the number of clang-formatted files.

An additional 530 files have been added to LLVM, and an additional
450 files are now clang-format clean. Raising the overall % to 53%

There are now 8857 files clean out of 16432 (ignoring lit tests)

2 years ago[DAG] Don't convert undef to 0 when creating buildvector
David Green [Sun, 6 Mar 2022 18:35:34 +0000 (18:35 +0000)]
[DAG] Don't convert undef to 0 when creating buildvector

When inserting undef into buildvectors created from shuffles of
buildvectors, we convert elements to the largest needed type. This had
the effect of converting undef into 0, which isn't needed as the
buildvector implicitly truncates and trunc(zext(undef)) == undef.

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

2 years ago[Hexagon] Move single-use global tables into their only user and turn them into Strin...
Benjamin Kramer [Sun, 6 Mar 2022 18:22:31 +0000 (19:22 +0100)]
[Hexagon] Move single-use global tables into their only user and turn them into StringSwitch

Delete the unused globals. NFCI.

2 years ago[X86] Update AVX512-BW mask intrinsic tests to avoid adds
Simon Pilgrim [Sun, 6 Mar 2022 17:23:51 +0000 (17:23 +0000)]
[X86] Update AVX512-BW mask intrinsic tests to avoid adds

As noticed in D119654, by adding the masked intrinsics results together we can end up with the selects being canonicalized away from the intrinsic - this isn't what we want to test here so replace with a insertvalue chain into a aggregate instead to retain all the results.

2 years ago[X86] Update AVX512 rotate intrinsic tests to avoid adds
Simon Pilgrim [Sun, 6 Mar 2022 17:05:44 +0000 (17:05 +0000)]
[X86] Update AVX512 rotate intrinsic tests to avoid adds

As noticed in D119654, by adding the masked intrinsics results together we can end up with the selects being canonicalized away from the intrinsic - this isn't what we want to test here so replace with a insertvalue chain into a aggregate instead to retain all the results.

2 years ago[X86] Update AVX512-VNNI mask intrinsic tests to avoid adds
Simon Pilgrim [Sun, 6 Mar 2022 16:58:29 +0000 (16:58 +0000)]
[X86] Update AVX512-VNNI mask intrinsic tests to avoid adds

As noticed in D119654, by adding the masked intrinsics results together we can end up with the selects being canonicalized away from the intrinsic - this isn't what we want to test here so replace with a insertvalue chain into a aggregate instead to retain all the results.

2 years agoDrop some more global std::maps. NFCI.
Benjamin Kramer [Sun, 6 Mar 2022 12:24:42 +0000 (13:24 +0100)]
Drop some more global std::maps. NFCI.

2 years ago[LoopSink] Do not try to sink phi nodes.
Florian Hahn [Sun, 6 Mar 2022 11:14:41 +0000 (11:14 +0000)]
[LoopSink] Do not try to sink phi nodes.

Skip phi nodes in the preheader. They may not be considered loop
invariant by the assertion below.

Reviewed By: reames

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

2 years ago[MLIR][Presburger][NFC] Fix PresburgerLocalSpace::print() output
Groverkss [Sun, 6 Mar 2022 11:12:20 +0000 (16:42 +0530)]
[MLIR][Presburger][NFC] Fix PresburgerLocalSpace::print() output

This change puts a colon before before the printing number of locals in
PresburgerLocalSpace::print().

2 years ago[Clang] Use = default(NFC)
Jun Zhang [Sun, 6 Mar 2022 05:01:49 +0000 (13:01 +0800)]
[Clang] Use = default(NFC)

2 years ago[RISCV] Add SimplifyDemandedBits support for FSR/FSL/FSRW/FSLW.
Craig Topper [Sun, 6 Mar 2022 05:26:28 +0000 (21:26 -0800)]
[RISCV] Add SimplifyDemandedBits support for FSR/FSL/FSRW/FSLW.

2 years ago[OpenMP][CMake] Ensure linking against libm for Linux
James Beddek [Sun, 6 Mar 2022 04:20:28 +0000 (20:20 -0800)]
[OpenMP][CMake] Ensure linking against libm for Linux

Do the same as is done for NetBSD. Some compiler-rt/lib/builtins files call
libm functions (e.g. fmaxl, fabs). Linking libomp with --rtlib=compiler-rt
references these functions.
Downstream report: https://bugs.gentoo.org/816831

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

2 years ago[OpenMP][CMake] Clean up the CMake variable `LIBOMPTARGET_LLVM_INCLUDE_DIRS`
Shilei Tian [Sun, 6 Mar 2022 03:37:46 +0000 (22:37 -0500)]
[OpenMP][CMake] Clean up the CMake variable `LIBOMPTARGET_LLVM_INCLUDE_DIRS`

`LIBOMPTARGET_LLVM_INCLUDE_DIRS` is currently checked and included for
multiple times redundantly. This patch is simply a clean up.

Reviewed By: jhuber6

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

2 years ago[libcxx][atomic] Remove workaround for PR31864
Kai Luo [Sun, 6 Mar 2022 00:55:22 +0000 (00:55 +0000)]
[libcxx][atomic] Remove workaround for PR31864

I believe the origin issue in PR31864 has been addressed by https://reviews.llvm.org/D59566.

As discussed in https://github.com/llvm/llvm-project/issues/53840, `ATOMIC_LLONG_LOCK_FREE == 2` sometimes is not consistent with `std::atomic<long long>::is_always_lock_free`, since the macro takes `long long`'s ABI alignment into account. https://reviews.llvm.org/D28213 proposed we should not rely on ABI alignment of types, thus we have consistent `ATOMIC_LLONG_LOCK_FREE` and `std::atomic<long long>::is_always_lock_free` on x86's old cpu. Currently, I plan to move on to remove the workaround which should have been addressed and don't want to break current tests.

Reviewed By: #libc, ldionne, Quuxplusone

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

2 years ago[YAML] Simplify code a bit. NFC.
Benjamin Kramer [Sat, 5 Mar 2022 21:24:20 +0000 (22:24 +0100)]
[YAML] Simplify code a bit. NFC.

2 years ago[clang-format] Handle goto labels for RemoveBracesLLVM
owenca [Sat, 5 Mar 2022 07:45:50 +0000 (23:45 -0800)]
[clang-format] Handle goto labels for RemoveBracesLLVM

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

2 years ago[IVDescriptor] Remove SinkCandidate from SinkAfter before re-sinking.
Florian Hahn [Sat, 5 Mar 2022 19:46:27 +0000 (19:46 +0000)]
[IVDescriptor] Remove SinkCandidate from SinkAfter before re-sinking.

This ensures the right order in the sink-after map is maintained. If we
re-sink an instruction, it must be sunk after all earlier instructions
have been sunk.

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

2 years agoMake ParsedAttrInfo and subclasses use constexpr construction
Benjamin Kramer [Sat, 5 Mar 2022 19:32:37 +0000 (20:32 +0100)]
Make ParsedAttrInfo and subclasses use constexpr construction

This removes a 30 kB global initializer. NFCI.

2 years ago[OpenMP] libomp: omp_in_explicit_task() implemented.
AndreyChurbanov [Sat, 5 Mar 2022 18:46:39 +0000 (21:46 +0300)]
[OpenMP] libomp: omp_in_explicit_task() implemented.

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

2 years ago[AArch64] Some tests to show reconstructing truncates. NFC
David Green [Sat, 5 Mar 2022 18:35:43 +0000 (18:35 +0000)]
[AArch64] Some tests to show reconstructing truncates. NFC

2 years agoDrop iostream include, which is forbidden in LLVM
Benjamin Kramer [Sat, 5 Mar 2022 18:31:44 +0000 (19:31 +0100)]
Drop iostream include, which is forbidden in LLVM

2 years ago[libc++] Granularize <utility> includes
Nikolas Klauser [Sat, 5 Mar 2022 18:17:07 +0000 (19:17 +0100)]
[libc++] Granularize <utility> includes

Reviewed By: ldionne, #libc

Spies: EricWF, libcxx-commits, arphaman

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

2 years ago[OpenCL] Turn global vector into static array. NFCI.
Benjamin Kramer [Sat, 5 Mar 2022 18:16:01 +0000 (19:16 +0100)]
[OpenCL] Turn global vector into static array. NFCI.

2 years ago[clang-format] QualifierOrder does not reorder template arguments
mydeveloperday [Sat, 5 Mar 2022 18:07:16 +0000 (18:07 +0000)]
[clang-format] QualifierOrder does not reorder template arguments

https://github.com/llvm/llvm-project/issues/53981

Reorder the qualifiers inside the template argument. This should handle the simple cases of

```
<const T>
<T const>
```

But only by relaxing that single letter capital variables are not possible macros

Fixes: #53981

Reviewed By: HazardyKnusperkeks, curdeius

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

2 years ago[libc++] Don't warn that coroutines aren't supported when including <experimental...
Nikolas Klauser [Thu, 3 Mar 2022 19:49:21 +0000 (20:49 +0100)]
[libc++] Don't warn that coroutines aren't supported when including <experimental/coroutine>

This change makes the behavior of `<experimental/coroutine>` consistent with other headers that only work conditionally.

Reviewed By: ldionne, #libc

Spies: Mordante, ChuanqiXu, libcxx-commits, arichardson

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

2 years ago[AArch64] fix i128-math.ll
Karl Meakin [Sat, 5 Mar 2022 17:51:58 +0000 (17:51 +0000)]
[AArch64] fix i128-math.ll

2 years ago[AArch64] Add test for i128 overflow/saturation ops (NFC)
Karl Meakin [Fri, 4 Mar 2022 18:31:50 +0000 (18:31 +0000)]
[AArch64] Add test for i128 overflow/saturation ops (NFC)

This test exposes opportunities for future optimization work

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

2 years ago[clang-format] Turn global COperatorsFollowingVar vector into a switch
Benjamin Kramer [Sat, 5 Mar 2022 16:59:05 +0000 (17:59 +0100)]
[clang-format] Turn global COperatorsFollowingVar vector into a switch

LLVM optimizes this into a bit test. NFCI.

2 years ago[SDAG] fold bitwise logic with shifted operands
Sanjay Patel [Fri, 4 Mar 2022 17:59:27 +0000 (12:59 -0500)]
[SDAG] fold bitwise logic with shifted operands

This extends acb96ffd149d to 'and' and 'xor' opcodes.

Copying from that message:

LOGIC (LOGIC (SH X0, Y), Z), (SH X1, Y) --> LOGIC (SH (LOGIC X0, X1), Y), Z

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

This is a reassociation + factoring fold. The common shift operation is moved
after a bitwise logic op on 2 input operands.
We get simpler cases of these patterns in IR, but I suspect we would miss all
of these exact tests in IR too. We also handle the simpler form of this plus
several other folds in DAGCombiner::hoistLogicOpWithSameOpcodeHands().

2 years ago[AArch64][x86] add tests for bitwise logic + shifts; NFC
Sanjay Patel [Fri, 4 Mar 2022 17:32:40 +0000 (12:32 -0500)]
[AArch64][x86] add tests for bitwise logic + shifts; NFC

Copy tests from ecf606cb4329ae and replace 'or' with 'xor' / 'and'.
This provides coverage for an enhancement of D120516 / acb96ffd149d

2 years ago[WebAssembly] Update WebAssemblyAsmTypeCheck for table.get
kamenokonokotan [Sat, 5 Mar 2022 15:34:28 +0000 (16:34 +0100)]
[WebAssembly] Update WebAssemblyAsmTypeCheck for table.get

This patch is aimed to resolve [[ https://github.com/llvm/llvm-project/issues/53789 | GitHub Issue #53789 ]].

Reviewed By: sbc100

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

2 years ago[RISCV] Fix incorrect codegen introduced by D119688.
Zakk Chen [Fri, 4 Mar 2022 03:44:46 +0000 (19:44 -0800)]
[RISCV] Fix incorrect codegen introduced by D119688.

We should not emit a tail agnostic vlse for a tail undisturbed vmv.s.x

In D119688:
-    if (IsScalarMove && !Node->getOperand(0).isUndef())
+    bool HasPassthruOperand = Node->getOpcode() != ISD::SPLAT_VECTOR;
+    if (HasPassthruOperand && !IsScalarMove &&
!Node->getOperand(0).isUndef())
       break;

The IsScalarMove check in the if statement had been changed.

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

2 years ago[RISCV][NFC] Precommit test cases for D120963.
Zakk Chen [Fri, 4 Mar 2022 03:43:17 +0000 (19:43 -0800)]
[RISCV][NFC] Precommit test cases for D120963.

2 years ago[NFC][Clang] Fix a couple of typos
Corentin Jabot [Sat, 5 Mar 2022 08:43:38 +0000 (09:43 +0100)]
[NFC][Clang] Fix a couple of typos

2 years ago[RISCV] Add CMOV isel pattern for (select (setgt X, -1), Y, Z)
Craig Topper [Sat, 5 Mar 2022 06:33:16 +0000 (22:33 -0800)]
[RISCV] Add CMOV isel pattern for (select (setgt X, -1), Y, Z)

setgt X, -1 is the canonical form of setge X, 0. We can swap the
select operands and use setlt X, X0 when selecting CMOV. This
avoid materializing the -1 in a register.

2 years ago[cmake] Pass /winsysroot explicitly
Shoaib Meenai [Sat, 5 Mar 2022 00:30:46 +0000 (16:30 -0800)]
[cmake] Pass /winsysroot explicitly

We were relying on HandleLLVMOptions adding this flag, but that's not
included in compiler-rt. Add the flag explicitly ourselves to ensure
it's present; the duplication of the flag in the parts of the build
which do include HandleLLVMOptions doesn't cause any issues.

Reviewed By: ychen

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

2 years ago[llvm-cov] New parameters to set coverage coverage_watermark
Petr Hosek [Sat, 5 Mar 2022 06:20:42 +0000 (22:20 -0800)]
[llvm-cov] New parameters to set coverage coverage_watermark

Add a pairs of parameters to set coverage watermark for llvm-cov, and
user can change the percentage thresholds marked with different colors
in the report.

Patch By: tanjinhua

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

2 years ago[RISCV] Support k-ext clang intrinsics
Shao-Ce SUN [Thu, 3 Mar 2022 14:12:02 +0000 (22:12 +0800)]
[RISCV] Support k-ext clang intrinsics

Reviewed By: craig.topper

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

2 years agoRevert "[polly] Fix regression test after D110620."
Arthur Eubanks [Sat, 5 Mar 2022 04:36:37 +0000 (20:36 -0800)]
Revert "[polly] Fix regression test after D110620."

This reverts commit 2aa624a94fa00ac5e9d34dbf549b016a8afd4d37.

D110620 was reverted.

2 years ago[libc++] Add _LIBCPP_HIDE_FROM_ABI to __quoted_proxy ctors.
Arthur O'Dwyer [Fri, 4 Mar 2022 23:29:39 +0000 (18:29 -0500)]
[libc++] Add _LIBCPP_HIDE_FROM_ABI to __quoted_proxy ctors.

ldionne says this looks right to him, too.

Reviewed as part of D120135.

2 years ago[libc++] [NFC] Formatting preliminary to D120135 (std::quoted)
Arthur O'Dwyer [Fri, 4 Mar 2022 23:15:20 +0000 (18:15 -0500)]
[libc++] [NFC] Formatting preliminary to D120135 (std::quoted)

This just gets some of the non-functional formatting out of the way
before the meat of D120135.

2 years ago[libc++] ADL-proof calls to __quoted and noskipws.
Arthur O'Dwyer [Fri, 4 Mar 2022 23:02:37 +0000 (18:02 -0500)]
[libc++] ADL-proof calls to __quoted and noskipws.

Reviewed as part of D120135.

2 years agoRevert "[SCEV] Infer ranges for SCC consisting of cycled Phis"
Arthur Eubanks [Fri, 4 Mar 2022 00:30:30 +0000 (16:30 -0800)]
Revert "[SCEV] Infer ranges for SCC consisting of cycled Phis"

This reverts commit fc539b0004d4fe8072aca00e38599a2300a955ce.

Causes miscompiles, see D110620.

2 years agoReland D119909 [ELF] Parallelize initializeLocalSymbols
Fangrui Song [Sat, 5 Mar 2022 03:00:10 +0000 (19:00 -0800)]
Reland D119909 [ELF] Parallelize initializeLocalSymbols

ObjFile::parse combines symbol initialization and resolution. Many tasks
unrelated to symbol resolution can be postponed and parallelized. This patch
extracts local symbol initialization and parallelizes it.

Technically the new function initializeLocalSymbols can be merged into
ObjFile::postParse, but functions like getSrcMsg may access the
uninitialized (all nullptr) local part of InputFile::symbols.

Linking chrome: 1.02x as fast with glibc malloc, 1.04x as fast with mimalloc

Depends on f456c3ae3f4182b23673929e8fe0aa18bcec4289 and D119908

Reviewed By: ikudrin

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

2 years ago[ELF] Move addWrappedSymbols before postParseObjectFile
Fangrui Song [Sat, 5 Mar 2022 02:56:37 +0000 (18:56 -0800)]
[ELF] Move addWrappedSymbols before postParseObjectFile

addWrappedSymbols may trigger archive extraction: split stack implementation
uses --wrap=pthread_create, which extracts libgcc.a(generic-morestack-thread.o).

This fixes the regression caused by 09602d3b47ec83abb2c26efa5a199c13b72c7abf by
making the invariant satisfied: no more non-compileBitcodeFiles object file is
produced at postParseObjectFile.

2 years ago[WebAssembly] Update Preprocessor/init.c test after 3be9e0ba972c
Thomas Lively [Sat, 5 Mar 2022 02:40:10 +0000 (18:40 -0800)]
[WebAssembly] Update Preprocessor/init.c test after 3be9e0ba972c

2 years ago[RISCV] Move vslide1up/down intrinsics into lowerVectorIntrinsicSplats. NFC
Craig Topper [Sat, 5 Mar 2022 01:44:29 +0000 (17:44 -0800)]
[RISCV] Move vslide1up/down intrinsics into lowerVectorIntrinsicSplats. NFC

Rename to lowerVectorIntrinsicScalars.

This allows us to share the code that checks if the scalar needs
to be type legalized.

2 years ago[CMake] Replace `TARGET_TRIPLE` with `TOOLCHAIN_TARGET_TRIPLE` for Win-to-Arm cross...
Vladimir Vereschaka [Sat, 5 Mar 2022 00:36:57 +0000 (16:36 -0800)]
[CMake] Replace `TARGET_TRIPLE` with `TOOLCHAIN_TARGET_TRIPLE` for Win-to-Arm cross toolchain cache file. NFC.

Avoid using TARGET_TRIPLE argument for the cross toolchain cmake cache file and replace it
with TOOLCHAIN_TARGET_TRIPLE.

Reference: https://reviews.llvm.org/D119918

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

2 years ago[RISCV] Merge more rv32/rv64 vector intrinsic tests that contain the same content.
Craig Topper [Fri, 4 Mar 2022 19:57:39 +0000 (11:57 -0800)]
[RISCV] Merge more rv32/rv64 vector intrinsic tests that contain the same content.

Use sed to convert iXLen to i32/i64 before running the test.

2 years ago[lldb/Test] Fix test_launch_scripted_process_stack_frames failure
Med Ismail Bennani [Sat, 5 Mar 2022 00:22:53 +0000 (16:22 -0800)]
[lldb/Test] Fix test_launch_scripted_process_stack_frames failure

This should fix the test_launch_scripted_process_stack_frames GreenDragon
test failure : https://green.lab.llvm.org/green/job/lldb-cmake/41901

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2 years ago[WebAssembly] Check bulk-memory when adjusting lang opts
Thomas Lively [Sat, 5 Mar 2022 00:07:16 +0000 (16:07 -0800)]
[WebAssembly] Check bulk-memory when adjusting lang opts

We previously had logic to disable pthreads, set the ThreadModel to Single, and
disable thread-safe statics when the atomics target features is disabled, since
that means that the resulting program will not be used in a threaded context.
Similarly check for the presence of the bulk-memory feature, since that is also
necessary to produce multithreaded programs.

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

2 years ago[clang-format] fix namepsace format when the name is macro expansion
Zequan Wu [Thu, 3 Mar 2022 19:59:57 +0000 (11:59 -0800)]
[clang-format] fix namepsace format when the name is macro expansion

Originally filed at crbug.com/1184570.
When the name of a namespace is a macro that takes arguments,
- It fixed the indentation.
- It fixed the namepsace end comments.

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

2 years ago[Docs] List __has_feature(dataflow_sanitizer) in LanguageExtensions docs.
Andrew Browne [Fri, 4 Mar 2022 23:45:55 +0000 (15:45 -0800)]
[Docs] List __has_feature(dataflow_sanitizer) in LanguageExtensions docs.

2 years ago[MSAN] extend ioctl interceptor to support BLKSSZGET
Kevin Athey [Fri, 4 Mar 2022 22:08:36 +0000 (14:08 -0800)]
[MSAN] extend ioctl interceptor to support BLKSSZGET

Reviewed By: eugenis

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

2 years ago[mlir][Pass] Add support for an InterfacePass and pass filtering based on OperationName
River Riddle [Thu, 3 Mar 2022 01:54:32 +0000 (17:54 -0800)]
[mlir][Pass] Add support for an InterfacePass and pass filtering based on OperationName

This commit adds a new hook Pass `bool canScheduleOn(RegisteredOperationName)` that
indicates if the given pass can be scheduled on operations of the given type. This makes it
easier to define constraints on generic passes without a) adding conditional checks to
the beginning of the `runOnOperation`, or b) defining a new pass type that forwards
from `runOnOperation` (after checking the invariants) to a new hook. This new hook is
used to implement an `InterfacePass` pass class, that represents a  generic pass that
runs on operations of the given interface type.

The PassManager will also verify that passes added to a pass manager can actually be
scheduled on that pass manager, meaning that we will properly error when an Interface
is scheduled on an operation that doesn't actually implement that interface.

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

2 years agoRevert "[ELF] Parallelize initializeLocalSymbols"
Jorge Gorbe Moya [Fri, 4 Mar 2022 22:02:20 +0000 (14:02 -0800)]
Revert "[ELF] Parallelize initializeLocalSymbols"

This reverts commit 09602d3b47ec83abb2c26efa5a199c13b72c7abf.

2 years ago[lldb/Test] Disable test_scripted_process_and_scripted_thread on Windows
Med Ismail Bennani [Fri, 4 Mar 2022 22:21:56 +0000 (14:21 -0800)]
[lldb/Test] Disable test_scripted_process_and_scripted_thread on Windows

This disables TestScriptedProcess.test_scripted_process_and_scripted_thread
on Windows since the inferior binary a linked to a dylib that doesn't
build on Windows.

This should fix https://lab.llvm.org/buildbot/#/builders/83/builds/16100

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2 years ago[libcxx] Fix the ctype `is` (pointer version) function for Windows
Martin Storsjö [Fri, 21 Jan 2022 23:21:31 +0000 (23:21 +0000)]
[libcxx] Fix the ctype `is` (pointer version) function for Windows

Previously, this test snippet would report incorrect information:

    F::mask m;
    std::wstring in(L"\u00DA"); // LATIN CAPITAL LETTER U WITH ACUTE
    f.is(in.data(), in.data() + 1, &m);
    // m & F::lower would be set

The single-character version of the `is` function wasn't
affected by this issue though.

Define `_LIBCPP_CTYPE_MASK_IS_COMPOSITE_ALPHA` for Windows,
as the `alpha` / `_ALPHA` constant is a mask consisting of
multiple bits set, which avoids setting `alpha` whenver any
of the bits is set, in the `do_is` implementation.

On Windows, with the "C" locale, wchars are classified according
to their Unicode interpretation, just as in the en_US.UTF-8 locale on
all platforms.

Due to the differing classification of some characters, the
`scan_is` and `scan_not` tests are quite annoying to fix, thus just
ifdef out some of the tests for the "C" locale there - the code gets
tested with the more standard en_US.UTF-8 locale anyway.

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

2 years ago[libc++] [LWG3656] Update the return type of std::bit_width.
Arthur O'Dwyer [Thu, 24 Feb 2022 01:08:28 +0000 (20:08 -0500)]
[libc++] [LWG3656] Update the return type of std::bit_width.

Fixes LWG3656, "Inconsistent bit operations returning a count".
https://cplusplus.github.io/LWG/issue3656

The fix has been approved for C++23 and left to vendors' discretion
in C++20 (but it sounds like everyone's on the same page that
of course it should be DR'ed back to C++20 too).

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

2 years ago[mlir][sparse] fix mlir-window build breakage
Aart Bik [Fri, 4 Mar 2022 21:26:56 +0000 (13:26 -0800)]
[mlir][sparse] fix mlir-window build breakage

Reviewed By: bixia

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

2 years agoUpdate references to the mailing list to reference Discourse. Also update references...
Tanya Lattner [Fri, 4 Mar 2022 22:27:07 +0000 (14:27 -0800)]
Update references to the mailing list to reference Discourse. Also update references to LLVM Bugzilla as we have moved to GitHub issues.

Reviewed By: lattner

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

2 years ago[mlir] RegionBranchOpInterface should be verifyWithRegions
Mogball [Fri, 4 Mar 2022 22:25:18 +0000 (22:25 +0000)]
[mlir] RegionBranchOpInterface should be verifyWithRegions

2 years agoRevert "Reland [SROA] Maintain shadow/backing alloca when some slices are noncapturni...
Roman Lebedev [Fri, 4 Mar 2022 22:08:11 +0000 (01:08 +0300)]
Revert "Reland [SROA] Maintain shadow/backing alloca when some slices are noncapturnig read-only calls to allow alloca partitioning/promotion"

There seems to be one more uncaught problem, SROA may now end up trying
to re-re-repromote the just-promoted shadow alloca, and do that endlessly.

This reverts commit adc0984d81f570ecc38ea23e7f556b95c7831e4c.

2 years ago[mlir][ods] Save the Enum info in EnumAttr
Mogball [Fri, 4 Mar 2022 21:59:14 +0000 (21:59 +0000)]
[mlir][ods] Save the Enum info in EnumAttr

2 years ago[mlir] NFC fix missing dependency on Async
Mogball [Fri, 4 Mar 2022 21:58:17 +0000 (21:58 +0000)]
[mlir] NFC fix missing dependency on Async

2 years agoObjectFile: add a case for `EM_RISCV`
Saleem Abdulrasool [Fri, 4 Mar 2022 21:50:54 +0000 (21:50 +0000)]
ObjectFile: add a case for `EM_RISCV`

This adds the jump slot mapping for RISCV.  This enables lldb to attach to a
remote debug server.  Although this doesn't enable debugging RISCV targets, it
is sufficient to attach, which is a slight improvement.

Tested with DebugServer2:
~~~
(lldb) gdb-remote localhost:1234
(lldb) Process 71438 stopped
* thread #1, name = 'reduced', stop reason = signal SIGTRAP
    frame #0: 0x0000003ff7fe1b20

error: Process 71438 is currently being debugged, kill the process before connecting.
(lldb) register read
general:
        x0 = 0x0000003ff7fe1b20
        x1 = 0x0000002ae00d3a50
        x2 = 0x0000003ffffff3e0
        x3 = 0x0000002ae01566e0
        x4 = 0x0000003fe567c7b0
        x5 = 0x0000000000001000
        x6 = 0x0000002ae00604ec
        x7 = 0x00000000000003ff
        x8 = 0x0000003fffc22db0
        x9 = 0x0000000000000000
       x10 = 0x0000000000000000
       x11 = 0x0000002ae603b1c0
       x12 = 0x0000002ae6039350
       x13 = 0x0000000000000000
       x14 = 0x0000002ae6039350
       x15 = 0x0000002ae6039350
       x16 = 0x73642f74756f3d5f
       x17 = 0x00000000000000dd
       x18 = 0x0000002ae6038f08
       x19 = 0x0000002ae603b1c0
       x20 = 0x0000002b0f3d3f40
       x21 = 0x0000003ff0b212d0
       x22 = 0x0000002b0f3a2740
       x23 = 0x0000002b0f3de3a0
       x24 = 0x0000002b0f3d3f40
       x25 = 0x0000002ad6929850
       x26 = 0x0000000000000000
       x27 = 0x0000002ad69297c0
       x28 = 0x0000003fe578b364
       x29 = 0x000000000000002f
       x30 = 0x0000000000000000
       x31 = 0x0000002ae602401a
        pc = 0x0000003ff7fe1b20
       ft0 = 0
       ft1 = 0
       ft2 = 0
       ft3 = 0
       ft4 = 0
       ft5 = 0
       ft6 = 0
       ft7 = 0
       fs0 = 0
       fs1 = 0
       fa0 = 0
       fa1 = 0
       fa2 = 0
       fa3 = 0
       fa4 = 0
       fa5 = 0
       fa6 = 0
       fa7 = 9.10304232197721e-313
       fs2 = 0
       fs3 = 1.35805727667792e-312
       fs4 = 1.35589259164679e-312
       fs5 = 1.35805727659887e-312
       fs6 = 9.10304232355822e-313
       fs7 = 0
       fs8 = 9.10304233027751e-313
       fs9 = 0
      fs10 = 9.10304232948701e-313
      fs11 = 1.35588724164707e-312
       ft8 = 0
       ft9 = 9.1372158616833e-313
      ft10 = 9.13720376537528e-313
      ft11 = 1.356808717416e-312
3 registers were unavailable.

(lldb) disassemble
error: Failed to disassemble memory at 0x3ff7fe1b2
~~~

2 years agoReapply "[cmake] Prefix gtest and gtest_main with "llvm_"."
Stella Laurenzo [Fri, 4 Mar 2022 20:08:04 +0000 (12:08 -0800)]
Reapply "[cmake] Prefix gtest and gtest_main with "llvm_"."

This reverts commit 7cdda6b8ce49ae3c90c068cff4dc355bba5d77f2.

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