platform/upstream/llvm.git
17 months agoInlining: Run the legacy AlwaysInliner before the regular inliner.
Amara Emerson [Thu, 9 Feb 2023 03:52:00 +0000 (19:52 -0800)]
Inlining: Run the legacy AlwaysInliner before the regular inliner.

We have several situations where it's beneficial for code size to ensure that every
call to always-inline functions are inlined before normal inlining decisions are
made. While the normal inliner runs in a "MandatoryOnly" mode to try to do this,
it only does it on a per-SCC basis, rather than the whole module. Ensuring that
all mandatory inlinings are done before any heuristic based decisions are made
just makes sense.

Despite being referred to the "legacy" AlwaysInliner pass, it's already necessary
for -O0 because the CGSCC inliner is too expensive in compile time to run at -O0.

This also fixes an exponential compile time blow up in
https://github.com/llvm/llvm-project/issues/59126

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

17 months ago[MLIR] Fix non-deterministic generation from buffer-deallocation pass
Uday Bondhugula [Thu, 9 Feb 2023 22:38:39 +0000 (04:08 +0530)]
[MLIR] Fix non-deterministic generation from buffer-deallocation pass

The buffer-deallocation pass generates a different output on each run
due to an unstable iteration order.

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

Reviewed By: mehdi_amini

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

17 months ago[ValueTracking] Replace an always false condition with an assert. NFC
Craig Topper [Thu, 9 Feb 2023 23:19:18 +0000 (15:19 -0800)]
[ValueTracking] Replace an always false condition with an assert. NFC

The one caller of this function already checked that V isn't a
Constant.

Alternatively, we could remove the check from the caller if reviewers
prefer.

Reviewed By: spatel

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

17 months agoAdd missing cases to clang switch after D141863
Krzysztof Drewniak [Thu, 9 Feb 2023 22:56:25 +0000 (22:56 +0000)]
Add missing cases to clang switch after D141863

Turns out there's a switch on APFloat semantics in clang I wasn't
aware of, fix the build error here.

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

17 months ago[Tooling/Inclusion] Use the StdSpecialSymbolMap.inc in the stdlib
Haojian Wu [Wed, 8 Feb 2023 08:41:55 +0000 (09:41 +0100)]
[Tooling/Inclusion] Use the StdSpecialSymbolMap.inc in the stdlib

Remove a special-case in clangd.

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

17 months ago[llvm-lib] Write object files in reversed order.
Jacek Caban [Thu, 9 Feb 2023 22:46:20 +0000 (00:46 +0200)]
[llvm-lib] Write object files in reversed order.

This isn't strictly needed, but this matches how MSVC lib.exe writes to
archives, so this makes llvm-lib more compatible and simplifies comparing
output between tools.

Reviewed By: hans

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

17 months ago[ELF][docs] Mention LLD_REPRODUCE and LLD_VERSION
Fangrui Song [Thu, 9 Feb 2023 22:38:17 +0000 (14:38 -0800)]
[ELF][docs] Mention LLD_REPRODUCE and LLD_VERSION

Reviewed By: peter.smith

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

17 months ago[flang] Fixed build after D142977. Added missing link to HLFIRDialect.
Slava Zakharin [Thu, 9 Feb 2023 22:10:36 +0000 (14:10 -0800)]
[flang] Fixed build after D142977. Added missing link to HLFIRDialect.
Differential Revision: https://reviews.llvm.org/D142977

17 months ago[llvm][APFloat] Add NaN-in-negative-zero formats by AMD and GraphCore
Krzysztof Drewniak [Tue, 10 Jan 2023 21:18:10 +0000 (21:18 +0000)]
[llvm][APFloat] Add NaN-in-negative-zero formats by AMD and GraphCore

AMD, GraphCore, and Qualcom have published a standard for 8-bit floats that
differs from the 8-bit floats defined by Nvidia, Intel, and ARM. This
commit adds support for these alternate 8-bit floats to APFloat in
order to enable their usage in MLIR. These formats are presented in
the paper at https://arxiv.org/abs/2206.02915 and are implemented in
GRaphCore hardware whose ISA is available at
https://docs.graphcore.ai/projects/isa-mk2-with-fp8/en/latest/_static/TileVertexISA-IPU21-1.3.1.pdf .

In these formats, like the existing Float8E4M3FN, there are no
infinity values and there is only one NaN. Unlike in that format,
however, the NaN values is 0x80, which would be negative 0 in IEEE
formats. This means that these formats also make 0 unsigned.

To allow for these new variant semantics, this commit adds
fltNanEncoding, which can be IEEE (the default), AllOnes (used by
Fleat8E4M3FN), or NegativeZero (used by the new formats,
Float8E5M2FNUZ and Float8E4M3FNUZ). Normalization, arithmetic, and
other such routines have been updated to account for the potential
variant semantics.

The two new formats are Float8E5M2FNUZ (5 bits exponent, 2 bits
mantissa, finite, unsigned zero) and Float8E4M3FNUZ (4 bits exponent,
3 bits mantissa, finite, unsigned zero).

Reviewed By: jakeh-gc, reedwm, lattner

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

17 months ago[libc][NFC] reorganize structs in printf
Michael Jones [Fri, 3 Feb 2023 21:13:23 +0000 (13:13 -0800)]
[libc][NFC] reorganize structs in printf

Previously the type description structs were defined in the parser. For
the fuzzing targets we'll need to use those, so I've moved them into
core_structs.h. Additionally I've renamed the function for determining
the TypeDesc from a given type. Previously it shared its name with
get_type_desc which is a related but separate function that is a part of
the parser.

Reviewed By: lntue

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

17 months ago[mlir][Memref] Add memref.memory_space_cast and its lowerings
Krzysztof Drewniak [Mon, 9 Jan 2023 16:04:09 +0000 (16:04 +0000)]
[mlir][Memref] Add memref.memory_space_cast and its lowerings

Address space casts are present in common MLIR targets (LLVM, SPIRV).
Some planned rewrites (such as one of the potential fixes to the fact
that the AMDGPU backend requires alloca() to live in address space 5 /
the GPU private memory space) may require such casts to be inserted
into MLIR code, where those address spaces could be represented by
arbitrary memory space attributes.

Therefore, we define memref.memory_space_cast and its lowerings.

Depends on D141293

