platform/upstream/llvm.git
13 months ago[clang][dataflow] Remove checks that test for consistency between `StructValue` and...
Martin Braenne [Thu, 20 Jul 2023 11:12:58 +0000 (11:12 +0000)]
[clang][dataflow] Remove checks that test for consistency between `StructValue` and `AggregateStorageLocation`.

Now that the redundancy between these two classes has been eliminated, these
checks aren't needed any more.

Reviewed By: ymandel, xazax.hun

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

13 months ago[clang][dataflow] Eliminate duplication between `AggregateStorageLocation` and `Struc...
Martin Braenne [Thu, 20 Jul 2023 11:12:39 +0000 (11:12 +0000)]
[clang][dataflow] Eliminate duplication between `AggregateStorageLocation` and `StructValue`.

After this change, `StructValue` is just a wrapper for an `AggregateStorageLocation`. For the wider context, see https://discourse.llvm.org/t/70086.

## How to review

- Start by looking at the comments added / changed in Value.h, StorageLocation.h,
  and DataflowEnvironment.h. This will give you a good overview of the semantic
  changes.

- Look at the corresponding .cpp files that implement the semantic changes.

- Transfer.cpp, TypeErasedDataflowAnalysis.cpp, and RecordOps.cpp show how the
  core of the framework is affected by the semantic changes.

- UncheckedOptionalAccessModel.cpp shows how this complex model is affected by
  the changes.

- Many of the changes in the rest of the patch are mechanical in nature.

Reviewed By: ymandel, xazax.hun

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

13 months ago[LAA] Add assertion to check both Start and End are invariant (NFC).
Florian Hahn [Mon, 24 Jul 2023 13:17:17 +0000 (15:17 +0200)]
[LAA] Add assertion to check both Start and End are invariant (NFC).

Add extra assert to check invariant of RuntimePointerChecking::insert to
guard against subtle changes when extending the scope of LAA.

13 months ago[llvm][nvptx] Add sm_90a
Guray Ozen [Thu, 20 Jul 2023 15:28:51 +0000 (17:28 +0200)]
[llvm][nvptx] Add sm_90a

This works adds `sm_90a` as nvptx target. `sm_90a` is required to generate  wgmma and setmaxnreg instructions.

Here is information about "a" prefix in PTX document:
Target architectures with suffix “a”, such as sm_90a, include architecture-accelerated features that are supported on the specified architecture only, hence such targets do not follow the onion layer model. Therefore, PTX code generated for such targets cannot be run on later generation devices. Architecture-accelerated features can only be used with targets that support these features.

Reviewed By: tra

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

13 months ago[mlir][gpu] Increase default SM version from 35 to 50
Guray Ozen [Mon, 24 Jul 2023 10:51:22 +0000 (12:51 +0200)]
[mlir][gpu] Increase default SM version from 35 to 50

Current SM version is 35 but it is deprecated long time ago. D155563 introduced ptxas compilations, using sm_35 causes failures in builtbot. This change increase default SM version to 50.

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

13 months ago[mlir][gpu] Fallback to JIT compilation
Guray Ozen [Mon, 24 Jul 2023 10:45:04 +0000 (12:45 +0200)]
[mlir][gpu] Fallback to JIT compilation

Recent change introduces compilation with ptxas compiler. The change is important to be able to different versions of ptxas compiler without changing the compiler.

It causes some failures in builtbot. This change adds fallback mechanism to JIt compilation that is original path.

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

13 months ago[SystemZ][z/OS] Add OpenFlags to CreateMissingDirectories path when creating temp...
Tony Tao [Mon, 24 Jul 2023 13:02:59 +0000 (09:02 -0400)]
[SystemZ][z/OS] Add OpenFlags to CreateMissingDirectories path when creating temp files

Additional patch to https://reviews.llvm.org/D103806 to add the same flags in the path where the CreateMissingDirectories booleans is set to true.

Reviewed By: abhina.sreeskantharajan

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

13 months ago[X86] combineConcatVectorOps - add basic concat(unpack(x,y),unpack(z,w)) -> unpack...
Simon Pilgrim [Mon, 24 Jul 2023 12:49:45 +0000 (13:49 +0100)]
[X86] combineConcatVectorOps - add basic concat(unpack(x,y),unpack(z,w)) -> unpack(concat(x,z),concat(y,w)) handling

Very limited support as we don't want to interfere with build_vector patterns

13 months ago[NFC][clang] Fix static analyzer concerns
Podchishchaeva, Mariya [Mon, 24 Jul 2023 12:31:47 +0000 (05:31 -0700)]
[NFC][clang] Fix static analyzer concerns

HeaderIncludesCallback and HeaderIncludesJSONCallback classes may own
resources and free them in the destructor. However they don't have copy
user-written constructors/assignment operators, so an attempt to copy a
HeaderIncludesCallback object will use compiler-generated copy
constructor which will only do dummy copy and afterwards there will be
use-after-free issues.

Reviewed By: aaron.ballman, tahonermann

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

13 months agoRevert "[Sema] Fix handling of functions that hide classes"
John Brawn [Mon, 24 Jul 2023 12:29:22 +0000 (13:29 +0100)]
Revert "[Sema] Fix handling of functions that hide classes"

This reverts commit dfca88341794eec88c5009a93c569172fff62635.

Causes clang/test/Modules/stress1.cpp to fail.

13 months ago[NFC][clang] Fix static analyzer concerns
Podchishchaeva, Mariya [Mon, 24 Jul 2023 12:15:40 +0000 (05:15 -0700)]
[NFC][clang] Fix static analyzer concerns

OMPTransformDirectiveScopeRAII doesn't have user-written copy
constructor/assignment operator but it frees memory in the destructor.
Delete these members since doesn't seem that OMPTransformDirectiveScopeRAII
objects are intended for copy.

Reviewed By: tahonermann, ABataev

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

13 months ago[Sema] Fix handling of functions that hide classes
John Brawn [Wed, 28 Jun 2023 09:31:38 +0000 (10:31 +0100)]
[Sema] Fix handling of functions that hide classes

When a function is declared in the same scope as a class with the same
name then the function hides that class. Currently this is done by a
single check after the main loop in LookupResult::resolveKind, but
this can give the wrong result when we have a using declaration in
multiple namespace scopes in two different ways:

 * When the using declaration is hidden in one namespace but not the
   other we can end up considering only the hidden one when deciding
   if the result is ambiguous, causing an incorrect "not ambiguous"
   result.

 * When two classes with the same name in different namespace scopes
   are both hidden by using declarations this can result in
   incorrectly deciding the result is ambiguous. There's currently a
   comment saying this is expected, but I don't think that's correct.

Solve this by checking each Decl to see if it's hidden by some other
Decl in the same scope. This means we have to delay removing anything
from Decls until after the main loop, in case a Decl is hidden by
another that is removed due to being non-unique.

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

13 months ago[AArch64] NFC: Move fadda tests to separate file.
Sander de Smalen [Fri, 14 Jul 2023 08:45:10 +0000 (09:45 +0100)]
[AArch64] NFC: Move fadda tests to separate file.

We want to test the fadda tests with 'streaming-compatible' flags,
such that we can ensure no 'fadda' (not valid in streaming mode) is
generated.

13 months ago[AArch64][SME] NFC: Pass target feature on RUN line, instead of function attribute.
Sander de Smalen [Thu, 13 Jul 2023 09:45:22 +0000 (10:45 +0100)]
[AArch64][SME] NFC: Pass target feature on RUN line, instead of function attribute.

This is anticipating adding new RUN lines testing for +sme, alongside +sve/+sve2.

13 months ago[NVPTX] Fix lack of `.noreturn` on certain functions for aliases
Joseph Huber [Sat, 22 Jul 2023 02:30:36 +0000 (21:30 -0500)]
[NVPTX] Fix lack of `.noreturn` on certain functions for aliases

Forgot to include this special handling on the declaration of the alias
function.

Reviewed By: tra

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

13 months agoFix the Clang sphinx build
Aaron Ballman [Mon, 24 Jul 2023 11:32:48 +0000 (07:32 -0400)]
Fix the Clang sphinx build

This addresses issues found by:
https://lab.llvm.org/buildbot/#/builders/92/builds/47783

13 months ago[InstCombine] Transform bitwise (A >> C - 1, zext(icmp)) -> zext (bitwise(A < 0,...
XChy [Mon, 24 Jul 2023 11:04:32 +0000 (13:04 +0200)]
[InstCombine] Transform bitwise (A >> C - 1, zext(icmp)) -> zext (bitwise(A < 0, icmp))

This extends foldCastedBitwiseLogic to handle the similar cases.
I have recently submitted a patch to implement a single fold like:

(A > 0) | (A < 0) -> zext (A != 0)

But it is not general enough, and some problems like
a < b & a >= b - 1 happen again.

So I generalize this fold by matching the pattern
bitwise(A >> C - 1, zext(icmp)), and replace A >> C - 1 with
zext(A < 0) here. (C is the scalar size bits of the type of A.)

Then we get bitwise(zext(A < 0), zext(icmp)), this will be folded
by original code in foldCastedBitwiseLogic, into
zext(bitwise(A < 0, icmp)). And finally, any related icmp fold will
be automatically implemented because bitwise(icmp,icmp) had been
implemented.

The proof of the correctness is obvious, because the folds below
were previously proved and implemented.
  A >> C - 1 -> zext(A < 0)
  bitwise(zext(A), zext(B)) -> zext(bitwise(A, B))
And the fold of this patch is the combination of folds above.

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

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

13 months ago[InstCombine] Add tests for bitwise (A >> C - 1, zext(icmp)) -> zext (bitwise(A<0...
XChy [Mon, 24 Jul 2023 11:02:40 +0000 (13:02 +0200)]
[InstCombine] Add tests for bitwise (A >> C - 1, zext(icmp)) -> zext (bitwise(A<0, icmp)) fold (NFC)

Tests for an upcoming bitwise (A >> C - 1, zext(icmp)) ->
zext (bitwise(A<0, icmp)) fold.

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

13 months ago[LV] Re-use existing broadcast value for live-ins.
Florian Hahn [Mon, 24 Jul 2023 10:50:46 +0000 (11:50 +0100)]
[LV] Re-use existing broadcast value for live-ins.

When requesting a vector value for a live-in, we can re-use the
broadcast of the live-in of part 0 for parts > 0.

13 months ago[InstCombine] Add test for infinite combine loop (NFC)
Nikita Popov [Mon, 24 Jul 2023 10:43:52 +0000 (12:43 +0200)]
[InstCombine] Add test for infinite combine loop (NFC)

Guard against the issue reported at
https://reviews.llvm.org/rG086ee99564af#1230303.

13 months ago[OPENMP][NFC] Editing OpenMP support page
Sandeep Kosuri [Mon, 24 Jul 2023 10:33:19 +0000 (05:33 -0500)]
[OPENMP][NFC] Editing OpenMP support page

13 months ago[clang][ASTDumper] Remove redundant dump of BlockDecl's ParmVarDecl
dingfei [Mon, 24 Jul 2023 10:38:42 +0000 (18:38 +0800)]
[clang][ASTDumper] Remove redundant dump of BlockDecl's ParmVarDecl

ParmVarDecl of BlockDecl is unnecessarily dumped twice.
Remove this duplication as other FunctionDecls.

Fixes https://github.com/llvm/llvm-project/issues/64005 (#2)

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

13 months ago[X86] combineConcatVectorOps - add concat(psadbw(x,y),psadbw(z,w)) -> psadbw(concat...
Simon Pilgrim [Mon, 24 Jul 2023 10:27:02 +0000 (11:27 +0100)]
[X86] combineConcatVectorOps - add concat(psadbw(x,y),psadbw(z,w)) -> psadbw(concat(x,z),concat(y,w)) handling

13 months ago[X86] Add reduce_add(ctpop(x)) 'count all bits in a vector' tests
Simon Pilgrim [Mon, 24 Jul 2023 10:13:56 +0000 (11:13 +0100)]
[X86] Add reduce_add(ctpop(x)) 'count all bits in a vector' tests

Also add some basic buildvector variants: build_vector(reduce_add(ctpop(x0)), reduce_add(ctpop(x1)), ...)

13 months ago[Sema][ObjC] Invalidate BlockDecl with invalid ParmVarDecl
dingfei [Mon, 24 Jul 2023 10:31:01 +0000 (18:31 +0800)]
[Sema][ObjC] Invalidate BlockDecl with invalid ParmVarDecl

BlockDecl should be invalidated because of its invalid ParmVarDecl.

Fixes #1 of https://github.com/llvm/llvm-project/issues/64005

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

13 months ago[mlir][gpu] Improving Cubin Serialization with ptxas Compiler
Guray Ozen [Mon, 24 Jul 2023 07:40:38 +0000 (09:40 +0200)]
[mlir][gpu] Improving Cubin Serialization with ptxas Compiler

This work improves how we compile the generated PTX code using the `ptxas` compiler. Currently, we rely on the driver's jit API to compile the PTX code. However, this approach has some limitations. It doesn't always produce the same binary output as the ptxas compiler, leading to potential inconsistencies in the generated Cubin files.

This work introduces a significant improvement by directly utilizing the ptxas compiler for PTX compilation. By doing so, we can achieve more consistent and reliable results in generating cubin files. Key Benefits:
- Using the Ptxas compiler directly ensures that the cubin files generated during the build process remain consistent with CUDA compilation using `nvcc` or `clang`.
- Another advantage of this work is that it allows developers to experiment with different ptxas compilers without the need to change the compiler. Performance among ptxas compiler versions are vary, therefore, one can easily try different ptxas compilers.

Reviewed By: nicolasvasilache

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

13 months ago[Sema][ObjC] Invalidate BlockDecl with invalid return expr & its parent BlockExpr
dingfei [Mon, 24 Jul 2023 10:21:14 +0000 (18:21 +0800)]
[Sema][ObjC] Invalidate BlockDecl with invalid return expr & its parent BlockExpr

Invalidate BlockDecl with implicit return type, in case any of the return value exprs is invalid.
Propagating the error info up by replacing BlockExpr with a RecoveryExpr.

The idea of this fix is given by @hokein(Haojian Wu)

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

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

13 months ago[test][TableGen] Reenable pattern-parsing.td with reverse_iteration
pvanhout [Mon, 24 Jul 2023 10:22:26 +0000 (12:22 +0200)]
[test][TableGen] Reenable pattern-parsing.td with reverse_iteration

D155821 should have fixed this.

13 months ago[Mips] Fix argument lowering for illegal vector types (PR63608)
Nikita Popov [Tue, 4 Jul 2023 11:06:20 +0000 (13:06 +0200)]
[Mips] Fix argument lowering for illegal vector types (PR63608)

The Mips MSA ABI requires that legal vector types are passed in
scalar registers in packed representation. E.g. a type like v16i8
would be passed as two i64 registers.

The implementation attempts to do the same for illegal vectors with
non-power-of-two element counts or non-power-of-two element types.
However, the SDAG argument lowering code doesn't support this, and
it is not easy to extend it to support this (we would have to deal
with situations like passing v7i18 as two i64 values).

This patch instead opts to restrict the special argument lowering
to only vectors with power-of-two elements and round element types.
Everything else is lowered naively, that is by passing each element
in promoted registers.

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

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

13 months ago[CodeGen] Add machine verification to some tests
Jay Foad [Mon, 24 Jul 2023 09:57:37 +0000 (10:57 +0100)]
[CodeGen] Add machine verification to some tests

This is to catch errors in an upcoming patch.

13 months ago[NFC][ValueTracking]: Remove redundant computeKnownBits call for LoadInst in isKnownN...
Dhruv Chawla [Fri, 21 Jul 2023 14:17:02 +0000 (19:47 +0530)]
[NFC][ValueTracking]: Remove redundant computeKnownBits call for LoadInst in isKnownNonZero

For load instructions, computeKnownBits only checks the range metadata.
This check is already present in isKnownNonZero, so there is no need to
fall through to computeKnownBits.

This change gives a speed improvement of 0.12-0.18%:
https://llvm-compile-time-tracker.com/compare.php?from=3c6ed559e5274307995586c1499a2c8e4e0276a0&to=78b462d8c4ae079638b728c6446da5999c4ee9f8&stat=instructions:u

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

13 months ago[RISCV] Set Fast flag for unaligned memory accesses
Luke Lau [Mon, 24 Jul 2023 09:58:22 +0000 (10:58 +0100)]
[RISCV] Set Fast flag for unaligned memory accesses

The +unaligned-scalar-mem and +unaligned-vector-mem features were added in
D126085 and D149375 respectively to allow subtargets to indicate that
they supported misaligned loads/stores with "sufficient" performance.
This is separate from whether or not the target actually supports
misaligned accesses, which could be determined from Zicclsm.

This patch enables the Fast flag under the assumption that any subtarget
that declares support for +unaligned-*-mem will want to opt into
optimisations that take advantage of misaligned scalar accesses, such as
store merging.

Reviewed By: reames

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

13 months ago[NFC][analyzer] Enable implicit destructor for cfg-lifetime tests
Tomasz Kamiński [Mon, 24 Jul 2023 09:02:44 +0000 (11:02 +0200)]
[NFC][analyzer] Enable implicit destructor for cfg-lifetime tests

This enables `cfg-temporary-dtors`, `cfg-rich-constructors`, and
`cfg-implicit-dtors` (defaults for CSA) for CFGLifetime test,
making int consistent with `cfg-scopes` test.
Before the fixes implemented in https://reviews.llvm.org/D153273,
this flags were incompatible.

Reviewed By: xazax.hun

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

13 months ago[LoongArch] Implement isZextFree
WANG Rui [Mon, 24 Jul 2023 09:47:09 +0000 (17:47 +0800)]
[LoongArch] Implement isZextFree

This returns true for 8-bit and 16-bit loads, allowing ld.bu/ld.hu to be selected and avoiding unnecessary masks.

Signed-off-by: WANG Rui <wangrui@loongson.cn>
Reviewed By: SixWeining, xen0n

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

13 months ago[LoongArch] Add test case showing suboptimal codegen when loading unsigned char/short
WANG Rui [Mon, 24 Jul 2023 09:47:08 +0000 (17:47 +0800)]
[LoongArch] Add test case showing suboptimal codegen when loading unsigned char/short

Implementing isZextFree will allow ld.bu or ld.hu to be selected rather than ld.b+mask and ld.h+mask.

Signed-off-by: WANG Rui <wangrui@loongson.cn>
Reviewed By: SixWeining, xen0n

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

13 months ago[LoongArch] Implement isLegalICmpImmediate
WANG Rui [Mon, 24 Jul 2023 09:35:03 +0000 (17:35 +0800)]
[LoongArch] Implement isLegalICmpImmediate

This causes a trivial improvement in the legalicmpimm.ll test case.

Signed-off-by: WANG Rui <wangrui@loongson.cn>
Reviewed By: SixWeining, xen0n

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

13 months ago[LoongArch][NFC] Add tests for (X & -256) == 256 -> (X >> 8) == 1
WANG Rui [Mon, 24 Jul 2023 09:35:02 +0000 (17:35 +0800)]
[LoongArch][NFC] Add tests for (X & -256) == 256 -> (X >> 8) == 1

Add tests for (X & -256) == 256 -> (X >> 8) == 1.

Signed-off-by: WANG Rui <wangrui@loongson.cn>
Reviewed By: xen0n

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

13 months ago[clangd] InlayHints.cpp - fix MSVC "not all control paths return a value" warning...
Simon Pilgrim [Mon, 24 Jul 2023 09:37:03 +0000 (10:37 +0100)]
[clangd] InlayHints.cpp - fix MSVC "not all control paths return a value" warning. NFC.

13 months ago[include_cleaner] IncludeSpeller.cpp - fix MSVC "not all control paths return a value...
Simon Pilgrim [Mon, 24 Jul 2023 09:34:40 +0000 (10:34 +0100)]
[include_cleaner] IncludeSpeller.cpp - fix MSVC "not all control paths return a value" warning. NFC.

13 months ago[JITLink] ppc64.h - fix MSVC "not all control paths return a value" warning. NFC.
Simon Pilgrim [Mon, 24 Jul 2023 09:33:28 +0000 (10:33 +0100)]
[JITLink] ppc64.h - fix MSVC "not all control paths return a value" warning. NFC.

13 months ago[clang][docs] Attempt to fix warning when building ReleaseNotes
Alex Bradbury [Mon, 24 Jul 2023 09:36:42 +0000 (10:36 +0100)]
[clang][docs] Attempt to fix warning when building ReleaseNotes

I believe my previous patch, 17a58b3ca7ec18585e9ea8ed8b39d72fe36fb6cb
introduced a warning here.

13 months ago[clang][RISCV] Fix ABI handling of empty structs with hard FP calling conventions...
Alex Bradbury [Mon, 24 Jul 2023 09:22:38 +0000 (10:22 +0100)]
[clang][RISCV] Fix ABI handling of empty structs with hard FP calling conventions in C++

As reported in <https://github.com/llvm/llvm-project/issues/58929>,
Clang's handling of empty structs in the case of small structs that may
be eligible to be passed using the hard FP calling convention doesn't
match g++. In general, C++ record fields are never empty unless
[[no_unique_address]] is used, but the RISC-V FP ABI overrides this.

After this patch, fields of structs that contain empty records will be
ignored, even in C++, when considering eligibility for the FP calling
convention ('flattening'). See also the relevant psABI issue
<https://github.com/riscv-non-isa/riscv-elf-psabi-doc/issues/358> which
seeks to clarify the documentation.

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

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

13 months ago[LoongArch] Implement isLegalAddImmediate
WANG Rui [Mon, 24 Jul 2023 09:16:03 +0000 (17:16 +0800)]
[LoongArch] Implement isLegalAddImmediate

This brings a trivial improvement in the and-add-lsr.ll test case.

Signed-off-by: WANG Rui <wangrui@loongson.cn>
Reviewed By: SixWeining, xen0n

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

13 months ago[LoongArch] Add tests for (and (add x, c1), (lshr y, c2))
WANG Rui [Mon, 24 Jul 2023 09:03:32 +0000 (17:03 +0800)]
[LoongArch] Add tests for (and (add x, c1), (lshr y, c2))

Add tests for (and (add x, c1), (lshr y, c2)).

Signed-off-by: WANG Rui <wangrui@loongson.cn>
Reviewed By: SixWeining, xen0n

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

13 months ago[analyzer] Fix crash in GenericTaintChecker when propagatig taint to AllocaRegion
Tomasz Kamiński [Mon, 24 Jul 2023 07:23:01 +0000 (09:23 +0200)]
[analyzer] Fix crash in GenericTaintChecker when propagatig taint to AllocaRegion

The `GenericTaintChecker` checker was crashing, when the taint
was propagated to `AllocaRegion` region in following code:
```
  int x;
  void* p = alloca(10);
  mempcy(p, &x, sizeof(x));
