platform/upstream/llvm.git
13 months ago[clang] Add serialization support for the DynamicAllocLValue variant of APValue:...
Nathan Ridge [Fri, 21 Jul 2023 08:05:14 +0000 (04:05 -0400)]
[clang] Add serialization support for the DynamicAllocLValue variant of APValue::LValueBase::Ptr

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

13 months ago[CodeGen] Support bitcode input containing multiple modules
Fangrui Song [Sat, 22 Jul 2023 03:05:35 +0000 (20:05 -0700)]
[CodeGen] Support bitcode input containing multiple modules

When using -fsplit-lto-unit (explicitly specified or due to using
-fsanitize=cfi/-fwhole-program-vtables), the emitted LLVM IR contains a module
flag metadata `"EnableSplitLTOUnit"`. If a module contains both type metadata
and `"EnableSplitLTOUnit"`, `ThinLTOBitcodeWriter.cpp` will write two modules
into the bitcode file. Compiling the bitcode (not ThinLTO backend compilation)
will lead to an error due to `parseIR` requiring a single module.

```
% clang -flto=thin a.cc -c -o a.bc
% clang -c a.bc
% clang -fsplit-lto-unit -flto=thin a.cc -c -o a.bc
% clang -c a.bc
error: Expected a single module
1 error generated.
```

There are multiple ways to have just one module in a bitcode file
output: `-Xclang -fno-lto-unit`, not using features like `-fsanitize=cfi`,
using `-fsanitize=cfi` with `-fno-split-lto-unit`. I think whether a
bitcode input file contains 2 modules (internal implementation strategy)
should not be a criterion to require an additional driver option when
the user seek for a non-LTO compile action.

Let's place the extra module (if present) into CodeGenOptions::LinkBitcodeFiles
(originally for -cc1 -mlink-bitcode-file). Linker::linkModules will link the two
modules together. This patch makes the following commands work:

```
clang -S -emit-llvm a.bc
clang -S a.bc
clang -c a.bc
```

Reviewed By: ormris

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

13 months agoOptimize emission of `dynamic_cast` to final classes.
Richard Smith [Sat, 22 Jul 2023 00:37:55 +0000 (17:37 -0700)]
Optimize emission of `dynamic_cast` to final classes.

- When the destination is a final class type that does not derive from
  the source type, the cast always fails and is now emitted as a null
  pointer or call to __cxa_bad_cast.

- When the destination is a final class type that does derive from the
  source type, emit a direct comparison against the corresponding base
  class vptr value(s). There may be more than one such value in the case
  of multiple inheritance; check them all.

For now, this is supported only for the Itanium ABI. I expect the same thing is
possible for the MS ABI too, but I don't know what guarantees are made about
vfptr uniqueness.

Reviewed By: rjmccall

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

13 months ago[lldb] Convert script native types to StructuredData counterpart
Med Ismail Bennani [Fri, 21 Jul 2023 23:43:24 +0000 (16:43 -0700)]
[lldb] Convert script native types to StructuredData counterpart

This patch adds the ability to pass native types from the script
interpreter to methods that use a {SB,}StructuredData argument.

To do so, this patch changes the `ScriptedObject` struture that holds
the pointer to the script object as well as the originating script
interpreter language. It also exposes that to the SB API via a new class
called `SBScriptObject`.

This structure allows the debugger to parse the script object and
convert it to a StructuredData object. If the type is not compatible
with the StructuredData types, we will store its pointer in a
`StructuredData::Generic` object.

This patch also adds some SWIG typemaps that checks the input argument to
ensure it's either an SBStructuredData object, in which case it just
passes it throught, or a python object that is NOT another SB type, to
provide some guardrails for the user.

rdar://111467140

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

Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
13 months agoSet default C++ level for PlayStation(r) to C++17.
Sunil Srivastava [Sat, 22 Jul 2023 01:18:21 +0000 (18:18 -0700)]
Set default C++ level for PlayStation(r) to C++17.

13 months ago[include-cleaner] allow spelling strategies to customize verbatim/system headers
Sam McCall [Wed, 19 Jul 2023 02:49:54 +0000 (04:49 +0200)]
[include-cleaner] allow spelling strategies to customize verbatim/system headers

Our use case is wanting to apply a spelling strategy to rewrite the spellings
written in IWYU pragma private directives.

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

13 months ago[lldb] Consider OP_addrx in DWARFExpression::Update_DW_OP_addr
Felipe de Azevedo Piovezan [Fri, 21 Jul 2023 23:39:31 +0000 (16:39 -0700)]
[lldb] Consider OP_addrx in DWARFExpression::Update_DW_OP_addr

This rewrites DW_OP_addrx inside DWARFExpression as an DW_OP_addr so
that we can update addresses that are originally located in the
debug_addr section.

The full discussion behind this can be found in
https://discourse.llvm.org/t/dwarfexpression-and-dw-op-addrx/71627/12, but a
summary follows.

When SymbolFileDWARF::ParseVariableDIE creates DWARFExpressions for
variables whose location is an OP_addr, it knows how to remap
addresses appropriately in the DebugMap case. It then calls
DWARFExpression::Update_DW_OP_addr, which updates the value associated
with OP_addr.

However, when we have an OP_addrx, the update function does
nothing. This makes sense, as the DWARFExpression does not have a
mutable view of the debug_addr section. In non-DebugMap flows this is
not an issue, as the debug_addr contains the correct addresses of
variables. In DebugMap flows, this is problematic because the work
done by RelinkOSOAddress is lost. By updating the OP to OP_addr, we
can also update the address as required,

We also explored the alternative of relinking the debug_addr section
when we are initializing OSOs (InitOSO). However, this creates an
inconsistent story for users of
DWARFExpression::GetLocation_DW_OP_addr. This function returns an
address without telling callers whether that address came from an
OP_addr or an OP_addrx. If we preemptively relink OP_addrx results
without doing the same for OP_addr results, then callers can’t know
whether the address they got was an executable address or an object
file address. In other words, they can’t know whether they need to
call LinkOSOFileAddress on those results or not.

This patch addresses the majority of test failures when enabling DWARF
5 for MachO (over 200 test failures).

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

13 months ago[mlir][tosa][fix] Add proper type checking trait for tosa mul
TatWai Chong [Fri, 21 Jul 2023 23:28:45 +0000 (16:28 -0700)]
[mlir][tosa][fix] Add proper type checking trait for tosa mul

when operating integer type tensors, tosa elementwise multiplication
requires the element type of result to be a 32-bit integer rather
than the same type as inputs.

Change-Id: Ifd3d7ebd879be5c6b2c8e23aa6d7ef41f39c6d41

Reviewed By: mgehre-amd

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

13 months ago[NFC] Remove extra semicolons in clang/lib/APINotes/APINotesFormat.h
Evan Wilde [Fri, 21 Jul 2023 23:17:16 +0000 (16:17 -0700)]
[NFC] Remove extra semicolons in clang/lib/APINotes/APINotesFormat.h