Reviewed By: ftynse

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

17 months ago[libc] Fix layering for bazel
Guillaume Chatelet [Thu, 9 Feb 2023 21:35:16 +0000 (21:35 +0000)]
[libc] Fix layering for bazel

17 months ago[clang-format] Insert a space between a numeric UDL and a dot
Owen Pan [Wed, 8 Feb 2023 02:36:28 +0000 (18:36 -0800)]
[clang-format] Insert a space between a numeric UDL and a dot

Fixes #60576.

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

17 months ago[DWARFLinker] Fix typo and improve comments (NFC)
Jonas Devlieghere [Thu, 9 Feb 2023 21:17:12 +0000 (13:17 -0800)]
[DWARFLinker] Fix typo and improve comments (NFC)

Fix a typo and improve comments to match the LLVM coding style.

17 months ago[lldb] Add the ability to remove diagnostic callbacks
Jonas Devlieghere [Thu, 9 Feb 2023 21:00:45 +0000 (13:00 -0800)]
[lldb] Add the ability to remove diagnostic callbacks

Add the ability to remove diagnostic callbacks. This is necessary for
diagnostics who's lifetime is tied to objects that can be destroyed.

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

17 months ago[AMDGPU] Refactor multiclass FLAT_Atomic_Pseudo. NFC.
Jay Foad [Fri, 3 Feb 2023 11:29:45 +0000 (11:29 +0000)]
[AMDGPU] Refactor multiclass FLAT_Atomic_Pseudo. NFC.

This is just for consistency with FLAT_Global_Atomic_Pseudo.

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

17 months ago[mlir][Linalg] NFC - Fail gracefully instead of crashing in SplitReduction
Nicolas Vasilache [Thu, 9 Feb 2023 20:59:38 +0000 (12:59 -0800)]
[mlir][Linalg] NFC - Fail gracefully instead of crashing in SplitReduction

17 months ago[mlir][sparse] fix integration test with "VLA" run
Aart Bik [Thu, 9 Feb 2023 20:36:10 +0000 (12:36 -0800)]
[mlir][sparse] fix integration test with "VLA" run

Reviewed By: Peiming

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

17 months ago[bazel] Port 499abb243c
Benjamin Kramer [Thu, 9 Feb 2023 20:35:08 +0000 (21:35 +0100)]
[bazel] Port 499abb243c

17 months ago[HWASAN] Add support for max_allocation_size_mb option
Kirill Stoimenov [Thu, 9 Feb 2023 18:23:06 +0000 (18:23 +0000)]
[HWASAN] Add support for max_allocation_size_mb option

Reviewed By: vitalybuka

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

17 months ago[llvm-c-test] Fix leak after D138415
Fangrui Song [Thu, 9 Feb 2023 20:17:26 +0000 (12:17 -0800)]
[llvm-c-test] Fix leak after D138415

17 months ago[mlir][memref] annotate operand and result of realloc with proper memory attributes
Aart Bik [Thu, 9 Feb 2023 18:53:44 +0000 (10:53 -0800)]
[mlir][memref] annotate operand and result of realloc with proper memory attributes

Reviewed By: springerm

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

17 months ago[RISCV] Implement a proposed mapping for Ztso
Philip Reames [Thu, 9 Feb 2023 19:45:10 +0000 (11:45 -0800)]
[RISCV] Implement a proposed mapping for Ztso

This change implements a proposed lowering from LLVM's memory model to the TSO memory model defined by the Ztso extension. Selecting the proposed mapping turns out to be an involved conversation that really didn't fit within a review description, so let me refer you to https://github.com/preames/public-notes/blob/master/riscv-tso-mappings.rst. This review implements the WMO compatible variant (the proposed one in that document).

Ztso is currently accepted as an experimental extension in LLVM. Despite the fact the extension was recently ratified, I think we need to leave it as experimental until we have wide agreement on the chosen mapping for ABI purposes.

I need to note that the current in-tree implementation defaults to generating WMO compatible fences. This is entirely compatible with the proposed mapping in this patch, but is unfortunately not compatible with the major alternative. The in tree implementation is explicitly experimental so the impact of this is limited, but it is worth calling out that if settle on the alternative we will have a minor ABI break. My apologies for not calling this out in the original patch; I had not realized at the time that one of our realistic choices for mappings wouldn't be WMO compatible.

This patch only contains the changes for load/store and fence. That is, it does not change the lowering for atomicrmw operations. This is a sound thing to do under the proposed mapping since the existing WMO mappings remain compatible. I do plan to change these; I'm just working incrementally.

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

17 months ago[Flang] Add Any and All intrinsics to simplify intrinsics pass
Sacha Ballantyne [Thu, 9 Feb 2023 18:57:04 +0000 (18:57 +0000)]
[Flang] Add Any and All intrinsics to simplify intrinsics pass

This patch provides a simplified version of the Any intrinsic as well as the All intrinsic
that can be used for inlining or simpiler use cases. These changes are targeting exchange2, and
provide a ~9% performance increase.

Reviewed By: Leporacanthicus, vzakhari

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

17 months ago[clang][deps] Migrate ModuleDepCollector to LexedFileChanged NFCI
Ben Langmuir [Wed, 8 Feb 2023 23:34:50 +0000 (15:34 -0800)]
[clang][deps] Migrate ModuleDepCollector to LexedFileChanged NFCI

LexedFileChanged has the semantics we want of ignoring #line/etc. It's
also consistent with other dep collectors like DependencyFileGenerator.

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

17 months ago[MachineOutliner] Make getOutliningType partially target-independent
duk [Thu, 9 Feb 2023 19:30:19 +0000 (14:30 -0500)]
[MachineOutliner] Make getOutliningType partially target-independent

