platform/upstream/llvm.git
18 months ago[bazel] Update Bazel version to 6.1.2.
Aaron Siddhartha Mondal [Sat, 22 Apr 2023 02:54:49 +0000 (04:54 +0200)]
[bazel] Update Bazel version to 6.1.2.

Reviewed By: #bazel_build, MaskRay, akuegel, rupprecht

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

18 months agoRestore "[MemProf] Context disambiguation cloning pass [patch 2/3]"
Teresa Johnson [Fri, 21 Apr 2023 21:49:35 +0000 (14:49 -0700)]
Restore "[MemProf] Context disambiguation cloning pass [patch 2/3]"

This restores d0649a6ad8be778abf7569f502148d577f8bc6f1 (reverted in
commit 03bf59d275a16815dc5a2e3f279815554f7cd0ca), with fixes for bot
failures. Confirmed that gcc, which reproduced both failures, now
builds it fine.

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

18 months ago[libc] Do not include the RPC targets if we're not in GPU mode.
Joseph Huber [Sat, 22 Apr 2023 01:02:26 +0000 (20:02 -0500)]
[libc] Do not include the RPC targets if we're not in GPU mode.

Summary:
The RPC targets assume a GPU environment. Theoretically we can build
this in all cases, but it is unused in any other target so it shouldn't
be listed.

18 months ago[OpenMP] Additional APIs used by the MSVC compiler for loop collapse
Natalia Glagoleva [Sat, 22 Apr 2023 00:47:00 +0000 (17:47 -0700)]
[OpenMP] Additional APIs used by the MSVC compiler for loop collapse
(rectangular and non-rectangular loops)

Submitting on behalf of Natalia Glagoleva <natgla@microsoft.com>

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

18 months ago[TableGen] Early exit from ExpandHwModeBasedTypes when there are no HwModes.
Craig Topper [Sat, 22 Apr 2023 00:27:06 +0000 (17:27 -0700)]
[TableGen] Early exit from ExpandHwModeBasedTypes when there are no HwModes.

Most targets don't use HwModes. For these targets we can skip
collecting the HwModes and copying all the pattern pointers.

18 months ago[libc] [NFC] Fixed comments formatting style.
Raman Tenneti [Sat, 22 Apr 2023 00:02:04 +0000 (17:02 -0700)]
[libc] [NFC] Fixed comments formatting style.

Fixed comments formatting style.

Reviewed By: rtenneti

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

18 months ago[TableGen] Remove some unnecessary TreePatternNodePtrs. NFC
Craig Topper [Sat, 22 Apr 2023 00:09:44 +0000 (17:09 -0700)]
[TableGen] Remove some unnecessary TreePatternNodePtrs. NFC

The patterns we're referring are still owned by the PatternToMatch
object. We don't need to increment their reference count here.

18 months ago[Object] Always initialized StartOfFile in Archive::Child::Child constructor.
Jacek Caban [Fri, 21 Apr 2023 23:47:55 +0000 (23:47 +0000)]
[Object] Always initialized StartOfFile in Archive::Child::Child constructor.

Fixes uninitialized memory access revealed by https://reviews.llvm.org/D146534.

In empty archives, we use Child(nullptr,nullptr,nullptr) in Archive constructor in setFirstRegular. This copies unitialized StartOfFile to FirstRegularStartOfFile, which child_begin may use later.

Reviewed By: efriedma

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

18 months ago[FuzzMutate] Correct type cast and add unit test for FCmp
Peter Rong [Fri, 21 Apr 2023 23:35:45 +0000 (16:35 -0700)]
[FuzzMutate] Correct type cast and add unit test for FCmp

