platform/upstream/llvm.git
21 months ago[X86] vec_ss_load_fold.ll - use X86 check prefix instead of X32
Simon Pilgrim [Sun, 29 Jan 2023 16:47:13 +0000 (16:47 +0000)]
[X86] vec_ss_load_fold.ll - use X86 check prefix instead of X32

We try to use X32 for tests on gnux32 triples

21 months ago[flang] If it's got an argument keyword, it can't become an array reference
Peter Klausler [Tue, 10 Jan 2023 21:26:39 +0000 (13:26 -0800)]
[flang] If it's got an argument keyword, it can't become an array reference

Array references like A(1) are commonly misparsed as function references,
since the parser has almost no semantic context, and the parse tree is
fixed up later by semantics once it can be disambiguated.  In a case
like A(I=1), however, the presence of an argument keyword must prevent
conversion into an array reference.  (It might still also be a structure
constructor.)

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

21 months ago[AArch64] Add A+B+1 and A-B-1 macro fusion for Ampere1A
Philipp Tomsich [Tue, 24 Jan 2023 17:55:17 +0000 (18:55 +0100)]
[AArch64] Add A+B+1 and A-B-1 macro fusion for Ampere1A

The Ampere1A core supports a new fusion pattern that optimises the
case of A+B+1 and A-B-1.  Add support.

Depends on D142396

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

21 months ago[InstSimplify] !(X && Y) || X --> true (for poison-safe logical ops)
Sanjay Patel [Sun, 29 Jan 2023 15:24:52 +0000 (10:24 -0500)]
[InstSimplify] !(X && Y) || X --> true (for poison-safe logical ops)

https://alive2.llvm.org/ce/z/xuvL46

This is the similar to the existing folds added with:
D138853 / f2973327496fc966c4e89597
7dbeb127eaf6
...but with the and/or swapped.

21 months ago[InstSimplify] add tests for poison-safe logical nand+or; NFC
Sanjay Patel [Sun, 29 Jan 2023 14:43:14 +0000 (09:43 -0500)]
[InstSimplify] add tests for poison-safe logical nand+or; NFC

21 months ago[Support] TypeName.h - add missing closing namespace comment. NFC.
Simon Pilgrim [Sun, 29 Jan 2023 14:37:47 +0000 (14:37 +0000)]
[Support] TypeName.h - add missing closing namespace comment. NFC.

Fixes clang-tidy warning

21 months ago[X86] avx2-conversions.ll - use X86 check prefix instead of X32 + add common CHECK...
Simon Pilgrim [Sun, 29 Jan 2023 14:30:35 +0000 (14:30 +0000)]
[X86] avx2-conversions.ll - use X86 check prefix instead of X32 + add common CHECK check-prefix

We try to use X32 for tests on gnux32 triples

21 months ago[X86] wide-scalar-shift-legalization.ll - use X86 check prefix instead of X32
Simon Pilgrim [Sun, 29 Jan 2023 14:24:45 +0000 (14:24 +0000)]
[X86] wide-scalar-shift-legalization.ll - use X86 check prefix instead of X32

We try to use X32 for tests on gnux32 triples

21 months ago[X86] wide-scalar-shift-by-byte-multiple-legalization.ll - use X86 check prefix inste...
Simon Pilgrim [Sun, 29 Jan 2023 14:24:28 +0000 (14:24 +0000)]
[X86] wide-scalar-shift-by-byte-multiple-legalization.ll - use X86 check prefix instead of X32

We try to use X32 for tests on gnux32 triples

21 months ago[X86] matchShuffleAsBlend - keep per-lane blend masks 'whole' if only one input is...
Simon Pilgrim [Sun, 29 Jan 2023 13:13:33 +0000 (13:13 +0000)]
[X86] matchShuffleAsBlend - keep per-lane blend masks 'whole' if only one input is used

For 32/64-bit element 256-bit X86ISD::BLENDI shuffle masks, see if each sub-lane only references (plus undefs) a single input - in which case ensure the blend mask component for that lane ONLY references that input.

This helps later subvector extraction/insertion nodes to peek through the blend node for that lane.

21 months agoGlobalISel: Include register class/bank in regbankselect debug printing
Matt Arsenault [Fri, 20 Jan 2023 17:03:56 +0000 (13:03 -0400)]
GlobalISel: Include register class/bank in regbankselect debug printing

21 months ago[mlir][gpu][spirv] Gpu min/max reductions lowering to SPIR-V
Ivan Butygin [Sat, 28 Jan 2023 15:14:07 +0000 (16:14 +0100)]
[mlir][gpu][spirv] Gpu min/max reductions lowering to SPIR-V

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

21 months ago[X86] lowerShuffleAsLanePermuteAndRepeatedMask - retain the per-lane undef elements...
Simon Pilgrim [Sun, 29 Jan 2023 11:03:41 +0000 (11:03 +0000)]
[X86] lowerShuffleAsLanePermuteAndRepeatedMask - retain the per-lane undef elements and don't just copy the repeated mask

lowerShuffleAsLanePermuteAndRepeatedMask expands a shuffle from shuffle(x,y,mask) to shuffle(shuffle(x,y,lanemask1),shuffle(x,y,lanemask2),repeatedinlanemask)

