platform/upstream/llvm.git
23 months agoRevert "[Clang][Attribute] Introduce maybe_undef attribute for function arguments...
Amy Kwan [Fri, 29 Jul 2022 18:16:37 +0000 (13:16 -0500)]
Revert "[Clang][Attribute] Introduce maybe_undef attribute for function arguments which accepts undef values"

This reverts commit a35c64ce23b7c7e4972c89b224b9363639dddea2.

Reverting this commit as it causes various failures on LE and BE PPC bots.

23 months ago[TSan][Darwin] Additional TSAN test requiring weak symbol for dyld64
Blue Gaston [Thu, 28 Jul 2022 21:41:32 +0000 (14:41 -0700)]
[TSan][Darwin] Additional TSAN test requiring weak symbol for dyld64

Tests require a weak symbol for dyld weak-def coalescing.

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

Adding additional weak attribute

23 months ago[AMDGPU] Omit unnecessary waitcnt before barriers
Austin Kerbow [Fri, 25 Feb 2022 07:26:51 +0000 (23:26 -0800)]
[AMDGPU] Omit unnecessary waitcnt before barriers

It is not necessary to wait for all outstanding memory operations before
barriers on hardware that can back off of the barrier in the event of an
exception when traps are enabled. Add a new subtarget feature which
tracks which HW has this ability.

Reviewed By: #amdgpu, rampitec

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

23 months ago[gn build] (manually) port 507125af3d0b more
Nico Weber [Fri, 29 Jul 2022 18:06:10 +0000 (14:06 -0400)]
[gn build] (manually) port 507125af3d0b more

23 months ago[gn build] (manually) port 507125af3d0b
Nico Weber [Fri, 29 Jul 2022 18:03:32 +0000 (14:03 -0400)]
[gn build] (manually) port 507125af3d0b

23 months agoReplace Optional::hasValue with has_value or operator bool. NFC
Fangrui Song [Fri, 29 Jul 2022 17:57:25 +0000 (10:57 -0700)]
Replace Optional::hasValue with has_value or operator bool. NFC

23 months ago[libc++] Rename __libcpp_assertion_handler to __libcpp_verbose_abort
Louis Dionne [Mon, 25 Jul 2022 17:43:47 +0000 (13:43 -0400)]
[libc++] Rename __libcpp_assertion_handler to __libcpp_verbose_abort

With the goal of reusing that handler to do other things besides
handling assertions (such as terminating when an exception is thrown
under -fno-exceptions), the name `__libcpp_assertion_handler` doesn't
really make sense anymore.

Furthermore, I didn't want to use the name `__libcpp_abort_handler`,
since that would give the impression that the handler is called
whenever `std::abort()` is called, which is not the case at all.

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

23 months ago[clang-repl] Disable execution unittests on unsupported platforms.
Sunho Kim [Fri, 29 Jul 2022 17:27:45 +0000 (02:27 +0900)]
[clang-repl] Disable execution unittests on unsupported platforms.

After the intoduction of global destructor support, there is a possiblity to run invalid instructions in the destructor of Interpreter class. Completely disable tests in platforms with failing test cases.

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

23 months agoDiagnose use of _Noreturn on a struct/union field
Aaron Ballman [Fri, 29 Jul 2022 17:16:10 +0000 (13:16 -0400)]
Diagnose use of _Noreturn on a struct/union field

C99 6.7.4p2 clarifies that a function specifier can only be used in the
declaration of a function. _Noreturn is a function specifier, so it is
a constraint violation to write it on a structure or union field, but
we missed that case.

Fixes #56800

23 months agoworkflows: Pass phab token to github-automation.py when creating a pull request
Tom Stellard [Fri, 29 Jul 2022 16:59:55 +0000 (09:59 -0700)]
workflows: Pass phab token to github-automation.py when creating a pull request

The script needs this in order to automatically assign a reviewer.

23 months ago[lld/mac] Comment changes requested on https://reviews.llvm.org/D130725
Nico Weber [Fri, 29 Jul 2022 16:55:04 +0000 (12:55 -0400)]
[lld/mac] Comment changes requested on https://reviews.llvm.org/D130725

No behavior change.

23 months ago[mlir][LLVM] Rework the API of GEPOp
Markus Böck [Thu, 28 Jul 2022 20:42:37 +0000 (22:42 +0200)]
[mlir][LLVM] Rework the API of GEPOp

The implementation and API of GEP Op has gotten a bit convoluted over the time. Issues with it are:
* Misleading naming: `indices` actually only contains the dynamic indices, not all of them. To get the amount of indices you need to query the size of `structIndices`
* Very difficult to iterate over all indices properly: One had to iterate over `structIndices`, check whether it contains the magic constant `kDynamicIndex`, if it does, access the next value in `index` etc.
* Inconvenient to build: One either has create lots of constant ops for every index or have an odd split of passing both a `ValueRange` as well as a `ArrayRef<int32_t>` filled with `kDynamicIndex` at the correct places.
* Implementation doing verification in the build method
and more.

This patch attempts to address all these issues via convenience classes and reworking the way GEP Op works:
* Adds `GEPArg` class which is a sum type of a `int32_t` and `Value` and is used to have a single convenient easy to use `ArrayRef<GEPArg>` in the builders instead of the previous `ValueRange` + `ArrayRef<int32_t>` builders.
* Adds `GEPIndicesAdapter` which is a class used for easy random access and iteration over the indices of a GEP. It is generic and flexible enough to also instead return eg. a corresponding `Attribute` for an operand inside of `fold`.
*  Rename `structIndices` to `rawConstantIndices` and `indices` to `dynamicIndices`: `rawConstantIndices` signifies one shouldn't access it directly as it is encoded, and `dynamicIndices` is more accurate and also frees up the `indices` name.
* Add `getIndices` returning a `GEPIndicesAdapter` to easily iterate over the GEP Ops indices.
* Move the verification/asserts out of the build method and into the `verify` method emitting op error messages.
* Add convenient builder methods making use of `GEPArg`.
* Add canonicalizer turning dynamic indices with constant values into constant indices to have a canonical representation.

