platform/upstream/llvm.git
2 years agoApply clang-tidy fixes for modernize-use-emplace to MLIR (NFC)
Mehdi Amini [Mon, 7 Mar 2022 10:12:44 +0000 (10:12 +0000)]
Apply clang-tidy fixes for modernize-use-emplace to MLIR (NFC)

2 years agoApply clang-tidy fixes for modernize-use-default-member-init to MLIR (NFC)
Mehdi Amini [Mon, 7 Mar 2022 10:12:43 +0000 (10:12 +0000)]
Apply clang-tidy fixes for modernize-use-default-member-init to MLIR (NFC)

2 years agoApply clang-tidy fixes for modernize-loop-convert to MLIR (NFC)
Mehdi Amini [Mon, 7 Mar 2022 10:12:39 +0000 (10:12 +0000)]
Apply clang-tidy fixes for modernize-loop-convert to MLIR (NFC)

2 years agoApply clang-tidy fixes for llvm-qualified-auto to MLIR (NFC)
Mehdi Amini [Mon, 7 Mar 2022 10:12:38 +0000 (10:12 +0000)]
Apply clang-tidy fixes for llvm-qualified-auto to MLIR (NFC)

2 years agoApply clang-tidy fixes for bugprone-macro-parentheses to MLIR (NFC)
Mehdi Amini [Mon, 7 Mar 2022 10:12:37 +0000 (10:12 +0000)]
Apply clang-tidy fixes for bugprone-macro-parentheses to MLIR (NFC)

2 years ago[CoroElide] Remove fallback for frame layout determination
Nikita Popov [Fri, 4 Mar 2022 12:07:58 +0000 (13:07 +0100)]
[CoroElide] Remove fallback for frame layout determination

Only determine the frame layout based on dereferenceable and align
attributes, and remove the type-based fallback, which is incompatible
with opaque pointers. The dereferenceable attribute is required,
while the align attribute uses default alignment of 1 (commonly,
align 1 attributes do not get placed, relying on default alignment).

The CoroSplit pass producing the resume function adds the necessary
attributes in https://github.com/llvm/llvm-project/blob/7daed359111f6d151fef447f520f85ef1dabedf6/llvm/lib/Transforms/Coroutines/CoroSplit.cpp#L840,
and their presence is checked in coro-debug.ll at least.

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

2 years ago[clang][modules] Fix failing test
Jan Svoboda [Mon, 7 Mar 2022 10:21:06 +0000 (11:21 +0100)]
[clang][modules] Fix failing test

This test started failing on Windows after b45888e959ad2d6562b8d321166e6387facdd412 due to path separators not matching up.

2 years agoRemove Simon Atanasyan from the code owners list. MIPS Backend.
Simon Atanasyan [Mon, 7 Mar 2022 10:08:12 +0000 (13:08 +0300)]
Remove Simon Atanasyan from the code owners list. MIPS Backend.

2 years ago[Coroutines] Allow FramePtr to be an Argument
Nikita Popov [Fri, 4 Mar 2022 14:09:57 +0000 (15:09 +0100)]
[Coroutines] Allow FramePtr to be an Argument

With opaque pointers, after splitRetconCoroutine() the FramePtr
may be an Argument rather than an Instruction. With typed pointers,
this currently doesn't happen because the FramePtr would be a
bitcast instruction.

Fix this by making FramePtr a Value and adding a helper for the
"after FramePtr" insertion point, which would be the start of the
function in the Argument case.

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

2 years ago[clang][modules] Report module maps affecting `no_undeclared_includes` modules
Jan Svoboda [Mon, 7 Mar 2022 09:22:06 +0000 (10:22 +0100)]
[clang][modules] Report module maps affecting `no_undeclared_includes` modules

Since D106876, PCM files don't report module maps as input files unless they contributed to the compilation.

Reporting only module maps of (transitively) imported modules is not enough, though. For modules marked with `[no_undeclared_includes]`, other module maps affect the compilation by introducing anti-dependencies.

This patch makes sure such module maps are being reported as input files.

Depends on D120463.

Reviewed By: dexonsmith

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

2 years ago[clang][modules] NFC: Simplify and clarify test
Jan Svoboda [Mon, 7 Mar 2022 09:21:30 +0000 (10:21 +0100)]
[clang][modules] NFC: Simplify and clarify test

This patch simplifies a test that checks only used module map files are reported as input files in PCM files.

Instead of using opaque `diff`, this patch uses `clang -module-file-info` and `FileCheck` to verify this.

Reviewed By: dexonsmith

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

2 years ago[AArch64] Turn truncating buildvectors into truncates
David Green [Mon, 7 Mar 2022 09:42:54 +0000 (09:42 +0000)]
[AArch64] Turn truncating buildvectors into truncates

When lowering large v16f32->v16i8 fp_to_si_sat, the fp_to_si_sat node is
split several times, creating an illegal v4i8 concat that gets expanded
into a BUILD_VECTOR. After some combining and other legalisation, it
ends up the a buildvector that extracts from 4 vectors, looking like
BUILDVECTOR(a0,a1,a2,a3,b0,b1,b2,b3,c0,c1,c2,c3,d0,d1,d2,d3). That is
really an v16i32->v16i8 truncate in disguise.

This adds a ReconstructTruncateFromBuildVector method to detect the
pattern, converting it back into the legal "concat(trunc(concat(trunc(a),
trunc(b))), trunc(concat(trunc(c), trunc(d))))" tree. The extracted
nodes could also be v4i16, in which case the truncates are not needed.
All those truncates and concats then become uzip1's, which is much
better than expanding by moving vector lanes around.

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

2 years ago[libc] Fix alignment logic in TLS image size calculation.
Siva Chandra Reddy [Mon, 7 Mar 2022 05:56:04 +0000 (05:56 +0000)]
[libc] Fix alignment logic in TLS image size calculation.

2 years ago[gn build] Port 5f62156762d4
LLVM GN Syncbot [Mon, 7 Mar 2022 09:08:13 +0000 (09:08 +0000)]
[gn build] Port 5f62156762d4

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.