platform/upstream/llvm.git
3 years ago[BasicAA] Handle PHIs without incoming values gracefully
Daniil Suchkov [Fri, 4 Jun 2021 23:17:02 +0000 (23:17 +0000)]
[BasicAA] Handle PHIs without incoming values gracefully

Fix a bug introduced by f6f6f6375d1a4bced8a6e79a78726ab32b8dd879.
Now for empty PHIs, instead of crashing on assert(hasVal()) in
Optional's internals, we'll return NoAlias, as we did before that patch.

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

3 years ago[Test] Add a JumpThreading test exposing a bug in BasicAA.
Daniil Suchkov [Fri, 4 Jun 2021 22:55:35 +0000 (22:55 +0000)]
[Test] Add a JumpThreading test exposing a bug in BasicAA.

3 years agoRevert "[AArch64] handle -Wa,-march="
Jian Cai [Mon, 7 Jun 2021 21:30:32 +0000 (14:30 -0700)]
Revert "[AArch64] handle -Wa,-march="

This reverts commit fd11a26d368c5a909fb88548fef2cee7a6c2c931.

3 years ago[mlir-lsp-server] Fix bug in symbol use/def tracking
River Riddle [Mon, 7 Jun 2021 21:00:00 +0000 (14:00 -0700)]
[mlir-lsp-server] Fix bug in symbol use/def tracking

We were accidentally only using the first found reference, instead of all of them. This revision fixes this by properly tracking all references to a symbol.

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

3 years ago[mlir-lsp-server] Add support for hover on symbol references
River Riddle [Mon, 7 Jun 2021 20:59:50 +0000 (13:59 -0700)]
[mlir-lsp-server] Add support for hover on symbol references

For now the hover simply shows the same information as hovering on the operation
name. If necessary this can be tweaked to something symbol specific later.

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

3 years ago[mlir-lsp-server] Add support for hover on region operations
River Riddle [Mon, 7 Jun 2021 20:59:39 +0000 (13:59 -0700)]
[mlir-lsp-server] Add support for hover on region operations

This revision adds support for hover on region operations, by temporarily removing the regions during printing. This revision also tweaks the hover format for operations to include symbol information, now that FuncOp can be shown in the hover.

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

3 years ago[lld/mac] Add reexports after reexporter to inputFiles
Nico Weber [Mon, 7 Jun 2021 15:00:34 +0000 (11:00 -0400)]
[lld/mac] Add reexports after reexporter to inputFiles

When a library "host"'s reexports change their installName with
`$ld$os10.11$install_name$host`, we used to write a load command for "host" but
write the version numbers of the reexport instead of "host". This fixes that.

I first thought that the rule is to take the version numbers from the library
that originally had that install name (implemented in D103819), but that's not
what ld64 seems to be doing: It takes the version number from the first dylib
with that install name it loads, and it loads the reexporting library before
the reexports. We already did most of that, we just added reexports before the
reexporter. After this change, we add the reexporter before the reexports.

Addresses https://bugs.llvm.org/show_bug.cgi?id=49800#c11 part 1.

(ld64 seems to add reexports after processing _all_ files on the command line,
while we add them right after the reexporter. For the common case of reexport +
$ld$ symbol changing back to the exporter name, this doesn't make a difference,
but you can construct a case where it does. I expect this to not make a
difference in practice though.)

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

3 years ago[ELF] getRelocatedSection: remove the check for ET_REL object file
Amir Ayupov [Mon, 7 Jun 2021 20:17:00 +0000 (13:17 -0700)]
[ELF] getRelocatedSection: remove the check for ET_REL object file

getRelocatedSection interface should not check that the object file is
relocatable, as executable files may have relocations preserved with
`--emit-relocs` linker flag. The relocations are useful in context of post-link
binary analysis for function reference identification. For example, BOLT relies
on relocations to perform function reordering.

Reviewed By: MaskRay, jhenderson

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

3 years ago[X32] Add Triple::isX32(), use it.
Harald van Dijk [Mon, 7 Jun 2021 19:48:39 +0000 (20:48 +0100)]
[X32] Add Triple::isX32(), use it.

So far, support for x86_64-linux-gnux32 has been handled by explicit
comparisons of Triple.getEnvironment() to GNUX32. This worked as long as
x86_64-linux-gnux32 was the only X32 environment to worry about, but we
now have x86_64-linux-muslx32 as well. To support this, this change adds
an isX32() function and uses it. It replaces all checks for GNUX32 or
MuslX32 by isX32(), except for the following:

- Triple::isGNUEnvironment() and Triple::isMusl() are supposed to treat
  GNUX32 and MuslX32 differently.
- computeTargetTriple() needs to be able to transform triples to add or
  remove X32 from the environment and needs to map GNU to GNUX32, and
  Musl to MuslX32.
- getMultiarchTriple() completely lacks any Musl support and retains the
  explicit check for GNUX32 as it can only return x86_64-linux-gnux32.

Reviewed By: MaskRay

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

3 years ago[clang] Fix reading long doubles with va_arg on x86_64 mingw
Martin Storsjö [Mon, 31 May 2021 20:55:26 +0000 (23:55 +0300)]
[clang] Fix reading long doubles with va_arg on x86_64 mingw

On x86_64 mingw, long doubles are always passed indirectly as
arguments (see an existing case in WinX86_64ABIInfo::classify);
generalize the existing code for reading varargs - any non-aggregate
type that is larger than 64 bits (which would be both long double
in mingw, and __int128) are passed indirectly too.

This makes reading varargs consistent with how they're passed,
fixing interop with both gcc and clang callers, for long double
and __int128.

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

3 years ago[LoopUnroll] Clamp unroll count to MaxTripCount
Nikita Popov [Sat, 5 Jun 2021 08:49:51 +0000 (10:49 +0200)]
[LoopUnroll] Clamp unroll count to MaxTripCount