However, we weren't making use of the fact that elements of the original mask might be undef - instead of fully applying the entire repeatedinlanemask to every lane, we can simplify the mask if we never demanded that element in the original mask.

Yet another improvement addressing regressions from D127115

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

21 months ago[LLDB][RISCV] Add RVV registers enums
Emmmer [Sun, 15 Jan 2023 14:25:40 +0000 (22:25 +0800)]
[LLDB][RISCV] Add RVV registers enums

RVV stands for "RISC-V V Extension", which adds 32 vector registers, and seven unprivileged CSRs (vstart, vxsat, vxrm, vcsr, vtype, vl, vlenb) to a base scalar RISC-V ISA.

The base vector extension is intended to provide general support for data-parallel execution within the 32-bit instruction encoding space, with later vector extensions supporting richer functionality for certain domains.

Reviewed By: DavidSpickett, kito-cheng

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

21 months ago[ELF][test] Improve AVR relocation tests
Ben Shi [Sat, 7 Jan 2023 14:44:57 +0000 (22:44 +0800)]
[ELF][test] Improve AVR relocation tests

Reviewed By: aykevl, MaskRay

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

21 months ago[AVR] Fix incorrect decoding of conditional branch instructions
Ben Shi [Sat, 7 Jan 2023 07:25:38 +0000 (15:25 +0800)]
[AVR] Fix incorrect decoding of conditional branch instructions

This patch fixes the inaccurate decoding of the offset operand of
the conditional branch instructions.

Reviewed By: aykevl

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

21 months ago[llvm] Use llvm::bit_ceil (NFC)
Kazu Hirata [Sun, 29 Jan 2023 08:12:52 +0000 (00:12 -0800)]
[llvm] Use llvm::bit_ceil (NFC)

If X is nonzero, NextPowerOf2(X - 1) is equivalent to
llvm::bit_ceil(X).  In this patch, std::max guarantees that X is
nonzero.

21 months ago[RISCV] Simplify code slightly. NFC
Craig Topper [Sun, 29 Jan 2023 06:43:20 +0000 (22:43 -0800)]
[RISCV] Simplify code slightly. NFC

These two pieces of code were using a switch with a single case and
a default that always returned.

Replace with an if statement that early returns.

21 months agoRevert commit 01adf96ebc86 because it caused "Unhandled DeclRefExpr" errors.
Liming Liu [Sun, 29 Jan 2023 06:27:12 +0000 (14:27 +0800)]
Revert commit 01adf96ebc86 because it caused "Unhandled DeclRefExpr" errors.

21 months ago[RISCV] Bump Zca, Zcb, Zcd, Zcf version to 1.0.
Craig Topper [Sun, 29 Jan 2023 06:04:34 +0000 (22:04 -0800)]
[RISCV] Bump Zca, Zcb, Zcd, Zcf version to 1.0.

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

21 months ago[clang] Add the check of membership in decltype for the issue #58674
Liming Liu [Tue, 10 Jan 2023 12:28:52 +0000 (20:28 +0800)]
[clang] Add the check of membership in decltype for the issue #58674

D137531 had once fixed the issue. However, it caused a crash during compiling
llvm/unittests/IR/PatternMatch.cpp in stage-2. The reason is the predicator
isDerivedFrom does not consider independent types if the derived type is
dependent.

This patch improves D137531 by adding an option to make isDerivedFrom consider
independent types.

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

21 months ago[JITLink][MachO] Error on N_EXT symbols with illegal string-table index 0.
Lang Hames [Sat, 28 Jan 2023 05:10:03 +0000 (21:10 -0800)]
[JITLink][MachO] Error on N_EXT symbols with illegal string-table index 0.

Index 0 is reserved for anonymous symbols, which can't have the N_EXT bit
set (since N_EXT means non-local scope, and non-local scope requires a name).

21 months agoAMDGPU: Don't insert pointer bitcasts for printf lowering
Matt Arsenault [Fri, 6 Jan 2023 23:50:55 +0000 (18:50 -0500)]
AMDGPU: Don't insert pointer bitcasts for printf lowering

Cleanup leftover typed pointer handling.

21 months ago[flang][MSVC] Disable test on Windows
Peter Klausler [Sun, 29 Jan 2023 01:25:50 +0000 (17:25 -0800)]
[flang][MSVC] Disable test on Windows

A test is crashing the compiler unexpectedly when built with MSVC;
disable it with an XFAIL until it can be analyzed further.

21 months ago[flang] Diagnose invalid initializations
Peter Klausler [Tue, 10 Jan 2023 22:30:27 +0000 (14:30 -0800)]
[flang] Diagnose invalid initializations

f18 current ignores attempts to initialize (with =expr) things
that are not objects, or allows meaningless initializations of
things that have mistakenly been promoted to be objects.
Fix by refusing to promote to objects names that have any
attributes that cannot be applied to objects, and then catch
data initializations of symbols that are not objects.

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

21 months agoAttributes: Check declarations for dereferenceable bytes
Matt Arsenault [Sat, 7 Jan 2023 21:42:12 +0000 (16:42 -0500)]
Attributes: Check declarations for dereferenceable bytes

