platform/upstream/llvm.git
19 months ago[AArch64] Regenerate test checks (NFC)
Nikita Popov [Tue, 20 Dec 2022 11:04:29 +0000 (12:04 +0100)]
[AArch64] Regenerate test checks (NFC)

19 months ago[AMDGPU][DOC][NFC] Update assembler syntax description
Dmitry Preobrazhensky [Tue, 20 Dec 2022 11:01:37 +0000 (14:01 +0300)]
[AMDGPU][DOC][NFC] Update assembler syntax description

Summary of changes:
- Enable register tuples with 9, 10, 11 and 12 registers (https://reviews.llvm.org/D138205).
- Small improvements and clarifications.
- Correct typos.

19 months ago[AArch64] Convert some tests to opaque pointers (NFC)
Nikita Popov [Tue, 20 Dec 2022 10:30:34 +0000 (11:30 +0100)]
[AArch64] Convert some tests to opaque pointers (NFC)

19 months agoRevert D139181 "[lld][Alignment][NFC] Use Align instead of log2 of alignment in Wasm...
Guillaume Chatelet [Tue, 20 Dec 2022 10:56:08 +0000 (10:56 +0000)]
Revert D139181 "[lld][Alignment][NFC] Use Align instead of log2 of alignment in Wasm Sections"

As discussed on the patch the Align type is probably not a good fit for
linkers.
This reverts commit cfe77f23d6f190d54763a7575cee95aceb9216bc.

19 months ago[llvm][cmake] Fix add_subdirectory build in multi-config
Sebastian Neubauer [Wed, 7 Dec 2022 21:17:39 +0000 (22:17 +0100)]
[llvm][cmake] Fix add_subdirectory build in multi-config

Using CMAKE_CFG_INTDIR in paths that are used in configure_file,
resulted in a folder that is literally called '${CONFIGURATION}'
for the multi-config ninja build.

I think this is a regression from a while ago. Fix this by replacing
CMAKE_CFG_INTDIR with '.'. We can only create one of the
LLVMConfig.cmake files as the consuming CMake project can only import a
single file. This creates LLVMConfig.cmake and others in the place where
they were previously and where they are for a single-config build.

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

19 months agoRevert "[clang][NFC] Clean up createDefaultOutputFile()"
Timm Bäder [Tue, 20 Dec 2022 10:46:09 +0000 (11:46 +0100)]
Revert "[clang][NFC] Clean up createDefaultOutputFile()"

This reverts commit d20101db48945e9d7a19ce3edcfd91d7e1aeadab.

Lifetime of the string is not what I thought it was it seems.

19 months ago[NFC][RISCV] Extract utility to calculate value through MajorVersion and MinorVersion
eopXD [Tue, 20 Dec 2022 10:34:52 +0000 (02:34 -0800)]
[NFC][RISCV] Extract utility to calculate value through MajorVersion and MinorVersion

Reviewed By: craig.topper

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

19 months ago[clang][NFC] Clean up createDefaultOutputFile()
Timm Bäder [Tue, 20 Dec 2022 10:19:20 +0000 (11:19 +0100)]
[clang][NFC] Clean up createDefaultOutputFile()

PathStorage is only used in one of the if branches, so doesn't need to
be a std::optional anyway.

19 months ago[Support] Move Target/CPU Printing out of CommandLine
Archibald Elliott [Tue, 13 Dec 2022 22:02:58 +0000 (22:02 +0000)]
[Support] Move Target/CPU Printing out of CommandLine

This change is rather more invasive than intended. The main intention
here is to make CommandLine.cpp not rely on llvm/Support/Host.h. Right
now, this reliance is only in 3 superficial places:
- Choosing how to expand response files (in two places)
- Printing the default triple and current CPU in `--version` output.

The built in version system has a method for adding "extra version
printers", commonly used by several tools (such as llc) to report the
registered targets in the built version of LLVM. It was reasonably easy
to move the logic for printing the default triple and current CPU into
a similar function, and register it with any relevant binaries.

The incompatible change here is that now, even if
LLVM_VERSION_PRINTER_SHOW_HOST_TARGET_INFO is defined, most binaries
will no longer print out the default target triple and cpu when provided
with `--version`, for instance llvm-as and llvm-dis. This breakage is
intended, but the changes in this patch keep printing the default target
and detected in `llc` and `opt` as these were remarked as important
binaries in the LLVM install.

The change to expanding response files may also be controversial, but I
believe that these macros should correspond exactly to the host triple
introspection used before.

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

19 months ago[include-cleaner] Respect IWYU pragmas during analyze
Kadir Cetinkaya [Tue, 20 Dec 2022 09:42:38 +0000 (10:42 +0100)]
[include-cleaner] Respect IWYU pragmas during analyze

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

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

19 months ago[RISCV] Refactor RVV Policy by structure
Piyou Chen [Tue, 20 Dec 2022 09:12:57 +0000 (01:12 -0800)]
[RISCV] Refactor RVV Policy by structure

RVV intrinsic function has several policy variants.

Include TU, TA, TAMU, TAMA, TUMU, TUMA, MU, MA, TUM, TAM

Currently, the clang side enumerates these policies, but it's hard to add a new policy.

This patch use structure to replace the origin policy enumeration, and enhance some policy transform logic.

This is a clean-up job that will not affect the RVV intrinsic functionality and make sure riscv_vector_builtin_cg.inc is the same as the original one.

Reviewed By: kito-cheng

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

19 months agoPre-commit more cases for PowerPC is_fpclass
Qiu Chaofan [Tue, 20 Dec 2022 09:10:51 +0000 (17:10 +0800)]
Pre-commit more cases for PowerPC is_fpclass

19 months ago[LICM] Allow load-only scalar promotion in the presence of aliasing loads
Nikita Popov [Thu, 1 Sep 2022 10:45:40 +0000 (12:45 +0200)]
[LICM] Allow load-only scalar promotion in the presence of aliasing loads

During scalar promotion, if there are additional potentially-aliasing
loads outside the promoted set, we can still perform a load-only
promotion. As the stores are retained, any potentially-aliasing
loads will still read the correct value.

This increases the number of load promotions in llvm-test-suite by
a factor of two:

                                |  Old |  New
    licm.NumPromotionCandidates | 4448 | 6038
    licm.NumLoadPromoted        |  479 | 1069
    licm.NumLoadStorePromoted   | 1459 | 1459

Unfortunately, this does have some impact on compile-time:
http://llvm-compile-time-tracker.com/compare.php?from=57f7f0d6cf0706a88e1ecb74f3d3e8891cceabfa&to=72b811738148aab399966a0435f13b695da1c1c8&stat=instructions
In part this is because we now have less early bailouts from
promotion, but also due to second order effects (e.g. for one case
I looked at we spend more time in SLP now).

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

19 months ago[CLANG] Fix typo in test/CodeGen/c-strings.c
Muhammad Omair Javaid [Tue, 20 Dec 2022 08:56:03 +0000 (13:56 +0500)]
[CLANG] Fix typo in test/CodeGen/c-strings.c

This patch fixes a typo in test/CodeGen/c-strings.c. Test was failing
on AArch64/Windows.

19 months agoFix an unused-variable warning in release build, NFC
Haojian Wu [Tue, 20 Dec 2022 08:38:03 +0000 (09:38 +0100)]
Fix an unused-variable warning in release build, NFC

19 months agomlir/{SPIRV,Bufferization}: use std::optional in .td files (NFC)
Ramkumar Ramachandra [Mon, 19 Dec 2022 18:50:54 +0000 (19:50 +0100)]
mlir/{SPIRV,Bufferization}: use std::optional in .td files (NFC)

This is part of an effort to migrate from llvm::Optional to
std::optional. 22426110c5ef changed the way mlir-tblgen generates .inc
files, emitting std::optional when an Optional attribute is specified in
a .td file. It also changed several .td files hard-coding llvm::Optional
to use std::optional. However, the patch excluded a few .td files in
SPIRV and Bufferization hard-coding llvm::Optional. This patch fixes
that defect, and after this patch, references to llvm::Optional in .cpp
and .h files can be replaced mechanically.

See also: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

Signed-off-by: Ramkumar Ramachandra <r@artagnon.com>
Differential Revision: https://reviews.llvm.org/D140329

19 months ago[flang] Finish substring lowering
Jean Perier [Tue, 20 Dec 2022 07:46:45 +0000 (08:46 +0100)]
[flang] Finish substring lowering

Hlfir.designate was made to support substrings but so far substrings
were not yet lowered to it. Implement support for them.

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

19 months ago[AMDGPU] Replace getPhysRegClass with getPhysRegBaseClass
Carl Ritson [Tue, 20 Dec 2022 06:47:13 +0000 (15:47 +0900)]
[AMDGPU] Replace getPhysRegClass with getPhysRegBaseClass

Accelerate finding the base class for a physical register by
building a statically mapping table from physical registers
to base classes using TableGen.

Replace uses of SIRegisterInfo::getPhysRegClass with
TargetRegisterInfo::getPhysRegBaseClass in order to use
the computed table.

Reviewed By: arsenm, foad

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

19 months ago[TableGen] Emit table mapping physical registers to base classes
Carl Ritson [Tue, 20 Dec 2022 06:21:51 +0000 (15:21 +0900)]
[TableGen] Emit table mapping physical registers to base classes

Allow targets to define a mapping from registers to register
classes such that each register has exactly one base class.
As registers may be in multiple register classes the base class
is determined by the container class with the lowest BaseClassOrder.

Only register classes with BaseClassOrder set are considered
when determining the base classes.  By default BaseClassOrder is
unset in RegisterClass so no code is generated unless a target
explicit defines one or more base register classes.

Reviewed By: arsenm, foad

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

19 months ago[UniformityAnalysis][NFC] Make checks independent of order using CHECK-DAG.
Sameer Sahasrabuddhe [Tue, 20 Dec 2022 06:05:45 +0000 (11:35 +0530)]
[UniformityAnalysis][NFC] Make checks independent of order using CHECK-DAG.

This fixes the buildbot failure on reverse iteration:
https://lab.llvm.org/buildbot/#/builders/54/builds/3034

19 months ago[RISCV] Replace i64:$r in tablegen patterns with GPR:$r. NFC
Craig Topper [Tue, 20 Dec 2022 04:52:33 +0000 (20:52 -0800)]
[RISCV] Replace i64:$r in tablegen patterns with GPR:$r. NFC

It's much more common to use a register class rather than a type.

Add an additional i64 cast to the patterns where needed to avoid
increasing isel table size.

19 months ago[RISCV] Add Predicates to the XVentanaCondOps isel patterns.
Craig Topper [Tue, 20 Dec 2022 03:28:56 +0000 (19:28 -0800)]
[RISCV] Add Predicates to the XVentanaCondOps isel patterns.

Missed this in the review of D139394. Not a functional issue because
select only makes it to isel with XVentanaCondOps.

19 months ago[RISCV] Add +xventanacondops command line to select-binop-identity.ll. NFC
Craig Topper [Tue, 20 Dec 2022 03:12:35 +0000 (19:12 -0800)]
[RISCV] Add +xventanacondops command line to select-binop-identity.ll. NFC

19 months ago[RISCV] Add zeroext attribute to i1 arguments in xventanacondops.ll. NFC
Craig Topper [Tue, 20 Dec 2022 03:09:24 +0000 (19:09 -0800)]
[RISCV] Add zeroext attribute to i1 arguments in xventanacondops.ll. NFC

Removes some extra andi instructions.

19 months ago[OpenMP] Account for dynamic shared memory in the AMDGPU nextgen plugin
Johannes Doerfert [Tue, 20 Dec 2022 03:09:07 +0000 (19:09 -0800)]
[OpenMP] Account for dynamic shared memory in the AMDGPU nextgen plugin

19 months ago[OpenMP] Improve AMDGPU Plugin
Johannes Doerfert [Sat, 17 Dec 2022 07:46:59 +0000 (23:46 -0800)]
[OpenMP] Improve AMDGPU Plugin

With this patch we:
- pick more sensible defaults for the number of teams, inspired by the
  old plugin, and configured via LIBOMPTARGET_AMDGPU_TEAMS_PER_CU.
- check the input signal of a kernel launch late, after the queue lock
  was taken, to avoid a barrier packet more often.
- copy the kernel arguments in one swoop into the appropriate memory.
- manually specialize the callbacks to avoid potential indirect calls.

19 months ago[fuchsia] Tune PrimaryGroupSizeLog to reduce fragmentation.
Luke Nicholson [Tue, 20 Dec 2022 02:33:51 +0000 (02:33 +0000)]
[fuchsia] Tune PrimaryGroupSizeLog to reduce fragmentation.

21U is the default group size, which demonstrates ~15mb reduction
in heap size for some highly fragmented heaps on Fuchsia, and
a general 5mb savings when devices are under no load.

Microbenchmarks show no performance regressions, but most of our
benchmarks perform no significant mallocs. So we are choosing the
default setting, and monitoring for potential performance
issues.

Reviewed By: Chia-hungDuan

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

19 months agoReapply "[OpenMP][FIX] Restrict more unsound assmptions about threading"
Johannes Doerfert [Sat, 17 Dec 2022 23:10:51 +0000 (15:10 -0800)]
Reapply "[OpenMP][FIX] Restrict more unsound assmptions about threading"

This reverts commit 3b052558125cbedf18c2ddb65780b50d6f437d54.

This patch got reverted due to an unrelated memory leak that has been
fixed.

19 months agoGlobalISel: Enable CSE of G_SELECT
Matt Arsenault [Mon, 21 Nov 2022 20:38:10 +0000 (15:38 -0500)]
GlobalISel: Enable CSE of G_SELECT

Stop trying to delete a select in one combine since it would
be deleting the CSE'd instruction if that happened.

19 months ago[gn build] Port 475ce4c200ca
LLVM GN Syncbot [Tue, 20 Dec 2022 01:52:50 +0000 (01:52 +0000)]
[gn build] Port 475ce4c200ca

19 months agoRFC: Uniformity Analysis for Irreducible Control Flow
Sameer Sahasrabuddhe [Tue, 20 Dec 2022 01:19:30 +0000 (06:49 +0530)]
RFC: Uniformity Analysis for Irreducible Control Flow

Uniformity analysis is a generalization of divergence analysis to
include irreducible control flow:

  1. The proposed spec presents a notion of "maximal convergence" that
     captures the existing convention of converging threads at the
     headers of natual loops.

  2. Maximal convergence is then extended to irreducible cycles. The
     identity of irreducible cycles is determined by the choices made
     in a depth-first traversal of the control flow graph. Uniformity
     analysis uses criteria that depend only on closed paths and not
     cycles, to determine maximal convergence. This makes it a
     conservative analysis that is independent of the effect of DFS on
     CycleInfo.

  3. The analysis is implemented as a template that can be
     instantiated for both LLVM IR and Machine IR.

Validation:
  - passes existing tests for divergence analysis
  - passes new tests with irreducible control flow
  - passes equivalent tests in MIR and GMIR

Based on concepts originally outlined by
Nicolai Haehnle <nicolai.haehnle@amd.com>

With contributions from Ruiling Song <ruiling.song@amd.com> and
Jay Foad <jay.foad@amd.com>.

Support for GMIR and lit tests for GMIR/MIR added by
Yashwant Singh <yashwant.singh@amd.com>.

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

19 months ago[mlir][tensor][linalg] Add a pattern that generalizes tensor.unpack op.
Hanhan Wang [Fri, 16 Dec 2022 21:03:10 +0000 (13:03 -0800)]
[mlir][tensor][linalg] Add a pattern that generalizes tensor.unpack op.

The pattern generalizes a tensor::UnPackOp into a sequence of tensor +
Linalg ops, when the outer dims are all 1s. It uses the trick of
rank-reduced tensor.extract_slice to get the tile; transpose the tile;
extract sub tile for incomplete cases if needed; use tensor.insert_slice
to insert it to the destination tensor.

Reviewed By: tyb0807, chelini

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

19 months ago[PowerPC][NFC] add explicit check for ctr loop pseudo expansion.
Chen Zheng [Mon, 19 Dec 2022 11:15:04 +0000 (06:15 -0500)]
[PowerPC][NFC] add explicit check for ctr loop pseudo expansion.

19 months ago[PowerPC] don't generate hardware loop.
Chen Zheng [Mon, 19 Dec 2022 10:58:09 +0000 (05:58 -0500)]
[PowerPC] don't generate hardware loop.

If the candidate loop already has hardware loop related intrinsics,
don't generate hardware loop on PPC. PPC does not support nested
hardware loops.

19 months ago[PowerPC][NFC] reuse a case for checking hardware loop intrinsic input
Chen Zheng [Mon, 19 Dec 2022 10:20:23 +0000 (05:20 -0500)]
[PowerPC][NFC] reuse a case for checking hardware loop intrinsic input

19 months ago[OpenMP][FIX] Ensure to inline `ompx::` functions after the rename in D140334
Johannes Doerfert [Tue, 20 Dec 2022 00:41:04 +0000 (16:41 -0800)]
[OpenMP][FIX] Ensure to inline `ompx::` functions after the rename in D140334

19 months ago[libc] Add support for standalone cross compilation of libc.
Siva Chandra Reddy [Sat, 17 Dec 2022 00:04:23 +0000 (00:04 +0000)]
[libc] Add support for standalone cross compilation of libc.

One should be able to do a cross build of the libc now. For example, using
clang on a x86_64 linux host, one can build for an aarch64 linux target by
specifying -DLIBC_TARGET_TRIPLE=aarch64-linux-gnu.

Follow up changes will add a baremetal config and also appropriate
documentation about cross compiling the libc for CPU targets.

Reviewed By: jhuber6

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

19 months ago[OpenMP] Change the nextgen plugin kernel thread count scheme as old plugins'
Ye Luo [Tue, 20 Dec 2022 00:26:38 +0000 (18:26 -0600)]
[OpenMP] Change the nextgen plugin kernel thread count scheme as old plugins'

Reviewed By: jdoerfert

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

19 months ago[gn build] Port 2916b9918275
LLVM GN Syncbot [Tue, 20 Dec 2022 00:03:21 +0000 (00:03 +0000)]
[gn build] Port 2916b9918275

19 months agoRevert "LTO: always parse modules in opaque pointer mode."
Steven Wu [Tue, 20 Dec 2022 00:02:18 +0000 (16:02 -0800)]
Revert "LTO: always parse modules in opaque pointer mode."

This reverts commit 8ba9a5218782fa4f94b5c516d513a4259992c254.

19 months ago[ADT] Alias llvm::Optional to std::optional
Benjamin Kramer [Mon, 19 Dec 2022 23:17:25 +0000 (00:17 +0100)]
[ADT] Alias llvm::Optional to std::optional

This avoids the continuous API churn when upgrading things to use
std::optional and makes trivial string replace upgrades possible.

I tested this with GCC 7.5, the oldest supported GCC I had around.

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

19 months ago[NFC] use Optional instead of separate bool
Florian Mayer [Mon, 19 Dec 2022 21:46:19 +0000 (13:46 -0800)]
[NFC] use Optional instead of separate bool

19 months ago[Clang] Prepare for llvm::Optional becoming std::optional.
Benjamin Kramer [Mon, 19 Dec 2022 23:15:11 +0000 (00:15 +0100)]
[Clang] Prepare for llvm::Optional becoming std::optional.

The needed tweaks are mostly trivial, the one nasty bit is Clang's usage
of OptionalStorage. To keep this working old Optional stays around as
clang::CustomizableOptional, with the default Storage removed.
Optional<File/DirectoryEntryRef> is replaced with a typedef.

I tested this with GCC 7.5, the oldest supported GCC I had around.

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

19 months ago[NFC] use bitwise or instead of addition
Florian Mayer [Mon, 19 Dec 2022 21:24:34 +0000 (13:24 -0800)]
[NFC] use bitwise or instead of addition

as the bits are all distinct, these two operations have the same result,
but the bitwise operation is more explicit about what's happening.

Reviewed By: hctim

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

19 months ago[SDAG] neg x with only low bit demanded is x
Philip Reames [Mon, 19 Dec 2022 23:24:45 +0000 (15:24 -0800)]
[SDAG] neg x with only low bit demanded is x

We have a version of this transform in InstCombine, but surprisingly not in SDAG.  Even more surprisingly, this benefits RISCV, but no other target. This was surprising enough I double checked my build configuration to make sure all targets were enabled; they appear to be.

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

19 months ago[ORC] Add JITDylib argument to ResourceManager notify-removing/transferring ops.
Lang Hames [Mon, 14 Nov 2022 06:12:09 +0000 (22:12 -0800)]
[ORC] Add JITDylib argument to ResourceManager notify-removing/transferring ops.

In some cases it's helpful to group trackers by JITDylib. E.g. Platform classes
may want to track initializer symbols with a `JITDylib -> Tracker -> [ Symbol ]`
map. This makes it easy to collect all symbols for the JITDylib, while still
allowing efficient removal of a single tracker. Passing the JITDylib as an
argument to ResourceManager::notifyRemovingResources and
ResourceManager::notifyTransferringResources supports such use-cases.

19 months ago[ORC] Add withResourceKeyDo method to ResourceTracker.
Lang Hames [Mon, 14 Nov 2022 00:41:04 +0000 (16:41 -0800)]
[ORC] Add withResourceKeyDo method to ResourceTracker.

This method behaves the same as MaterializationResponsibility::withResourceKeyDo
(which now forwards to the new method): It locks the session while providing
access to the ResourceKey associated with the tracker.

Adding this method to ResourceTracker allows resources to be allocated and
tracked for a given MaterializationUnit prior to that MaterializationUnit being
materialized. E.g. Platforms can now track and remove initializers and other
symbols.

19 months ago[OpenMP] Export `ompx::` symbols from the device runtime
Johannes Doerfert [Mon, 19 Dec 2022 19:25:05 +0000 (11:25 -0800)]
[OpenMP] Export `ompx::` symbols from the device runtime

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

19 months ago[OpenMP] Rename the `_OMP` namespace in the device runtime to `ompx`
Johannes Doerfert [Mon, 19 Dec 2022 18:54:15 +0000 (10:54 -0800)]
[OpenMP] Rename the `_OMP` namespace in the device runtime to `ompx`

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

19 months agoDrop unused forward declarations of llvm::Optional. NFC.
Benjamin Kramer [Mon, 19 Dec 2022 22:42:08 +0000 (23:42 +0100)]
Drop unused forward declarations of llvm::Optional. NFC.

19 months ago[mlir] Add operator!= to WalkResult, for completeness.
Benjamin Kramer [Mon, 19 Dec 2022 22:38:55 +0000 (23:38 +0100)]
[mlir] Add operator!= to WalkResult, for completeness.

19 months ago[mlir][linalg] Downscale 2D pooling with unit dimensions for height to 1D pooling
Murali Vijayaraghavan [Fri, 16 Dec 2022 04:51:01 +0000 (04:51 +0000)]
[mlir][linalg] Downscale 2D pooling with unit dimensions for height to 1D pooling

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

19 months ago[OpenMP][NFC] Cleanup clause boilerplate
Johannes Doerfert [Mon, 19 Dec 2022 07:19:48 +0000 (23:19 -0800)]
[OpenMP][NFC] Cleanup clause boilerplate

- Add helper classes to avoid duplicated boilerplate.
- Add `final` for classes inheriting from those helpers.
- Fix a `struct` vs `class` mismatch.

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

19 months ago[RISCV] Match neg (and x, 1) to two shifts to improve codesize
Philip Reames [Mon, 19 Dec 2022 21:56:01 +0000 (13:56 -0800)]
[RISCV] Match neg (and x, 1) to two shifts to improve codesize

The negate operation is never compressible (as the destination and rs1 register must differ). The two shift versions will be equal size if the input GPR is reused, or smaller if this is the only use of the input.

For clarity, the operation being performed is (select (low-bit-of x), -1, 0).

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

19 months ago[mlir] Drop Optional::value() references from tblgen files
Benjamin Kramer [Mon, 19 Dec 2022 21:38:37 +0000 (22:38 +0100)]
[mlir] Drop Optional::value() references from tblgen files

std::optional::value() has undesired exception checking semantics and is
unavailable in older Xcode (see _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS).
The call sites block std::optional migration.

19 months ago[mlir][sparse] minor merger code cleanup
Aart Bik [Mon, 19 Dec 2022 20:55:22 +0000 (12:55 -0800)]
[mlir][sparse] minor merger code cleanup

Moved larger constructor from header to CPP file.
Used toMLIRString() for DimLvlType debug.
Minor layout changes.

Reviewed By: Peiming

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

19 months agoFix gcc 7.5 build break after TypeSize ctors became constexpr
Paul Robinson [Mon, 19 Dec 2022 21:16:04 +0000 (13:16 -0800)]
Fix gcc 7.5 build break after TypeSize ctors became constexpr

As seen here: https://lab.llvm.org/staging/#/builders/235/builds/1135

19 months ago[clang] Don't spuriously pass -stdlib=libc++ to CC1 on Darwin
Louis Dionne [Tue, 13 Dec 2022 15:10:35 +0000 (10:10 -0500)]
[clang] Don't spuriously pass -stdlib=libc++ to CC1 on Darwin

Previously, we would be passing down -stdlib=libc++ from the Driver
to CC1 whenever the default standard library on the platform was libc++,
even if -stdlib= had not been passed to the Driver. This meant that we
would pass -stdlib=libc++ in nonsensical circumstances, such as when
compiling C code.

This logic had been added in b534ce46bd40 to make sure that header
search paths were set up properly. However, since libc++ is now the
default Standard Library on Darwin, passing this explicitly is not
required anymore. Indeed, if no -stdlib= is specified, CC1 will end
up using libc++ if it queries which standard library to use, without
having to be told.

Not passing -stdlib= at all to CC1 on Darwin should become possible
once CC1 stops relying on it to set up framework search paths.

Furthermore, this commit also removes a diagnostic checking whether the
deployment target is too old to support libc++. Nowadays, all supported
deployment targets use libc++ and compiling with libstdc++ is not
supported anymore. The Driver was the wrong place to issue this
diagnostic since it doesn't know whether libc++ will actually be linked
against (e.g. C vs C++), which would lead to spurious diagnostics.
Given that these targets are not supported anymore, we simply drop
the diagnostic instead of trying to refactor it into CC1.

rdar://103198514

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

19 months ago[clangd] Support type hints for `decltype(expr)`
v1nh1shungry [Mon, 19 Dec 2022 21:01:30 +0000 (16:01 -0500)]
[clangd] Support type hints for `decltype(expr)`

Reviewed By: nridge

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

19 months ago[clang][dataflow][NFC] Fix comments related to widening.
Yitzhak Mandelbaum [Mon, 19 Dec 2022 14:47:35 +0000 (14:47 +0000)]
[clang][dataflow][NFC] Fix comments related to widening.

The comments describing the API for analysis `widen` and the environment `widen`
were overly strict in the preconditions they assumed for the operation. In
particular, both assumed that the previous value preceded the current value in
the relevant ordering. However, that's not generally how widen operators work
and widening itself can violate this property. That is, when the previous value
is the result of a widening, it can easily be "greater" than the current value.

This patch updates the comments to accurately reflect the expectations.

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

19 months ago[AArch64] Add additional umull tests cases. NFC
David Green [Mon, 19 Dec 2022 21:01:01 +0000 (21:01 +0000)]
[AArch64] Add additional umull tests cases. NFC

19 months ago[NFC] fix some clang-tidy warnings for hwasan pass
Florian Mayer [Mon, 19 Dec 2022 20:56:08 +0000 (12:56 -0800)]
[NFC] fix some clang-tidy warnings for hwasan pass

19 months ago[LV] Convert some tests to use opaque pointers (NFC).
Florian Hahn [Mon, 19 Dec 2022 20:55:44 +0000 (20:55 +0000)]
[LV] Convert some tests to use opaque pointers (NFC).

19 months ago[LV] Convert some tests to use opaque pointers (NFC).
Florian Hahn [Mon, 19 Dec 2022 20:44:44 +0000 (20:44 +0000)]
[LV] Convert some tests to use opaque pointers (NFC).

19 months ago[libc] Fix full build check for the GPU build
Joseph Huber [Mon, 19 Dec 2022 20:42:01 +0000 (14:42 -0600)]
[libc] Fix full build check for the GPU build

Summary:
This condition should fire when the full build is set OFF instead of
when it is ON.

19 months ago[LV] Remove unused AAResults argument (NFC).
Florian Hahn [Mon, 19 Dec 2022 20:37:47 +0000 (20:37 +0000)]
[LV] Remove unused AAResults argument (NFC).

AAResults is passed to LoopVectorizationLegality but no longer used.
Remove the dead code.

19 months ago[mlir][AMDGPU] Make header build standalone. NFC.
Benjamin Kramer [Mon, 19 Dec 2022 20:10:19 +0000 (21:10 +0100)]
[mlir][AMDGPU] Make header build standalone. NFC.

19 months ago[ubsan] Convert tests to check 'target=...'
Paul Robinson [Mon, 19 Dec 2022 20:03:55 +0000 (12:03 -0800)]
[ubsan] Convert tests to check 'target=...'

Part of the project to eliminate special handling for triples in lit
expressions.

19 months agoReapply "[Attributor][FIX] Allow negative offsets for ranges"
Johannes Doerfert [Sat, 17 Dec 2022 21:15:43 +0000 (13:15 -0800)]
Reapply "[Attributor][FIX] Allow negative offsets for ranges"

This reverts commit d57a3443f3e2b423fd7f5402f017dc7c0dff8cdf.

This patch was never part of the memory leak problem that lead to the
revert, just an innocent bystander caught in the middle...

Also, added a second reproducer reported after the revert.

19 months ago[tsan] Convert tests to check 'target=...'
Paul Robinson [Mon, 19 Dec 2022 19:32:24 +0000 (11:32 -0800)]
[tsan] Convert tests to check 'target=...'

Part of the project to eliminate special handling for triples in lit
expressions.

19 months ago[FileCheck] Remove the last llvm::Optional
Benjamin Kramer [Mon, 19 Dec 2022 19:21:15 +0000 (20:21 +0100)]
[FileCheck] Remove the last llvm::Optional

It doesn't seem necessary and it's blocking std::optional.

19 months agoMake evaluation of nested requirement consistent with requires expr.
Utkarsh Saxena [Tue, 29 Nov 2022 13:05:53 +0000 (14:05 +0100)]
Make evaluation of nested requirement consistent with requires expr.

Fixes: https://github.com/llvm/llvm-project/issues/45563
```
template<class T>  concept True = true;

template <class T>
concept C1 = requires (T) {
   requires True<typename T::value> || True<T>;
};

template <class T>
constexpr bool foo()
requires True<typename T::value> || True<T> {
    return true;
}
static_assert(C1<double>); // Previously failed due to SFINAE error
static_assert(foo<int>()); // but this works fine.
```
The issue here is the discrepancy between how a [nested requirement is evaluated](https://github.com/llvm/llvm-project/blob/main/clang/lib/Sema/SemaTemplateInstantiate.cpp#L2331) Vs how a [non-nested requirement is evaluated](https://github.com/llvm/llvm-project/blob/main/clang/lib/Sema/SemaConcept.cpp#L167-L200).

This patch makes constraint checking consistent for nested requirement
and trailing requires expressions by reusing the same evaluator.

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

19 months agoHIP: Directly call fabs builtins
Matt Arsenault [Sun, 20 Nov 2022 22:36:02 +0000 (14:36 -0800)]
HIP: Directly call fabs builtins

All the attribute numbering changes are due to the ocml function being
assumed convergent, and the direct call is not.

This begins a series of patches to avoid using the thinnest
ocml wrappers around llvm intrinsics. These wrapper functions
aren't buying anything and add complexity. As we do not propagate
fast math flags into the library on linking, and cannot generally
safely do so, we're losing information by calling into them. Directly
call the builtins so we get the fast math flags set appropriate for the
translation unit naturally.

19 months agoRevert "[AIX][BigArchive] Treat the archive is empty if the first child member offset...
Mitch Phillips [Mon, 19 Dec 2022 19:02:14 +0000 (11:02 -0800)]
Revert "[AIX][BigArchive] Treat the archive is empty if the first child member offset is zero"

This reverts commit b26fe2a3e520a520e785dc6b4e5758b7fde6af9d.

Reason: Broke the ASan build bots. See more info in the original
phabricator review: https://reviews.llvm.org/D138986

19 months ago[sanitizer-common] Convert tests to check 'target=...'
Paul Robinson [Mon, 19 Dec 2022 19:00:50 +0000 (11:00 -0800)]
[sanitizer-common] Convert tests to check 'target=...'

Part of the project to eliminate special handling for triples in lit
expressions.

19 months ago[lit] Fix a few issues in relative_lines.py
Haojian Wu [Mon, 19 Dec 2022 14:10:49 +0000 (15:10 +0100)]
[lit] Fix a few issues in relative_lines.py

- fixes error: Line: 91  result += contents[pos:m.start(index)] TypeError: can only concatenate str (not "bytes") to str
- fixes the "-code-completion-at=%s:%(lineb'-7')" rewritten results

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

19 months agoRevert "Reland "[TargetLowering] Teach DemandedBits about VSCALE""
Saleem Abdulrasool [Mon, 19 Dec 2022 18:12:08 +0000 (18:12 +0000)]
Revert "Reland "[TargetLowering] Teach DemandedBits about VSCALE""

This reverts commit 3010f60381bcd828d1b409cfaa576328bcd05bbc.

This change introduced undefined behaviour (reported at
https://reviews.llvm.org/D138508#inline-1352840).  Additionally, it
appears to be responsible for a mis-compilation on RISCV64 with the
vector extension (https://github.com/llvm/llvm-project/issues/59594).
The commit message indicates that this is meant to be ARM64 specific
though is a generic selection change.

19 months ago[include-cleaner] Base-type usage from member exprs is implicit.
Haojian Wu [Mon, 19 Dec 2022 08:22:42 +0000 (09:22 +0100)]
[include-cleaner] Base-type usage from member exprs is implicit.

Per the discussion on https://reviews.llvm.org/D140095#inline-1352956

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

19 months agoReland "[pgo] Avoid introducing relocations by using private alias"
Paul Kirth [Fri, 9 Dec 2022 04:35:23 +0000 (04:35 +0000)]
Reland "[pgo] Avoid introducing relocations by using private alias"

In many cases, we can use an alias to avoid a symbolic relocations,
instead of using the public, interposable symbol. When the instrumented
function is in a COMDAT, we can use a hidden alias, and still avoid
references to discarded sections.

New compiler-rt tests are Linux only for now.

Previous versions of this patch allowed the compiler to name the
generated alias, but that would only be valid when the functions were
local. Since the alias may be used across TUs we use a more
deterministic naming convention, and add a `.local` suffix to the alias
name just as we do for relative vtables aliases.

Reviewed By: phosek

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

19 months ago[SPIR-V] Support memory(...) function attributes
Michal Paszkowski [Mon, 19 Dec 2022 18:36:32 +0000 (19:36 +0100)]
[SPIR-V] Support memory(...) function attributes

Adds support for memory(...) function attributes in SPIR-V function
control info lowering.

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

19 months ago[SPIR-V] Disable MachineLateInstrsCleanup pass
Michal Paszkowski [Mon, 19 Dec 2022 18:05:30 +0000 (19:05 +0100)]
[SPIR-V] Disable MachineLateInstrsCleanup pass

This patch disables MachineLateInstrsCleanup pass (since it does not
work with virtual registers) and modifies LIT tests to run with -O0.

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

19 months ago[X86] Fix SLM uops counts for WriteBitTestSetRegRMW instructions
Simon Pilgrim [Mon, 19 Dec 2022 11:23:02 +0000 (11:23 +0000)]
[X86] Fix SLM uops counts for WriteBitTestSetRegRMW instructions

The set/reset/complement RMW variants use +1uop compared to the BT read-only instructions

Based off llvm-exegesis captures, confirmed with Agner + uops.info

19 months ago[libc][gpu][NFC] Move CMake logic to prepare GPU build to a separate file.
Siva Chandra Reddy [Sat, 17 Dec 2022 17:02:00 +0000 (17:02 +0000)]
[libc][gpu][NFC] Move CMake logic to prepare GPU build to a separate file.

Reviewed By: jhuber6

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

19 months ago[RISCV] Add codegen support for RISCV XVentanaCondOps Extension
Kautuk Consul [Mon, 19 Dec 2022 17:42:24 +0000 (09:42 -0800)]
[RISCV] Add codegen support for RISCV XVentanaCondOps Extension

This patch adds codegen support for part of XVentanaCondOps extension.
This extension is designed to reduce the number of branches in
the generated RISCV assembly by replacing branches with conditional
move instructions as defined by XVentanaCondOps specification.

The specification for XVentanaCondOps extension can be found at:
https://github.com/ventanamicro/ventana-custom-extensions/releases/download/v1.0.1/ventana-custom-extensions-v1.0.1.pdf

Co-authored-by: Mikhail Gudim <mgudim@ventanamicro.com>
Differential Revision: https://reviews.llvm.org/D139394

19 months agoFix: [DebugInfo] Add function to test debug values for equivalence
Stephen Tozer [Mon, 19 Dec 2022 17:53:46 +0000 (17:53 +0000)]
Fix: [DebugInfo] Add function to test debug values for equivalence

Fixes a test in 6d169089 which had unspecified platform dependencies
and platform-dependent output.

19 months agomlir/DialectConversion: use std::optional (NFC)
Ramkumar Ramachandra [Mon, 19 Dec 2022 13:25:14 +0000 (14:25 +0100)]
mlir/DialectConversion: use std::optional (NFC)

This is part of an effort to migrate from llvm::Optional to
std::optional. This patch touches DialectConversion, and modifies
existing conversions and tests appropriately.

See also: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

Signed-off-by: Ramkumar Ramachandra <r@artagnon.com>
Differential Revision: https://reviews.llvm.org/D140303

19 months ago[profile] Convert tests to check 'target=...'
Paul Robinson [Mon, 19 Dec 2022 17:43:59 +0000 (09:43 -0800)]
[profile] Convert tests to check 'target=...'

Part of the project to eliminate special handling for triples in lit
expressions.

19 months ago[DebugInfo] Add function to test debug values for equivalence
Stephen Tozer [Mon, 19 Dec 2022 15:44:16 +0000 (15:44 +0000)]
[DebugInfo] Add function to test debug values for equivalence

This patch adds a new function that can be used to check all the
properties, other than the machine values, of a pair of debug values for
equivalence. This is done by folding the "directness" into the
expression, converting the expression to variadic form if it is not
already in that form, and then comparing directly. In a few places which
check whether two debug values are identical to see if their ranges can
be merged, this function will correctly identify cases where two debug
values are expressed differently but have the same meaning, allowing
those ranges to be correctly merged.

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

19 months agoReapply "GlobalISel: Make LLT constructors constexpr"
Matt Arsenault [Mon, 19 Dec 2022 00:29:59 +0000 (19:29 -0500)]
Reapply "GlobalISel: Make LLT constructors constexpr"

I initially attempted this in 5a95be22d248be654b992dfb25e3850dbb182a14. It
was reverted in 81cbe0ca83c2f912ff612ddb65629a108197b0d1 since it
crashed GCC 5.3. That has dropped out of the list of supported host
compilers, so try again.

19 months agoDAG: Pull fneg out of select feeding fadd into fsub
Simon Pilgrim [Thu, 15 Dec 2022 23:35:45 +0000 (18:35 -0500)]
DAG: Pull fneg out of select feeding fadd into fsub

Enables folding fadd x, (select c, (fneg a), (fneg b))
-> fsub (select a, b), c

Avoids some regressions in a future AMDGPU change.

19 months agoAMDGPU: Add regression tests for fmin/fmax legacy matching
Matt Arsenault [Thu, 15 Dec 2022 12:44:32 +0000 (07:44 -0500)]
AMDGPU: Add regression tests for fmin/fmax legacy matching

19 months ago[llvm][ADT] Fix Any with msvc and lto
Sebastian Neubauer [Mon, 19 Dec 2022 13:25:05 +0000 (14:25 +0100)]
[llvm][ADT] Fix Any with msvc and lto

llvm::Any had and has several bugs, so we eventually want to replace it
with std::any.

Unfortunately, we cannot do that right now because of bugs in the msvc
standard library that are only fixed in VS 2022 17.4.

When lto is enabled in msvc, constant symbols end up at the same
address, breaking the TypeId implementation of llvm::Any.
Make the TypeId<T>::Id non-const to fix this.

I was able to find an easy reproducer (tried in godbolt with
x64 msvc v19.32 and `/GL` as compiler flags to enable lto):

```c++

template <typename T> struct TypeId {
  // Remove the const here and below to make it work.
  static const char Id;
};

template <typename T> const char TypeId<T>::Id = 0;

template <typename A, typename B>
bool isSame() {
  return &TypeId<A>::Id == &TypeId<B>::Id;
}

class A {};
class B {};

int main() {
  // This should output "is same 0" because the addresses of A's and B's
  // TypeId::Id should be different.
  printf("is same %d\n", isSame<A, B>());
  return 0;
}
```

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

19 months ago[LAA] Convert test to opaque pointers (NFC)
Nikita Popov [Fri, 16 Dec 2022 12:00:59 +0000 (13:00 +0100)]
[LAA] Convert test to opaque pointers (NFC)

When converting this test to opaque pointers (and dropping bitcast),
we get improved memory checks. Per fhahn:

> It looks like the difference is due to the logic that determines
> pointer strides in LAA not handling bitcasts. Without the
> bitcasts, the logic now triggers successfully.

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

19 months ago[AArch64] Add alias predicate-as-counter register for PFALSE
Caroline.Concatto@arm.com [Mon, 19 Dec 2022 14:01:39 +0000 (14:01 +0000)]
[AArch64] Add alias predicate-as-counter register for PFALSE

According to:
https://developer.arm.com/documentation/ddi0602/2022-09/
PFALSE should:
"...an assembler must also accept predicate-as-counter register
name for the destination predicate register."

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

19 months agoAMDGPU: Add more fneg combine tests
Matt Arsenault [Fri, 16 Dec 2022 01:09:08 +0000 (20:09 -0500)]
AMDGPU: Add more fneg combine tests

19 months ago[clang][dataflow] Remove stray lines from `Environment::join`
Yitzhak Mandelbaum [Mon, 19 Dec 2022 14:49:03 +0000 (14:49 +0000)]
[clang][dataflow] Remove stray lines from `Environment::join`

Removes an assertion and a useless line. The assertion seems left over from
earlier debugging and the line that follows is a stray line.

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

19 months agoARM: Add baseline tests for fadd with select combine
Matt Arsenault [Fri, 16 Dec 2022 01:08:23 +0000 (20:08 -0500)]
ARM: Add baseline tests for fadd with select combine

19 months ago[clang-tidy][NFC] Replace custom isStatic matcher with the existing isStaticStorageClass
Carlos Galvez [Mon, 19 Dec 2022 15:22:47 +0000 (15:22 +0000)]
[clang-tidy][NFC] Replace custom isStatic matcher with the existing isStaticStorageClass

19 months ago[gn build] Port ca0f4e193b05
LLVM GN Syncbot [Mon, 19 Dec 2022 15:16:21 +0000 (15:16 +0000)]
[gn build] Port ca0f4e193b05

19 months ago[NFC][llvm-exegesis] Try to fix GCC7 build
Roman Lebedev [Mon, 19 Dec 2022 15:09:30 +0000 (18:09 +0300)]
[NFC][llvm-exegesis] Try to fix GCC7 build

https://lab.llvm.org/staging/#/builders/235/builds/1121