Unrolling with more iterations than MaxTripCount is pointless, as
those iterations can never be executed. As such, we clamp ULO.Count
to MaxTripCount if it is known. This means we no longer need to
consider iterations after MaxTripCount for exit folding, and the
CompletelyUnroll flag becomes independent of ULO.TripCount.

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

3 years ago[OpenMP][runtime] add .clang-tidy file
Peyton, Jonathan L [Fri, 4 Jun 2021 19:26:08 +0000 (14:26 -0500)]
[OpenMP][runtime] add .clang-tidy file

Use same checks as compiler-rt which removes checks for readability-*
and llvm-header style.

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

3 years ago[OpenMP] libomp: implement OpenMP 5.1 inoutset task dependence type
AndreyChurbanov [Mon, 7 Jun 2021 18:42:51 +0000 (21:42 +0300)]
[OpenMP] libomp: implement OpenMP 5.1 inoutset task dependence type

Refactored code of dependence processing and added new inoutset dependence type.
Compiler can set dependence flag to 0x8 when call __kmpc_omp_task_with_deps.
Size of type of the dependence flag changed from 1 to 4 bytes in clang.
All dependence flags library gets so far and corresponding dependence types:
1 - IN, 2 - OUT, 3 - INOUT, 4 - MUTEXINOUTSET, 8 - INOUTSET.

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

3 years agoAMDGPU: Move codegen test out of MIR test directory
Matt Arsenault [Sat, 5 Jun 2021 23:10:38 +0000 (19:10 -0400)]
AMDGPU: Move codegen test out of MIR test directory

This is testing an actual pass, not the MIR parser/printer.

3 years agoGlobalISel: Use MMO helper for getting the size in bits
Matt Arsenault [Sun, 6 Jun 2021 15:41:48 +0000 (11:41 -0400)]
GlobalISel: Use MMO helper for getting the size in bits

3 years agoGlobalISel: Remove unnecessary .getReg(0)s
Matt Arsenault [Mon, 7 Jun 2021 18:11:52 +0000 (14:11 -0400)]
GlobalISel: Remove unnecessary .getReg(0)s

3 years ago[SCEV] Compute exit counts for unsigned IVs using mustprogress semantics
Philip Reames [Mon, 7 Jun 2021 18:16:23 +0000 (11:16 -0700)]
[SCEV] Compute exit counts for unsigned IVs using mustprogress semantics

The motivation here is simple loops with unsigned induction variables w/non-one steps. A toy example would be:
for (unsigned i = 0; i < N; i += 2) { body; }

Given C/C++ semantics, we do not get the nuw flag on the induction variable. Given that lack, we currently can't compute a bound for this loop. We can do better for many cases, depending on the contents of "body".

The basic intuition behind this patch is as follows:
* A step which evenly divides the iteration space must wrap through the same numbers repeatedly. And thus, we can ignore potential cornercases where we exit after the n-th wrap through uint32_max.
* Per C++ rules, infinite loops without side effects are UB. We already have code in SCEV which relies on this.  In LLVM, this is tied to the mustprogress attribute.

Together, these let us conclude that the trip count of this loop must come before unsigned overflow unless the body would form a well defined infinite loop.

A couple notes for those reading along:
* I reused the loop properties code which is overly conservative for this case. I may follow up in another patch to generalize it for the actual UB rules.
* We could cache the n(s/u)w facts. I left that out because doing a pre-patch which cached existing inference showed a lot of diffs I had trouble fully explaining. I plan to get back to this, but I don't want it on the critical path.

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

3 years ago[MLIR][GPU] Simplify memcpy of cast
William S. Moses [Sat, 5 Jun 2021 01:27:15 +0000 (21:27 -0400)]
[MLIR][GPU] Simplify memcpy of cast

Introduce a simplification that allows memcpy of a cast to simply use the underlying op

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

3 years ago[libc++] Rename 'and' to '&&'
Louis Dionne [Mon, 7 Jun 2021 17:48:45 +0000 (13:48 -0400)]
[libc++] Rename 'and' to '&&'

3 years ago[lld/mac] Add a test for -reexport_library + -dead_strip_dylibs
Nico Weber [Mon, 7 Jun 2021 14:22:25 +0000 (10:22 -0400)]
[lld/mac] Add a test for -reexport_library + -dead_strip_dylibs

Our behavior here already matched ld64, now we have a test for it.

(ld64 even strips the library here if you also pass -needed_library bar.dylib.
That seems wrong to me, and lld honors needed_library in that case.)

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

3 years ago[MLIR] Conditional Branch Argument Propagation
William S. Moses [Sun, 2 May 2021 04:08:24 +0000 (00:08 -0400)]
[MLIR] Conditional Branch Argument Propagation

In an operation in the true/false dest of a branch,
one can assume that the operation itself was true/false if
only that edge can reach the operation.

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

3 years ago[RISCV] Lower i8/i16 bswap/bitreverse to grevi/greviw with Zbp.
Craig Topper [Mon, 7 Jun 2021 17:21:53 +0000 (10:21 -0700)]
[RISCV] Lower i8/i16 bswap/bitreverse to grevi/greviw with Zbp.

Include known bits support so we know we don't need to zext the
output if the input was already zero extended.

Reviewed By: luismarques

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

3 years ago[RS4GC] Treat inttoptr as base pointer
Philip Reames [Mon, 7 Jun 2021 17:20:45 +0000 (10:20 -0700)]
[RS4GC] Treat inttoptr as base pointer

This is a modified version of a patch by tolziplohu with a style change, and most importantly, a revised commit message.

inttoptr for a non-integral address space is currently ill defined in the LangRef.  Figuring out exactly what the dynamic semantics of such a cast would be is hard, and not yet settled.  Despite that, we still need to go ahead and implement something in RS4GC for a couple of reasons.

First, as a simple consistency argument.  We're apparently added support for constexpr inttoptrs a while back, and even have tests which exercised them.  Having a lack of constant folding trigger a crash during lowering is non-ideal.