There are some trailing semicolons on namespaces in
clang/lib/APINotes/APINotesFormat.h. These result in warnings while
building and don't need to be there.

Reviewed By: compnerd

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

13 months ago[AMDGPU] Fix an unused variable warning
Kazu Hirata [Fri, 21 Jul 2023 23:14:41 +0000 (16:14 -0700)]
[AMDGPU] Fix an unused variable warning

This patch fixes:

  llvm/lib/Target/AMDGPU/AMDGPUCodeGenPrepare.cpp:1006:9: error:
  unused variable 'Ty' [-Werror,-Wunused-variable]

13 months agoEnable compact unwind in all darwin simulators
Jon Roelofs [Fri, 21 Jul 2023 19:51:39 +0000 (12:51 -0700)]
Enable compact unwind in all darwin simulators

... since they've always supported it.

rdar://104359594

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

13 months agoRevert "[RISCV] Add test which shows alignment of constant pools and the functions...
Philip Reames [Fri, 21 Jul 2023 23:02:33 +0000 (16:02 -0700)]
Revert "[RISCV] Add test which shows alignment of constant pools and the functions which followed"

This reverts commit cbf2a6ce197e8176c01316fe25400aae0b7390c4.  This was a precommited test for a change which is being abandoned.

13 months agoRevert "Reapply [IR] Mark and constant expressions as undesirable"
Nathan Chancellor [Fri, 21 Jul 2023 22:23:08 +0000 (15:23 -0700)]
Revert "Reapply [IR] Mark and constant expressions as undesirable"

This reverts commit 086ee99564afbb11449c08ea2e094f7f49fadde5.

This patch causes an infinite loop when building arch/mips/mm/c-r4k.c in
the Linux kernel. See the comment in Phabricator for a reduced
reproducer: https://reviews.llvm.org/rG086ee99564afbb11449c08ea2e094f7f49fadde5

13 months agoAMDGPU: Fix variables only used in asserts
Matt Arsenault [Fri, 21 Jul 2023 22:52:50 +0000 (18:52 -0400)]
AMDGPU: Fix variables only used in asserts

13 months agoAMDGPU: Implement new 2ulp fdiv lowering
Matt Arsenault [Sun, 16 Jul 2023 12:32:08 +0000 (08:32 -0400)]
AMDGPU: Implement new 2ulp fdiv lowering

Extends the new frexp scaled reciprocal to the general case. The
reciprocal case is just the same thing when frexp of 1 is constant
folded. Could probably clean up the code to rely on that constant
folding.

Improves results for the IEEE path for the default OpenCL division. We
used to only emit the fdiv.fast intrinsic with a 2.5 ulp accuracy
threshold with DAZ, which uses explicit range checks. This gives us a
better fast option with the default IEEE behavior.

13 months agoAMDGPU: Refactor AMDGPUCodeGenPrepare fdiv handling
Matt Arsenault [Wed, 19 Jul 2023 14:11:53 +0000 (10:11 -0400)]
AMDGPU: Refactor AMDGPUCodeGenPrepare fdiv handling

NFC-ish. Does trigger some reordering of the fdiv scalarization. Also
skips scalarizing in more cases where nothing was going to happen. We
can still scalarize in some no-op edge cases.

https://reviews.llvm.org/D155740

13 months agoTrack the RequestingModule in the HeaderSearch LookupFile cache.
Richard Smith [Fri, 21 Jul 2023 21:53:36 +0000 (14:53 -0700)]
Track the RequestingModule in the HeaderSearch LookupFile cache.

Different requesting modules can have different lookup results, so don't
cache results across modules.

Fixes a regression introduced in reviews.llvm.org/D132779.

Test case based on one provided by Jan Svoboda.

Reviewed By: jansvoboda11

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

13 months ago[flang] Fix portability warning that was incorrectly an "else if"
Peter Klausler [Thu, 20 Jul 2023 19:37:25 +0000 (12:37 -0700)]
[flang] Fix portability warning that was incorrectly an "else if"

A semantics check for an assumed-length dummy procedure pointer was
inappropriately part of an "else" clause for a preceding check,
causing it to not be applied in all situations.

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

13 months ago[mlir][arith] Add canon pattern for chained `arith.muli`
Jakub Kuderski [Fri, 21 Jul 2023 22:17:39 +0000 (18:17 -0400)]
[mlir][arith] Add canon pattern for chained `arith.muli`

@benvanik reported this as missing.

Reviewed By: Mogball

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

13 months ago[HWASAN][LSAN] Replace cstdint with stdint.h
Kirill Stoimenov [Fri, 21 Jul 2023 21:17:50 +0000 (21:17 +0000)]
[HWASAN][LSAN] Replace cstdint with stdint.h

Reviewed By: brooksmoses, MaskRay

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

13 months ago[flang] Emit just one warning for a bad format edit descriptor
Peter Klausler [Thu, 20 Jul 2023 21:44:46 +0000 (14:44 -0700)]
[flang] Emit just one warning for a bad format edit descriptor

An attempt to use an edit descriptor (other than A or L) in a FORMAT
statement without arequired 'w' width will elicit warnings from both
the parser and the I/O checker in semantics.  Remove the warning from
the parser.

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

13 months agoTOSA-to-Linalg lowering for element-wise ops
Rafael Ubal Tena [Fri, 21 Jul 2023 21:48:11 +0000 (14:48 -0700)]
TOSA-to-Linalg lowering for element-wise ops

- Wrote complete documentation for the `Broadcastable` op trait. This is mostly meant as a thorough description of its previous behavior, with the exception of minor feature updates.

- Restricted legality criteria for a `Broadcastable` op in order to simplify current and future lowering passes and increase efficiency of code generated by those passes. New restriction are: 1) A dynamic dimension in an inferred result is not compatible with a static dimension in the actual result. 2) Broadcast semantics are restricted to input operands and not supported between inferred and actual result shapes.

- Implemented TOSA-to-Linalg lowering support for unary, binary, tertiary element-wise ops. This support is complete for all legal cases described in the `Broadcastable` trait documentation.

- Added unit tests for `tosa.abs`, `tosa.add`, and `tosa.select` as examples of unary, binary, and tertiary ops.

Reviewed By: eric-k256

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

13 months ago[RISCV] Add test which shows alignment of constant pools and the functions which...
Philip Reames [Fri, 21 Jul 2023 19:39:45 +0000 (12:39 -0700)]
[RISCV] Add test which shows alignment of constant pools and the functions which followed

13 months ago[flang][runtime] Fix NORM2([negative, ...])
Peter Klausler [Thu, 20 Jul 2023 20:50:10 +0000 (13:50 -0700)]
[flang][runtime] Fix NORM2([negative, ...])

NORM2 is broken for arrays that start with a negative number
because it sets the initial running max_ value to that number
rather than to its absolute value.

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