The only breaking change is for any users building GEPOps that have so far used the old `ValueRange` + `ArrayRef<int32_t>` builder as well as those using the generic syntax.

Another follow up patch then goes through upstream and makes use of the new `ArrayRef<GEPArg>` builder to remove a lot of code building constants for GEP indices.

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

23 months ago[ELF] Strip directories for -Map when emitting reproducer rsp
Alex Brachet [Fri, 29 Jul 2022 16:17:33 +0000 (16:17 +0000)]
[ELF] Strip directories for -Map when emitting reproducer rsp

Similarly to -o output directories will not be created so -Map being
copied verbatim will likely cause ld.lld @response.txt to fail.

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

23 months ago[mlir][complex] Canonicalize complex.add zero
lewuathe [Fri, 29 Jul 2022 12:31:55 +0000 (14:31 +0200)]
[mlir][complex] Canonicalize complex.add zero

Adding complex value with 0 for real and imaginary part can be ignored.

NOTE: This type of canonicalization can be written in an easy and tidy format using `complex.number` after constant op supports custom attribute.

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

23 months ago[InstCombine] canonicalize zext-and-of-bool compare to narrow and
Sanjay Patel [Fri, 29 Jul 2022 15:28:51 +0000 (11:28 -0400)]
[InstCombine] canonicalize zext-and-of-bool compare to narrow and

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

We should choose one of these forms, and the option that uses
the narrow type allows the motivating example from issue #56294
to reduce. In the best case (no 'not' needed and 'trunc' remains),
this does remove an instruction.

Note that there is what looks like a regression because there
is an existing canonicalization that turns trunc into and+icmp.
That is a long-standing transform, and I'm not sure what effect
reversing it would have.

23 months ago[mlir][NFC] accept plain OpBuidler in folded construction helpers
Alex Zinenko [Mon, 25 Jul 2022 16:28:39 +0000 (16:28 +0000)]
[mlir][NFC] accept plain OpBuidler in folded construction helpers

A group of functions in the Affine dialect provides a mechanism for
buliding folded-by-construction operations. These functions used to
accept a `RewriterBase` reference because they may need to erase the
operations that were folded and notify the rewriter when called from
rewrite patterns. Adopt a different approach: postpone the builder
notification of the op creation until we are certain that the op will
not be folded away. This removes the need to notify the rewriter about
op deletion following op construction in case of successful folding, and
removes a bunch of one-off `IRRewriter` instances in transform code that
may mess up insertion points.

Reviewed By: springerm, mravishankar

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

23 months ago[Clang] Do not check for underscores in isAllowedInitiallyIDChar
Corentin Jabot [Fri, 29 Jul 2022 09:04:28 +0000 (11:04 +0200)]
[Clang] Do not check for underscores in isAllowedInitiallyIDChar

isAllowedInitiallyIDChar is only used with non-ASCII codepoints,
which are handled by isAsciiIdentifierStart.
To make that clearer, remove the check for _ from
isAllowedInitiallyIDChar, and assert on ASCII - to ensure neither
_ or $ are passed to this function.

Reviewed By: tahonermann, aaron.ballman

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

23 months ago[libc][math] Added sinhf function.
Kirill Okhotnikov [Thu, 7 Jul 2022 11:48:11 +0000 (13:48 +0200)]
[libc][math] Added sinhf function.

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

23 months ago[libc][math] Added coshf function.
Kirill Okhotnikov [Thu, 7 Jul 2022 11:08:19 +0000 (13:08 +0200)]
[libc][math] Added coshf function.

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

23 months ago[AArch64][SVE] Change DupLane128Combine Index comparison to 0
Matt Devereau [Fri, 29 Jul 2022 14:20:00 +0000 (14:20 +0000)]
[AArch64][SVE] Change DupLane128Combine Index comparison to 0

IdxInsert == IdxDupLane is incorrect. IdxInsert is the starting element number,
whereas IdxIndex is the index of a quadword

23 months ago[InstCombine] add tests for icmp with cast bool logic; NFC
Sanjay Patel [Thu, 28 Jul 2022 15:29:11 +0000 (11:29 -0400)]
[InstCombine] add tests for icmp with cast bool logic; NFC

23 months ago[X86] combineAndnp - constant fold ANDNP(C,X) -> AND(~C,X) (REAPPLIED)
Simon Pilgrim [Fri, 29 Jul 2022 14:12:18 +0000 (15:12 +0100)]
[X86] combineAndnp - constant fold ANDNP(C,X) -> AND(~C,X) (REAPPLIED)

If the LHS op has a single use then using the more general AND op is likely to allow commutation, load folding, generic folds etc.

Updated version - original version rG057db2002bb3 didn't correctly account for multiple uses of the mask that might be folding "OR(AND(X,C),AND(Y,~C)) -> OR(AND(X,C),ANDNP(C,Y))" in canonicalizeBitSelect

23 months ago[RISCV][doc] Improve documentation comments on atomics intrinsics
Alex Bradbury [Fri, 29 Jul 2022 14:05:27 +0000 (15:05 +0100)]
[RISCV][doc] Improve documentation comments on atomics intrinsics

Previously, it was necessary to check the atomics lowering or expansion
code to determine which argument was which.

This patch additionally tweaks the documentation comment in
TargetLowering to clarify the return value of the intrinsic and that the
intrinsic isn't required to mask and shift the result (this is handled
by the target-independent code in AtomicExpandPass).

23 months ago[InstCombine] Avoid ConstantExpr::getFNeg() calls (NFCI)
Nikita Popov [Fri, 29 Jul 2022 13:45:56 +0000 (15:45 +0200)]
[InstCombine] Avoid ConstantExpr::getFNeg() calls (NFCI)

