platform/upstream/llvm.git
13 months ago[clang-tidy] Check functions called from catch blocks
Deniz Evrenci [Wed, 7 Jun 2023 00:31:13 +0000 (01:31 +0100)]
[clang-tidy] Check functions called from catch blocks

These functions can rethrow a current exception that is caught by the
catch block. We can pass the currently caught excections to the function
declaration analyzer just like the statement analyzer to handle this
case.

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

13 months ago[InstCombine] Remove unused function createInstructionCombiningPass
Kazu Hirata [Sun, 11 Jun 2023 14:56:37 +0000 (07:56 -0700)]
[InstCombine] Remove unused function createInstructionCombiningPass

The last use was removed by:

  commit 934c82d31801e65aa3bbe99a0e64f903621c2e04
  Author: Florian Hahn <flo@fhahn.com>
  Date:   Fri Feb 24 13:39:32 2023 +0100

Once I remove createInstructionCombiningPass, then:

InstructionCombiningPass::InstructionCombiningPass(unsigned MaxIterations)

becomes unused.  Once I remove that:

InstructionCombiningPass::MaxIterations is always initialized with
InstCombineDefaultMaxIterations, so this patch does the constant
propagation and removes InstructionCombiningPass::MaxIterations as
well.

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

13 months ago[ConstraintElimination] Handle `ICMP_EQ` predicates
Antonio Frighetto [Sat, 10 Jun 2023 16:49:33 +0000 (18:49 +0200)]
[ConstraintElimination] Handle `ICMP_EQ` predicates

Simplification of equality predicates is now supported by
transferring equalities into inequalities. This is achieved
by separately checking that both `isConditionImplied(A >= B)`
and `isConditionImplied(A <= B)` hold.

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

13 months ago[NFC] Replace ;; with ;
David Green [Sun, 11 Jun 2023 09:25:24 +0000 (10:25 +0100)]
[NFC] Replace ;; with ;

13 months ago[RISCV][NFC] Fix typo in RISCVAsmPrinter::emitNTLHint
Yingwei Zheng [Sun, 11 Jun 2023 08:42:01 +0000 (16:42 +0800)]
[RISCV][NFC] Fix typo in RISCVAsmPrinter::emitNTLHint

13 months ago[AArch64] Make VECREDUCE_FMIN/FMAX legal. NFCI
David Green [Sun, 11 Jun 2023 08:42:34 +0000 (09:42 +0100)]
[AArch64] Make VECREDUCE_FMIN/FMAX legal. NFCI

VECREDUCE_FMIN/FMAX wil be lowered to fminnmv/fmaxnmv. They needn't be custom
lowered through an intrinsic to do it, and can be treated as Legal instead.

13 months ago[libcxx] Use the unoptimized routines for volatile source types
AdityaK [Sun, 11 Jun 2023 06:10:23 +0000 (23:10 -0700)]
[libcxx] Use the unoptimized routines for volatile source types

As reported in: D147741

Reviewers: philnik, var-const, ldionne, hans

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

13 months ago[ObjectYAML] Remove unused struct DebugSubsectionState
Kazu Hirata [Sun, 11 Jun 2023 04:52:52 +0000 (21:52 -0700)]
[ObjectYAML] Remove unused struct DebugSubsectionState

The last use was removed by:

  commit a3da4467fa8ed514130736c6c15f01422159d00d
  Author: Zachary Turner <zturner@google.com>
  Date:   Wed Jun 14 05:31:00 2017 +0000

13 months ago[Scalar] Remove unused function createLICMPass
Kazu Hirata [Sun, 11 Jun 2023 04:52:50 +0000 (21:52 -0700)]
[Scalar] Remove unused function createLICMPass

The last use was removed by:

  commit d623b2f95fd559901f008a0588dddd0949a8db01
  Author: Arthur Eubanks <aeubanks@google.com>
  Date:   Fri Mar 10 17:24:19 2023 -0800

13 months ago[CodeGen] Remove unused declaration createNVPTXRuntimeFunction
Kazu Hirata [Sun, 11 Jun 2023 04:52:49 +0000 (21:52 -0700)]
[CodeGen] Remove unused declaration createNVPTXRuntimeFunction

The corresponding definition was removed by:

  commit 3cc1f1fc1d97952136185f4eafb827694875de17
  Author: Joseph Huber <jhuber6@vols.utk.edu>
  Date:   Thu Oct 8 12:03:11 2020 -0400

13 months ago[Transforms] Remove unused declaration createGVExtractionPass
Kazu Hirata [Sun, 11 Jun 2023 04:52:47 +0000 (21:52 -0700)]
[Transforms] Remove unused declaration createGVExtractionPass

The corresponding function definition was removed by:

  commit 2118b9d39b91e93c0146611235072cd6ca0f27b1
  Author: Arthur Eubanks <aeubanks@google.com>
  Date:   Tue Dec 20 12:55:05 2022 -0800

13 months ago[TableGen] Fix indentation. NFC
Michael Liao [Sun, 11 Jun 2023 02:03:33 +0000 (22:03 -0400)]
[TableGen] Fix indentation. NFC

13 months ago[llvm] Remove unused declarations initialize.*Pass
Kazu Hirata [Sun, 11 Jun 2023 02:21:00 +0000 (19:21 -0700)]
[llvm] Remove unused declarations initialize.*Pass

13 months ago[AVR] Optimize 8-bit rotation when rotation bits == 3
Ben Shi [Sun, 11 Jun 2023 00:41:44 +0000 (08:41 +0800)]
[AVR] Optimize 8-bit rotation when rotation bits == 3

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

Reviewed By: aykevl

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