The motivation behind this patch is to unify some of the outliner logic across architectures. This looks nicer in general and makes fixing [issues like this](https://reviews.llvm.org/D124707#3483805) easier.
There are some notable changes here:
    1. `isMetaInstruction()` is used directly instead of checking for specific meta-instructions like `IMPLICIT_DEF` or `KILL`. This was already done in the RISC-V implementation, but other architectures still did hardcoded checks.
        - As an exception to this, CFI instructions are explicitly delegated to the target because RISC-V has different handling for those.

    2. `isTargetIndex()` checks are replaced with an assert; none of the architectures supported actually use `MO_TargetIndex` at this point in time.

    3. `isCFIIndex()` and `isFI()` checks are also replaced with asserts, since these operands should not exist in [any context](https://reviews.llvm.org/D122635#3447214) at this stage in the pipeline.

Reviewed by: paquette

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

17 months ago[flang] Fix polymorphic-temp.f90 tests
Valentin Clement [Thu, 9 Feb 2023 19:30:49 +0000 (20:30 +0100)]
[flang] Fix polymorphic-temp.f90 tests

17 months ago[flang] Support polymorphic inputs for TRANSFER intrinsic
Valentin Clement [Thu, 9 Feb 2023 19:17:10 +0000 (20:17 +0100)]
[flang] Support polymorphic inputs for TRANSFER intrinsic

Result must carry the polymorphic type information from the mold.

Reviewed By: jeanPerier

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

17 months ago[mlir] Handle different pointer sizes in unranked memref descriptors
Krzysztof Drewniak [Mon, 9 Jan 2023 15:56:22 +0000 (15:56 +0000)]
[mlir] Handle different pointer sizes in unranked memref descriptors

The code for unranked memref descriptors assumed that
sizeof(!llvm.ptr) == lizeof(!llvm.ptr<N>) for all address spaces N.
This is not always true (ex. the AMDGPU compiler backend has
sizeof(!llvm.ptr) = 64 bits but sizeof(!llvm.ptr<5>) = 32 bits, where
address space 5 is used for stack allocations). While this is merely
an overallocation in the case where a non-0 address space has pointers
smaller than the default, the existing code could cause OOB memory
accesses when sizeof(!llvm.ptr<N>) > sizeof(!llvm.ptr).

So, add an address spaces parameter to computeSizes in order to
partially resolve this class of bugs. Note that the LLVM data layout
in the conversion passes is currently set to "" and not constructed
from the MLIR data layout or some other source, but this could change
in the future.

Depends on D142159

Reviewed By: ftynse

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

17 months ago[flang] Support polymorphic inputs for EOSHIFT intrinsic
Valentin Clement [Thu, 9 Feb 2023 14:23:48 +0000 (06:23 -0800)]
[flang] Support polymorphic inputs for EOSHIFT intrinsic

Result must carry the polymorphic type information from the array.

17 months ago[libclang] Add "global:" to the module map explicitly; NFC intended
Aaron Ballman [Thu, 9 Feb 2023 19:00:58 +0000 (14:00 -0500)]
[libclang] Add "global:" to the module map explicitly; NFC intended

17 months ago[BOLT] Rename BF::isParentFragment -> isChildOf
Amir Ayupov [Thu, 9 Feb 2023 18:56:55 +0000 (10:56 -0800)]
[BOLT] Rename BF::isParentFragment -> isChildOf

`isChildOf` is a more concise name for the check. Also, there's no need to
test if the function is a fragment before doing `isChildOf` check.

Reviewed By: #bolt, rafauler, maksfb

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

17 months ago[BOLT][Wrapper] Don't compare output upon error exit code
Amir Ayupov [Thu, 9 Feb 2023 18:54:53 +0000 (10:54 -0800)]
[BOLT][Wrapper] Don't compare output upon error exit code

Fix llvm-bolt-wrapper to skip output file checks if llvm-bolt exits with error
code.

Test Plan:
- checkout to revision with invalid NFC mismatch in `is-strip.s` test
  (e.g. 056af487831fb573e6895901d1e48f93922f9635~)
- run `nfc-check-setup.py`
- run `bin/llvm-lit -a tools/bolt/test/X86/is-strip.s`

Reviewed By: #bolt, rafauler

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

17 months ago[clangd] Fix getQueryScopes for using-directive with inline namespace
Tom Praschan [Sun, 29 Jan 2023 16:02:56 +0000 (17:02 +0100)]
[clangd] Fix getQueryScopes for using-directive with inline namespace

For example, in the following code

```

using namespace std::string_literals;

int main() {
    strin^ // Completes `string` instead of `std::string`
}
```

The using declaration would make completion drop the std namespace, even though it shouldn't.

printNamespaceScope() skips inline namespaces, so to fix this use
printQualifiedName() instead

See https://github.com/clangd/clangd/issues/1451

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

17 months agoRevert "HHVM calling conventions."
Amir Aupov [Thu, 9 Feb 2023 18:52:51 +0000 (10:52 -0800)]
Revert "HHVM calling conventions."

This reverts commit cce239c45d6ef3865a017b5b3f935964e0348734.

HHVM calling conventions are unused. Remove them by partially reverting the commit.

Reviewed By: MaskRay, MatzeB

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

17 months ago[bazel] Fix libc
Fangrui Song [Thu, 9 Feb 2023 18:46:25 +0000 (18:46 +0000)]
[bazel] Fix libc

17 months agoRemove test case that tries to allocate impossible amounts
Jason Molenda [Thu, 9 Feb 2023 18:43:13 +0000 (10:43 -0800)]
Remove test case that tries to allocate impossible amounts

The sanitizer bots are failing with this test; they
impose a maximum 0x10000000000 size on allocations, and
malloc on darwin will let me malloc that much.  The
alternative to keep this would be to break it out into a
seperate test in TestProcessAIP and skip that if it's on
the sanitizer, but this is seeming too fragile IMO so I'm
punting it entirely.

17 months ago[Inliner] Remove legacy simple inliner
Arthur Eubanks [Mon, 6 Feb 2023 21:50:49 +0000 (13:50 -0800)]
[Inliner] Remove legacy simple inliner

It's part of the optimization pipeline, of which the legacy pass manager version is deprecated.

17 months agoRevert "[mlir] Add function for checking if a block is inside a loop"
Kiran Chandramohan [Thu, 9 Feb 2023 18:35:38 +0000 (18:35 +0000)]
Revert "[mlir] Add function for checking if a block is inside a loop"

Reverting since the shared library builds are failing.

This reverts commit dcee187522c6e2e1a56ffc9b58bfe11c6ac44662.

17 months ago[Flang][OpenMP] Do not consider procedure names for data-sharing
Kiran Chandramohan [Thu, 9 Feb 2023 17:44:49 +0000 (17:44 +0000)]
[Flang][OpenMP] Do not consider procedure names for data-sharing

An incorrect error was issued for procedure names occuring in OpenMP
regions with default clause set to NONE. Fix is to ignore all cases
where names are various kinds of procedures.

Fixes issue https://github.com/flang-compiler/f18-llvm-project/issues/1350

Reviewed By: peixin

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

17 months ago[MTE stack] fix incorrect offset for st2g
Florian Mayer [Wed, 8 Feb 2023 02:03:43 +0000 (18:03 -0800)]
[MTE stack] fix incorrect offset for st2g

Reviewed By: eugenis

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

17 months agoAdd generic type attribute mapping infrastructure, use it in GpuToX
Krzysztof Drewniak [Thu, 19 Jan 2023 21:56:04 +0000 (21:56 +0000)]
Add generic type attribute mapping infrastructure, use it in GpuToX

Remapping memory spaces is a function often needed in type
conversions, most often when going to LLVM or to/from SPIR-V (a future
commit), and it is possible that such remappings may become more
common in the future as dialects take advantage of the more generic
memory space infrastructure.

Currently, memory space remappings are handled by running a
special-purpose conversion pass before the main conversion that
changes the address space attributes. In this commit, this approach is
replaced by adding a notion of type attribute conversions
TypeConverter, which is then used to convert memory space attributes.

Then, we use this infrastructure throughout the *ToLLVM conversions.
This has the advantage of loosing the requirements on the inputs to
those passes from "all address spaces must be integers" to "all
memory spaces must be convertible to integer spaces", a looser
requirement that reduces the coupling between portions of MLIR.

ON top of that, this change leads to the removal of most of the calls
to getMemorySpaceAsInt(), bringing us closer to removing it.

(A rework of the SPIR-V conversions to use this new system will be in
a folowup commit.)

As a note, one long-term motivation for this change is that I would
eventually like to add an allocaMemorySpace key to MLIR data layouts
and then call getMemRefAddressSpace(allocaMemorySpace) in the
relevant *ToLLVM in order to ensure all alloca()s, whether incoming or
produces during the LLVM lowering, have the correct address space for
a given target.

I expect that the type attribute conversion system may be useful in
other contexts.

Reviewed By: ftynse

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

17 months ago[lldb] Print an error for unsupported combinations of log options
Jonas Devlieghere [Thu, 9 Feb 2023 17:04:44 +0000 (09:04 -0800)]
[lldb] Print an error for unsupported combinations of log options

Print an error for unsupported combinations of log handlers and log
options. Only the stream log handler takes a file and only the circular
and stream handler take a buffer size. This cannot be dealt with through
option groups because the option combinations depend on the requested
handler.

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

17 months ago[MLGO] Update test for MBB Profile Dump
Aiden Grossman [Thu, 9 Feb 2023 17:46:26 +0000 (17:46 +0000)]
[MLGO] Update test for MBB Profile Dump

This patch updates the test for the MBB profile dump to include a
function that has multiple basic blocks so that we can test the
numbering of multiple basic blocks within an individual function.

17 months ago[flang] Support polymorphic inputs for CSHIFT intrinsic
Valentin Clement [Thu, 9 Feb 2023 17:20:15 +0000 (18:20 +0100)]
[flang] Support polymorphic inputs for CSHIFT intrinsic

Result must carry the polymorphic type information from the array.

Reviewed By: jeanPerier

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

17 months ago[TTI][AArch64] Cost model insertelement and indexed LD1 instructions
Sjoerd Meijer [Thu, 9 Feb 2023 16:07:17 +0000 (16:07 +0000)]
[TTI][AArch64] Cost model insertelement and indexed LD1 instructions

An indexed LD1 instruction, or "ASIMD load, 1 element, one lane, B/H/S"
instruction that loads a value and inserts an element into a vector is
an expensive instruction. It has a latency of 8 on modern cores. We
generate an indexed LD1 when an insertelement instruction has a load as an
operand and this patch is recognising and makes indexed LD1 more expensive.

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

17 months ago[z/OS][pg] Throw error when using -pg on z/OS
Michael Francis [Mon, 9 Jan 2023 18:35:54 +0000 (18:35 +0000)]
[z/OS][pg] Throw error when using -pg on z/OS

Throw an error when trying to compile with `-pg` on z/OS,
as the platform does not support `gprof`.

Reviewed By: cebowleratibm, MaskRay

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

17 months ago[Clang][AIX][p]Enable -p Functionality
Michael Francis [Wed, 18 Jan 2023 19:38:02 +0000 (19:38 +0000)]
[Clang][AIX][p]Enable -p Functionality

This patch enables `-p` functionality into Clang on AIX and Linux
To create parity with GCC.

The purpose of the `-p` flag is similar to that of `-pg`, but the
results are analyzed with the `prof` tool as opposed to the `gprof` tool.
More details can be found in this RFC post:
https://discourse.llvm.org/t/rfc-add-p-driver-support-to-clang/66013?u=francii

On AIX, compiling with `-p` links against `mcrt0.o`
and produces a mon.out file analyzed with the `prof` tool,
while `-pg` links against `gcrt0.o` and produces a `gmon.out`file
analyzed with the `gprof` tool. The differences are therefore
only a concern when linking, so calling `-p` will push `-pg` to cc1.

An AIX test for `-p` already exists, and I recently
another test was added here:
https://github.com/llvm/llvm-project/commit/dc9846ce988b9ddfcbc42cd462d5d94b634b3161
As such, there is no AIX test case attached to this patch.

Reviewed By: daltenty

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

17 months ago[SelectionDAG] Do not second-guess alignment for alloca
Andrew Savonichev [Thu, 9 Feb 2023 15:45:20 +0000 (18:45 +0300)]
[SelectionDAG] Do not second-guess alignment for alloca

Alignment of an alloca in IR can be lower than the preferred alignment
on purpose, but this override essentially treats the preferred
alignment as the minimum alignment.

The patch changes this behavior to always use the specified
alignment. If alignment is not set explicitly in LLVM IR, it is set to
DL.getPrefTypeAlign(Ty) in computeAllocaDefaultAlign.

Tests are changed as well: explicit alignment is increased to match
the preferred alignment if it changes output, or omitted when it is
hard to determine the right value (e.g. for pointers, some structs, or
weird types).

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

17 months ago[X86] combineConcatVectorOps - pull out repeated uses of VT.getScalarSizeInBits(...
Simon Pilgrim [Thu, 9 Feb 2023 15:43:10 +0000 (15:43 +0000)]
[X86] combineConcatVectorOps - pull out repeated uses of VT.getScalarSizeInBits(). NFC.

We already have a EltSizeInBits variable

17 months ago[AMDGPU][GlobalISel] Fix selection of image sample g16 instructions
Mirko Brkusanin [Thu, 9 Feb 2023 15:26:39 +0000 (16:26 +0100)]
[AMDGPU][GlobalISel] Fix selection of image sample g16 instructions

Pre-GFX10 A16 modifier would imply G16. From GFX10 and onwards there are
separate instructions for 16bit gradients. This fixes the condition for
selecting G16 opcodes. Also stop adding G16 flag to instructions that do not
use gradients for GFX10 onwards.

17 months ago[mlir] Add function for checking if a block is inside a loop
Tom Eccles [Tue, 10 Jan 2023 16:08:58 +0000 (16:08 +0000)]
[mlir] Add function for checking if a block is inside a loop

This function returns whether a block is nested inside of a loop. There
can be three kinds of loop:
  1) The block is nested inside of a LoopLikeOpInterface
  2) The block is nested inside another block which is in a loop
  3) There is a cycle in the control flow graph