Instead call the constant folding API, which can fail. For now,
this should be NFC, as we still allow the creation of fneg
constant expressions.

23 months ago[DAG] Use recursivelyDeleteUnusedNodes in CommitTargetLoweringOpt.
Amaury Séchet [Sun, 24 Jul 2022 23:17:07 +0000 (23:17 +0000)]
[DAG] Use recursivelyDeleteUnusedNodes in CommitTargetLoweringOpt.

It simplifies the logic and removes the need for manual bookkeeping.

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

23 months ago[libc++] Remove constexpr vector from LLVM 16 release notes
Louis Dionne [Fri, 29 Jul 2022 13:46:21 +0000 (09:46 -0400)]
[libc++] Remove constexpr vector from LLVM 16 release notes

We are shipping it in LLVM 15 via a cherry-pick.

23 months ago[AMDGPU] Enable image_gather4h instruction for gfx10 and gfx11
Mirko Brkusanin [Fri, 29 Jul 2022 13:16:09 +0000 (15:16 +0200)]
[AMDGPU] Enable image_gather4h instruction for gfx10 and gfx11

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

23 months ago[Debuginfo][DWARF][NFC] Add paired methods working with DWARFDebugInfoEntry.
Alexey Lapshin [Fri, 29 Jul 2022 10:43:02 +0000 (13:43 +0300)]
[Debuginfo][DWARF][NFC] Add paired methods working with DWARFDebugInfoEntry.

This review is extracted from D96035.

DWARF Debuginfo classes have two representations for DIEs: DWARFDebugInfoEntry
(short) and DWARFDie(extended). Depending on the task, it might be more convenient
to use DWARFDebugInfoEntry or/and DWARFDie. DWARFUnit class already has methods
working with DWARFDie and DWARFDebugInfoEntry. This patch adds more
methods working with DWARFDebugInfoEntry to have paired functionality.

Reviewed By: aprantl

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

23 months ago[mlir][Complex] Add a convenience getValue() method.
Adrian Kuegel [Fri, 29 Jul 2022 13:17:57 +0000 (15:17 +0200)]
[mlir][Complex] Add a convenience getValue() method.

This method returns the value as std::complex<APFloat>

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

23 months ago[AMDGPU] user-sgpr-init16-bug does not apply to gfx1103
Jay Foad [Fri, 22 Jul 2022 11:38:37 +0000 (12:38 +0100)]
[AMDGPU] user-sgpr-init16-bug does not apply to gfx1103

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

23 months ago[X86] Add regression test case from rG057db2002bb3
Simon Pilgrim [Fri, 29 Jul 2022 13:20:23 +0000 (14:20 +0100)]
[X86] Add regression test case from rG057db2002bb3

When constant folding "ANDNP(C,X) -> AND(~C,X)" we hit cases such as this where we interfered with the "OR(AND(X,C),AND(Y,~C)) -> OR(AND(X,C),ANDNP(C,Y))" fold in canonicalizeBitSelect

23 months ago[TargetLowering] Move a few hasOneUse() tests later to reduce unnecessary computation...
Simon Pilgrim [Fri, 29 Jul 2022 13:08:59 +0000 (14:08 +0100)]
[TargetLowering] Move a few hasOneUse() tests later to reduce unnecessary computations. NFC.

Many of these cases, an early-out on the much cheaper getOpcode() check will avoid us needing to call hasOneUse() entirely.

23 months agoAMDGPU: Fix assertion when printing unreachable functions
Matt Arsenault [Sun, 24 Jul 2022 23:18:41 +0000 (19:18 -0400)]
AMDGPU: Fix assertion when printing unreachable functions

Since 814a0abccefdd2e52b1b507f21ce842b689dbedd, this would break if we
had a function in the module that becomes dead in any codegen IR
pass. The function wasn't deleted since it was initially used in dead
code, but is detached from the call graph and doesn't appear in the PO
traversal. Do a second walk over the module to populate the resources
of any functions which weren't already processed.

23 months agoRegisterCoalescer: Shrink main range after shrinking subranges
Matt Arsenault [Mon, 6 Jun 2022 23:34:36 +0000 (19:34 -0400)]
RegisterCoalescer: Shrink main range after shrinking subranges

If the subregister uses were dead, this would leave the main range
segment pointing to a deleted instruction.

Not sure if this should try to avoid shrinking if we know we don't
have dead components.

23 months ago[NFCI] Propagate MLTAL through more concepts in prep of deferred inst.
Erich Keane [Fri, 29 Jul 2022 12:52:40 +0000 (05:52 -0700)]
[NFCI] Propagate MLTAL through more concepts in prep of deferred inst.

In preperation of the deferred instantation progress, this patch
propagates the multi-level template argument lists further through the
API to reduce the size of that patch.

23 months ago[Libcalls] Add tests with maytrap & non-errno for math libcalls.
Florian Hahn [Fri, 29 Jul 2022 12:45:33 +0000 (13:45 +0100)]
[Libcalls] Add tests with maytrap & non-errno for math libcalls.

23 months agoRevert "[AMDGPU] avoid blind converting to VALU REG_SEQUENCE and PHIs"
Alexander Timofeev [Fri, 29 Jul 2022 12:19:07 +0000 (14:19 +0200)]
Revert "[AMDGPU] avoid blind converting to VALU REG_SEQUENCE and PHIs"

This reverts commit 76d9ae924cc361578ecbb5688559f7cebc78ab87.
because it causes several VK CTS tests to fail

23 months ago[mlir][Complex] Add convenience builder for complex.number attribute.
Adrian Kuegel [Fri, 29 Jul 2022 11:30:29 +0000 (13:30 +0200)]
[mlir][Complex] Add convenience builder for complex.number attribute.

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