This will allow tablegen to start directly marking intrinsics as
dereferenceable in a useful way. Not sure if callsites should override
or use the max.

21 months ago[Clang] Treat `std::forward_like` as builtin
Alexander Shaposhnikov [Sun, 29 Jan 2023 00:04:51 +0000 (00:04 +0000)]
[Clang] Treat `std::forward_like` as builtin

This diff extends D123345 by adding support for std::forward_like.

Test plan: ninja check-clang check-clang-tools check-llvm

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

21 months agoUse llvm::bit_ceil (NFC)
Kazu Hirata [Sun, 29 Jan 2023 00:13:09 +0000 (16:13 -0800)]
Use llvm::bit_ceil (NFC)

Note that:

  std::has_single_bit(X) ? X : llvm::NextPowerOf2(X);

is equivalent to:

  std::bit_ceil(X)

even for input 0.

21 months ago[OpenMP][NVPTX] Added `__tgt_rtl_launch_kernel` in old CUDA plugin
Shilei Tian [Sat, 28 Jan 2023 23:56:00 +0000 (18:56 -0500)]
[OpenMP][NVPTX] Added `__tgt_rtl_launch_kernel` in old CUDA plugin

Fix #60248.

Reviewed By: jhuber6

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

21 months ago[flang] Diagnose known out-of-range subscripts in more circumstances
Peter Klausler [Tue, 10 Jan 2023 20:23:57 +0000 (12:23 -0800)]
[flang] Diagnose known out-of-range subscripts in more circumstances

Semantics can catch out-of-range subscript values already when they
appear in DATA statement objects and constant folding of name constant
array indexing; this patch fills the gap by checking known constant
subscript values in other contexts.

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

21 months ago[ADT] Fix a comment typo
Kazu Hirata [Sat, 28 Jan 2023 23:24:36 +0000 (15:24 -0800)]
[ADT] Fix a comment typo

21 months agoUse llvm::byteswap instead of ByteSwap_{16,32,64} (NFC)
Kazu Hirata [Sat, 28 Jan 2023 23:22:37 +0000 (15:22 -0800)]
Use llvm::byteswap instead of ByteSwap_{16,32,64} (NFC)

21 months ago[llvm] Use llvm::bit_width (NFC)
Kazu Hirata [Sat, 28 Jan 2023 23:04:20 +0000 (15:04 -0800)]
[llvm] Use llvm::bit_width (NFC)

21 months ago[Target] Use llvm::Log2_{32,64} (NFC)
Kazu Hirata [Sat, 28 Jan 2023 23:04:18 +0000 (15:04 -0800)]
[Target] Use llvm::Log2_{32,64} (NFC)

21 months ago[SystemZ] Use llvm::bit_floor (NFC)
Kazu Hirata [Sat, 28 Jan 2023 23:04:16 +0000 (15:04 -0800)]
[SystemZ] Use llvm::bit_floor (NFC)

21 months agoRevert "[SCCP] Support NUW/NSW inference for all overflowing binary operators."
Florian Hahn [Sat, 28 Jan 2023 21:33:28 +0000 (21:33 +0000)]
Revert "[SCCP] Support NUW/NSW inference for all overflowing binary operators."

This reverts commit 024115ab14822a97c09adcd2545c14e78b843b36.

I suspect that this may be causing some buildbot bootstrapping failures.
Revert while I investigate.

21 months agoUse llvm::count{lr}_{zero,one} (NFC)
Kazu Hirata [Sat, 28 Jan 2023 20:41:19 +0000 (12:41 -0800)]
Use llvm::count{lr}_{zero,one} (NFC)

21 months ago[MLIR][OpenMP] Add conversion support from FIR to LLVM Dialect for OMP Target Data...
Akash Banerjee [Thu, 26 Jan 2023 14:40:33 +0000 (14:40 +0000)]
[MLIR][OpenMP] Add conversion support from FIR to LLVM Dialect for OMP Target Data directives

This enables conversion of OpenMP Target Data, Enter Data and Exit Data from FIR Dialect to LLVM IR Dialect.

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

21 months ago[RISCV] Simplify predicates with llvm::countr_zero (NFC)
Kazu Hirata [Sat, 28 Jan 2023 20:14:43 +0000 (12:14 -0800)]
[RISCV] Simplify predicates with llvm::countr_zero (NFC)

It takes less code (in C++ and the host assembly) to get rid of the
trailing zeros and compare against {3,5,9} than divide the immediate
by {3,5,9} and check to see if we have a power of 2.

21 months ago[CMake] Replace clang binary if using clang-bolt target
Amir Ayupov [Sat, 28 Jan 2023 19:49:58 +0000 (11:49 -0800)]
[CMake] Replace clang binary if using clang-bolt target

Instead of creating an extra clang-bolt binary and clang++-bolt symlink,
replace the original clang binary with BOLT-optimized one.

This fixes the issue with installing optimized binary as `install-clang`
target now copies the new version.

Reviewed By: phosek

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

21 months ago[RISCV] Use llvm::Log2_64 (NFC)
Kazu Hirata [Sat, 28 Jan 2023 19:33:02 +0000 (11:33 -0800)]
[RISCV] Use llvm::Log2_64 (NFC)