```
This crash was caused by the fact that determining type of
`AllocaRegion` returns a null `QualType`.

This patch makes `AllocaRegion` expose its type as `void`,
making them consistent with results of `malloc` or `new`
that produce `SymRegion` with `void*` symbol.

Reviewed By: steakhal, xazax.hun

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

13 months ago[DAGCombine] Canonicalize operands for visitANDLike
WANG Rui [Mon, 24 Jul 2023 05:24:07 +0000 (13:24 +0800)]
[DAGCombine] Canonicalize operands for visitANDLike

During the construction of SelectionDAG, there are no explicit canonicalization rules to adjust the order of operands for AND nodes.  This may prevent the optimization in DAGCombiner::visitANDLike from being triggered. This patch canonicalizes the operands before matches, which can be observed to improve optimization on the RISC-V target architecture.

Canonicalize:
```
and(x, add) -> and(add, x)
```

Signed-off-by: WANG Rui <wangrui@loongson.cn>
Reviewed By: RKSimon

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

13 months ago[RISCV] Add tests for (and (add x, c1), (lshr y, c2))
WANG Rui [Mon, 24 Jul 2023 05:23:57 +0000 (13:23 +0800)]
[RISCV] Add tests for (and (add x, c1), (lshr y, c2))

Add tests for (and (add x, c1), (lshr y, c2)).

Signed-off-by: WANG Rui <wangrui@loongson.cn>
Reviewed By: craig.topper

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

13 months ago[AArch64][SME] Use `fmov` instead of NEON `movi` for FP value.
Sander de Smalen [Mon, 24 Jul 2023 08:04:15 +0000 (08:04 +0000)]
[AArch64][SME] Use `fmov` instead of NEON `movi` for FP value.

NEON `movi` is not valid in Streaming SVE mode, so use an `fmov`
instruction instead for zero-initializing a FP value.

Reviewed By: hassnaa-arm

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

13 months agoRevert "[NFC] Add checks for self-assignment."
Michael Platings [Mon, 24 Jul 2023 08:35:19 +0000 (09:35 +0100)]
Revert "[NFC] Add checks for self-assignment."

This reverts commit 8ac137acefc01caf636db5f95eb0977c97def1ba.

The code does not compile.

13 months ago[TableGen][GlobalISel] Fix warning when casting to `void *`
pvanhout [Mon, 24 Jul 2023 08:28:39 +0000 (10:28 +0200)]
[TableGen][GlobalISel] Fix warning when casting to `void *`

13 months ago[NFC] Add checks for self-assignment.
Sindhu Chittireddy [Thu, 20 Jul 2023 03:15:47 +0000 (20:15 -0700)]
[NFC] Add checks for self-assignment.

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

13 months ago[clang][CodeGen] Introduce `-frecord-command-line` for MachO
Antonio Frighetto [Mon, 24 Jul 2023 07:23:31 +0000 (09:23 +0200)]
[clang][CodeGen] Introduce `-frecord-command-line` for MachO

Allow clang driver command-line recording when
targeting MachO object files as well.

Reviewed-by: sgraenitz
Differential Revision: https://reviews.llvm.org/D155716

13 months ago[TableGen][GlobalISel] Guarantee stable iteration order for stop-after-parse
pvanhout [Thu, 20 Jul 2023 12:24:12 +0000 (14:24 +0200)]
[TableGen][GlobalISel] Guarantee stable iteration order for stop-after-parse

Builds on top of 6de2735c2428 to fix remaining issues with iteration order in the MatchTable Combiner backend.
See D155789 as well.

Reviewed By: MaskRay

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

13 months ago[ConstraintElim] Add facts implied by MinMaxIntrinsic
Yingwei Zheng [Mon, 24 Jul 2023 07:03:34 +0000 (15:03 +0800)]
[ConstraintElim] Add facts implied by MinMaxIntrinsic

Fixes https://github.com/llvm/llvm-project/issues/63896 and https://github.com/rust-lang/rust/issues/113757.
This patch adds facts implied by llvm.smin/smax/umin/umax intrinsics.

Reviewed By: fhahn

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

13 months ago[clang-tidy] Add bugprone-empty-catch check
Piotr Zegar [Sun, 23 Jul 2023 19:22:42 +0000 (19:22 +0000)]
[clang-tidy] Add bugprone-empty-catch check

Detects and suggests addressing issues with empty catch statements.

Reviewed By: xgupta

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

13 months ago[analyzer][docs] Add CSA release notes
Balazs Benics [Mon, 24 Jul 2023 06:26:54 +0000 (08:26 +0200)]
[analyzer][docs] Add CSA release notes

We'll soon branch off, and start releasing clang-17.
Here is a patch, adjusting the release notes for what we achieved since
the last release.

I used this command to inspect the interesting commits:
```
git log --oneline llvmorg-16.0.0..llvm/main \
  clang/{lib/StaticAnalyzer,include/clang/StaticAnalyzer} | \
  grep -v NFC | grep -v -i revert
