platform/upstream/llvm.git
21 months ago[mlir][Linalg] Add a transform.structured.lower_pack op
Nicolas Vasilache [Fri, 27 Jan 2023 16:24:14 +0000 (08:24 -0800)]
[mlir][Linalg] Add a transform.structured.lower_pack op

This revision introduces `transform.structured.lower_pack` which allows
rewriting a `tensor.pack` to `tensor.pad` + `tensor.expand_shape` + `linalg.transpose`.

The implementation is currently limited to static pack ops that do not have outer_dims permutations.

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

21 months ago[Kaleidoscope] Update code snippets in text to match full code listings
Dhruv Chawla [Tue, 31 Jan 2023 17:56:53 +0000 (23:26 +0530)]
[Kaleidoscope] Update code snippets in text to match full code listings

There were quite a few places in the tutorial where the snippets were not up to date with the full code listings given. I have updated all of the ones I could find, which mostly involves changing `.` to `->` when accessing through a `std::unique_ptr`, changing `while (1)` to `while (true)`, and other such small changes.

There are still however a few places where I am not sure what to do, such as:
- Chapter 4: `ParseTopLevelExpr()` in chapter 3 sets the ProtoTypeAST
             name to "", however it is referred to as "__anon_expr"
             in chapter 4. Would it be required to mention this change
             in chapter 4?
- Chapter 9: The code snippets refer to the top level expression as
             "main", however the full code listing refers to it as
             "__anon_expr". I think given the context of the chapter
             it makes sense to refer to it as "main", so I have
             updated the code listing to reflect that.
- Chapter 9: In chapter 9 the diff given for `HandleTopLevelExpression()`
             deletes code that is not mentioned anywhere else, so I am
             not sure what is to be done there.
- Miscellaneous: I don't think this is very important, however the
                 casing used for the first word of error messages
                 tends to vary between upper and lower case between
                 chapters and I do not know if it is worth reconciling
                 these differences.

Reviewed By: xgupta

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

21 months ago[llvm-c] add LLVMReplaceMDNodeOperandWith
Davide Bertola [Tue, 31 Jan 2023 17:02:50 +0000 (09:02 -0800)]
[llvm-c] add LLVMReplaceMDNodeOperandWith

I'm working on a tool that visits debug info and massages it using the
llvm-c API. I noticed that LLVMGetOperand special cases MDNodes so I
can get their operands, but I can't replace them. This patch adds
LLVMReplaceMDNodeOperandWith which boils down to
MDNode::replaceOperandWith.

The name was chosen for consistency with LLVMGetMDNodeOperands and
LLVMGetMDNodeNumOperands.

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

21 months ago[AST] assert(false) -> llvm_unreachable
Benjamin Kramer [Tue, 31 Jan 2023 17:55:58 +0000 (18:55 +0100)]
[AST] assert(false) -> llvm_unreachable

Has the advantage of not triggering missing return warnings even in
NDEBUG builds.

21 months ago[Clang] Do not attempt to directly link arch tools in 32-bit mode
Joseph Huber [Tue, 31 Jan 2023 17:55:05 +0000 (11:55 -0600)]
[Clang] Do not attempt to directly link arch tools in 32-bit mode

Summary:
We offer almost no support for offloading on 32-bit systems. This causes
some problems when cross-compiling for 32-bit machines as it will find
the CUDA from the host that is incompatible. Instead we force these to
always use the dynamically loaded version, which should always compile.

21 months ago[Clang] Add machinery to catch overflow in unary minus outside of a constant expressi...
Shafik Yaghmour [Tue, 31 Jan 2023 17:33:06 +0000 (09:33 -0800)]
[Clang] Add machinery to catch overflow in unary minus outside of a constant expression context

We provide several diagnostics for various undefined behaviors due to signed
integer overflow outside of a constant expression context. We were missing the
machinery to catch overflows due to unary minus.

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

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

21 months ago[llvm-ifs] Add support for --target=riscv
Alex Brachet [Tue, 31 Jan 2023 17:31:35 +0000 (17:31 +0000)]
[llvm-ifs] Add support for --target=riscv

21 months ago[MTE] Add AArch64GlobalsTagging Pass
Mitch Phillips [Tue, 31 Jan 2023 17:24:13 +0000 (09:24 -0800)]
[MTE] Add AArch64GlobalsTagging Pass

Adds an IR pass for -fsanitize=memtag-globals. This pass goes over the
tag-capable global variables, and replaces them with a tagged global
variable of the same contents. This new global variable will have its
size and alignment adjusted if neccesary so that they're both a multiple
of the tag granule size (16 bytes).

Global merge must also be suppressed for tagged globals, as each global
variable must have a unique tag. This can possibly be relaxed in future;
globals that are identical in size, alignment, and content can possibly
be merged. The major problem comes from tail- or head-merging, which if
left unchecked, could have partially-overlapping global variables with
different memory tags, leading to crashes at runtime.

Reviewed By: fmayer, eugenis

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

21 months ago[RISCV] Handle FRMArg as an optional operand instead of using InstAliases.
Craig Topper [Tue, 31 Jan 2023 17:08:13 +0000 (09:08 -0800)]
[RISCV] Handle FRMArg as an optional operand instead of using InstAliases.

Instead of having InstAliases without operand. Use the optional
operand infrastructure.

Still use the PrintAliases/NoAlias controls to determine if we
print "dyn" or not.

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

21 months ago[clang][WebAssembly] Initial support for reference type externref in clang
Paulo Matos [Mon, 9 Jan 2023 14:15:12 +0000 (15:15 +0100)]
[clang][WebAssembly] Initial support for reference type externref in clang

This patch introduces a new type __externref_t that denotes a WebAssembly opaque
reference type. It also implements builtin __builtin_wasm_ref_null_extern(),
that returns a null value of __externref_t. This lays the ground work
for further builtins and reference types.

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

21 months ago[flang] Single entry point for GET_ENVIRONMENT_VARIABLE
Leandro Lupori [Thu, 19 Jan 2023 17:45:19 +0000 (17:45 +0000)]
[flang] Single entry point for GET_ENVIRONMENT_VARIABLE

This patch refactors the runtime support for GET_ENVIRONMENT_VARIABLE
to have a single entry point instead of 2. It also updates lowering
accordingly.

This makes it easier to handle dynamically optional arguments.
See also https://reviews.llvm.org/D118777

Reviewed By: jeanPerier

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

21 months ago[SanitizerBinaryMetadata] Pretend compiler-generated loads/stores are atomic
Marco Elver [Tue, 31 Jan 2023 16:28:23 +0000 (17:28 +0100)]
[SanitizerBinaryMetadata] Pretend compiler-generated loads/stores are atomic

Profiling and GCOV generate known data-racy loads/stores. Pretend they
are atomic so that analysis using PC-keyed metadata for atomics do not
report them as data races (which would look like false positives).

Reviewed By: dvyukov

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

21 months ago[flang] Suppress a warning in D118631 [-Wunused-result]
Shao-Ce SUN [Tue, 31 Jan 2023 16:24:43 +0000 (00:24 +0800)]
[flang] Suppress a warning in D118631 [-Wunused-result]