This will be useful for Flang's stack arrays pass, which moves array
allocations from the heap to the stack. Special handling is needed when
allocations occur inside of loops to ensure additional stack space is
not allocated on each loop iteration.

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

17 months ago[libclang] Tweaks for clang_CXXMethod_isExplicit
Aaron Ballman [Thu, 9 Feb 2023 14:53:10 +0000 (09:53 -0500)]
[libclang] Tweaks for clang_CXXMethod_isExplicit

This adds a release note that was accidentally dropped, and moves the
symbol from LLVM 16 to LLVM 17 in the module map.

Amends 0a51bc731bcc2c27e4fe97957a83642d93d989be

17 months ago[include-mapping] Add C-compatibility symbol entries.
Haojian Wu [Mon, 6 Feb 2023 10:39:17 +0000 (11:39 +0100)]
[include-mapping] Add C-compatibility symbol entries.

Extending the python generator:
- to generate C-compatibility symbols
- to generate macros

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

17 months agoDisable MSVC C5105 warnings
Aaron Ballman [Thu, 9 Feb 2023 14:27:14 +0000 (09:27 -0500)]
Disable MSVC C5105 warnings

Suppresses "macro expansion producing 'defined' has undefined behavior"
due to the diagnostic triggering in WinBase.h (a system header file).