```

This filters in CSA directories and filters out NFC and revert commits.

Given that in the release-notes, we usually don't put links to commits,
I'll remove them from this patch as well. I just put them there to make
it easier to review for you.

I tried to group the changes into meaningful chunks, and dropped some of
the uninteresting commits.
I've also dropped the commits that were backported to clang-16.

Check out how it looks, and propose changes like usual.

---

FYI the `ninja docs-clang-html` produces the html docs, including the `ReleaseNotes`.
And the produced artifact will be at `build/tools/clang/docs/html/ReleaseNotes.html`.

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

13 months ago[RISCV] Add Zicond RUN lines to xaluo.ll. NFC
Craig Topper [Mon, 24 Jul 2023 05:42:36 +0000 (22:42 -0700)]
[RISCV] Add Zicond RUN lines to xaluo.ll. NFC

A couple of these tests show a need for computeKnownBits support
for Zicond.

13 months ago[JITLink][PowerPC] Correct handling of R_PPC64_REL24_NOTOC
Kai Luo [Mon, 24 Jul 2023 06:00:20 +0000 (14:00 +0800)]
[JITLink][PowerPC] Correct handling of R_PPC64_REL24_NOTOC

According to the ELFv2 ABI

> This relocation type is used to specify a function call where the TOC pointer is not initialized. It is similar to R_PPC64_REL24 in that it specifies a symbol to be resolved. If the symbol resolves to a function that requires a TOC pointer (as determined by st_other bits) then a link editor must arrange for the call to be via the global entry point of the called function. Any stub code must not rely on a valid TOC base address in r2.

This patch fixes handling of `R_PPC64_REL24_NOTOC` by using the same stub code sequence as lld.

Reviewed By: lhames

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

13 months ago[ConstraintElim] Add test cases from PR63896. NFC.
Yingwei Zheng [Mon, 24 Jul 2023 05:57:00 +0000 (13:57 +0800)]
[ConstraintElim] Add test cases from PR63896. NFC.

This patch adds some test cases from https://github.com/llvm/llvm-project/issues/63896.

Reviewed By: fhahn

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

13 months ago[RISCV] Remove unused check prefixes for tests. NFC
Jim Lin [Mon, 24 Jul 2023 04:29:07 +0000 (12:29 +0800)]
[RISCV] Remove unused check prefixes for tests. NFC

Also remove the warning line for that these prefixes are unused.

Reviewed By: craig.topper

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

13 months ago[RISCV] Support register allocation for GHC when f/d is not specified in the architecture
eopXD [Fri, 21 Jul 2023 03:59:34 +0000 (20:59 -0700)]
[RISCV] Support register allocation for GHC when f/d is not specified in the architecture

This patch supports register allocation for floating-point types when
`zfinx` and `zdinx` is specified in the architecture for the GHC
calling convention.

Reviewed By: craig.topper

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

13 months ago[LoongArch] Add definition for LVZ/LBT instructions
wanglei [Mon, 24 Jul 2023 03:40:29 +0000 (11:40 +0800)]
[LoongArch] Add definition for LVZ/LBT instructions

This patch defines the `LVZ` and `LBT` extension instructions, which
provide enough definitions for llvm-mc and llvm-objdump to correctly
handle these instructions.

It also defines the `SCR` (Scratchpad Register) register class, which
are used by the `LBT` extension instructions.

Reviewed By: SixWeining, xen0n

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

13 months ago[mlir] Enable converting properties during C create
Jacques Pienaar [Mon, 24 Jul 2023 04:40:12 +0000 (21:40 -0700)]
[mlir] Enable converting properties during C create

This enables querying properties passed as attributes during
construction time. In particular needed for type inference where the
Operation has not been created at this point. This allows Python
construction of operations whose type inference depends on properties.

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

13 months ago[XCOFF] Write source language ID and CPU version ID into C_FILE symbol.
esmeyi [Mon, 24 Jul 2023 04:35:24 +0000 (00:35 -0400)]
[XCOFF] Write source language ID and CPU version ID into C_FILE symbol.

Summary: The source language ID and CPU version ID are required by debuggers on AIX. AIX's system assembler determines the source language ID based on the source file's name suffix, and the behavior in this patch is consistent with it.

Reviewed By: shchenz

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

13 months ago[mlir][py] Reuse more of CAPI build time inference.
Jacques Pienaar [Mon, 24 Jul 2023 04:26:52 +0000 (21:26 -0700)]
[mlir][py] Reuse more of CAPI build time inference.

This reduces code generated for type inference and instead reuses
facilities CAPI side that performed same role.

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

13 months ago[AMDGPU] Add llvm.amdgcn.wave.reduce.umin/umax Intrinsic.
Pravin Jagtap [Mon, 24 Jul 2023 04:05:42 +0000 (00:05 -0400)]
[AMDGPU] Add llvm.amdgcn.wave.reduce.umin/umax Intrinsic.

When input to intrinsic is uniform value, reduced value is
same as input whereas if input value is divergent we need
to iterate over all active lanes of WaveFront to perform
the reduction.

The control flow for a `loop` has been set up, which
iterates over `only` active lanes to perform reduction.

Introduced WAVE_REDUCE_UMIN_PSEUDO_U32 and
WAVE_REDUCE_UMAX_PSEUDO_U32 Pseudos which
are lowered Post-ISel (in `EmitInstrWithCustomInserter `).

Reviewed By: arsenm, #amdgpu

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

13 months ago[RISCV] Adjust definition order in RISCVInstrInfoZvk.td to be the same with other...
Jim Lin [Mon, 24 Jul 2023 02:33:40 +0000 (10:33 +0800)]
[RISCV] Adjust definition order in RISCVInstrInfoZvk.td to be the same with other td file

The definition order is operand/SDNode, instruction class template,
instruction, pseudo instruciton, codegen patterns, ....

13 months ago[AArch64][GlobalISel] Remove unused variable 'v2s8' in AArch64LegalizerInfo.cpp ...
Jie Fu [Mon, 24 Jul 2023 03:33:02 +0000 (11:33 +0800)]
[AArch64][GlobalISel] Remove unused variable 'v2s8' in AArch64LegalizerInfo.cpp (NFC)

/Users/jiefu/llvm-project/llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp:53:13: error: unused variable 'v2s8' [-Werror,-Wunused-variable]
  const LLT v2s8 = LLT::fixed_vector(2, 8);
            ^
1 error generated.

13 months agoRevert commits for kernel environment
Shilei Tian [Mon, 24 Jul 2023 03:30:45 +0000 (23:30 -0400)]
Revert commits for kernel environment

This reverts commits for kernel environments as they causes issues in AMD BB.

13 months ago[AArch64][GlobalISel] Legalize <2 x s8> and <4 x s8> for G_BUILD_VECTOR
Zhongyunde [Mon, 24 Jul 2023 03:25:07 +0000 (11:25 +0800)]
[AArch64][GlobalISel] Legalize <2 x s8> and <4 x s8> for G_BUILD_VECTOR

Refer to commit ccffc27, the remaining types <2 x s8> and <4 x s8> should
also be promoted to <2 x s32> and <4 x s16>.

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

Reviewed By: aemerson, tschuett, paquette, dmgreen
Differential Revision: https://reviews.llvm.org/D153394

13 months ago[CMake] Disable GCC -Wnonnull
Farid Zakaria [Mon, 24 Jul 2023 03:19:42 +0000 (20:19 -0700)]
[CMake] Disable GCC -Wnonnull

I noticed during the build that GCC would emit a ton of nonnull
warnings.

Example:
```
/usr/local/google/home/fmzakari/code/github.com/llvm/llvm-project/clang/include/clang/AST/ExternalASTSource.h:378:54: warning: ‘this’ pointer is null [-Wnonnull]
  378 |       Ptr = reinterpret_cast<uint64_t>((Source->*Get)(Ptr >> 1));
      |                                        ~~~~~~~~~~~~~~^~~~~~~~~~