Second, and more fundementally, the optimizer is allowed to insert undefined constructs in unreachable code.  At the same time, we can't assume that dynamically dead code is always pruned before lowering.  As a result, we must assume that inttoptrs can occur (even if completely ill defined) along dead paths.  We need the lowering to not crash.  The stackmaps produced can be garbage (as the assumption is the code is dynamically dead), but the lowering itself can't crash.

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

3 years ago[XCOFF][AIX] Enable tooling support for 64 bit symbol table parsing
jasonliu [Mon, 7 Jun 2021 14:52:55 +0000 (14:52 +0000)]
[XCOFF][AIX] Enable tooling support for 64 bit symbol table parsing

Add in the ability of parsing symbol table for 64 bit object.

Reviewed By: jhenderson, DiggerLin

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

3 years ago[InstCombine] intersect nsz and ninf fast-math-flags (FMF) for fneg(fdiv) fold
Sanjay Patel [Mon, 7 Jun 2021 17:05:04 +0000 (13:05 -0400)]
[InstCombine] intersect nsz and ninf fast-math-flags (FMF) for fneg(fdiv) fold

https://alive2.llvm.org/ce/z/3KPvih

https://llvm.org/PR49654

3 years ago[InstCombine] refactor match clauses; NFC
Sanjay Patel [Mon, 7 Jun 2021 15:48:45 +0000 (11:48 -0400)]
[InstCombine] refactor match clauses; NFC

We need to adjust the FMF propagation on at least
one of these transforms as discussed in:
https://llvm.org/PR49654
...so this should make it easier to intersect flags.

3 years ago[InstCombine] add tests for FMF propagation via -(C/X); NFC
Sanjay Patel [Mon, 7 Jun 2021 14:42:28 +0000 (10:42 -0400)]
[InstCombine] add tests for FMF propagation via -(C/X); NFC

There are bugs here as discussed in:
https://llvm.org/PR49654

3 years ago[RISCV] Don't enable loop vectorizer interleaving if the V extension isn't enabled.
Craig Topper [Mon, 7 Jun 2021 06:31:43 +0000 (23:31 -0700)]
[RISCV] Don't enable loop vectorizer interleaving if the V extension isn't enabled.

This can cause the vectorizer to generate interleaved scalar
code which might be ok for some CPUs, but definitely not all.
Disable it to restore the previous scalar behavior.

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

3 years ago[Demangle][Rust] Parse instantiating crate
Tomasz Miąsko [Mon, 7 Jun 2021 17:11:16 +0000 (19:11 +0200)]
[Demangle][Rust] Parse instantiating crate

Reviewed By: dblaikie

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

3 years ago[AArch64] handle -Wa,-march=
Jian Cai [Mon, 7 Jun 2021 17:12:13 +0000 (10:12 -0700)]
[AArch64] handle -Wa,-march=

This fixed PR#48894 for AArch64. The issue has been fixed for Arm in
https://reviews.llvm.org/D95872

The following rules apply to -Wa,-march with this change:
  - Only compiler options apply to non assembly files
  - Compiler and assembler options apply to assembly files
  - For assembly files, we prefer the assembler option(s) if we have both kinds of option
  - Of the options that apply (or are preferred), the last value wins (it's not additive)

Reviewed By: DavidSpickett, nickdesaulniers

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

3 years ago[VPlan] Print successors of VPRegionBlocks.
Florian Hahn [Mon, 7 Jun 2021 16:45:19 +0000 (17:45 +0100)]
[VPlan] Print successors of VPRegionBlocks.

The non-DOT printing does not include the successors of VPregionBlocks.
This patch use the same style for printing successors as for
VPBasicBlock.

I think the printing of successors could be a bit improved further, as
at the moment it is hard to ensure a check line matches all successors.
But that can be done as follow-up.

Reviewed By: a.elovikov

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

3 years ago[dfsan] Fix internal build errors because of more strict warning checks
Jianzhou Zhao [Mon, 7 Jun 2021 16:55:56 +0000 (16:55 +0000)]
[dfsan] Fix internal build errors because of more strict warning checks

3 years ago[docs] Set Phabricator as the tool for pre-commit reviews
Krzysztof Parzyszek [Mon, 7 Jun 2021 13:51:11 +0000 (08:51 -0500)]
[docs] Set Phabricator as the tool for pre-commit reviews

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

3 years ago[libc++] Simplify a few macros in __config
Louis Dionne [Fri, 4 Jun 2021 17:31:22 +0000 (13:31 -0400)]
[libc++] Simplify a few macros in __config

Several macros were guarded with a check along the lines of:

 #ifndef MACRO
 #  define MACRO ...
 #endif

However, some of these macros are never intended to be defined by users,
so it's pointless to make this check (i.e. the first #ifndef is always
true). This commit removes those checks.

The motivation for doing this cleanup is to remove the impression that
arbitrary configurations macros can be defined by users when including
libc++ headers, which doesn't work reliably and leads to macro spaghetti.
If one needs to be able to override a knob in the __config, that's fine,
but the proper way to do that is to document the macro as being a public
facing knob in the documentation, and most likely to migrate that macro
to __config_site (depending on the nature of the macro).

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

3 years ago[lldb] Fix TypeSystemClang compilation after D101777
Raphael Isemann [Mon, 7 Jun 2021 16:45:03 +0000 (18:45 +0200)]
[lldb] Fix TypeSystemClang compilation after D101777

We apparently now need to pass the DeclName of the target decl to the
constructor.

3 years ago[NFC] Add missing include to LaneBitmask.h to fix modules build
Raphael Isemann [Mon, 7 Jun 2021 16:43:00 +0000 (18:43 +0200)]
[NFC] Add missing include to LaneBitmask.h to fix modules build

3 years ago[CostModel][AArch64] NFC: Simplify some cost model tests for SVE.
Sander de Smalen [Mon, 7 Jun 2021 15:55:44 +0000 (16:55 +0100)]
[CostModel][AArch64] NFC: Simplify some cost model tests for SVE.