21 months ago[llvm] Use llvm::Log2_64 (NFC)
Kazu Hirata [Sat, 28 Jan 2023 19:20:47 +0000 (11:20 -0800)]
[llvm] Use llvm::Log2_64 (NFC)

21 months ago[flang] Diagnose fixed form statement that begins with continuation line
Peter Klausler [Mon, 9 Jan 2023 23:53:39 +0000 (15:53 -0800)]
[flang] Diagnose fixed form statement that begins with continuation line

A fixed form continuation line should not be the first line of a statement;
emit a warning if it looks like one is so that the programmer can look
for a missing card.

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

21 months ago[flang] Warn about defined operator with too few/many dummy arguments
Peter Klausler [Mon, 9 Jan 2023 22:16:17 +0000 (14:16 -0800)]
[flang] Warn about defined operator with too few/many dummy arguments

A function in a defined operator generic interface will syntactically
have one or two arguments.  If a defined operator includes a specific
function with 0 or more than 2 dummy arguments, there's no way that it
could be invoked by way of the interface.  Emit a warning.

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

21 months ago[SCCP] Support NUW/NSW inference for all overflowing binary operators.
Florian Hahn [Sat, 28 Jan 2023 17:40:40 +0000 (17:40 +0000)]
[SCCP] Support NUW/NSW inference for all overflowing binary operators.

Extend the NUW/NSW inference logic add in 72121a20cd and cdeaf5f28c3dc
to all overflowing binary operators.

Reviewed By: nikic

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

21 months ago[flang] Enforce ENTRY dummy argument usage restriction
Peter Klausler [Thu, 5 Jan 2023 18:40:50 +0000 (10:40 -0800)]
[flang] Enforce ENTRY dummy argument usage restriction

A dummy argument that appears only in ENTRY statements may
not be used in the executable part prior to its first ENTRY
statement.

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

21 months ago[Target] Use llvm::count{l,r}_{zero,one} (NFC)
Kazu Hirata [Sat, 28 Jan 2023 17:23:07 +0000 (09:23 -0800)]
[Target] Use llvm::count{l,r}_{zero,one} (NFC)

21 months ago[libc++] Addresses LWG3754
Mark de Wever [Sat, 21 Jan 2023 12:38:39 +0000 (13:38 +0100)]
[libc++] Addresses LWG3754

  LWG3754 Class template expected synopsis contains declarations that do
  not match the detailed description

This parts of the detailed synopsis that is not copied in libc++, so
effectively there's nothing to do.

Reviewed By: #libc, philnik

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

21 months ago[llvm] Use llvm::bit_floor instead of llvm::PowerOf2Floor (NFC)
Kazu Hirata [Sat, 28 Jan 2023 17:06:31 +0000 (09:06 -0800)]
[llvm] Use llvm::bit_floor instead of llvm::PowerOf2Floor (NFC)

21 months ago[RISCV] Use std::clamp (NFC)
Kazu Hirata [Sat, 28 Jan 2023 16:49:02 +0000 (08:49 -0800)]
[RISCV] Use std::clamp (NFC)

21 months ago[LSAN] Remove -fuse-ld=lld from HWASAN config
Kirill Stoimenov [Sat, 28 Jan 2023 15:57:21 +0000 (15:57 +0000)]
[LSAN] Remove -fuse-ld=lld from HWASAN config

I needed that to make -fsanitize-hwaddress-experimental-aliasing work, but it looks like the test pass without it also. This should fix https://lab.llvm.org/buildbot/#/builders/192 failures.

Reviewed By: kstoimenov

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

21 months agoRevert "[X86][ABI] Don't preserve return regs for preserve_all/preserve_most CCs"
Hans Wennborg [Sat, 28 Jan 2023 15:38:15 +0000 (16:38 +0100)]
Revert "[X86][ABI] Don't preserve return regs for preserve_all/preserve_most CCs"

This caused Chromium to crash, see comment on the code review.

