platform/upstream/llvm.git
18 months agoSpeculatively fix the Clang sphinx build
Aaron Ballman [Wed, 11 Jan 2023 12:29:36 +0000 (07:29 -0500)]
Speculatively fix the Clang sphinx build

This file builds correctly for me locally, but gives a warning about
not being able to lex the binary literal as C++ code.

This should fix the issue found by:
https://lab.llvm.org/buildbot/#/builders/92/builds/38522

18 months ago[Test] Regenerate checks in fold.ll using auto-update script
Max Kazantsev [Wed, 11 Jan 2023 12:22:12 +0000 (19:22 +0700)]
[Test] Regenerate checks in fold.ll using auto-update script

18 months ago[clang][Interp][NFC] Remove code duplication in VisitRecordInitializer
Timm Bäder [Wed, 11 Jan 2023 11:12:05 +0000 (12:12 +0100)]
[clang][Interp][NFC] Remove code duplication in VisitRecordInitializer

We can just use the regular VisitCallExpr logic here, since we have the
pointer to initialize already on the stack.

18 months ago[clang][Interp][NFC] Add an assertion
Timm Bäder [Wed, 11 Jan 2023 11:48:12 +0000 (12:48 +0100)]
[clang][Interp][NFC] Add an assertion

This is unnecessary in the current state of the interpreter, but will ne
important later.

18 months ago[CVP] Add tests for condition constraint at use (NFC)
Nikita Popov [Wed, 11 Jan 2023 11:59:03 +0000 (12:59 +0100)]
[CVP] Add tests for condition constraint at use (NFC)

18 months ago[Test] Add complementary test for umin_seq
Max Kazantsev [Wed, 11 Jan 2023 11:48:28 +0000 (18:48 +0700)]
[Test] Add complementary test for umin_seq

18 months ago[ReleaseNotes] Add Neoverse V2 CPU to LLVM's release notes
Victor Campos [Tue, 10 Jan 2023 15:29:05 +0000 (15:29 +0000)]
[ReleaseNotes] Add Neoverse V2 CPU to LLVM's release notes

This new CPU was mentioned in Clang's release notes, but was missing
from LLVM's.

Reviewed By: dmgreen

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

18 months ago[include-mapping] Fix the instructions for running stdlib recognizer. Mention python...
Viktoriia Bakalova [Wed, 11 Jan 2023 11:05:49 +0000 (11:05 +0000)]
[include-mapping] Fix the instructions for running stdlib recognizer. Mention python command explicitly. Remove angle brackets.

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

18 months agoRevert "Revert "[clang-format] Add an option for breaking after C++11 attributes""
Krasimir Georgiev [Wed, 11 Jan 2023 11:30:30 +0000 (11:30 +0000)]
Revert "Revert "[clang-format] Add an option for breaking after C++11 attributes""

This reverts commit 879bfe6a979295f834b76df66b19a203b93eed0f.

owenpan@ pointed out on https://reviews.llvm.org/D140956 that this
actually makes the formatting more consistent, so it's not a regression.

18 months ago[docs] Add newline in clang release notes.
Utkarsh Saxena [Wed, 11 Jan 2023 11:28:10 +0000 (12:28 +0100)]
[docs] Add newline in clang release notes.

18 months ago[clang-format][doc] Fix doc format for IntegerLiteralSeparator
Owen Pan [Wed, 11 Jan 2023 10:17:54 +0000 (02:17 -0800)]
[clang-format][doc] Fix doc format for IntegerLiteralSeparator

18 months ago[Test] Add test showing missing canonicalization opportunity in SCEV
Max Kazantsev [Wed, 11 Jan 2023 11:04:38 +0000 (18:04 +0700)]
[Test] Add test showing missing canonicalization opportunity in SCEV

We could have same SCEVs for the following expressions:
  zext(umin(x, y)) and umin(zext(x), zext(y));
  zext(umax(x, y)) and umax(zext(x), zext(y))
  sext(smin(x, y)) and smin(zsxt(x), sext(y));
  sext(smax(x, y)) and smax(sext(x), sext(y)).

18 months ago[mlir][arith] Optimize arith.cmpi based on integer range analysis.
Ivan Butygin [Fri, 23 Dec 2022 15:20:20 +0000 (16:20 +0100)]
[mlir][arith] Optimize arith.cmpi based on integer range analysis.

Add a pass which do arith dialect ops optimization based on integer range analysis (only cmpi for now).

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

18 months agoPerform access checking to private members in simple requirement.
Utkarsh Saxena [Thu, 22 Dec 2022 04:05:31 +0000 (05:05 +0100)]
Perform access checking to private members in simple requirement.

> Dependent access checks.

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

We previously ignored dependent access checks to private members.
These are visible only to the `RequiresExprBodyExpr` (through `PerformDependentDiagnositcs`) and not to the individual requirements.

---

> Non-dependent access checks.
Fixes: https://github.com/llvm/llvm-project/issues/53334
Access to members in a non-dependent context would always yield an
invalid expression. When it appears in a requires-expression, then this
is a hard error as this would always result in a substitution failure.

https://eel.is/c++draft/expr.prim.req#general-note-1
> Note 1: If a requires-expression contains invalid types or expressions in its requirements, and it does not appear within the declaration of a templated entity, then the program is ill-formed. — end note]
> If the substitution of template arguments into a requirement would always result in a substitution failure, the program is ill-formed; no diagnostic required.

The main issue here is the delaying of the diagnostics.
Use a `ParsingDeclRAIIObject` creates a separate diagnostic pool for diagnositcs associated to the `RequiresExprBodyDecl`.
This is important because dependent diagnostics should not be leaked/delayed to higher scopes (Eg. inside a template function or in a trailing requires). These dependent diagnostics must be attached to the `DeclContext` of the parameters of `RequiresExpr` (which is the `RequiresExprBodyDecl` in this case).
Non dependent diagnostics, on the other hand, should not delayed and surfaced as hard errors.

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