13 months ago[AVR] Optimize 8-bit rotation when rotation bits >= 4
Ben Shi [Sun, 11 Jun 2023 00:36:16 +0000 (08:36 +0800)]
[AVR] Optimize 8-bit rotation when rotation bits >= 4

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

Reviewed By: aykevl, Patryk27, jacquesguan

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

13 months ago[Transforms] Remove AddDiscriminatorsLegacyPass
Kazu Hirata [Sat, 10 Jun 2023 22:32:47 +0000 (15:32 -0700)]
[Transforms] Remove AddDiscriminatorsLegacyPass

The last use was removed by:

  commit ae0987d242e266847f21f5fa1bffa97ce3eff586
  Author: Kazu Hirata <kazu@google.com>
  Date:   Sat Jun 10 13:51:35 2023 -0700

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

13 months ago[Scalar] Remove CallSiteSplittingLegacyPass
Kazu Hirata [Sat, 10 Jun 2023 22:20:40 +0000 (15:20 -0700)]
[Scalar] Remove CallSiteSplittingLegacyPass

The last use was removed by:

  commit fd48d0a0adaa5fcdd24d02a58ba8a6210adafc28
  Author: Kazu Hirata <kazu@google.com>
  Date:   Sat Jun 10 13:51:37 2023 -0700

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

13 months ago[Transforms] Remove unused function createSimpleLoopUnrollPass
Kazu Hirata [Sat, 10 Jun 2023 20:51:38 +0000 (13:51 -0700)]
[Transforms] Remove unused function createSimpleLoopUnrollPass

The last use was removed by:

  commit d623b2f95fd559901f008a0588dddd0949a8db01
  Author: Arthur Eubanks <aeubanks@google.com>
  Date:   Fri Mar 10 17:24:19 2023 -0800

13 months ago[Transforms] Remove unused function createCallSiteSplittingPass
Kazu Hirata [Sat, 10 Jun 2023 20:51:37 +0000 (13:51 -0700)]
[Transforms] Remove unused function createCallSiteSplittingPass

The last use was removed by:

  commit d623b2f95fd559901f008a0588dddd0949a8db01
  Author: Arthur Eubanks <aeubanks@google.com>
  Date:   Fri Mar 10 17:24:19 2023 -0800

13 months ago[Transforms] Remove unused function createAddDiscriminatorsPass
Kazu Hirata [Sat, 10 Jun 2023 20:51:35 +0000 (13:51 -0700)]
[Transforms] Remove unused function createAddDiscriminatorsPass

  commit f7ca01333214f934c580c162afdee933e7430b6c
  Author: Nikita Popov <npopov@redhat.com>
  Date:   Tue Feb 28 16:38:45 2023 +0100

13 months ago[Analysis] Remove unused function createAAResultsWrapperPass
Kazu Hirata [Sat, 10 Jun 2023 20:51:34 +0000 (13:51 -0700)]
[Analysis] Remove unused function createAAResultsWrapperPass

The last use was removed by:

  commit 934c82d31801e65aa3bbe99a0e64f903621c2e04
  Author: Florian Hahn <flo@fhahn.com>
  Date:   Fri Feb 24 13:39:32 2023 +0100

13 months ago[ConstraintElim] Add additional monotonic phi tests.
Florian Hahn [Sat, 10 Jun 2023 20:43:05 +0000 (21:43 +0100)]
[ConstraintElim] Add additional monotonic phi tests.

Add extra test coverage with cases that showed mis-compiles in earlier
versions of an upcoming patch. Also add tests for integer phis

13 months agoRevert "[MCParser] Modernize CppHashInfoTy (NFC)"
Kazu Hirata [Sat, 10 Jun 2023 20:34:30 +0000 (13:34 -0700)]
Revert "[MCParser] Modernize CppHashInfoTy (NFC)"

This reverts commit c0f9d7b0e6199ca3bde5a6d0036a8ada0bb6253b.

A build error has been reported with gcc-7.

This patch fixes:

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

13 months ago[X86] Make constant `mul` -> `shl` + `add`/`sub` work for vector types
Noah Goldstein [Sat, 10 Jun 2023 18:17:55 +0000 (13:17 -0500)]
[X86] Make constant `mul` -> `shl` + `add`/`sub` work for vector types

Something like:
    `%r = mul %x, <33, 33, 33, ...>`

Is best lowered as:
    `%tmp = %shl x, <5, 5, 5>; %r = add %tmp, %x`

As well, since vectors have non-destructive shifts, we can also do
cases where the multiply constant is `Pow2A +/- Pow2B` for arbitrary A
and B, unlike in the scalar case where the extra `mov` instructions
make it not worth it.

Reviewed By: pengfei

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

13 months ago[InstCombine] Canonicalize (icmp eq/ne X, rotate(X)) to always use rotate-left
Noah Goldstein [Sat, 10 Jun 2023 18:16:53 +0000 (13:16 -0500)]
[InstCombine] Canonicalize (icmp eq/ne X, rotate(X)) to always use rotate-left

We canonicalize rotate-right -> rotate-left in other places. Makes
sense to do so here as well.
Proof: https://alive2.llvm.org/ce/z/HL3TpK

Reviewed By: nikic

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