17 months ago[AMDGPU] Remove unused ClangBuiltin definition for fmed3
Jay Foad [Thu, 9 Feb 2023 13:57:42 +0000 (13:57 +0000)]
[AMDGPU] Remove unused ClangBuiltin definition for fmed3

__builtin_amdgcn_fmed3 is unused since the actual builtins are
defined by Clang and have a floating point type suffix, h or f.

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

17 months ago[mlir][Linalg] Fix expected buffer semantics crash
Nicolas Vasilache [Thu, 9 Feb 2023 14:01:54 +0000 (06:01 -0800)]
[mlir][Linalg] Fix expected buffer semantics crash

Fixes #58747

17 months ago[libc] Introduce a config macro file
Guillaume Chatelet [Thu, 9 Feb 2023 13:59:57 +0000 (13:59 +0000)]
[libc] Introduce a config macro file

17 months ago[mlir][llvm] Fuse MD_access_group & MD_loop import
Christian Ulmann [Wed, 8 Feb 2023 13:47:29 +0000 (14:47 +0100)]
[mlir][llvm] Fuse MD_access_group & MD_loop import

This commit moves the importing logic of access group metadata into the
loop annotation importer. These two metadata imports can be grouped
because access groups are only used in combination with
`llvm.loop.parallel_accesses`.

As a nice side effect, this commit decouples the LoopAnnotationImporter
from the ModuleImport class.

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

17 months ago[libc] Add an optimization macro header
Guillaume Chatelet [Thu, 9 Feb 2023 13:35:31 +0000 (13:35 +0000)]
[libc] Add an optimization macro header

17 months ago[MemorySSA] Add test for gep with loop invariant pointer operand and
luxufan [Thu, 9 Feb 2023 12:34:15 +0000 (20:34 +0800)]
[MemorySSA] Add test for gep with loop invariant pointer operand and
indexes are all constant

17 months ago[mlir][NFC] Use fully qualified C++ namespaces in .td files.
Vladislav Vinogradov [Tue, 7 Feb 2023 08:21:07 +0000 (11:21 +0300)]
[mlir][NFC] Use fully qualified C++ namespaces in .td files.

Some extra cases that were not covered in 6da0184b.

Reviewed By: springerm

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

17 months ago[clang-tidy][doc] Improve clang-tidy documentation
Carlos Galvez [Fri, 6 Jan 2023 17:35:30 +0000 (17:35 +0000)]
[clang-tidy][doc] Improve clang-tidy documentation

- Specify that the .clang-tidy file is in YAML format.
- Document the options that may be used in the .clang-tidy file,
- Add missing documentation for existing options (User).
- Fix spurious newline after the dash that comes after every
  command-line option. This was inconsistent with single-line
  descriptions, which lacked a newline. The description is now
  aligned with the dash and the corresponding command-line option,
  more visually pleasing.

This enables documenting upcoming global clang-tidy
configuration options.

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

17 months ago[mlir] add support for transform dialect value handles
Alex Zinenko [Fri, 3 Feb 2023 14:00:33 +0000 (14:00 +0000)]
[mlir] add support for transform dialect value handles

Introduce support for the third kind of values in the transform dialect:
value handles. Similarly to operation handles, value handles are
pointing to a set of values in the payload IR. This enables
transformation to be targeted at specific values, such as individual
results of a multi-result payload operation without indirecting through
the producing op or block arguments that previously could not be easily
addressed. This is expected to support a broad class of memory-oriented
transformations such as selective bufferization, buffer assignment, and
memory transfer management.

Value handles are functionally similar to operation handles and require
similar implementation logic. The most important change concerns the
handle invalidation mechanism where operation and value handles can
affect each other.