Reviewed By: klausler

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

21 months ago[flang] More subscript triplet checking at compilation time
Peter Klausler [Mon, 30 Jan 2023 22:37:48 +0000 (14:37 -0800)]
[flang] More subscript triplet checking at compilation time

When a triplet's lower and upper bounds are the same, we can
check them without requiring a constant stride.

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

21 months ago[flang] Handle missing substring upper bound better when folding
Peter Klausler [Tue, 31 Jan 2023 00:06:09 +0000 (16:06 -0800)]
[flang] Handle missing substring upper bound better when folding

When folding a substring of a named constant or character literal,
acquire the value of a missing upper bound from the base object.

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

21 months ago[clangd] Add semantic token for angle brackets
Christian Kandeler [Wed, 20 Jul 2022 08:57:59 +0000 (10:57 +0200)]
[clangd] Add semantic token for angle brackets

This is needed for clients that would like to visualize matching
opening and closing angle brackets, which can be valuable in non-trivial
template declarations or instantiations.
It is not possible to do this with simple lexing, as the tokens
could also refer to operators.

Reviewed By: kadircet

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

21 months ago[clang-format][NFC] Bring FormatTokenSource under test.
Manuel Klimek [Tue, 31 Jan 2023 16:03:26 +0000 (16:03 +0000)]
[clang-format][NFC] Bring FormatTokenSource under test.

Add tests for FormatTokenSource and harden it against edge cases.

21 months ago[BranchRelaxation] Strengthen post condition assertions
Philip Reames [Tue, 31 Jan 2023 15:50:40 +0000 (07:50 -0800)]
[BranchRelaxation] Strengthen post condition assertions

The whole point of this pass is to rewrite branches so that branches are in bounds. We should assert that we succeeded rather than just that we kept our internal data structure in sync.

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

21 months ago[flang][driver] Add support for -embed-offload-object flag in flang
Jan Sjodin [Fri, 20 Jan 2023 19:33:22 +0000 (14:33 -0500)]
[flang][driver] Add support for -embed-offload-object flag in flang

This patch adds support for the -embed-offload-object flag to embed offloading
binaries in host code. This flag is identical to the clang flag with the same name.

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

Reviewed By: awarzynski, jhuber6

21 months ago[mlir][SubElements] Disambiguate cast<> call for MSVC
Benjamin Kramer [Tue, 31 Jan 2023 15:34:41 +0000 (16:34 +0100)]
[mlir][SubElements] Disambiguate cast<> call for MSVC

For some reason MSVC selects Attribute::cast here, and then fails to
call it because it takes no arguments. Feels like a generic lambda compiler
bug.

mlir/include\mlir/IR/StorageUniquerSupport.h(135): error C2672: 'mlir::Attribute::cast': no matching overloaded function found

21 months ago[PowerPC] Do not convert lwz to lwa if the offset is not a multiple of 4
Nemanja Ivanovic [Tue, 31 Jan 2023 15:52:13 +0000 (09:52 -0600)]
[PowerPC] Do not convert lwz to lwa if the offset is not a multiple of 4

The transform that converts this checks the alignment of the global
object being accessed. However, there was no check for the offset
within the global object which caused the compiler to produce a
DS relocation for an unaligned address.

21 months ago[RISCV] Add asserts that we don't increase codesize during pseudo expansion
Philip Reames [Tue, 31 Jan 2023 15:44:53 +0000 (07:44 -0800)]
[RISCV] Add asserts that we don't increase codesize during pseudo expansion

We currently assume that pseudo expansion doesn't increase the distance between a branch and it's label. This patch adds some asserts to catch violations of this property in pseudo expansion.

I chose to only do the assertion at the function level as we have to scan the whole function for size changes (since expansion can create multiple blocks). We could cache individual block sizes, and thus make the check cheap enough to do after every expansion, but that requires more complex code.

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

21 months ago[LLDB] Do not dereference promise pointer in `coroutine_handle` pretty printer
Adrian Vogelsgesang [Tue, 31 Jan 2023 13:16:04 +0000 (05:16 -0800)]
[LLDB] Do not dereference promise pointer in `coroutine_handle` pretty printer

So far, the pretty printer for `std::coroutine_handle` internally
dereferenced the contained frame pointer displayed the `promise`
as a sub-value. As noticed in https://reviews.llvm.org/D132624
by @labath, this can lead to an endless loop in lldb during printing
if the coroutine frame pointers form a cycle.

This commit breaks the cycle by exposing the `promise` as a pointer
type instead of a value type. The depth to which the `frame variable`
and the `expression` commands dereference those pointers can be
controlled using the `--ptr-depth` argument.

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

21 months ago[AArch64][SME2] Add LLVM IR intrinsics for multi-single dots
David Sherwood [Tue, 31 Jan 2023 15:18:58 +0000 (15:18 +0000)]
[AArch64][SME2] Add LLVM IR intrinsics for multi-single dots

Adds intrinsics for the following SME2 instructions:

* sdot (multi-single, 2 and 4 vectors, 32-bit and 64-bit ZA)
* udot (multi-single, 2 and 4 vectors, 32-bit and 64-bit ZA)
* usdot (multi-single, 2 and 4 vectors)
* sudot (multi-single, 2 and 4 vectors)
* fdot (multi-single, 2 and 4 vectors)
* bfdot (multi-single, 2 and 4 vectors)

NOTE: These intrinsics are still in development and are subject to future changes.

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

21 months ago[clang][CGCall] Remove header file not used. [NFCI]
Francesco Petrogalli [Tue, 31 Jan 2023 15:11:58 +0000 (16:11 +0100)]
[clang][CGCall] Remove header file not used. [NFCI]

Reviewed By: fpetrogalli

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

21 months ago[reland][NFC] Transition GlobalObject alignment from MaybeAlign to Align
Guillaume Chatelet [Tue, 31 Jan 2023 15:02:46 +0000 (15:02 +0000)]
[reland][NFC] Transition GlobalObject alignment from MaybeAlign to Align

This is a follow up on https://reviews.llvm.org/D142459#4081179.
This first patch adds an overload to `GlobalObject::setAlignment` that accepts an `Align` type.
This already handles most of the calls.

This patch also converts a few call sites to the new type when this is safe.