13 months ago[InstCombine] Transform (icmp eq/ne rotate(X,AX),rotate(Y,AY)) -> (icmp eq/ne rotate...
Noah Goldstein [Wed, 7 Jun 2023 17:42:22 +0000 (12:42 -0500)]
[InstCombine] Transform (icmp eq/ne rotate(X,AX),rotate(Y,AY)) -> (icmp eq/ne rotate(Y,AX-AY))

Only do so if we don't create more instructions, so either both
rotates have one use or one of the rotates has one use and both `AX`
and `AY` are constant.
Proof: https://alive2.llvm.org/ce/z/rVmJgz

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

13 months ago[InstCombine] Add tests for equality `icmp` with rotates; NFC
Noah Goldstein [Wed, 7 Jun 2023 17:41:16 +0000 (12:41 -0500)]
[InstCombine] Add tests for equality `icmp` with rotates; NFC

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

13 months ago[libc++][spaceship][NFC] Updates `SpaceshipProjects.csv` with full details from ...
Hristo Hristov [Sat, 18 Mar 2023 17:58:26 +0000 (19:58 +0200)]
[libc++][spaceship][NFC] Updates `SpaceshipProjects.csv` with full details from `P1614R2`

Adds the remaining sections from [[ https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1614r2.html | P1614R2 ]]
Some entries were reordered for easier tracking.
The items in the table match [[ https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1614r2.html | P1614R2 ]]'s sections strictly.

Reviewed By: Mordante, #libc

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

13 months ago[Transforms] Fix an unused variable warning
Kazu Hirata [Sat, 10 Jun 2023 18:57:48 +0000 (11:57 -0700)]
[Transforms] Fix an unused variable warning

This patch fixes:

  llvm/lib/Transforms/Utils/AMDGPUEmitPrintf.cpp:415:18: error: unused
  variable 'StBuff' [-Werror,-Wunused-variable]

13 months ago[AMDGPU] Stop hardcoding v_mov_b32 in VOPD. NFCI.
Stanislav Mekhanoshin [Sat, 10 Jun 2023 10:18:06 +0000 (03:18 -0700)]
[AMDGPU] Stop hardcoding v_mov_b32 in VOPD. NFCI.

There is no single possible reason to to it.

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

13 months ago[CMake] Add missing CheckCSourceCompiles include
Sam James [Sat, 10 Jun 2023 18:20:47 +0000 (19:20 +0100)]
[CMake] Add missing CheckCSourceCompiles include

Fails with cmake-3.27_rc1 otherwise:
```

CMake Error at /var/tmp/portage/sys-libs/libcxxabi-17.0.0_pre20230609/work/llvm/cmake/modules/HandleLLVMOptions.cmake:821 (CHECK_C_SOURCE_COMPILES):
  Unknown CMake command "CHECK_C_SOURCE_COMPILES".
Call Stack (most recent call first):
  CMakeLists.txt:156 (include)
```

Needed for CHECK_C_SOURCE_COMPILES.

Bug: https://bugs.gentoo.org/908233

Reviewed By: mgorny

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

13 months ago[CodeGen] Remove mentions of OLDPM
Kazu Hirata [Sat, 10 Jun 2023 17:40:43 +0000 (10:40 -0700)]
[CodeGen] Remove mentions of OLDPM

We stopped testing with -check-prefix=SAMPLEPGO-OLDPM and
-check-prefix=THINLTO-OLDPM as of:

  commit 8a7a28075b7fa70d56b131c10a4d1add777d5830
  Author: Thomas Preud'homme <thomasp@graphcore.ai>
  Date:   Fri Sep 17 10:23:40 2021 +0100

13 months ago[Transforms] Remove unused declaration createAssumeSimplifyPass
Kazu Hirata [Sat, 10 Jun 2023 17:40:41 +0000 (10:40 -0700)]
[Transforms] Remove unused declaration createAssumeSimplifyPass

The corresponding function definition was removed by:

  commit 7be8341f19bfd9baf979ecadef22d1bcaa47b54e
  Author: Arthur Eubanks <aeubanks@google.com>
  Date:   Tue Apr 25 14:34:24 2023 -0700

13 months agoFix CodeGen HIP test case failing on some targets
Vikram [Sat, 10 Jun 2023 17:27:48 +0000 (13:27 -0400)]
Fix CodeGen HIP test case failing on some targets

13 months ago[MLIR][doc] Make summary appear different than discription
rikhuijzer [Sat, 10 Jun 2023 17:10:34 +0000 (19:10 +0200)]
[MLIR][doc] Make summary appear different than discription

This patch aims to clarify which part of the docs is the summary and which
part is the description.

I did a preview of the output and think the suggested bold and italic style
is much clearer and looks reasonably nice.

I've considered also to enforce capitalization of the first letter of the
summary and ending with a dot (as discussed in
https://reviews.llvm.org/D151649), but it seems to me that the tradeoff in
extra test running time is not worth it. Currently, `emitOpDoc` is not
triggered for every `summary` during `check-mlir`.

Reviewed By: jpienaar

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

13 months agoLowerMemIntrinsics: Skip memmove with different address spaces
Matt Arsenault [Sat, 10 Jun 2023 15:58:09 +0000 (11:58 -0400)]
LowerMemIntrinsics: Skip memmove with different address spaces

This is a quick fix for an assert when the source and dest have
different address spaces. The pointer compare needs to have matching
types, but we can't generically introduce addrspacecast and we don't
know if the address spaces alias.

13 months ago[AVR] Fix incorrect expansion of pseudo instruction ROLBRd
Ben Shi [Wed, 7 Jun 2023 09:59:02 +0000 (17:59 +0800)]
[AVR] Fix incorrect expansion of pseudo instruction ROLBRd

Since ROLBRd needs an implicit R1 (on AVR) or an implicit R17 (on AVRTiny),
we split ROLBRd to ROLBRdR1 (on AVR) and ROLBRdR17 (on AVRTiny).

Reviewed By: aykevl, Patryk27

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

13 months ago[AVR] Enable sub register liveness
Ben Shi [Sat, 10 Jun 2023 03:22:33 +0000 (11:22 +0800)]
[AVR] Enable sub register liveness

Reviewed By: Patryk27

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

13 months ago[AVR][NFC] Improve CodeGen tests
Ben Shi [Sat, 10 Jun 2023 03:25:53 +0000 (11:25 +0800)]
[AVR][NFC] Improve CodeGen tests

Reviewed By: Patryk27

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

13 months ago[MCParser] Modernize CppHashInfoTy (NFC)
Kazu Hirata [Sat, 10 Jun 2023 16:02:26 +0000 (09:02 -0700)]
[MCParser] Modernize CppHashInfoTy (NFC)

13 months ago[llvm] Use DenseMapBase::lookup (NFC)
Kazu Hirata [Sat, 10 Jun 2023 16:02:25 +0000 (09:02 -0700)]
[llvm] Use DenseMapBase::lookup (NFC)

13 months ago[Transforms] Remove unused declarations
Kazu Hirata [Sat, 10 Jun 2023 16:02:23 +0000 (09:02 -0700)]
[Transforms] Remove unused declarations

The corresponding function definitions were removed by:

  commit 4153f989bab0f2f300fa8d3001ebeef7b6d9672c
  Author: Arthur Eubanks <aeubanks@google.com>
  Date:   Sun Oct 2 13:20:21 2022 -0700

13 months ago[Transforms] Remove unused declarations
Kazu Hirata [Sat, 10 Jun 2023 16:02:21 +0000 (09:02 -0700)]
[Transforms] Remove unused declarations

The corresponding function definitions were removed by:

  commit ef37504879eecab1af98c70888bee0be403b9c60
  Author: Arthur Eubanks <aeubanks@google.com>
  Date:   Mon Oct 24 09:26:16 2022 -0700

13 months ago[TableGen] Remove unused declaration TimeRegions
Kazu Hirata [Sat, 10 Jun 2023 16:02:20 +0000 (09:02 -0700)]
[TableGen] Remove unused declaration TimeRegions

The corresponding definition was removed by:

  commit 54f9ee334114e9b494fc80978357d58295a48bd1
  Author: Paul C. Anagnostopoulos <paul@windfall.com>
  Date:   Thu Oct 22 02:58:49 2020 -0400

13 months agoAMDGPU: Implement known bits functions for min3/max3/med3
Matt Arsenault [Wed, 27 Jan 2016 21:45:37 +0000 (13:45 -0800)]
AMDGPU: Implement known bits functions for min3/max3/med3

13 months agoAMDGPU: Add baseline tests for known bits handling of med3
Matt Arsenault [Sat, 10 Jun 2023 12:25:03 +0000 (08:25 -0400)]
AMDGPU: Add baseline tests for known bits handling of med3

13 months ago[flang][hlfir] allow recursive intrinsic lowering
Tom Eccles [Tue, 6 Jun 2023 15:15:25 +0000 (15:15 +0000)]
[flang][hlfir] allow recursive intrinsic lowering

We need to allow recursive application of intrinsic lowering patterns,
otherwise we cannot lower nested calls of the same intrinsic e.g.
matmul(matmul(a, b), c).

matmul(matmul(a, b), matmul(c, d)) requires hlfir.associate of hlfir
expr with more than one use (TODO).

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

13 months ago[AMDGPU] Non hostcall printf support for HIP
Vikram [Thu, 11 May 2023 09:00:17 +0000 (05:00 -0400)]
[AMDGPU] Non hostcall printf support for HIP

This is an alternative to currently existing hostcall implementation and uses printf buffer similar to OpenCL,
The data stored in the buffer (i.e the data frame) for each printf call are as follows,
1. Control DWord - contains info regarding stream, format string constness and size of data frame
2. Hash of the format string (if constant) else the format string itself
3. Printf arguments (each aligned to 8 byte boundary)

The format string Hash is generated using LLVM's MD5 Message-Digest Algorithm implementation and only low 64 bits are used.
The implementation still uses amdhsa metadata and hash is stored as part of format string itself to ensure
minimal changes in runtime.

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

13 months ago[clang][WebAssembly] Implement support for table types and builtins
Paulo Matos [Sat, 10 Jun 2023 13:51:05 +0000 (15:51 +0200)]
[clang][WebAssembly] Implement support for table types and builtins

This commit implements support for WebAssembly table types and
respective builtins. Table tables are WebAssembly objects to store
reference types. They have a large amount of semantic restrictions
including, but not limited to, only being allowed to be declared
at the top-level as static arrays of zero-length. Not being arguments
or result of functions, not being stored ot memory, etc.

This commit introduces the __attribute__((wasm_table)) to attach to
arrays of WebAssembly reference types. And the following builtins to
manage tables:

* ref   __builtin_wasm_table_get(table, idx)
* void  __builtin_wasm_table_set(table, idx, ref)
* uint  __builtin_wasm_table_size(table)
* uint  __builtin_wasm_table_grow(table, ref, uint)
* void  __builtin_wasm_table_fill(table, idx, ref, uint)
* void  __builtin_wasm_table_copy(table, table, uint, uint, uint)

This commit also enables reference-types feature at bleeding-edge.

This is joint work with Alex Bradbury (@asb).

Reviewed By: aaron.ballman

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

13 months agoAMDGPU: Move LICM after AMDGPUCodeGenPrepare
Matt Arsenault [Thu, 8 Jun 2023 01:17:25 +0000 (21:17 -0400)]
AMDGPU: Move LICM after AMDGPUCodeGenPrepare

The commit that added the run says it's to hoist uniform parts of
integer division expansion. That expansion is performed later, so this
didn't do anything in that case. Move this later so the original test
shows the improvement.

This also saves a run of "Canonicalize natural loops". Not sure why
this appears to be still getting a separate loop PM run. Also feels a
bit heavy to run this just for divide. Is there a way to specifically
hoist the divide sequence when it expands?

13 months ago[clang-tidy] Optimize misc-confusable-identifiers
Piotr Zegar [Sat, 10 Jun 2023 07:44:18 +0000 (07:44 +0000)]
[clang-tidy] Optimize misc-confusable-identifiers

This is final optimization for this check. Main
improvements comes from changing a logic order
in mayShadow function, to first validate result
of mayShadowImpl, then search primary context in
a vectors. Secondary improvement comes from excluding
all implicit code by using TK_IgnoreUnlessSpelledInSource.
All other changes are just cosmetic improvements.

Tested on Cataclysm-DDA open source project, result in
check execution time reduction from 3682 seconds to
100 seconds (~0.25s per TU). That's 97.2% reduction for
this change alone. Resulting in cumulative improvement for
this check around -99.6%, finally bringing this check
into a cheap category.

Reviewed By: serge-sans-paille

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

13 months agoPromoteMem2Reg: use poison instead of undef as placeholder in phi entries from unreac...
Nuno Lopes [Sat, 10 Jun 2023 10:19:03 +0000 (11:19 +0100)]
PromoteMem2Reg: use poison instead of undef as placeholder in phi entries from unreachable predecessors [NFC]

13 months ago[SCCP] Skip computing intrinsics if one of its args is unknownOrUndef
luxufan [Sat, 10 Jun 2023 07:48:46 +0000 (15:48 +0800)]
[SCCP] Skip computing intrinsics if one of its args is unknownOrUndef

For constant range supported intrinsics, we got consantrange from args
no matter if they are unknown or undef. And the constant range computed
from unknown or undef value state is full range.

I think compute with full constant range is harmful since although we
can do mergeIn after these args value state are changed, the merge
operation of two constant ranges is union.

Reviewed By: nikic

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

13 months ago[SCCP][NFC] Precommit test
luxufan [Sat, 10 Jun 2023 07:36:06 +0000 (15:36 +0800)]
[SCCP][NFC] Precommit test

13 months ago[NFC][SetVector] Update some usages of SetVector to SmallSetVector
Dhruv Chawla [Thu, 8 Jun 2023 14:51:39 +0000 (20:21 +0530)]
[NFC][SetVector] Update some usages of SetVector to SmallSetVector

This patch is a continuation of D152497. It updates usages of SetVector
that were found in llvm/ and clang/ which were originally specifying either
SmallPtrSet or SmallVector to just using SmallSetVector, as the overhead
of SetVector is reduced with D152497.

This also helps clean up the code a fair bit, and gives a decent speed
boost at -O0 (~0.2%):
https://llvm-compile-time-tracker.com/compare.php?from=9ffdabecabcddde298ff313f5353f9e06590af62&to=97f1c0cde42ba85eaa67cbe89bec8fe45b801f21&stat=instructions%3Au

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

13 months ago[SetVector] Improve performance for small sizes
Dhruv Chawla [Wed, 7 Jun 2023 07:16:52 +0000 (12:46 +0530)]
[SetVector] Improve performance for small sizes

SmallSetVector has an inefficiency where it does set insertions
regardless of the number of elements present within it. This contrasts
with other "Small-" containers where they use linear scan up to a
certain size "N", after which they switch to another strategy.

This patch implements this functionality in SetVector, adding a template
parameter "N" which specifies the number of elements upto which the
SetVector follows the "small" strategy. Due to the use of "if
constexpr", there is no "small" code emitted when N is 0 which makes
this a zero overhead change for users using the default behaviour.

This change also allows having SmallSetVector use DenseSet instead of
SmallDenseSet by default, which helps a little with performance.

The reason for implementing this functionality in SetVector instead of
SmallSetVector is that it allows reusing all the code that is already
there and it is just augmented with the "isSmall" checks.

This change gives a good speedup (0.4%):
https://llvm-compile-time-tracker.com/compare.php?from=086601eac266ec253bf313c746390ff3e5656132&to=acd0a72a4d3ee840f7b455d1b35d82b11ffdb3c0&stat=instructions%3Au

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

13 months ago[libc][NFC] Introduce a Location object for consistent failure logging
Guillaume Chatelet [Fri, 9 Jun 2023 13:23:27 +0000 (13:23 +0000)]
[libc][NFC] Introduce a Location object for consistent failure logging

This is just an implementation detail.

Reviewed By: sivachandra

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

13 months ago[libc][NFC] Clean up matchers namespace
Guillaume Chatelet [Fri, 9 Jun 2023 13:37:01 +0000 (13:37 +0000)]
[libc][NFC] Clean up matchers namespace

This is a follow up to https://reviews.llvm.org/D152503

Reviewed By: sivachandra

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

13 months ago[libc][math] Move str method from FPBits class to testing utils.
Tue Ly [Sat, 10 Jun 2023 03:48:49 +0000 (23:48 -0400)]
[libc][math] Move str method from FPBits class to testing utils.

str method of FPBits class is only used for pretty printing its objects
in tests.  It brings cpp::string dependency to FPBits class, which is not ideal
for embedded use case.  We move str method to a free function in test utils and
remove this dependency of FPBits class.

Reviewed By: sivachandra

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

13 months ago[MemCpyOpt] Use memcpy source directly if dest is known to be immutable from attributes
khei4 [Wed, 7 Jun 2023 03:26:33 +0000 (12:26 +0900)]
[MemCpyOpt] Use memcpy source directly if dest is known to be immutable from attributes
Differential Revision: https://reviews.llvm.org/D150970

13 months ago[MemCpyOpt] precommit test for memcpy removal for immutable arguments from attributes...
khei4 [Wed, 7 Jun 2023 03:23:00 +0000 (12:23 +0900)]
[MemCpyOpt] precommit test for memcpy removal for immutable arguments from attributes (NFC)
Differential Revision: https://reviews.llvm.org/D150967

13 months ago[clang][NFC] Refactor printableTextForNextCharacter
Timm Bäder [Thu, 18 May 2023 05:26:42 +0000 (07:26 +0200)]
[clang][NFC] Refactor printableTextForNextCharacter

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

13 months ago[clang][parse][NFC] Fix grammar in a comment
Timm Bäder [Fri, 9 Jun 2023 04:54:04 +0000 (06:54 +0200)]
[clang][parse][NFC] Fix grammar in a comment

13 months ago[GlobalIsel][X86] Legalize G_FREEZE
Thorsten Schütt [Fri, 9 Jun 2023 07:08:25 +0000 (09:08 +0200)]
[GlobalIsel][X86] Legalize G_FREEZE

Reviewed By: arsenm

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

13 months ago[libc++][spaceship] Implement `operator<=>` for `stack`
Hristo Hristov [Tue, 14 Mar 2023 19:18:55 +0000 (21:18 +0200)]
[libc++][spaceship] Implement `operator<=>` for `stack`

Depends on D146066

Depends on D132268

Implements parts of P1614R2 `operator<=>` for `stack`

Reviewed By: #libc, Mordante

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

13 months ago[SelectionDAG] Update test case according to post review comments, NFC
Phoebe Wang [Sat, 10 Jun 2023 04:00:46 +0000 (12:00 +0800)]
[SelectionDAG] Update test case according to post review comments, NFC

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

13 months ago[HWASAN] Fix verbose_threads
Vitaly Buka [Sat, 10 Jun 2023 03:39:15 +0000 (20:39 -0700)]
[HWASAN] Fix verbose_threads

Looks like D104248 acidentally moved the code.

13 months ago[libc++][spaceship] Implement `operator<=>` for `vector`
Hristo Hristov [Sat, 20 May 2023 15:37:00 +0000 (18:37 +0300)]
[libc++][spaceship] Implement `operator<=>` for `vector`

Implements part of P1614R2 "The Mothership has Landed"

Depends on D150188

Reviewed By: Mordante, #libc

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

13 months ago[libc++][spaceship] Fixed `__debug_three_way_comp`'s `operator()` for `vector<bool...
Hristo Hristov [Fri, 9 Jun 2023 17:00:19 +0000 (20:00 +0300)]
[libc++][spaceship] Fixed `__debug_three_way_comp`'s `operator()` for `vector<bool>'s `operator<=>`

An issue with `operator()` was found during the implementation of https://reviews.llvm.org/D132268.

This patch aims to resolve the issues by updating the operator to use perfect forwarding.

The original motivation for `three_way_comp_ref_type` is given in: https://reviews.llvm.org/D131395

`three_way_comp_ref_type`'s implementation is inspired by `comp_ref_type`, which has two overloads:

```
    template <class _Tp, class _Up>
    bool operator()(const _Tp& __x,  const _Up& __y);

    template <class _Tp, class _Up>
    bool operator()(_Tp& __x,  _Up& __y);
```

`__debug_three_way_comp` is missing the first overload and also declares the typealias`_three_way_comp_ref_type ` incorrectly.

Reviewed By: #libc, philnik

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

13 months ago[test][HWASAN] Add verbose_threads test
Vitaly Buka [Sat, 10 Jun 2023 03:32:08 +0000 (20:32 -0700)]
[test][HWASAN] Add verbose_threads test

13 months ago[NFC] Remove old README.txt under llvm/lib/Analysis/
Shivam Gupta [Fri, 9 Jun 2023 12:31:51 +0000 (18:01 +0530)]
[NFC] Remove old README.txt under llvm/lib/Analysis/

Github issue might be place to list them.
I think these two optimization oppertunities are fulfilled now.
Aleast for first testcase is not there and for second it seems fixed -
https://godbolt.org/z/KEzz4hafn

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

13 months agoAMDGPU: Extract test out of old patch
Matt Arsenault [Sat, 10 Jun 2023 01:51:34 +0000 (21:51 -0400)]
AMDGPU: Extract test out of old patch

Don't think the patch is still useful but I don't see equivalent tests
for decreased alloca alignment.

https://reviews.llvm.org/D23908

13 months agoAMDGPU: Mark scalar loads as rematerializable
Matt Arsenault [Wed, 30 Nov 2022 00:17:33 +0000 (19:17 -0500)]
AMDGPU: Mark scalar loads as rematerializable

This should be true, but this is useless as is. The rematerialization
logic only permits rematerialize with constant physical register uses,
so non-constant physregs or virtual register uses (the case that
really matters) are not rematerialized. Add the tests which shows
nothing happens, but should in the future.

Also, all loads should really be rematerializable so in the future
this should apply to all the other kinds.

13 months agoAMDGPU: Avoid endpgm in middle of block for fallback trap lowering.
Matt Arsenault [Wed, 7 Jun 2023 19:38:08 +0000 (15:38 -0400)]
AMDGPU: Avoid endpgm in middle of block for fallback trap lowering.

This was inserting an s_endpgm in the middle of the block when it has
to be a terminator. Split the block and insert a branch to a new block
with the trap if it's not in a terminator position.

Fixes verifier error on LDS in function with no trap support (and
other trap sources).

13 months agoGlobalISel: Remove block insertion legalizer check
Matt Arsenault [Wed, 7 Jun 2023 21:21:58 +0000 (17:21 -0400)]
GlobalISel: Remove block insertion legalizer check

This report was broken. The passed null block would crash in the
remark constructor.

I have a patch which will introduce a new block, and it seems to work
fine. It doesn't require legalizing any instructions in the new block,
so it's possible those will be missed.

13 months agoCodeGen: Expand memory intrinsics in PreISelIntrinsicLowering
Matt Arsenault [Wed, 7 Jun 2023 13:03:17 +0000 (09:03 -0400)]
CodeGen: Expand memory intrinsics in PreISelIntrinsicLowering

Expand large or unknown size memory intrinsics into loops in the
default lowering pipeline if the target doesn't have the corresponding
libfunc. Previously AMDGPU had a custom pass which existed to call the
expansion utilities.

With a default no-libcall option, we can remove the libfunc checks in
LoopIdiomRecognize for these, which never made any sense. This also
provides a path to lifting the immarg restriction on
llvm.memcpy.inline.

There seems to be a bug where TLI reports functions as available if
you use -march and not -mtriple.

13 months ago[ASTStructuralEquivalence] Fix crash when ObjCCategoryDecl doesn't have corresponding...
Volodymyr Sapsai [Fri, 26 May 2023 01:09:11 +0000 (18:09 -0700)]
[ASTStructuralEquivalence] Fix crash when ObjCCategoryDecl doesn't have corresponding ObjCInterfaceDecl.

When this happens, it is invalid code and there is diagnostic
```
error: cannot find interface declaration for '...'
```

But clang shouldn't crash even if code is invalid. Though subsequent
diagnostic can be imperfect because without ObjCInterfaceDecl we don't have
a type for error messages.

rdar://108818430

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

13 months ago[bazel][NFC] Add Dialect/Func/Extensions library and deps
Jordan Rupprecht [Sat, 10 Jun 2023 00:04:41 +0000 (17:04 -0700)]
[bazel][NFC] Add Dialect/Func/Extensions library and deps

Added in D120368

13 months ago[-Wunsafe-buffer-usage] Remove the unnecessary `const` qualifier in safe buffer analysis
ziqingluo-90 [Fri, 9 Jun 2023 23:39:51 +0000 (16:39 -0700)]
[-Wunsafe-buffer-usage] Remove the unnecessary `const` qualifier in safe buffer analysis

Casting away the qualifier raises a warning in 1e270be0886c3a770e7a967679552a02dfc1dca9

13 months ago[clang-format] Remove redundant test case
Paul Kirth [Fri, 9 Jun 2023 21:15:41 +0000 (21:15 +0000)]
[clang-format] Remove redundant test case

The test is now properly covered in unit tests, and shouldn't have been
added in the initial commit of D152473.

Reviewed By: owenpan

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

13 months agoAMDGPU: Add baseline tests for integer mad matching
Matt Arsenault [Thu, 8 Jun 2023 21:55:36 +0000 (17:55 -0400)]
AMDGPU: Add baseline tests for integer mad matching

Test some clpeak-like patterns with multiple use muls.

13 months agoInline: Fix case of not inlining with denormal-fp-math-f32
Matt Arsenault [Fri, 9 Jun 2023 22:23:03 +0000 (18:23 -0400)]
Inline: Fix case of not inlining with denormal-fp-math-f32

This was failing to inline the opencl libraries with daz enabled. As a
modifier to the base mode, denormal-fp-mode-f32 is weird and has no
meaning if it's missing.

13 months agoAMDGPU: Add inlining testcases for denormal-fp-math
Matt Arsenault [Fri, 9 Jun 2023 22:19:15 +0000 (18:19 -0400)]
AMDGPU: Add inlining testcases for denormal-fp-math

Somehow missed this one and it's not working correctly

13 months ago[test][Msan] Move x86 specific tests into subdir
Vitaly Buka [Fri, 9 Jun 2023 22:27:19 +0000 (15:27 -0700)]
[test][Msan] Move x86 specific tests into subdir

13 months ago[-Wunsafe-buffer-usage] Add fix-its for function parameters using the `span` strategy
ziqingluo-90 [Fri, 9 Jun 2023 22:37:21 +0000 (15:37 -0700)]
[-Wunsafe-buffer-usage] Add fix-its for function parameters using the `span` strategy

Generate fix-its for function parameters that are raw pointers used
unsafely.  Currently, the analyzer fixes one parameter at a time.

Fix-its for a function parameter includes:

- Fix the parameter declaration of the definition, result in a new
  overload of the function. We call the function with the original
  signature the old overload.
- For any other existing declaration of the old overload, mark it with
  the [[unsafe_buffer_usage]] attribute and generate a new overload
  declaration next to it.
- Creates a new definition for the old overload, which is simply
  defined by a call to the new overload.

Reviewed by: NoQ (Artem Dergachev), t-rasmud (Rashmi Mudduluru), and
             jkorous (Jan Korous)

Differential revision: https://reviews.llvm.org/D143048

13 months ago[lldb][NFCI] Replace some static ConstStrings with StringLiterals in Disassembler
Alex Langford [Fri, 9 Jun 2023 22:37:09 +0000 (15:37 -0700)]
[lldb][NFCI] Replace some static ConstStrings with StringLiterals in Disassembler

These should have been replaced in e53e1de57ecc but I missed them
because ConstStrings can be implicitly converted to llvm::StringRefs.

13 months ago[RDF] Do not use trailing return type after all, NFC
Krzysztof Parzyszek [Fri, 9 Jun 2023 22:33:38 +0000 (15:33 -0700)]
[RDF] Do not use trailing return type after all, NFC

This sort of reverts commit d3b34b7f3a7cbfc96aea897419f167b5ee19e61a,
the issue with `Use` will be addressed by using fully-qualified name.

13 months ago[RDF] Stop looking when reached code node in getNextRef with NextOnly
Krzysztof Parzyszek [Tue, 6 Jun 2023 19:14:49 +0000 (12:14 -0700)]
[RDF] Stop looking when reached code node in getNextRef with NextOnly

NextOnly tells getNextRef to only check the next node in the chain, and
stop iterating. The loop didn't stop though when the next link pointed
back to the beginning of the circular list.

13 months ago[InstCombine] Optimize and of icmps with power-of-2 and contiguous masks
John McIver [Fri, 9 Jun 2023 21:26:30 +0000 (15:26 -0600)]
[InstCombine] Optimize and of icmps with power-of-2 and contiguous masks

Add an instance combine optimization for expressions of the form:

(%arg u< C1) & ((%arg & C2) != C2) -> %arg u< C2

Where C1 is a power-of-2 and C2 is a contiguous mask starting 1 bit below
C1. This commit resolves GitHub missed-optimization issue #54856.

Validation of scalar tests:
  - https://alive2.llvm.org/ce/z/JfKjiU
  - https://alive2.llvm.org/ce/z/AruHY_
  - https://alive2.llvm.org/ce/z/JAiR6t
  - https://alive2.llvm.org/ce/z/S2X2e5
  - https://alive2.llvm.org/ce/z/4cycdE
  - https://alive2.llvm.org/ce/z/NcDiLP

Validation of vector tests:
  - https://alive2.llvm.org/ce/z/ABY6tE
  - https://alive2.llvm.org/ce/z/BTJi3s
  - https://alive2.llvm.org/ce/z/3BKWpu
  - https://alive2.llvm.org/ce/z/RrAbkj
  - https://alive2.llvm.org/ce/z/nM6fsN

Reviewed By: goldstein.w.n

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

13 months ago[InstCombine][NFC] Add tests pre-implementation of issue #54856
John McIver [Fri, 9 Jun 2023 21:22:25 +0000 (15:22 -0600)]
[InstCombine][NFC] Add tests pre-implementation of issue #54856

Provide both positive and negative testing using scalar and vector values for
issue #54856.

Reviewed By: goldstein.w.n

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

13 months ago[GlobalISel] Fix D144336 in a different way, by choosing operands from the first...
Amara Emerson [Fri, 9 Jun 2023 21:37:54 +0000 (14:37 -0700)]
[GlobalISel] Fix D144336 in a different way, by choosing operands from the first of the div/rem insts.

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

13 months ago[libc] Fix some tests on NVPTX due to insufficient stack size
Joseph Huber [Fri, 9 Jun 2023 21:08:52 +0000 (16:08 -0500)]
[libc] Fix some tests on NVPTX due to insufficient stack size

A few of these tests were disabled due to failing on NVPTX. After
looking into it the vast majority of these cases were due to
insufficient stack memory. This can be worked around by increasing the
stack size in the loader or by reducing the memory usage in the case of
large string constants.

Reviewed By: tra

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

13 months agoFix regex in test case so that it doesn't match "coverage" in directory
Akira Hatanaka [Thu, 8 Jun 2023 23:18:16 +0000 (16:18 -0700)]
Fix regex in test case so that it doesn't match "coverage" in directory
names

The test case was failing because "-f{{[^"]*coverage.*}}" was matching
the following string:

"-fdebug-compilation-dir=/Users/buildslave/jenkins/workspace/coverage/"

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

13 months ago[clang-tidy] Fix error in documentation of bugprone-unchecked-optional-access.
Yitzhak Mandelbaum [Fri, 9 Jun 2023 20:42:09 +0000 (20:42 +0000)]
[clang-tidy] Fix error in documentation of bugprone-unchecked-optional-access.

The documentation claims that the check recognizes `ASSERT_THAT`, but it doesn't
recognize any googletest macros at the moment. This patch removes the reference.

13 months ago[test] Use update_test_checks for dse.ll
Arthur Eubanks [Fri, 9 Jun 2023 20:24:06 +0000 (13:24 -0700)]
[test] Use update_test_checks for dse.ll

13 months ago[test] Explain the purpose of LLVM :: LTO/Resolution/X86/local-def-dllimport.ll
Matthew Voss [Fri, 9 Jun 2023 19:58:26 +0000 (12:58 -0700)]
[test] Explain the purpose of LLVM :: LTO/Resolution/X86/local-def-dllimport.ll

Requested in https://reviews.llvm.org/D148950#4315575

13 months ago[clang-format] Add test case for issue 63170
Paul Kirth [Thu, 8 Jun 2023 21:58:42 +0000 (21:58 +0000)]
[clang-format] Add test case for issue 63170