18 months ago[clang][Interp][NFC] Print Pointee address of Pointer
Timm Bäder [Mon, 26 Dec 2022 11:00:52 +0000 (12:00 +0100)]
[clang][Interp][NFC] Print Pointee address of Pointer

18 months ago[compiler-rt] support armv5t, armv6
Ties Stuij [Wed, 11 Jan 2023 10:00:02 +0000 (10:00 +0000)]
[compiler-rt] support armv5t, armv6

The legwork for these was done by https://reviews.llvm.org/D138725. Here we're
just adding the arch names to the cmake files and linking them to
arm_min_SOURCES.

Reviewed By: MaskRay

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

18 months ago[X86] Add scheduling info of CodeGenOnly but encodable instructions for AlderlakeP...
Haohai Wen [Wed, 11 Jan 2023 10:08:52 +0000 (18:08 +0800)]
[X86] Add scheduling info of CodeGenOnly but encodable instructions for AlderlakeP model

Automatically generated by D130897. This fixed issue #58792.

Reviewed By: pengfei

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

18 months agoRevert "[DWARFLibrary] Add support to re-construct cu-index"
Dmitri Gribenko [Wed, 11 Jan 2023 10:11:53 +0000 (11:11 +0100)]
Revert "[DWARFLibrary] Add support to re-construct cu-index"

This reverts commit 73712c8790a93c29e513f5e201f92ac5b2370cf9. It causes
a MemorySanitizer error in LLVM testsuite. See
the discussion on https://reviews.llvm.org/D137882 for details.

18 months ago[TargetParser] Generate the defs for RISCV CPUs using llvm-tblgen.
Francesco Petrogalli [Wed, 11 Jan 2023 09:23:55 +0000 (10:23 +0100)]
[TargetParser]  Generate the defs for RISCV CPUs using llvm-tblgen.

Rework the change to prevent build failures. NFCI.

The failing code was submitted as
cf7a8305a2b4ddfd299c748136cb9a2960ef7089 and reverted via
8bd65e535fb33bc48805bafed8217b16a853e158.

The rework in this new commit prevents failures like the following:

FAILED: tools/clang/lib/Basic/CMakeFiles/obj.clangBasic.dir/Targets/RISCV.cpp.o
/usr/bin/c++  [bunch of non interesting stuff]  -c <path-to>/llvm-project/clang/lib/Basic/Targets/RISCV.cpp
In file included from <path-to>/llvm-project/clang/lib/Basic/Targets/RISCV.cpp:19:
<path-to>/llvm-project/llvm/include/llvm/TargetParser/RISCVTargetParser.h:29:10: fatal error: llvm/TargetParser/RISCVTargetParserDef.inc: No such file or directory
  29 | #include "llvm/TargetParser/RISCVTargetParserDef.inc"
     |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

These failures happen because the library LLVMTargetParser depends on
RISCVTargetParserTableGen, which is a tablegen target that generates
the list of CPUs in
llvm/TargetParser/RISCVTargetParserDef.inc. This *.inc file is
included by the public header file
llvm/TargetParser/RISCVTargetParser.h.

The header file llvm/TargetParser/RISCVTargetParser.h is also used in
components (clangDriver and clangBasic) that link into
LLVMTargetParser, but on some configurations such components might end
up being built before TargetParser is ready.

The fix is to make sure that clangDriver and clangBasic depend on the
tablegen target RISCVTargetParserTableGen, which generates the .inc
file whether or not LLVMTargetParser is ready.

WRT the original patch at https://reviews.llvm.org/D137517, this
commit is just adding RISCVTargetParserTableGen in the DEPENDS list of
clangDriver and clangBasic.

18 months ago[BOLT][AArch64] add lock to FixRelaxations pass
Denis Revunov [Wed, 11 Jan 2023 08:38:47 +0000 (03:38 -0500)]
[BOLT][AArch64] add lock to FixRelaxations pass

Since the pass is multithreaded, BC.Ctx must be protected. Otherwise we get crashes when processing.

Reviewed by: yota9

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

18 months ago[RISCV][NFC] Update V spec section numbers
Luke Lau [Tue, 10 Jan 2023 14:05:37 +0000 (14:05 +0000)]
[RISCV][NFC] Update V spec section numbers