Here is the list of the remaining call sites:

 - [clang/lib/CodeGen/CodeGenModule.cpp:1688](https://github.com/llvm/llvm-project/blob/e195e6bad6706230a4b5fd4b5cc13de1f16f25cc/clang/lib/CodeGen/CodeGenModule.cpp#L1688)
 - [llvm/lib/AsmParser/LLParser.cpp:1309](https://github.com/llvm/llvm-project/blob/e195e6bad6706230a4b5fd4b5cc13de1f16f25cc/llvm/lib/AsmParser/LLParser.cpp#L1309)
 - [llvm/lib/AsmParser/LLParser.cpp:6050](https://github.com/llvm/llvm-project/blob/e195e6bad6706230a4b5fd4b5cc13de1f16f25cc/llvm/lib/AsmParser/LLParser.cpp#L6050)
 - [llvm/lib/Bitcode/Reader/BitcodeReader.cpp:3871](https://github.com/llvm/llvm-project/blob/e195e6bad6706230a4b5fd4b5cc13de1f16f25cc/llvm/lib/Bitcode/Reader/BitcodeReader.cpp#L3871)
 - [llvm/lib/Bitcode/Reader/BitcodeReader.cpp:4030](https://github.com/llvm/llvm-project/blob/e195e6bad6706230a4b5fd4b5cc13de1f16f25cc/llvm/lib/Bitcode/Reader/BitcodeReader.cpp#L4030)
 - [llvm/lib/IR/Core.cpp:2018](https://github.com/llvm/llvm-project/blob/e195e6bad6706230a4b5fd4b5cc13de1f16f25cc/llvm/lib/IR/Core.cpp#L2018)
 - [llvm/lib/IR/Globals.cpp:141](https://github.com/llvm/llvm-project/blob/e195e6bad6706230a4b5fd4b5cc13de1f16f25cc/llvm/lib/IR/Globals.cpp#L141)
 - [llvm/lib/Linker/IRMover.cpp:660](https://github.com/llvm/llvm-project/blob/e195e6bad6706230a4b5fd4b5cc13de1f16f25cc/llvm/lib/Linker/IRMover.cpp#L660)
 - [llvm/lib/Linker/LinkModules.cpp:361](https://github.com/llvm/llvm-project/blob/e195e6bad6706230a4b5fd4b5cc13de1f16f25cc/llvm/lib/Linker/LinkModules.cpp#L361)
 - [llvm/lib/Linker/LinkModules.cpp:362](https://github.com/llvm/llvm-project/blob/e195e6bad6706230a4b5fd4b5cc13de1f16f25cc/llvm/lib/Linker/LinkModules.cpp#L362)
 - [llvm/lib/Transforms/IPO/MergeFunctions.cpp:782](https://github.com/llvm/llvm-project/blob/e195e6bad6706230a4b5fd4b5cc13de1f16f25cc/llvm/lib/Transforms/IPO/MergeFunctions.cpp#L782)
 - [llvm/lib/Transforms/IPO/MergeFunctions.cpp:840](https://github.com/llvm/llvm-project/blob/e195e6bad6706230a4b5fd4b5cc13de1f16f25cc/llvm/lib/Transforms/IPO/MergeFunctions.cpp#L840)
 - [llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp:1813](https://github.com/llvm/llvm-project/blob/e195e6bad6706230a4b5fd4b5cc13de1f16f25cc/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp#L1813)
 - [llvm/tools/llvm-reduce/deltas/ReduceGlobalObjects.cpp:27](https://github.com/llvm/llvm-project/blob/e195e6bad6706230a4b5fd4b5cc13de1f16f25cc/llvm/tools/llvm-reduce/deltas/ReduceGlobalObjects.cpp#L27)

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

21 months ago[clang-format][NFC] Move IndexedTokenSource to FormatTokenSource header.
Manuel Klimek [Tue, 31 Jan 2023 15:06:20 +0000 (15:06 +0000)]
[clang-format][NFC] Move IndexedTokenSource to FormatTokenSource header.

Finish refactoring of the token sources towards a single location.

21 months ago[flang] Improve error message for move_alloc
David Truby [Mon, 30 Jan 2023 15:48:45 +0000 (15:48 +0000)]
[flang] Improve error message for move_alloc

This patch improves the error message when MOVE_ALLOC is passed the same
allocated allocatable as both the to and from arguments.

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

21 months ago[Clang] Improve error message for violations of -fmodules-decluse.
James Y Knight [Mon, 30 Jan 2023 20:05:29 +0000 (15:05 -0500)]
[Clang] Improve error message for violations of -fmodules-decluse.

Now it reports the name of the indirectly-used module which is
missing.

Reviewed By: ChuanqiXu

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

21 months ago[LiveDebugValues] Allow EntryValue with OP_deref expressions
Felipe de Azevedo Piovezan [Thu, 26 Jan 2023 17:47:03 +0000 (12:47 -0500)]
[LiveDebugValues] Allow EntryValue with OP_deref expressions

With D68945, more DBG_VALUEs were created without the indirect operand,
instead relying on OP_deref to accomplish the same effect.

At the time, however, we were not able to handle arbitrary expressions
in combination with OP_LLVM_entry_value, so D71416 prevented the use of
such operation in the presence of expressions.

As per the comment in DIExpression::isValid, "we support only entry
values of a simple register location." As such, a simple deref operation
should be supported. In fact, D80345 added support for indirect
DBG_VALUEs.

Taken the patches above into consideration, this commit relaxes the
restrictions on which expressions are allowed for entry value
candidates: the expression must be either empty or a single dereference
operator.

This patch is useful for D141381, which adds support for storing the
address of ABI-indirect parameters on the stack.

Depends on D142160

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

21 months ago[clang-format][NFC] Pull FormatTokenSource into its own header.
Manuel Klimek [Tue, 31 Jan 2023 13:55:44 +0000 (13:55 +0000)]
[clang-format][NFC] Pull FormatTokenSource into its own header.

Prepare getting FormatTokenSource under unit testing.

21 months ago[mlir] multi-argument binding for top-level transform ops
Alex Zinenko [Wed, 25 Jan 2023 16:53:25 +0000 (16:53 +0000)]
[mlir] multi-argument binding for top-level transform ops

`applyTransforms` now takes an optional mapping to be associated with
trailing block arguments of the top-level transform op, in addition to
the payload root. This allows for more advanced forms of communication
between C++ code and the transform dialect interpreter, in particular
supplying operations without having to re-match them during
interpretation.

Reviewed By: shabalin

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

21 months ago[OpenMP][FIX] Properly check assume only uses
Johannes Doerfert [Tue, 31 Jan 2023 11:33:49 +0000 (03:33 -0800)]
[OpenMP][FIX] Properly check assume only uses

We improved our simplification and this exposed a bug in the store
elimination. A load that had dead uses and assume uses was thought to be
used by assumes only. Consequently we also deleted the "dead use users".
This was a problem because a dead use just means we will not use the
load there. The user might still be needed.

Exposed by OvO, reported by @ye-luo.

21 months agoRevert D142708 "[NFC] Transition GlobalObject alignment from MaybeAlign to Align"
Guillaume Chatelet [Tue, 31 Jan 2023 14:10:25 +0000 (14:10 +0000)]
Revert D142708 "[NFC] Transition GlobalObject alignment from MaybeAlign to Align"

This is breaking the build bots. e.g.,
https://lab.llvm.org/buildbot/#/builders/121/builds/27549

This reverts commit 6717efe74da825214cb4d307ad35e5fbda353301.

21 months ago[NFC] Transition GlobalObject alignment from MaybeAlign to Align
Guillaume Chatelet [Fri, 27 Jan 2023 12:53:40 +0000 (12:53 +0000)]
[NFC] Transition GlobalObject alignment from MaybeAlign to Align

This is a follow up on https://reviews.llvm.org/D142459#4081179.
This first patch adds an overload to `GlobalObject::setAlignment` that accepts an `Align` type.
This already handles most of the calls.

This patch also converts a few call sites to the new type when this is safe.

Here is the list of the remaining call sites:

 - [clang/lib/CodeGen/CodeGenModule.cpp:1688](https://github.com/llvm/llvm-project/blob/e195e6bad6706230a4b5fd4b5cc13de1f16f25cc/clang/lib/CodeGen/CodeGenModule.cpp#L1688)
 - [llvm/lib/AsmParser/LLParser.cpp:1309](https://github.com/llvm/llvm-project/blob/e195e6bad6706230a4b5fd4b5cc13de1f16f25cc/llvm/lib/AsmParser/LLParser.cpp#L1309)
 - [llvm/lib/AsmParser/LLParser.cpp:6050](https://github.com/llvm/llvm-project/blob/e195e6bad6706230a4b5fd4b5cc13de1f16f25cc/llvm/lib/AsmParser/LLParser.cpp#L6050)
 - [llvm/lib/Bitcode/Reader/BitcodeReader.cpp:3871](https://github.com/llvm/llvm-project/blob/e195e6bad6706230a4b5fd4b5cc13de1f16f25cc/llvm/lib/Bitcode/Reader/BitcodeReader.cpp#L3871)
 - [llvm/lib/Bitcode/Reader/BitcodeReader.cpp:4030](https://github.com/llvm/llvm-project/blob/e195e6bad6706230a4b5fd4b5cc13de1f16f25cc/llvm/lib/Bitcode/Reader/BitcodeReader.cpp#L4030)
 - [llvm/lib/IR/Core.cpp:2018](https://github.com/llvm/llvm-project/blob/e195e6bad6706230a4b5fd4b5cc13de1f16f25cc/llvm/lib/IR/Core.cpp#L2018)
 - [llvm/lib/IR/Globals.cpp:141](https://github.com/llvm/llvm-project/blob/e195e6bad6706230a4b5fd4b5cc13de1f16f25cc/llvm/lib/IR/Globals.cpp#L141)
 - [llvm/lib/Linker/IRMover.cpp:660](https://github.com/llvm/llvm-project/blob/e195e6bad6706230a4b5fd4b5cc13de1f16f25cc/llvm/lib/Linker/IRMover.cpp#L660)
 - [llvm/lib/Linker/LinkModules.cpp:361](https://github.com/llvm/llvm-project/blob/e195e6bad6706230a4b5fd4b5cc13de1f16f25cc/llvm/lib/Linker/LinkModules.cpp#L361)
 - [llvm/lib/Linker/LinkModules.cpp:362](https://github.com/llvm/llvm-project/blob/e195e6bad6706230a4b5fd4b5cc13de1f16f25cc/llvm/lib/Linker/LinkModules.cpp#L362)
 - [llvm/lib/Transforms/IPO/MergeFunctions.cpp:782](https://github.com/llvm/llvm-project/blob/e195e6bad6706230a4b5fd4b5cc13de1f16f25cc/llvm/lib/Transforms/IPO/MergeFunctions.cpp#L782)
 - [llvm/lib/Transforms/IPO/MergeFunctions.cpp:840](https://github.com/llvm/llvm-project/blob/e195e6bad6706230a4b5fd4b5cc13de1f16f25cc/llvm/lib/Transforms/IPO/MergeFunctions.cpp#L840)
 - [llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp:1813](https://github.com/llvm/llvm-project/blob/e195e6bad6706230a4b5fd4b5cc13de1f16f25cc/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp#L1813)
 - [llvm/tools/llvm-reduce/deltas/ReduceGlobalObjects.cpp:27](https://github.com/llvm/llvm-project/blob/e195e6bad6706230a4b5fd4b5cc13de1f16f25cc/llvm/tools/llvm-reduce/deltas/ReduceGlobalObjects.cpp#L27)

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

21 months ago[MLIR] Split `generalize-tensor-pack.mlir` (NFC)
Lorenzo Chelini [Mon, 30 Jan 2023 07:06:28 +0000 (08:06 +0100)]
[MLIR] Split `generalize-tensor-pack.mlir` (NFC)

Follow a suggestion after landing https://reviews.llvm.org/D140060.
Having RUN in the middle of the file is difficult to find; split the
test into two.

Reviewed By: hanchung

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

21 months ago[GuardWidening] Choose right point for generating wide condition for branches. PR6023...
Max Kazantsev [Tue, 31 Jan 2023 11:41:25 +0000 (18:41 +0700)]
[GuardWidening] Choose right point for generating wide condition for branches. PR60234. Take 2

There was a crash because there was inconsistency between 'isAvailableAt'
and 'makeAvailableAt' queries. 'makeAvailableAt' is called on conditions
of both guards (dominating and dominated) and 'isAvailableAt' is called
only for dominated guard's condition. Before this patch, it didn't matter
because insertion point always matched the dominating guard. Now, because
they are different, this inconsistency leads to incorrect transforms which
are caught by assert.

The fix is to check 'isAvailableAt' for both conditions.

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

21 months ago[RISCV] Implement isMultiStoresCheaperThanBitsMerge hook
Alex Bradbury [Tue, 31 Jan 2023 12:46:52 +0000 (12:46 +0000)]
[RISCV] Implement isMultiStoresCheaperThanBitsMerge hook

Grabs the same logic and reasoning from the X86 implementation of the
hook. The benefit is slightly less clear for when the soft float ABI is
used (i.e. there's no transfer from an FPR to a GPR), but I've opted not
to gate it based on ABI.

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

21 months ago[flang] derived-type finalization
Valentin Clement [Tue, 31 Jan 2023 12:46:12 +0000 (13:46 +0100)]
[flang] derived-type finalization

This patch implements the derived-type finalization for
monomorphic and polymorphic derived-type.

The finalization is done through a call to the `Destroy`
runtime function so the allocatable component object are also
finalized correctly when needed. It would be possible to finalize
monomorphic derived-type with non finalizable component with a
direct call to their finalize subroutine.

7.5.6.3 point 1: LHS nonallocatable object and LHS allocatable
object finalization. Done with call to `Destroy` for monomorphic
derived-type and through `Assign` for polymorphic entities.

7.5.6.3 point 2: Done within the deallocation calls.

7.5.6.3 point 3: A function context is added to the bridge to
attach finalization that need to happen on function/subroutine
exit.

7.5.6.3 point 4: BLOCK construct not yet implemented.

7.5.6.3 point 5/6: Finalization attach to the stmtCtx in a
similar way than 9.7.3.2 point 4.

7.5.6.3 point 7: INTENT(OUT) finalization done with a
call to `Destroy` runtime function call.

This patch passes 9/10 tests in the proposed test-suite
https://github.com/llvm/llvm-test-suite/pull/13

- The case with BLOCK construct will be implemented later when
  BLOCK are implemented upstream.

- Automatic deallocation is not yet implemented. Finalization triggered
  by automatic deallocation is then not triggered.

Reviewed By: jeanPerier, PeteSteinfeld

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

21 months ago[RISCV][test] Add tests ahead of isMultiStoresCheaperThanBitsMerge hook implementation
Alex Bradbury [Tue, 31 Jan 2023 12:40:47 +0000 (12:40 +0000)]
[RISCV][test] Add tests ahead of isMultiStoresCheaperThanBitsMerge hook implementation

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

21 months agoDAG: Remove redundant check for return alignment
Matt Arsenault [Mon, 30 Jan 2023 22:51:01 +0000 (18:51 -0400)]
DAG: Remove redundant check for return alignment

This is already what the CallBase getRetAlign does

21 months ago[AMDGPU] Use tablegen to list uniform intrinsics
Yashwant Singh [Tue, 31 Jan 2023 12:13:42 +0000 (17:43 +0530)]
[AMDGPU] Use tablegen to list uniform intrinsics

Right now we do opcode wise matching to identify uniform/non-divergent
AMDGPU intrinsics. It is duplicated at 2 places once at IR level uniformity analysis
and at MIR level. Moving them to single tablegen table for consistency and adding
and API rapper to access them.

Reviewed By: arsenm, #amdgpu

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

21 months ago[AArch64][SME2] Add multi-vector min/max intrinsics
Kerry McLaughlin [Tue, 31 Jan 2023 11:47:56 +0000 (11:47 +0000)]
[AArch64][SME2] Add multi-vector min/max intrinsics

Adds intrinsics for the following SME2 instructions:
 - smax, umax, fmax (single, 2 & 4 vector)
 - smax, umax, fmax (multi, 2 & 4 vector)
 - smin, umin, fmin (single, 2 & 4 vector)
 - smin, umin, fmin (multi, 2 & 4 vector)

NOTE: These intrinsics are still in development and are subject to future changes.

Reviewed By: david-arm

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

21 months ago[LoongArch] Add baseline test for (X & Y) == Y and (X & Y) != Y
gonglingqin [Tue, 31 Jan 2023 09:47:54 +0000 (17:47 +0800)]
[LoongArch] Add baseline test for (X & Y) == Y and (X & Y) != Y

Add baseline testing for upcoming optimization patches according the
guideline https://reviews.llvm.org/rG1d6d1ecca7ec.

21 months ago[AArch64][SME2] Add SME2 outer product intrinsics
Kerry McLaughlin [Tue, 31 Jan 2023 10:50:51 +0000 (10:50 +0000)]
[AArch64][SME2] Add SME2 outer product intrinsics

Adds intrinsics for the following:
 - smopa / smops
 - umopa / umops
 - bmopa / bmops

Tests for existing SME mopa/mops intrinsics have also been updated
to use the maximum allowed ZA tile number.

 NOTE: These intrinsics are still in development and are subject
 to future changes.

Reviewed By: david-arm

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

21 months ago[3/3][Clang][RISCV] Add `__riscv_` for overloaded intrinsics
eopXD [Fri, 27 Jan 2023 09:46:11 +0000 (01:46 -0800)]
[3/3][Clang][RISCV] Add `__riscv_` for overloaded intrinsics

This commit adds prefix for the overloaded RVV intrinsics.

This is the 3rd commit of a patch-set to add __riscv_ for all RVV
intrinsics.

This follows the naming guideline under riscv-c-api-doc to add the
`__riscv_` suffix for all RVV intrinsics.

Pull Request:
riscv-non-isa/riscv-c-api-doc#31
riscv-non-isa/rvv-intrinsic-doc#189

Depends on D142644.

Reviewed By: kito-cheng

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

21 months ago[Test] Add motivating test for revert of fix of PR60234
Max Kazantsev [Tue, 31 Jan 2023 11:33:19 +0000 (18:33 +0700)]
[Test] Add motivating test for revert of fix of PR60234

21 months ago[mlir][bufferization] Fix failing lit test
Maya Amrami [Tue, 31 Jan 2023 10:56:59 +0000 (12:56 +0200)]
[mlir][bufferization] Fix failing lit test

Checks were too strict and by the time the patch was submitted,
the output of the test changed.

Reviewed By: springerm

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

21 months ago[Polly] Fix tests (NFC)
Nikita Popov [Tue, 31 Jan 2023 11:05:14 +0000 (12:05 +0100)]
[Polly] Fix tests (NFC)

Missed in 5f01a626dd0615df49773d419c75aeb33666ee83.

21 months ago[PowerPC] Improve materialization for immediates which is almost a 32 bit splat.
esmeyi [Tue, 31 Jan 2023 11:02:17 +0000 (06:02 -0500)]
[PowerPC] Improve materialization for immediates which is almost a 32 bit splat.

Summary: Some 64 bit constants can be materialized with fewer instructions than we currently use. We consider a 64 bit immediate value divided into four parts, Hi16OfHi32 (bits 48...63), Lo16OfHi32 (bits 32...47), Hi16OfLo32 (bits 16...31), Lo16OfLo32 (bits 0...15). When any three parts are equal, the immediate can be treated as "almost" a splat of a 32 bit value in a 64 bit register. For such case, we can use 3 instructions to generate the splat and use 1 instruction to modify the different part:

Reviewed By: shchenz

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

21 months ago[bazel] Add missing includes for 5212058
Goran Flegar [Tue, 31 Jan 2023 10:41:35 +0000 (11:41 +0100)]
[bazel] Add missing includes for 5212058

21 months ago[LICM] Regenerate test checks (NFC)
Nikita Popov [Tue, 31 Jan 2023 10:48:35 +0000 (11:48 +0100)]
[LICM] Regenerate test checks (NFC)

21 months ago[ConstantFold] Fix inbounds inference on mismatching source element type
Nikita Popov [Mon, 30 Jan 2023 14:30:20 +0000 (15:30 +0100)]
[ConstantFold] Fix inbounds inference on mismatching source element type

When inferring that a GEP of a global variable is inbounds because
there is no notional overindexing, we need to check that the
global value type and the GEP source element type match.

This was not necessary with typed pointers (because we would have
a bitcast in between), but is necessary with opaque pointers.

We should be able to recover some of the safe cases by performing
an offset based inbounds inference in DL-aware ConstantFolding.

21 months ago[AArch64] turn extended vecreduce bigger than v16i8 into udot/sdot
Zain Jaffal [Mon, 23 Jan 2023 10:08:33 +0000 (10:08 +0000)]
[AArch64] turn extended vecreduce bigger than v16i8 into udot/sdot

We can do this by breaking vecreduce into v16i8 vectors generating udot/sdot and concatenating them.

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

21 months ago[Clang] Fix typo in ReleaseNotes.rst
Corentin Jabot [Tue, 31 Jan 2023 10:19:30 +0000 (11:19 +0100)]
[Clang] Fix typo in ReleaseNotes.rst

21 months ago[2/3][Clang][RISCV] Add `__riscv_` for non-overloaded intrinsics
eopXD [Thu, 26 Jan 2023 17:01:41 +0000 (09:01 -0800)]
[2/3][Clang][RISCV] Add `__riscv_` for non-overloaded intrinsics

This commit adds prefix for the non-overloaded RVV intrinsics.

This is the 2nd commit of a patch-set to add __riscv_ for all RVV
intrinsics.

This follows the naming guideline under riscv-c-api-doc to add the
`__riscv_` suffix for all RVV intrinsics.

Pull Request:
riscv-non-isa/riscv-c-api-doc#31
riscv-non-isa/rvv-intrinsic-doc#189

Depends on D142085.

Reviewed By: kito-cheng

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

21 months ago[InstCombine] Add additional constexpr gep inbounds tests (NFC)
Nikita Popov [Tue, 31 Jan 2023 10:15:45 +0000 (11:15 +0100)]
[InstCombine] Add additional constexpr gep inbounds tests (NFC)

21 months ago[AArch64] Add additional tests for dotreduce to check for `v4i8` and `v24i8`
Zain Jaffal [Tue, 31 Jan 2023 09:52:34 +0000 (09:52 +0000)]
[AArch64] Add additional tests for dotreduce to check for `v4i8` and `v24i8`

Reviewed By: fhahn

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

21 months ago[Thumb2] Upgrade intrinsic upgrading code
Sergei Barannikov [Mon, 30 Jan 2023 16:07:20 +0000 (19:07 +0300)]
[Thumb2] Upgrade intrinsic upgrading code

Enabling opaque pointers has changed the mangled names of these two ARM
intrinsics:

`arm.mve.vldr.gather.offset.predicated.v2i64.p0i64.v2i64.v4i1`
`arm.mve.vstr.scatter.offset.predicated.p0i64.v2i64.v2i64.v4i1`

They are now spelled as:

`arm.mve.vldr.gather.offset.predicated.v2i64.p0.v2i64.v4i1`
`arm.mve.vstr.scatter.offset.predicated.p0.v2i64.v2i64.v4i1`

Upgrade intrinsic upgrading code to account for the change in names.

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

21 months ago[Clang] Implement Change scope of lambda trailing-return-type
Corentin Jabot [Sun, 6 Feb 2022 21:58:43 +0000 (22:58 +0100)]
[Clang] Implement Change scope of lambda trailing-return-type

This implements P2036R3 and P2579R0.
That is, explicit, int, and implicit capture become visible
at the start of the parameter head.

Reviewed By: aaron.ballman

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

21 months ago[clang][compiler-rt] Support LLVM_ENABLE_PER_TARGET_RUNTIME_DIR on Arm Linux and BSD
David Spickett [Thu, 1 Dec 2022 14:54:17 +0000 (14:54 +0000)]
[clang][compiler-rt] Support LLVM_ENABLE_PER_TARGET_RUNTIME_DIR on Arm Linux and BSD

The orginal single folder layout produced libraries in the form:
lib/linux/<libname>-<archname>.a

That archname for Arm depended on whether you had hard or soft float.
This is sometimes shown as "arm" (soft) vs. "armhf" (hard).

If this is set in a triple we do it in the final portion, the ABI.
"gnueabi" for soft float, "gnueabihf" for hard float.

Meaning that the expected triple is:
arm-unknown-linux-gnueabihf
Not this:
armhf-unknown-linux-gnueabihf

For the per target layout I have decided to rely on the ABI portion
of the triple instead of the arch name used for the old layout
(doing that would produce the invalid triple above).

This means that building with triple:
armv8l-unknown-linux-gnueabihf
Will result in libraries in:
lib/arm-unknown-linux-gnueabihf/

And clang will now know to look for "arm" instead of "armv8l".
Meaning that we can share libraries between an armv8 and armv7 build
as we did with the previous layout. In addition to handling spelling
differences e.g. "armv8l" with an "l" on some Linux distros.

compiler-rt will autodetect that the "armhf" and/or "arm" architecture
can be built. We then replace the given triple's architecture with that.
Then if the triple's float ABI doesn't match, we change that. That new
triple is then used as the folder name.

If you select to build only the given triple, with COMPILER_RT_DEFAULT_TARGET_ONLY,
compiler-rt will not autodetect the architecture and for that I assume you
know what you're doing. In that case the library path will use the unomdified triple.

From what I can tell, this is how most large builds e.g Android and
Arm's Embedded Toolchain for llvm do things. I assume that big endian "armeb"
builds would end up doing this too.

Bare metal builds will not be using per target runtime dirs so they
remain as they were.

Depends on D139536

Reviewed By: MaskRay, phosek

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

21 months agoRevert "[2/3][Clang][RISCV] Add `__riscv_` for non-overloaded intrinsics"
eopXD [Tue, 31 Jan 2023 09:45:42 +0000 (01:45 -0800)]
Revert "[2/3][Clang][RISCV] Add `__riscv_` for non-overloaded intrinsics"

This reverts commit 2153544865a9733b06579823814c981f735e4201.
Buildbot failure https://lab.llvm.org/buildbot#builders/139/builds/35218
shows left-out test cases that were not updated.

21 months ago[2/3][Clang][RISCV] Add `__riscv_` for non-overloaded intrinsics
eopXD [Thu, 26 Jan 2023 17:01:41 +0000 (09:01 -0800)]
[2/3][Clang][RISCV] Add `__riscv_` for non-overloaded intrinsics

This commit adds prefix for the non-overloaded RVV intrinsics.

This is the 2nd commit of a patch-set to add __riscv_ for all RVV
intrinsics.

This follows the naming guideline under riscv-c-api-doc to add the
`__riscv_` suffix for all RVV intrinsics.

Pull Request:
riscv-non-isa/riscv-c-api-doc#31
riscv-non-isa/rvv-intrinsic-doc#189

Depends on D142085.

Reviewed By: kito-cheng

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

21 months ago [mlir][OneShotModuleBufferize] Add a new flag: no-analysis-func-filter
Maya Amrami [Mon, 30 Jan 2023 14:11:56 +0000 (16:11 +0200)]
 [mlir][OneShotModuleBufferize] Add a new flag: no-analysis-func-filter

OneShotModuleBufferize fails if the input IR cannot be analyzed.
One can set CopyBeforeWrite=true in order to skip analysis.
In that case, a buffer copy is inserted on every write.
This leads to many copies, also in FuncOps that could be analyzed.

This change aims to copy buffers only when it is a must.
When running OneShotModuleBufferize with CopyBeforeWrite=false,
FuncOps whose names are specified in noAnalysisFuncFilter will not be
analyzed. Ops in these FuncOps will not be analyzed as well.
They will be bufferized with CopyBeforeWrite=true,
while the other ops will be bufferized with CopyBeforeWrite=false.

Reviewed By: springerm

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

21 months ago[1/3][Clang][RISCV] Add `__riscv_` prefix for vread, vwrite, vlenb, vsetvl, and vsetvlmax
eopXD [Thu, 26 Jan 2023 16:31:56 +0000 (08:31 -0800)]
[1/3][Clang][RISCV] Add `__riscv_` prefix for vread, vwrite, vlenb, vsetvl, and vsetvlmax

This commit adds prefix for intrinsics that are defined through
`HeaderCode` under `riscv_vector.td`.

This is the 1st commit of a patch-set to add `__riscv_` for all RVV
intrinsics.

This follows the naming guideline under riscv-c-api-doc to add the
`__riscv_` suffix for all RVV intrinsics.

Pull Request:
riscv-non-isa/riscv-c-api-doc#31
riscv-non-isa/rvv-intrinsic-doc#189

Depends on D142016.

Reviewed By: kito-cheng

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

21 months ago[flang] Lower storage_size intrinsic for polymorphic entities
Valentin Clement [Tue, 31 Jan 2023 08:44:07 +0000 (09:44 +0100)]
[flang] Lower storage_size intrinsic for polymorphic entities

Lower STOARGE_SIZE intrinsic when the argument is polymoprhic
or unlimited polymorphic. STOARGE_SIZE for monomorphic entity is folded
by the frontend.

Reviewed By: vzakhari, vdonaldson

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

21 months agoRevert "[GuardWidening] Choose right point for generating wide condition for branches...
Max Kazantsev [Tue, 31 Jan 2023 08:37:02 +0000 (15:37 +0700)]
Revert "[GuardWidening] Choose right point for generating wide condition for branches. PR60234"

This reverts commit 5cb568a37a53a9b0fd8fc9c2c35870cad43623e9.

Internal testing found failures, need to investigate.

21 months ago[mlir][vector][bufferize] Fix Windows build failure introduced by D141686
Matthias Springer [Tue, 31 Jan 2023 08:33:06 +0000 (09:33 +0100)]
[mlir][vector][bufferize] Fix Windows build failure introduced by D141686

21 months ago[IR][doc] Alignment is always set in memory for load/store/alloca/cmpxchg/atomicrmw.
Guillaume Chatelet [Thu, 26 Jan 2023 14:08:20 +0000 (14:08 +0000)]
[IR][doc] Alignment is always set in memory for load/store/alloca/cmpxchg/atomicrmw.

Context https://reviews.llvm.org/D142459#4081179

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

21 months agoReland "[mlir][LLVM] Add all LLVM parameter attributes"
Christian Ulmann [Tue, 31 Jan 2023 07:54:52 +0000 (08:54 +0100)]
Reland "[mlir][LLVM] Add all LLVM parameter attributes"

This change was reverted because it introduced a linking issue due to
duplicated symbols. Making sure that the detail helper only has a static
header implementation fixes this issue.

Reviewed By: gysit

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

21 months ago[mlir][vector][bufferize] Bufferize vector.mask and vector.yield
Matthias Springer [Tue, 31 Jan 2023 07:56:03 +0000 (08:56 +0100)]
[mlir][vector][bufferize] Bufferize vector.mask and vector.yield

The masked op can currently not bufferize out-of-place. Such IR would be rejected by the One-Shot Bufferize because it would mean that a new buffer allocation is yielded from a block. Furthermore, only one operation is currently allowed inside `vector.mask`.

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

21 months ago[mlir] Adjust AttributeTest to show skip behavior.
Adrian Kuegel [Tue, 31 Jan 2023 07:08:44 +0000 (08:08 +0100)]
[mlir] Adjust AttributeTest to show skip behavior.

walk() skips identical sub-attributes. Adjust the unit test to show
this.

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

21 months ago[libc] Unify full build and default build static archive targets to just "libc".
Siva Chandra Reddy [Tue, 31 Jan 2023 07:08:49 +0000 (07:08 +0000)]
[libc] Unify full build and default build static archive targets to just "libc".

21 months ago[Fuchsia] Re-enable HWASan for globals in runtimes
Petr Hosek [Mon, 30 Jan 2023 18:54:46 +0000 (18:54 +0000)]
[Fuchsia] Re-enable HWASan for globals in runtimes

This is now supported.

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

21 months ago[runtimes][libc] Keep the libc target as "libc".
Siva Chandra Reddy [Mon, 30 Jan 2023 18:56:22 +0000 (18:56 +0000)]
[runtimes][libc] Keep the libc target as "libc".

It currently renamed to "llvmlibc" under the runtimes/boostrap build.
This prevents us from making a full libc build.

Reviewed By: phosek

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

21 months ago[mlir] Remove redundant virtual keyword. NFC
Adrian Kuegel [Tue, 31 Jan 2023 07:18:51 +0000 (08:18 +0100)]
[mlir] Remove redundant virtual keyword. NFC

Found by ClangTidyLegacy check.

21 months ago[clangd] Stop filtering lit tests based on target-triple
Kadir Cetinkaya [Tue, 31 Jan 2023 07:01:35 +0000 (08:01 +0100)]
[clangd] Stop filtering lit tests based on target-triple

We are performing this filtering due to having unix style file paths in
certain tests. Hence we're actually trying to filter based on host
platform and not the target-triple LLVM is using.

2493a7016416c90038be5c816e12a7ad07cee054 introduced filtering based on
host platform already, so we can get rid of target-triple based
filtering now.

21 months ago[mlir][SubElements] Remove the ability to override implementations
River Riddle [Tue, 31 Jan 2023 06:42:14 +0000 (22:42 -0800)]
[mlir][SubElements] Remove the ability to override implementations

It's much cleaner and simpler to drive wacky configs via the
AttrTypeSubElementHandler interface, instead of override.

21 months ago[GuardWidening] Choose right point for generating wide condition for branches. PR60234
Max Kazantsev [Tue, 31 Jan 2023 05:29:26 +0000 (12:29 +0700)]
[GuardWidening] Choose right point for generating wide condition for branches. PR60234

When guards are represented as widenable branches, there is a tricky
situation when the branch stays in loop but widenable condition doesn't.
It means that the widenable condition is loop-invariant, and some other
optimizations could have done changes using this fact.

If widening is allowed to create widened condition inside this loop,
and join the loop-invariant wc with some non-invariant facts, it can
cause miscompile. See example of this at https://github.com/llvm/llvm-project/issues/60234.

The solution is to adjust the point of generationg the wide condition,
and therefore of hoisting all related parts there. It should not be before
the branch, but before the widenable_condition call. The fact that `wc()`
and the wide condition are in the same block guarantees that they will
not violate the invariance property for any loop.

Differential Revision: https://reviews.llvm.org/D142693
Reviewed By: apilipenko

21 months ago[mlir][vector] Add folder for bitcast of integer splat constants
Quinn Dawkins [Mon, 30 Jan 2023 15:42:42 +0000 (10:42 -0500)]
[mlir][vector] Add folder for bitcast of integer splat constants

This is a similar to the existing folder for f16 to f32 added with
D96041 but instead for integer types where destination bits > source bits.

Reviewed By: ThomasRaoux

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

21 months ago[lldb] Remove unimplemented SBTraceCursor::GetExecutionContextRef
Jonas Devlieghere [Tue, 31 Jan 2023 04:27:28 +0000 (20:27 -0800)]
[lldb] Remove unimplemented SBTraceCursor::GetExecutionContextRef

Fixes TAPI verification error:

  SBTraceCursor.h:130:23: error: declaration has external linkage, but dynamic library doesn't have symbol '__ZN4lldb13SBTraceCursor22GetExecutionContextRefEv'
  SBExecutionContext &GetExecutionContextRef();
                      ^

Remove the method as it doesn't have an implementation.

21 months ago[AVR][NFC] Refactor 'AVRAsmPrinter::PrintAsmOperand'
Ben Shi [Fri, 20 Jan 2023 02:34:08 +0000 (10:34 +0800)]
[AVR][NFC] Refactor 'AVRAsmPrinter::PrintAsmOperand'

Reviewed By: Chenbing.Zheng, aykevl

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

21 months ago[Doc] Removes extra argument of ReplaceInstWithValue()
Vasileios Porpodas [Tue, 31 Jan 2023 01:13:29 +0000 (17:13 -0800)]
[Doc] Removes extra argument of ReplaceInstWithValue()

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

21 months ago[PowerPC] Pre-commit test for fix to peephole opt
Nemanja Ivanovic [Tue, 31 Jan 2023 02:59:51 +0000 (20:59 -0600)]
[PowerPC] Pre-commit test for fix to peephole opt

This just adds a test case with current code gen. The patch
with the fix will correct the code gen.

21 months ago[lldb,FreeBSD] getValue => operator* for Optional migration
Fangrui Song [Tue, 31 Jan 2023 02:57:54 +0000 (18:57 -0800)]
[lldb,FreeBSD] getValue => operator* for Optional migration

21 months ago[InstCombine][LV] Fold (add (zext (add X, -1)), 1) -> (zext X) if X is non-zero.
Craig Topper [Tue, 31 Jan 2023 01:45:01 +0000 (17:45 -0800)]
[InstCombine][LV] Fold (add (zext (add X, -1)), 1) -> (zext X) if X is non-zero.

This artifact can appear from the vectorizer. (add X, -1) is the
backedge taken count. It gets zero extended and then 1 is added to
it to get the trip count.

There is usually a dominating branch that rules out X being zero.

Alive: https://alive2.llvm.org/ce/z/NsRDwX

21 months ago[InstCombine] Add test cases for D142783. NFC"
Craig Topper [Tue, 31 Jan 2023 01:44:55 +0000 (17:44 -0800)]
[InstCombine] Add test cases for D142783. NFC"

21 months ago[MLIR] Remove unnecessary Block argument on MemRefDependenceGraph::init
Uday Bondhugula [Tue, 31 Jan 2023 01:22:45 +0000 (06:52 +0530)]
[MLIR] Remove unnecessary Block argument on MemRefDependenceGraph::init

Remove unnecessary Block argument on MemRefDependenceGraph::init.
`block` is already a field on MDG.

Reviewed By: dcaballe

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

21 months ago[mlir][vector] Clarify vector.contract promotion behavior
Lei Zhang [Tue, 31 Jan 2023 00:05:19 +0000 (00:05 +0000)]
[mlir][vector] Clarify vector.contract promotion behavior

This commit updates vector.contract documentation to clarify
the promotion behavior if operands and the result have different
bitwidths. It also adds a check to disable signed/unsigned integer
types and only allow signless integers.

Reviewed By: ThomasRaoux

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

21 months ago[NFC] Correct argument comment typo
Gregory Alfonso [Tue, 31 Jan 2023 00:06:45 +0000 (16:06 -0800)]
[NFC] Correct argument comment typo

For Darwin, the boolean being passed is called IsSimulator, not "IsImulator"

Reviewed By: MaskRay

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

21 months ago[Libomptarget] Fix building AMDGPU tests
Joseph Huber [Mon, 30 Jan 2023 23:52:04 +0000 (17:52 -0600)]
[Libomptarget] Fix building AMDGPU tests

Summary:
Accidentally deleted this.

21 months ago[RISCV] Peak through BITCAST in isUsedByReturnOnly
Luke Lau [Mon, 30 Jan 2023 17:51:12 +0000 (17:51 +0000)]
[RISCV] Peak through BITCAST in isUsedByReturnOnly

A follow up to 47b1f8362aa409b591b5e9c8a9ff0e3e1d76ed9c,
This covers some more cases on soft-float ABIs with the f/d extension.
I left the TODO in as there is still the case where we need to handle rv32i without f/d, but that looks like it requires changes to SelectionDAGLegalize::ExpandFPLibCall

Reviewed By: asb, reames

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

21 months ago[flang] Use proper attributes for runtime calls with 'i1' arguments/returns.
Slava Zakharin [Sat, 28 Jan 2023 02:14:00 +0000 (18:14 -0800)]
[flang] Use proper attributes for runtime calls with 'i1' arguments/returns.

Clang uses signext/zeroext attributes for integer arguments shorter than
the default 'int' type on a target. So Flang has to match this for functions
from Fortran runtime and also for BIND(C) routines. This patch implements
ABI adjustments only for Fortran runtime calls. BIND(C) part will be done
separately.

This resolves https://github.com/llvm/llvm-project/issues/58579

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

21 months ago[X86] Move RDFLAGS/WRFLAGS expansion until after RA
Bill Wendling [Mon, 30 Jan 2023 21:19:52 +0000 (13:19 -0800)]
[X86] Move RDFLAGS/WRFLAGS expansion until after RA

The register allocator may introduce reloads in the middle of reading
and writing the EFLAGS register, due to the RDFLAGS & WRFLAGS pseudos
being expanded before RA. This may cause an issue where the stack
pointer was adjusted but the stack offset for the reload wasn't
accounted for (see [1]).

To avoid this, expand these pseudos after register allocation.

[1] https://github.com/llvm/llvm-project/issues/59102

Reviewed By: craig.topper, nickdesaulniers, pengfei

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

21 months agolld/COFF: simplify startswith+substr
Fangrui Song [Mon, 30 Jan 2023 23:28:10 +0000 (15:28 -0800)]
lld/COFF: simplify startswith+substr

21 months ago[hwasan] Support __lsan_default_options
Fangrui Song [Mon, 30 Jan 2023 23:07:46 +0000 (15:07 -0800)]
[hwasan] Support __lsan_default_options

Reviewed By: vitalybuka

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

21 months ago[lldb/test] Skip TestStackCoreScriptedProcess if Asan is enabled
Med Ismail Bennani [Mon, 30 Jan 2023 23:01:31 +0000 (15:01 -0800)]
[lldb/test] Skip TestStackCoreScriptedProcess if Asan is enabled

This patch skips TestStackCoreScriptedProcess because the test times out
when the Address Sanitizer is running.

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
21 months ago[PowerPC] Fix incorrect shift amount for build_vector
Nemanja Ivanovic [Mon, 30 Jan 2023 22:34:50 +0000 (16:34 -0600)]
[PowerPC] Fix incorrect shift amount for build_vector

The pattern for a build_vector node was incorrect for big endian
subtargets.

21 months ago[flang] Fixed Flang LIT testing after D142548.
Slava Zakharin [Mon, 30 Jan 2023 22:35:31 +0000 (14:35 -0800)]
[flang] Fixed Flang LIT testing after D142548.

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

21 months ago[LSAN][HWASAN] Run LSAN tests with HWASAN enabled
Kirill Stoimenov [Mon, 30 Jan 2023 20:20:55 +0000 (20:20 +0000)]
[LSAN][HWASAN] Run LSAN tests with HWASAN enabled

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

Reviewed By: vitalybuka

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