```

Reviewed By: MaskRay, rsmith

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

13 months ago[sanitizer] use the right type for sizeof for interceptor hook
Wu, Yingcong [Mon, 24 Jul 2023 03:12:39 +0000 (20:12 -0700)]
[sanitizer] use the right type for sizeof for interceptor hook

`PRE_READ` is called with a pointer and the size of the object
the pointer points to. But there is one line of code not calling
`PRE_READ` correctly(likely missing a dereference).
This patch fixes the problem.

Reviewed By: MaskRay

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

13 months ago[RISCV] Add codegen for Zfbfmin instructions
Jun Sha (Joshua) [Mon, 24 Jul 2023 02:37:58 +0000 (10:37 +0800)]
[RISCV] Add codegen for Zfbfmin instructions

The implementation in https://reviews.llvm.org/D151313 is done for the circumstance without Zfbfmin. This patch adds codegen support for the 6 instructions provided in Zfbfmin extension.

Reviewed By: craig.topper

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

13 months ago[X86] Remove SHA512 from Graniterapids in backend.
Freddy Ye [Mon, 24 Jul 2023 01:30:00 +0000 (01:30 +0000)]
[X86] Remove SHA512 from Graniterapids in backend.

Frontend didn't and this feature.

13 months agoReapply: [MemCpyOpt] implement single BB stack-move optimization which unify the...
khei4 [Sat, 22 Jul 2023 05:25:32 +0000 (14:25 +0900)]
Reapply: [MemCpyOpt] implement single BB stack-move optimization which unify the static unescaped allocas""

This reverts commit c9d419c1df72b0160e374f8d0b9f30508b3b98a7.
Differential Revision: https://reviews.llvm.org/D153453

13 months ago[LLVM] Remove the module dump introduced mistakenly
Shilei Tian [Sun, 23 Jul 2023 22:55:41 +0000 (18:55 -0400)]
[LLVM] Remove the module dump introduced mistakenly

13 months ago[MLIR][OpenMP] Remove local_unnamed_addr from check line
Shilei Tian [Sun, 23 Jul 2023 22:51:02 +0000 (18:51 -0400)]
[MLIR][OpenMP] Remove local_unnamed_addr from check line

13 months ago[MLIR][OpenMP] Fix wrong check lines in mlir/test/Target/LLVMIR/omptarget-region...
Shilei Tian [Sun, 23 Jul 2023 22:45:44 +0000 (18:45 -0400)]
[MLIR][OpenMP] Fix wrong check lines in mlir/test/Target/LLVMIR/omptarget-region-device-llvm.mlir

13 months ago[OpenMP] Introduce kernel environment
Shilei Tian [Sun, 23 Jul 2023 22:35:38 +0000 (18:35 -0400)]
[OpenMP] Introduce kernel environment

This patch introduces per kernel environment. Previously, flags such as execution mode are set through global variables with name like `__kernel_name_exec_mode`. They are accessible on the host by reading the corresponding global variable, but not from the device. Besides, some assumptions, such as no nested parallelism, are not per kernel basis, preventing us applying per kernel optimization in the device runtime.

This is a combination and refinement of patch series D116908, D116909, and D116910.

Depend on D155886.

Reviewed By: jdoerfert

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

13 months ago[X86] Fix a typo of Broadwell after D74918. NFC
Fangrui Song [Sun, 23 Jul 2023 22:15:05 +0000 (15:15 -0700)]
[X86] Fix a typo of Broadwell after D74918. NFC

Close #64053

13 months agoReleaseNotes: add lld/ELF notes
Fangrui Song [Sun, 23 Jul 2023 22:06:33 +0000 (15:06 -0700)]
ReleaseNotes: add lld/ELF notes

13 months ago[OpenMP][Plugin] Update the global address calculation
Shilei Tian [Sun, 23 Jul 2023 21:40:52 +0000 (17:40 -0400)]
[OpenMP][Plugin] Update the global address calculation

Current global address caculation doesn't work for AMDGPU in some cases (https://reviews.llvm.org/D142569#4506212).
The root cause is the `sh_addr` is not substracted when caculating the address.

Reviewed By: jdoerfert

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

13 months ago[mlir][docs][nfc] Fix markdown link
Andrzej Warzynski [Sun, 23 Jul 2023 21:05:47 +0000 (23:05 +0200)]
[mlir][docs][nfc] Fix markdown link

13 months ago[clang-tidy] performance-* checks: Also allow allow member expressions to be used...
Shivam Gupta [Sun, 23 Jul 2023 18:11:39 +0000 (23:41 +0530)]
[clang-tidy] performance-* checks: Also allow allow member expressions to be used in a const manner.

Until now when determining all the const uses of a VarDecl we only considered
how the variable itself was used. This change extends checking for const usages
of the type's members as well.

This increases the number of true positives for various performance checks that
share the same const usage analysis.

Path by Felix Berger

Reviewed By: njames93, PiotrZSL

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

13 months ago[AArch64] Lower fcvtl2 (fpext) via tablegen patterns.
David Green [Sun, 23 Jul 2023 18:17:11 +0000 (19:17 +0100)]
[AArch64] Lower fcvtl2 (fpext) via tablegen patterns.

This patch does two things. First it removes the tryHighFPExt DAG2DAG method
used to select fcvtl2 instructions, using tablegen patterns through
SelectExtractHigh instead. This essentially undoes D71515, in a way that should
hopefully avoid any regressions. The second is that a GI equivalent of
SelectExtractHigh is added in selectExtractHigh, from G_UNMERGE_VALUES. The
end result is that GlobalISel (and some constrained fpext) can now make use of
the fcvtl2 instructions, saving an extra dup/ext.

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

13 months agoRevert "[clang-tidy] Add bugprone-empty-catch check"
Piotr Zegar [Sun, 23 Jul 2023 18:12:47 +0000 (18:12 +0000)]
Revert "[clang-tidy] Add bugprone-empty-catch check"

CI failed on "ubuntu-fast" due to disabled exceptions.

This reverts commit f256fee5343033bf8a31aee06a80f3e982b76f82.

13 months ago[gn build] Port f256fee53430
LLVM GN Syncbot [Sun, 23 Jul 2023 18:04:35 +0000 (18:04 +0000)]
[gn build] Port f256fee53430

13 months ago[clang-tidy] Add bugprone-empty-catch check
Piotr Zegar [Sun, 23 Jul 2023 18:02:03 +0000 (18:02 +0000)]
[clang-tidy] Add bugprone-empty-catch check

Detects and suggests addressing issues with empty catch statements.

Reviewed By: xgupta

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

13 months ago[X86] IsEligibleForTailCallOptimization - use for-range loops where possible. NFCI.
Simon Pilgrim [Sun, 23 Jul 2023 17:41:12 +0000 (18:41 +0100)]
[X86] IsEligibleForTailCallOptimization - use for-range loops where possible. NFCI.

13 months ago[InstCombine] Fix bug in canonicalization of Pow2 Tests (From: D152673)
Noah Goldstein [Sun, 23 Jul 2023 16:26:20 +0000 (11:26 -0500)]
[InstCombine] Fix bug in canonicalization of Pow2 Tests (From: D152673)

D152673 Incorrectly didn't account for operand position in the `icmp`,
i.e it treated `icmp uge x, y` the same as `icmp uge y, x` which is
incorrect:
https://reviews.llvm.org/rG142f7448e770f25b774b058a7eab1f107c4daad9

The fix takes operand position into account. The new tests
exhaustively cover all operand positions for `ule`, `uge`, `ult`,
`ugt` (the set of predicates) and all transform verify with the new
commit.

Reviewed By: nikic

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

13 months ago[AArch64][GISel] Additional FPExt vector lowering
David Green [Sun, 23 Jul 2023 15:58:13 +0000 (16:58 +0100)]
[AArch64][GISel] Additional FPExt vector lowering

Similar to D155311, this adds lowering for more vector cases for FPExt

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

13 months ago[BOLT] Fix jump table issue for split functions
Maksim Panchenko [Sat, 22 Jul 2023 02:14:26 +0000 (19:14 -0700)]
[BOLT] Fix jump table issue for split functions

A jump table in a split function may contain an entry matching a start
address of another fragment of the function. While converting addresses
to labels, we used to ignore such entries resulting in underpopulated
jump table. Change that, so we always create one label per address.

Reviewed By: Amir

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

13 months ago[LSR] Use poison instead of undef as placeholder [NFC]
Nuno Lopes [Sun, 23 Jul 2023 14:57:21 +0000 (15:57 +0100)]
[LSR] Use poison instead of undef as placeholder [NFC]
This value is patcher afterwards, and only used temporarily during dbg info construction

13 months ago[X86] getIntImmCostInst - avoid repeating getNumOperands() in for-loop (style). NFC.
Simon Pilgrim [Sun, 23 Jul 2023 14:49:22 +0000 (15:49 +0100)]
[X86] getIntImmCostInst - avoid repeating getNumOperands() in for-loop (style). NFC.

13 months ago[X86] getIntImmCostInst - silence static analyzer overflow warning. NFCI.
Simon Pilgrim [Sun, 23 Jul 2023 14:45:10 +0000 (15:45 +0100)]
[X86] getIntImmCostInst - silence static analyzer overflow warning. NFCI.

Use the divideCeil uint64_t return type directly

13 months ago[Scalarizer] Fold -1 mask in shufflevector to poison instead of undef
Nuno Lopes [Sun, 23 Jul 2023 14:02:23 +0000 (15:02 +0100)]
[Scalarizer] Fold -1 mask in shufflevector to poison instead of undef
Per latest LangRef

13 months ago[clang-tidy][clang-tidy-diff.py] Change shebang from python to python3
Shivam Gupta [Sun, 23 Jul 2023 13:53:32 +0000 (19:23 +0530)]
[clang-tidy][clang-tidy-diff.py] Change shebang from python to python3

13 months ago[X86][FP16] Split v32f16 shuffle when feature BWI is off
Phoebe Wang [Sun, 23 Jul 2023 12:29:54 +0000 (20:29 +0800)]
[X86][FP16] Split v32f16 shuffle when feature BWI is off

Found this problem when investigating #63017

Reviewed By: RKSimon

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

13 months ago[clang-tidy][NFC] Fix links to fuchsia codding standard
Piotr Zegar [Sun, 23 Jul 2023 12:29:18 +0000 (12:29 +0000)]
[clang-tidy][NFC] Fix links to fuchsia codding standard

Correct links to fuchsia codding standard in
documentation for fuchsia-* checks.

Partially fixes: #62334

13 months ago[X86] lowerRegToMasks - rename masklen -> MaskLenVT. NFC.
Simon Pilgrim [Sun, 23 Jul 2023 11:21:39 +0000 (12:21 +0100)]
[X86] lowerRegToMasks - rename masklen -> MaskLenVT. NFC.

Fixes style warning