23 months ago[compiler-rt][builtins][RISCV] Set COMPILER_RT_HAS_FLOAT16 for RISC-V compiler-rt...
Luís Marques [Fri, 29 Jul 2022 11:27:44 +0000 (13:27 +0200)]
[compiler-rt][builtins][RISCV] Set COMPILER_RT_HAS_FLOAT16 for RISC-V compiler-rt tests, fixes test__extendhfsf2

Since D92241, compiler-rt/cmake/builtin-config-ix.cmake automatically tests
the host compiler for support of _Float16 and conditionally defines
COMPILER_RT_HAS_FLOAT16. That defines the macro while the compiler-rt
builtins are being built. To also define it during the compiler-rt test
runs requires whitelisting the architecture in
compiler-rt/test/builtins/CMakeLists.txt, as done in this patch. That seems
brittle. Ideally, we'd move to a solution where the target compiler was
automatically tested as well, but I'm not sure how feasible that is with the
current CMake setup.

For now, this patch whitelists RISC-V, fixing errors in test__extendhfsf2.
Alternate solutions that fix the root issue are welcome, though.

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

23 months agoRevert "[compiler-rt][builtins][RISCV] Set COMPILER_RT_HAS_FLOAT16 for RISC-V compile...
Luís Marques [Fri, 29 Jul 2022 11:25:53 +0000 (13:25 +0200)]
Revert "[compiler-rt][builtins][RISCV] Set COMPILER_RT_HAS_FLOAT16 for RISC-V compiler-rt tests, fixes test__extendhfsf2"

This reverts commit 55920d92827c7a6dbb5c7d03f37686a46d7f817f.

23 months ago[compiler-rt][builtins][RISCV] Set COMPILER_RT_HAS_FLOAT16 for RISC-V compiler-rt...
Luís Marques [Fri, 29 Jul 2022 11:21:54 +0000 (13:21 +0200)]
[compiler-rt][builtins][RISCV] Set COMPILER_RT_HAS_FLOAT16 for RISC-V compiler-rt tests, fixes test__extendhfsf2

Since D92241, compiler-rt/cmake/builtin-config-ix.cmake automatically tests
the host compiler for support of _Float16 and conditionally defines
COMPILER_RT_HAS_FLOAT16. That defines the macro while the compiler-rt
builtins are being built. To also define it during the compiler-rt test
runs requires whitelisting the architecture in
compiler-rt/test/builtins/CMakeLists.txt, as done in this patch. That seems
brittle. Ideally, we'd move to a solution where the target compiler was
automatically tested as well, but I'm not sure how feasible that is with the
current CMake setup.

For now, this patch whitelists RISC-V, fixing errors in test__extendhfsf2.
Alternate solutions that fix the root issue are welcome, though.

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

23 months ago[clangd][NFCI] Store TUPath inside ParsedAST
Kadir Cetinkaya [Thu, 28 Jul 2022 09:08:55 +0000 (11:08 +0200)]
[clangd][NFCI] Store TUPath inside ParsedAST

Lots of features built on top of ASTs require getting back to the path
of the TU and they used lossy conversion from file ids using sourcemanager.
This patch preserves the file path passed by the caller inside ParsedAST for
later use.

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

23 months agoVirtualFileSystem.h - don't use \param in general description - use \p instead to...
Simon Pilgrim [Fri, 29 Jul 2022 11:21:44 +0000 (12:21 +0100)]
VirtualFileSystem.h - don't use \param in general description - use \p instead to fix Wdocumentation warnings.

23 months agoFix unknown parameter Wdocumentation warning. NFC.
Simon Pilgrim [Fri, 29 Jul 2022 11:17:30 +0000 (12:17 +0100)]
Fix unknown parameter Wdocumentation warning. NFC.

23 months ago[DAG] Move a few hasOneUse() tests later to reduce unnecessary computations. NFC.
Simon Pilgrim [Fri, 29 Jul 2022 10:34:29 +0000 (11:34 +0100)]
[DAG] Move a few hasOneUse() tests later to reduce unnecessary computations. NFC.

Many of these cases, an early-out on the much cheaper getOpcode() check will avoid us needing to call hasOneUse() entirely.

23 months ago[libc] Fix prototype_test_gen
Guillaume Chatelet [Fri, 29 Jul 2022 10:18:54 +0000 (10:18 +0000)]
[libc] Fix prototype_test_gen

23 months ago[libc] Fix prototype_test_gen
Guillaume Chatelet [Fri, 29 Jul 2022 10:06:54 +0000 (10:06 +0000)]
[libc] Fix prototype_test_gen

23 months ago[Support] Add KnownBits::concat method
Simon Pilgrim [Fri, 29 Jul 2022 10:06:26 +0000 (11:06 +0100)]
[Support] Add KnownBits::concat method

Add a method for the various cases where we need to concatenate 2 KnownBits together (BUILD_PAIR and SHIFT_PARTS in particular) - uses the existing APInt::concat 'HiBits.concat(LoBits)' convention

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

23 months agoFix typo in FPUtil/aarch64/FMA.h
Guillaume Chatelet [Fri, 29 Jul 2022 10:04:11 +0000 (10:04 +0000)]
Fix typo in FPUtil/aarch64/FMA.h

23 months ago[libc][NFC] Use STL case for type_traits
Guillaume Chatelet [Thu, 28 Jul 2022 19:39:19 +0000 (19:39 +0000)]
[libc][NFC] Use STL case for type_traits

Migrating all private STL code to the standard STL case but keeping it under the CPP namespace to avoid confusion. Starting with the type_traits header.

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

23 months ago[IR] Simplify Intrinsic::getDeclaration. NFC.
Jay Foad [Fri, 29 Jul 2022 09:40:58 +0000 (10:40 +0100)]
[IR] Simplify Intrinsic::getDeclaration. NFC.