This patch includes two cleanups that make it easier to introduce value
handles:

  - `RaggedArray` structure that encapsulates the SmallVector of
    ArrayRef backed by flat SmallVector logic, frequently used in the
    transform interfaces implementation;

  - rewrite the tests that associated payload handles with an integer
    value `reinterpret_cast`ed as a pointer, which were a frequent
    source of confusion and crashes when adding more debugging
    facilities that can inspect the payload.

Reviewed By: springerm

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

17 months agoRevert "[YAML IO] Check that mapping doesn't contain duplicating keys"
Anton Sidorenko [Thu, 9 Feb 2023 12:07:23 +0000 (15:07 +0300)]
Revert "[YAML IO] Check that mapping doesn't contain duplicating keys"

LLDB failures: https://lab.llvm.org/buildbot/#/builders/17/builds/33865

This reverts commit 4c228ee6d40a7cff256f1a680561b6c0155ad704.

17 months ago[llvm][cmake][Trivial] don't use `/Zc:preprocessor` with clang-cl
Markus Böck [Thu, 9 Feb 2023 12:01:49 +0000 (13:01 +0100)]
[llvm][cmake][Trivial] don't use `/Zc:preprocessor` with clang-cl

The flag is not recognized by clang-cl and emits unused command line warning for every translation unit

17 months ago[YAML IO] Check that mapping doesn't contain duplicating keys
Anton Sidorenko [Mon, 16 Jan 2023 15:03:12 +0000 (18:03 +0300)]
[YAML IO] Check that mapping doesn't contain duplicating keys

According to YAML specification keys must be unique for a mapping node:
"The content of a mapping node is an unordered set of key/value node pairs, with
the restriction that each of the keys is unique".

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

17 months agoAMDGPU/MC: Fix decoders for VSrc_v2b32 and VSrc_v2f32 RegisterOperands
Petar Avramovic [Thu, 9 Feb 2023 10:29:56 +0000 (11:29 +0100)]
AMDGPU/MC: Fix decoders for VSrc_v2b32 and VSrc_v2f32 RegisterOperands

Decoder should make 32 bit value when decoding immediates, not 64 bit.

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

17 months agoAMDGPU/MC: Add assembler tests for v2f32 and v2b32 with imm operand
Petar Avramovic [Wed, 8 Feb 2023 12:39:56 +0000 (13:39 +0100)]
AMDGPU/MC: Add assembler tests for v2f32 and v2b32 with imm operand

Add test coverage for https://github.com/llvm/llvm-project/issues/60563.
D142636 introduced a bug: incorrect disassembly of floating point inline
constants for v_pk_mov_b32, v_pk_add_f32, v_pk_mul_f32 and v_pk_fma_f32.
Precommit for D143574.

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

17 months ago[mlir][FuncToLLVM] Add option for emitting opaque pointers
Markus Böck [Thu, 9 Feb 2023 11:11:42 +0000 (12:11 +0100)]
[mlir][FuncToLLVM] Add option for emitting opaque pointers

Part of https://discourse.llvm.org/t/rfc-switching-the-llvm-dialect-and-dialect-lowerings-to-opaque-pointers/68179

FuncToLLVM contains some logic working with Memrefs and their lowerings and in the process creating pointer types, loads and allocas. This patch ports the code of these to be compatible with opaque pointers and adds a pass option to enable the use of opaque pointers within the pass.

For the migration effort, the tests have been rewritten to use opaque pointers with dedicated test files for typed pointer support

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

17 months ago[AArch64] Protect against overflowing shift amounts in performSETCCCombine
David Green [Thu, 9 Feb 2023 10:55:37 +0000 (10:55 +0000)]
[AArch64] Protect against overflowing shift amounts in performSETCCCombine

In the attached test case we can get into positions where the shift gets a
constant shift amount that is negative or larger than the bitwidth, leading to
trying to create an invalid constant. Add a check to make sure we can handle it
without assertions.

Fixes #60530

17 months ago[libc][NFC] separate macros in several targets
Guillaume Chatelet [Thu, 9 Feb 2023 10:50:49 +0000 (10:50 +0000)]
[libc][NFC] separate macros in several targets

17 months ago[LLDB] Add missing newline to "image lookup" output
David Spickett [Tue, 7 Feb 2023 17:39:31 +0000 (17:39 +0000)]
[LLDB] Add missing newline to "image lookup" output

When using --name, due to a missing newline, multiple symbol results
were not correctly printed:
```
(lldb) image lookup -r -n "As<.*"
2 matches found in <...>/tbi_lisp:
        Address: tbi_lisp<...>
        Summary: tbi_lisp<...> at Symbol.cpp:75        Address: tbi_lisp<...>
        Summary: tbi_lisp<...> at Symbol.cpp:82
```
It should be:
```
(lldb) image lookup -r -n "As<.*"
2 matches found in /home/david.spickett/tbi_lisp/tbi_lisp:
        Address: tbi_lisp<...>
        Summary: tbi_lisp<...> at Symbol.cpp:75
        Address: tbi_lisp<...>
        Summary: tbi_lisp<...> at Symbol.cpp:82
```
With Address/Summary on separate lines.

Reviewed By: clayborg, labath

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

17 months ago[AMDGPU] Ignore unused bits in VINTERP encoding
Jay Foad [Thu, 9 Feb 2023 10:15:10 +0000 (10:15 +0000)]
[AMDGPU] Ignore unused bits in VINTERP encoding

In the GFX11 VINTERP encoding bits 23, 59 and 60 are unused. Change the
disassembler to ignore these bits.

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

17 months ago[Support] Emulate SIGPIPE handling in raw_fd_ostream write for Windows
Andrew Ng [Fri, 20 Jan 2023 15:12:09 +0000 (15:12 +0000)]
[Support] Emulate SIGPIPE handling in raw_fd_ostream write for Windows

Prevent errors and crash dumps for broken pipes on Windows.

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

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

17 months ago[mlir][bufferization] Improve aliasing OpOperand/OpResult property
Matthias Springer [Thu, 9 Feb 2023 10:32:09 +0000 (11:32 +0100)]
[mlir][bufferization] Improve aliasing OpOperand/OpResult property