* Merged some functions into a single function, to make the costs more obvious.
* Moved scalable-mem-op-cost-model.ll -> sve-ldst.ll to be more consistent with other filenames.

3 years ago[CostModel] Return Invalid cost in getArithmeticCost instead of crashing for scalable...
Sander de Smalen [Mon, 7 Jun 2021 12:02:38 +0000 (13:02 +0100)]
[CostModel] Return Invalid cost in getArithmeticCost instead of crashing for scalable vectors.

This fixes an issue in BasicTTIImpl.h where it tries to do a
cast<FixedVectorType> on a scalable vector type in order to get the
scalarization cost. Because scalarization of scalable vectors is not
supported, we return Invalid instead.

Reviewed By: RKSimon

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

3 years ago[Demangle][Rust] Parse dyn-trait-assoc-binding
Tomasz Miąsko [Mon, 7 Jun 2021 16:14:06 +0000 (18:14 +0200)]
[Demangle][Rust] Parse dyn-trait-assoc-binding

Reviewed By: dblaikie

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

3 years ago[Demangle][Rust] Parse dyn-trait
Tomasz Miąsko [Mon, 7 Jun 2021 16:13:19 +0000 (18:13 +0200)]
[Demangle][Rust] Parse dyn-trait

Reviewed By: dblaikie

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

3 years ago[Demangle][Rust] Parse dyn-bounds
Tomasz Miąsko [Mon, 7 Jun 2021 16:12:13 +0000 (18:12 +0200)]
[Demangle][Rust] Parse dyn-bounds

Reviewed By: dblaikie

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

3 years ago[mlir][openacc] Add conversion for if operand to scf.if for standalone data operation
Valentin Clement [Mon, 7 Jun 2021 16:09:25 +0000 (12:09 -0400)]
[mlir][openacc] Add conversion for if operand to scf.if for standalone data operation

This patch convert the if condition on standalone data operation such as acc.update,
acc.enter_data and acc.exit_data to a scf.if with the operation in the if region.
It removes the operation when the if condition is constant and false. It removes the
the condition if it is contant and true.

Conversion to scf.if is done in order to use the translation to LLVM IR dialect out of the box.
Not sure this is the best approach or we should perform this during the translation from OpenACC
to LLVM IR dialect. Any thoughts welcome.

Reviewed By: ftynse

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

3 years ago[mlir][openacc] Add canonicalization for standalone data operations for if condition
Valentin Clement [Mon, 7 Jun 2021 15:40:26 +0000 (11:40 -0400)]
[mlir][openacc] Add canonicalization for standalone data operations for if condition

This patch add canonicalization for the standalone data operation with constant if condition.
It is extracted from this patch D103325.

Reviewed By: ftynse

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

3 years ago[Clang][CodeGen] Set the size of llvm.lifetime to unknown for scalable types.
Hsiangkai Wang [Thu, 20 May 2021 02:22:08 +0000 (10:22 +0800)]
[Clang][CodeGen] Set the size of llvm.lifetime to unknown for scalable types.

If the memory object is scalable type, we do not know the exact size of
it at compile time. Set the size of lifetime marker to unknown if the
object is scalable one.

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

3 years ago[mlir][openacc] Conversion of data operands in acc.parallel to LLVM IR dialect
Valentin Clement [Mon, 7 Jun 2021 15:21:51 +0000 (11:21 -0400)]
[mlir][openacc] Conversion of data operands in acc.parallel to LLVM IR dialect

Convert data operands from the acc.parallel operation using the same conversion pattern than D102170.

Reviewed By: ftynse

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

3 years ago[OpenMP] Check loc for NULL before dereferencing it
Bryan Chan [Mon, 7 Jun 2021 14:37:24 +0000 (10:37 -0400)]
[OpenMP] Check loc for NULL before dereferencing it

The ident_t * argument in __kmp_get_monotonicity was being used without
a customary NULL check, causing the function to crash in a Debug build.
Release builds were not affected thanks to dead store elimination.

3 years ago[flang][driver] Add support for the "-init-only" option
Stuart Ellis [Mon, 7 Jun 2021 14:40:26 +0000 (15:40 +0100)]
[flang][driver] Add support for the "-init-only" option

Adding the `-init-only` option and corresponding frontend action to
generate a diagnostic.

`-init-only` vs `-test-io`:
`-init-only` ignores the input (it never calls the prescanner)
`-test-io` is similar to `-init-only`, but does read and print the input
without calling the prescanner.

This patch also adds a Driver test to check this action.

Reviewed By: awarzynski, AMDChirag

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

3 years ago[InstCombine] Support negation of scalable-vector splats
Fraser Cormack [Mon, 7 Jun 2021 10:19:20 +0000 (11:19 +0100)]
[InstCombine] Support negation of scalable-vector splats

This patch is an extension of D103421. It allows the InstCombiner to
generate the negated form of integer scalable-vector splats. It can
technically handle fixed-length vectors too but those are completely
covered by the preceding logic.

This enables extra combining opportunities for scalable vector types.

Reviewed By: RKSimon

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

3 years ago[clang] Remove inadvertent commit
Nathan Sidwell [Mon, 7 Jun 2021 14:15:34 +0000 (07:15 -0700)]
[clang] Remove inadvertent commit

Oops, missed this pattern in my .gitignore.  Sorry.

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

3 years ago[clang] Fix using-enum breakage
Nathan Sidwell [Mon, 7 Jun 2021 13:52:45 +0000 (06:52 -0700)]
[clang] Fix using-enum breakage