This revision fixes an incorrect type cast from Instruction to ICmpInstr, which should have been to FCmpInstr instead. It turns out that StrategiesTest.cpp was missing a test case for InstModificationIRStrategy and FCmp, which is also now implemented in this revision. After this revision, [[ https://reviews.llvm.org/D148854 | llvm-stress in D148854 ]] no longer crashes randomly.

Reviewed By: Peter

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

18 months ago[mlir][sparse] avoid slice rewriting when conditions are not met
Aart Bik [Fri, 21 Apr 2023 21:40:31 +0000 (14:40 -0700)]
[mlir][sparse] avoid slice rewriting when conditions are not met

Reviewed By: Peiming

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

18 months ago[RISCV] Pass data EEW instead of index EEW to V*Sched for indexed loads and stores
Nitin John Raj [Wed, 19 Apr 2023 23:08:55 +0000 (16:08 -0700)]
[RISCV] Pass data EEW instead of index EEW to V*Sched for indexed loads and stores

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

18 months ago[RISCV] Rename some variables to improve code clarity
Nitin John Raj [Wed, 19 Apr 2023 23:28:29 +0000 (16:28 -0700)]
[RISCV] Rename some variables to improve code clarity

18 months ago[Demangle] replace std::string_view::substr which may throw
Nick Desaulniers [Fri, 21 Apr 2023 22:51:29 +0000 (15:51 -0700)]
[Demangle] replace std::string_view::substr which may throw

llvm/Demangle copies the implementation from libcxxabi/src/demangle/.
libcxxabi/ cannot use potentially-throwing std::string_view::substr, so
change llvm/Demangle to avoid these function calls.

I ran into linkage failures stemming from the usage of
std::string_view::substr. substr does a bounds check and may throw.

Fixes: f198e0b594aa ("[StringView] remove dropFront")

Reviewed By: MaskRay

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

18 months ago[Demangle] remove unused params of microsoftDemangle
Nick Desaulniers [Fri, 21 Apr 2023 22:26:51 +0000 (15:26 -0700)]
[Demangle] remove unused params of microsoftDemangle

No call sites use these parameters, so drop them.

Reviewed By: MaskRay

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

18 months ago[CMake] Add missing find_package for LibEdit
Petr Hosek [Fri, 21 Apr 2023 22:34:11 +0000 (22:34 +0000)]
[CMake] Add missing find_package for LibEdit

After building and installing LLVM with LibEdit as a dependency, it is
necessary to find it again when LLVM is consumed by another CMake
project, otherwise CMake will report an error about a missing target.

Note that the FindLibEdit.cmake file is in the "LLVM Common CMake
Utils" directory, outside of the LLVM sub-project source directory, so
the installed LLVMConfig.cmake relies on the user having installed the
LLVM common CMake modules or make available their own Find module.

Also note that the controlling HAVE_LIBEDIT CMake variable in
LLVMConfig.cmake.in has a different naming convention compared to
other similar variables like 'LLVM_ENABLE_TERMINFO'. Refactoring this
name would involve touching additional files and should be a follow-up
commit.

Patch By: ekilmer

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

18 months ago[mlir][openacc] NFC Fix acc.databounds description incorrect bullet
Razvan Lupusoru [Fri, 21 Apr 2023 22:14:22 +0000 (15:14 -0700)]
[mlir][openacc] NFC Fix acc.databounds description incorrect bullet

A dash used in description is an automatic bullet in documentation
if it is the first character of the line. The dash used in the
particular location being fixed was intended to be a separator.
Thus move it to previous line to fix incorrect bullet-ization.

Reviewed By: clementval

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

18 months ago[mlir][linalg] Expose lowerPack and lowerUnPack utils.
Hanhan Wang [Fri, 21 Apr 2023 20:25:33 +0000 (13:25 -0700)]
[mlir][linalg] Expose lowerPack and lowerUnPack utils.

Reviewed By: qcolombet

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

18 months ago[Lint] Remove legacy pass
Arthur Eubanks [Fri, 21 Apr 2023 21:52:37 +0000 (14:52 -0700)]
[Lint] Remove legacy pass

18 months ago[libc++] Make std::allocator_arg and friends conforming in C++17
Louis Dionne [Mon, 6 Mar 2023 21:43:34 +0000 (16:43 -0500)]
[libc++] Make std::allocator_arg and friends conforming in C++17

This patch makes global tag variables like std::allocator_arg
conform to C++17 by defining them as inline constexpr variables.
This is possible without creating an ODR violation now that we don't
define strong definitions of those variables in the shared library
anymore.

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

18 months ago[Inliner] Remove -update-return-attrs flag
Arthur Eubanks [Fri, 21 Apr 2023 20:34:11 +0000 (13:34 -0700)]
[Inliner] Remove -update-return-attrs flag

This is by default on and I don't see any reason to turn it off. There's also no testing of it.

Reviewed By: nikic

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

18 months agoRevert "[MemProf] Context disambiguation cloning pass [patch 2/3]"
Teresa Johnson [Fri, 21 Apr 2023 21:37:42 +0000 (14:37 -0700)]
Revert "[MemProf] Context disambiguation cloning pass [patch 2/3]"

This reverts commit d0649a6ad8be778abf7569f502148d577f8bc6f1.

Reverting due to a number of bot failures that need investigation.

18 months ago[MemProf] Context disambiguation cloning pass [patch 2/3]
Teresa Johnson [Wed, 4 Jan 2023 04:19:57 +0000 (20:19 -0800)]
[MemProf] Context disambiguation cloning pass [patch 2/3]

Performs cloning on the CallsiteContextGraph (not on the IR or summary
index), in order to uniquely identify the allocation behavior of an
allocation call given its context. In order to do this, the graph is
recursively traversed starting from the allocation nodes, until we
identify a point where the allocation behavior is unambiguous (the edges
have a single allocation type). Nodes are then cloned as we unwind the
recursion. We try to perform the minimal amount of cloning required to
disambiguate the contexts.

The follow-on patch will contain the support for applying the cloning to
the IR.

Depends on D140908 and D145836.

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

18 months agoMake sure SelectMostRelevantFrame happens only when returning to the user.
Jim Ingham [Fri, 21 Apr 2023 20:49:01 +0000 (13:49 -0700)]
Make sure SelectMostRelevantFrame happens only when returning to the user.

This is a user facing action, it is meant to focus the user's attention on
something other than the 0th frame when you stop somewhere where that's
helpful. For instance, stopping in pthread_kill after an assert will select
the assert frame.

This is not something you want to have happen internally in lldb, both
because internally you really don't want the selected frame changing out
from under you, and because the recognizers can do arbitrary work, and that
can cause deadlocks or other unexpected behavior.

However, it's not something that the current code does
explicitly after a stop has been delivered, it's expected to happen implicitly
as part of stopping. I changing this to call SMRF explicitly after a user
stop, but that got pretty ugly quickly.

So I added a bool to control whether to run this and audited all the current
uses to determine whether we're returning to the user or not.

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

18 months ago[ELF][test] Test .glink code sequence and DT_PPC64_GLINK
Fangrui Song [Fri, 21 Apr 2023 20:46:20 +0000 (13:46 -0700)]
[ELF][test] Test .glink code sequence and DT_PPC64_GLINK

18 months ago[flang][openacc] Fix the value of lower bound, upper bound and extent
Valentin Clement [Fri, 21 Apr 2023 20:22:28 +0000 (13:22 -0700)]
[flang][openacc] Fix the value of lower bound, upper bound and extent

Update the lowering to match the intent of the newly added operation
as described here D148860.

Reviewed By: razvanlupusoru

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

18 months agoTestSTL was marked as skipped unconditionally in 2018, undo
Jason Molenda [Fri, 21 Apr 2023 20:16:50 +0000 (13:16 -0700)]
TestSTL was marked as skipped unconditionally in 2018, undo

It was avoiding a crash at the time on macOS, apparently, and
it skipped the test on all platforms.  This test passes for me
now on macOS, let's remove the skip and see how the bots go.

18 months ago[RISCV][Docs] Tweak the note about zicsr and zifencei since we now support version...
Craig Topper [Fri, 21 Apr 2023 19:40:58 +0000 (12:40 -0700)]
[RISCV][Docs] Tweak the note about zicsr and zifencei since we now support version 2.1 of the base I specification.

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

18 months ago[MLIR][Vector] Enable masked vectorizaton of contraction ops
Diego Caballero [Fri, 21 Apr 2023 18:36:47 +0000 (18:36 +0000)]
[MLIR][Vector] Enable masked vectorizaton of contraction ops

This patch enables the vectorization of contraction ops using vector
masking. Support for vectorizing contractions is already there so this
is just adding contraction ops to the list of supported ops in
`vectorizeDynamicLinalgOpPrecondition` and adding a test.

Reviewed By: hanchung, awarzynski

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

18 months ago[dataflow] Don't crash in Environment::dump when decls have weird names
Sam McCall [Fri, 21 Apr 2023 19:07:17 +0000 (21:07 +0200)]
[dataflow] Don't crash in Environment::dump when decls have weird names

18 months ago[libc] Ignore unknown CUDA versions for `libc` targeting NVPTX
Joseph Huber [Fri, 21 Apr 2023 18:26:13 +0000 (13:26 -0500)]
[libc] Ignore unknown CUDA versions for `libc` targeting NVPTX

Summary:
We generally need a CUDA toolchain to build the tests for the GPU `libc`
targeting NVPTX. However, clang will commonly emit warnings on versions
that are too new. We can ignore these in `libc` since we are manually
specifying the `+ptx` version to use whenever we compile. So we do not
need to worry about unexpected changes and we do not depend on any newer
features. So this should not be problematic.

18 months ago[libc] Bump up sm_60's CUDA feature to +ptx63
Joseph Huber [Fri, 21 Apr 2023 18:24:27 +0000 (13:24 -0500)]
[libc] Bump up sm_60's CUDA feature to +ptx63

Summary:
The sm_60 GPU is the oldest model that's supported for using the RPC
features of the `libc` GPU runtime. This also requires at least `+ptx63`
to enable use of the active mask. So, this patch sets that as the
minimum.

18 months ago[OpenMP] Enable the IDE support for the device runtime
Shilei Tian [Fri, 21 Apr 2023 18:12:57 +0000 (14:12 -0400)]
[OpenMP] Enable the IDE support for the device runtime

Currently the device runtime is built as a custom target, which will not be included
in the compile commands. Those language servers using compile commands cannot
handle device runtime correctly.

In this patch, when `CMAKE_EXPORT_COMPILE_COMMANDS` is turned on, dummy
targets that will be excluded from all will be added. Those targets will not be
built or installed if we just simply do `make` or `make install`, but their
compilation will be included in the compile commands.

Reviewed By: jhuber6

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

18 months ago[gn] Port f84ac48f1e83 (BOLT_TARGETS_TO_BUILD)
Nico Weber [Fri, 21 Apr 2023 18:07:17 +0000 (14:07 -0400)]
[gn] Port f84ac48f1e83 (BOLT_TARGETS_TO_BUILD)

18 months agoFix an issue with th_task_state_memo_stack and proxy/helper tasks
Alex Duran [Thu, 9 Mar 2023 23:46:24 +0000 (17:46 -0600)]
Fix an issue with th_task_state_memo_stack and proxy/helper tasks

When proxy or helper tasks were used in inactive parallel regions, no
memo of the th_task_state was stored in the stack, so th_task_state
became invalid. This change inserts an item in the memo stack to track
these th_task_states.

Patch by Alex Duran.

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

18 months ago[clang][deps] NFC: Refactor and comment ModuleDeps sorting
Jan Svoboda [Fri, 21 Apr 2023 17:43:07 +0000 (10:43 -0700)]
[clang][deps] NFC: Refactor and comment ModuleDeps sorting

I once again stumbled across `IndexedModuleID` and was confused by the mutable `InputIndex` field.

This patch adds comments around that piece of code and unifies/simplifies related functions.

Reviewed By: Bigcheese

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

18 months ago[RISCV] Add Tag_RISCV_arch attribute by default when using clang as an assembler.
Craig Topper [Fri, 21 Apr 2023 17:54:24 +0000 (10:54 -0700)]
[RISCV] Add Tag_RISCV_arch attribute by default when using clang as an assembler.

Can be disabled with -mno-default-build-attributes just like ARM.

Reviewed By: asb

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

18 months ago[BOLT] Remove unneeded dyncasts
Nathan Sidwell [Thu, 20 Apr 2023 22:11:54 +0000 (18:11 -0400)]
[BOLT] Remove unneeded dyncasts

These checks are unnecessary -- we've already bailed if the format was wrong.

Reviewed By: rafauler

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

18 months ago[clang] NFCI: Optimize storage and lookup of analyzer options
Jan Svoboda [Fri, 21 Apr 2023 15:58:36 +0000 (08:58 -0700)]
[clang] NFCI: Optimize storage and lookup of analyzer options

This patch moves `llvm::sort()` from `AnalyzerOptions` constructor to initialization of local static variable in `isUnknownAnalyzerConfig()`.

This avoids unnecessary work, which can speed up Clang tools that initialize lots of `CompilerInvocation`s (and therefore `AnalyzerOptions`).

Reviewed By: steakhal

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

18 months ago[DAG][AArch64] Limit preferIncOfAddToSubOfNot until after legalization if the node...
David Green [Fri, 21 Apr 2023 17:35:58 +0000 (18:35 +0100)]
[DAG][AArch64] Limit preferIncOfAddToSubOfNot until after legalization if the node has wrap flags

If the add node has wrap flags then they will be destroyed by converting to
sub/not. The flags can be useful in converting to rhadd, for example, but that
may be required late if the node types need to be legalized. This limits the
preferIncOfAddToSubOfNot fold until after legalize DAG if the node have flags
to allow more folding.

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

18 months agoRevert "[clang] trigger -Wcast-qual on functional casts"
Aaron Ballman [Fri, 21 Apr 2023 17:33:39 +0000 (13:33 -0400)]
Revert "[clang] trigger -Wcast-qual on functional casts"

This reverts commit 7c0021923503a9a5fe1ba1f0b778b5b83c42aa43.

It broke post-commit buildbots:
https://lab.llvm.org/buildbot/#/builders/37/builds/21631

18 months ago[lldb] Let Mangled decide whether a name is mangled or not
Jonas Devlieghere [Fri, 21 Apr 2023 17:06:12 +0000 (10:06 -0700)]
[lldb] Let Mangled decide whether a name is mangled or not

We have a handful of places in LLDB where we try to outsmart the logic
in Mangled to determine whether a string is mangled or not. There's at
least one place (*) where we are getting this wrong and causes a subtle
bug. The `cstring_is_mangled` is cheap enough that we should always rely
on it to determine whether a string is mangled or not.

(*) `ObjectFileMachO` assumes that a symbol that starts with a double
underscore (such as `__pthread_kill`) is mangled. That's mostly
harmless, until you use `function.name-without-args` in the frame
format. The formatter calls `Symbol::GetNameNoArguments()` which is a
wrapper around `Mangled::GetName(ePreferDemangledWithoutArguments)`. The
latter will first try using the appropriate language plugin to get the
demangled name without arguments, and if that fails, falls back to
returning the demangled name. Because we forced Mangled to treat the
symbol as a mangled name (even though it's not) there's no demangled
name. The result is that frames don't show any symbol at all.

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

18 months ago[mlir][openacc] Add descriptions for new acc data operations
Razvan Lupusoru [Thu, 20 Apr 2023 22:48:57 +0000 (15:48 -0700)]
[mlir][openacc] Add descriptions for new acc data operations

The acc.bounds operation now clarifies that it is meant to be
zero-based. I added example for both C++ and Fortran to
show the normalized representation.

I also added description for each operand in the data entry
and data exit operations.

Reviewed By: clementval

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

18 months ago[NFC][CodeGenPrepare] Match against the correct instruction when checking profitabili...
Momchil Velikov [Fri, 21 Apr 2023 16:34:54 +0000 (17:34 +0100)]
[NFC][CodeGenPrepare] Match against the correct instruction when checking profitability of folding an address

The "nested" `AddressingModeMatcher`s in
`AddressingModeMatcher::isProfitableToFoldIntoAddressingMode` are constructed
using the original memory instruction, even though they check whether the
address operand of a differrent memory instructon is foldable. The memory
instruction is used only for a dominance check (when not checking for
profitability), and using the wrong memory instruction does not change the
outcome of the test - if an address is foldable, the dominance test afects which
of the two possible ways to fold is chosen, but this result is discarded.

As an example, in

    target triple = "x86_64-linux"

    declare i1 @check(i64, i64)
    define i32 @f(i1 %cc, ptr %p, ptr %q, i64 %n) {
    entry:
      br label %loop

    loop:
      %iv = phi i64 [ %i, %C ], [ 0, %entry ]
      %offs = mul i64 %iv, 4

      %c.0 = icmp  ult i64 %iv, %n
      br i1 %c.0, label %A, label %fail

    A:
      br i1 %cc, label %B, label %C

    C:
      %u = phi i32 [0, %A], [%w, %B]
      %i = add i64 %iv, 1
      %a.0 = getelementptr i8, ptr %p, i64 %offs
      %a.1 = getelementptr i8, ptr %a.0, i64 4
      %v = load i32, ptr %a.1
      %c.1 = icmp eq i32 %v, %u
      br i1 %c.1, label %exit, label %loop

    B:
      %a.2 = getelementptr i8, ptr %p, i64 %offs
      %a.3 = getelementptr i8, ptr %a.2, i64 4
      %w = load i32, ptr %a.3
      br label %C

    exit:
      ret i32 -1

    fail:
       ret i32 0
    }

the dominance test is perfomed between `%i = ...` and `%v = ...` at the moment
we're checking whether `%a3 = ...` is foldable

Using the memory instruction, which uses the interesting address is "more
correct" and this change is needed by a future patch.

Reviewed By: mkazantsev

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

18 months ago[BOLT] Add BOLT_TARGETS_TO_BUILD
Nathan Sidwell [Thu, 20 Apr 2023 19:22:18 +0000 (15:22 -0400)]
[BOLT] Add BOLT_TARGETS_TO_BUILD

Adds BOLT_TARGETS_TO_BUILD, which defaults to the intersection of
X86;AArch64 and LLVM_TARGETS_TO_BUILD, but allows configuration to
alter that -- for instance omitting one of those two targets even if
llvm supports both.

Reviewed By: rafauler

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

18 months ago[mlir][vector] NFC: Expose castAwayContractionLeadingOneDim
Lei Zhang [Fri, 21 Apr 2023 16:41:01 +0000 (09:41 -0700)]
[mlir][vector] NFC: Expose castAwayContractionLeadingOneDim

This commit exposes the transformation behind the pattern.
It is useful for more targeted application on a specific op
for once.

Reviewed By: kuhar

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

18 months ago[RISCV] NFC tweaks in extension descriptions, sorting
Eric Gouriou [Fri, 21 Apr 2023 16:37:46 +0000 (17:37 +0100)]
[RISCV] NFC tweaks in extension descriptions, sorting

NFC changes in RISCISAInfo and RISCFeatures, and matching updates to the
MC tests.

- Drop the '.' in the parentheses section of the Zvk extension
  descriptions. This is supported by
<https://www.masterclass.com/articles/period-inside-or-outside-parentheses#>,
- Remove an extraneous space in the description of Zvt,
- Reorder the ImpliedExts.* constant literals in RISCISAInfo.cpp, as
  suggested in <https://reviews.llvm.org/D148483>.

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

18 months ago[BOLT] Robustify compile-time config check
Nathan Sidwell [Wed, 19 Apr 2023 20:07:25 +0000 (16:07 -0400)]
[BOLT] Robustify compile-time config check

The BOLT runtime is specifically hard coded for x86_64 linux or x86_64
darwin. (Using x86_64 syscalls, hardcoding syscall numbers.)

Make it very clear this is for those specific pair of systems.

Reviewed By: rafauler

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

18 months ago[SystemZ][z/OS] Make LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL available for external...
Zibi Sarbinowski [Fri, 21 Apr 2023 16:29:36 +0000 (11:29 -0500)]
[SystemZ][z/OS] Make LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL available for external unwind library.

On z/OS, we need to pass the location of unwind interface header when building cxxabi. The cmake macro `LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL` is available for this purpose but it is only used with conjunction with `LIBCXXABI_USE_LLVM_UNWINDER`. For the external unwind library we need to use LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL unconditionally whenever it is set.

Reviewed By: #libc_abi, muiez, phosek, SeanP

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

18 months ago[mlir][sparse][gpu] generate proper memcpy in/out host and device
Aart Bik [Wed, 19 Apr 2023 03:56:41 +0000 (20:56 -0700)]
[mlir][sparse][gpu] generate proper memcpy in/out host and device

The host registration is a convenient way to get CUDA kernels
running, but it may be slow and does not work for all buffer
(like global constants). This revision uses the proper alloc
copy dealloc chains for buffers, using asynchronous chains
to increase overlap. The host registration mechanism is
kept under a flag for the output, just for experimentation
purposes while this project ramps up.

Reviewed By: Peiming

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

18 months ago[SLP]Fix the cost for the extractelements, used in several nodes.
Alexey Bataev [Thu, 20 Apr 2023 14:11:48 +0000 (07:11 -0700)]
[SLP]Fix the cost for the extractelements, used in several nodes.

Currently the compiler calculates the compensation cost for the
extractelements, removed during vectorization. But if the extractelement
instruction is used in several nodes, we can calculate the compensation
for them several times.

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

18 months ago[LV][IndVars] Move test to correct directory and regenerate (NFC)
Nikita Popov [Fri, 21 Apr 2023 16:02:29 +0000 (18:02 +0200)]
[LV][IndVars] Move test to correct directory and regenerate (NFC)

For some reason, an IndVarSimplify test was in the LoopVectorize
directory.

18 months ago[gn build] Port 6c9066fe2ecc
LLVM GN Syncbot [Fri, 21 Apr 2023 15:51:37 +0000 (15:51 +0000)]
[gn build] Port 6c9066fe2ecc

18 months ago[CMake][AIX] Fixing AIX rpath
Qiongsi Wu [Fri, 21 Apr 2023 15:31:46 +0000 (11:31 -0400)]
[CMake][AIX] Fixing AIX rpath

Recent commit https://github.com/llvm/llvm-project/commit/8f833f88ab78265a8e0ebb0d1522771d67c708a9 modified the installation rpath and did not set `BUILD_WITH_INSTALL_RPATH` correctly on AIX, which led to installation failures on AIX. This patch sets `BUILD_WITH_INSTALL_RPATH` on AIX to fix the installation failures.

Reviewed By: buttaface, daltenty

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

18 months ago[Matrix] Handle integer types when distributing transposes across adds.
Florian Hahn [Fri, 21 Apr 2023 15:35:11 +0000 (16:35 +0100)]
[Matrix] Handle integer types when distributing transposes across adds.

The current code did not properly account for integer matrixes. Check
if the operands are floating point or integer matrixes and use FAdd/Add
accordingly.

This is already done for other cases, like multiplies.

Fixes #62281.

18 months agoMake diagnostics API safer to use
Adrian Prantl [Fri, 21 Apr 2023 15:20:39 +0000 (08:20 -0700)]
Make diagnostics API safer to use

I received a crash report in DiagnosticManager that was caused by a
nullptr diagnostic having been added. The API allows passing in a null
unique_ptr, but all the methods are written assuming that all pointers
a dereferencable. This patch makes it impossible to add a null
diagnostic.

rdar://107633615

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

18 months agoRecommit "[AArch64] Fix incorrect `isLegalAddressingMode`"
Momchil Velikov [Fri, 21 Apr 2023 14:27:36 +0000 (15:27 +0100)]
Recommit "[AArch64] Fix incorrect `isLegalAddressingMode`"

This patch recommits 0827e2fa3fd15b49fd2d0fc676753f11abb60cab after
reverting it in ed7ada259f665a742561b88e9e6c078e9ea85224.  Added
workround for `Targetlowering::AddrMode` no longer being an aggregate
in C++20.

`AArch64TargetLowering::isLegalAddressingMode` has a number of
defects, including accepting an addressing mode, which consists of
only an immediate operand, or not checking the offset range for an
addressing mode in the form `1*ScaledReg + Offs`.

This patch fixes the above issues.

Reviewed By: dmgreen

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

Change-Id: I41a520c13ce21da503ca45019979bfceb8b648fa

18 months ago[AArch64] Fix crash caused by performExtractVectorEltCombine on DUP nodes with float...
Zain Jaffal [Fri, 21 Apr 2023 15:20:03 +0000 (16:20 +0100)]
[AArch64] Fix crash caused by performExtractVectorEltCombine on DUP nodes with float operands.

Reviewed By: dmgreen

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

18 months ago[SLP]Fix a crash on scalarized vectors.
Alexey Bataev [Fri, 21 Apr 2023 14:44:36 +0000 (07:44 -0700)]
[SLP]Fix a crash on scalarized vectors.

Need to register in-vector for scalarized types to avoid crash in
further analysis.

18 months ago[ConstraintElim] Fix integer overflow in ConstraintSystem::negate.
Florian Hahn [Fri, 21 Apr 2023 15:09:46 +0000 (16:09 +0100)]
[ConstraintElim] Fix integer overflow in ConstraintSystem::negate.

This fixes another integer overflow that was exposed by a variant of the
test case from #62226.

18 months ago[CostModel][X86] Add i64 MUL latency/codesize/size-latency cost estimates
Simon Pilgrim [Fri, 21 Apr 2023 14:55:22 +0000 (15:55 +0100)]
[CostModel][X86] Add i64 MUL latency/codesize/size-latency cost estimates

18 months ago[CostModel][X86] Add i32 MUL latency/codesize/size-latency cost estimates
Simon Pilgrim [Fri, 21 Apr 2023 12:28:07 +0000 (13:28 +0100)]
[CostModel][X86] Add i32 MUL latency/codesize/size-latency cost estimates

18 months ago[CostModel][X86] Improve i16 and vXi16 MUL costs
Simon Pilgrim [Fri, 21 Apr 2023 09:31:24 +0000 (10:31 +0100)]
[CostModel][X86] Improve i16 and vXi16 MUL costs

Use a modified version of the D103695 script to determine more accurate throughput/latency/codesize/size-latency cost estimates

18 months ago[lldb] Update QEMU git URL in setup.sh
David Spickett [Fri, 21 Apr 2023 14:30:51 +0000 (14:30 +0000)]
[lldb] Update QEMU git URL in setup.sh

The old name was maintained for a while but now it has been changed
to gitlab.

18 months ago[tests] Add missing REQUIRES: aarch64-registered-target to llvm-lib test
Jacek Caban [Fri, 21 Apr 2023 14:27:05 +0000 (17:27 +0300)]
[tests] Add missing REQUIRES: aarch64-registered-target to llvm-lib test

Fixes Buildbot failures introduced by eb56ef3edd9f1d21e625f0158dfc4edc48bd7349 and 85a2c50ec4979b87267e4f2068f2921beb0b98f2.

Reviewed By: TWeaver

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

18 months ago[llvm-exegesis][AArch64] Only run tests on aarch64 hosts
Tom Stellard [Fri, 21 Apr 2023 14:17:49 +0000 (07:17 -0700)]
[llvm-exegesis][AArch64] Only run tests on aarch64 hosts

The add-return.s test is failing on s390x.

See also e30ce634f75c01cc8784cb0c4972c42987178c1d.

Reviewed By: courbet

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

18 months ago[SLP][NFC]Make computeExtractCost a member of ShuffleCostEstimator, NFC.
Alexey Bataev [Thu, 20 Apr 2023 18:48:44 +0000 (11:48 -0700)]
[SLP][NFC]Make computeExtractCost a member of ShuffleCostEstimator, NFC.

Moved computeExtractCost to ShuffleCostEstimator class as another step
for unifying actual codegen/cost estimation for buildvectors.

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

18 months ago[asan][test][win] Fix demangled_names test on MSVC target
Alvin Wong [Fri, 21 Apr 2023 13:46:58 +0000 (21:46 +0800)]
[asan][test][win] Fix demangled_names test on MSVC target

Fix error with b5e3d131f9ed6687cacffb67de8f54214dd8d2b3 (D147444).

18 months ago[coroutine] Salvage dbg.values in the original function as well
Felipe de Azevedo Piovezan [Wed, 19 Apr 2023 13:04:54 +0000 (09:04 -0400)]
[coroutine] Salvage dbg.values in the original function as well

D97673 implemented salvaging o dbg.value inside coroutine funclets, but
left the original function untouched. Before, only dbg.addr and dbg.decl
would get salvaged.

D121324 implemented salvaging of dbg.addr and dbg.decl in the original
function as well, but not of dbg.values.

This patch unifies salvaging in the original function and related
funclets, so that all intrinsics are salvaged in all functions. This is
particularly useful for ABIs where the original function is also
rewritten to receive the frame pointer as an argument.

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

18 months ago[SCEV] Clarify inference in isAddRecNeverPoison()
Nikita Popov [Tue, 18 Apr 2023 10:33:58 +0000 (12:33 +0200)]
[SCEV] Clarify inference in isAddRecNeverPoison()

The justification in isAddRecNeverPoison() no longer applies, as
it dates back to a time where LLVM had an unconditional forward
progress guarantee. However, we also no longer need it, because we
can exploit branch on poison UB instead.

For a single exit loop (without abnormal exits) we know that all
instructions dominating the exit will be executed, so if any of
them trigger UB on poison that means that addrec is not poison.

This is slightly stronger than the previous code, because a) we
don't need the exit to also be the latch and b) we don't need the
value to be used in the exit branch in particular, any UB-producing
instruction is fine.

I don't expect much practical impact from this change, this is
mainly to clarify the reasoning behind this logic.

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

18 months agoAvoid capping heap to stack optimization for __kmpc_alloc_shared allocations.
Doru Bercea [Thu, 20 Apr 2023 20:54:46 +0000 (16:54 -0400)]
Avoid capping heap to stack optimization for __kmpc_alloc_shared allocations.

Review: https://reviews.llvm.org/D148849

18 months ago[asan][test][win] Port more tests to not use clang-cl on MinGW
Alvin Wong [Mon, 3 Apr 2023 14:50:14 +0000 (22:50 +0800)]
[asan][test][win] Port more tests to not use clang-cl on MinGW

Depends on D147432

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

18 months ago[asan][test][win] Port trivial tests to not use clang-cl on MinGW
Alvin Wong [Mon, 3 Apr 2023 08:37:31 +0000 (16:37 +0800)]
[asan][test][win] Port trivial tests to not use clang-cl on MinGW

Use clang driver on MinGW where clang-cl is not usable. MSVC target
still uses clang-cl to minimize changes to existing test runners.

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

18 months agoRevert "[ConstantFolding] Fix crash when folding vector llvm.is.fpclass"
Jay Foad [Fri, 21 Apr 2023 12:59:13 +0000 (13:59 +0100)]
Revert "[ConstantFolding] Fix crash when folding vector llvm.is.fpclass"

This reverts commit 5fc6425fb6c77052a26cf0cf7b886449fabe1af4.

It is reported to cause other crashes that require a larger fix.

18 months ago[llvm-lib] [llvm-readobj] [llvm-cvtres] Add Support for ARM64X object files.
Jacek Caban [Fri, 21 Apr 2023 12:32:07 +0000 (15:32 +0300)]
[llvm-lib] [llvm-readobj] [llvm-cvtres] Add Support for ARM64X object files.

Similar to D125411, but for ARM64X.

ARM64X PE binaries are hybrids containing both ARM64EC and pure ARM64
variants in one file. They are usually linked by passing separate
ARM64EC and ARM64 object files to linker. Linked binaries use ARM64
machine and contain additional CHPE metadata in their load config.
CHPE metadata support is not part of this patch, I plan to send that later.

Using ARM64X as a machine type of object files themselves is somewhat
ambiguous, but such files are allowed by MSVC. It treats them as ARM64
or ARM64EC object, depending on the context. Such objects can be
produced with cvtres.exe -machine:arm64x.

Reviewed By: efriedma

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

18 months ago[llvm-nm] Print EC symbol map.
Jacek Caban [Fri, 21 Apr 2023 12:31:54 +0000 (15:31 +0300)]
[llvm-nm] Print EC symbol map.

This is useful for examining ARM64EC static libraries and allows
better llvm-lib testing. Changes to Archive class will also be
useful for LLD to support ARM64EC, where it will need to use one
map or the other, depending on linking target (or both, in case of
ARM64X, but separately as they are in different namespaces).

Reviewed By: jhenderson, efriedma

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

18 months ago[llvm-lib] Add support for ARM64EC libraries.
Jacek Caban [Fri, 21 Apr 2023 12:31:21 +0000 (15:31 +0300)]
[llvm-lib] Add support for ARM64EC libraries.

ARM64EC allows having both pure ARM64 objects and ARM64EC in the
same archive. This allows using single static library for linking
pure ARM64, pure ARM64EC or mixed modules (what MS calls ARM64X:
a single module that may be used in both modes). To achieve that,
such static libraries need two separated symbol maps. The usual map
contains only pure ARM64 symbols, while a new /<ECSYMBOLS>/ section
contains EC symbols. EC symbols map has very similar format to the
usual map, except it doesn't contain object offsets and uses offsets
from regular map instead. This is true even for pure ARM64EC static
library: it will simply have 0 symbols in the symbol map.

Reviewed By: efriedma

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

18 months ago[BasicBlockUtils][NFCI] Extract branch inverting to a separate method
Max Kazantsev [Fri, 21 Apr 2023 12:06:06 +0000 (19:06 +0700)]
[BasicBlockUtils][NFCI] Extract branch inverting to a separate method

The motivation is to make possible branch inverting code reuse.

Patch by Aleksandr Popov!

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

18 months ago[libc++] Fix likely rebase conflict that was not resolved properly
Louis Dionne [Fri, 21 Apr 2023 12:37:35 +0000 (08:37 -0400)]
[libc++] Fix likely rebase conflict that was not resolved properly

18 months ago[LoopLoadElimination] Preserve DT and LI (NFCI)
Nikita Popov [Fri, 21 Apr 2023 12:31:59 +0000 (14:31 +0200)]
[LoopLoadElimination] Preserve DT and LI (NFCI)

This pass makes control-flow changes, but only via LoopSimplify
and LoopVersioning utilities, which perserve DT and LI.

18 months agoValueTracking: Recognize >=, <= compares with 0 as is.fpclass masks
Matt Arsenault [Wed, 19 Apr 2023 22:51:11 +0000 (18:51 -0400)]
ValueTracking: Recognize >=, <= compares with 0 as is.fpclass masks

Leave DAZ handling for a future change.

18 months agoInstCombine: Add some baseline tests for recognizing fcmp as is.fpclass
Matt Arsenault [Wed, 19 Apr 2023 23:08:29 +0000 (19:08 -0400)]
InstCombine: Add some baseline tests for recognizing fcmp as is.fpclass

We should be able to recognize > 0, < 0 indicates the sign.

18 months agoRevert "Reland [Modules] Remove unnecessary check when generating name lookup table...
Ilya Biryukov [Fri, 21 Apr 2023 11:49:27 +0000 (13:49 +0200)]
Revert "Reland [Modules] Remove unnecessary check when generating name lookup table in ASTWriter"

This reverts commit 67b298f6d82e0b4bb648ac0dabe895e816a77ef1.

We got linker errors with undefined symbols during a compiler release
and tracked it down to this change. I am in the process of understanding
what is happening and getting a reproducer.

Sorry for reverting this again.

I will reopen #61065 until we fix this.

18 months ago[clang-format] Fix dropped 'else'.
Manuel Klimek [Fri, 21 Apr 2023 11:56:37 +0000 (11:56 +0000)]
[clang-format] Fix dropped 'else'.

'else' was dropped accidentally in 398cddf6acec.

Patch by Jared Grubb.

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

18 months ago[LLDB] Don't print register fields when asked for a specific format
David Spickett [Thu, 20 Apr 2023 10:07:21 +0000 (10:07 +0000)]
[LLDB] Don't print register fields when asked for a specific format

Previously if a register had fields we would always print them after the
value if the register was asked for by name.
```
(lldb) register read MDCR_EL3
MDCR_EL3 = 0x00000000
         = {
             ETBAD = 0
<...>
             RLTE = 0
           }
```
This can be quite annoying if there are a whole lot of fields but you
want to see the register in a specific format.
```
(lldb) register read MDCR_EL3 -f i
MDCR_EL3 = 0x00000000   unknown     udf    #0x0
         = {
             ETBAD = 0
<...lots of fields...>
```
Since it pushes the interesting bit far up the terminal. To solve this,
don't print fields if the user passes --format. If they're doing that
then I think it's reasonable to assume they know what they want and only
want to see that output.

This also gives users a way to silence fields, but not change the format.
By doing `register read foo -f x`. In case they are not useful or perhaps
they are trying to work around a crash.

I have customised the help text for --format for register read to explain this:
```
-f <format> ( --format <format> )
     Specify a format to be used for display. If this is set, register fields will not be dispayed.
```

Reviewed By: jasonmolenda

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

18 months ago[clang] trigger -Wcast-qual on functional casts
Jorge Pinto Sousa [Fri, 21 Apr 2023 11:45:05 +0000 (07:45 -0400)]
[clang] trigger -Wcast-qual on functional casts

-Wcast-qual does not trigger on the following code in Clang, but does
in GCC.

const auto i = 42;
using T = int*;
auto p = T(&i);

The expected behavior is that a functional cast should trigger
the warning the same as the equivalent C cast because
the meaning is the same, and nothing about the functional cast
makes it easier to recognize that a const_cast is occurring.

Fixes https://github.com/llvm/llvm-project/issues/62083
Differential Revision: https://reviews.llvm.org/D148276

18 months ago[X86][FastISel] Handle CRC32 intrinsics
Alexis Engelke [Fri, 10 Mar 2023 11:26:10 +0000 (12:26 +0100)]
[X86][FastISel] Handle CRC32 intrinsics

Some applications make heavy use of the crc32 operation (e.g., as part
of a hash function), so having a FastISel path avoids fallbacks to
SelectionDAG and improves compile times, in our case by ~1.5%.

Reviewed By: pengfei

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

18 months ago[IRCE] Support non-strict range check's predicate
Max Kazantsev [Fri, 21 Apr 2023 10:58:16 +0000 (17:58 +0700)]
[IRCE] Support non-strict range check's predicate

Patch by Aleksandr Popov!

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

18 months ago[Pipelines] Don't explicitly require ORE
Nikita Popov [Fri, 21 Apr 2023 11:15:15 +0000 (13:15 +0200)]
[Pipelines] Don't explicitly require ORE

LICM does not use ORE from the pass manager, it constructs its
own instance. As such, explicitly requiring the analysis in the
pipeline is unnecessary.

18 months ago[libc++] Use $CXX instead of 'c++' in run-buildbot
Louis Dionne [Thu, 20 Apr 2023 19:06:41 +0000 (15:06 -0400)]
[libc++] Use $CXX instead of 'c++' in run-buildbot

We don't have `c++` anymore in the Docker image, but the script does
require $CXX to be in the environment so that should always work.

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

18 months agoValueTracking: Add baseline tests for fma computeKnownFPClass
Matt Arsenault [Mon, 17 Apr 2023 18:48:50 +0000 (14:48 -0400)]
ValueTracking: Add baseline tests for fma computeKnownFPClass

18 months agoValueTracking: Add tests for fneg/fabs computeKnownFPClass
Matt Arsenault [Wed, 19 Apr 2023 13:25:00 +0000 (09:25 -0400)]
ValueTracking: Add tests for fneg/fabs computeKnownFPClass

18 months agoValueTracking: Implement computeKnownFPClass for fpext
Matt Arsenault [Mon, 10 Apr 2023 02:18:03 +0000 (22:18 -0400)]
ValueTracking: Implement computeKnownFPClass for fpext

18 months ago[Pipelines] Don't request BFI in LICM-only loop pass adaptors
Nikita Popov [Fri, 21 Apr 2023 10:55:12 +0000 (12:55 +0200)]
[Pipelines] Don't request BFI in LICM-only loop pass adaptors

LICM doesn't use BFI anymore, so requesting BFI in these loop
pass adaptors is just a waste of compile-time.

18 months ago[NewGVN] Convert tests to opaque pointers (NFC)
Nikita Popov [Fri, 21 Apr 2023 10:42:22 +0000 (12:42 +0200)]
[NewGVN] Convert tests to opaque pointers (NFC)

18 months ago[NewGVN] Regenerate test checks (NFC)
Nikita Popov [Fri, 21 Apr 2023 10:40:36 +0000 (12:40 +0200)]
[NewGVN] Regenerate test checks (NFC)

18 months ago[IRCE][NFCI] Refactor parseRangeCheckICmp
Max Kazantsev [Fri, 21 Apr 2023 10:16:59 +0000 (17:16 +0700)]
[IRCE][NFCI] Refactor parseRangeCheckICmp

Simplify parseRangeCheckICmp:
- If RHS is loop-variant, swap LHS/RHS and swap predicate
- all checks are either IV >(=) const or IV <(=) RHS (maybe not const)

Patch by Aleksandr Popov!

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

18 months ago[CodeGen] Enable AArch64 SVE FCMLA/FCADD instruction generation in ComplexDeinterleaving
Igor Kirillov [Mon, 3 Apr 2023 16:22:01 +0000 (16:22 +0000)]
[CodeGen] Enable AArch64 SVE FCMLA/FCADD instruction generation in ComplexDeinterleaving

This commit adds support for scalable vector types in theComplexDeinterleaving
pass, allowing it to recognize and handle `llvm.vector.interleave2` and
`llvm.vector.deinterleave2` intrinsics for both fixed and scalable vectors

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

18 months ago[FlattenCFG] Replace branch condition with a created one correctly
Max Kazantsev [Fri, 21 Apr 2023 09:49:18 +0000 (16:49 +0700)]
[FlattenCFG] Replace branch condition with a created one correctly

Fix case when FlattenCFGOpt combines the conditions but doesn't update
branch with a new combined condition. It happens when one of the
combinable condition is inverted and has more then 1 user

Patch by Aleksandr Popov!

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

18 months ago[FlattenCFG] Add a test to demonstrate bug
Max Kazantsev [Fri, 21 Apr 2023 09:41:51 +0000 (16:41 +0700)]
[FlattenCFG] Add a test to demonstrate bug

FlattenCFGOpt combines the conditions but doesn't update branch with a
new combined condition. It happens when one of the combinable condition
is inverted and has more then 1 user.

Patch by Aleksandr Popov!

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

18 months ago[Coverity] Fix uninitialized scalar members in TableGen
Akshay Khadse [Fri, 21 Apr 2023 09:42:04 +0000 (17:42 +0800)]
[Coverity] Fix uninitialized scalar members in TableGen

This change fixes static code analysis warnings

Reviewed By: skan

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