23 months ago[LoongArch] Offset folding for frameindex
wanglei [Fri, 29 Jul 2022 09:09:04 +0000 (17:09 +0800)]
[LoongArch] Offset folding for frameindex

This patch is for frameindex calculations.

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

23 months ago[LoongArch] Refactor insertDivByZeroTrap
wanglei [Fri, 29 Jul 2022 08:46:14 +0000 (16:46 +0800)]
[LoongArch] Refactor insertDivByZeroTrap

Ensure non-terminators don't follow terminators.
This patch fixes the `sdiv-udiv-srem-urem.ll` test failure with
expensive check.

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

23 months ago[AArch64][DAGCombine] Add performBuildVectorCombine 'extract_elt ~> anyext'
David Sherwood [Fri, 29 Jul 2022 08:32:08 +0000 (09:32 +0100)]
[AArch64][DAGCombine] Add performBuildVectorCombine 'extract_elt ~> anyext'

A build vector of two extracted elements is equivalent to an extract
subvector where the inner vector is any-extended to the
extract_vector_elt VT, because extract_vector_elt has the effect of an
any-extend.

  (build_vector (extract_elt_i16_to_i32 vec Idx+0) (extract_elt_i16_to_i32 vec Idx+1))
  => (extract_subvector (anyext_i16_to_i32 vec) Idx)

Depends on D130697

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

23 months agofix test function attribute [NFC]
Nuno Lopes [Fri, 29 Jul 2022 08:42:44 +0000 (09:42 +0100)]
fix test function attribute [NFC]

23 months ago[NFC][AArch64] Precommit vector-fcvt tests
David Sherwood [Fri, 29 Jul 2022 08:01:35 +0000 (09:01 +0100)]
[NFC][AArch64] Precommit vector-fcvt tests

Add tests which show code quality of uitofp and sitofp.

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

23 months ago[bolt] Replace Optional::getValue with value or operator*. NFC
Fangrui Song [Fri, 29 Jul 2022 08:15:23 +0000 (01:15 -0700)]
[bolt] Replace Optional::getValue with value or operator*. NFC

23 months ago[SCEV] Avoid repeated proveNoSignedWrapViaInduction calls.
Florian Hahn [Fri, 29 Jul 2022 08:15:02 +0000 (09:15 +0100)]
[SCEV] Avoid repeated proveNoSignedWrapViaInduction calls.

 At the moment, proveNoSignedWrapViaInduction may be called for the
same AddRec a large number of times via getSignExtendExpr. This can have
a severe compile-time impact for very loop-heavy code.

If proveNoSignedWrapViaInduction failed to prove NSW the first time,
it is unlikely to succeed on subsequent tries and the cost doesn't seem
to be justified.

This is the signed version of 8daa338297d533d / D130648.

This can drastically improve compile-time in some excessive cases and
also has a slightly positive compile-time impact on CTMark:

NewPM-O3: -0.06%
NewPM-ReleaseThinLTO: -0.04%
NewPM-ReleaseLTO-g: -0.04%

https://llvm-compile-time-tracker.com/compare.php?from=8daa338297d533db4d1ae8d3770613eb25c29688&to=aed126a196e7a5a9803543d9b4d6bdb233d0009c&stat=instructions

Reviewed By: nikic

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

23 months ago[mlir][toy] Replace Optional::getValue with value. NFC
Fangrui Song [Fri, 29 Jul 2022 08:10:51 +0000 (01:10 -0700)]
[mlir][toy] Replace Optional::getValue with value. NFC

23 months agoRevert "[JITLink][COFF] Implement include/alternatename linker directive."
Sunho Kim [Fri, 29 Jul 2022 08:02:29 +0000 (17:02 +0900)]
Revert "[JITLink][COFF] Implement include/alternatename linker directive."

This reverts commit f1fcd06a2a29fc534cb9f365cb4a01559f3378ce.

Faliures reported in
https://lab.llvm.org/buildbot/#/builders/193/builds/16143 and http://lab.llvm.org/buildbot/#/builders/91/builds/13010

23 months ago[ELF] CallGraphSort: replace vector<int> with unique_ptr<int[]>. NFC
Fangrui Song [Fri, 29 Jul 2022 07:59:47 +0000 (00:59 -0700)]
[ELF] CallGraphSort: replace vector<int> with unique_ptr<int[]>. NFC

We can't use C++20 make_unique_for_overwrite yet.

23 months ago[JITLink][COFF] Implement include/alternatename linker directive.
Sunho Kim [Fri, 29 Jul 2022 07:48:04 +0000 (16:48 +0900)]
[JITLink][COFF] Implement include/alternatename linker directive.

Implements include/alternatename linker directive. Alternatename is used by static msvc runtime library. Alias symbol is technically incorrect (we have to search for external definition) but we don't have a way to represent this in jitlink/orc yet, this is solved in the following up patch.

Inlcude linker directive is used in ucrt to forcelly lookup the static initializer symbols so that they will be emitted. It's implemented as extenral symbols with live flag on that cause the lookup of these symbols.

Reviewed By: lhames

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

23 months ago[ELF] Move combineEhSections from Writer to SyntheticSections. NFC
Fangrui Song [Fri, 29 Jul 2022 07:47:29 +0000 (00:47 -0700)]
[ELF] Move combineEhSections from Writer to SyntheticSections. NFC

This not only places the function in the right place, but also allows inlining addSection.

23 months ago[ELF] Combine EhInputSection removal and MergeInputSection removal. NFC
Fangrui Song [Fri, 29 Jul 2022 07:39:57 +0000 (00:39 -0700)]
[ELF] Combine EhInputSection removal and MergeInputSection removal. NFC

23 months ago[JITLink][COFF][x86_64] Implement ADDR64 relocation.
Sunho Kim [Fri, 29 Jul 2022 07:31:14 +0000 (16:31 +0900)]
[JITLink][COFF][x86_64] Implement ADDR64 relocation.