> Currently both calling conventions preserve registers that are used to
> store a return value. This causes the returned value to be lost:
>
>   define i32 @bar() {
>     %1 = call preserve_mostcc i32 @foo()
>     ret i32 %1
>   }
>
>   define preserve_mostcc i32 @foo() {
>     ret i32 2
>     ; preserve_mostcc will restore %rax,
>     ; whatever it was before the call.
>   }
>
> This contradicts the current documentation (preserve_allcc "behaves
> identical to the `C` calling conventions on how arguments and return
> values are passed") and also breaks [[clang::preserve_most]].
>
> This change makes CSRs be preserved iff they are not used to store a
> return value (e.g. %rax for scalars, {%rax:%rdx} for __int128, %xmm0
> for double). For void functions no additional registers are
> preserved, i.e. the behaviour is backward compatible with existing
> code.
>
> Differential Revision: https://reviews.llvm.org/D141020

This reverts commit 0276fa89d7a4dbe73105c9148f947716b3d8f17f.

21 months agoFix Clang sphinx build
Aaron Ballman [Sat, 28 Jan 2023 13:56:22 +0000 (08:56 -0500)]
Fix Clang sphinx build

This addresses the issue found in:
https://lab.llvm.org/buildbot/#/builders/92/builds/39306

21 months agoAMDGPU: Convert fcopysign tests to generated checks and add cases
Matt Arsenault [Fri, 27 Jan 2023 00:25:17 +0000 (20:25 -0400)]
AMDGPU: Convert fcopysign tests to generated checks and add cases

21 months agoAMDGPU: Add fneg and select test
Matt Arsenault [Tue, 13 Dec 2022 18:26:25 +0000 (13:26 -0500)]
AMDGPU: Add fneg and select test

21 months ago[Clang][RISCV] Simplify RVV intrinsic policy suffix
eopXD [Wed, 18 Jan 2023 13:50:19 +0000 (05:50 -0800)]
[Clang][RISCV] Simplify RVV intrinsic policy suffix

This patch works towards the simplification proposal [0] of Nick
Knight. After this patch, we have reduced the hierarchy of intrinsics
from two sets (non-policy and policy) into a single set, with a general
assumption that policy behavior is agnostic unless specified.

[0] https://gist.github.com/nick-knight/6cb0b74b351a25323dfb1821d3a269b9

Pull Request: riscv-non-isa/rvv-intrinsic-doc#186.

Depends on D141796.

Reviewed By: craig.topper, kito-cheng

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

21 months ago[bazel] Adjust lsp-server-support include paths for 305d71853965
Benjamin Kramer [Sat, 28 Jan 2023 10:04:57 +0000 (11:04 +0100)]
[bazel] Adjust lsp-server-support include paths for 305d71853965

21 months ago[bazel] Add a dep from target asm parsers to :TargetParser
Benjamin Kramer [Sat, 28 Jan 2023 10:01:07 +0000 (11:01 +0100)]
[bazel] Add a dep from target asm parsers to :TargetParser

This is needed for the AArch64 asm parser after 9ea00fc74c3c

21 months ago[bazel][mlir] Remove references to SubElementInterfaces.
Chenguang Wang [Sat, 28 Jan 2023 09:58:55 +0000 (10:58 +0100)]
[bazel][mlir] Remove references to SubElementInterfaces.

It was removed in D142272.

This commit is manually verified with:

  bazel test --config=generic_clang @llvm-project//mlir/unittests:ir_tests

Reviewed By: bkramer

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

21 months ago[RISCV] Use llvm::bit_floor and std::clamp (NFC)
Kazu Hirata [Sat, 28 Jan 2023 08:49:38 +0000 (00:49 -0800)]
[RISCV] Use llvm::bit_floor and std::clamp (NFC)

21 months agoUse std::optional instead of llvm::Optional (NFC)
Kazu Hirata [Sat, 28 Jan 2023 08:45:19 +0000 (00:45 -0800)]
Use std::optional instead of llvm::Optional (NFC)

21 months ago[RISCV] Refine the (mul (zext.w X), C) -> mulhu isel heuristic.
Craig Topper [Sat, 28 Jan 2023 07:41:06 +0000 (23:41 -0800)]
[RISCV] Refine the (mul (zext.w X), C) -> mulhu isel heuristic.

We try to shift both X and C left by 32 to replace the zext.w
with a SLLI and use mulhu. If C is already a simm32, this likely
makes a constant that is more expensive to materialize.

21 months ago[Docs] Fix a statement wrt instruction alignment of 0
Shivam Gupta [Sat, 28 Jan 2023 05:01:33 +0000 (10:31 +0530)]
[Docs] Fix a statement wrt instruction alignment of 0

21 months agoRecommit "Reorder (shl (add/sub (shl x, C0), y), C1) -> (add/sub (shl x, C0 + C1...
Noah Goldstein [Fri, 27 Jan 2023 23:26:41 +0000 (17:26 -0600)]
Recommit "Reorder (shl (add/sub (shl x, C0), y), C1) -> (add/sub (shl x, C0 + C1), (shl y, C1))" 2nd Try

First time caused build failure:
    https://lab.llvm.org/buildbot/#/builders/183/builds/10447
but after investigating it seems to be unrelated. The same
test/build passed later with the original commit here:
    https://lab.llvm.org/buildbot/#/builders/183/builds/10448

This is just expanding the existing pattern that exists for AND/XOR/OR
and gets a bit more parallelism in from the instruction sequence.

Alive2:
Add  - https://alive2.llvm.org/ce/z/dSmPkV
Sub1 - https://alive2.llvm.org/ce/z/6rpi5V
Sub2 - https://alive2.llvm.org/ce/z/UfYeUd

Reviewed By: spatel

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

21 months agoRecommit "Add optimizations for icmp eq/ne (mul(X, Y), 0)" 2nd Try
Noah Goldstein [Fri, 27 Jan 2023 23:26:19 +0000 (17:26 -0600)]
Recommit "Add optimizations for icmp eq/ne (mul(X, Y), 0)" 2nd Try

First time caused build failure:
    https://lab.llvm.org/buildbot/#/builders/183/builds/10447
but after investigating it seems to be unrelated. The same
test/build passed later with the original commit here:
    https://lab.llvm.org/buildbot/#/builders/183/builds/10448

1. Add checks if X and/or Y are odd. The Odd values are unnecessary to
   the icmp: isZero(Odd * N) == isZero(N)

2. If neither X nor Y is known odd, then if X * Y cannot overflow AND
   if X and/or Y is non-zero, the non-zero values are unnecessary to the
   icmp.

Reviewed By: nikic

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

21 months ago[X86] Use llvm::bit_ceil (NFC)
Kazu Hirata [Sat, 28 Jan 2023 02:33:25 +0000 (18:33 -0800)]
[X86] Use llvm::bit_ceil (NFC)

The argument is known to be nonzero, so we can safely switch to
llvm::bit_ceil.

21 months agollvm-reduce: Add REQUIRES: default_triple to test
Matt Arsenault [Sat, 28 Jan 2023 02:14:05 +0000 (22:14 -0400)]
llvm-reduce: Add REQUIRES: default_triple to test

Allegedly fixes test failure if there are no targets built.

21 months agoLoopStrengthReduce: Convert AMDGPU tests to opaque pointers
Matt Arsenault [Sat, 28 Jan 2023 02:00:25 +0000 (22:00 -0400)]
LoopStrengthReduce: Convert AMDGPU tests to opaque pointers

21 months agoAMDGPU: Support atomicrmw uinc_wrap/udec_wrap
Matt Arsenault [Thu, 3 Nov 2022 06:42:58 +0000 (23:42 -0700)]
AMDGPU: Support atomicrmw uinc_wrap/udec_wrap

For now keep the exising intrinsics working.

21 months agoFix "not all control paths return a value" introduced by D142642
Mircea Trofin [Sat, 28 Jan 2023 01:58:20 +0000 (17:58 -0800)]
Fix "not all control paths return a value" introduced by D142642

21 months agoAdded a note that "%p" is also a Lit token and needs to be escaped.
Flash Sheridan [Sat, 28 Jan 2023 01:57:59 +0000 (17:57 -0800)]
Added a note that "%p" is also a Lit token and needs to be escaped.

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

21 months agoExplain code coverage with Lit in docs/SourceBasedCodeCoverage.rst
Flash Sheridan [Sat, 28 Jan 2023 01:51:18 +0000 (17:51 -0800)]
Explain code coverage with Lit in docs/SourceBasedCodeCoverage.rst

The documentation for code coverage in clang/docs/SourceBasedCodeCoverage.rst omits a couple of crucial steps when using it with Lit.
This patch should fix that.

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

21 months ago[mlir][NFC] Move the headers for lsp-server-support to include/
River Riddle [Sat, 28 Jan 2023 00:32:36 +0000 (16:32 -0800)]
[mlir][NFC] Move the headers for lsp-server-support to include/

This makes it a bit easier to share the functionality for building
language servers, and makes the API public. No real functional
change, as the API was already intended for this anyways.

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

21 months ago[AArch64] Fix crash for expandMOVImm
zhongyunde [Sat, 28 Jan 2023 01:09:10 +0000 (09:09 +0800)]
[AArch64] Fix crash for expandMOVImm

Fix https://github.com/llvm/llvm-project/issues/59892

Reviewed By: efriedma

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

21 months ago[flang] Catch out-of-range constant arguments to CHAR/ACHAR
Peter Klausler [Tue, 3 Jan 2023 18:09:37 +0000 (10:09 -0800)]
[flang] Catch out-of-range constant arguments to CHAR/ACHAR

When folding the intrinsic functions CHAR and ACHAR, emit an
error message if the argument is out of the valid range for the
kind of the result.

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

21 months ago[gn build] Port 5b8dc7c8a552
LLVM GN Syncbot [Sat, 28 Jan 2023 01:04:03 +0000 (01:04 +0000)]
[gn build] Port 5b8dc7c8a552

21 months ago[mlgo] Introduce an "InteractiveModelRunner"
Mircea Trofin [Thu, 26 Jan 2023 15:58:17 +0000 (07:58 -0800)]
[mlgo] Introduce an "InteractiveModelRunner"

This is a model runner for ML researchers using environments like
CompilerGym. In such environments, researchers host the compiler and
want to be able to observe the problem space (features) at each decision
step of some optimization pass, at which point the compiler is stopped,
waiting for the host makes a decision and provide an advice back to
the compiler, which then continues its normal operation, and so on.

The InteractiveModelRunner supports this scenario for the feature set
exposed by the compiler at a given time. It uses 2 files - ideally FIFO
pipes - one to pass data to the host, the other to get advices back from
the host. This means this scenario is supported with no special
dependencies. The file creation and deletion is the responsibility of
the host. Hooking up this model evaluator to a MLGO-ed pass is the
responsibilty of the pass author, and subsequent patches will do so for
the current set of mlgo passes, and offer an API to easily "just opt in"
by default when mlgo-ing a new pass.

The data protocol is that of the training logger: the host sees a training
log doled out observation by observation by reading from one of the
files, and passes back its advice as a serialized tensor (i.e. tensor value
memory dump) via the other file.

There are some differences wrt the log seen during training: the
interactive model doesn't currently include the outcome (because it should be
identical to the decision, and it's also not present in the "release"
mode); and partial rewards aren't currently communicated back.