13 months ago[mlir] Move attr -> properties to not require Operation
Jacques Pienaar [Fri, 21 Jul 2023 21:54:43 +0000 (14:54 -0700)]
[mlir] Move attr -> properties to not require Operation

This allows for converting before/without an Operation is created.

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

13 months ago[flang] Strengthen procedure compatibility checking
Peter Klausler [Thu, 20 Jul 2023 18:46:31 +0000 (11:46 -0700)]
[flang] Strengthen procedure compatibility checking

Add more checks to procedure compatibility testing for procedure pointer
assignments, actual procedure arguments, &c.  Specifically, don't
allow corresponding dummy data objects to differ in their use
of polymorphism, assumed size arrays, or assumed shape arrays.

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

13 months ago[NVPTX] Add initial support for '.alias' in PTX
Joseph Huber [Wed, 12 Jul 2023 18:35:01 +0000 (13:35 -0500)]
[NVPTX] Add initial support for '.alias' in PTX

This patch adds initial support for using aliases when targeting PTX. We
perform a pretty strict conversion from the globals referenced to the
expected output. as described in the PTX documentation at
https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#kernel-and-function-directives-alias

These cannot currently be used due to a bug in the `nvlink`
implementation that causes aliases to pruned functions to crash the
linker.

Reviewed By: tra

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

13 months ago[flang] Portability warning and documentation for an obscure extension
Peter Klausler [Thu, 20 Jul 2023 17:39:04 +0000 (10:39 -0700)]
[flang] Portability warning and documentation for an obscure extension

A quotation mark can appear in a Fortran character literal by doubling
it; for example, PRINT *, "'""'" prints '"'.  When those doubled
quotation marks are split by a free form line continuation, the
continuation line should have an ampersand before the second quotation
mark.  But most compilers, including this one, allow the second
quotation mark to appear as the first character on the continuation
line, too.

So this works:

  print *, "'"&
"'"

but it really should be written as:

  print *, "'"&
&"'"

Emit a portability warning and document that we support this near-universal
extension.

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

13 months ago[clangd] Allow indexing of __reserved_names outside system headers
Sam McCall [Sat, 15 Jul 2023 20:21:25 +0000 (22:21 +0200)]
[clangd] Allow indexing of __reserved_names outside system headers

The special handling for these names was added in
https://github.com/llvm/llvm-project/commit/055d8090d1d5137dab88533995e0c5d9b5390c28
and the motivation was the C++ standard library.

It turns out some projects like using these names anyway, in particular the
linux kernel. D153946 proposed making this a config option, but there are
some implementation issues with the config system.

As an alternative, this patch tweaks the heuristic so we only drop these symbols
in system headers. This does the right thing for linux and the C++ standard
library, at least.

Fixes https://github.com/clangd/clangd/issues/1680
Fixes https://github.com/llvm/llvm-project/issues/63862

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

13 months ago[Headers][doc] Add SHA1/SHA256 intrinsic descriptions
Paul Robinson [Thu, 20 Jul 2023 16:44:18 +0000 (09:44 -0700)]
[Headers][doc] Add SHA1/SHA256 intrinsic descriptions

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

13 months ago[flang] Rename new test file
Peter Klausler [Fri, 21 Jul 2023 21:16:56 +0000 (14:16 -0700)]
[flang] Rename new test file

A recent patch added a new test file whose name conflicts with an existing
test on case-insensitive filesystems.  Rename it.

13 months ago[flang] Ensure that NULL(without MOLD=) not passed to dummy argument with assumed...
Peter Klausler [Wed, 19 Jul 2023 22:02:32 +0000 (15:02 -0700)]
[flang] Ensure that NULL(without MOLD=) not passed to dummy argument with assumed type parameters

A dummy argument with an assumed (*) character length or derived type parameter
value specification needs to be associated with an actual argument that can
supply a value for it, so make sure that a NULL without a MOLD= is not being
passed.

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

13 months ago[clangd] Use index for go-to-type
Sam McCall [Thu, 20 Jul 2023 22:23:35 +0000 (00:23 +0200)]
[clangd] Use index for go-to-type

This ensures it finds the definition even if not visible.

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

13 months ago[clangd] Add BlockEnd comments for control flow statements
Sam McCall [Mon, 17 Jul 2023 06:02:40 +0000 (08:02 +0200)]
[clangd] Add BlockEnd comments for control flow statements

These mark the end of CompoundStmts bodies of if/while/for/switch.
To identify which statement is being ended, we include abbreviated
text of the condition/loop variable.

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

13 months ago[flang] Disallow ASYNCHRONOUS for subroutine
Peter Klausler [Wed, 19 Jul 2023 20:56:32 +0000 (13:56 -0700)]
[flang] Disallow ASYNCHRONOUS for subroutine

The check for inappropriate usage of the ASYNCHRONOUS attribute
needed to be moved in declaration checking so that it can catch
attempts to use it on a subroutine.

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

13 months ago[flang] Enforce F'2023 C7125
Peter Klausler [Wed, 19 Jul 2023 20:23:53 +0000 (13:23 -0700)]
[flang] Enforce F'2023 C7125

An item whose declared type is ABSTRACT may not appear in an
array constructor.

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

13 months ago[libc] Remove test RPC opcodes from the exported header
Joseph Huber [Mon, 10 Jul 2023 14:38:37 +0000 (09:38 -0500)]
[libc] Remove test RPC opcodes from the exported header

This patch does the noisy work of removing the test opcodes from the
exported interface to an interface that is only visible in `libc`. The
benefit of this is that we both test the exported RPC registration more
directly, and we do not need to give this interface to users.

I have decided to export any opcode that is not a "core" libc feature as
having its MSB set in the opcode. We can think of these as non-libc
"extensions".

Reviewed By: JonChesterfield

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

13 months agoAMDGPU: Overhaul and improve rcp and rsq f32 formation
Matt Arsenault [Mon, 3 Jul 2023 14:22:24 +0000 (10:22 -0400)]
AMDGPU: Overhaul and improve rcp and rsq f32 formation

The highlight change is a new denormal safe 1ulp lowering which uses
rcp after using frexp to perform input scaling. This saves 2
instructions compared to other implementations which performed an
explicit denormal range change. This improves the OpenCL default, and
requires a flag for HIP. I don't believe there's any flag wired up for
OpenMP to emit the necessary fpmath metadata.

This provides several improvements and changes that were hard to
separate without regressing one case or another. Disturbingly the
OpenCL conformance test seems to have the reciprocal test commented
out. I locally hacked it back in to test this.

Starts introducing f32 rsq intrinsics in AMDGPUCodeGenPrepare. Like
the rcp case, we could do this in codegen if !fpmath were preserved
(although we would lose some computeKnownFPClass tricks). Start
requiring contract flags to form rsq. The rsq fusion actually improves
the result from ~2ulp to ~1ulp. We have some older fusion in codegen
which only keys off unsafe math which should be refined.