Implements ADDR64 relocation using x86_64 edge kind.

Reviewed By: lhames

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

23 months ago[ELF] Remove redundant isa<InputSection>(sec). NFC
Fangrui Song [Fri, 29 Jul 2022 07:30:52 +0000 (00:30 -0700)]
[ELF] Remove redundant isa<InputSection>(sec). NFC

combineEhSections has been called to remove EhInputSection.

23 months ago[JITLink][COFF] Implement dllimport stubs.
Sunho Kim [Fri, 29 Jul 2022 07:27:07 +0000 (16:27 +0900)]
[JITLink][COFF] Implement dllimport stubs.

Implements dllimport stubs using GOT table manager. Benefit of using GOT table manager is that we can just reuse jitlink-check architecture.

Reviewed By: lhames

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

23 months ago[libc++][ranges] implement `std::ranges::unique{_copy}`
Hui Xie [Sat, 23 Jul 2022 00:44:25 +0000 (01:44 +0100)]
[libc++][ranges] implement `std::ranges::unique{_copy}`

implement `std::ranges::unique` and `std::ranges::unique_copy`

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

23 months ago[clang][Driver] Handle SPARC -mcpu=native etc.
Rainer Orth [Fri, 29 Jul 2022 07:27:09 +0000 (09:27 +0200)]
[clang][Driver] Handle SPARC -mcpu=native etc.

To make use of SPARC support in `getHostCPUName` as implemented by D130272
<https://reviews.llvm.org/D130272>, this patch uses it to handle
`-mcpu=native` and `-mtune=native`.  To match GCC, this patch rejects
`-march` instead of silently treating it as a no-op.

Tested on `sparcv9-sun-solaris2.11` and checking that those options are
passed on as `-target-cpu` resp. `-tune-cpu` as expected.

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

23 months ago[ORC][COFF] Handle COFF import files of static archive.
Sunho Kim [Fri, 29 Jul 2022 05:39:57 +0000 (14:39 +0900)]
[ORC][COFF] Handle COFF import files of static archive.

Handles COFF import files of static archive. Changes static library genrator to build up object file map keyed by symbol name that excludes the symbols from dllimported symbols so that static generator will not be responsible for them. It exposes the list of dynamic libraries that need to be imported. Client should properly load the libraries in this list beforehand. Object file map is also an improvment from the past in terms of performance. Archive.findSym does a slow O(n) linear serach of symbol list to find the symbol. (we call findSym O(n) times, thus full time complexity is O(n^2); we were the only user of findSym function in fact)

There is a room for improvements in how to load the libraries in the list. We currently just hand the responsibility over to the clinet. A better way would be let ORC read this list and hand them over to JITLink side that would also help validation (e.g. not trying to generate stub for non dllimported targets) Nevertheless, we will have to exclude the symbols from COFF import object file list and need a way to access this list, which this patch offers.

Reviewed By: lhames

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

23 months ago[Driver] Use libatomic for 32-bit SPARC atomics support on Linux
Rainer Orth [Fri, 29 Jul 2022 07:19:38 +0000 (09:19 +0200)]
[Driver] Use libatomic for 32-bit SPARC atomics support on Linux

This is the Linux/sparc64 equivalent to D118021
<https://reviews.llvm.org/D118021>, necessary to provide an external
implementation of atomics on 32-bit SPARC which LLVM cannot inline even
with `-mcpu=v9` or an equivalent default.

Tested on `sparc64-unknown-linux-gnu`.

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

23 months ago[ELF] Remove one inputSections loop. NFC
Fangrui Song [Fri, 29 Jul 2022 07:03:50 +0000 (00:03 -0700)]
[ELF] Remove one inputSections loop. NFC

23 months ago[BOLT] Ignore functions accessing false positive jump tables
Huan Nguyen [Fri, 29 Jul 2022 06:17:53 +0000 (23:17 -0700)]
[BOLT] Ignore functions accessing false positive jump tables

Disassembly and branch target analysis are not decoupled, so any
analysis that depends on disassembly may not operate properly.

In specific, analyzeJumpTable uses instruction bounds check property.
A jump table was analyzed twice: (a) during disassembly, and (b) after
disassembly, so there are potentially some mismatched results.

In this update, functions that access JTs which fail the second check
will be marked as ignored.

Test Plan:
```
ninja check-bolt
```

Reviewed By: Amir

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

23 months ago[BOLT] Remove --allow-stripped option
Huan Nguyen [Fri, 29 Jul 2022 06:15:20 +0000 (23:15 -0700)]
[BOLT] Remove --allow-stripped option

AllowStripped has not been used in BOLT.
This option is replaced by actively detecting stripped binary.

Test Plan:

Reviewed By: Amir

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

23 months ago[BOLT] Add BinaryContext::IsStripped
Huan Nguyen [Fri, 29 Jul 2022 06:08:45 +0000 (23:08 -0700)]
[BOLT] Add BinaryContext::IsStripped

Determine stripped status of a binary based on .symtab

Test Plan:
```
ninja check-bolt
```

Reviewed By: Amir

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

23 months ago[LoongArch] Remove the temporary .mir tests as they have been rewrote by .s tests...
Weining Lu [Fri, 29 Jul 2022 02:57:42 +0000 (10:57 +0800)]
[LoongArch] Remove the temporary .mir tests as they have been rewrote by .s tests. NFC

23 months ago[C++20] [Modules] Merge same concept decls in global module fragment
Chuanqi Xu [Fri, 29 Jul 2022 02:44:30 +0000 (10:44 +0800)]
[C++20] [Modules] Merge same concept decls in global module fragment

According to [basic.def.odr]p14, the same redeclarations in different TU
but not attached to a named module are allowed. But we didn't take care
of concept decl for this condition. This patch tries to fix this
problem.

