platform/upstream/llvm.git
2 years ago[flang][driver] Support parsing response files
Diana Picus [Tue, 3 May 2022 09:44:35 +0000 (09:44 +0000)]
[flang][driver] Support parsing response files

Add support for reading response files in the flang driver. Response
files contain command line arguments and are used whenever a command
becomes longer than the shell/environment limit. Response files are
recognized via the special "@path/to/response/file.rsp" syntax, which
distinguishes them from other file inputs.

This patch hardcodes GNU tokenization, since we don't have a CL mode for
the driver. In the future we might want to add a --rsp-quoting command
line option, like clang has, to accommodate Windows platforms.

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

2 years ago[SelectionDAGBuilder] Pass fast math flags to most of VP SDNodes.
Yeting Kuo [Fri, 13 May 2022 23:25:36 +0000 (07:25 +0800)]
[SelectionDAGBuilder] Pass fast math flags to most of VP SDNodes.

The patch does not pass math flags to float VPCmpIntrinsics because LLParser
could not identify float VPCmpIntrinsics as FPMathOperators.

Reviewed By: craig.topper

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

2 years ago[flang][Runtime] Use proper prototypes in Fortran_main. NFCI
Diana Picus [Mon, 16 May 2022 07:58:09 +0000 (07:58 +0000)]
[flang][Runtime] Use proper prototypes in Fortran_main. NFCI

This is compiled as C code, so it's a good idea to be explicit about the
prototype. Clang complains about this when -Wstrict-prototypes is used.

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

2 years ago[PowerPC] Treat llvm.fmuladd intrinsic as using CTR
Qiu Chaofan [Wed, 18 May 2022 07:55:02 +0000 (15:55 +0800)]
[PowerPC] Treat llvm.fmuladd intrinsic as using CTR

This fixes bug 55463, similar to D78668. This is a temporary fix since
we will switch to post-isel CTR loop determination in the future.

Reviewed By: dim, shchenz

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

2 years ago[GreedyPatternRewriter] Avoid reversing constant order
rkayaith [Wed, 18 May 2022 07:38:42 +0000 (00:38 -0700)]
[GreedyPatternRewriter] Avoid reversing constant order

The previous fix from af371f9f98da only applied when using a bottom-up
traversal. The change here applies the constant preprocessing logic to the
top-down case as well. This resolves the issue with the canonicalizer pass still
reordering constants, since it uses a top-down traversal by default.

Fixes #51892

Reviewed By: rriddle

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

2 years ago[SCEVExpander] Expand umin_seq using freeze
Nikita Popov [Wed, 11 May 2022 10:34:16 +0000 (12:34 +0200)]
[SCEVExpander] Expand umin_seq using freeze