The assumption - just like with the training logger - is that the host
is co-located, thus avoiding any endianness concerns. In a distributed
environment, it is up to the hosting infrastructure to intermediate
that.

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

21 months ago[flang] Portability warnings for an ambiguous ASSOCIATED() case
Peter Klausler [Wed, 11 Jan 2023 22:31:49 +0000 (14:31 -0800)]
[flang] Portability warnings for an ambiguous ASSOCIATED() case

The standard's specification for the ASSOCIATED() intrinsic function
describes its optional second argument (TARGET=) as being required
to be a valid target for a pointer assignment statement in which the
first argument (POINTER=) was the left-hand side.  Some Fortran compilers
apparently interpret this text as a requirement that the POINTER= argument
actually be a valid left-hand side to a pointer assignment statement,
and emit an error if it is not so.  This particularly affects the
use of an explicit NULL pointer as the first argument.

Such usage is well-defined, benign, useful, and supported by at least
two other compilers, so we should continue to accept it.  This patch
adds a portability warning and some documentation.

In order to implement the portability warning in the best way, the
special checks on calls to the ASSOCIATED() intrinsic function have
been moved from intrinsic processing to Semantics/check-calls.cpp,
whence they have access to semantics' toolchest.  Special checks for
other intrinsic functions might also migrate in the future in order
to keep them all in one place.

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

