platform/upstream/llvm.git
23 months ago[X86] combineSelect fold 'smin' style pattern select(pcmpgt(RHS, LHS), LHS, RHS)...
Simon Pilgrim [Sat, 30 Jul 2022 14:31:31 +0000 (15:31 +0100)]
[X86] combineSelect fold 'smin' style pattern select(pcmpgt(RHS, LHS), LHS, RHS) -> select(pcmpgt(LHS, RHS), RHS, LHS) if pcmpgt(LHS, RHS) already exists

Avoids repeated commuted comparisons when we're performing min/max and clamp patterns

23 months agoConstantFolding: fold OOB accesses to poison instead of undef
Nuno Lopes [Sat, 30 Jul 2022 14:20:32 +0000 (15:20 +0100)]
ConstantFolding: fold OOB accesses to poison instead of undef

23 months ago[InstCombine] avoid splitting a constant expression with div/rem fold
Sanjay Patel [Sat, 30 Jul 2022 13:43:09 +0000 (09:43 -0400)]
[InstCombine] avoid splitting a constant expression with div/rem fold

Follow-up to d4940c0f3d43 to further limit the transform
to avoid an unintended pattern/fold of a constant expression.

23 months ago[DAG] Pull out repeated getOperand() calls for shuffle ops. NFC.
Simon Pilgrim [Sat, 30 Jul 2022 12:59:47 +0000 (13:59 +0100)]
[DAG] Pull out repeated getOperand() calls for shuffle ops. NFC.

23 months ago[AMDGPU] Fix || vs && precedence warning. NFC.
Simon Pilgrim [Sat, 30 Jul 2022 11:19:21 +0000 (12:19 +0100)]
[AMDGPU] Fix || vs && precedence warning. NFC.

23 months ago[NFC] Switch a few uses of undef to poison as placeholders for unreachable code
Nuno Lopes [Sat, 30 Jul 2022 12:55:56 +0000 (13:55 +0100)]
[NFC] Switch a few uses of undef to poison as placeholders for unreachable code

23 months ago[X86] Add test cases for D129537
Luo, Yuanke [Sat, 30 Jul 2022 11:39:03 +0000 (19:39 +0800)]
[X86] Add test cases for D129537

23 months agoSelectionDAGNodes.h - fix Wdocumentation warnings. NFC.
Simon Pilgrim [Sat, 30 Jul 2022 10:05:33 +0000 (11:05 +0100)]
SelectionDAGNodes.h - fix Wdocumentation warnings. NFC.

23 months agoDependencyScanningTool.h - fix Wdocumentation warning. NFC.
Simon Pilgrim [Sat, 30 Jul 2022 10:00:35 +0000 (11:00 +0100)]
DependencyScanningTool.h - fix Wdocumentation warning. NFC.

23 months agoSema.h - fix Wdocumentation warnings. NFC.
Simon Pilgrim [Sat, 30 Jul 2022 10:00:16 +0000 (11:00 +0100)]
Sema.h - fix Wdocumentation warnings. NFC.

23 months ago[libc++][ranges] Implement `std::ranges::partial_sort_copy`.
Konstantin Varlamov [Sat, 30 Jul 2022 09:42:05 +0000 (02:42 -0700)]
[libc++][ranges] Implement `std::ranges::partial_sort_copy`.

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

23 months ago[InstCombine] Add fold for redundant sign bits count comparison
Alexander Shaposhnikov [Sat, 30 Jul 2022 09:06:37 +0000 (09:06 +0000)]
[InstCombine] Add fold for redundant sign bits count comparison

For power-of-2 C:
((X s>> ShiftC) ^ X) u< C --> (X + C) u< (C << 1)
((X s>> ShiftC) ^ X) u> (C - 1) --> (X + C) u> ((C << 1) - 1)