Expand rsq patterns by checking for denormal inputs and pre/post
multiplying like the current library code does. We also take advantage
of computeKnownFPClass to avoid the scaling when we can statically
prove the input cannot be a denormal. We could do the same for the rcp
case, but unlike rsq a large input can underflow to denormal. We need
additional upper bound exponent checks on the input in order to do the
same for rcp.

This rsq handling also now starts handling the negated case. We
introduce rsq with an fneg. In the case the fneg doesn't fold into its
user, it's a neutral change but provides improvement if it is foldable
as a source modifier.

Also starts respecting the arcp attribute properly, and more strictly
interprets afn. We were previously interpreting afn as implying you
could do the reciprocal expansion of an fdiv. The codegen handling of
these also needs to be revisited.

This also effectively introduces the optimization
combineRepeatedFPDivisors enables, just done in the IR instead (and
only for f32).

This is almost across the board better. The one minor regression is
for gfx6/buggy frexp case where for multiple reciprocals, we could
previously reuse rematerialized constants per instance (it's neutral
for a single rcp).

The fdiv.fast and sqrt handling need to be revisited next.

https://reviews.llvm.org/D155593

13 months ago[MLIR][ANALYSIS] Add liveness analysis utility
Srishti Srivastava [Fri, 21 Jul 2023 20:28:57 +0000 (13:28 -0700)]
[MLIR][ANALYSIS] Add liveness analysis utility

This commit adds a utility to implement liveness analysis using the
sparse backward data-flow analysis framework. Theoretically, liveness
analysis assigns liveness to each (value, program point) pair in the
program and it is thus a dense analysis. However, since values are
immutable in MLIR, a sparse analysis, which will assign liveness to
each value in the program, suffices here.

Liveness analysis has many applications. It can be used to avoid the
computation of extraneous operations that have no effect on the memory
or the final output of a program. It can also be used to optimize
register allocation. Both of these applications help achieve one very
important goal: reducing runtime.

A value is considered "live" iff it:
  (1) has memory effects OR
  (2) is returned by a public function OR
  (3) is used to compute a value of type (1) or (2).
It is also to be noted that a value could be of multiple types (1/2/3) at
the same time.

A value "has memory effects" iff it:
  (1.a) is an operand of an op with memory effects OR
  (1.b) is a non-forwarded branch operand and a block where its op could
  take the control has an op with memory effects.

A value `A` is said to be "used to compute" value `B` iff `B` cannot be
computed in the absence of `A`. Thus, in this implementation, we say that
value `A` is used to compute value `B` iff:
  (3.a) `B` is a result of an op with operand `A` OR
  (3.b) `A` is used to compute some value `C` and `C` is used to compute
  `B`.

---

It is important to note that there already exists an MLIR liveness
utility here: llvm-project/mlir/include/mlir/Analysis/Liveness.h. So,
what is the need for this new liveness analysis utility being added by
this commit? That need is explained as follows:-

The similarities between these two utilities is that both use the
fixpoint iteration method to converge to the final result of liveness.
And, both have the same theoretical understanding of liveness as well.

However, the main difference between (a) the existing utility and (b)
the added utility is the "scope of the analysis". (a) is restricted to
analysing each block independently while (b) analyses blocks together,
i.e., it looks at how the control flows from one block to the other,
how a caller calls a callee, etc. The restriction in the former implies
that some potentially non-live values could be marked live and thus the
full potential of liveness analysis will not be realised.

This can be understood using the example below:

```
1 func.func private @private_dead_return_value_removal_0() -> (i32, i32) {
2   %0 = arith.constant 0 : i32
3   %1 = arith.addi %0, %0 : i32
4   return %0, %1 : i32, i32
5 }
6 func.func @public_dead_return_value_removal_0() -> (i32) {
7   %0:2 = func.call @private_dead_return_value_removal_0() : () -> (i32, i32)
8   return %0#0 : i32
9 }
```

Here, if we just restrict our analysis to a per-block basis like (a), we
will say that the %1 on line 3 is live because it is computed and then
returned outside its block by the function. But, if we perform a
backward data-flow analysis like (b) does, we will say that %0#1 of line
7 is not live because it isn't returned by the public function and thus,
%1 of line 3 is also not live. So, while (a) will be unable to suggest
any IR optimizations, (b) can enable this IR to convert to:-

```
1 func.func private @private_dead_return_value_removal_0() -> i32 {
2   %0 = arith.constant 0 : i32
3   return %0 : i32
4 }
5 func.func @public_dead_return_value_removal_0() -> i32 {
6   %0 = call @private_dead_return_value_removal_0() : () -> i32
7   return %0 : i32
8 }
```

One operation was removed and one unnecessary return value of the
function was removed and the function signature was modified. This is an
optimization that (b) can enable but (a) cannot. Such optimizations can
help remove a lot of extraneous computations that are currently being
done.

Signed-off-by: Srishti Srivastava <srishtisrivastava.ai@gmail.com>
Reviewed By: matthiaskramm, jcai19

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

13 months ago[flang] Catch case of character array constructor with indeterminable length
Peter Klausler [Wed, 19 Jul 2023 19:06:31 +0000 (12:06 -0700)]
[flang] Catch case of character array constructor with indeterminable length

F'2023 7.8 para 5 requires that an implied DO loop with no iterations
in a character array constructor should have items whose lengths are
constant expressions independent of the value of the implied DO loop
index.

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

13 months ago[AArch64] Move branch relaxation after bbsection assignment
Daniel Hoekwater [Tue, 27 Jun 2023 01:30:27 +0000 (01:30 +0000)]
[AArch64] Move branch relaxation after bbsection assignment

Because branch relaxation needs to factor in if branches target
a block in the same section or a different one, it needs to run
after the Basic Block Sections / Machine Function Splitting passes.

Because Jump table compression relies on block offsets remaining
fixed after the table is compressed, we must also move the JT
compression pass.

The only tests affected are ones enforcing just the ordering and
the a few that have basic block ids changed because RenumberBlocks
hasn't run yet.

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

13 months ago[SLP][NFC]Add a test with strided loads, NFC.
Alexey Bataev [Fri, 21 Jul 2023 20:13:01 +0000 (13:13 -0700)]
[SLP][NFC]Add a test with strided loads, NFC.

13 months ago[flang][runtime] Detect NEWUNIT= without FILE= or STATUS='SCRATCH'
Peter Klausler [Wed, 19 Jul 2023 00:05:47 +0000 (17:05 -0700)]
[flang][runtime] Detect NEWUNIT= without FILE= or STATUS='SCRATCH'

It is an error to open a new unit with OPEN(NEWUNIT=) and have
neither a file name nor a scratch status.  Catch it, and report a
new error code.

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

13 months ago[LV] Replace use of getMaxSafeDepDist with isSafeForAnyVector (NFC)
Florian Hahn [Fri, 21 Jul 2023 20:05:50 +0000 (22:05 +0200)]
[LV] Replace use of getMaxSafeDepDist with isSafeForAnyVector (NFC)