This fixes a build breakage.  I managed to attach this particular
change to the wrong diff in the stack when rebasing.  And flubbed
testing :(

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

3 years ago[AMDGPU] Use s_add_i32 for address additions
Sebastian Neubauer [Mon, 7 Jun 2021 14:09:48 +0000 (16:09 +0200)]
[AMDGPU] Use s_add_i32 for address additions

This allows to convert the add instruction to s_addk_i32 and
v_add_nc_u32 instead of needing v_add_co_u32 when converting to a VALU
instruction.

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

3 years ago[test] Use host platform specific error message substitution
Abhina Sreeskantharajan [Mon, 7 Jun 2021 14:06:11 +0000 (10:06 -0400)]
[test] Use host platform specific error message substitution

This testcase is failing on z/OS because the regex doesn't match the spelling. This patch modifies the testcase to use the error substitution so it will pass on all platforms.

Reviewed By: jhenderson

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

3 years ago[Constants] Extend support for scalable-vector splats
Fraser Cormack [Mon, 31 May 2021 17:31:55 +0000 (18:31 +0100)]
[Constants] Extend support for scalable-vector splats

This patch extends the various "isXXX" functions of the `Constant` class
to include scalable-vector splats.

In several "isXXX" functions, code that was separately inspecting
`ConstantVector` and `ConstantDataVector` was unified to use
`getSplatValue`, which already includes support for said splats.

In the varous "isNotXXX" functions, code was added to check whether the
scalar splat value -- if any -- satisfies the predicate.

An extra fix for `isNotMinSignedValue` was included, as it previously
crashed when passed a scalable-vector type because it unconditionally
cast to `FixedVectorType`

These changes address numerous missed optimizations, a compiler crash
mentioned above and -- perhaps most egregiously -- an infinite loop in
InstCombine due to the compiler breaking canonical form when it failed
to pick up on a splat in a select instruction.

Test cases have been added to cover as many of these functions as
possible, though existing coverage is slim; it doesn't appear that there
are any in-tree uses of `Constant::isNegativeZeroValue`, for example.

Reviewed By: RKSimon

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

3 years ago[clangd] Bump recommended gRPC version (1.33.2 -> 1.36.3)
Kirill Bobyrev [Mon, 7 Jun 2021 13:36:25 +0000 (15:36 +0200)]
[clangd] Bump recommended gRPC version (1.33.2 -> 1.36.3)

Context: https://github.com/clangd/clangd/pull/783

Reviewed By: kadircet

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

3 years ago[clang][NFC] Break out enum completion from other type context completion
Nathan Sidwell [Tue, 4 May 2021 14:29:06 +0000 (07:29 -0700)]
[clang][NFC] Break out enum completion from other type context completion

This prepatch for using-enum breaks out the enum completion that that
will need from the existing scope completion logic.

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

3 years ago[clang][NFC] Break out BaseUsingDecl from UsingDecl
Nathan Sidwell [Mon, 3 May 2021 18:05:56 +0000 (11:05 -0700)]
[clang][NFC] Break out BaseUsingDecl from UsingDecl

This is a pre-patch for adding using-enum support.  It breaks out
the shadow decl handling of UsingDecl to a new intermediate base
class, BaseUsingDecl, altering the decl hierarchy to

def BaseUsing : DeclNode<Named, "", 1>;
  def Using : DeclNode<BaseUsing>;
def UsingPack : DeclNode<Named>;
def UsingShadow : DeclNode<Named>;
  def ConstructorUsingShadow : DeclNode<UsingShadow>;

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

3 years ago[AMDGPU] Increase alignment of LDS globals if necessary before LDS lowering.
hsmahesha [Mon, 7 Jun 2021 11:51:19 +0000 (17:21 +0530)]
[AMDGPU] Increase alignment of LDS globals if necessary before LDS lowering.

Before packing LDS globals into a sorted structure, make sure that
their alignment is properly updated based on their size. This will make
sure that the members of sorted structure are properly aligned, and
hence it will further reduce the probability of unaligned LDS access.

Reviewed By: rampitec

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

3 years ago[InstCombine] Missed optimization for pow(x, y) * pow(x, z) with fast-math
Daniil Seredkin [Mon, 7 Jun 2021 11:01:29 +0000 (07:01 -0400)]
[InstCombine] Missed optimization for pow(x, y) * pow(x, z) with fast-math

If FP reassociation (fast-math) is allowed, then LLVM is free to do the
following transformation pow(x, y) * pow(x, z) -> pow(x, y + z).
This patch adds this transformation and tests for it.
See more https://bugs.llvm.org/show_bug.cgi?id=47205

It handles two cases

1. When operands of fmul are different instructions

%4 = call reassoc float @llvm.pow.f32(float %0, float %1)
%5 = call reassoc float @llvm.pow.f32(float %0, float %2)
%6 = fmul reassoc float %5, %4
-->
%3 = fadd reassoc float %1, %2
%4 = call reassoc float @llvm.pow.f32(float %0, float %3)

2. When operands of fmul are the same instruction

%4 = call reassoc float @llvm.pow.f32(float %0, float %1)
%5 = fmul reassoc float %4, %4
-->
%3 = fadd reassoc float %1, %1
%4 = call reassoc float @llvm.pow.f32(float %0, float %3)

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

3 years ago[MLIR][SPIRV] Use getAsmResultName(...) hook for AddressOfOp.
KareemErgawy [Mon, 7 Jun 2021 11:19:39 +0000 (13:19 +0200)]
[MLIR][SPIRV] Use getAsmResultName(...) hook for AddressOfOp.

Implements better naming for results of spv.mlir.addressof ops by making it
inherit from OpAsmOpInterface and implementing the associated
getAsmResultName(...) hook.

Reviewed By: antiagainst

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

3 years ago[clang] Fix a crash during code completion
Adam Czachorowski [Tue, 1 Jun 2021 16:24:33 +0000 (18:24 +0200)]
[clang] Fix a crash during code completion

During code completion, lookupInDeclContext() calls
CodeCompletionDeclConsumer::FoundDecl(),which can mutate StoredDeclsMap,
over which lookupInDeclContext() iterates. This can lead to invalidation
of iterators and an assert()-crash.

Example code where this happens:
 #include <list>
 int main() {
   std::list<int>;
   std::^
 }
with code completion on ^ with -std=c++20.

I do not have a repro case that does not need standard library.

This fix stores pointers to NamedDecls in a temporary vector, then
visits them outside of the main loop, when StoredDeclsMap iterators are
gone.

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

3 years agoExternalASTSource.h - remove unused StringRef and <string> includes. NFCI.
Simon Pilgrim [Mon, 7 Jun 2021 11:21:12 +0000 (12:21 +0100)]
ExternalASTSource.h - remove unused StringRef and <string> includes. NFCI.

3 years ago[gn build] fix syntax error from 50bb1b930dbc
Nico Weber [Mon, 7 Jun 2021 11:27:54 +0000 (07:27 -0400)]
[gn build] fix syntax error from 50bb1b930dbc

3 years ago[clangd] Drop TestTUs dependency on gtest
Kadir Cetinkaya [Fri, 4 Jun 2021 11:32:17 +0000 (13:32 +0200)]
[clangd] Drop TestTUs dependency on gtest

TestTU now prints errors to llvm::errs and aborts on failures via
llvm_unreachable, rather than executing ASSERT_FALSE.

We'd like to make use of these testing libraries in different test suits that
might be compiling with a different gtest version than LLVM has.

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

3 years ago[AArch64][SVE] Improve codegen for dupq SVE ACLE intrinsics
Bradley Smith [Thu, 20 May 2021 10:13:34 +0000 (11:13 +0100)]
[AArch64][SVE] Improve codegen for dupq SVE ACLE intrinsics

Use llvm.experimental.vector.insert instead of storing into an alloca
when generating code for these intrinsics. This defers the codegen of
the generated vector to instruction selection, allowing existing
shufflevector style optimizations to apply.

Additionally, introduce a new target transform that can recognise fixed
predicate patterns in the svbool variants of these intrinsics.

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

3 years ago[mlir][linalg] Add padding helper functions to PadTensorOp
Matthias Springer [Mon, 7 Jun 2021 11:13:08 +0000 (20:13 +0900)]
[mlir][linalg] Add padding helper functions to PadTensorOp

Add helper functions to quickly check for zero low/high padding.

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

3 years ago[LV] Update more target-specific tests after 23c2f2e6b24d.
Florian Hahn [Mon, 7 Jun 2021 11:12:48 +0000 (12:12 +0100)]
[LV] Update more target-specific tests after 23c2f2e6b24d.

3 years ago[Matrix] Add -matrix-allow-contract=false to tests.
Florian Hahn [Mon, 7 Jun 2021 10:53:17 +0000 (11:53 +0100)]
[Matrix] Add -matrix-allow-contract=false to tests.

Explicitly specify contract behavior, so the tests are independent of
the current default of the flag.

3 years ago[mlir] Add offset/stride helper functions to OffsetSizeAndStrideOpInterface
Matthias Springer [Mon, 7 Jun 2021 11:05:25 +0000 (20:05 +0900)]
[mlir] Add offset/stride helper functions to OffsetSizeAndStrideOpInterface

* Add hasUnitStride and hasZeroOffset to OffsetSizeAndStrideOpInterface. These functions are useful for various patterns. E.g., some vectorization patterns apply only for tensor ops with zero offsets and/or unit stride.
* Add getConstantIntValue and isEqualConstantInt helper functions, which are useful for implementing the two above functions, as well as various patterns.

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

3 years ago[AMDGPU][Libomptarget] Remove atlc global
Pushpinder Singh [Mon, 7 Jun 2021 09:29:29 +0000 (09:29 +0000)]
[AMDGPU][Libomptarget] Remove atlc global

This global struct used to hold various flags for monitoring the
initialization of hsa.

Reviewed By: JonChesterfield

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

3 years ago[OpenCL] Add const attribute to ctz() builtins
Stuart Brady [Mon, 1 Mar 2021 19:38:40 +0000 (19:38 +0000)]
[OpenCL] Add const attribute to ctz() builtins

Reviewed By: svenvh

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

3 years ago[llvm] Add interface to order inlining
Liqiang Tao [Mon, 7 Jun 2021 10:26:34 +0000 (18:26 +0800)]
[llvm] Add interface to order inlining

This patch abstract Calls in Inliner:run() to InlineOrder.
With this patch, it's possible to customize the inlining order,
e.g. use queue or priority queue.

Reviewed By: kazu

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

3 years ago[lld/mac] Implement support for searching dylibs with @rpath/ in install name
Nico Weber [Mon, 7 Jun 2021 01:52:23 +0000 (21:52 -0400)]
[lld/mac] Implement support for searching dylibs with @rpath/ in install name

Also adjust a few comments, and move the DylibFile comment talking about
umbrella next to the parameter again.

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

3 years ago[clang] NFC: test for undefined behaviour in RawComment::getFormattedText()
Dmitry Polukhin [Fri, 4 Jun 2021 21:41:53 +0000 (14:41 -0700)]
[clang] NFC: test for undefined behaviour in RawComment::getFormattedText()

This diff adds testcase for the issue fixed in https://reviews.llvm.org/D77468
but regression test was not added in the diff. On Clang 9 it caused
crash in cland during code completion.

Test Plan: check-clang-unit

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

3 years ago[NFC] Fix semantic discrepancy for MVT::LAST_VALUETYPE
Guillaume Chatelet [Mon, 7 Jun 2021 10:04:16 +0000 (10:04 +0000)]
[NFC] Fix semantic discrepancy for MVT::LAST_VALUETYPE

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

3 years ago[PhaseOrdering] Update tests after 23c2f2e6b24d.
Florian Hahn [Mon, 7 Jun 2021 09:59:06 +0000 (10:59 +0100)]
[PhaseOrdering] Update tests after 23c2f2e6b24d.

3 years agoASTConcept.h - remove unused <string> include. NFCI.
Simon Pilgrim [Mon, 7 Jun 2021 09:15:45 +0000 (10:15 +0100)]
ASTConcept.h - remove unused <string> include. NFCI.

3 years ago[SimpleLoopBoundSplit] Split Bound of Loop which has conditional branch with IV
Jingu Kang [Thu, 6 May 2021 14:53:00 +0000 (15:53 +0100)]
[SimpleLoopBoundSplit] Split Bound of Loop which has conditional branch with IV

This pass transforms loops that contain a conditional branch with induction
variable. For example, it transforms left code to right code:

                             newbound = min(n, c)
 while (iv < n) {            while(iv < newbound) {
   A                           A
   if (iv < c)                 B
     B                         C
   C                         }
 }                           if (iv != n) {
                               while (iv < n) {
                                 A
                                 C
                               }
                             }

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

3 years ago[Clang] Support a user-defined __dso_handle
Andrew Savonichev [Mon, 24 May 2021 10:29:59 +0000 (13:29 +0300)]
[Clang] Support a user-defined __dso_handle

This fixes PR49198: Wrong usage of __dso_handle in user code leads to
a compiler crash.

When Init is an address of the global itself, we need to track it
across RAUW. Otherwise the initializer can be destroyed if the global
is replaced.

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

3 years ago[LV] Mark increment of main vector loop induction variable as NUW.
Florian Hahn [Mon, 7 Jun 2021 08:24:27 +0000 (09:24 +0100)]
[LV] Mark increment of main vector loop induction variable as NUW.

This patch marks the induction increment of the main induction variable
of the vector loop as NUW when not folding the tail.

If the tail is not folded, we know that End - Start >= Step (either
statically or through the minimum iteration checks). We also know that both
Start % Step == 0 and End % Step == 0. We exit the vector loop if %IV +
%Step == %End. Hence we must exit the loop before %IV + %Step unsigned
overflows and we can mark the induction increment as NUW.

This should make SCEV return more precise bounds for the created vector
loops, used by later optimizations, like late unrolling.

At the moment quite a few tests still need to be updated, but before
doing so I'd like to get initial feedback to make sure I am not missing
anything.

Note that this could probably be further improved by using information
from the original IV.

Attempt of modeling of the assumption in Alive2:
https://alive2.llvm.org/ce/z/H_DL_g

Part of a set of fixes required for PR50412.

Reviewed By: mkazantsev

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

3 years ago[AMDGPU] Fix MC tests for v_fmaak_f16 and v_fmamk_f16
Jay Foad [Fri, 4 Jun 2021 14:49:02 +0000 (15:49 +0100)]
[AMDGPU] Fix MC tests for v_fmaak_f16 and v_fmamk_f16

This looks like a mistake when the tests were committed in r363946.
There were two sets of tests for the f32 variant of these instructions,
instead of one set for f16 and one set for f32.

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

3 years ago[mlir][linalg] Cleanup LinalgOp usage in comprehensive bufferization.
Tobias Gysi [Mon, 7 Jun 2021 08:43:23 +0000 (08:43 +0000)]
[mlir][linalg] Cleanup LinalgOp usage in comprehensive bufferization.

Replace the uses of deprecated Structured Op Interface methods in ComprehensiveBufferize.cpp. This patch is based on https://reviews.llvm.org/D103394.

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

3 years ago[OpenCL] Fix missing addrspace on implicit move assignment operator
Ole Strohm [Mon, 7 Jun 2021 08:34:53 +0000 (09:34 +0100)]
[OpenCL] Fix missing addrspace on implicit move assignment operator

This fixes the missing address space on `this` in the implicit move
assignment operator.
The function called here is an abstraction around the lines that have
been removed which also sets the address space correctly.
This is copied from CopyConstructor, CopyAssignment and MoveConstructor,
all of which use this function, and now MoveAssignment does too.

Fixes: PR50259

Reviewed By: svenvh

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

3 years ago[AMDGPU][Libomptarget] Rework logic for locating kernarg pools
Pushpinder Singh [Thu, 3 Jun 2021 08:58:10 +0000 (08:58 +0000)]
[AMDGPU][Libomptarget] Rework logic for locating kernarg pools

Previous logic was to always use the first kernarg pool found to allocate
kernel args. This patch changes this to use only the kernarg pool which
has non-zero size. This logic is also reworked to not use any globals.

Reviewed By: JonChesterfield

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

3 years agoFixed the build failure of yaml2obj in XCOFFEmitter.cpp:
Esme-Yi [Mon, 7 Jun 2021 05:45:05 +0000 (05:45 +0000)]
Fixed the build failure of yaml2obj in XCOFFEmitter.cpp:
  error: ambiguous overload for 'operator=='
  (operand types are 'llvm::yaml::Hex16' and 'llvm::XCOFF::MagicNumber')
     Is64Bit = Obj.Header.Magic == XCOFF::XCOFF64;

3 years ago[yaml2obj] Initial the support of yaml2obj for 32-bit XCOFF.
Esme-Yi [Mon, 7 Jun 2021 04:14:44 +0000 (04:14 +0000)]
[yaml2obj] Initial the support of yaml2obj for 32-bit XCOFF.

Summary: The patch implements the mapping of the Yaml
information to XCOFF object file to enable the yaml2obj
tool for XCOFF. Currently only 32-bit is supported.

Reviewed By: jhenderson, shchenz

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

3 years ago[lld/mac] Implement support for searching dylibs with @loader_path/ in install name
Nico Weber [Sun, 6 Jun 2021 22:12:27 +0000 (18:12 -0400)]
[lld/mac] Implement support for searching dylibs with @loader_path/ in install name

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

3 years ago[lld/mac] Implement support for searching dylibs with @executable_path/ in install...
Nico Weber [Sun, 6 Jun 2021 20:57:19 +0000 (16:57 -0400)]
[lld/mac] Implement support for searching dylibs with @executable_path/ in install name

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

3 years ago[lld/mac] Rename DylibFile::dylibName to DylibFile::installName
Nico Weber [Sun, 6 Jun 2021 22:25:28 +0000 (18:25 -0400)]
[lld/mac] Rename DylibFile::dylibName to DylibFile::installName

The flag to set it is called `-install_name`, and it's called `installName` in tbd files.

No behavior change.

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

3 years ago[lld/mac] Use fewer magic numbers in magic $ld$ handling code
Nico Weber [Sun, 6 Jun 2021 20:11:25 +0000 (16:11 -0400)]
[lld/mac] Use fewer magic numbers in magic $ld$ handling code

Also simply a conditional and de-alias a variable.
Minor cleanups, no behavior change.

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

3 years ago[dfsan] Use the sanitizer allocator to reduce memory cost
Jianzhou Zhao [Fri, 23 Apr 2021 22:35:25 +0000 (22:35 +0000)]
[dfsan] Use the sanitizer allocator to reduce memory cost

dfsan does not use sanitizer allocator as others. In practice,
we let it use glibc's allocator since tcmalloc needs more work
to be working with dfsan well. With glibc, we observe large
memory leakage. This could relate to two things:

1) glibc allocator has limitation: for example, tcmalloc can reduce memory footprint 2x easily