(https://github.com/llvm/llvm-project/issues/56479)

Test plan:
0/ ninja check-llvm check-clang + bootstrap LLVM/Clang
1/ https://alive2.llvm.org/ce/z/eEUfx3

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

23 months ago[libc++] Fix reverse_iterator::iterator_concept
Nikolas Klauser [Sun, 24 Jul 2022 14:46:57 +0000 (16:46 +0200)]
[libc++] Fix reverse_iterator::iterator_concept

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

Reviewed By: ldionne, Mordante, huixie90, #libc

Spies: libcxx-commits, hewillk

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

23 months ago[ELF] Support missing relocations in AArch64::getImplicitAddend()
Fangrui Song [Sat, 30 Jul 2022 08:24:55 +0000 (01:24 -0700)]
[ELF] Support missing relocations in AArch64::getImplicitAddend()

23 months ago[InstCombine] Add baseline tests for redundant sign bits count folds
Alexander Shaposhnikov [Sat, 30 Jul 2022 08:23:45 +0000 (08:23 +0000)]
[InstCombine] Add baseline tests for redundant sign bits count folds

Add baseline tests. NFC.
(https://github.com/llvm/llvm-project/issues/56479)

Test plan:
ninja check-all

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

23 months ago[ELF] Write R_AARCH64_IRELATIVE addends with -z rel
Fangrui Song [Sat, 30 Jul 2022 08:19:59 +0000 (01:19 -0700)]
[ELF] Write R_AARCH64_IRELATIVE addends with -z rel

23 months ago[NFC] Use more appropriate SmallVectorImpl::append call in std::initializer_list...
Dawid Jurczak [Sat, 30 Jul 2022 07:15:11 +0000 (09:15 +0200)]
[NFC] Use more appropriate SmallVectorImpl::append call in std::initializer_list SmallVector constructor

Since we are in constructor there is no need to perform redundant call to SmallVectorImpl::clear() inside assign function.
Although calling cheaper append function instead assign doesn't make any difference on optimized builds
(DSE does the job removing stores), we still save some cycles for debug binaries.

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

23 months ago[X86][FP16] Regenerate test cases. NFC.
Phoebe Wang [Sat, 30 Jul 2022 05:13:21 +0000 (13:13 +0800)]
[X86][FP16] Regenerate test cases. NFC.

23 months ago[llvm] Use is_contained (NFC)
Kazu Hirata [Sat, 30 Jul 2022 04:18:44 +0000 (21:18 -0700)]
[llvm] Use is_contained (NFC)

23 months agoUse is_sorted (NFC)
Kazu Hirata [Sat, 30 Jul 2022 04:18:42 +0000 (21:18 -0700)]
Use is_sorted (NFC)

23 months agoUse value instead of getValue (NFC)
Kazu Hirata [Sat, 30 Jul 2022 04:18:41 +0000 (21:18 -0700)]
Use value instead of getValue (NFC)

23 months ago[clang] Use has_value instead of value (NFC)
Kazu Hirata [Sat, 30 Jul 2022 04:18:39 +0000 (21:18 -0700)]
[clang] Use has_value instead of value (NFC)

23 months ago[LLDB][RISCV] Add DWARF Registers
Emmmer [Thu, 28 Jul 2022 07:38:33 +0000 (15:38 +0800)]
[LLDB][RISCV] Add DWARF Registers

According to [RISC-V DWARF Specification](https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/master/riscv-dwarf.adoc) add RISCV DWARF Registers.

Don't worry about the difference between riscv32 and riscv64, they just have different bytes of registers.

Reviewed By: DavidSpickett

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

23 months ago[libc] Compile integration tests with -ffreestanding to avoid mixup with system libc.
Siva Chandra Reddy [Sat, 30 Jul 2022 01:37:55 +0000 (01:37 +0000)]
[libc] Compile integration tests with -ffreestanding to avoid mixup with system libc.

23 months agoPreserve qualifiers when getting fully qualified type
Weverything [Sat, 30 Jul 2022 02:17:20 +0000 (19:17 -0700)]
Preserve qualifiers when getting fully qualified type

15f3cd6bfc670ba6106184a903eb04be059e5977 moved the handling of UsingType
to a later point in the function getFullyQualifiedType.  This moved it
after the removal of an ElaboratedType and its qualifiers.  However,
the qualifiers were not added back, causing the fully qualified type to
have a qualifier mismatch with the original type.  Make sure the
qualifers are added before continuing to fully qualify the type.

23 months ago[AMDGPU] Extend SILoadStoreOptimizer to s_load instructions
Carl Ritson [Sat, 30 Jul 2022 02:13:20 +0000 (11:13 +0900)]
[AMDGPU] Extend SILoadStoreOptimizer to s_load instructions

Apply merging to s_load as is done for s_buffer_load.

Reviewed By: foad

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

23 months ago[InstCombine] Refactor foldICmpMulConstant
Alexander Shaposhnikov [Sat, 30 Jul 2022 01:43:25 +0000 (01:43 +0000)]
[InstCombine] Refactor foldICmpMulConstant

This is a follow-up to 2ebfda2417
(replace "if" with "else if" since the cases nuw/nsw
were meant to be handled separately).

Test plan:
1/ ninja check-llvm check-clang check-lld
2/ Bootstrapped LLVM/Clang pass tests

23 months ago[Clang] Fix handling of Max from getValueRange(...) in IntExprEvaluator::VisitCastExp...
Shafik Yaghmour [Sat, 30 Jul 2022 02:17:42 +0000 (19:17 -0700)]
[Clang] Fix handling of Max from getValueRange(...) in IntExprEvaluator::VisitCastExpr(...)

This is a follow-up to D130058 to fix how we handle the Max value we obtain from
getValueRange(...) in IntExprEvaluator::VisitCastExpr(...) which in the case of
an enum that contains an enumerator with the max integer value will overflow by
one.

The fix is to decrement the value of Max and use slt and ult for comparison Vs
sle and ule.`

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

23 months agoFix lack of cc1 flag in llvmcmd sections when assertions are enabled
Aiden Grossman [Sat, 30 Jul 2022 01:38:34 +0000 (18:38 -0700)]
Fix lack of cc1 flag in llvmcmd sections when assertions are enabled

Currently when assertions are enabled, the cc1 flag is not
inserted into the llvmcmd section of object files with embedded
bitcode. This deviates from the normal behavior where this is
the first flag that is inserted. This error stems from incorrect
use of the function generateCC1CommandLine() which requires
manually adding in the -cc1 flag which is currently not done.

Reviewed By: jansvoboda11

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

23 months ago[MLIR] Fix getCommonBlock utility in affine analysis
Uday Bondhugula [Sat, 30 Jul 2022 01:39:02 +0000 (07:09 +0530)]
[MLIR] Fix getCommonBlock utility in affine analysis

Fix the hardcoded check for `FuncOp` in `getCommonBlock` utility: the
check should have been for an op that starts an affine scope. The
incorrect block returned in turn causes dependence analysis to function
incorrectly.

This change allows affine store-load forwarding to work correctly inside
any ops that start an affine scope.

Reviewed By: ftynse, dcaballe

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

23 months agoRevert "[compiler-rt] [builtins] Detect _Float16 support at compile time"
Phoebe Wang [Sat, 30 Jul 2022 01:41:33 +0000 (09:41 +0800)]
Revert "[compiler-rt] [builtins] Detect _Float16 support at compile time"

This reverts commit ce6d40f5c23923a807388c58b82b4c343eced0ce.

Revert due to it broke the sanitizer-windows buildbot: https://lab.llvm.org/buildbot/#/builders/127/builds/33583/steps/4/logs/stdio

23 months ago[libc] Implement cosf function that is correctly rounded to all rounding modes.
Tue Ly [Wed, 27 Jul 2022 16:22:27 +0000 (12:22 -0400)]
[libc] Implement cosf function that is correctly rounded to all rounding modes.

Implement cosf function that is correctly rounded to all rounding
modes.

Performance benchmark using perf tool from CORE-MATH project

(https://gitlab.inria.fr/core-math/core-math/-/tree/master) on Ryzen 1700:
Before this patch (not correctly rounded):
```
$ CORE_MATH_PERF_MODE="rdtsc" ./perf.sh cosf
CORE-MATH reciprocal throughput   : 19.043
System LIBC reciprocal throughput : 26.328
LIBC reciprocal throughput        : 30.955

$ CORE_MATH_PERF_MODE="rdtsc" ./perf.sh cosf --latency
GNU libc version: 2.31
GNU libc release: stable
CORE-MATH latency   : 49.995
System LIBC latency : 59.286
LIBC latency        : 60.174

```
After this patch (correctly rounded):
```
$ CORE_MATH_PERF_MODE="rdtsc" ./perf.sh cosf
GNU libc version: 2.31
GNU libc release: stable
CORE-MATH reciprocal throughput   : 19.072
System LIBC reciprocal throughput : 26.286
LIBC reciprocal throughput        : 13.631

$ CORE_MATH_PERF_MODE="rdtsc" ./perf.sh cosf --latency
GNU libc version: 2.31
GNU libc release: stable
CORE-MATH latency   : 49.872
System LIBC latency : 59.468
LIBC latency        : 56.119
```

Reviewed By: orex, zimmermann6

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

23 months ago[flang] Add semantics test for EVENT WAIT statement
Naje George [Mon, 25 Jul 2022 23:07:07 +0000 (16:07 -0700)]
[flang] Add semantics test for EVENT WAIT statement

Reviewed By: ktras

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

23 months ago[ELF] Move addDependentLibrary/handleSectionGroup. NFC
Fangrui Song [Sat, 30 Jul 2022 00:07:09 +0000 (17:07 -0700)]
[ELF] Move addDependentLibrary/handleSectionGroup. NFC

To reduce diff for my upcoming parallel input section initialization patch.

23 months ago[mlir][sparse]Add more test cases for sparse reshape
Anlun Xu [Fri, 29 Jul 2022 23:40:47 +0000 (16:40 -0700)]
[mlir][sparse]Add more test cases for sparse reshape

Add more test cases for sparse reshape

Reviewed By: Peiming

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

23 months ago[clang-repl] Add missing link component.
Sunho Kim [Fri, 29 Jul 2022 22:59:43 +0000 (07:59 +0900)]
[clang-repl] Add missing link component.

OrcJIT was missing in LLVM_LINK_COMPONENTS.

23 months agoUpdate references to mailing lists that have moved to Discourse.
tlattner [Fri, 29 Jul 2022 22:55:14 +0000 (15:55 -0700)]
Update references to mailing lists that have moved to Discourse.

23 months agoRevert D130458 "[llvm-objcopy] Support --{,de}compress-debug-sections for zstd"
Fangrui Song [Fri, 29 Jul 2022 22:46:51 +0000 (15:46 -0700)]
Revert D130458 "[llvm-objcopy] Support --{,de}compress-debug-sections for zstd"

This reverts commit c26dc2904b95b3685d883e760e84046ea6c33d7f.

The new Zstd dispatch has an ongoing design discussion related to https://reviews.llvm.org/D130516#3688123 .
Revert for now before it is resolved.

23 months ago[ASTWriter] Provide capability to output a PCM/PCH file that does not write out infor...
Argyrios Kyrtzidis [Thu, 28 Jul 2022 07:48:56 +0000 (00:48 -0700)]
[ASTWriter] Provide capability to output a PCM/PCH file that does not write out information about its output path

This is useful to enable sharing of the same PCH file even when it's intended for a different output path.

The only information this option disables writing is for `ORIGINAL_PCH_DIR` record which is treated as optional and (when present) used as fallback for resolving input file paths relative to it.

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

23 months ago[clang-repl] Disable exectuion unitests on unsupported platform by lljit instance...
Sunho Kim [Fri, 29 Jul 2022 22:17:05 +0000 (07:17 +0900)]
[clang-repl] Disable exectuion unitests on unsupported platform by lljit instance test.

The method used in 4191d661c74622c6fa72c1643e4567f45e6c9e1b was fragile because it didn't consider cross-platform builds and rely on enlisting unsupported targets. Uses the host-supports-jit mechanism to make an escape path. This should fix buildbot failures happening in upstream as well as out-of-tree.

23 months ago[RISCV] Precommit test for D123265
Luís Marques [Fri, 29 Jul 2022 21:56:26 +0000 (23:56 +0200)]
[RISCV] Precommit test for D123265

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

23 months agoAdd BAT testing framework
Rafael Auler [Wed, 6 Jul 2022 22:53:27 +0000 (15:53 -0700)]
Add BAT testing framework

This patch refactors BAT to be testable as a library, so we
can have open-source tests on it. This further fixes an issue with
basic blocks that lack a valid input offset, making BAT omit those
when writing translation tables.

Test Plan: new testcases added, new testing tool added (llvm-bat-dump)

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

23 months ago[InstCombine] fix miscompile from urem/udiv transform with constant expression
Sanjay Patel [Fri, 29 Jul 2022 21:02:47 +0000 (17:02 -0400)]
[InstCombine] fix miscompile from urem/udiv transform with constant expression

The isa<Constant> check could misfire on an instruction with 2 constant
operands. This bug was introduced with bb789381fc11cce (D36988).

See issue #56810 for a C source example that exposed the bug.

23 months ago[RISCV] Add isel pattern for (setne/eq GPR, -2048)
Craig Topper [Fri, 29 Jul 2022 21:01:14 +0000 (14:01 -0700)]
[RISCV] Add isel pattern for (setne/eq GPR, -2048)

For constants in the range [-2047, 2048] we use addi. If the constant
is -2048 we can use xori. If we don't match this explicitly, we'll
emit an LI for the -2048 followed by an XOR.

23 months ago[lld][WebAssemby] Demote LazySymbols back to undefined symbols if they are not loaded
Sam Clegg [Thu, 28 Jul 2022 22:45:02 +0000 (15:45 -0700)]
[lld][WebAssemby] Demote LazySymbols back to undefined symbols if they are not loaded

A LazySymbol is one that lives in `.a` archive and gets pulled in by a
strong reference.  However, weak references to such symbols do not
result in them be loaded from the archive.  In this case we want to
treat such symbols at undefined rather then lazy, once symbols
resolution is complete.

This fixes a crash bug in the linker when weakly referenced symbol that
lives in an archive file is live at the end of the link.  In the case of
dynamic linking this is expected to turn into an import with (in the
case of a function symbol) a function index.

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

23 months ago[lld][WebAsssembly] Convert more tests from IR to assembly. NFC
Sam Clegg [Thu, 28 Jul 2022 22:45:02 +0000 (15:45 -0700)]
[lld][WebAsssembly] Convert more tests from IR to assembly. NFC

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

23 months ago[InstCombine] add tests for udiv/urem miscompile; NFC
Sanjay Patel [Fri, 29 Jul 2022 20:24:52 +0000 (16:24 -0400)]
[InstCombine] add tests for udiv/urem miscompile; NFC

See issue #56810

23 months ago[InstCombine] add test for icmp with zext-bool logic; NFC
Sanjay Patel [Fri, 29 Jul 2022 17:34:21 +0000 (13:34 -0400)]
[InstCombine] add test for icmp with zext-bool logic; NFC

23 months ago[LLDB][NFC][Reliability] Fixes for int overflow and uninitialized state
Slava Gurevich [Fri, 29 Jul 2022 19:23:03 +0000 (12:23 -0700)]
[LLDB][NFC][Reliability] Fixes for int overflow and uninitialized state

Fixing potential int overflow and uninitialized variables.
These were found by Coverity static code inspection.

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

23 months ago[IRBuilder] Make createCallHelper a member function. NFC.
Jay Foad [Fri, 29 Jul 2022 08:59:16 +0000 (09:59 +0100)]
[IRBuilder] Make createCallHelper a member function. NFC.

This just avoids explicitly passing in 'this' as an argument in a bunch
of places.

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

23 months ago[LangRef] Reduce depth of table of contents
Jay Foad [Wed, 27 Jul 2022 14:08:00 +0000 (15:08 +0100)]
[LangRef] Reduce depth of table of contents

The table of contents in the HTML version of this doc takes up 25 pages
(in my browser, on my 4K monitor) and is too long for me to navigate
comfortably. And most of it is irrelevant detail like this:

- Bitwise Binary Operations
  - 'shl' Instruction
    - Syntax:
    - Overview:
    - Arguments:
    - Semantics:
    - Example:
  - 'lshr' Instruction
    - Syntax:
    - Overview:
    - Arguments:
    - Semantics:
    - Example:

Reducing the contents depth from 4 to 3 removes most of this detail,
leaving just a list of instructions, which only takes up 7 pages and I
find it much easier to navigate.

Incidentally the depth was set to 3 when this document was first
converted to reST and was only increased to 4 in what looks like an
accidental change: 080133453bae62a43466e881ffc03fb7cffd7288

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

23 months ago[clang][dataflow] Handle multiple context-sensitive calls to the same function
Sam Estep [Fri, 29 Jul 2022 19:39:52 +0000 (19:39 +0000)]
[clang][dataflow] Handle multiple context-sensitive calls to the same function

This patch enables context-sensitive analysis of multiple different calls to the same function (see the `ContextSensitiveSetBothTrueAndFalse` example in the `TransferTest` suite) by replacing the `Environment` copy-assignment with a call to the new `popCall` method, which  `std::move`s some fields but specifically does not move `DeclToLoc` and `ExprToLoc` from the callee back to the caller.

To enable this, the `StorageLocation` for a given parameter needs to be stable across different calls to the same function, so this patch also improves the modeling of parameter initialization, using `ReferenceValue` when necessary (for arguments passed by reference).

This approach explicitly does not work for recursive calls, because we currently only plan to use this context-sensitive machinery to support specialized analysis models we write, not analysis of arbitrary callees.

Reviewed By: ymandel, xazax.hun

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

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

This reverts commit 4e1fe96.

Reverting this commit and fix the tests that caused failures due to
a35c64c.

23 months ago[compiler-rt] [builtins] Detect _Float16 support at compile time
Dimitry Andric [Thu, 28 Jul 2022 17:52:16 +0000 (19:52 +0200)]
[compiler-rt] [builtins] Detect _Float16 support at compile time

Instead of detecting `_Float16` support at CMake configuration time,
detect it at compile time by checking for the predefined (by the
compiler) macro `__FLT16_MAX__` instead.

This solves the issue where compiler-rt is built simultaneously for both
x86_64 and i386 targets, and the CMake configuration uses x86_64
compilation to detect `_Float16` support, while it may not be supported
by the i386 target (if it does not have SSE2).

While here, rename `COMPILERT_RT_HAS_FLOAT16` to `CRT_HAS_FLOAT16`, to
conform more to the naming style used in `int_lib.h` and `int_types.h`.

Reviewed By: MaskRay

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

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