Replace the use of getMaxSafeDepDistBytes with the more direct
isSafeForAnyVector. This removes the need to define getMaxSafeDepDistBytes.

13 months agoValueTracking: Implement computeKnownFPClass for frexp
Matt Arsenault [Wed, 3 May 2023 13:52:53 +0000 (09:52 -0400)]
ValueTracking: Implement computeKnownFPClass for frexp

Work around the lack of proper multiple return values by looking
at the extractvalue.

https://reviews.llvm.org/D150982

13 months agoValueTracking: Add baseline tests for frexp handling in computeKnownFPClass
Matt Arsenault [Wed, 3 May 2023 11:37:16 +0000 (07:37 -0400)]
ValueTracking: Add baseline tests for frexp handling in computeKnownFPClass

13 months agoAMDGPU: Add baseline test for fdiv combine
Matt Arsenault [Sun, 2 Jul 2023 00:21:28 +0000 (20:21 -0400)]
AMDGPU: Add baseline test for fdiv combine

13 months ago[flang] Preserve errors from generic matching
Peter Klausler [Tue, 18 Jul 2023 23:14:49 +0000 (16:14 -0700)]
[flang] Preserve errors from generic matching

When searching for a matching specific procedure for a set of actual
arguments in a type-bound generic interface for a defined operator,
don't discard any error messages that may have been produced for
the specific that was found.  Tweak the code to preserve those
messages and add them to the context's messages, and add a test.

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

13 months ago[flang][hlfir] Added missing fir.convert for i1 result of hlfir.dot_product.
Slava Zakharin [Fri, 21 Jul 2023 19:11:51 +0000 (12:11 -0700)]
[flang][hlfir] Added missing fir.convert for i1 result of hlfir.dot_product.

Some operations using the result of hlfir.dot_product can tolerate
that the type of the result changes from !fir.logical to i1 during
intrinsics lowering, but some won't. I added a separate LIT case with
fir.store to mimic one of the nag tests.

Reviewed By: kiranchandramohan

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

13 months ago[flang][hlfir] Preserve polymorphism for the result of hlfir.transpose.
Slava Zakharin [Fri, 21 Jul 2023 19:11:42 +0000 (12:11 -0700)]
[flang][hlfir] Preserve polymorphism for the result of hlfir.transpose.

Reviewed By: kiranchandramohan

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

13 months ago[NFC][flang] Distinguish MATMUL and MATMUL-TRANSPOSE printouts.
Slava Zakharin [Fri, 21 Jul 2023 19:11:25 +0000 (12:11 -0700)]
[NFC][flang] Distinguish MATMUL and MATMUL-TRANSPOSE printouts.

When MatmulTranpose reports incorrect shapes of the arguments
it cannot represent itself as MATMUL, because the reading
of the first argument's shape will be confusing.

Reviewed By: kiranchandramohan

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

13 months ago[flang] Stricter checking of DIM= arguments to LBOUND/UBOUND/SIZE
Peter Klausler [Tue, 18 Jul 2023 20:31:23 +0000 (13:31 -0700)]
[flang] Stricter checking of DIM= arguments to LBOUND/UBOUND/SIZE

DIM= arguments with constant values can be checked for validity
even when other arguments to an intrinsic function can't be
folded.  Handle errors with assumed-rank arguments as well.

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

13 months ago[flang] Finalize &/or destroy ABSTRACT types
Peter Klausler [Tue, 18 Jul 2023 21:53:21 +0000 (14:53 -0700)]
[flang] Finalize &/or destroy ABSTRACT types

The runtime type information tables always flag ABSTRACT types as
needing neither destruction in general nor finalization in particular.
This is incorrect.  Although an ABSTRACT type may not itself have
a FINAL procedure -- its argument cannot be polymorphic, but
ABSTRACT types in declarations must always be so -- it can still
have finalizable components &/or components requiring deallocation.

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

13 months ago[InstCombine] If there is a known-bit transform is_pow2 check to just check for any...
Noah Goldstein [Fri, 21 Jul 2023 18:31:47 +0000 (13:31 -0500)]
[InstCombine] If there is a known-bit transform is_pow2 check to just check for any other bits

in `ctpop(X) eq/ne 1` or `ctpop(X) ugt/ule 1`, if there is any
known-bit in `X`, instead of going through `ctpop`, we can just test
if there are any other known bits in `X`. If there are, `X` is not a
power of 2. If there aren't, `X` is a power of 2.

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

Reviewed By: nikic

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

13 months ago[InstCombine] Add tests for ispow2 comparisons with a known bit; NFC
Noah Goldstein [Mon, 12 Jun 2023 03:38:46 +0000 (22:38 -0500)]
[InstCombine] Add tests for ispow2 comparisons with a known bit; NFC

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

13 months ago[InstCombine] Canonicalize `(X^(X-1)) u{ge,lt} X` as pow2 test
Noah Goldstein [Sun, 11 Jun 2023 21:13:30 +0000 (16:13 -0500)]
[InstCombine] Canonicalize `(X^(X-1)) u{ge,lt} X` as pow2 test

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

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

13 months ago[InstCombine] Add tests for canonicalizing `(X^(X-1)) u{ge,lt} X` as pow2 test; NFC
Noah Goldstein [Sun, 11 Jun 2023 21:41:46 +0000 (16:41 -0500)]
[InstCombine] Add tests for canonicalizing `(X^(X-1)) u{ge,lt} X` as pow2 test; NFC

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

13 months ago[flang] Support implicit global external as procedure pointer target
Peter Klausler [Tue, 18 Jul 2023 16:32:33 +0000 (09:32 -0700)]
[flang] Support implicit global external as procedure pointer target

A name that has been used to reference an undeclared global external
procedure should be accepted as the target of a procedure pointer
assignment statement.

Fixes llvm-test-suite/Fortran/gfortran/regression/proc_ptr_45.f90.

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

13 months ago[flang] Compare component types In AreSameComponent()
Peter Klausler [Mon, 17 Jul 2023 23:35:34 +0000 (16:35 -0700)]
[flang] Compare component types In AreSameComponent()

The subroutine AreSameComponent() of the predicate AreSameDerivedType()
had a TODO about checking component types that needed completion in order
to properly detect that two specific procedures of a generic are
distinguishable in the llvm-test-suite/Fortran/gfortran/regression
test import7.f90.

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

13 months ago[llvm-objdump] Use BBEntry::BBID to represent basic block numbers.
Rahman Lavaee [Mon, 17 Jul 2023 14:23:42 +0000 (07:23 -0700)]
[llvm-objdump] Use BBEntry::BBID to represent basic block numbers.

Reviewed By: aidengrossman, mtrofin, JestrTulip

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