Reviewed By: ilya-biryukov

Differention Revision: https://reviews.llvm.org/D130614

23 months ago[Clang][Attribute] Introduce maybe_undef attribute for function arguments which accep...
skc7 [Tue, 19 Jul 2022 09:53:31 +0000 (09:53 +0000)]
[Clang][Attribute] Introduce maybe_undef attribute for function arguments which accepts undef values

Add the ability to put __attribute__((maybe_undef)) on function arguments.
Clang codegen introduces a freeze instruction on the argument.

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

23 months ago[HLSL] Add HLSLResource attribute
Chris Bieneman [Fri, 15 Jul 2022 21:36:47 +0000 (16:36 -0500)]
[HLSL] Add HLSLResource attribute

HLSL Resource objects will have restrictions on use and codegen
requirements. This patch is fairly minimal just adding the attribute
with no spellings since it will only be attached by the
HLSLExternalSemaSource.

Depends on D1300017.

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

23 months ago[mlir][complex] Canonicalize consecutive complex.conj
lewuathe [Fri, 29 Jul 2022 00:40:57 +0000 (09:40 +0900)]
[mlir][complex] Canonicalize consecutive complex.conj

We can canonicalize consecutive complex.conj just by removing all conjugate operations.

Reviewed By: pifon2a

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

23 months ago[clang-format] Handle Verilog attributes
sstwcw [Fri, 29 Jul 2022 00:17:02 +0000 (00:17 +0000)]
[clang-format] Handle Verilog attributes

Reviewed By: HazardyKnusperkeks, owenpan

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

23 months ago[clang-format] Handle Verilog case statements
sstwcw [Fri, 29 Jul 2022 00:12:46 +0000 (00:12 +0000)]
[clang-format] Handle Verilog case statements

These statements are like switch statements in C, but without the 'case'
keyword in labels.

How labels are parsed.  In UnwrappedLineParser, the program tries to
parse a statement every time it sees a colon.  In TokenAnnotator, a
colon that isn't part of an expression is annotated as a label.

The token type `TT_GotoLabelColon` is added.  We did not include Verilog
in the name because we thought we would eventually have to fix the
problem that case labels in C can't contain ternary conditional
expressions and we would use that token type.

The style is like below.  Labels are on separate lines and indented by
default.  The linked style guide also has examples where labels and the
corresponding statements are on the same lines.  They are not supported
for now.

https://github.com/lowRISC/style-guides/blob/master/VerilogCodingStyle.md

```
case (state_q)
  StIdle:
    state_d = StA;
  StA: begin
    state_d = StB;
  end
endcase
```

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

23 months ago[clang-format] Handle Verilog user-defined primitives
sstwcw [Thu, 28 Jul 2022 23:49:33 +0000 (23:49 +0000)]
[clang-format] Handle Verilog user-defined primitives

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

23 months ago[clang-format] Handle Verilog modules
sstwcw [Thu, 28 Jul 2022 23:39:46 +0000 (23:39 +0000)]
[clang-format] Handle Verilog modules

Now things inside hierarchies like modules and interfaces are
indented.  When the module header spans multiple lines, all except the
first line are indented as continuations.  We added the property
`IsContinuation` to mark lines that should be indented this way.

In order that the colons inside square brackets don't get labeled as
`TT_ObjCMethodExpr`, we added a check to only use this type when the
language is not Verilog.

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

23 months ago[clang-format] Handle Verilog blocks
sstwcw [Thu, 28 Jul 2022 23:24:43 +0000 (23:24 +0000)]
[clang-format] Handle Verilog blocks

Now stuff inside begin-end blocks get indented.

Some tests are moved into FormatTestVerilog.Block from
FormatTestVerilog.If because they have nothing to do with if statements.

Reviewed By: HazardyKnusperkeks, owenpan

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

23 months ago[clang-format] Handle Verilog numbers and operators
sstwcw [Thu, 28 Jul 2022 23:17:19 +0000 (23:17 +0000)]
[clang-format] Handle Verilog numbers and operators

Reviewed By: HazardyKnusperkeks

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

23 months ago[lld/mac] Add support for $ld$previous symbols with explicit symbol name
Nico Weber [Thu, 9 Jun 2022 16:13:31 +0000 (12:13 -0400)]
[lld/mac] Add support for $ld$previous symbols with explicit symbol name

A symbol `$ld$previous$/Another$1.2.3$1$3.0$14.0$_xxx$` means
"pretend symbol `_xxx` is in dylib `/Another` with version `1.2.3`
if the deployment target is between `3.0` and `14.0` and we're
targeting platform `1` (ie macOS)".

This means dylibs can now inject synthetic dylibs into the link, so
DylibFile needs to grow a 3rd constructor.