After https://reviews.llvm.org/D151954 we've noticed some issues w/
clang-format behavior, as outlined in
https://github.com/llvm/llvm-project/issues/63170.

Valid C/C++ files, that were previously accepted, are now rejected by
clang-format, emitting the message:

"The new replacement overlaps with an existing replacement."

This reverts commit 4b9764959dc4b8783e18747c1742ab164e4bc4ee and
d2627cf88d2553a4c2e850430bdb908a4b7d2e52, which depends on it.

Reviewed By: phosek

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

13 months ago[NewGVN] Fold equivalent freeze instructions
Jay Foad [Fri, 9 Jun 2023 12:44:06 +0000 (13:44 +0100)]
[NewGVN] Fold equivalent freeze instructions

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

13 months ago[NewGVN] Precommit test for folding freeze
Jay Foad [Fri, 9 Jun 2023 12:42:42 +0000 (13:42 +0100)]
[NewGVN] Precommit test for folding freeze

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

13 months ago[LoadStoreVectorizer] Optimize check for IsAllocaAccess. NFC
Bjorn Pettersson [Fri, 9 Jun 2023 19:36:23 +0000 (21:36 +0200)]
[LoadStoreVectorizer] Optimize check for IsAllocaAccess. NFC

Swap order for checking address space and the strip pointer cast
when analyzing if a load/store is accessing an alloca. This to
make sure we do the cheaper check first.

This is done as a follow up to D152386.