13 months ago[libc] Disable 'DecodeInOtherBases` test on GPU targets
Joseph Huber [Fri, 21 Jul 2023 16:18:13 +0000 (11:18 -0500)]
[libc] Disable 'DecodeInOtherBases` test on GPU targets

This test is excessively slow on GPU targets, taking anywhere beween 5
and 60 seconds to complete each time it's run. See
https://lab.llvm.org/buildbot/#/builders/55/builds/52203/steps/12/logs/stdio
for an example on the NVPTX buildbot. Simply disable testing this on the
GPU for now.

Reviewed By: michaelrj

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

13 months ago[X86] combineBitcastvxi1 - don't prematurely create PACKSS nodes.
Simon Pilgrim [Fri, 21 Jul 2023 18:10:06 +0000 (19:10 +0100)]
[X86] combineBitcastvxi1 - don't prematurely create PACKSS nodes.

Similar to Issue #63710 - by truncating the v8i16 result with a PACKSS node before type legalization, we fail to make use of various folds that rely on TRUNCATE nodes.

This required tweaks to LowerTruncateVecPackWithSignBits to recognise when the truncation source has been widened and to more closely match combineVectorSignBitsTruncation wrt truncating with PACKSS/PACKUS on AVX512 targets.

One of the last stages before we can finally get rid of combineVectorSignBitsTruncation.