21 months ago[LSAN] Disable leak_check_before_thread_started for hwasan
Kirill Stoimenov [Sat, 28 Jan 2023 00:46:12 +0000 (00:46 +0000)]
[LSAN] Disable leak_check_before_thread_started for hwasan

21 months agoRevert "Reorder (shl (add/sub (shl x, C0), y), C1) -> (add/sub (shl x, C0 + C1),...
Noah Goldstein [Sat, 28 Jan 2023 00:44:45 +0000 (18:44 -0600)]
Revert "Reorder (shl (add/sub (shl x, C0), y), C1) -> (add/sub (shl x, C0 + C1), (shl y, C1))"

This reverts commit edd80befeeb92000800ded2a6f3dcdfd672d95ea.

Caused test failures in Clangd: https://lab.llvm.org/buildbot/#/builders/183/builds/10447
reverting while investigating.

21 months agoRevert "Add optimizations for icmp eq/ne (mul(X, Y), 0)"
Noah Goldstein [Sat, 28 Jan 2023 00:44:02 +0000 (18:44 -0600)]
Revert "Add optimizations for icmp eq/ne (mul(X, Y), 0)"

This reverts commit aa250ceb3ff15d55bb506b4bc8196f143133d8b5.

Caused test failures in Clangd: https://lab.llvm.org/buildbot/#/builders/183/builds/10447
reverting while investigating.

21 months ago[RISCV] Teach computeKnownBits that vsetvli returns <= 65536.
Craig Topper [Sat, 28 Jan 2023 00:39:54 +0000 (16:39 -0800)]
[RISCV] Teach computeKnownBits that vsetvli returns <= 65536.

Resolves a FIXME. We could do even better taking into account SEW/LMUL.

21 months ago[ValueTracking] Teach computeKnownBits about riscv.vsetvli.opt and riscv.vsetvlimax...
Craig Topper [Fri, 27 Jan 2023 23:52:31 +0000 (15:52 -0800)]
[ValueTracking] Teach computeKnownBits about riscv.vsetvli.opt and riscv.vsetvlimax.opt intrinsics.

These are like the intrinsic without opt, but don't have side effects.

Add missing test cases for riscv.vsetvlimax.

21 months agollvm-reduce: Parse file from the opened buffer instead of the file
Matt Arsenault [Fri, 27 Jan 2023 21:58:20 +0000 (17:58 -0400)]
llvm-reduce: Parse file from the opened buffer instead of the file

If this wasn't bitcode this was opening a second MemoryBuffer.

21 months agollvm-reduce: Use WithColor in another place
Matt Arsenault [Fri, 27 Jan 2023 18:32:07 +0000 (14:32 -0400)]
llvm-reduce: Use WithColor in another place

Use more consistently capitalized/colorized/punctuated error messages.

21 months agollvm-reduce: Use ThreadPool feature to wait for tasks to complete
Matt Arsenault [Fri, 27 Jan 2023 20:36:42 +0000 (16:36 -0400)]
llvm-reduce: Use ThreadPool feature to wait for tasks to complete

Don't use the hackier barrier I wrote using the task queue.

21 months agollvm-reduce: Use consistent type for reducer function
Matt Arsenault [Fri, 27 Jan 2023 18:47:18 +0000 (14:47 -0400)]
llvm-reduce: Use consistent type for reducer function

21 months ago[LSAN][HWASAN] Run LSAN tests with HWASAN enabled
Kirill Stoimenov [Fri, 27 Jan 2023 23:40:39 +0000 (23:40 +0000)]
[LSAN][HWASAN] Run LSAN tests with HWASAN enabled

A lot of tests are disabled by using UNSUPPORTED. The plan is to remove UNSUPPORTED for tests that are fixed.

Reviewed By: vitalybuka

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