The only other interesting thing is that such an injected dylib
counts as a use of the original dylib. This patch gets this mostly
right (if _only_ `$ld$previous` symbols are used from a dylib,
we don't add a dep on the dylib itself, matching ld64), but one case
where we don't match ld64 yet is that ld64 even omits the original
dylib when linking it with `-needed-l`. Lld currently still adds a load
command for the original dylib in that case. (That's for a future
patch.)

Fixes #56074.

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

23 months agoAMDGPU: Take care of "tied" operand when removeOperand
Changpeng Fang [Fri, 29 Jul 2022 00:30:49 +0000 (17:30 -0700)]
AMDGPU: Take care of "tied" operand when removeOperand

Summary:
  Flat scratch load of D16 type by default has tied vdst_in operand (with vdst). This should be taken
care of at the time of "removeOperand" in eliminateFrameIndex. Otherwise we will hit an assert saying
"Cannot move tied operands". This patch unties vdst_in before the move, and retie it with vdst afterwards.

Reviewers:
  arsenm, foad

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

23 months ago[Matrix] Refactor transpose distribution. NFC
Francis Visoiu Mistrih [Wed, 20 Jul 2022 09:45:31 +0000 (11:45 +0200)]
[Matrix] Refactor transpose distribution. NFC

Use a function to distribute transposes. Preparation for future patches.

23 months ago[lld-macho] Allow linking with ABI compatible architectures
Vincent Lee [Thu, 28 Jul 2022 06:31:21 +0000 (23:31 -0700)]
[lld-macho] Allow linking with ABI compatible architectures

Linking fails when targeting `x86_64-apple-darwin` for runtimes. The issue
is that LLD strictly assumes the target architecture be present in the tbd
files (which isn't always true). For example, when targeting `x86_64h`, it should
work with `x86_64` because they are ABI compatible. This is also inline with what
ld64 does.

An environment variable (which ld64 also supports) is also added to preserve the
existing behavior of strict architecture matching.

Reviewed By: #lld-macho, int3

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

23 months agoUpdate references to mailing lists that have moved to Discourse.
tlattner [Thu, 28 Jul 2022 23:54:38 +0000 (16:54 -0700)]
Update references to mailing lists that have moved to Discourse.

23 months ago[flang] Fix build failure
V Donaldson [Thu, 28 Jul 2022 21:48:06 +0000 (14:48 -0700)]
[flang] Fix build failure

23 months ago[clang][lld][cmake] Simplify header dirs
John Ericson [Tue, 26 Jul 2022 07:17:30 +0000 (07:17 +0000)]
[clang][lld][cmake] Simplify header dirs

We don't need to recompute the list LLVMConfig.cmake provides us.

When LLVM is being built, the list is two elements long: generated headers and headers from source.

When LLVM is already built,the list is one element long: the installed header directory containing both generated and hand-written sources.

Reviewed By: sebastian-ne

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

23 months ago[LLDB] Fix missing return value in SBBreakpointLocation::GetQueueName()
Slava Gurevich [Wed, 27 Jul 2022 19:30:19 +0000 (12:30 -0700)]
[LLDB] Fix missing return value in SBBreakpointLocation::GetQueueName()

- Fix a typo in the function that never returns a significant value

- Add unit tests for the getters/setters in SBBreakpointLocation

- Verified the newly added unit test succeeds after the fix:
llvm-lit -sv  lldb/test/API/functionalities/breakpoint/breakpoint_locations/TestBreakpointLocations.py

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

23 months ago[Clang] Diagnose ill-formed constant expression when setting a non fixed enum to...
Shafik Yaghmour [Thu, 28 Jul 2022 22:26:15 +0000 (15:26 -0700)]
[Clang] Diagnose ill-formed constant expression when setting a non fixed enum to a value outside the range of the enumeration values

DR2338 clarified that it was undefined behavior to set the value outside the
range of the enumerations values for an enum without a fixed underlying type.

We should diagnose this with a constant expression context.

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

23 months ago[GlobalISel] Handle nullptr constants in dbg.value
Felipe de Azevedo Piovezan [Thu, 28 Jul 2022 21:56:52 +0000 (14:56 -0700)]
[GlobalISel] Handle nullptr constants in dbg.value

Currently, the LLVM IR -> MIR translator fails to translate dbg.values
whose first argument is a null pointer. However, in other portions of
the code, such pointers are always lowered to the constant zero, for
example see IRTranslator::Translate(Constant, Register).

This patch addresses the limitation by following the same approach of
lowering null pointers to zero.

A prior test was checking that null pointers were always lowered to
$noreg; this test is changed to check for zero, and the previous
behavior is now checked by introducing a dbg.value whose first argument
is the address of a global variable.

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

23 months ago[lld-macho] `-exported_symbols` should hide symbols before LTO runs
Jez Ng [Thu, 28 Jul 2022 21:55:12 +0000 (17:55 -0400)]
[lld-macho] `-exported_symbols` should hide symbols before LTO runs

We were previously doing it after LTO, which did have the desired effect
of having the un-exported symbols marked as private extern in the final
output binary, but doing it before LTO creates more optimization
opportunities.

One observable difference is that LTO can now elide un-exported symbols
entirely, so they may not even be present as private externs in the
output.

This is also what ld64 implements.

Reviewed By: #lld-macho, thevinster

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

23 months ago[GlobalISel][nfc] Remove unnecessary cast
Felipe de Azevedo Piovezan [Thu, 28 Jul 2022 21:53:47 +0000 (14:53 -0700)]
[GlobalISel][nfc] Remove unnecessary cast

The getOperand method already returns a Constant when it is called on
a ConstantExpression, as such the cast is not needed. To prevent a type
mismatch between the different return statements of the lambda, the
lambda return type is explicitly provided.

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

23 months ago[mlir] Introduce DefaultValuedOptionalAttr
Jacques Pienaar [Thu, 28 Jul 2022 21:43:13 +0000 (14:43 -0700)]
[mlir] Introduce DefaultValuedOptionalAttr

Currently DefaultValuedAttr is confusingly actually default valued &
optional but that was an artifact of development and longstanding TODO
to address. Add new attribute that matches this behavior for cases where
that is actually the desired behavior before addressing TODO (e.g., this
is an incremental step to fixing DefaultValuedAttr).

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

23 months ago[AMDGPU][Scheduler] Avoid initializing Register pressure tracker when tracking is...
Anshil Gandhi [Thu, 28 Jul 2022 19:27:42 +0000 (13:27 -0600)]
[AMDGPU][Scheduler] Avoid initializing Register pressure tracker when tracking is disabled

When register pressure tracking is disabled, the scheduler attempts to load
pressures at SReg_32 and VGPR_32. This causes an index out of bounds error.
This patch fixes this issue by disabling the initialization of RPTracker
when not needed. NFC

Reviewed By: rampitec, kerbowa, arsenm

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