%x umin_seq %y is currently expanded to %x == 0 ? 0 : umin(%x, %y).
This patch changes the expansion to umin(%x, freeze %y) instead
(https://alive2.llvm.org/ce/z/wujUhp).

The motivation for this change are the test cases affected by
D124910, where the freeze expansion ultimately produces better
optimization results. This is largely because
`(%x umin_seq %y) == %x` is a common expansion pattern, which
reliably optimizes in freeze representation, but only sometimes
with the zero comparison (in particular, if %x == 0 can fold to
something else, we generally won't be able to cover reasonable
code from this.)

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

2 years ago[LoopUnroll] Avoid branch on poison for runtime unroll with multiple exits
Nikita Popov [Tue, 17 May 2022 09:26:14 +0000 (11:26 +0200)]
[LoopUnroll] Avoid branch on poison for runtime unroll with multiple exits

When performing runtime unrolling with multiple exits, one of the
earlier (non-latch) exits may exit the loop on the first iteration,
such that we never branch on the latch exit condition. As such, we
need to freeze the condition of the new branch that is introduced
before the loop, as it now executes unconditionally.

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

2 years ago[llvm-nm] Always use opaque pointers (PR55506)
Nikita Popov [Tue, 17 May 2022 08:50:18 +0000 (10:50 +0200)]
[llvm-nm] Always use opaque pointers (PR55506)

Always enable opaque pointers in llvm-nm, because the tool doesn't
actually care, and this allows us to read both typed pointer and
opaque pointer bitcode files in one archive. Previously this
depended on the order inside the archive (it would work with an
opaque pointer bitcode file first, but fail with a typed pointer
bitcode file first).

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

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

2 years ago[mlir][Canonicalize] Fix command-line options
rkayaith [Wed, 18 May 2022 07:27:54 +0000 (00:27 -0700)]
[mlir][Canonicalize] Fix command-line options

The canonicalize command-line options currently have no effect, as the pass is
reading the pass options in its constructor, before they're actually
initialized. This results in the default values of the options always being used.

The change here moves the initialization of the `GreedyRewriteConfig` out of the
constructor, so that it runs after the pass options have been parsed.

Fixes #55466

Reviewed By: rriddle

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

2 years ago[mlir:PDLL] Don't append / for directory code completion
River Riddle [Wed, 18 May 2022 01:32:46 +0000 (18:32 -0700)]
[mlir:PDLL] Don't append / for directory code completion

This allows for properly using / as a trigger character, i.e.
more easily allows chaining include directory completions.

2 years ago[mlir:PDLL] Improve the location ranges of several expressions during parsing
River Riddle [Wed, 18 May 2022 00:49:28 +0000 (17:49 -0700)]
[mlir:PDLL] Improve the location ranges of several expressions during parsing

This allows for the range to encompass more of the source associated
with the full expression, making diagnostics easier to see/tooling easier/etc.

2 years ago[mlir:PDLL] Drop space as a completion commit character
River Riddle [Wed, 18 May 2022 00:57:18 +0000 (17:57 -0700)]
[mlir:PDLL] Drop space as a completion commit character

This causes annoyances when attempting to use space as
a trigger character (to start a different completion).

2 years ago[llvm-readobj] Fix printing of Windows ARM unwind opcodes, add tests
Martin Storsjö [Mon, 22 Nov 2021 22:44:58 +0000 (00:44 +0200)]
[llvm-readobj] Fix printing of Windows ARM unwind opcodes, add tests

The existing code was essentially untested; in some cases, it used
too narrow variable types to fit all the bits, in some cases the
bit manipulation operations were incorrect.

For the "ldr lr, [sp], #x" opcode, there's nothing in the documentation
that says it cannot be used in a prologue. (In practice, it would
probably seldom be used there, but technically there's nothing
stopping it from being used.) The documentation only specifies the
operation to replay for unwinding it, but the corresponding mirror
instruction to be printed for a prologue is "str lr, [sp, #-x]!".

Also improve printing of register masks, by aggregating registers
into ranges where possible, and make the printing of the terminating
branches clearer, as "bx <reg>" and "b.w <target>".

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

2 years ago[ArgPromotion] Add unused-argument.ll test (NFC)
Pavel Samolysov [Wed, 18 May 2022 07:05:13 +0000 (10:05 +0300)]
[ArgPromotion] Add unused-argument.ll test (NFC)

If a pointer argument is unused within the callee, this argument should
be removed from the function's signature while all used pointer
arguments should be promoted as it is expected. The ArgumentPromotion
pass doesn't touch unused non-pointer arguments at all.

2 years agoRevert "[clang-format] Fix WhitespaceSensitiveMacros not being honoured when macro...
Marek Kurdej [Wed, 18 May 2022 05:25:12 +0000 (07:25 +0200)]
Revert "[clang-format] Fix WhitespaceSensitiveMacros not being honoured when macro closing parenthesis is followed by a newline."

This reverts commit 50cd52d9357224cce66a9e00c9a0417c658a5655.

It provoked regressions in C++ and ObjectiveC as described in https://reviews.llvm.org/D123676#3515949.

Reproducers:
```
MACRO_BEGIN
#if A
int f();
#else
int f();
#endif
```

```
NS_SWIFT_NAME(A)
@interface B : C
@property(readonly) D value;
@end
```

2 years ago[MLIR][Presburger] Cleanup getMaybeValues in FACV
Groverkss [Wed, 18 May 2022 04:14:14 +0000 (09:44 +0530)]
[MLIR][Presburger] Cleanup getMaybeValues in FACV

This patch cleans up multiple getMaybeValue functions to take an IdKind instead
of special functions.

Reviewed By: arjunp

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

2 years ago[MLIR][Presburger] Attach values only to non-local identifiers in FAVC
Groverkss [Wed, 18 May 2022 03:43:30 +0000 (09:13 +0530)]
[MLIR][Presburger] Attach values only to non-local identifiers in FAVC

This patch changes `FlatAffineValueConstraints` to only allow attaching
values to non-local identifiers.

The reasoning for this change is:
1. Information attached to local identifiers can be lost since local identifiers
  can be removed for output size optimizations.
2. There are no current use cases for attaching values to Local identifiers.
3. Attaching a value to a local identifier does not make sense since a local
  identifier represents existential quantification.

This patch also adds some additional asserts to the affected functions.

Reviewed By: arjunp, bondhugula

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

2 years ago[BasicAA] Remove unneeded special case for malloc/calloc
Philip Reames [Wed, 18 May 2022 03:34:19 +0000 (20:34 -0700)]
[BasicAA] Remove unneeded special case for malloc/calloc

This code pre-exists the generic handling for inaccessiblememonly.  If we remove it and update one test with inaccessiblememonly, nothing else changes.  Note that simply running O1 on that test would annotate malloc with the missing inaccessiblememonly.

2 years ago[NFC][Clang] Modify expect of fail test or XFAIL because CSKY align is different
Zi Xuan Wu (Zeson) [Wed, 11 May 2022 08:48:40 +0000 (16:48 +0800)]
[NFC][Clang] Modify expect of fail test or XFAIL because CSKY align is different

CSKY is always in 4-byte align, no matter it's long long type.
For global aggregate variable, it's 4-byte align if its size is bigger than or equal to 4 bytes.

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

2 years ago[NFC][AMDGPU][CodeGen] Use ArrayRef in TargetLowering functions
Shao-Ce SUN [Wed, 18 May 2022 00:19:25 +0000 (08:19 +0800)]
[NFC][AMDGPU][CodeGen] Use ArrayRef in TargetLowering functions

Based on D123467.

Reviewed By: rampitec

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

2 years ago[InstCombine] add tests for icmp-fsh
Chenbing Zheng [Wed, 18 May 2022 02:01:44 +0000 (10:01 +0800)]
[InstCombine] add tests for icmp-fsh

2 years ago[JumpThreading] Let ProcessImpliedCondition look into freeze instructions
Juneyoung Lee [Wed, 18 May 2022 01:41:31 +0000 (10:41 +0900)]
[JumpThreading] Let ProcessImpliedCondition look into freeze instructions

This patch makes JumpThreading's ProcessImpliedCondition deal with frozen
conditions.

Reviewed By: nikic

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

2 years agoPrecommit a test file for D84941
Juneyoung Lee [Wed, 18 May 2022 01:41:25 +0000 (10:41 +0900)]
Precommit a test file for D84941

2 years ago[lld][ELF] Support BFD name elf32-avr
Ben Shi [Thu, 12 May 2022 13:26:15 +0000 (13:26 +0000)]
[lld][ELF] Support BFD name elf32-avr

Reviewed By: MaskRay

differential Revision: https://reviews.llvm.org/D125544

2 years ago[mlir][tosa] Rework tosa.apply_scale lowering for 32-bit
Robert Suderman [Tue, 17 May 2022 23:00:04 +0000 (16:00 -0700)]
[mlir][tosa] Rework tosa.apply_scale lowering for 32-bit

Added handling rounding behavior in 32-bits for when possible. This
avoids kernel compilation generating scalarized code on platforms where
64-bit vectors are not available.

As the 48-bit lowering requires 64-bit anyway, we added a full 64-bit
solution simplifying the old path.

Reviewed By: dcaballe, mravishankar

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

2 years agoRevert "[RISCV] Enable strict assertions in InsertVSETVLI data flow"
Philip Reames [Tue, 17 May 2022 22:51:41 +0000 (15:51 -0700)]
Revert "[RISCV] Enable strict assertions in InsertVSETVLI data flow"

This reverts commit 79a66ec97b4fb8cbc4e0a81ead356caf5507a6ea.

The stronger asserts served their purpose; I stumbled across another bug.  Will reapply once this one is also fixed.

The bug appears to be a variant of a previous one:
* We mutate an instruction in one block.
* That mutation changes the phase3 results of another block.

This is very similiar to a previous issue, except cross block instead of within a single block.

2 years ago[mlir][SCF] Fix scf.while bufferization
Matthias Springer [Tue, 17 May 2022 20:58:54 +0000 (22:58 +0200)]
[mlir][SCF] Fix scf.while bufferization

Before this fix, the bufferization implementation made the incorrect assumption that the values yielded from the "before" region must match with the values yielded from the "after" region.

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

2 years ago[pseudo] Design notes from discussion today. NFC
Sam McCall [Tue, 17 May 2022 22:08:47 +0000 (00:08 +0200)]
[pseudo] Design notes from discussion today. NFC

2 years ago[ConstantRange] Improve the implementation of binaryAnd
Alexander Shaposhnikov [Tue, 17 May 2022 21:30:44 +0000 (21:30 +0000)]
[ConstantRange] Improve the implementation of binaryAnd

This diff adjusts binaryAnd to take advantage of the analysis
based on KnownBits.

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

Test plan:
1/ ninja check-llvm
2/ ninja check-llvm-unit

2 years ago[BOLT][NFC] Suppress unused variable warnings
Amir Ayupov [Tue, 17 May 2022 21:30:00 +0000 (14:30 -0700)]
[BOLT][NFC] Suppress unused variable warnings

Addresses the warnings emitted by Apple Clang 13.1.6 (Xcode 13.3.1).
Tip @tschuett issue #55404.

Reviewed By: rafauler

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

2 years ago[BOLT][NFC] Move BinaryDominatorTree out of BinaryLoop header
Amir Ayupov [Tue, 17 May 2022 21:19:43 +0000 (14:19 -0700)]
[BOLT][NFC] Move BinaryDominatorTree out of BinaryLoop header

Split up the BinaryLoop header and move BinaryDominatorTree into its own header,
preparing it for a standalone use.

Reviewed By: rafauler

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

2 years ago[RISCV] Add additional test coverage of 11a7e77c and related transforms
Philip Reames [Tue, 17 May 2022 20:31:51 +0000 (13:31 -0700)]
[RISCV] Add additional test coverage of 11a7e77c and related transforms

2 years ago[docs][LangRef] Fix typo in llvm.smul.fix example
Nuno Lopes [Tue, 17 May 2022 20:36:36 +0000 (21:36 +0100)]
[docs][LangRef] Fix typo in llvm.smul.fix example

2 years ago[libc] add snprintf
Michael Jones [Tue, 17 May 2022 19:03:23 +0000 (12:03 -0700)]
[libc] add snprintf

After adding sprintf, snprintf is simple. The functions are very
similar. The tests only cover the behavior of the max length since the
sprintf tests should cover the other behavior.

Reviewed By: lntue

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

2 years ago[clang][dataflow] Fix double visitation of nested logical operators
Eric Li [Tue, 17 May 2022 18:08:25 +0000 (18:08 +0000)]
[clang][dataflow] Fix double visitation of nested logical operators

Sub-expressions that are logical operators are not spelled out
separately in basic blocks, so we need to manually visit them when we
encounter them. We do this in both the `TerminatorVisitor`
(conditionally) and the `TransferVisitor` (unconditionally), which can
cause cause an expression to be visited twice when the binary
operators are nested 2+ times.

This changes the visit in `TransferVisitor` to check if it has been
evaluated before trying to visit the sub-expression.

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

2 years ago[gn build] Port 1f49714d3e19
LLVM GN Syncbot [Tue, 17 May 2022 19:47:10 +0000 (19:47 +0000)]
[gn build] Port 1f49714d3e19

2 years ago[gn build] Port 1188faa7ab4b
LLVM GN Syncbot [Tue, 17 May 2022 19:47:09 +0000 (19:47 +0000)]
[gn build] Port 1188faa7ab4b

2 years ago[trace][intelpt] Support system-wide tracing [6] - Break IntelPTCollector into smalle...
Walter Erquinigo [Thu, 5 May 2022 21:42:54 +0000 (14:42 -0700)]
[trace][intelpt] Support system-wide tracing [6] - Break IntelPTCollector into smaller files and minor refactor

IntelPTCollector is very big and has 3 classes in it. It's actually cleaner if each one has its own file. This also gives more visibility to the developer about the different kinds of "tracers" that we have.

Besides that, I'm now restricting the creation of the BinaryData chunks to GetState() instead of having it in different places, which is not very clean, because the gdb-remote protocol should be as restricted as possible.

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

2 years ago[trace][intelpt] Support system-wide tracing [5] - Disable/enable per-core tracing...
Walter Erquinigo [Wed, 4 May 2022 20:24:49 +0000 (13:24 -0700)]
[trace][intelpt] Support system-wide tracing [5] - Disable/enable per-core tracing based on the process state

When tracing on per-core mode, we are tracing all processes, which means
that after hitting a breakpoint, our process will stop running (thus
producing no more tracing data) but other processes will continue
writing to our trace buffers. This causes a big data loss for our trace.
As a way to remediate this, I'm adding some logic to pause and unpause
tracing based on the target's state. The earlier we do it the better,
however, I'm not adding the trigger at the earliest possible point for
simplicity of this diff. Later we can improve that part.

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

2 years ago[trace][intelpt] Support system-wide tracing [4] - Support per core tracing on lldb...
Walter Erquinigo [Tue, 3 May 2022 02:10:39 +0000 (19:10 -0700)]
[trace][intelpt] Support system-wide tracing [4] - Support per core tracing on lldb-server

This diffs implements per-core tracing on lldb-server. It also includes tests that ensure that tracing can be initiated from the client and that the jLLDBGetState ppacket returns the list of trace buffers per core.

This doesn't include any decoder changes.

Finally, this makes some little changes here and there improving the existing code.

A specific piece of code that can't reliably be tested is when tracing
per core fails due to permissions. In this case we add a
troubleshooting message and this is the manual test:

```
/proc/sys/kernel/perf_event_paranoid set to 1

(lldb) process trace start --per-core-tracing                                         error: perf event syscall failed: Permission denied
 You might need that /proc/sys/kernel/perf_event_paranoid has a value of 0 or -1.
``

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

2 years ago[gn build] Port 6aabf60f2fb7
LLVM GN Syncbot [Tue, 17 May 2022 19:38:35 +0000 (19:38 +0000)]
[gn build] Port 6aabf60f2fb7

2 years ago[AMDGPU] Add llvm.amdgcn.global.load.lds intrinsic
Stanislav Mekhanoshin [Tue, 17 May 2022 18:25:45 +0000 (11:25 -0700)]
[AMDGPU] Add llvm.amdgcn.global.load.lds intrinsic

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

2 years agoRevert "Reland "[clangd] Indexing of standard library""
Sam McCall [Tue, 17 May 2022 19:32:45 +0000 (21:32 +0200)]
Revert "Reland "[clangd] Indexing of standard library""

This reverts commit ccdb56ac10eef3048135169a67d239328c2b1de6.

Still seeing windows failures on GN bots: http://45.33.8.238/win/58316/step_9.txt

Unfortunately I can't debug these at all - it's a bare unsymbolized
stacktrace, and I can't reproduce the failure.

2 years ago[AMDGPU] Enable FLAT LDS DMA on gfx9/10 before gfx940
Stanislav Mekhanoshin [Thu, 5 May 2022 22:44:16 +0000 (15:44 -0700)]
[AMDGPU] Enable FLAT LDS DMA on gfx9/10 before gfx940

We always had global and scratch loads to LDS in the gfx9,
but did not handle it. These were available via the 'lds'
encoding bit. In gfx940 this bit was reused as 'svs' which
resulted in new '_lds' opcodes effectively pushing this
bit into the opcode, but functionally it is the same. These
instructions are also available on gfx10.

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

2 years ago[gn build] Port ccdb56ac10ee
LLVM GN Syncbot [Tue, 17 May 2022 19:07:18 +0000 (19:07 +0000)]
[gn build] Port ccdb56ac10ee

2 years ago[RISCV] Minor reorganization of VSETVLIInfo::operator== for readability [NFC]
Philip Reames [Tue, 17 May 2022 19:05:11 +0000 (12:05 -0700)]
[RISCV] Minor reorganization of VSETVLIInfo::operator== for readability [NFC]

2 years agoReland "[clangd] Indexing of standard library"
Sam McCall [Tue, 17 May 2022 18:04:02 +0000 (20:04 +0200)]
Reland "[clangd] Indexing of standard library"

This reverts commit 76ddbb1ca747366417be64fdf79218df099a5973.

2 years ago[clang][dataflow] Weaken guard to only check for storage location
Eric Li [Tue, 17 May 2022 18:48:23 +0000 (18:48 +0000)]
[clang][dataflow] Weaken guard to only check for storage location

Weaken the guard for whether a sub-expression has been evaluated to
only check for the storage location, instead of checking for the
value. It should be sufficient to check for the storage location, as
we don't necessarily guarantee that a value will be set for the
location (although this is currently true right now).

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

2 years ago[RISCV] Canonicalize AVL=setvli to AVL=Imm or AVL=VLMAX
Philip Reames [Tue, 17 May 2022 18:29:39 +0000 (11:29 -0700)]
[RISCV] Canonicalize AVL=setvli to AVL=Imm or AVL=VLMAX

This patch adds a transform to the local prepass in InsertVSETVLI which canonicalizes an AVL of a register from another vsetvli into immediate or VLMAX when VTYPE is the same. In this patch, I chose to be conservative and avoid arbitrary vreg forwarding due to profitability concerns about possibility overlapping live ranges.

This has the effect of eliminating vsetvli instructions in loops which are walking either VLMAX or a constant number of lanes per iteration.

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

2 years ago[libc] add sprintf
Michael Jones [Thu, 12 May 2022 20:43:15 +0000 (13:43 -0700)]
[libc] add sprintf

This adds the sprintf entrypoint, as well as unit tests. Currently
sprintf only supports %%, %s, and %c, but the other conversions are on
the way.

Reviewed By: sivachandra, lntue

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

2 years ago[InstCombine] fold more shuffles with FP<->Int cast operands
Sanjay Patel [Tue, 17 May 2022 17:58:51 +0000 (13:58 -0400)]
[InstCombine] fold more shuffles with FP<->Int cast operands

shuffle (cast X), (cast Y), Mask --> cast (shuffle X, Y, Mask)

This extends the transform added with 0353c2c996c5.

If the casts are to a larger element type, the transform
reduces shuffle bit width, so that should be a win for
most codegen (if not, it can be inverted).

2 years ago[pseudo] benchmark cleanups. NFC
Sam McCall [Tue, 10 May 2022 13:45:38 +0000 (15:45 +0200)]
[pseudo] benchmark cleanups. NFC

- add missing benchmark for lex/preprocess steps
- name benchmarks after the function they're benchmarking, when appropriate
- remove unergonomic "run" prefixes from benchmark names
- give a useful error message if --grammar or --source are missing
- Use realistic example of how to run, run all benchmarks by default.
  (for someone who doesn't know the commands, this is the most useful action)
- Improve typos/wording in comment
- clean up unused vars
- avoid "parseable stream" name, which isn't a great name & not one I expected
  to escape from ClangPseudoMain

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

2 years ago[mlir] Update LLVMIR Fastmath flags use of MLIR BitEnum functionality
jfurtek [Tue, 17 May 2022 18:18:52 +0000 (18:18 +0000)]
[mlir] Update LLVMIR Fastmath flags use of MLIR BitEnum functionality

This diff updates the LLVMIR dialect Fastmath flags attribute to use recently
added features of `BitEnum` attributes. Specifically, this diff uses the bit
enum "group" case to represent the `fast` value as an alias for a combination
of other values (`ninf`, `nnan`, ...), instead of using a separate integer
value. (This is in line with LLVM's fastmath flags representation.) This diff
also leverages the `printBitEnumPrimaryGroups` `tblgen` field for concise
enum printing.

The `BitEnum` features were developed for an upcoming diff that adds `fastmath`
support to the arithmetic dialect. This diff simply applies some of the relevant
new features to the LLVM dialect attribute.

Reviewed By: ftynse, Mogball

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

2 years ago[clangd] Add command-line flag to set background indexing thread priority.
Sam McCall [Mon, 16 May 2022 09:16:37 +0000 (11:16 +0200)]
[clangd] Add command-line flag to set background indexing thread priority.

This is a followup to D124715, which changed the default, and it anticipates
future patches raising the priority of Low (which is currently equal to
Background on Windows & Linux).
The main point is to allow users to restore the old behavior, which e.g.
allows efficiency cores to remain idle.

I did consider making this a config setting, this is a more complicated change:
 - needs to touch queue priorities as well as thread priorities
 - we don't know the priority until evaluating the config inside the task
 - users would want the ability to prioritize background indexing tasks relative
   to each other without necessarily affecting thread priority, so using one
   option for both may be confusing
I don't really have a use case, so I prefer the simpler thing.

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

2 years ago[RISCV] Enable strict assertions in InsertVSETVLI data flow
Philip Reames [Tue, 17 May 2022 18:00:39 +0000 (11:00 -0700)]
[RISCV] Enable strict assertions in InsertVSETVLI data flow

These asserts are believed to hold after several recent miscompiles have been fixed.  If you see an assertion failure on this change, please toggle the default back and make sure you file a bug with a reproducer.  We may have as yet uncaught miscompiles lurking in this code.

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

2 years ago[NFC][lldb][trace] Use uint64_t when decoding and enconding json
Walter Erquinigo [Tue, 10 May 2022 04:44:09 +0000 (21:44 -0700)]
[NFC][lldb][trace] Use uint64_t when decoding and enconding json

llvm's json parser supports uint64_t, so let's better use it for the
packets being sent between lldb and lldb-server instead of using int64_t
as an intermediate type, which might be error-prone.

2 years ago[AMDGPU] gfx11 scalar alu instructions
Joe Nash [Thu, 21 Apr 2022 18:24:54 +0000 (14:24 -0400)]
[AMDGPU] gfx11 scalar alu instructions

MC layer support for SOP(scalar alu operations) including encoding
support for s_delay_alu and s_sendmsg_rtn.

Contributors:
Jay Foad <jay.foad@amd.com>

Patch 7/N for upstreaming of AMDGPU gfx11 architecture.

Depends on D125319

Reviewed By: #amdgpu, arsenm

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

2 years ago[AMDGPU] Add test for no waitcnt before issuing LDS DMA. NFC.
Stanislav Mekhanoshin [Mon, 16 May 2022 22:58:28 +0000 (15:58 -0700)]
[AMDGPU] Add test for no waitcnt before issuing LDS DMA. NFC.

A wait is only needed after the DMA before LDS can be read.

2 years ago[X86] Rename combineCONCAT_VECTORS\INSERT_SUBVECTOR\EXTRACT_SUBVECTOR to match Opcode...
Simon Pilgrim [Tue, 17 May 2022 17:15:30 +0000 (18:15 +0100)]
[X86] Rename combineCONCAT_VECTORS\INSERT_SUBVECTOR\EXTRACT_SUBVECTOR to match Opcode name. NFCI.

Its a lot easier to quickly search for the combine when it actually contains the name of the opcode it combines.

2 years ago[AMDGPU] Add intrinsics llvm.amdgcn.{raw|struct}.buffer.load.lds
Stanislav Mekhanoshin [Fri, 13 May 2022 20:31:38 +0000 (13:31 -0700)]
[AMDGPU] Add intrinsics llvm.amdgcn.{raw|struct}.buffer.load.lds

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

2 years ago[mlir][LLVMIR] Use a new way to verify GEPOp indices
Min-Yih Hsu [Thu, 21 Apr 2022 00:46:39 +0000 (17:46 -0700)]
[mlir][LLVMIR] Use a new way to verify GEPOp indices

Previously, GEPOp relies on `findKnownStructIndices` to check if a GEP
index should be static. The truth is, `findKnownStructIndices` can only
tell you a GEP index _might_ be indexing into a struct (which should use
a static GEP index). But GEPOp::build and GEPOp::verify are falsely
taking this information as a certain answer, which creates many false
alarms like the one depicted in
`test/Target/LLVMIR/Import/dynamic-gep-index.ll`.

The solution presented here adopts a new verification scheme: When we're
recursively checking the child element types of a struct type, instead
of checking every child types, we only check the one dictated by the
(static) GEP index value. We also combine "refinement" logics --
refine/promote struct index mlir::Value into constants -- into the very
verification process since they have lots of logics in common. The
resulting code is more concise and less brittle.

We also hide GEPOp::findKnownStructIndices since most of the
aforementioned logics are already encapsulated within GEPOp::build and
GEPOp::verify, we found little reason for findKnownStructIndices (or the
new findStructIndices) to be public.

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

2 years agofix typo error in DivergenceAnalysis.h
Ruobing Han [Tue, 17 May 2022 16:54:36 +0000 (16:54 +0000)]
fix typo error in DivergenceAnalysis.h

Fix a typo error in the comment in DivergenceAnalysis.h

Reviewed By: asbirlea

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

2 years ago[AArch64] Teach perfect shuffles tables about D-lane movs
David Green [Tue, 17 May 2022 17:16:45 +0000 (18:16 +0100)]
[AArch64] Teach perfect shuffles tables about D-lane movs

Similar to D123386, this adds D-Movs to the AArch64 perfect shuffle
tables, slightly lowering the costs a little more. This is a rough
improvement in general, especially if you ignore mov v0.16b, v2.16b type
moves that are often artefacts of the calling convention.

The D register movs are encoded as (0x4 | LaneIdx), and to generate a D
register move we are required to bitcast into a higher type, but it is
otherwise very similar to the S-lane mov's already supported.

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

2 years ago[Polly] Mark classes as final by default. NFC.
Michael Kruse [Tue, 17 May 2022 15:55:27 +0000 (10:55 -0500)]
[Polly] Mark classes as final by default. NFC.

This make is obivious that a class was not intended to be derived from.

NPM analysis pass can unfortunately not marked as final because they are
derived from a llvm::Checker<T> template internally by the NPM.

Also normalize the use of classes/structs
 * NPM passes are structs
 * Legacy passes are classes
 * structs that have methods and are not a visitor pattern are classes
 * structs have public inheritance by default, remove "public" keyword
 * Use typedef'ed type instead of inline forward declaration

2 years ago[LV] Regenerate check lines for some tests.
Florian Hahn [Tue, 17 May 2022 16:44:54 +0000 (17:44 +0100)]
[LV] Regenerate check lines for some tests.

Make sure the auto-generated check lines are up-to-date for some files,
to reduce the test diff in upcoming changes

2 years ago[clang-cl] Add /Zc:wchar_t- option
Pengxuan Zheng [Fri, 13 May 2022 02:50:18 +0000 (19:50 -0700)]
[clang-cl] Add /Zc:wchar_t- option

Map /Zc:wchar_t- to the cc1 flag -fno-wchar which is already supported.

Reviewed By: thakis

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

2 years ago[AMDGPU] Add a MIR test for D125567
Jay Foad [Tue, 17 May 2022 15:50:08 +0000 (16:50 +0100)]
[AMDGPU] Add a MIR test for D125567

2 years ago[llvm][json] Fix UINT64 json parsing
Walter Erquinigo [Tue, 10 May 2022 15:16:32 +0000 (08:16 -0700)]
[llvm][json] Fix UINT64 json parsing

https://reviews.llvm.org/D109347 added support for UINT64 json numeric
types. However, it seems that it didn't properly test uint64_t numbers
larger than the int64_t because the number parsing logic doesn't
have any special handling for these large numbers.

This diffs adds a handler for large numbers, and besides that, fixes the
parsing of signed types by checking for errno ERANGE, which is the
recommended way to check if parsing fails because of out of bounds
errors. Before this diff, strtoll was always returning a number within
the bounds of an int64_t and the bounds check it was doing was completely
superfluous.

As an interesting fact about the old implementation, when calling strtoll
with "18446744073709551615", the largest uint64_t, End was S.end(), even
though it didn't use all digits. Which means that this check can only be
used to identify if the numeric string is malformed or not.

This patch also adds additional tests for extreme cases.

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

2 years ago[lldb-vscode] Fix data race in lldb-vscode when running with ThreadSanitizer
Walter Erquinigo [Tue, 17 May 2022 15:53:51 +0000 (08:53 -0700)]
[lldb-vscode] Fix data race in lldb-vscode when running with ThreadSanitizer

This patch fixes https://github.com/llvm/llvm-project/issues/54768. A ProgressEventReporter creates a dedicated thread that keeps checking whether there are new events that need to be sent to IDE as long as m_thread_should_exit is true. When the VSCode instance is destructed, it will set m_thread_should_exit to false, which caused a data race because at the same time its ProgressEventReporter is reading this value to determine whether it should quit. This fix simply uses mutex to ensure they cannot read and write this value at the same time.

Committed on behalf of PRESIDENT810

Reviewed By: clayborg, wallace

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

2 years agoRevert "[llvm-objcopy][test] Add cmp after copy"
Keith Smiley [Tue, 17 May 2022 16:06:58 +0000 (09:06 -0700)]
Revert "[llvm-objcopy][test] Add cmp after copy"

This reverts commit 0d863b5b90a2f11e58b0b54d7183cb1577fd3a0b.

Broke a test https://reviews.llvm.org/D125478#3519509

2 years ago[OpaquePtr][BitcodeReader] Explicitly turn off opaque pointers if we see a typed...
Arthur Eubanks [Tue, 17 May 2022 00:49:59 +0000 (17:49 -0700)]
[OpaquePtr][BitcodeReader] Explicitly turn off opaque pointers if we see a typed pointer

Followup to D125735 on the bitcode reader side.

Reviewed By: #opaque-pointers, nikic

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

2 years ago[OpaquePtr][LLParser] Explicitly turn off opaque pointers if we see a star
Arthur Eubanks [Tue, 17 May 2022 00:01:09 +0000 (17:01 -0700)]
[OpaquePtr][LLParser] Explicitly turn off opaque pointers if we see a star

If we turn on --opaque-pointers, tests with '*' would use opaque pointers.

Can't really test this without flipping the default value for --opaque-pointers.

Reviewed By: #opaque-pointers, nikic

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

2 years agoFix the std::string formatter to report errors in the case where the
Jim Ingham [Tue, 17 May 2022 15:21:09 +0000 (08:21 -0700)]
Fix the std::string formatter to report errors in the case where the
string points to unaccessible memory.

The formatter tries to get the data field of the std::string, and to
check whether that fails it just checks that the ValueObjectSP
returned is not empty. But we never return empty ValueObjectSP's to
indicate failure, since doing so would lose the Error object that
tells you why fetching the ValueObject failed.

This patch adds a check for ValueObject::GetError().Success().

I also added a test case for this failure, and reworked the test case
a bit (to use run_to_source_breakpoint). I also renamed a couple of
single letter locals which don't follow the lldb coding conventions.

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

2 years ago[gn build] Port 76ddbb1ca747
LLVM GN Syncbot [Tue, 17 May 2022 15:17:39 +0000 (15:17 +0000)]
[gn build] Port 76ddbb1ca747

2 years agoRevert "[clangd] Indexing of standard library"
Sam McCall [Tue, 17 May 2022 15:16:40 +0000 (17:16 +0200)]
Revert "[clangd] Indexing of standard library"

This reverts commit ecaa4d9662c9a6ac013ac40a8ad72a2c75e3fd3b.

2 years ago[InstCombine] remove cast-of-signbit to shift transform
Sanjay Patel [Tue, 17 May 2022 14:21:02 +0000 (10:21 -0400)]
[InstCombine] remove cast-of-signbit to shift transform

The transform was wrong in 3 ways:

1. It created an extra instruction when the source and dest types don't match.
2. It did not account for an extra use of the icmp, so could create 2 extra insts.
3. It favored bit hacks over icmp (icmp generally has better analysis).

This fixes #54692 (modeled by the PhaseOrdering tests).

This is a minimal step to fix the bug, but we should likely invert
this and the sibling transform for the "is negative" pattern too.

The backend should be able to invert this back to a shift if that
leads to better codegen.

This is a reduced try of 3794cc0e9964 - that was reverted because
it could cause infinite loops by conflicting with the related
transforms in this block that create shifts.

2 years ago[RISCV] Add a test showing incorrect RVV stack alignment
Fraser Cormack [Fri, 1 Oct 2021 11:45:43 +0000 (12:45 +0100)]
[RISCV] Add a test showing incorrect RVV stack alignment

The RISC-V stack is assumed to be aligned to 16 bytes and can handle stack
realignment for larger objects, but the "RVV stack" is only ensured to be
aligned to 8 bytes. This means that objects specified at a larger alignment may
be misaligned, not only for 16-byte-aligned RVV objects that don't trigger
realignment, but also for 32-byte-and-larger-aligned objects which do.

The new test checks a variety of alignment configurations, showing the
misaligned cases.

Reviewed By: reames

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

2 years ago[LV] Fetch vector loop region once and remember it (NFC).
Florian Hahn [Tue, 17 May 2022 14:57:23 +0000 (15:57 +0100)]
[LV] Fetch vector loop region once and remember it (NFC).

This avoids an unnecessary lookup and makes the code slightly more
compact.

2 years ago[gn build] Port ecaa4d9662c9
LLVM GN Syncbot [Tue, 17 May 2022 14:51:11 +0000 (14:51 +0000)]
[gn build] Port ecaa4d9662c9

2 years ago[clangd] Indexing of standard library
Sam McCall [Sun, 28 Nov 2021 23:09:41 +0000 (00:09 +0100)]
[clangd] Indexing of standard library

This provides a nice "warm start" with all headers indexed, not just
those included so far.

The standard library is indexed after a preamble is parsed, using that
file's configuration. The result is pushed into the dynamic index.
If we later see a higher language version, we reindex it.

It's configurable as Index.StandardLibrary, off by default for now.

Based on D105177 by @kuhnel

Fixes https://github.com/clangd/clangd/issues/618

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

2 years ago[RISCV] Drop notion of "strict" vsetvli compatibility
Fraser Cormack [Tue, 17 May 2022 07:52:20 +0000 (08:52 +0100)]
[RISCV] Drop notion of "strict" vsetvli compatibility

With recent fixes to the dataflow in place, we now never pass
Strict=true to isCompatible, so remove the parameter completely.

Reviewed By: reames

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

2 years ago[NFC][AIX] Reenable mri1.test
Jake Egan [Tue, 17 May 2022 14:26:59 +0000 (10:26 -0400)]
[NFC][AIX] Reenable mri1.test

This test is passing now because of D124017 and D123949.

Reviewed By: DiggerLin

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

2 years ago[IRBuilder] Move insertvalue/extractvalue to fold infrastructure
Nikita Popov [Tue, 17 May 2022 13:55:42 +0000 (15:55 +0200)]
[IRBuilder] Move insertvalue/extractvalue to fold infrastructure

Move from the old CreateXYZ() to the new FoldXYZ() mechanism.

This change is likely NFC in practice, because I don't think that
the places using InstSimplifyFolder use insertvalue/extractvalue.

2 years agoFix release note typo from 6da3d66f
Erich Keane [Tue, 17 May 2022 13:35:06 +0000 (06:35 -0700)]
Fix release note typo from 6da3d66f

2 years ago[mlir] vim: add bf16 type
Cullen Rhodes [Fri, 13 May 2022 15:11:25 +0000 (15:11 +0000)]
[mlir] vim: add bf16 type

2 years ago[mlir][licm] Fix debug output with newlines
Cullen Rhodes [Thu, 5 May 2022 14:25:44 +0000 (14:25 +0000)]
[mlir][licm] Fix debug output with newlines

2 years agoFix an unused variable warning in no-asserts build mode
Dmitri Gribenko [Tue, 17 May 2022 13:27:44 +0000 (15:27 +0200)]
Fix an unused variable warning in no-asserts build mode

2 years ago[concepts] Implement dcl.decl.general p4: No constraints on non-template funcs
Erich Keane [Mon, 16 May 2022 14:55:35 +0000 (07:55 -0700)]
[concepts] Implement dcl.decl.general p4: No constraints on non-template funcs

The standard says:
The optional requires-clause ([temp.pre]) in an init-declarator or
member-declarator shall be present only if the declarator declares a
templated function ([dcl.fct]).

This implements that limitation, and updates the tests to the best of my
ability to capture the intent of the original checks.

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

2 years ago[pseudo] Add the missing ; terminal for module-declaration rule.
Haojian Wu [Tue, 17 May 2022 13:13:51 +0000 (15:13 +0200)]
[pseudo] Add the missing ; terminal for module-declaration rule.

2 years ago[SLP]Add an extra check for select minmax reduction to avoid crash.
Alexey Bataev [Tue, 17 May 2022 12:32:01 +0000 (05:32 -0700)]
[SLP]Add an  extra check for select minmax reduction to avoid crash.

Need to check if the reduction is still (not)cmp-select pattern min/max
reduction to avoid compiler crash during building list of reduction
operations. cmp-sel pattern provides 2 reduction operations, while
intrinsics - just one.

2 years ago[pgo] Fix doc typo: thingswith -> things with
Konrad Kleine [Tue, 17 May 2022 10:48:03 +0000 (10:48 +0000)]
[pgo] Fix doc typo: thingswith -> things with

The title says it all.

Reviewed By: thakis

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

2 years agoEnabling the detection of devtoolset-11 toolchain.
Kamau Bridgeman [Thu, 12 May 2022 20:02:00 +0000 (15:02 -0500)]
Enabling the detection of devtoolset-11 toolchain.

This patch allows systems to build the llvm-project with the devtoolset-11
toolchain.

Reviewed By: phosek

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

2 years ago[DAG] Fold (shl (srl x, c), c) -> and(x, m) even if srl has other uses
Simon Pilgrim [Tue, 17 May 2022 12:40:03 +0000 (13:40 +0100)]
[DAG] Fold (shl (srl x, c), c) -> and(x, m) even if srl has other uses

If we're using shift pairs to mask, then relax the one use limit if the shift amounts are equal - we'll only be generating a single AND node.

AArch64 has a couple of regressions due to this, so I've enforced the existing one use limit inside a AArch64TargetLowering::shouldFoldConstantShiftPairToMask callback.

Part of the work to fix the regressions in D77804

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

2 years ago[libc++] Introduce LIBCXX_LIBRARY_VERSION
Louis Dionne [Mon, 16 May 2022 13:50:56 +0000 (09:50 -0400)]
[libc++] Introduce LIBCXX_LIBRARY_VERSION

This allows controlling the current_version linker property on Apple
platforms.

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

2 years ago[clang] Expose CoawaitExpr's operand in the AST
Nathan Ridge [Mon, 4 Apr 2022 06:29:21 +0000 (02:29 -0400)]
[clang] Expose CoawaitExpr's operand in the AST

Previously the Expr returned by getOperand() was actually the
subexpression common to the "ready", "suspend", and "resume"
expressions, which often isn't just the operand but e.g.
await_transform() called on the operand.

It's important for the AST to expose the operand as written
in the source for traversals and tools like clangd to work
correctly.

Fixes https://github.com/clangd/clangd/issues/939

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

2 years ago[RegAllocGreedy] New hook regClassPriorityTrumpsGlobalness
Jay Foad [Wed, 4 May 2022 15:33:32 +0000 (16:33 +0100)]
[RegAllocGreedy] New hook regClassPriorityTrumpsGlobalness

Add a new TargetRegisterInfo hook to allow targets to tweak the
priority of live ranges, so that AllocationPriority of the register
class will be treated as more important than whether the range is local
to a basic block or global. This is determined per-MachineFunction.

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

2 years ago[mlir][Tablegen-LSP] Don't link with llvm dylib
David Spickett [Tue, 17 May 2022 11:00:34 +0000 (11:00 +0000)]
[mlir][Tablegen-LSP] Don't link with llvm dylib

This updates 5de12bb703c5104b3fd64ee51c6900d6171d826a
to not link with the dylib since that does not include
the tablegen library.

Should fix flang dylib build failures:
https://lab.llvm.org/buildbot/#/builders/177/builds/5120

2 years ago[VPlan] Move usesScalars/onlyFirstLaneUsed to VPUser.
Florian Hahn [Tue, 17 May 2022 10:20:06 +0000 (11:20 +0100)]
[VPlan] Move usesScalars/onlyFirstLaneUsed to VPUser.

Those helpers model properties of a user and they should also be
available to non-recipe users. This will be used in D123537 for a new
exit value user.

Reviewed By: Ayal

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

2 years ago[AArch64] Extra tests useful for D-lane shuffles. NFC
David Green [Tue, 17 May 2022 10:15:55 +0000 (11:15 +0100)]
[AArch64] Extra tests useful for D-lane shuffles. NFC

2 years ago[JumpThreading] Regenerate test checks (NFC)
Nikita Popov [Tue, 17 May 2022 10:12:46 +0000 (12:12 +0200)]
[JumpThreading] Regenerate test checks (NFC)