`getAliasingOpOperands`/`getAliasingOpResults` now encodes OpOperand/OpResult, buffer relation and a degree of certainty. E.g.:
```
// aliasingOpOperands(%r) = {(%t, EQUIV, DEFINITE)}
// aliasingOpResults(%t) = {(%r, EQUIV, DEFINITE)}
%r = tensor.insert %f into %t[%idx] : tensor<?xf32>

// aliasingOpOperands(%r) = {(%t0, EQUIV, MAYBE), (%t1, EQUIV, MAYBE)}
// aliasingOpResults(%t0) = {(%r, EQUIV, MAYBE)}
// aliasingOpResults(%t1) = {(%r, EQUIV, MAYBE)}
%r = arith.select %c, %t0, %t1 : tensor<?xf32>
```

`BufferizableOpInterface::bufferRelation` is removed, as it is now part of `getAliasingOpOperands`/`getAliasingOpResults`.

This change allows for better analysis, in particular wrt. equivalence. This allows additional optimizations and better error checking (which is sometimes overly conservative). Examples:

* EmptyTensorElimination can eliminate `tensor.empty` inside `scf.if` blocks. This requires a modeling of equivalence: It is not a per-OpResult property anymore. Instead, it can be specified for each OpOperand and OpResult. This is important because `tensor.empty` may be eliminated only if all values on the SSA use-def chain to the final consumer (`tensor.insert_slice`) are equivalent.
* The detection of "returning allocs from a block" can be improved. (Addresses a TODO in `assertNoAllocsReturned`.) This allows us to bufferize IR such as "yielding a `tensor.extract_slice` result from an `scf.if` branch", which currently fails to bufferize because the alloc detection is too conservative.
* Better bufferization of loops. Aliases of the iter_arg can be yielded (even if they are not equivalent) without having to realloc and copy the entire buffer on each iteration.

The above-mentioned examples are not yet implemented with this change. This change just improves the BufferizableOpInterface, its implementations and related helper functions, so that better aliasing information is available for each op.

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

17 months agoFix call to deprecated API in bd87a2449da0c82e63cebdf9c131c54a5472e3a7
Alex Richardson [Thu, 9 Feb 2023 10:26:21 +0000 (10:26 +0000)]
Fix call to deprecated API in bd87a2449da0c82e63cebdf9c131c54a5472e3a7

17 months ago[mlir][sparse] Port the remaining integration tests to use SVE
Andrzej Warzynski [Tue, 7 Feb 2023 17:34:23 +0000 (17:34 +0000)]
[mlir][sparse] Port the remaining integration tests to use SVE

This patch updates the remaining SparseCompiler integration tests to
target SVE when available.

Two tests will require some investigation in the future:
  * sparse_matmul.mlir
  * sparse_tanh.mlir
The former passes regardless - that's due to how `CHECK` lines are
defined. The latter fails when SVE is enabled, but passes when it's
disabled. I marked it as UNSUPPORTED as there is no mechanism to XFAIL a
test conditionally. Also, see [1] for more details.

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

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

17 months ago[CGP] Add generic TargetLowering::shouldAlignPointerArgs() implementation
Alex Richardson [Thu, 9 Feb 2023 09:33:32 +0000 (09:33 +0000)]
[CGP] Add generic TargetLowering::shouldAlignPointerArgs() implementation

This function was added for ARM targets, but aligning global/stack pointer
arguments passed to memcpy/memmove/memset can improve code size and
performance for all targets that don't have fast unaligned accesses.
This adds a generic implementation that adjusts the alignment to pointer
size if unaligned accesses are slow.
Review D134168 suggests that this significantly improves performance on
synthetic benchmarks such as Dhrystone on RV32 as it avoids memcpy() calls.

Reviewed By: efriedma

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

17 months agoSimplify test from change D73904
Michael Platings [Wed, 8 Feb 2023 16:59:52 +0000 (16:59 +0000)]
Simplify test from change D73904

This part of the test can break if multilib is enabled, and isn't
important to testing the change with which is was added.

The relevant part of the test is
ARM-EABI: "-lclang_rt.builtins-arm"
which remains.

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

17 months ago[Test] Fix YAML mapping keys duplication. NFC.
Anton Sidorenko [Mon, 16 Jan 2023 14:58:28 +0000 (17:58 +0300)]
[Test] Fix YAML mapping keys duplication. NFC.

YAML specification does not allow keys duplication an a mapping. However, YAML
parser in LLVM does not have any check on that and uses only the last key entry.
In this change duplicated keys are merged to satisfy the spec.

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

17 months agoReland "[X86][ABI] Don't preserve return regs for preserve_all/preserve_most CCs""
Anton Bikineev [Mon, 6 Feb 2023 12:16:08 +0000 (13:16 +0100)]
Reland "[X86][ABI] Don't preserve return regs for preserve_all/preserve_most CCs""

The original change mistakenly excluded parameter registers from the
list of callee-saved-registers. This reland fixes it - it only excludes
the return registers for preserve_all/preserve_most CCs.

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

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

17 months ago[clang][codegen] Fix emission of consteval constructor of derived type
Mariya Podchishchaeva [Thu, 9 Feb 2023 09:34:26 +0000 (04:34 -0500)]
[clang][codegen] Fix emission of consteval constructor of derived type

For simple derived type ConstantEmitter returns a struct of the same
size but different type which is then stored field-by-field into memory
via pointer to derived type. In case base type has more fields than derived,
the incorrect GEP is emitted. So, just cast pointer to derived type to
appropriate type with enough fields.

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

Reviewed By: aaron.ballman

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

17 months agoReland D143267: [LoopVectorize] Use DataLayout::getIndexType instead of i32 for non...
Sander de Smalen [Wed, 8 Feb 2023 16:47:02 +0000 (16:47 +0000)]
Reland D143267: [LoopVectorize] Use DataLayout::getIndexType instead of i32 for non-constant GEP indices.

Fixed issue where 'ConstantInt::get(IndextTy, -Part)' was executed with the wrong type for Part,
e.g. IndexTy was i64, but Part was 'unsigned', which led to things like 'mul i64 .., 4294967292',
which was obviously wrong.

Also changed sve-vector-reverse.ll to be vectorized with UF>1 to test this.

This reverts commit 1f01cdda68614dba12af3cc3aff38541d0abcc6b.

17 months ago[Docs] Clarify behavior of llvm-lit -vv
Jay Foad [Wed, 8 Feb 2023 15:24:11 +0000 (15:24 +0000)]
[Docs] Clarify behavior of llvm-lit -vv

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