2) glibc may call unmmap directly as an internal system call by using system call number. so DFSan has no way to release shadow spaces for those unmmap.

Using sanitizer allocator addresses the above issues
1) its memory management is close to tcmalloc

2) we can register callback when sanitizer allocator calls unmmap, so dfsan can release shadow spaces correctly.

Our experiment with internal server-based application proved that with the change, in a-few-day run, memory usage leakage is close to what tcmalloc does w/o dfsan.

This change mainly follows MSan's code.

1) define allocator callbacks at dfsan_allocator.h|cpp

2) mark allocator APIs to be discard

3) intercept allocator APIs

4) make dfsan_set_label consistent with MSan's SetShadow when setting 0 labels, define dfsan_release_meta_memory when unmap is called

5) add flags about whether zeroing memory after malloc/free. dfsan works at byte-level, so bit-level oparations can cause reading undefined shadow. See D96842. zeroing memory after malloc helps this. About zeroing after free, reading after free is definitely UB, but if user code does so, it is hard to debug an overtainting caused by this w/o running MSan. So we add the flag to help debugging.

This change will be split to small changes for review. Before that, a question is
"this code shares a lot of with MSan, for example, dfsan_allocator.* and dfsan_new_delete.*.
Does it make sense to unify the code at sanitizer_common? will that introduce some
maintenance issue?"