21 months agoManual DWARF index: don't skip over -gmodules debug info
Adrian Prantl [Fri, 27 Jan 2023 00:42:31 +0000 (16:42 -0800)]
Manual DWARF index: don't skip over -gmodules debug info

This fixes a regression introduced by
https://reviews.llvm.org/D131437. The intention of the patch was to
avoid indexing DWO skeleton units, but it also skipped over full DWARF
compile units linked via a -gmodules DW_AT_dwo_name attribute. This
patch restores the functionality and adds a test for it.

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

21 months ago[flang] Fix shared library build
Peter Klausler [Fri, 27 Jan 2023 23:51:20 +0000 (15:51 -0800)]
[flang] Fix shared library build

A recent patch introduced a dependency upon Semantics from
Evaluate; fixing immediately.

21 months ago[BOLT][DWARF] Add logging for split dwarf
Alexander Yermolovich [Fri, 27 Jan 2023 23:49:01 +0000 (15:49 -0800)]
[BOLT][DWARF] Add logging for split dwarf

Added logging when bolt is processing binary with split dwarf.

Reviewed By: rafauler

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

21 months agoReorder (shl (add/sub (shl x, C0), y), C1) -> (add/sub (shl x, C0 + C1), (shl y,...
Noah Goldstein [Fri, 27 Jan 2023 23:26:41 +0000 (17:26 -0600)]
Reorder (shl (add/sub (shl x, C0), y), C1) -> (add/sub (shl x, C0 + C1), (shl y, C1))

This is just expanding the existing pattern that exists for AND/XOR/OR
and gets a bit more parallelism in from the instruction sequence.

Alive2:
Add  - https://alive2.llvm.org/ce/z/dSmPkV
Sub1 - https://alive2.llvm.org/ce/z/6rpi5V
Sub2 - https://alive2.llvm.org/ce/z/UfYeUd

Reviewed By: spatel

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

21 months agoAdd tests for reoredering (shift (add (shift x, C0), y), C1); NFC
Noah Goldstein [Fri, 27 Jan 2023 23:26:51 +0000 (17:26 -0600)]
Add tests for reoredering (shift (add (shift x, C0), y), C1); NFC

Reviewed By: spatel

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

21 months agoAdd optimizations for icmp eq/ne (mul(X, Y), 0)
Noah Goldstein [Fri, 27 Jan 2023 23:26:19 +0000 (17:26 -0600)]
Add optimizations for icmp eq/ne (mul(X, Y), 0)

1. Add checks if X and/or Y are odd. The Odd values are unnecessary to
   the icmp: isZero(Odd * N) == isZero(N)

2. If neither X nor Y is known odd, then if X * Y cannot overflow AND
   if X and/or Y is non-zero, the non-zero values are unnecessary to the
   icmp.

Reviewed By: nikic

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

21 months agoAdd tests for binops with conditions/assume constraints
Noah Goldstein [Fri, 27 Jan 2023 23:25:57 +0000 (17:25 -0600)]
Add tests for binops with conditions/assume constraints

Reviewed By: nikic

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

21 months ago[mlir] Promote the SubElementInterfaces to a core Attribute/Type construct
River Riddle [Sat, 21 Jan 2023 05:39:13 +0000 (21:39 -0800)]
[mlir] Promote the SubElementInterfaces to a core Attribute/Type construct

This commit restructures the sub element infrastructure to be a core part
of attributes and types, instead of being relegated to an interface. This
establishes sub element walking/replacement as something "always there",
which makes it easier to rely on for correctness/etc (which various bits of
infrastructure want, such as Symbols).

Attribute/Type now have `walk` and `replace` methods directly
accessible, which provide power API for interacting with sub elements. As
part of this, a new AttrTypeWalker class is introduced that supports caching
walked attributes/types, and a friendlier API (see the simplification of symbol
walking in SymbolTable.cpp).

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

21 months ago[lldb][Test] TestVSCode_completions.py: fix expected type strings
Michael Buch [Fri, 27 Jan 2023 23:21:49 +0000 (23:21 +0000)]
[lldb][Test] TestVSCode_completions.py: fix expected type strings

Fixes build failures following https://reviews.llvm.org/D141828

21 months ago[mlir][sparse] fixed typo
Aart Bik [Fri, 27 Jan 2023 22:29:31 +0000 (14:29 -0800)]
[mlir][sparse] fixed typo

Reviewed By: bixia

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

21 months ago[flang][parser] Diagnose an invalid space
Peter Klausler [Fri, 6 Jan 2023 01:04:10 +0000 (17:04 -0800)]
[flang][parser] Diagnose an invalid space

In free form, don't silently skip over an invalid space between
an underscore and a kind parameter.

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

21 months ago[flang] Correct procedure pointer (or dummy) compatibility check
Peter Klausler [Sun, 1 Jan 2023 15:35:37 +0000 (07:35 -0800)]
[flang] Correct procedure pointer (or dummy) compatibility check

Fix a subtle bug in procedure compatibility checking with base
derived types vs. their extensions to ensure that a procedure
expecting an extended type cannot be associated with a pointer
(or dummy procedure) to a procedure expecting a base type.

  subroutine s1(base); ... subroutine s2(extended)
  procedure(s1), pointer :: p
  p => s2 ! <- must be caught as an error

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