platform/upstream/llvm.git
16 months agoAMDGPU: Add baseline 16-bit mad matching tests
Matt Arsenault [Mon, 5 Jun 2023 17:52:12 +0000 (13:52 -0400)]
AMDGPU: Add baseline 16-bit mad matching tests

16 months agoAMDGPU: Convert test to generated checks
Matt Arsenault [Mon, 5 Jun 2023 17:51:03 +0000 (13:51 -0400)]
AMDGPU: Convert test to generated checks

16 months ago[flang] Pad output correctly after tabbing with ADVANCE='no' (bug#63111)
Peter Klausler [Mon, 5 Jun 2023 21:58:20 +0000 (14:58 -0700)]
[flang] Pad output correctly after tabbing with ADVANCE='no' (bug#63111)

Correct the code that implements the production of spaces to bring the
furthestPositionInRecord up to a positionInRecord that was tabbed forward
by a T or TR control edit descriptor.

Fixes bug https://github.com/llvm/llvm-project/issues/63111.

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

16 months agofix build issue on bazel
Aart Bik [Mon, 5 Jun 2023 22:13:32 +0000 (15:13 -0700)]
fix build issue on bazel

Needed to fix:
https://github.com/llvm/llvm-project/commit/53a5c3ab4dbe434753e0e4e3505efa2e5692e752
https://github.com/llvm/llvm-project/commit/db7cc0348c9a0aa44b23948949afef488d5083dd

Reviewed By: Peiming, anlunx

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

16 months ago[hwasan] Properly restore SP tag on exceptions
Florian Mayer [Mon, 5 Jun 2023 21:14:27 +0000 (14:14 -0700)]
[hwasan] Properly restore SP tag on exceptions

Reviewed By: vitalybuka

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

16 months ago[bazel][libc] Add targets for integer abs and div functions.
Siva Chandra Reddy [Sat, 3 Jun 2023 23:04:20 +0000 (23:04 +0000)]
[bazel][libc] Add targets for integer abs and div functions.

Reviewed By: lntue

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

16 months ago[libc++][NFC] Add __element_count and use it in the constexpr C functions
Nikolas Klauser [Mon, 5 Jun 2023 22:07:42 +0000 (15:07 -0700)]
[libc++][NFC] Add __element_count and use it in the constexpr C functions

This makes it less ambiguous what the parameter is meant to get.

Reviewed By: #libc, ldionne

Spies: ldionne, libcxx-commits

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

16 months ago[RISCV] Lower experimental_get_vector_length intrinsic to vsetvli for some cases.
Craig Topper [Mon, 5 Jun 2023 22:02:11 +0000 (15:02 -0700)]
[RISCV] Lower experimental_get_vector_length intrinsic to vsetvli for some cases.

This patch lowers to vsetvli when the AVL is i32 or XLenVT and
the VF is a power of 2 in the range [1, 64]. VLEN=32 is not supported
as we don't have a valid type mapping for that. VF=1 is not supported
with Zve32* only.

The element width is used to set the SEW for the vsetvli if possible.
Otherwise we use SEW=8.

Reviewed By: reames

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

16 months ago[Demangle] refactor DLangDemangle to use std::string_view
Nick Desaulniers [Mon, 5 Jun 2023 21:31:55 +0000 (14:31 -0700)]
[Demangle] refactor DLangDemangle to use std::string_view

Many existing methods of the D Language Demangler take a C style string
and return an adjusted pointer to the same object as the input string is
consumed.

Make it more obvious by changing the signatures to accept
std::string_view& when the input is modified vs a copy of a
std::string_view when the input is not.

Reviewed By: efriedma

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

16 months ago[lld] StringRef::{starts,ends}with => {starts,ends}_with. NFC
Fangrui Song [Mon, 5 Jun 2023 21:36:19 +0000 (14:36 -0700)]
[lld] StringRef::{starts,ends}with => {starts,ends}_with. NFC

The latter form is now preferred to be similar to C++20 starts_with.
This replacement also removes one function call when startswith is not inlined.

16 months agoReland [compiler-rt][CMake] Properly set COMPILER_RT_HAS_LLD
Arthur Eubanks [Thu, 23 Feb 2023 19:21:33 +0000 (11:21 -0800)]
Reland [compiler-rt][CMake] Properly set COMPILER_RT_HAS_LLD

LLVM_TOOL_LLD_BUILD is a relic of the pre-monorepo times. This causes us to never set COMPILER_RT_HAS_LLD.

Instead, set it from the runtimes build if lld is being built and lld is used as the compiler-rt linker.

Mark a test that requires libstdc++ as requiring Android, as other platforms may not have a libstdc++ lying around.

Reviewed By: MaskRay

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

16 months ago[RISCV] Add RISCVISD nodes for vfwadd/vfwsub.
Craig Topper [Mon, 5 Jun 2023 20:47:28 +0000 (13:47 -0700)]
[RISCV] Add RISCVISD nodes for vfwadd/vfwsub.

Add a DAG combine to form these from FADD_VL/FSUB_VL and FP_EXTEND_VL.

This makes it similar to other widening ops and allows us to handle
using the same FP_EXTEND_VL for both operands.

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

16 months ago[RISCV] Rename SDT_RISCVVWBinOpW_VL->SDT_RISCVVWIntBinOpW_VL. NFC
Craig Topper [Mon, 5 Jun 2023 20:47:22 +0000 (13:47 -0700)]
[RISCV] Rename SDT_RISCVVWBinOpW_VL->SDT_RISCVVWIntBinOpW_VL. NFC

Preparation for D151969 which adds an FP version.

16 months ago[lldb][NFCI] Change the way Process stores StructuredData plugins
Alex Langford [Fri, 2 Jun 2023 01:26:33 +0000 (18:26 -0700)]
[lldb][NFCI] Change the way Process stores StructuredData plugins

Instead of having a map from ConstString to StructuredDataPluginSP, we
can use an llvm::StringMap. The keys themselves don't need to be
ConstStrings, so an llvm::StringMap feels most natural.

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

16 months ago[Driver] Allow -fsanitize=kcfi with -fsanitize-minimal-runtime
Sami Tolvanen [Mon, 5 Jun 2023 16:37:12 +0000 (16:37 +0000)]
[Driver] Allow -fsanitize=kcfi with -fsanitize-minimal-runtime

Having both UBSan with the minimal runtime and KCFI enabled can be
useful in low-level software. As there are no conflicts between the
flags, add KCFI to the list of compatible sanitizers.

16 months ago[RISCV][test] Fix a couple of whitespace issues
Jessica Clarke [Mon, 5 Jun 2023 20:25:04 +0000 (21:25 +0100)]
[RISCV][test] Fix a couple of whitespace issues

16 months ago[ADT] Deprecate StringRef::{starts,ends}with_insensitive
Kazu Hirata [Mon, 5 Jun 2023 20:18:07 +0000 (13:18 -0700)]
[ADT] Deprecate StringRef::{starts,ends}with_insensitive

This patch deprecates StringRef::{starts,ends}with_insensitive as
their uses have migrated to {starts,ends}_with_insensitive,
respectively.

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

16 months ago[Support] Remove {Bits,Float,Double}To{Bits,Float,Double}
Kazu Hirata [Mon, 5 Jun 2023 20:18:05 +0000 (13:18 -0700)]
[Support] Remove {Bits,Float,Double}To{Bits,Float,Double}

These functions have been deprecated since:

  commit 0f52c1f86c62dadf69a7b732779abf59edea3d5c
  Author: Kazu Hirata <kazu@google.com>
  Date:   Tue Feb 14 09:52:36 2023 -0800

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

16 months ago[Support] Remove PowerOf2Floor and ByteSwap_{16,32,64}
Kazu Hirata [Mon, 5 Jun 2023 20:18:03 +0000 (13:18 -0700)]
[Support] Remove PowerOf2Floor and ByteSwap_{16,32,64}

These functions have been deprecated since:

  commit b49b429fde3a282664289d7a2155d994085eb232
  Author: Kazu Hirata <kazu@google.com>
  Date:   Sun Feb 12 21:42:07 2023 -0800

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

16 months ago[lldb][NFCI] ConstString methods should take StringRefs by value
Alex Langford [Fri, 2 Jun 2023 17:19:57 +0000 (10:19 -0700)]
[lldb][NFCI] ConstString methods should take StringRefs by value

StringRef was made to be passed by value efficiently.

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

16 months ago[BOLT][NFC] Drop MMap events for deleted files
Amir Ayupov [Mon, 5 Jun 2023 20:02:59 +0000 (13:02 -0700)]
[BOLT][NFC] Drop MMap events for deleted files

Don't parse/handle mmap events with "(deleted)" filename.

Reviewed By: #bolt, rafauler

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

16 months ago[Demangle] convert microsoftDemangle to take a std::string_view
Nick Desaulniers [Mon, 5 Jun 2023 19:53:38 +0000 (12:53 -0700)]
[Demangle] convert microsoftDemangle to take a std::string_view

This should be last of the "bottom-up conversions" of various demanglers
to accept std::string_view.  After this, D149104 may be revisited.

Reviewed By: MaskRay

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

16 months ago[Sema] Fix a warning
Kazu Hirata [Mon, 5 Jun 2023 19:59:58 +0000 (12:59 -0700)]
[Sema] Fix a warning

This patch fixes:

  clang/lib/Sema/SemaExprCXX.cpp:5591:3: error: default label in
  switch which covers all enumeration values
  [-Werror,-Wcovered-switch-default]

16 months agollvm-dwarfdump --verify: Add support for .debug_str_offsets[.dwo]
David Blaikie [Mon, 5 Jun 2023 19:57:11 +0000 (19:57 +0000)]
llvm-dwarfdump --verify: Add support for .debug_str_offsets[.dwo]

Had a couple of issues lately causing corrupted strings due to
problematic str_offsets (overflow due to >4GB .debug_str.dwo section in
a dwp and the dwp tool silently overflowing the 32 bit offsets updated
in the .debug_str_offsets.dwo section, and then more recently two CUs in
a dwo caused the dwp tool to reapply the offset adjustment twice
corrupting str_offsets.dwo as well) - so let's check that the offsets
are valid.

This assumes no suffix merging - if anyone implements that, then this
checking should just be removed for the most part (we could still check
the offsets are within the bounds of .debug_str[.dwo], but nothing more
- any offset in the range would be valid, the offsets wouldn't have to
land at the start of a string)

16 months ago[lldb][NFCI] Use size_t in OptionValueProperties
Alex Langford [Thu, 1 Jun 2023 23:23:25 +0000 (16:23 -0700)]
[lldb][NFCI] Use size_t in OptionValueProperties

In many places we're using uint32_t where we should be using size_t.
We should be consistent.

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

16 months agoTest case improvement (Do not optimize debug locations across section boundaries...
Pierre Calixte [Mon, 5 Jun 2023 19:51:26 +0000 (12:51 -0700)]
Test case improvement (Do not optimize debug locations across section boundaries/D149294)

Ensure that the expected location directives are from different sections.

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

16 months ago[lldb][NFCI] Change return type of REPL::GetSourceFileBasename
Alex Langford [Fri, 2 Jun 2023 01:37:37 +0000 (18:37 -0700)]
[lldb][NFCI] Change return type of REPL::GetSourceFileBasename

These don't really need to be in the ConstString StringPool. I've
changed the return type to StringRef because on llvm.org and downstream
in the swift fork, this returns a constant value. We could change it to
return a std::string or something else if it needs to be able to change
between calls.

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

16 months ago[NVPTX] fixed vector-compare test.
Artem Belevich [Mon, 5 Jun 2023 19:44:05 +0000 (12:44 -0700)]
[NVPTX] fixed vector-compare test.

Apparently this test didn't actually test anything other that the IR compiles.

16 months ago[flang] Fix crash from bug#63099 (gfortran/regression/oldstyle_3.f90)
Peter Klausler [Mon, 5 Jun 2023 18:31:53 +0000 (11:31 -0700)]
[flang] Fix crash from bug#63099 (gfortran/regression/oldstyle_3.f90)

In InitElement() in flang/lib/Semantics/data-to-inits.cpp, don't
assume that values_.Location() can be called until after it has been
verified that values_.IsAtEnd() is not true.

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

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

16 months agoCoalesce 16-bit FP types to use integer register classes.
Artem Belevich [Sat, 27 May 2023 00:11:23 +0000 (17:11 -0700)]
Coalesce 16-bit FP types to use integer register classes.

i16/f16/bf16 will use the same .b16 registers and
i32/v2f16 and v2bf16 will share .b32 registers.

The changes are mostly mechanical, intended to remove unnecessary register
classes which tend to produce redundant register moves.

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

v2f16 regtype conversion to i32

16 months ago[Clang] Add release note for 877210faa447
Nathan Chancellor [Mon, 5 Jun 2023 19:12:21 +0000 (12:12 -0700)]
[Clang] Add release note for 877210faa447

Reviewed By: erichkeane, nickdesaulniers

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

16 months agoFix MLIR build with Shared lib enabled
Mehdi Amini [Mon, 5 Jun 2023 19:10:24 +0000 (12:10 -0700)]
Fix MLIR build with Shared lib enabled

db7cc0348c9a0 added OpenMP support to the execution engine but didn't
add the explicit CMake dependency.

16 months agoActivate OpenMP translation in MLIR execution engine CAPI.
Rafael Ubal Tena [Mon, 5 Jun 2023 18:56:44 +0000 (11:56 -0700)]
Activate OpenMP translation in MLIR execution engine CAPI.

We've observed that the MLIR Jit Engine fails when the `omp` dialect is used due to a failure to register OpenMP-related translations. This small patch addresses this issue.

Reviewed By: mehdi_amini

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

16 months ago[scudo] Change configuration for Trusty, use mmap()
Dmitriy Filchenko [Mon, 5 Jun 2023 18:28:09 +0000 (18:28 +0000)]
[scudo] Change configuration for Trusty, use mmap()

Trusty runs in memory constrained environments, with many apps
having only one page (4KB) of heap memory available. However, we
still want to mmap() multiples of PAGE_SIZE at a time.

Additionally, switch Scudo from using sbrk() to mmap().

Reviewed By: cferris

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

16 months agoFix LLVM sphinx build
Aaron Ballman [Mon, 5 Jun 2023 18:14:23 +0000 (14:14 -0400)]
Fix LLVM sphinx build

Addresses the issue found by:
https://lab.llvm.org/buildbot/#/builders/30/builds/35886

16 months agotree-sitter-mlir: add a more complete grammar
Ramkumar Ramachandra [Mon, 20 Feb 2023 14:57:51 +0000 (15:57 +0100)]
tree-sitter-mlir: add a more complete grammar

Contribute a grammar, along with associated tests, from the upstream
project maintained at https://github.com/artagnon/tree-sitter-mlir. The
new grammar includes several fixes, and successfully parses 60-80% of
MLIR tests in the Arith, Math, ControlFlow, SCF, Tensor, Affine, and
Linalg dialects.

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

16 months agoRespect "-fdiagnostics-absolute-paths" on emit include location
Charalampos Mitrodimas [Mon, 5 Jun 2023 17:43:33 +0000 (17:43 +0000)]
Respect "-fdiagnostics-absolute-paths" on emit include location

This commit fixes "TextDiagnostic::emitIncludeLocation" when compiling
with "-fdiagnostics-absolute-paths" flag enabled by emitting the absolute
path of the included file.

Fixes #63026

Reviewed By: aaron.ballman

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

16 months ago[clang][NFC] refactors value type traits so we can have more than bools
Christopher Di Bella [Fri, 2 Jun 2023 21:19:03 +0000 (21:19 +0000)]
[clang][NFC] refactors value type traits so we can have more than bools

Since all the type traits up until now have had Boolean vaules, we've
always been able to assume that the expressions are `bool`. This is
about to change (D151952 introduces a trait that returns `size_t`), so
we need to restructure the code so it doesn't become unwieldy.

This is achieved by giving traits a designated "return" type.

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

16 months ago[Flang] Map `ieee_fma` intrinsic to `llvm.fma`
Shao-Ce SUN [Mon, 5 Jun 2023 16:55:59 +0000 (00:55 +0800)]
[Flang] Map `ieee_fma` intrinsic to `llvm.fma`

Map `ieee_fma` intrinsic to LLVM IR as `llvm.fma`.

Reviewed By: klausler

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

16 months agoReplace deprecated startswith_insensitive with starts_with_insensitive
Fangrui Song [Mon, 5 Jun 2023 18:01:27 +0000 (11:01 -0700)]
Replace deprecated startswith_insensitive with starts_with_insensitive

16 months ago[InstCombine] Add transform `(icmp pred (shl {nsw and/or nuw} X, Y), C)` -> `(icmp...
Noah Goldstein [Mon, 5 Jun 2023 07:37:08 +0000 (02:37 -0500)]
[InstCombine] Add transform `(icmp pred (shl {nsw and/or nuw} X, Y), C)` -> `(icmp pred X, C)`

Three new transforms:
    1) `(icmp pred (shl nsw nuw X, Y), C)` [if `C <= 0`] -> `(icmp pred X, C)`
        - ugt: https://alive2.llvm.org/ce/z/K_57J_
        - sgt: https://alive2.llvm.org/ce/z/BL8u_a
        - sge: https://alive2.llvm.org/ce/z/yZZVYz
        - uge: https://alive2.llvm.org/ce/z/R4jwwJ
        - ule: https://alive2.llvm.org/ce/z/-gbmth
        - sle: https://alive2.llvm.org/ce/z/ycZVsh
        - slt: https://alive2.llvm.org/ce/z/4MzHYm
        - sle: https://alive2.llvm.org/ce/z/fgNfex
        - ult: https://alive2.llvm.org/ce/z/cXfvH5
        - eq : https://alive2.llvm.org/ce/z/sZh_Ti
        - ne : https://alive2.llvm.org/ce/z/UrqSWA

    2) `(icmp eq/ne (shl {nsw|nuw} X, Y), 0)` -> `(icmp eq/ne X, 0)`
        - eq+nsw: https://alive2.llvm.org/ce/z/aSJN6D
        - eq+nuw: https://alive2.llvm.org/ce/z/r2_-br
        - ne+nuw: https://alive2.llvm.org/ce/z/RkETtu
        - ne+nsw: https://alive2.llvm.org/ce/z/8iSfW3

    3) `(icmp slt (shl nsw X, Y), 0/1)` -> `(icmp pred X, 0/1)`
       `(icmp sgt (shl nsw X, Y), 0/-1)` -> `(icmp pred X, 0/-1)`
        - slt: https://alive2.llvm.org/ce/z/eZYRan
        - sgt: https://alive2.llvm.org/ce/z/QQeP26

    Transform 3) is really sle/slt/sge/sgt with 0, but sle/sge
    canonicalize to slt/sgt respectively so its implemented as such.

Reviewed By: nikic

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

16 months ago[InstCombine] Add tests for tranforming `(icmp pred (shl {nsw and/or nuw} X, Y),...
Noah Goldstein [Mon, 5 Jun 2023 07:37:06 +0000 (02:37 -0500)]
[InstCombine] Add tests for tranforming `(icmp pred (shl {nsw and/or nuw} X, Y), C)`; NFC

Reviewed By: nikic

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

16 months ago[sanitizer] add new symbolizer symbol
Florian Mayer [Mon, 5 Jun 2023 17:57:49 +0000 (10:57 -0700)]
[sanitizer] add new symbolizer symbol

16 months ago[mlir][sparse] Make getNumTensors() consistent between LoopEmitter and Merger.
Peiming Liu [Mon, 5 Jun 2023 17:26:40 +0000 (17:26 +0000)]
[mlir][sparse] Make getNumTensors() consistent between LoopEmitter and Merger.

Reviewed By: aartbik

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

16 months ago[Sema] Do not emit -Wunused-variable for variables declared with cleanup attribute
Nathan Chancellor [Mon, 5 Jun 2023 17:49:41 +0000 (10:49 -0700)]
[Sema] Do not emit -Wunused-variable for variables declared with cleanup attribute

A variable declared with __attribute__((cleanup)) cannot be unused, as
its address is passed to the clean up function. Do not emit
-Wunused-variable for variables declared with the cleanup attribute,
which matches GCC's behavior: https://godbolt.org/z/dz5YfTsan

Reviewed By: erichkeane, nickdesaulniers

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

16 months ago[IRBUilder] Introduce getAllOnesMask [nfc]
Philip Reames [Mon, 5 Jun 2023 17:46:49 +0000 (10:46 -0700)]
[IRBUilder] Introduce getAllOnesMask [nfc]

Simplify D99750 by factoring out a utility which we already have multiple instances of in tree.

16 months agoRemove vestiges of removed OCaml modules
Alan Hu [Mon, 5 Jun 2023 17:19:45 +0000 (13:19 -0400)]
Remove vestiges of removed OCaml modules

Several OCaml modules using the old PassManager API were removed in
https://reviews.llvm.org/D144751, but the META file still needed to be
updated to remove them. This diff also removes an unused macro definition
related to the module removals.

Reviewed By: nikic

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

16 months agoRevert "Properly restore SP tag on exceptions"
Florian Mayer [Mon, 5 Jun 2023 17:26:33 +0000 (10:26 -0700)]
Revert "Properly restore SP tag on exceptions"

This reverts commit 6a2e0cb418175bb985aa898604560110a77c43da.

16 months ago[AMDGPU] Add intrinsic for converting global pointers to resources
Krzysztof Drewniak [Wed, 19 Apr 2023 15:19:14 +0000 (15:19 +0000)]
[AMDGPU] Add intrinsic for converting global pointers to resources

Define the function @llvm.amdgcn.make.buffer.rsrc, which take a 64-bit
pointer, the 16-bit stride/swizzling constant that replace the high 16
bits of an address in a buffer resource, the 32-bit extent/number of
elements, and the 32-bit flags (the latter two being the 3rd and 4th
wards of the resource), and combines them into a ptr addrspace(8).

This intrinsic is lowered during the early phases of the backend.

This intrinsic is needed so that alias analysis can correctly infer
that a certain buffer resource points to the same memory as some
global pointer. Previous methods of constructing buffer resources,
which relied on ptrtoint, would not allow for such an inference.

Depends on D148184

Reviewed By: arsenm

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

16 months ago[AMDGPU] Use resource base for buffer instruction MachineMemOperands
Krzysztof Drewniak [Wed, 12 Apr 2023 23:18:17 +0000 (23:18 +0000)]
[AMDGPU] Use resource base for buffer instruction MachineMemOperands

1. Remove the existing code that would encode the constant offsets (if
there were any) on buffer intrinsic operations onto their
`MachineMemOperand`s. As far as I can tell, this use of `offset` has
no substantial impact on the generated code, especially since the same
reasoning is performed by areMemAccessesTriviallyDisjoint().

2. When a buffer resource intrinsic takes a pointer argument as the
base resource/descriptor, place that memory argument in the value
field of the MachineMemOperand attached to that intrinsic.

This is more conservative than what would be produced by more typical
LLVM code using GEP, as the Value (for alias analysis purposes)
corresponding to accessing buffer[0] and buffer[1] is the same.
However, the target-specific analysis of disjoint offsets covers a lot
of the simple usecases.

Despite this limitation, the new buffer intrinsics, combined with
LLVM's existing pointer annotations, allow for non-trivial
optimizations, as seen in the new tests, where marking two buffer
descriptors "noalias" allows merging together loads and stores in a
"load from A, modify loaded value, store to B" sequence, which would
not be possible previously.

Depends on D147547

Reviewed By: arsenm

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

16 months agoRevert "[libc++] Optimize for_each for segmented iterators"
Nikolas Klauser [Mon, 5 Jun 2023 17:00:02 +0000 (10:00 -0700)]
Revert "[libc++] Optimize for_each for segmented iterators"

This reverts commit b1dc43aa3a05c2f14725e2e6428544208ccbe161.

16 months ago[AMDGPU] Add buffer intrinsics that take resources as pointers
Krzysztof Drewniak [Tue, 4 Apr 2023 17:11:04 +0000 (17:11 +0000)]
[AMDGPU] Add buffer intrinsics that take resources as pointers

In order to enable the LLVM frontend to better analyze buffer
operations (and to potentially enable more precise analyses on the
backend), define versions of the raw and structured buffer intrinsics
that use `ptr addrspace(8)` instead of `<4 x i32>` to represent their
rsrc arguments.

The new intrinsics are named by replacing `buffer.` with `buffer.ptr`.

One advantage to these intrinsic definitions is that, instead of
specifying that a buffer load/store will read/write some memory, we
can indicate that the memory read or written will be based on the
pointer argument. This means that, for example, a read from a
`noalias` buffer can be pulled out of a loop that is modifying a
distinct buffer.

In the future, we will define custom PseudoSourceValues that will
allow us to package up the (buffer, index, offset) triples that buffer
intrinsics contain and allow for more precise backend analysis.

This work also enables creating address space 7, which represents
manipulation of raw buffers using native LLVM load and store
instructions.

Where tests simply used a buffer intrinsic while testing some other
code path (such as the tests for VGPR spills), they have been updated
to use the new intrinsic form. Tests that are "about" buffer
intrinsics (for instance, those that ensure that they codegen as
expected) have been duplicated, either within existing files or into
new ones.

Depends on D145441

Reviewed By: arsenm, #amdgpu

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

16 months ago[Demangle] convert is*Encoding to use std::string_view
Nick Desaulniers [Mon, 5 Jun 2023 16:33:44 +0000 (09:33 -0700)]
[Demangle] convert is*Encoding to use std::string_view

This was originally a part of D149104 which was backed out. This change
is uncontroversial though, so split it out and reland it.

Reviewed By: MaskRay

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

16 months ago[Flang][PFT] Skip continue insertion for OpenMP Loops
Kiran Chandramohan [Mon, 5 Jun 2023 16:14:12 +0000 (16:14 +0000)]
[Flang][PFT] Skip continue insertion for OpenMP Loops

Unstructured regions presents some issues for OpenMP code generation.
While there are no branches out of the OpenMP region, there can be
branches inside. This required the availability of an artificial
target at the end of an OpenMP region. This was implemented by
insertion an artifical `continue` and marking it as a target for
a branch.
(https://github.com/flang-compiler/f18-llvm-project/pull/1178)

The artificial target is not required for OpenMP loops. Since the
DO loop end can itself be a target of a branch. Moreover, insertion
of the continue between the end of the loop and the end of the
OpenMP loop construct presents problems since the OpenMP MLIR
loop construct models both the loop and the construct. This can
cause the terminator of the OpenMP loop construct to be missed.
This patch solves the issue by skipping the insertion of the
continue.

Note: This issue is only hit if the `end openmp loop` directive
is missed.

This patch fixes the issues in:
-> https://github.com/llvm/llvm-project/issues/58378
-> https://github.com/flang-compiler/f18-llvm-project/issues/1426

Fixes #58378

Reviewed By: vdonaldson

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

16 months ago[RISCV] Switch vwsll.v* instructions to use the VSHT_IV_V_X_I class instead of VALU_I...
Craig Topper [Mon, 5 Jun 2023 16:24:50 +0000 (09:24 -0700)]
[RISCV] Switch vwsll.v* instructions to use the VSHT_IV_V_X_I class instead of VALU_IV_V_X_I.

This allows us to remove the uimm5 argument and changes the
scheduler class from ALU to Shift.

Ultimately we need a WShift scheduler class, but we need to scrub
all of the crypto instructions for scheduler classes so I'll leave
that for future work.

Reviewed By: 4vtomat, ego

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

16 months ago[TableGen] Fix indentation. NFC
Michael Liao [Mon, 5 Jun 2023 16:19:58 +0000 (12:19 -0400)]
[TableGen] Fix indentation. NFC

16 months ago[LLD] Emit DT_PPC64_OPT into the dynamic section
Stefan Pintilie [Fri, 2 Jun 2023 18:46:25 +0000 (14:46 -0400)]
[LLD] Emit DT_PPC64_OPT into the dynamic section

As per section 4.2.2 of the PowerPC ELFv2 ABI, this value tells the dynamic linker which optimizations it is allowed to do.
Specifically, the higher order bit of the two tells the dynamic linker that there may be multiple TOC pointers in the binary.

When we resolve any NOTOC relocations during linking, we need to set this value because we may be calling
TOC functions from NOTOC functions when the NOTOC function already clobbered the TOC pointer.

In practice, this ensures that the PLT resolver always resolves the call to the GEP (global entry point) of
the TOC function (which will set up the TOC for the TOC function).

Original patch by nemanjai

Reviewed By: MaskRay

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

16 months ago[clangd] Move completion signatures and labelDetails
Sam McCall [Tue, 23 May 2023 20:39:55 +0000 (22:39 +0200)]
[clangd] Move completion signatures and labelDetails

(When clients support it, otherwise keep the existing rendering).

In VSCode this makes the signature darker.

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

16 months ago[Flang][OpenMP] Refactor to properly fix privatisation of loop bounds
Kiran Chandramohan [Mon, 5 Jun 2023 15:43:37 +0000 (15:43 +0000)]
[Flang][OpenMP] Refactor to properly fix privatisation of loop bounds

The OpenMP loop Operations have the bounds attached to them. If the
loop bounds are privatised then the privatisation has to happen
before the loop operation is created. To do this the privatisation
is split into two steps. The first step performs cloning and
firstprivate handling, the second step performs lastprivate handling.

This also reverts the changes in the temporary fix (D127137).

Fixes https://github.com/flang-compiler/f18-llvm-project/issues/1171#issuecomment-1143880545
Fixes https://github.com/flang-compiler/f18-llvm-project/issues/1171#issuecomment-1119997442

Fixes #60872

Reviewed By: NimishMishra

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

16 months ago[clangd] Show size, offset and padding for bit fields on hover
SR_team [Mon, 5 Jun 2023 15:52:06 +0000 (17:52 +0200)]
[clangd] Show size, offset and padding for bit fields on hover

Examle:
```
struct test {
char a;
char b : 3;
char c : 5;
int d;
int e : 27;
};
```

{F27617774}
{F27617776}
{F27617777}
{F27617780}

Reviewed By: sammccall

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

16 months ago[libunwind] Removes CMake work-arounds.
Mark de Wever [Sun, 4 Jun 2023 15:41:17 +0000 (17:41 +0200)]
[libunwind] Removes CMake work-arounds.

CMake older than 3.20.0 is no longer supported.
This removes work-arounds for no longer supported versions.

Reviewed By: #libunwind, mstorsjo

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

16 months ago[flang] [stack-arrays] fix unused variable warning
Tom Eccles [Mon, 5 Jun 2023 15:35:14 +0000 (15:35 +0000)]
[flang] [stack-arrays] fix unused variable warning

16 months agoSilence C++17 extension warnings; NFC
Aaron Ballman [Mon, 5 Jun 2023 15:34:17 +0000 (11:34 -0400)]
Silence C++17 extension warnings; NFC

Amends 12728e144994efe84715f4e5dbb8c3104e9f0b5a
Addresses issues found by:
https://lab.llvm.org/buildbot/#/builders/216/builds/22308

16 months ago[NFC][DAG] Move isTruncateOf so that it can be used in foldBinOpIntoSelect.
Amaury Séchet [Mon, 5 Jun 2023 15:32:33 +0000 (15:32 +0000)]
[NFC][DAG] Move isTruncateOf so that it can be used in foldBinOpIntoSelect.

16 months agoSilence C++17 extension diagnostics in test; NFC
Aaron Ballman [Mon, 5 Jun 2023 15:31:55 +0000 (11:31 -0400)]
Silence C++17 extension diagnostics in test; NFC

Amends 12728e144994efe84715f4e5dbb8c3104e9f0b5a
Found by:
https://lab.llvm.org/buildbot/#/builders/139/builds/42135

16 months ago[LoopUnroll] Add test for SCEV invalidation issue (NFC)
Nikita Popov [Mon, 5 Jun 2023 15:25:59 +0000 (17:25 +0200)]
[LoopUnroll] Add test for SCEV invalidation issue (NFC)

Test for the issue reported at https://reviews.llvm.org/D149331#4387931.

16 months agoRevert "[LCSSA] Don't invalidate SCEV"
Nikita Popov [Mon, 5 Jun 2023 15:23:07 +0000 (17:23 +0200)]
Revert "[LCSSA] Don't invalidate SCEV"

This reverts commit 5cbb9f7a58d98ba432c6ddeefa581f6fc521315c.

Causes verifier error reported at
https://reviews.llvm.org/D149331#4387931.

16 months ago[mlir] [linalg] Update documentation for fuse_into_containing_op
Harsh Menon [Fri, 2 Jun 2023 23:18:00 +0000 (16:18 -0700)]
[mlir] [linalg] Update documentation for fuse_into_containing_op

This patch updates the docs for fuse_into_containing_op. It
updates the returned values to include the new_containing_op
and adds a brief description of the new_containing_op.

updates the docs with new changes in the
op regarding the return of the new_containing_op as well
as a brief description o

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

16 months ago[clangd] Revert to older include spelling approach.
Viktoriia Bakalova [Mon, 5 Jun 2023 15:18:17 +0000 (15:18 +0000)]
[clangd] Revert to older include spelling approach.

16 months ago[NFC][CLANG] Fix nullptr dereference issue in checkSizelessVectorShift()
Manna, Soumi [Mon, 5 Jun 2023 15:09:25 +0000 (08:09 -0700)]
[NFC][CLANG] Fix nullptr dereference issue in checkSizelessVectorShift()

This patch uses castAs instead of getAs which will assert if the type doesn't match in checkSizelessVectorShift(clang::Sema &, clang::ActionResult<clang::Expr *, true> &, clang::ActionResult<clang::Expr *, true> &, clang::SourceLocation, bool).

Reviewed By: erichkeane

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

16 months ago[C] Support _Generic expressions with a type operand
Aaron Ballman [Mon, 5 Jun 2023 15:03:14 +0000 (11:03 -0400)]
[C] Support _Generic expressions with a type operand

_Generic accepts an expression operand whose type is matched against a
list of associations. The expression operand is unevaluated, but the
type matched is the type after lvalue conversion. This conversion loses
type information, which makes it more difficult to match against
qualified or incomplete types.

This extension allows _Generic to accept a type operand instead of an
expression operand. The type operand form does not undergo any
conversions and is matched directly against the association list.

This extension is also supported in C++ as we already supported
_Generic selection expressions there.

The RFC for this extension can be found at:
https://discourse.llvm.org/t/rfc-generic-selection-expression-with-a-type-operand/70388

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

16 months agoRevert "[DAGCombine] Make sure combined nodes are added back to the worklist in topol...
JP Lehr [Mon, 5 Jun 2023 14:39:50 +0000 (10:39 -0400)]
Revert "[DAGCombine] Make sure combined nodes are added back to the worklist in topological order."

This reverts commit e69fa03ddd85812be3143d79a0359c3e8d43bd45.

This patch lead to build time outs on the AMDGPU OpenMP runtime
buildbot.

16 months ago[ConstraintElimination] Refactor `checkAndReplaceCondition` (NFC)
Antonio Frighetto [Mon, 5 Jun 2023 14:53:27 +0000 (16:53 +0200)]
[ConstraintElimination] Refactor `checkAndReplaceCondition` (NFC)

Handling `true` and `false` constant replacements is now abstracted
out into a single lambda function `ReplaceCmpWithConstant`, so as to
reduce code duplication.

16 months ago[mlir][spirv] Change numeric constant's bit-extension decision to be based on type
Md Abdullah Shahneous Bari [Mon, 5 Jun 2023 14:46:29 +0000 (10:46 -0400)]
[mlir][spirv] Change numeric constant's bit-extension decision to be based on type

Integer constants with bit width less than a word (e.g., i8, i16)
should be bit extended based on its type to be SPIR-V spec-compliant.
Previously, the decision was based on the most significant bit of the
value which ignores the signless semantics and causes problems when
interfacing with SPIR-V tools.

Dealing with numeric literals: the SPIR-V spec says, "If a numeric
type’s bit width is less than 32-bits, the value appears in the
low-order bits of the word, and the high-order bits must be 0 for
a floating-point type or integer type with Signedness of 0, or sign
extended for an integer type with a Signedness of 1 (similarly for the
remaining bits of widths larger than 32 bits but not a multiple of 32
bits)."

Therefore, signless integers (e.g., i8, i16) and unsigned integers
should be 0-extended, and signed integers (e.g., si8, si16) should be
sign-extended.

Patch By: mshahneo
Reviewed By: kuhar

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

16 months agoRevert "[LCSSA] Remove unused ScalarEvolution argument (NFC)"
Nikita Popov [Mon, 5 Jun 2023 14:41:49 +0000 (16:41 +0200)]
Revert "[LCSSA] Remove unused ScalarEvolution argument (NFC)"

This reverts commit 5362a0d859d8e96b3f7c0437b7866e17a818a4f7.

In preparation for reverting a dependent revision.

16 months ago[libc++] Use .gen.py tests for the transitive inclusion tests
Louis Dionne [Wed, 31 May 2023 20:32:06 +0000 (13:32 -0700)]
[libc++] Use .gen.py tests for the transitive inclusion tests

This finishes the transition of tests covered in generate_header_tests.py
to the new .gen.py format.

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

16 months ago[gn build] Port b77e50e6aef5
LLVM GN Syncbot [Mon, 5 Jun 2023 14:11:26 +0000 (14:11 +0000)]
[gn build] Port b77e50e6aef5

16 months ago[libc++] Implement `stop_token`
Hui [Wed, 17 May 2023 12:22:23 +0000 (13:22 +0100)]
[libc++] Implement `stop_token`

Implement stop_token
http://eel.is/c++draft/thread.stoptoken

16 months ago[AppleAccelTable][NFC] Remove `struct` keyword from member decl
Felipe de Azevedo Piovezan [Sat, 3 Jun 2023 10:37:30 +0000 (06:37 -0400)]
[AppleAccelTable][NFC] Remove `struct` keyword from member decl

This is only needed in C.

Depends on D151989

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

16 months ago[mlir][Vector] Fix a propagation bug with transfer_read
Quentin Colombet [Mon, 5 Jun 2023 12:33:52 +0000 (14:33 +0200)]
[mlir][Vector] Fix a propagation bug with transfer_read

In the vector distribute patterns, we used to move
`vector.transfer_read`s out of `vector.warp_execute_on_lane0`s
irrespectively of how they were defined.

This could create transfer_read operations that would read values from
within the warpOp's body from outside of the body.
E.g.,
```
warpop {
  %defined_in_body
  %read = transfer_read %defined_in_body
  vector.yield %read
}
```
=>
```
warpop {
  %defined_in_body
  vector.yield ...
}
// %defined_in_body is referenced outside of its scope.
%read = transfer_read %defined_in_body
```

The fix consists in checking that all the values feeding the new
`transfer_read` are defined outside of warpOp's body.

Note: We could do this check before creating any operation, but that would
mean knowing what `affine::makeComposedAffineApply` actually do. So the
current fix is a trade off of coupling the implementations of this
propagation and `makeComposedAffineApply` versus compile time.

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

16 months ago[TypePromotion] Don't treat bitcast as a Source
David Green [Mon, 5 Jun 2023 13:42:08 +0000 (14:42 +0100)]
[TypePromotion] Don't treat bitcast as a Source

This removes BitCasts from isSource in Type Promotion, as I don't believe they
need to be treated as Sources. They will usually be from floats or hoisted
constants, where constants will be handled already.

This fixes #62513, but didn't otherwise cause any differences in the tests I
ran.

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

16 months ago[GlobalISel][X86] Regenerate legalize-undef.mir
Simon Pilgrim [Mon, 5 Jun 2023 13:26:36 +0000 (14:26 +0100)]
[GlobalISel][X86] Regenerate legalize-undef.mir

16 months ago[X86] Replace X32 test check prefix with X86 + add common CHECK prefix
Simon Pilgrim [Mon, 5 Jun 2023 13:23:00 +0000 (14:23 +0100)]
[X86] Replace X32 test check prefix with X86 + add common CHECK prefix

We try to only use X32 for gnux32 triple test cases

16 months ago[X86] Replace X32 test check prefix with X86
Simon Pilgrim [Mon, 5 Jun 2023 13:21:41 +0000 (14:21 +0100)]
[X86] Replace X32 test check prefix with X86

We try to only use X32 for gnux32 triple test cases

16 months agoAdd customization group for MLIR.
Philipp Stephani [Mon, 5 Jun 2023 13:34:17 +0000 (15:34 +0200)]
Add customization group for MLIR.

Otherwise the customization options don’t appear in any group.

Reviewed By: sammccall

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

16 months ago[clang][Interp][NFC] Make a single-line comment a doc comment
Timm Bäder [Mon, 5 Jun 2023 13:27:51 +0000 (15:27 +0200)]
[clang][Interp][NFC] Make a single-line comment a doc comment

16 months ago[mlir][vector][NFC] Clean up headers
Matthias Springer [Mon, 5 Jun 2023 12:16:23 +0000 (14:16 +0200)]
[mlir][vector][NFC] Clean up headers

Certain functions were declared in `VectorOps.h` instead of `VectorTransforms.h` or `VectorRewritePatterns.h`.

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

16 months agoCheck for a ‘buffer’ type instead of ‘buffer-live’.
Philipp Stephani [Mon, 5 Jun 2023 13:09:47 +0000 (15:09 +0200)]
Check for a ‘buffer’ type instead of ‘buffer-live’.

Reviewed By: sammccall

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

16 months agoRemove 3-byte characters causing clang-tblgen to get I/O error.
Zibi Sarbinowski [Mon, 5 Jun 2023 12:56:34 +0000 (07:56 -0500)]
Remove 3-byte characters causing clang-tblgen to get I/O error.

[SystemZ} This revision fixes the following error caused by 301eb6b68f30074ee3a90e2dfbd11dfd87076323.
LLVM ERROR: IO failure on output stream: EDC5122I Input/output error.

The characters seems to be 3-byte characters which cause the failure with auto conversion from EBCDIC to ASCII.
Credit to @Kai who found this issue.

Reviewed By: abhina.sreeskantharajan

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

16 months ago[clang][Diagnostics] Split source ranges into line ranges before...
Timm Bäder [Fri, 2 Jun 2023 07:03:12 +0000 (09:03 +0200)]
[clang][Diagnostics] Split source ranges into line ranges before...

... emitting them.

This makes later code easier to understand, since we emit the code
snippets line by line anyway.
It also fixes the weird underlinig of multi-line source ranges.

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

16 months ago[clang][dataflow] Use a `PointerValue` for `value` property in optional checker.
Martin Braenne [Mon, 5 Jun 2023 11:30:39 +0000 (11:30 +0000)]
[clang][dataflow] Use a `PointerValue` for `value` property in optional checker.

The `ReferenceValue` class will be eliminated as part of the ongoing migration
to strict handling of value categories (see https://discourse.llvm.org/t/70086
for details).

Reviewed By: gribozavr2

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

16 months agoFix test bot breakage from 36f351098cd50809658493d9b2e22a795874bab0
Alexey Lapshin [Mon, 5 Jun 2023 11:34:57 +0000 (13:34 +0200)]
Fix test bot breakage from 36f351098cd50809658493d9b2e22a795874bab0

This addresses the issue found by: https://lab.llvm.org/buildbot/#/builders/168/builds/13834

16 months ago[Flang][OpenMP][MLIR] Add lowering from PFT to MLIR (FIR) for OpenMP declare target...
Andrew Gozillon [Mon, 5 Jun 2023 11:46:27 +0000 (06:46 -0500)]
[Flang][OpenMP][MLIR] Add lowering from PFT to MLIR (FIR) for OpenMP declare target directive in Flang

This patch adds PFT lowering for the OpenMP declare target directive
in Flang to the omp dialects declare target attribute, which currently
applies to function or global operations.

Reviewers: kiranchandramohan, skatrak, jsjodin

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

16 months ago[AMDGPU][AsmParser][NFC] Specify parser methods directly in operand classes.
Ivan Kosarev [Mon, 5 Jun 2023 11:58:34 +0000 (12:58 +0100)]
[AMDGPU][AsmParser][NFC] Specify parser methods directly in operand classes.

Eliminates the need for custom operand classes whose only purpose is to
define a parser method.

Part of <https://github.com/llvm/llvm-project/issues/62629>.

Reviewed By: dp

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

16 months ago[clang-tidy] Move the misc system header dir to Inputs subdir, NFC.
Haojian Wu [Mon, 5 Jun 2023 11:52:15 +0000 (13:52 +0200)]
[clang-tidy] Move the misc system header dir to Inputs subdir, NFC.

Follows the existing patterns, and makes life easier for bazel build
system.

16 months ago[AMDGPU][AsmParser][NFC] Immediate operand classes to derive from custom operands.
Ivan Kosarev [Mon, 5 Jun 2023 11:40:39 +0000 (12:40 +0100)]
[AMDGPU][AsmParser][NFC] Immediate operand classes to derive from custom operands.

Removes unnecessary duplication in TableGen definitions.

Part of <https://github.com/llvm/llvm-project/issues/62629>.

Reviewed By: dp

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

16 months ago[clang][Interp][NFC] Make Src parameter for move functions const
Timm Bäder [Mon, 5 Jun 2023 09:55:46 +0000 (11:55 +0200)]
[clang][Interp][NFC] Make Src parameter for move functions const

16 months agofix failures caused by https://reviews.llvm.org/D146737
Mateja Marjanovic [Mon, 5 Jun 2023 11:09:38 +0000 (13:09 +0200)]
fix failures caused by https://reviews.llvm.org/D146737

buildbot: https://lab.llvm.org/buildbot/#/builders/77/builds/27340

16 months ago[DAGCombine] Make sure combined nodes are added back to the worklist in topological...
Amaury Séchet [Sat, 30 Apr 2022 23:45:28 +0000 (23:45 +0000)]
[DAGCombine] Make sure combined nodes are added back to the worklist in topological order.

Currently, a node and its users are added back to the worklist in reverse topological order after it is combined. This diff changes that order to be topological. This is part of a larger migration to get the DAGCombiner to process nodes in topological order.

Reviewed By: RKSimon

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

16 months ago[GlobalISel][X86] Add 128/256/512-bit vector and/or/xor test coverage
Simon Pilgrim [Mon, 5 Jun 2023 11:08:12 +0000 (12:08 +0100)]
[GlobalISel][X86] Add 128/256/512-bit vector and/or/xor test coverage

Based off the legalize-add-v*.mir tests