Reviewed By: morehouse

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

3 years ago[CostModel][X86] Add 512-bit bswap costs
Simon Pilgrim [Sun, 6 Jun 2021 21:36:26 +0000 (22:36 +0100)]
[CostModel][X86] Add 512-bit bswap costs

3 years ago[CostModel][X86] Add 512-bit bswap cost tests
Simon Pilgrim [Sun, 6 Jun 2021 21:24:34 +0000 (22:24 +0100)]
[CostModel][X86] Add 512-bit bswap cost tests

3 years ago[ARM] MVE tests for vmull from a splat. NFC
David Green [Sun, 6 Jun 2021 21:30:02 +0000 (22:30 +0100)]
[ARM] MVE tests for vmull from a splat. NFC

3 years ago[AArch64] Extra tests for vector shift. NFC
David Green [Sun, 6 Jun 2021 21:29:44 +0000 (22:29 +0100)]
[AArch64] Extra tests for vector shift. NFC

3 years ago[CostModel][X86] Improve AVX512 FDIV costs
Simon Pilgrim [Sun, 6 Jun 2021 20:40:59 +0000 (21:40 +0100)]
[CostModel][X86] Improve AVX512 FDIV costs

Add missing v16f32/v8f64 costs and adjust other costs as well based off the SkylakeServer model