17 months ago[libc] Add documentation for the macros folder
Guillaume Chatelet [Thu, 9 Feb 2023 09:34:08 +0000 (09:34 +0000)]
[libc] Add documentation for the macros folder

17 months ago[libc][NFC] Format bazel file
Guillaume Chatelet [Thu, 9 Feb 2023 09:33:40 +0000 (09:33 +0000)]
[libc][NFC] Format bazel file

17 months ago[libc][NFC] Move cpu_features.h to properties subfolder
Guillaume Chatelet [Thu, 9 Feb 2023 09:30:24 +0000 (09:30 +0000)]
[libc][NFC] Move cpu_features.h to properties subfolder

17 months ago[libc][NFC] Move compiler_features.h to properties subfolder
Guillaume Chatelet [Thu, 9 Feb 2023 09:25:45 +0000 (09:25 +0000)]
[libc][NFC] Move compiler_features.h to properties subfolder

17 months ago[mlir][llvm] Add extra attributes to the atomic ops.
Tobias Gysi [Thu, 9 Feb 2023 08:15:56 +0000 (09:15 +0100)]
[mlir][llvm] Add extra attributes to the atomic ops.

The revision adds a number of extra arguments to the
atomic read modify write and compare and exchange
operations. The extra arguments include the volatile,
weak, syncscope, and alignment attributes.

The implementation also adapts the fence operation to use
a assembly format and generalizes the helper used
to obtain the syncscope name.

Reviewed By: Dinistro

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

17 months ago[libc][NFC] Move architectures.h to properties subfolder
Guillaume Chatelet [Thu, 9 Feb 2023 09:20:39 +0000 (09:20 +0000)]
[libc][NFC] Move architectures.h to properties subfolder

17 months ago[mlir][transform] Fix apply WithPDLPatternsOp with non-pattern op
Kohei Yamaguchi [Thu, 9 Feb 2023 09:02:33 +0000 (10:02 +0100)]
[mlir][transform] Fix apply WithPDLPatternsOp with non-pattern op

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

Fix crash with segmentation fault when transform::WithPDLPatternsOp is
applied with non-pattern op. Added check for existing transform ops with
pattern op.

Reviewed By: ftynse

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

17 months ago[mlir][llvm] Purge struct_attr
Christian Ulmann [Thu, 9 Feb 2023 08:27:13 +0000 (09:27 +0100)]
[mlir][llvm] Purge struct_attr

This commit removes the `llvm.struct_attr` which was used to bundle
result attributes that were previously attached to multiple results.
This extension isn't part of LLVM as result attribute semantics cannot
be supported on a struct field granularity.
Furthermore, many usages promoted result attributes to argument
attributes but this does not necessary preserve the semantics.

Reviewed By: gysit

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

17 months ago[mlir][bufferization][NFC] Cache definitions of read tensors
Matthias Springer [Thu, 9 Feb 2023 08:10:48 +0000 (09:10 +0100)]
[mlir][bufferization][NFC] Cache definitions of read tensors

This is to avoid unnecessary traversals of the IR.

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

17 months ago[mlir][vector] Prevent duplicating operations during vector distribute
Thomas Raoux [Thu, 9 Feb 2023 07:15:11 +0000 (07:15 +0000)]
[mlir][vector] Prevent duplicating operations during vector distribute

We should distribute ops that have other uses than the yield op as this
would duplicate those ops.

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

17 months ago[mlir][Tiling] Properly reject "buffer semantic" operations
Quentin Colombet [Wed, 8 Feb 2023 08:23:13 +0000 (09:23 +0100)]
[mlir][Tiling] Properly reject "buffer semantic" operations

Our tiling implementation assumes a "tensor semantic" for the operation to
be tiled.
Prior to this patch, if we provide a tilable op with "buffer semantic", we
will assert instead of gracefully reject the input.

This patch turns the assert in a proper error.

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

17 months ago[NFC][TableGen] Refine the check in Decoder
Xiang1 Zhang [Thu, 9 Feb 2023 07:27:02 +0000 (15:27 +0800)]
[NFC][TableGen] Refine the check in Decoder
The Opcode occupy 2 bytes in following test, we should use {{[0-9]+}}
to match the total value if it, not a part of it.
OPC_Decode(uleb128 Opcode, uleb128 DIdx)
and so do for OPC_TryDecode.

17 months ago[mlir][bufferize][NFC] Optimize read-only tensor detection
Matthias Springer [Thu, 9 Feb 2023 08:00:52 +0000 (09:00 +0100)]
[mlir][bufferize][NFC] Optimize read-only tensor detection

Check alias sets instead of traversing the IR.

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

17 months ago[flang][hlfir] Lower procedure designators to HLFIR
Jean Perier [Thu, 9 Feb 2023 08:02:43 +0000 (09:02 +0100)]
[flang][hlfir] Lower procedure designators to HLFIR

- Add a convertProcedureDesignatorToHLFIR that converts the
  fir::ExtendedValue from the current lowering to a
  fir.boxproc/tuple<fir.boxproc, len> mlir::Value.

- Allow fir.boxproc/tuple<fir.boxproc, len> as hlfir::Entity values
  (a function is an address, but from a Fortran entity point of view,
  procedure that are not procedure pointers cannot be assigned to, so
  it makes a lot more sense to consider those as values).

- Modify symbol association to not generate an hlfir.declare for dummy
  procedures. They are not needed and allowing hlfir.declare to declare
  function values would make its verifier and handling overly complex
  for little benefits (maybe an hlfir.declare_proc could be added if it
  turnout out useful later for debug info and attributes storing
  purposes).

- Allow translation from hlfir::Entity to fir::ExtendedValue.
  convertToBox return type had to be relaxed because some intrinsics
  handles both object and procedure arguments and need to lower their
  object arguments "asBox". fir::BoxValue is not intended to carry
  dummy procedures (all its member functions would make little sense
  and its verifier does not accept such type).
  Note that AsAddr, AsValue and AsBox will always return the same MLIR
  value for procedure designators because they are always handled the
  same way in FIR.

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

17 months ago[AVR] Optimize 16-bit comparison with a constant
Ben Shi [Sat, 21 Jan 2023 13:42:25 +0000 (21:42 +0800)]
[AVR] Optimize 16-bit comparison with a constant

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

Reviewed By: jacquesguan, aykevl

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