The section numbers got reshuffled around between v0.10 and [[ https://github.com/riscv/riscv-v-spec/blob/v1.0/v-spec.adoc |  v1.0 of the spec ]], this updates references in comments to refer to their version in v1.0.

Reviewed By: craig.topper

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

18 months ago[AArch64] Add REQUIRES: aarch64-registered-target to aarch64-targetattr-arch.c. NFC
David Green [Wed, 11 Jan 2023 10:10:01 +0000 (10:10 +0000)]
[AArch64] Add REQUIRES: aarch64-registered-target to aarch64-targetattr-arch.c. NFC

18 months agoRevert "[TargetParser] Generate the defs for RISCV CPUs using llvm-tblgen."
Francesco Petrogalli [Wed, 11 Jan 2023 09:22:56 +0000 (10:22 +0100)]
Revert "[TargetParser] Generate the defs for RISCV CPUs using llvm-tblgen."

This reverts commit cf7a8305a2b4ddfd299c748136cb9a2960ef7089.

18 months ago[InstCombine] Handle assume(X & Pow2 != 0) in computeKnownBits()
Noah Goldstein [Wed, 11 Jan 2023 09:18:46 +0000 (10:18 +0100)]
[InstCombine] Handle assume(X & Pow2 != 0) in computeKnownBits()

If we know that X & Pow2 != 0, then the bit at that position is
known one.

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

18 months ago[LoongArch] Refine the condition to return Match_RequiresAMORdDifferRkRj in AsmParser...
Weining Lu [Wed, 11 Jan 2023 09:11:40 +0000 (17:11 +0800)]
[LoongArch] Refine the condition to return Match_RequiresAMORdDifferRkRj in AsmParser. NFC

This can suppress compilation warning like `enumerated mismatch in conditional expression`.

See:
https://lab.llvm.org/staging/#/builders/236/builds/645/steps/6/logs/warnings__1_

18 months ago[MLIR][Tensor] Fix example for pack/unpack (NFC)
Lorenzo Chelini [Wed, 11 Jan 2023 09:09:26 +0000 (10:09 +0100)]
[MLIR][Tensor] Fix example for pack/unpack (NFC)

18 months ago[LoopVectorize] Clear cache of `LoopAccessInfoManager`
Miguel Saldivar [Wed, 11 Jan 2023 08:37:25 +0000 (08:37 +0000)]
[LoopVectorize] Clear cache of `LoopAccessInfoManager`

LAI is cached during the LoopDistribute pass, and is later re-used during LoopVectorize. The problem is that LoopVectorize changes SCEV, and the cached LAI does not get updated. Hence, when re-using the cached LAI, it references an invalid SCEV.

Fixes #59319

Reviewed By: fhahn

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

18 months ago[InstCombine] Add tests for icmp ne non-zero power of 2; NFC
Noah Goldstein [Wed, 11 Jan 2023 09:01:39 +0000 (10:01 +0100)]
[InstCombine] Add tests for icmp ne non-zero power of 2; NFC

Tests for D140851.

18 months ago[TargetParser] Generate the defs for RISCV CPUs using llvm-tblgen.
Francesco Petrogalli [Tue, 10 Jan 2023 21:09:06 +0000 (22:09 +0100)]
[TargetParser] Generate the defs for RISCV CPUs using llvm-tblgen.

This patch removes the file `llvm/include/llvm/TargetParser/RISCVTargetParser.def` and replaces it with a tablegen-generated `.inc` file out of `llvm/lib/Target/RISCV/RISCV.td`.

The module system has been updated to make sure we can build clang/llvm with `-DLLVM_ENABLE_MODULES=On`

Reviewed By: craig.topper

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

18 months ago[OpenMP][FIX] Avoid performance regression accidentally introduced
Johannes Doerfert [Wed, 11 Jan 2023 06:29:58 +0000 (22:29 -0800)]
[OpenMP][FIX] Avoid performance regression accidentally introduced

18 months ago[AArch64] Make -march and target(arch=..) attributes imply dependent features
David Green [Wed, 11 Jan 2023 08:48:23 +0000 (08:48 +0000)]
[AArch64] Make -march and target(arch=..) attributes imply dependent features

Specifying an architecture revision should also add feature strings for
any dependent default extensions. Otherwise the new checks for
target-dependent features for acle intrinsics from D134353 and D132034
can fail.

This patch does that in setFeatureEnabled, similar to the addition of
dependent architecture revisions. +sve also needs to be added to armv9
architectures in the target parser, as it is implied by +sve2.

Fixes #59911

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

18 months agoReland "[CMake][LoongArch] Add LoongArch to LLVM_ALL_TARGETS so it is built by default"
Weining Lu [Wed, 11 Jan 2023 08:35:48 +0000 (16:35 +0800)]
Reland "[CMake][LoongArch] Add LoongArch to LLVM_ALL_TARGETS so it is built by default"

This follows the [[ https://discourse.llvm.org/t/rfc-promoting-the-loongarch-backend-from-experimental-to-official/67506/ | RFC ]].

Follow-on commits will add appropriate release notes changes etc.

Submit this now and in a minimal form so there is reasonable time before
16.0.0 is branched to resolve any issues arising from e.g. the backend
being exposed on different compiler/sanitizer setups.

The current builder for LoongArch is on the [[ https://lab.llvm.org/staging/#/builders/236 | staging area ]].

Reviewed By: jyknight, MaskRay, echristo, myhsu, tstellar, arsenm

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

18 months ago[flang] Lowering and implementation for extends_type_of
Valentin Clement [Wed, 11 Jan 2023 08:31:33 +0000 (09:31 +0100)]
[flang] Lowering and implementation for extends_type_of

Add implementation and loweirng for the extends_type_of
intrinsic.

The standard mentions this: otherwise if the dynamic type of A or MOLD is
extensible, the result is true if and only if the dynamic type of A is an
extension type of the dynamic type of MOLD. Which could be interpreted that
`extends_type_of(a, a)` could be false since a type is not an extension of
itself. Gfortran result for this is `true` so the same behavior is applied
here as well.

Depends on D141364

Reviewed By: jeanPerier, PeteSteinfeld

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

18 months ago[flang] Lowering and implementation for same_type_as
Valentin Clement [Wed, 11 Jan 2023 08:30:14 +0000 (09:30 +0100)]
[flang] Lowering and implementation for same_type_as

The test performed by same_type_as does not consider kind type
parameters. If an exact match is not found, the name of the
derived type is compared. The name in the runtime info does not include
the kind type parameters as it does in the mangled name.

Reviewed By: jeanPerier, PeteSteinfeld

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

18 months ago[flang] Only deallocate intent(out) allocatable through runtime if allocated
Valentin Clement [Wed, 11 Jan 2023 08:20:28 +0000 (09:20 +0100)]
[flang] Only deallocate intent(out) allocatable through runtime if allocated

Deallocation of intent(out) allocatable was done in D133348. This patch adds
an if guard when the deallocation is done through a runtime call. The runtime
is crashing if the box is not allocated. Call the runtime only if the box is
allocated. This is the case for derived type, polymorphic and unlimited
polymorphic entities.

Reviewed By: PeteSteinfeld

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

18 months ago[PowerPC][GISel] Select sync instructions required by atomic operations
Kai Luo [Wed, 11 Jan 2023 08:08:49 +0000 (16:08 +0800)]
[PowerPC][GISel] Select sync instructions required by atomic operations

This is part of selecting `G_ATOMIC*` instructions. Select `isync`, `sync` and `lwsync` in GISel.

Reviewed By: arsenm

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

18 months ago[LoongArch] Fixed llvm/test/CodeGen/LoongArch/intrinsic.ll test failure when EXPENSIV...
gonglingqin [Wed, 11 Jan 2023 07:04:45 +0000 (15:04 +0800)]
[LoongArch] Fixed llvm/test/CodeGen/LoongArch/intrinsic.ll test failure when EXPENSIV_CHECK is enabled [1].

Specifically:
```
*** Bad machine code: Using an undefined physical register ***
- function:    movgr2fcsr
- basic block: %bb.0 entry (0x1af5e60)
- instruction: MOVGR2FCSR $fcsr1, %0:gpr
- operand 0:   $fcsr1

*** Bad machine code: Using an undefined physical register ***
- function:    movfcsr2gr
- basic block: %bb.0 entry (0x133fae0)
- instruction: %0:gpr = MOVFCSR2GR $fcsr1
- operand 1:   $fcsr1
```

By building MachineInstructions, the state of the register is
clarified, and the error caused by using undefined physical registers
is fixed.

[1]: https://lab.llvm.org/buildbot/#/builders/16/builds/41677

18 months ago[NFC][AsmWriter] Use HasSubstr in test
Vitaly Buka [Wed, 11 Jan 2023 08:11:32 +0000 (00:11 -0800)]
[NFC][AsmWriter] Use HasSubstr in test

18 months ago[AsmWriter] Fix leak after D141343
Vitaly Buka [Wed, 11 Jan 2023 08:04:37 +0000 (00:04 -0800)]
[AsmWriter] Fix leak after D141343

18 months ago[DWARFLibrary] Init field after D137882
Vitaly Buka [Wed, 11 Jan 2023 07:52:19 +0000 (23:52 -0800)]
[DWARFLibrary] Init field after D137882

18 months ago[Clang][RISCV][NFC] Reorganize test case for rvv intrinsics
eopXD [Sat, 7 Jan 2023 15:15:59 +0000 (07:15 -0800)]
[Clang][RISCV][NFC] Reorganize test case for rvv intrinsics

The file hierarchy is reorganized into:

```
├── rvv-intrinsics-autogenerated
│   ├── non-policy
│   │   ├── non-overloaded
│   │   └── overloaded
│   └── policy
│       ├── non-overloaded
│       └── overloaded
└── rvv-intrinsics-handcrafted
```

Separating auto-generated test cases and hand-craft ones. The
auto-generated ones are basic API tests generated from the intrinsic
generator [0].

This re-organization allows direct copy-and-paste from the produced
outputs of the generator in future API changes, which is discussed
and needs to be implemented towards a v1.0 RVV intrinsic.

[0] https://github.com/riscv-non-isa/rvv-intrinsic-doc/pull/181

Reviewed By: craig.topper

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

18 months ago[libc] Use the boostrap build's target triple if available.
Siva Chandra Reddy [Tue, 3 Jan 2023 21:05:25 +0000 (21:05 +0000)]
[libc] Use the boostrap build's target triple if available.

Reviewed By: lntue

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

18 months ago[Test] Add test showing one more missing case of turn-to-invariant with widening
Max Kazantsev [Wed, 11 Jan 2023 05:56:57 +0000 (12:56 +0700)]
[Test] Add test showing one more missing case of turn-to-invariant with widening

18 months agoDo not short circuit hoistIVInc when recomputation of poison flags is needed.
Owen Anderson [Mon, 2 Jan 2023 05:27:52 +0000 (22:27 -0700)]
Do not short circuit hoistIVInc when recomputation of poison flags is needed.

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

Reviewed By: nikic

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

18 months ago[libc] Implement str{,n}casecmp
Alex Brachet [Wed, 11 Jan 2023 05:38:33 +0000 (05:38 +0000)]
[libc] Implement str{,n}casecmp

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

18 months ago[Test] Give test variables more reasonable names
Max Kazantsev [Wed, 11 Jan 2023 05:29:26 +0000 (12:29 +0700)]
[Test] Give test variables more reasonable names

18 months ago[IndVars] Support AND/OR in optimizeLoopExitWithUnknownExitCount
Max Kazantsev [Wed, 11 Jan 2023 04:12:11 +0000 (11:12 +0700)]
[IndVars] Support AND/OR in optimizeLoopExitWithUnknownExitCount

This patch allows optimizeLoopExitWithUnknownExitCount to deal with
branches by conditions that are not immediately ICmp's, but aggregates
of ICmp's joined by arithmetic or logical AND/OR. Each ICmp is optimized
independently.

Differential Revision: https://reviews.llvm.org/D139832
Reviewed By: nikic

18 months ago[gn build] Port e4e0f9330798
LLVM GN Syncbot [Wed, 11 Jan 2023 04:09:00 +0000 (04:09 +0000)]
[gn build] Port e4e0f9330798

18 months agoRemove the ThreadLocal template from LLVM.
Owen Anderson [Tue, 10 Jan 2023 03:48:20 +0000 (20:48 -0700)]
Remove the ThreadLocal template from LLVM.

This has been obsoleted by C++ thread_local for a long time.
As far as I know, Xcode was the last supported toolchain to add
support for C++ thread_local in 2016.

As a precaution, use LLVM_THREAD_LOCAL which provides even greater
backwards compatibility, allowing this to function even pre-C++11
versions of GCC.

Reviewed By: nikic

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

18 months agoRemove a FIXME that will never be fixed since undef is being removed.
Owen Anderson [Tue, 10 Jan 2023 03:14:31 +0000 (20:14 -0700)]
Remove a FIXME that will never be fixed since undef is being removed.

Reviewed By: nikic

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

18 months ago[clang-format] Properly handle the C11 _Generic keyword.
Emilia Dreamer [Wed, 11 Jan 2023 04:00:07 +0000 (06:00 +0200)]
[clang-format] Properly handle the C11 _Generic keyword.

This patch properly recognizes the generic selection expression
introduced in C11, by adding an additional token type for the colons
present in such expressions.

Previously, they would be recognized as
"inline ASM colons" purely by the fact that those are the last thing
checked for.

I tried to avoid adding an addition token type, but since colons by
default like having spaces around them, I chose to add a new type so
that no space is added after the type selector.

Currently, no aspect of the formatting of these expressions in able to
be configured, as I'm not sure what could even be configured here.

One notable thing is that association list is always formatted as
either entirely on one line, if it can fit, or with line breaks
after every comma in the expression (also after the controlling expr.)

This visually makes them more similar to switch statements when long,
matching the behaviour of the selection expression, being that of a sort
of switch on types, but also allows for terseness when only selecting
for a few things.

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

Reviewed By: HazardyKnusperkeks, owenpan, MyDeveloperDay

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

18 months ago[clang-format] Inherit RightAlign options across scopes
Emilia Dreamer [Wed, 11 Jan 2023 03:56:08 +0000 (05:56 +0200)]
[clang-format] Inherit RightAlign options across scopes

D119599 added the ability to align compound assignments, right aligning
them in order to line up at the equals sign.
However, that patch didn't account for AlignTokens being called
recursively across scopes, which reset the right justification to be
false in any scope besides the top scope. This meant the compound
assignments were aligned, just not at the right place.
(No tests also ever introduced any scopes)

This patch makes sure to inherit the right justification value, just as
every other parameter is passed on.

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

Reviewed By: HazardyKnusperkeks, owenpan, MyDeveloperDay

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

18 months ago[DAGCombiner] Update test comments for pr59898; NFC
chenglin.bi [Wed, 11 Jan 2023 02:57:54 +0000 (10:57 +0800)]
[DAGCombiner] Update test comments for pr59898; NFC

18 months ago[AArch64] Only enable `foldCSELOfCSEl` DAG combine when x != y
chenglin.bi [Wed, 11 Jan 2023 02:44:54 +0000 (10:44 +0800)]
[AArch64] Only enable `foldCSELOfCSEl` DAG combine when x != y

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

Fix: https://github.com/llvm/llvm-project/issues/59902

Reviewed By: dmgreen

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

18 months ago[mlir][vector] Fix crash in extractelement vec distribution
Thomas Raoux [Wed, 11 Jan 2023 01:42:59 +0000 (01:42 +0000)]
[mlir][vector] Fix crash in extractelement vec distribution

Prevent creating a vector of size 0 that would fail verifier.
Vector 1d with a single element should be treated like 0d vectors.

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

18 months ago[X86][CodeGen]Fix extract f16 from big vectors
Wang, Xin10 [Tue, 10 Jan 2023 14:02:49 +0000 (06:02 -0800)]
[X86][CodeGen]Fix extract f16 from big vectors

When use llc -mattr=+avx512fp16, it will crash.

```
define half @test(<64 x half> %x, i64 %idx){
   %res = extractelement <64 x half> %x, i64 %idx
   ret half %res
}
```
The root cause is when we enable avx512fp16 we lose custom handler
for extract f16 from big vectors which is not loaded from pointer.

Reviewed By: pengfei

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

18 months ago[CMake] Make libLLVM functionable for Android
Kudryashov Evgeny [Tue, 10 Jan 2023 14:01:36 +0000 (06:01 -0800)]
[CMake] Make libLLVM functionable for Android

libLLVM.so is empty if it is built with Android NDK (`-DLLVM_BUILD_LLVM_DYLIB=ON`). The patch fixes it.

Reviewed By: xbolva00

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

18 months ago[mlir][affine] Canonicalize single value affine.min/max
Kai Sasaki [Tue, 10 Jan 2023 05:42:39 +0000 (14:42 +0900)]
[mlir][affine] Canonicalize single value affine.min/max

Canonicalize identity affine.min/max to allow further optimization to follow the def-use chain of the given values. The reported issue is https://github.com/llvm/llvm-project/issues/59399.

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

18 months agoAMDGPU/SIInsertWait: Skip dummy tied source
Ruiling Song [Thu, 5 Jan 2023 01:29:48 +0000 (09:29 +0800)]
AMDGPU/SIInsertWait: Skip dummy tied source

For D16 memory load instructions, the hardware usually only write to half
of the 32bit register, but we define the destination register using
32bit register for the MachineIR instruction. Without the extra tied
source register, LLVM framework will think previous write to the other
half of the register being dead. This is because by using 32bit register
as the destination register, LLVM will think the instruction will always
overwrite the whole 32bit register. By adding the extra tied source,
LLVM will think we are reading the register, so previous write to the
register will not be dead. This dummy tied source is introducing
unnecessary read-after-write dependency. The change here is to bypass the
tied source that can be skipped, thus avoiding an unnecessary s_waitcnt.

Reviewed by: foad

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

18 months agoAMDGPU: Remove IsSourceOfDivergence check
Ruiling Song [Tue, 3 Jan 2023 07:17:54 +0000 (15:17 +0800)]
AMDGPU: Remove IsSourceOfDivergence check

This bit is not set/reserved in td file. Let's remove it for now,
we can always add it back if we need it.

Reviewed by: foad

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

18 months agoAMDGPU: Promote array alloca if used by memmove/memcpy
Ruiling Song [Tue, 20 Dec 2022 00:58:46 +0000 (08:58 +0800)]
AMDGPU: Promote array alloca if used by memmove/memcpy

Reviewed by: arsenm

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

18 months ago[NFC][AVR] Use inline field initializers
Vitaly Buka [Wed, 11 Jan 2023 01:48:37 +0000 (17:48 -0800)]
[NFC][AVR] Use inline field initializers

18 months ago[AVR] Init member added by D140830
Vitaly Buka [Wed, 11 Jan 2023 01:41:36 +0000 (17:41 -0800)]
[AVR] Init member added by D140830

18 months agoclang: Convert test to generated checks and opaque pointers
Matt Arsenault [Mon, 9 Jan 2023 23:21:11 +0000 (18:21 -0500)]
clang: Convert test to generated checks and opaque pointers

18 months agoAMDGPU: Use constant and externally_initialized for block handle
Matt Arsenault [Fri, 23 Dec 2022 20:45:34 +0000 (15:45 -0500)]
AMDGPU: Use constant and externally_initialized for block handle

The runtime initializes this.

18 months agoAMDGPU: Fix opaque pointer handling for enqueued blocks, again
Matt Arsenault [Mon, 9 Jan 2023 22:45:15 +0000 (17:45 -0500)]
AMDGPU: Fix opaque pointer handling for enqueued blocks, again

18 months agoRevert "[CMake][LoongArch] Add LoongArch to LLVM_ALL_TARGETS so it is built by default"
Weining Lu [Wed, 11 Jan 2023 01:33:03 +0000 (09:33 +0800)]
Revert "[CMake][LoongArch] Add LoongArch to LLVM_ALL_TARGETS so it is built by default"

This reverts commit b5cb91fc1cb851dcc4d3dc82a19a9d56dd352350.

This commit causes expensive check fail:
https://lab.llvm.org/buildbot/#/builders/16/builds/41677.

18 months agoThis is to fix runtime problem for member data used in target region.
Jennifer Yu [Mon, 9 Jan 2023 20:30:08 +0000 (12:30 -0800)]
This is to fix runtime problem for member data used in target region.

The problem is happened when base class member field is used in target
region , the size is wrong, cause runtime to fail. Currently the size of
calculation is depended on index of field, since field is in base class,
the calculation is wrong.

According OpenMP 5.2 148:21:
If the target construct is within a class non-static member function,
and a variable is an accessible data member of the object for which the
non-static data member function is invoked, the variable is treated as
if the this[:1] expression had appeared in a map clause with a map-type
of tofrom.

One way to fix this is emitting code to generate this[:1] instead only
when class has any base class.

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

18 months ago[NFC][AIX] Temporarily XFAIL test while investigating
Jake Egan [Wed, 11 Jan 2023 00:51:00 +0000 (19:51 -0500)]
[NFC][AIX] Temporarily XFAIL test while investigating
Previous attempt to restrict this test to x86 and aarch64 targets only didn't work.
So XFAIL this test while investigating to get the AIX bot back to green.

18 months ago[AsmWriter] Don't crash when printing a null operand bundle.
Vasileios Porpodas [Tue, 10 Jan 2023 05:25:18 +0000 (21:25 -0800)]
[AsmWriter] Don't crash when printing a null operand bundle.

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

18 months ago[libc++] Use _LIBCPP_HIDE_FROM_ABI_VIRTUAL instead of _LIBCPP_INLINE_VISIBILITY attri...
yronglin [Wed, 11 Jan 2023 00:28:22 +0000 (08:28 +0800)]
[libc++] Use _LIBCPP_HIDE_FROM_ABI_VIRTUAL instead of _LIBCPP_INLINE_VISIBILITY attribute on virtual function

Reviewed By: #libc, philnik, ldionne

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

18 months ago[lldb] Only add lldb-framework-cleanup dependency to existing targets
Jonas Devlieghere [Wed, 11 Jan 2023 00:22:07 +0000 (16:22 -0800)]
[lldb] Only add lldb-framework-cleanup dependency to existing targets

The Xcode standalone build doesn't have the install-liblldb and
install-liblldb-stripped targets. Fix the resulting CMake error "Cannot
add target-level dependencies to non-existent target" by only adding the
dependency when the targets exist.

18 months ago[libc++][test] Move `common_input_iterator` to `test_iterators.h`
Joe Loser [Sun, 8 Jan 2023 22:07:19 +0000 (15:07 -0700)]
[libc++][test] Move `common_input_iterator` to `test_iterators.h`

There's a bit of duplication in use of `common_input_iterator` as noted in
https://reviews.llvm.org/D141216.  Lift `common_input_iterator` into
`test_iterators.h`.

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

18 months ago[HWASAN] Implmented LSAN specifc thread support.
Kirill Stoimenov [Tue, 10 Jan 2023 19:25:10 +0000 (19:25 +0000)]
[HWASAN] Implmented LSAN specifc thread support.

Implemented LSAN interface on HwasanThreadList and added os_id to __hwasan::Thread.

Reviewed By: vitalybuka

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

18 months ago[CMake][LoongArch] Add LoongArch to LLVM_ALL_TARGETS so it is built by default
Weining Lu [Tue, 10 Jan 2023 23:53:06 +0000 (07:53 +0800)]
[CMake][LoongArch] Add LoongArch to LLVM_ALL_TARGETS so it is built by default

This follows the [[ https://discourse.llvm.org/t/rfc-promoting-the-loongarch-backend-from-experimental-to-official/67506/ | RFC ]].

Follow-on commits will add appropriate release notes changes etc.

Submit this now and in a minimal form so there is reasonable time before
16.0.0 is branched to resolve any issues arising from e.g. the backend
being exposed on different compiler/sanitizer setups.

The current builder for LoongArch is on the [[ https://lab.llvm.org/staging/#/builders/236 | staging area ]].

Reviewed By: jyknight, MaskRay, echristo, myhsu, tstellar, arsenm

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

18 months ago[HWASAN] Added thread annotations to HwasanThreadList.
Kirill Stoimenov [Tue, 10 Jan 2023 22:41:48 +0000 (22:41 +0000)]
[HWASAN] Added thread annotations to HwasanThreadList.

Reviewed By: vitalybuka

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

18 months ago[LegacyPM] Port example pass SimplifyCFG to new PM
Sebastian Peryt [Tue, 10 Jan 2023 23:15:42 +0000 (15:15 -0800)]
[LegacyPM] Port example pass SimplifyCFG to new PM

This is part of effort in removing -enable-new-pm flag.
As a prat of this effort one of example passes SimplifyCFG must
be ported to new PM which will allow to remove the flag
calls from the tests that are using this pass.

Reviewed By: aeubanks

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

18 months ago[RISCV] Remove RISCVSubtarget::getArchMinVLen()/getArchMaxVLen().
Craig Topper [Tue, 10 Jan 2023 23:32:11 +0000 (15:32 -0800)]
[RISCV] Remove RISCVSubtarget::getArchMinVLen()/getArchMaxVLen().

Fold them into their only callers, getRealMinVLen()/getArchMaxVLen().

It is unclear right now when these are needed so removing to discourage
misuse.

Between Zvl*b extensions, vector length command line options, and
vscale range, we have several ways to influence vector length. We
need to try to keep all code on the same page.

18 months ago[DWARFLibrary] Add support to re-construct cu-index
Alexander Yermolovich [Tue, 10 Jan 2023 23:14:47 +0000 (15:14 -0800)]
[DWARFLibrary] Add support to re-construct cu-index

According to DWARF5 specification and gnu specification for DWARF4 the offset
entry in the CU/TU Index is 32 bits. This presents a problem when
.debug_info.dwo in DWP file grows beyond 4GB. The CU Index becomes partially
corrupted.

This diff adds manual parsing of .debug_info.dwo/.debug_abbrev.dwo to
reconstruct CU index in general, and TU index for DWARF5. This is a work around
until DWARF6 spec is finalized.

Next patch will change internal CU/TU struct to 64 bit, and change uses as
necessary. The plan is to land all the patches in one go after all are approved.

This patch originates from the discussion in: https://discourse.llvm.org/t/dwarf-dwp-4gb-limit/63902

Reviewed By: dblaikie

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

18 months ago[AsmWriter] Don't crash when printing addrspace and the operand is null
Vasileios Porpodas [Mon, 9 Jan 2023 23:18:55 +0000 (15:18 -0800)]
[AsmWriter] Don't crash when printing addrspace and the operand is null

This helps print instructions with detached operands in the debugger.

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

18 months ago[gn build] Remove --rtlib=libgcc for Android builds
Arthur Eubanks [Tue, 10 Jan 2023 23:12:03 +0000 (15:12 -0800)]
[gn build] Remove --rtlib=libgcc for Android builds

Recent Android NDKs don't ship with libgcc

18 months ago[OpenMP] Avoid running openmp-opt on dead functions
Johannes Doerfert [Tue, 10 Jan 2023 21:51:28 +0000 (13:51 -0800)]
[OpenMP] Avoid running openmp-opt on dead functions

The Attributor has logic to run only on assumed live functions and this
is exposed to users now. OpenMP-opt will (mostly) ignore dead internal
functions now but run the same deduction as before if an internal
function is marked live.

This should lower compile time as we run on less code and delete more
code early on. For the full OpenMC module compiled with noinline and
JITed at runtime, we save ~25%, or ~10s on my machine during JITing.

18 months ago[OpenMP] Ensure AAHeapToShared is only looking at one function
Johannes Doerfert [Tue, 10 Jan 2023 22:01:00 +0000 (14:01 -0800)]
[OpenMP] Ensure AAHeapToShared is only looking at one function

When we collect and process allocations we did not verify the call
against the anchor scope / associated function. This should be done to
avoid processing calls multiple times and generally looking at calls not
in the AAs scope.

18 months ago[OpenMP] Disable ICV deduction by default.
Johannes Doerfert [Tue, 10 Jan 2023 21:55:06 +0000 (13:55 -0800)]
[OpenMP] Disable ICV deduction by default.

This is not tested well and needs to be revisited in the future.

18 months ago[test] Use -verify-cfg-preserved=0 in new-pass-manager.ll
Arthur Eubanks [Tue, 10 Jan 2023 22:55:12 +0000 (14:55 -0800)]
[test] Use -verify-cfg-preserved=0 in new-pass-manager.ll

This matches other tests and makes this test less sensitive

18 months agoRevert "[perf-training] Check extension in findFilesWithExtension"
Amir Aupov [Tue, 10 Jan 2023 22:21:39 +0000 (14:21 -0800)]
Revert "[perf-training] Check extension in findFilesWithExtension"

This reverts commit 1fbbf92e4fda3c7a3be1c02e1f7240135557846d.

18 months ago[Attributor] Improve use of dominating writes during reasoning
Johannes Doerfert [Wed, 14 Dec 2022 01:51:21 +0000 (17:51 -0800)]
[Attributor] Improve use of dominating writes during reasoning

This resolves a recent regression introduced by a bug fix and allows us
to use dominating write information (formerly HasBeenWrittenTo
information) to skip potential interfering accesses.

Generally, there are two changes here:
1) If we have dominating writes they form a chain and we can look at the
   least one to minimize the distance between the write and the (read)
   access in question.
2) If such a least dominating write exists, we can ignore writes in
   other functions as long as they cannot be reached from code between
   this write and the (read) access in question.

We have all the tools available to make such queries and the positive
tests show the result. Note that the negative test from the bug fix is
still in tree and not affected.

As a side-effect, we can remove the (arbitrary) treshold now on the
number of interfering accesses since we do not iterate over dominating
ones anymore.

18 months ago[libc][NFC] Remove the now unused WrapperGen tool and tests.
Siva Chandra Reddy [Tue, 10 Jan 2023 22:06:38 +0000 (22:06 +0000)]
[libc][NFC] Remove the now unused WrapperGen tool and tests.

18 months ago[mlir][tosa] Remove redundant "tosa.transpose" operations
Aviad Cohen [Tue, 10 Jan 2023 20:35:50 +0000 (12:35 -0800)]
[mlir][tosa] Remove redundant "tosa.transpose" operations

We can fold redundant Tosa::TransposeOp actions like identity tranpose/transpose(traspose).

Reviewed By: rsuderman

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

18 months ago[Sanitizer][Apple] Enable sanitizer common unittests for arm64 archs on Apple
Blue Gaston [Sat, 7 Jan 2023 00:26:54 +0000 (17:26 -0700)]
[Sanitizer][Apple] Enable sanitizer common unittests for arm64 archs on Apple

This patch enables sanitizer common unit tests for arm64 architecture only on apple devices.

It also lowers the expected compression ratio for 64 bit machines. Unsure of justification of 130. On apple arm64 we're seeing this number comeout to 128.6

rdar://101436019

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

18 months ago[mlir][Index] Add index.mins and index.minu
Krzysztof Drewniak [Mon, 9 Jan 2023 17:05:54 +0000 (17:05 +0000)]
[mlir][Index] Add index.mins and index.minu

Signed and unsigned minimum operations were missing from the Index
dialect and are needed to test integer range inference.

Reviewed By: Mogball

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

18 months ago[mlir][Arith] Fix bug in zero-extension range inference
Krzysztof Drewniak [Mon, 9 Jan 2023 16:58:24 +0000 (16:58 +0000)]
[mlir][Arith] Fix bug in zero-extension range inference

D135089 extracted the extui code into a helper, but used fromSigned
instead of fromUnsigned.

Reviewed By: Mogball, ThomasRaoux

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

18 months ago[RISCV] Add test coverage for TSO AMOs [nfc]
Philip Reames [Tue, 10 Jan 2023 20:20:50 +0000 (12:20 -0800)]
[RISCV] Add test coverage for TSO AMOs [nfc]

18 months ago[mlir][tosa] Add uint16 to TOSA type support
Rob Suderman [Tue, 10 Jan 2023 19:40:45 +0000 (11:40 -0800)]
[mlir][tosa] Add uint16 to TOSA type support

UInt16 is included as a required TOSA type for basic
operations. Added support as a TOSA Tensor.

Reviewed By: NatashaKnk

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

18 months ago[DAGCombine] fold (sext (sext_inreg x)) -> (sext (trunc x))
Amaury Séchet [Wed, 4 Jan 2023 15:17:35 +0000 (15:17 +0000)]
[DAGCombine] fold (sext (sext_inreg x)) -> (sext (trunc x))

This fixes a regression introduced by D127115 in test/CodeGen/PowerPC/store-forward-be64.ll

Reviewed By: RKSimon

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

18 months agoFix math.cbrt with vector and f16 arguments.
Johannes Reifferscheid [Tue, 10 Jan 2023 20:15:49 +0000 (21:15 +0100)]
Fix math.cbrt with vector and f16 arguments.

Reviewed By: bkramer

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

18 months agoReapply "[Attributor] Introduce AA[Intra/Inter]Reachability"
Johannes Doerfert [Sat, 17 Dec 2022 23:16:41 +0000 (15:16 -0800)]
Reapply "[Attributor] Introduce AA[Intra/Inter]Reachability"

This reverts commit e425a4c45618fcfa8ffb13be4ddfaa5d28aa38f1 after the
memory leak has been fixed.

18 months ago[libc++][utils] Remove unused import in `run.py`
Joe Loser [Mon, 9 Jan 2023 23:51:26 +0000 (16:51 -0700)]
[libc++][utils] Remove unused import in `run.py`

`import sys` is unused in `libcxx/utils/run.py`: remove it.

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

18 months ago[libc++] Remove warning for `LIBCXX_SYSROOT`, `LIBCXX_TARGET_TRIPLE`, and `LIBCXX_GCC...
Joe Loser [Tue, 10 Jan 2023 03:13:44 +0000 (20:13 -0700)]
[libc++] Remove warning for `LIBCXX_SYSROOT`, `LIBCXX_TARGET_TRIPLE`, and `LIBCXX_GCC_TOOLCHAIN`

Support for these CMake variables has been a warning for a while now.  The
comment indicates to just remove the warning message entirely as anyone impacted
had to have update to new mechanisms in order to use `libc++`.  So, remove the
warning message.

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

18 months ago[llvm][ADT] Add deduction guides for `MutableArrayRef`
Joe Loser [Mon, 9 Jan 2023 22:37:11 +0000 (15:37 -0700)]
[llvm][ADT] Add deduction guides for `MutableArrayRef`

Similar to https://reviews.llvm.org/D140896, this adds deduction guides for the
counterpart of `ArrayRef`: `MutableArrayRef`.  The update plan is the following:

1) Add deduction guides for `MutableArrayRef`.
2) Change uses in-tree from `makeMutableArrayRef` to use deduction guides
3) Mark `makeMutableArrayRef` as deprecated for some time before removing to
   give downstream users time to update.

The deduction guides are similar to those provided by the `makeMutableArrayRef`
function templates, except we don't need one explicitly from `MutableArrayRef`.

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