3 years ago[RISCV] Replace && with ||. Spotted by coverity.
Craig Topper [Sun, 6 Jun 2021 19:48:25 +0000 (12:48 -0700)]
[RISCV] Replace && with ||. Spotted by coverity.

We should be exiting when the shift amount is greater than
the bit width regardless of whether it is a power of 2.

Reported by Simon Pilgrim here https://reviews.llvm.org/D96661

This requires getting a shift amount that is out of bounds that
wasn't already optimized by SelectionDAG. This would be pretty
trick to construct a test for.

Or it would require a non-power of 2 shift amount and a mask
that has runs of ones and zeros of the next lowest power of 2 from
that shift amount. I tried a little to produce a test for this,
but didn't get it to work.

3 years ago[X86][SSE] LowerFP_TO_INT - remove dead code. NFCI.
Simon Pilgrim [Sun, 6 Jun 2021 19:00:34 +0000 (20:00 +0100)]
[X86][SSE] LowerFP_TO_INT - remove dead code. NFCI.

Non-Strict v2f32->v2i64 cases have already early-returned to be handled by legalization.

3 years ago[X86][SSE] combineVectorTruncation - simplify PSHUFB-is-better logic. NFCI.
Simon Pilgrim [Sun, 6 Jun 2021 18:53:49 +0000 (19:53 +0100)]
[X86][SSE] combineVectorTruncation - simplify PSHUFB-is-better logic. NFCI.

OutSVT is guaranteed to be i8/i16 and we accept any InSVT that isn't i64

3 years agoRevert "[LoopUnrollAndJam] Change LoopUnrollAndJamPass to LoopNest pass"
maekawatoshiki [Sun, 6 Jun 2021 16:26:47 +0000 (01:26 +0900)]
Revert "[LoopUnrollAndJam] Change LoopUnrollAndJamPass to LoopNest pass"

This reverts commit 21653600034084e8335374ddc1eb8d362158d9a8.

To fix the crash problem in legacy pass manager

3 years ago[Clang][OpenMP] Refactor checking for mutually exclusive clauses. NFC.
Michael Kruse [Sun, 6 Jun 2021 14:18:59 +0000 (09:18 -0500)]
[Clang][OpenMP] Refactor checking for mutually exclusive clauses. NFC.

Multiple clauses are mutually exclusive. This patch refactors the functions that check for pairs of mutually exclusive clauses into a generalized function which also also accepts a list of clause types if which at most one can appear.

NFC patch extracted out of D99459 by request.

Reviewed By: ABataev

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