13 months ago[X86] truncateVectorWithPACK - avoid concat_vectors(extract_subvector(pack()),extract...
Simon Pilgrim [Fri, 21 Jul 2023 17:16:11 +0000 (18:16 +0100)]
[X86] truncateVectorWithPACK - avoid concat_vectors(extract_subvector(pack()),extract_subvector(pack())) for sub-128 bit vectors

As we start using this after type legalization, we must avoid creating concat_vectors nodes so late.

13 months ago[AMDGPU] Remove std::optional from VOPD::ComponentProps. NFC.
Stanislav Mekhanoshin [Thu, 20 Jul 2023 20:12:37 +0000 (13:12 -0700)]
[AMDGPU] Remove std::optional from VOPD::ComponentProps. NFC.

This class has to be fast and efficient with a trivial copy
constructor.

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

13 months ago[test] Unsupport CodeGenCXX/destructors for LLVM_ENABLE_REVERSE_ITERATION builds
Fangrui Song [Fri, 21 Jul 2023 17:28:52 +0000 (10:28 -0700)]
[test] Unsupport CodeGenCXX/destructors for LLVM_ENABLE_REVERSE_ITERATION builds

_ZN5test312_GLOBAL__N_11CD2Ev and _ZN5test312_GLOBAL__N_11DD0Ev are
swapped in LLVM_ENABLE_REVERSE_ITERATION builds. Unsupport for now.

13 months agoNFC. Move remaining affine/memref test cases into respective dialect dirs
Uday Bondhugula [Thu, 20 Jul 2023 16:20:13 +0000 (21:50 +0530)]
NFC. Move remaining affine/memref test cases into respective dialect dirs

Move a bunch of lingering test cases from test/Transforms/ into
test/Dialect/Affine and MemRef.

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

13 months ago[X86] Add isUpperSubvectorUndef helper to simplify recognition of vectors widened...
Simon Pilgrim [Fri, 21 Jul 2023 16:48:11 +0000 (17:48 +0100)]
[X86] Add isUpperSubvectorUndef helper to simplify recognition of vectors widened with undef upper subvectors. NFC.

13 months ago[Sanitizers][Darwin][Test] Mark symbolize_pc test on Darwin/TSan+UBSan as UNSUPPORTED
Arthur Eubanks [Fri, 21 Jul 2023 16:47:08 +0000 (09:47 -0700)]
[Sanitizers][Darwin][Test] Mark symbolize_pc test on Darwin/TSan+UBSan as UNSUPPORTED

Followup to https://reviews.llvm.org/rG760c208f6ff9e97a9a11523c00874a1eec4f876b which XFAIL'd them, but they pass in some configurations.

13 months ago[flang] Accept an assumed-rank array as operand of ASSOCIATED()
Peter Klausler [Mon, 17 Jul 2023 16:42:47 +0000 (09:42 -0700)]
[flang] Accept an assumed-rank array as operand of ASSOCIATED()

The ASSOCIATED() intrinsic was mistakenly defined in the intrinsic
function table as requiring operands of known rank, which unintentionally
prevented assumed-rank dummy arguments from being tested.

Fixes llvm-test-suite/Fortran/gfortran/regression/pr88932.f90.

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

13 months agoclang/Debian: add Debian Trixie now that it is in unstable
Sylvestre Ledru [Fri, 21 Jul 2023 16:23:14 +0000 (18:23 +0200)]
clang/Debian: add Debian Trixie now that it is in unstable

13 months ago[MLIR][Linalg] Preserve DPS when decomposing Softmax
Lorenzo Chelini [Fri, 21 Jul 2023 11:28:45 +0000 (13:28 +0200)]
[MLIR][Linalg] Preserve DPS when decomposing Softmax

Preserve destination passing style (DPS) when decomposing
`linalg.Softmax`; instead of creating a new empty, which may materialize
as a new buffer after bufferization, use the result directly.

Reviewed By: qcolombet

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

13 months ago[RISCV][NFC] Add RISCVSubtarget field to RISCVExpandPseudo and RISCVPreRAExpandPseudo
Alex Bradbury [Fri, 21 Jul 2023 15:37:50 +0000 (16:37 +0100)]
[RISCV][NFC] Add RISCVSubtarget field to RISCVExpandPseudo and RISCVPreRAExpandPseudo

To my eye, it's cleaner to just get hold of STI in runOnMachineFunction
(as we do already for InstrInfo) and then accessing the field as needed
rather than to have repeated lookup code in the member functions or
helpers that need it.

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

13 months ago[libc] Treat the locks array as a bitfield
Joseph Huber [Fri, 21 Jul 2023 15:34:09 +0000 (10:34 -0500)]
[libc] Treat the locks array as a bitfield

Currently we keep an internal buffer of device memory that is used to
indicate ownership of a port. Since we only use this as a single bit we
can simply turn this into a bitfield. I did this manually rather than
having a separate type as we need very special handling of the masks
used to interact with the locks.

Reviewed By: JonChesterfield

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

13 months ago[Support] Implement LLVM_ENABLE_REVERSE_ITERATION for StringMap
Fangrui Song [Fri, 21 Jul 2023 15:46:51 +0000 (08:46 -0700)]
[Support] Implement LLVM_ENABLE_REVERSE_ITERATION for StringMap

ProgrammersManual.html says

> StringMap iteration order, however, is not guaranteed to be deterministic, so any uses which require that should instead use a std::map.

This patch makes -DLLVM_REVERSE_ITERATION=on (currently
-DLLVM_ENABLE_REVERSE_ITERATION=on works as well) shuffle StringMap
iteration order (actually flipping the hash so that elements not in the
same bucket are reversed) to catch violations, similar to D35043 for
DenseMap. This should help change the hash function (e.g., D142862,
D155781).

With a lot of fixes, there are still some violations. This patch
implements the "reverse_iteration" lit feature to skip such tests.
Eventually we should remove this feature.

`ninja check-{llvm,clang,clang-tools}` are clean with
`#define LLVM_ENABLE_REVERSE_ITERATION 1`.

Reviewed By: jhenderson

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

13 months ago[bazel] update config.h.cmake
Mikhail Goncharov [Fri, 21 Jul 2023 15:38:01 +0000 (17:38 +0200)]
[bazel] update config.h.cmake

13 months ago[RISCV] Allow delayed decision for ADD/SUB relocations
Fangrui Song [Fri, 21 Jul 2023 15:37:58 +0000 (08:37 -0700)]
[RISCV] Allow delayed decision for ADD/SUB relocations

For a label difference `A-B` in assembly, if A and B are separated by a
linker-relaxable instruction, we should emit a pair of ADD/SUB
relocations (e.g. R_RISCV_ADD32/R_RISCV_SUB32,
R_RISCV_ADD64/R_RISCV_SUB64).

However, the decision is made upfront at parsing time with inadequate
heuristics (`requiresFixup`). As a result, LLVM integrated assembler
incorrectly suppresses R_RISCV_ADD32/R_RISCV_SUB32 for the following
code:
```
// Simplified from a workaround https://android-review.googlesource.com/c/platform/art/+/2619609
// Both end and begin are not defined yet. We decide ADD/SUB relocations upfront and don't know they will be needed.
.4byte end-begin

begin:
  call foo
end:
```

To fix the bug, make two primary changes:

* Delete `requiresFixups` and the overridden emitValueImpl (from D103539).
  This deletion requires accurate evaluateAsAbolute (D153097).
* In MCAssembler::evaluateFixup, call handleAddSubRelocations to emit
  ADD/SUB relocations.

However, there is a remaining issue in
MCExpr.cpp:AttemptToFoldSymbolOffsetDifference. With MCAsmLayout, we may
incorrectly fold A-B even when A and B are separated by a
linker-relaxable instruction. This deficiency is acknowledged (see
D153097), but was previously bypassed by eagerly emitting ADD/SUB using
`requiresFixups`. To address this, we partially reintroduce `canFold` (from
D61584, removed by D103539).

Some expressions (e.g. .size and .fill) need to take the `MCAsmLayout`
code path in AttemptToFoldSymbolOffsetDifference, avoiding relocations
(weird, but matching GNU assembler and needed to match user
expectation). Switch to evaluateKnownAbsolute to leverage the `InSet`
condition.

As a bonus, this change allows for the removal of some relocations for
the FDE `address_range` field in the .eh_frame section.

riscv64-64b-pcrel.s contains the main test.
Add a linker relaxable instruction to dwarf-riscv-relocs.ll to test what
it intends to test.
Merge fixups-relax-diff.ll into fixups-diff.ll.

Reviewed By: kito-cheng

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

13 months agoRevert "[X86][BF16] Do not scalarize masked load for BF16 when we have BWI"
Phoebe Wang [Fri, 21 Jul 2023 15:29:11 +0000 (23:29 +0800)]
Revert "[X86][BF16] Do not scalarize masked load for BF16 when we have BWI"

This reverts commit ca1c05208ed35ba72869c65ad773b2cca4bbd360.

It caused Buildbot fail: https://lab.llvm.org/buildbot#builders/220/builds/24870

13 months ago[flang][nfc] Clarify the usage of llvmArgs and mlirArgs
Andrzej Warzynski [Fri, 21 Jul 2023 09:47:36 +0000 (10:47 +0100)]
[flang][nfc] Clarify the usage of llvmArgs and mlirArgs

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

13 months ago[X86][BF16] Do not scalarize masked load for BF16 when we have BWI
Phoebe Wang [Fri, 21 Jul 2023 15:18:38 +0000 (23:18 +0800)]
[X86][BF16] Do not scalarize masked load for BF16 when we have BWI

Fixes #63017

Reviewed By: RKSimon

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

13 months ago[mlir][nvgpu] Set useDefaultAttributePrinterParser
Guray Ozen [Fri, 21 Jul 2023 14:59:15 +0000 (16:59 +0200)]
[mlir][nvgpu] Set useDefaultAttributePrinterParser

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

13 months agoRevert "[mlir][spirv] Add D155747 to `.git-blame-ignore-revs`"
Jakub Kuderski [Fri, 21 Jul 2023 14:59:16 +0000 (10:59 -0400)]
Revert "[mlir][spirv] Add D155747 to `.git-blame-ignore-revs`"

This reverts commit b8a20658fee019fe9126a29f930ddd5dedec51ff.

This does not preserve the line history of cut-and-pasted code like I
expected.

13 months ago[ARM] Extend regression test for D154281
Jay Foad [Fri, 21 Jul 2023 14:43:11 +0000 (15:43 +0100)]
[ARM] Extend regression test for D154281

Add a test case with a larger call frame which does not satisfy
ARMFrameLowering::hasReservedCallFrame.

13 months ago[FunctionAttrs] Add tests for PR63936 (NFC)
Nikita Popov [Fri, 21 Jul 2023 14:44:38 +0000 (16:44 +0200)]
[FunctionAttrs] Add tests for PR63936 (NFC)

13 months agoAdd missing SLEEF mappings to scalable vector functions for log2 and log2f
Maciej Gabka [Thu, 20 Jul 2023 08:31:48 +0000 (08:31 +0000)]
Add missing SLEEF mappings to scalable vector functions for log2 and log2f

In the original commit adding SLEEF mappings, https://reviews.llvm.org/D146839
mappings for log2/log2f were missing.

Reviewed By: paulwalker-arm

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

13 months ago[ValueTracking] Check non-zero operator before dominating condition (NFC)
Nikita Popov [Fri, 21 Jul 2023 13:24:08 +0000 (15:24 +0200)]
[ValueTracking] Check non-zero operator before dominating condition (NFC)

Prefer checking for non-zero operator before non-zero via
dominating conditions. This is to make sure we don't have
compile-time regressions when special cases that are currently
part of isKnownNonZero() get moved into isKnownNonZeroFromOperator().

13 months ago[DAG] SimplifyDemandedBits - call ComputeKnownBits for constant non-uniform ISD:...
Simon Pilgrim [Fri, 21 Jul 2023 13:44:03 +0000 (14:44 +0100)]
[DAG] SimplifyDemandedBits - call ComputeKnownBits for constant non-uniform ISD::SRL shift amounts

We only attempted to determine KnownBits for uniform constant shift amounts, but ComputeKnownBits is able to handle some non-uniform cases as well that we can use as a fallback.

13 months ago[mlir][linalg] MapCopyToThreadsOp: Support tensor.pad
Matthias Springer [Fri, 21 Jul 2023 13:35:53 +0000 (15:35 +0200)]
[mlir][linalg] MapCopyToThreadsOp: Support tensor.pad

Also return the generated loop op.

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

13 months ago[ValueTracking] Extract isKnownNonZeroFromOperator() (NFC)
Nikita Popov [Fri, 21 Jul 2023 13:23:02 +0000 (15:23 +0200)]
[ValueTracking] Extract isKnownNonZeroFromOperator() (NFC)

Split off the primary part of the isKnownNonZero() implementation,
in the same way it is done for computeKnownBits(). This makes it
easier to reorder different parts of isKnownNonZero().

13 months agoRevert "[TLI][AArch64] Add missing SLEEF mappings to scalable vector functions for...
Maciej Gabka [Fri, 21 Jul 2023 13:50:10 +0000 (13:50 +0000)]
Revert "[TLI][AArch64] Add missing SLEEF mappings to scalable vector functions for log2 and log2f"

This reverts commit 791c89600aaa288d7066aea95a1e06cd6d61b2e3.

13 months ago[TLI][AArch64] Add missing SLEEF mappings to scalable vector functions for log2 and...
Maciej Gabka [Thu, 20 Jul 2023 08:31:48 +0000 (08:31 +0000)]
[TLI][AArch64] Add missing SLEEF mappings to scalable vector functions for log2 and log2f

In the original commit adding SLEEF mappings, https://reviews.llvm.org/D146839
mappings for log2/log2f were missing.

Reviewed By: paulwalker-arm

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

13 months ago[mlir][linalg] BufferizeToAllocationOp: Add option to materialize buffers for operands
Matthias Springer [Fri, 21 Jul 2023 13:29:16 +0000 (15:29 +0200)]
[mlir][linalg] BufferizeToAllocationOp: Add option to materialize buffers for operands

Add an option that does not bufferize the targeted op itself, but just materializes a buffer for the destination operands. This is useful for partial bufferization of complex ops such as `scf.forall`, which need special handling (and an analysis if the region).

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

13 months ago[mlir][transform] Add `apply_cse` option to `transform.apply_patterns` op
Matthias Springer [Fri, 21 Jul 2023 13:12:52 +0000 (15:12 +0200)]
[mlir][transform] Add `apply_cse` option to `transform.apply_patterns` op

Applying the canonicalizer and CSE in an interleaved fashion is useful after bufferization (and maybe other transforms) to fold away self copies.

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

13 months ago[clang][analyzer]Fix non-effective taint sanitation
Daniel Krupp [Wed, 19 Jul 2023 12:01:53 +0000 (14:01 +0200)]
[clang][analyzer]Fix non-effective taint sanitation

There was a bug in alpha.security.taint.TaintPropagation checker
in Clang Static Analyzer.
Taint filtering could only sanitize const arguments.
After this patch, taint filtering is effective also
on non-const parameters.

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

13 months ago[Clang] Diagnose jumps into statement expressions
Corentin Jabot [Fri, 7 Jul 2023 08:58:13 +0000 (10:58 +0200)]
[Clang] Diagnose jumps into statement expressions

Such jumps are not allowed by GCC and allowing them
can lead to situations where we jumps into unevaluated
statements.

Fixes #63682

Reviewed By: aaron.ballman, #clang-language-wg

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

13 months ago[mlir][nvgpu] Ignore -Wunused-function in NVGPUDialect.cpp (NFC)
Jie Fu [Fri, 21 Jul 2023 12:45:59 +0000 (20:45 +0800)]
[mlir][nvgpu] Ignore -Wunused-function in NVGPUDialect.cpp (NFC)

In file included from /Users/jiefu/llvm-project/mlir/lib/Dialect/NVGPU/IR/NVGPUDialect.cpp:363:
/Users/jiefu/llvm-project/build-Release/tools/mlir/include/mlir/Dialect/NVGPU/IR/NVGPUAttrDefs.cpp.inc:22:36: error: unused function 'generatedAttributeParser' [-Werror,-Wunused-function]
static ::mlir::OptionalParseResult generatedAttributeParser(::mlir::AsmParser &parser, ::llvm::StringRef *mnemonic, ::mlir::Type type, ::mlir::Attribute &value) {
                                   ^
/Users/jiefu/llvm-project/build-Release/tools/mlir/include/mlir/Dialect/NVGPU/IR/NVGPUAttrDefs.cpp.inc:46:30: error: unused function 'generatedAttributePrinter' [-Werror,-Wunused-function]
static ::mlir::LogicalResult generatedAttributePrinter(::mlir::Attribute def, ::mlir::AsmPrinter &printer) {
                             ^
2 errors generated.

13 months ago[llvm][SLP] Exit early if inputs to comparator are equal
David Berard [Fri, 21 Jul 2023 12:24:47 +0000 (05:24 -0700)]
[llvm][SLP] Exit early if inputs to comparator are equal

**TL;DR:** This PR modifies a comparator. The comparator is used in a subsequent call to llvm::stable_sort. Sorting comparators should follow strict weak ordering - in particular, (x < x) should return false. This PR adds a fix to avoid an infinite loop when the inputs to the comparator are equal.

**Details**:

Sometimes when two equivalent tensors passed into the comparator, we encounter infinite looping (at https://github.com/llvm/llvm-project/blob/aae2eaae2cefd3132059925c4592276defdb1faa/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp#L4049)

Although it seems like this comparator will never be called with two equivalent pointers, some sanitizers, e.g. https://chromium.googlesource.com/chromiumos/third_party/gcc/+/refs/heads/stabilize-zako-5712.88.B/libstdc++-v3/include/bits/stl_algo.h#360, will add checks for (x < x). When this sanitizer is used with the current implementation, it triggers a comparator check for (x < x) which runs into the infinite loop

Reviewed By: ABataev

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

13 months ago[clangd] Prefer definitions for gototype and implementation
Kadir Cetinkaya [Wed, 14 Sep 2022 08:07:15 +0000 (10:07 +0200)]
[clangd] Prefer definitions for gototype and implementation

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

13 months ago[X86] matchBinaryShuffle - match PACKUS for v2i64 -> v4i32 shuffle truncation patterns.
Simon Pilgrim [Fri, 21 Jul 2023 11:26:45 +0000 (12:26 +0100)]
[X86] matchBinaryShuffle - match PACKUS for v2i64 -> v4i32 shuffle truncation patterns.

Handle PACKUSWD on +SSE41 targets, or fallback to PACKUSBW on any +SSE2 target

13 months ago[X86] Add packus.ll test coverage
Simon Pilgrim [Fri, 21 Jul 2023 10:56:35 +0000 (11:56 +0100)]
[X86] Add packus.ll test coverage

Similar to the existing packss.ll tests

13 months ago[X86] packss.ll - add SSE4.2 test coverage
Simon Pilgrim [Thu, 20 Jul 2023 13:31:02 +0000 (14:31 +0100)]
[X86] packss.ll - add SSE4.2 test coverage