platform/upstream/llvm.git
21 months ago[llvm][NFC] Consolidate equivalent function type parsing code into
Leonard Chan [Wed, 5 Oct 2022 18:40:50 +0000 (18:40 +0000)]
[llvm][NFC] Consolidate equivalent function type parsing code into
single function

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

21 months ago[mlir][arith] Add andi, ori, and xori support to WIE
Jakub Kuderski [Wed, 5 Oct 2022 18:34:26 +0000 (14:34 -0400)]
[mlir][arith] Add andi, ori, and xori support to WIE

Reviewed By: ThomasRaoux

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

21 months ago[Dwarf] Remove unnecessary module flags from test
Ellis Hoag [Wed, 5 Oct 2022 18:06:12 +0000 (11:06 -0700)]
[Dwarf] Remove unnecessary module flags from test

These extra module flags are not needed for this test, so remove them. In fact, leaving them in produces the following error message:

> invalid behavior operand in module flag (unexpected constant)

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

21 months ago[libc][Obvious] Add "__" prefix to sched_getcpucount in the spec and elsewhere.
Siva Chandra Reddy [Wed, 5 Oct 2022 17:12:06 +0000 (17:12 +0000)]
[libc][Obvious] Add "__" prefix to sched_getcpucount in the spec and elsewhere.

Without this fix, the declaration in sched.h will not have the "__" prefix and
will cause a compile failure.

Reviewed By: michaelrj

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

21 months ago[mlir][mlprogram] Add CAPI project for MLProgram
Rob Suderman [Wed, 5 Oct 2022 17:55:25 +0000 (10:55 -0700)]
[mlir][mlprogram] Add CAPI project for MLProgram

Reviewed By: jpienaar

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

21 months ago[RISCV][ISel] Refactor the formation of VW operations
Quentin Colombet [Thu, 22 Sep 2022 04:16:08 +0000 (04:16 +0000)]
[RISCV][ISel] Refactor the formation of VW operations

This patch centralizes all the combines of add|sub|mul with extended
operands in one "framework".
The rationale for this change is to offer a one-stop-shop for all these
transformations so that, in the future, it is easier to make combine
decisions for a web of instructions (i.e., instructions connected
through s|zext operands).

Technically this patch is not NFC because the new version is more
powerful than the previous version.
In particular, it diverges in two cases:
- VWMULSU can now also be produced from `mul(splat, zext)`, whereas
  previously only `mul(sext, splat)` were supported when `splat`s were
  involved. (As demonstrated in rvv/fixed-vectors-vwmulsu.ll)
- VWSUB(U) can now also be produced from `sub(splat, ext)`, whereas
  previously only `sub(ext, splat)` were supported when `splat`s were
  involved. (As demonstrated in rvv/fixed-vectors-vwsub.ll)

If we wanted, we could block these transformations to make this
patch really NFC. For instance, we could do something similar to
`AllowSplatInVW_W`, which prevents the combines to form vw(add|sub)(u)_w
when the RHS is a splat.

Regarding the "framework" itself, the bulk of the patch is some
boilderplate code that abstracts away the actual extensions that are
present in the DAG. This allows us to handle `vwadd_w(ext a, b)` as if
it was a regular `add(ext a, ext b)`. Since the node `ext b` doesn't
actually exist in the DAG, we have a bunch of methods (all in the
NodeExtensionHelper class) that fake all that for us.

The other half of the change is around `CombineToTry` and
`CombineResult`. These helper structures respectively:
- Represent the kind of combines that can be applied to a node, and
- Store what needs to happen to do that combine.

This can be viewed as a two step approach:
- First, check if a pattern applies, and
- Second apply it.

The checks and the materialization of the combines are decoupled so that
in the future we can perform several checks and do all the related
applies in one go.

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

21 months ago[mlir] Make UnitAttr's default val in unwrapped builder
Jacques Pienaar [Wed, 5 Oct 2022 17:40:58 +0000 (10:40 -0700)]
[mlir] Make UnitAttr's default val in unwrapped builder

UnitAttr is optional but unwrapped builders require it. Make Change onstructing
from bool as required for when not set at moment (for UnitAttr nothing needs to
be constructed, this is true for others here too and can be addressed
together).

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

21 months ago[Sema][ObjC] Fix assertion failure in getCommonNonSugarTypeNode
Akira Hatanaka [Wed, 5 Oct 2022 01:35:22 +0000 (18:35 -0700)]
[Sema][ObjC] Fix assertion failure in getCommonNonSugarTypeNode

Instead of checking that the protocols of both types are all equal,
check that the canonical decls are equal.

21 months ago[aarch64] add missing run line to a test
Nico Weber [Tue, 13 Sep 2022 12:53:05 +0000 (08:53 -0400)]
[aarch64] add missing run line to a test

The CHECK-IOS lines were added in 1c353419ab51f, but without a
matching FileCheck invocation. Add it.

The dead CHECK-IOS lines were found by Daniel Bertalan.

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

21 months agoAdd `const` to `dump` method of `OpFoldResult`.
Mahesh Ravishankar [Wed, 5 Oct 2022 17:26:34 +0000 (17:26 +0000)]
Add `const` to `dump` method of `OpFoldResult`.

While most `dump` methods are marked `const`, some arent marked as
`const`. Adding `const` to `OpFoldResult` here since this was
encountered as an issue while debugging (doing `dump` within a debug
console threw an error indicating the method should be marked
`const`).

Reviewed By: ftynse

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

21 months ago[mlir][Linalg] Expose vectorization precondition check as a utility function.
Mahesh Ravishankar [Tue, 4 Oct 2022 22:04:43 +0000 (22:04 +0000)]
[mlir][Linalg] Expose vectorization precondition check as a utility function.

This patch exposes the method to check if an op can be vectorized or
not for downstream uses. Also adds a check to mark elementwise operations
that have non-vectorizable ops (like `tensor.extract`) as non vectorizable.

Reviewed By: nicolasvasilache, dcaballe, ThomasRaoux

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

21 months ago[lld][ELF] Fix lazy ThinLTO index writing in thin archives
Aiden Grossman [Sat, 1 Oct 2022 06:24:32 +0000 (06:24 +0000)]
[lld][ELF] Fix lazy ThinLTO index writing in thin archives

Currently when the --thinlto-emit-index-files is used with LLD and a
thin archive is passed containing references to object files to link
against where the object files are in a different folder than the thin
archive and some of the archives aren't linked against (ie stay lazy),
the empty index file writer ends up trying to write to a path that
doesn't exist. This patch changes the behavior of that function to use
the path of the obj member of the BitcodeFile object rather than just
the path of the BitcodeFile object itself, which matches the behavior of
the default (non-lazy) case.

Fixes #57963

Regression test added.

Reviewed By: MaskRay

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

21 months agoRevert "[compiler-rt][test] Heed COMPILER_RT_DEBUG when compiling unittests"
Vitaly Buka [Wed, 5 Oct 2022 16:59:25 +0000 (09:59 -0700)]
Revert "[compiler-rt][test] Heed COMPILER_RT_DEBUG when compiling unittests"

Breaks some bots, details in https://reviews.llvm.org/D91620

This reverts commit 93b1256e38f63a81561288b9a90c5d52af63cb6e.

21 months agoRevert "[mlir][sparse] Restore case coverage warning fix"
Vitaly Buka [Wed, 5 Oct 2022 16:47:51 +0000 (09:47 -0700)]
Revert "[mlir][sparse] Restore case coverage warning fix"

Breaks https://lab.llvm.org/buildbot/#/builders/168/builds/9288

This reverts commit 83839700c32996c58ddebc0c74e3dc4970e005bc.

21 months ago[mlir][sparse] introduce a higher-order tensor mapping
Aart Bik [Tue, 4 Oct 2022 21:34:37 +0000 (14:34 -0700)]
[mlir][sparse] introduce a higher-order tensor mapping

This extension to the sparse tensor type system in MLIR
opens up a whole new set of sparse storage schemes, such as
block sparse storage (e.g. BCSR) and ELL (aka jagged diagonals).

This revision merely introduces the type extension and
initial documentation. The actual interpretation of the type
(reading in tensors, lowering to code, etc.) will follow.

Reviewed By: Peiming

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

21 months ago[libc++][chrono] Implements formatter month.
Mark de Wever [Sun, 20 Mar 2022 12:40:02 +0000 (13:40 +0100)]
[libc++][chrono] Implements formatter month.

Partially implements:
- P1361 Integration of chrono with text formatting

Reviewed By: ldionne, #libc

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

21 months agoFix SourceManager::isBeforeInTranslationUnit bug with token-pasting
Sam McCall [Mon, 26 Sep 2022 23:15:06 +0000 (01:15 +0200)]
Fix SourceManager::isBeforeInTranslationUnit bug with token-pasting

isBeforeInTranslationUnit compares SourceLocations across FileIDs by
mapping them onto a common ancestor file, following include/expansion edges.

It is possible to get a tie in the common ancestor, because multiple
"chunks" of a macro arg will expand to the same macro param token in the body:
  #define ID(X) X
  #define TWO 2
  ID(1 TWO)
Here two FileIDs both expand into `X` in ID's expansion:
 - one containing `1` and spelled on line 3
 - one containing `2` and spelled by the macro expansion of TWO
isBeforeInTranslationUnit breaks this tie by comparing the two FileIDs:
the one "on the left" is always created first and is numerically smaller.
This seems correct so far.

Prior to this patch it also takes a shortcut (unclear if intentionally).
Instead of comparing the two FileIDs that directly expand to the same location,
it compares the original FileIDs being compared. These may not be the
same if there are multiple macro expansions in between.
This *almost* always yields the right answer, because macro expansion
yields "trees" of FileIDs allocated in a contiguous range: when comparing tree A
to tree B, it doesn't matter what representative you pick.

However, the splitting of >> tokens is modeled as macro expansion (as if
the first '>' was a macro that expands to a '>' spelled a scratch buffer).
This splitting occurs retroactively when parsing, so the FileID allocated is
larger than expected if it were a real macro expansion performed during lexing.
As a result, macro tree A can be on the left of tree B, and yet contain
a token-split FileID whose numeric value is *greator* than those in B.
In this case the tiebreak gives the wrong answer.

Concretely:
  #define ID(X) X
  template <typename> class S{};
  ID(
    ID(S<S<int>> x);
    int y;
  )

  Given Greater = (typeloc of S<int>).getEndLoc();
        Y       = (decl of y).getLocation();
  isBeforeInTranslationUnit(Greater, Y) should return true, but returns false.

Here the common FileID of (Greater, Y) is the body of the outer ID
expansion, and they both expand to X within it.
With the current tiebreak rules, we compare the FileID of Greater (a split)
to the FileID of Y (a macro arg expansion into X of the outer ID).
The former is larger because the token split occurred relatively late.

This patch fixes the issue by removing the shortcut. It tracks the immediate
FileIDs used to reach the common file, and uses these IDs to break ties.
In the example, we now compare the macro arg expansion of the inner ID()
to the macro arg expansion of Y, and find that it is smaller.

This requires some changes to the InBeforeInTUCacheEntry (sic).
We store a little more data so it's probably slightly slower.
It was difficult to resist more invasive changes:
 - performance: the sizing is very suspicious, and once the cache "fills up"
   we're thrashing a single entry
 - API: the class seems to be needlessly complicated
However I tried to avoid mixing these with subtle behavior changes, and
will send a followup instead.

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

21 months ago[HLSL] Support register binding attribute on global variable
Xiang Li [Fri, 30 Sep 2022 17:54:05 +0000 (10:54 -0700)]
[HLSL] Support register binding attribute on global variable

Allow register binding attribute on variables.

Report warning when register binding attribute applies to local variable or static variable.
It will be ignored in this case.

Type check for register binding is tracked with https://github.com/llvm/llvm-project/issues/57886.

Reviewed By: aaron.ballman

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

21 months ago[Dwarf] Reference the correct CU when inlining
Ellis Hoag [Tue, 4 Oct 2022 19:34:31 +0000 (12:34 -0700)]
[Dwarf] Reference the correct CU when inlining

Sometimes when a function is inlined into a different CU, `llvm-dwarfdump --verify` would find an inlined subroutine with an invalid abstract origin. This is because `DwarfUnit::addDIEEntry()` will incorrectly assume the inlined subroutine and the abstract origin are from the same CU if it can't find the CU for the inlined subroutine.

In the added test, the inlined subroutine for `bar()` is created before the CU for `B.swift` is created, so it tries to point to `goo()` in the wrong CU. Interestingly, if we swap the order of the two functions then we don't see a crash since the module for `goo()` is created first.

The fix is to give a parent DIE to `ScopeDIE` before calling `addDIEEntry()` so that its CU can be found. Luckily, `constructInlinedScopeDIE()` is only called once so we can pass it the DIE of the scope's parent and give it a child just after it's created.

`constructInlinedScopeDIE()` should always return a DIE, so assert that it is not null.

Reviewed By: aprantl

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

21 months ago[mlir][unittest] Fix crash when building with MSVC 2022
Alexandre Ganea [Fri, 30 Sep 2022 12:27:04 +0000 (08:27 -0400)]
[mlir][unittest] Fix crash when building with MSVC 2022

The test Dialect/Affine/ops.mlir was failing when building with
Visual Studio 2022 version 17.3.5. This was caused by a bad MSVC codegen, when
capturing a `constexpr` in a lambda. The bug was reported to Microsoft, see
differential for more information.

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

21 months ago[mlir] Fix ambiguity when building with Clang 14.0.6
Alexandre Ganea [Fri, 30 Sep 2022 12:22:54 +0000 (08:22 -0400)]
[mlir] Fix ambiguity when building with Clang 14.0.6

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

21 months ago[Orc] Fix the SharedMemoryMapper dtor
Alexandre Ganea [Fri, 30 Sep 2022 12:17:14 +0000 (08:17 -0400)]
[Orc] Fix the SharedMemoryMapper dtor

As briefly discussed on https://reviews.llvm.org/rG1134d3a03facccd75efc5385ba46918bef94fcb6, fix the unintended copy while iterating on Reservations and add a mutex guard, to be symmetric with other usages of Reservations.

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

21 months ago[Syntax] Fix macro-arg handling in TokenBuffer::spelledForExpanded
Sam McCall [Mon, 26 Sep 2022 01:22:09 +0000 (03:22 +0200)]
[Syntax] Fix macro-arg handling in TokenBuffer::spelledForExpanded

A few cases were not handled correctly. Notably:
  #define ID(X) X
  #define HIDE a ID(b)
  HIDE
spelledForExpanded() would claim HIDE is an equivalent range of the 'b' it
contains, despite the fact that HIDE also covers 'a'.

While trying to fix this bug, I found findCommonRangeForMacroArgs hard
to understand (both the implementation and how it's used in spelledForExpanded).
It relies on details of the SourceLocation graph that are IMO fairly obscure.
So I've added/revised quite a lot of comments and made some naming tweaks.

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

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

21 months ago[libc++] Get rid of _LIBCPP_HAS_OPEN_WITH_WCHAR in the test suite
Louis Dionne [Tue, 4 Oct 2022 15:28:45 +0000 (11:28 -0400)]
[libc++] Get rid of _LIBCPP_HAS_OPEN_WITH_WCHAR in the test suite

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

21 months ago[ConstraintElimination] Convert NewIndices to vector and rename (NFCI).
Florian Hahn [Wed, 5 Oct 2022 15:25:00 +0000 (16:25 +0100)]
[ConstraintElimination] Convert NewIndices to vector and rename (NFCI).

The callers of getConstraint only require a list of new variables.
Update the naming and types to make this clearer.

21 months ago[AMDGPU] Fix V_CMP_CLASS_F16_t16_e64 src1 type.
Joe Nash [Thu, 29 Sep 2022 17:30:25 +0000 (13:30 -0400)]
[AMDGPU] Fix V_CMP_CLASS_F16_t16_e64 src1 type.

For V_CMP_CLASS_F16_t16_e64 and V_CMPX_CLASS_F16_t16_e64,
https://reviews.llvm.org/D133723 changed the value type of src1 from i32 to i16.
These src1 operands are 16 bits, therefore need to be encoded as true16
operands. So the _e32 type was correctly set to VGPR_32_Lo128.
In _e64 form the operand class went from
VSrc_b32 to VSrc_b16. For some reason, we cannot encode inline literals for
VSrc_b16, see 5f5f566b265db00f577ead268400d99f34ba9cdd. In this phase of
the true16 implementation, VSrc_b16 and VSrc_b32 are still similar,
except from that quirk of inlines. So set the operand class to regain
that function.

Reviewed By: dp, arsenm

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

21 months ago[OpenMP][FIX] Update device API to match recent changes
Johannes Doerfert [Wed, 5 Oct 2022 15:06:35 +0000 (08:06 -0700)]
[OpenMP][FIX] Update device API to match recent changes

21 months ago[PhaseOrdering] Name instructions in test (NFC)
Nikita Popov [Wed, 5 Oct 2022 15:03:48 +0000 (17:03 +0200)]
[PhaseOrdering] Name instructions in test (NFC)

Run through opt -instnamer.

21 months ago[libc++][chrono] Implements formatter year.
Mark de Wever [Sun, 20 Mar 2022 12:40:02 +0000 (13:40 +0100)]
[libc++][chrono] Implements formatter year.

Partially implements:
- P1361 Integration of chrono with text formatting

Reviewed By: ldionne, #libc

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

21 months ago[SLP][NFC]Add a test for CSE for extractelements.
Alexey Bataev [Wed, 5 Oct 2022 14:52:39 +0000 (07:52 -0700)]
[SLP][NFC]Add a test for CSE for extractelements.

21 months ago[RISCV][CodeGen] Add Scheduling for vset{i}vl{i} instruction
Michael Maitland [Tue, 4 Oct 2022 19:18:39 +0000 (12:18 -0700)]
[RISCV][CodeGen] Add Scheduling for vset{i}vl{i} instruction

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

21 months ago[LICM] Convert tests to opaque pointers (NFC)
Nikita Popov [Wed, 5 Oct 2022 14:40:29 +0000 (16:40 +0200)]
[LICM] Convert tests to opaque pointers (NFC)

Using https://gist.github.com/nikic/98357b71fd67756b0f064c9517b62a34.

The opaque pointer migration resolves the TODO on test_fence3: The
transform now works as expected by dint of the bitcast no longer
existing.

21 months ago[LICM] Adjust speculation test to avoid no-op instruction (NFC)
Nikita Popov [Wed, 5 Oct 2022 14:40:29 +0000 (16:40 +0200)]
[LICM] Adjust speculation test to avoid no-op instruction (NFC)

Such GEPs don't exist with opaque pointers, give it an actual
offset.

21 months ago[NFC][AMDGPULowerKernelAttributes] Factorize repeated code into function
Juan Manuel MARTINEZ CAAMAÑO [Wed, 5 Oct 2022 13:38:35 +0000 (08:38 -0500)]
[NFC][AMDGPULowerKernelAttributes] Factorize repeated code into function

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

21 months ago[LangRef][VP] Change masked-off lanes from undef to poison
Fraser Cormack [Wed, 5 Oct 2022 07:31:00 +0000 (08:31 +0100)]
[LangRef][VP] Change masked-off lanes from undef to poison

These were all changed in 32b1b06b7081bd722750c6f3d528336f3f7ed34b (as
discussed in D133967) but some intrinsics introduced since have
re-introduced `undef` as the masked-off value.

Reviewed By: reames, eopXD

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

21 months ago[NFC][RISCV] Move getSEWLMULRatio function to header
Anton Sidorenko [Wed, 5 Oct 2022 13:58:07 +0000 (14:58 +0100)]
[NFC][RISCV] Move getSEWLMULRatio function to header

More uses of getSEWLMULRatio will be added in D130895.

Reviewed By: craig.topper, frasercrmck

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

21 months ago[flang] Deallocate polymorphic and unlimited polymorphic intent(out) allocatable...
Valentin Clement [Wed, 5 Oct 2022 14:05:11 +0000 (16:05 +0200)]
[flang] Deallocate polymorphic and unlimited polymorphic intent(out) allocatable with runtime

Polymorphic and unlimited polymorphic entities should be handled by runtime. This patch
update the condition in `genDeallocate` to force polymorphic and unlimited polymorphic entities
to be deallocated through a runtime call and not inlined.

Depends on D135143

Reviewed By: jeanPerier, PeteSteinfeld

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

21 months ago[DSE] Convert tests to opaque pointers (NFC)
Nikita Popov [Wed, 5 Oct 2022 13:28:15 +0000 (15:28 +0200)]
[DSE] Convert tests to opaque pointers (NFC)

Using https://gist.github.com/nikic/98357b71fd67756b0f064c9517b62a34.

21 months ago[Index] USRGeneration doesn't depend on unnamed.printName() => ''. NFC
Sam McCall [Tue, 4 Oct 2022 20:05:16 +0000 (22:05 +0200)]
[Index] USRGeneration doesn't depend on unnamed.printName() => ''. NFC

This prepares for printName() to print `(anonymous struct)` etc in D134813.

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

21 months ago[clangd] Stop isSpelledInSource from printing source locations.
Sam McCall [Wed, 5 Oct 2022 13:48:28 +0000 (15:48 +0200)]
[clangd] Stop isSpelledInSource from printing source locations.

It shows up on profiles, albeit only at 0.1% or so.

21 months ago[Attributor] Teach AAPointerInfo about atomic cmxchg and rmw
Johannes Doerfert [Mon, 12 Sep 2022 20:22:05 +0000 (13:22 -0700)]
[Attributor] Teach AAPointerInfo about atomic cmxchg and rmw

The atomic operations behave similar to a store except that we don't
know the new value and we read the result first.

21 months ago[AMDGPU][MC][GFX11] Correct e64_dpp variants of v_movreld and v_movrelsd
Dmitry Preobrazhensky [Wed, 5 Oct 2022 13:44:00 +0000 (16:44 +0300)]
[AMDGPU][MC][GFX11] Correct e64_dpp variants of v_movreld and v_movrelsd

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

21 months ago[AArch64][SME] Set up a lazy-save/restore around calls.
Kerry McLaughlin [Wed, 5 Oct 2022 13:01:24 +0000 (14:01 +0100)]
[AArch64][SME] Set up a lazy-save/restore around calls.

Setting up a lazy-save mechanism around calls is done during SelectionDAG
because calls to intrinsics may be expanded into an actual function call
(e.g. calls to @llvm.cos()), and maintaining an allowed-list in the SMEABI
pass is not feasible.

The approach for conditionally restoring the lazy-save based on the runtime
value of TPIDR2_EL0 is similar to how we handle conditional smstart/smstop.
We create a pseudo-node which gets expanded into a conditional branch and
expands to a call to __arm_tpidr2_restore(%tpidr2_object_ptr).

The lazy-save buffer and TPIDR2 block are only allocated once at the start
of the function. For each call, the TPIDR2 block is initialised, and at
the end of the call, a pseudo node (RestoreZA) is planted.

Patch by Sander de Smalen.

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

21 months ago[Attributor] AAPointerInfo can model non-escaping call uses
Johannes Doerfert [Mon, 12 Sep 2022 01:43:20 +0000 (18:43 -0700)]
[Attributor] AAPointerInfo can model non-escaping call uses

If a call base use will not capture a pointer we can approximate the
effects. This is important especially for readnone/only uses. Even
may-write uses are not too bad with reachability in place. Capturing
is the problem as we loose track of update sides.

21 months ago[DSE] Regenerate test checks (NFC)
Nikita Popov [Wed, 5 Oct 2022 13:26:41 +0000 (15:26 +0200)]
[DSE] Regenerate test checks (NFC)

21 months ago[DSE] Fix variable name clash in test (NFC)
Nikita Popov [Wed, 5 Oct 2022 13:25:40 +0000 (15:25 +0200)]
[DSE] Fix variable name clash in test (NFC)

update_tests_checks.py generates the same identifier for lowercase
and uppercase variable names. Make sure they have a distinct name.

21 months ago[clang][Sema] Fix crash on invalid base destructor
Kadir Cetinkaya [Wed, 5 Oct 2022 10:09:56 +0000 (12:09 +0200)]
[clang][Sema] Fix crash on invalid base destructor

LookupSpecialMember might fail, so changes the cast to cast_or_null.
Inside Sema, skip a particular base, similar to other cases, rather than
asserting on dtor showing up.

Other option would be to mark classes with invalid destructors as invalid, but
that seems like a lot more invasive and we do lose lots of diagnostics that
currently work on classes with broken members.

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

21 months ago[Attributor] Teach AAPointerInfo to look into aggregates
Johannes Doerfert [Wed, 31 Aug 2022 19:13:42 +0000 (12:13 -0700)]
[Attributor] Teach AAPointerInfo to look into aggregates

If we have a constant aggregate, e.g., as an initializer, we usually
failed to extract the proper value/type from it. This patch provides the
size and offset information necessary to extract the right part of the
constant.

21 months ago[Attributor][NFC] Re-run update_test_checks on all Attributor tests
Johannes Doerfert [Wed, 5 Oct 2022 12:39:02 +0000 (05:39 -0700)]
[Attributor][NFC] Re-run update_test_checks on all Attributor tests

21 months ago[MemCpyOpt] Convert tests to opaque pointers (NFC)
Nikita Popov [Wed, 5 Oct 2022 12:26:57 +0000 (14:26 +0200)]
[MemCpyOpt] Convert tests to opaque pointers (NFC)

Converted using the script at
https://gist.github.com/nikic/98357b71fd67756b0f064c9517b62a34.

21 months ago[MemCpyOpt] Don't hoist above producer of pointer operand
Nikita Popov [Wed, 5 Oct 2022 12:51:07 +0000 (14:51 +0200)]
[MemCpyOpt] Don't hoist above producer of pointer operand

This was already handled correctly below, but not checked for the
original store pointer operand. Encountered when converting tests
to opaque pointers, where the intermediate bitcast goes away.

21 months ago[Clang][OpenMP] Only check value if the expression is not instantiation dependent
Shilei Tian [Wed, 5 Oct 2022 12:43:53 +0000 (08:43 -0400)]
[Clang][OpenMP] Only check value if the expression is not instantiation dependent

Currently the following case fails:
```
template<typename Ty>
Ty foo(Ty *addr, Ty val) {
  Ty v;
#pragma omp atomic compare capture
  {
    v = *addr;
    if (*addr > val)
      *addr = val;
  }
  return v;
}
```

The compiler complains `addr` is not a lvalue. That's because when an expression
is instantiation dependent, we cannot tell if it is lvalue or not.

Reviewed By: ABataev

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

21 months ago[AggressiveInstCombine] Fix cases where non-opaque pointers are used
David Stuttard [Mon, 3 Oct 2022 18:21:18 +0000 (19:21 +0100)]
[AggressiveInstCombine] Fix cases where non-opaque pointers are used

In the case of non-opaque pointers, when combining consecutive loads,
need to bitcast the pointer source to the combined type size, otherwise
asserts are triggered.

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

21 months ago[mlir] tweak declarative assembly doc
Oleksandr "Alex" Zinenko [Wed, 5 Oct 2022 12:33:47 +0000 (14:33 +0200)]
[mlir] tweak declarative assembly doc

Change the formal argument of the `functional-type` directive from "results" to "outputs" to avoid confusion with the `results` directive.

21 months ago[flang][OpenMP] Support privatization for single construct
Peixin Qiao [Wed, 5 Oct 2022 12:22:33 +0000 (20:22 +0800)]
[flang][OpenMP] Support privatization for single construct

This supports the lowering of private and firstprivate clauses in single
construct. The alloca ops are emitted in the entry block according to
https://llvm.org/docs/Frontend/PerformanceTips.html#use-of-allocas, and
the load/store ops are emitted in the single region. The data race
problem is handled in OMPIRBuilder. That is, the barrier is emitted in
OMPIRBuilder.

Co-authored-by: Nimish Mishra <neelam.nimish@gmail.com>
Reviewed By: kiranchandramohan

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

21 months agoReapply [InstCombine] Switch foldOpIntoPhi() to use InstSimplify
Nikita Popov [Fri, 30 Sep 2022 10:13:40 +0000 (12:13 +0200)]
Reapply [InstCombine] Switch foldOpIntoPhi() to use InstSimplify

The infinite loop seen on buildbots should be fixed by
11897708c0229c92802e747564e7c34b722f045f (assuming there are not
multiple infinite combine loops...)

-----

foldOpIntoPhi() currently only folds operations into the phi if all
but one operands constant-fold. The two exceptions to this are freeze
and select, where we allow more general simplification.

This patch makes foldOpIntoPhi() generally simplification based and
removes all the instruction-specific logic. We just try to simplify
the instruction for each operand, and for the (potentially) one
non-simplified operand, we move it into the new block with adjusted
operands.

This fixes https://github.com/llvm/llvm-project/issues/57448, which
was my original motivation for the change.

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

21 months ago[LLDB][RISCV][NFC] Rewrite instruction in algebraic datatype
Emmmer [Wed, 28 Sep 2022 15:04:08 +0000 (23:04 +0800)]
[LLDB][RISCV][NFC] Rewrite instruction in algebraic datatype

The old approach (dedicated ExecXXX for each instruction) is not flexible and results in duplicated code when RVC kicks in.

According to the spec, every compressed instruction can be decoded to a non-compressed one. So we can lower compressed instructions to instructions we already had, which requires a decoupling between the decoder and executor.

This patch:
- use llvm::Optional and its combinators AMAP.
- use template constraints on common instruction.
- make instructions strongly-typed (no uint32_t everywhere bc it is error-prone and burdens the developer when lowering the RVC) with the help of algebraic datatype (std::variant).

Note:
(NFC) because this is more of a refactoring in preparation for RVC.

Reviewed By: DavidSpickett

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

21 months ago[InstCombine] Directly replace instr in foldIntegerTypedPHI() (NFCI)
Nikita Popov [Wed, 5 Oct 2022 11:26:20 +0000 (13:26 +0200)]
[InstCombine] Directly replace instr in  foldIntegerTypedPHI() (NFCI)

Rather than inserting a ptrtoint + inttoptr pair, directly replace
the inttoptr with the new phi node. This ensures that no other
transform can undo it before the pair gets folded away.

This avoids the infinite loop when combined with D134954.

This is NFCI in the sense that it shouldn't make a difference, but
could due to different worklist order.

21 months ago[InstCombine] Add test for infinite combine loop with D134954 (NFC)
Nikita Popov [Wed, 5 Oct 2022 11:11:13 +0000 (13:11 +0200)]
[InstCombine] Add test for infinite combine loop with D134954 (NFC)

The patch interacts badly with foldIntegerTypedPHI().

21 months ago[mlir][transform] Add failing test for GPU transform dialect
Guray Ozen [Wed, 5 Oct 2022 11:09:27 +0000 (13:09 +0200)]
[mlir][transform] Add failing test for GPU transform dialect

The GPU transform dialect currently has restrictions and several situations where we can't use transform dialect.

This update includes a method to test a failing cases in GPU transform dialect.

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

21 months ago[mlir][transform][nfc] typo fix
Guray Ozen [Wed, 5 Oct 2022 06:48:19 +0000 (08:48 +0200)]
[mlir][transform][nfc] typo fix

fix typo

Reviewed By: nicolasvasilache, ftynse

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

21 months ago[gn build] Port f0f474dfd03b
LLVM GN Syncbot [Wed, 5 Oct 2022 09:44:51 +0000 (09:44 +0000)]
[gn build] Port f0f474dfd03b

21 months ago[AArch64][SME] Add codegen pass to handle ZA state in arm_new_za functions.
David Sherwood [Wed, 5 Oct 2022 08:12:31 +0000 (08:12 +0000)]
[AArch64][SME] Add codegen pass to handle ZA state in arm_new_za functions.

The new pass implements the following:

* Inserts code at the start of an arm_new_za function to
    commit a lazy-save when the lazy-save mechanism is active.
* Adds a smstart intrinsic at the start of the function.
* Adds a smstop intrinsic at the end of the function.

Patch co-authored by kmclaughlin.

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

21 months ago[VP] Fix unused variable in release configurations
Fraser Cormack [Wed, 5 Oct 2022 09:32:44 +0000 (10:32 +0100)]
[VP] Fix unused variable in release configurations

21 months agoFix clang baremetal test
Mikhail Goncharov [Wed, 5 Oct 2022 09:32:28 +0000 (11:32 +0200)]
Fix clang baremetal test

def48cae45a5085b7759f2be71768e27718b901a accidentally dropped -no-canonical-prefixes

21 months ago[SimpleLoopUnswitch] Clear dispos in deleteDeadBlocksFromLoop.
Florian Hahn [Wed, 5 Oct 2022 09:28:15 +0000 (10:28 +0100)]
[SimpleLoopUnswitch] Clear dispos in deleteDeadBlocksFromLoop.

SimpleLoopUnswitch may remove blocks from loops. Clear block and loop
dispositions in that case, to clean up invalid entries in the cache.

Fixes #58158.

Fixes #58159.

21 months ago[SimpleLoopUnswitch] Simplify test, reduce the passes to trigger crash.
Florian Hahn [Wed, 5 Oct 2022 09:19:54 +0000 (10:19 +0100)]
[SimpleLoopUnswitch] Simplify test, reduce the passes to trigger crash.

This simplifies the test case added in e399dd601 to only require indvars
and simple-loop-unswitch. This allows adding the test case for #58158 to
the same file, keeping related tests together.

21 months agoRevert "[clang][Lex] Fix a crash on malformed string literals"
Kadir Cetinkaya [Wed, 5 Oct 2022 08:37:12 +0000 (10:37 +0200)]
Revert "[clang][Lex] Fix a crash on malformed string literals"

This reverts commit 36a200208facf58d454c9b7253c956c2f2a8b946.

21 months ago[SROA] Regenerate test checks (NFC)
Nikita Popov [Wed, 5 Oct 2022 08:30:44 +0000 (10:30 +0200)]
[SROA] Regenerate test checks (NFC)

21 months ago[AArch64][SME] Prevent SVE object address calculations between smstop and call
David Sherwood [Wed, 5 Oct 2022 07:41:23 +0000 (07:41 +0000)]
[AArch64][SME] Prevent SVE object address calculations between smstop and call

This patch introduces a new AArch64 ISD node (OBSCURE_COPY) that can
be used when we want to prevent SVE object address calculations
from being rematerialised between a smstop/smstart and a call.
At the moment we use COPY to copy the frame index to a register,
which leads to problems because the "simple register coalescing"
pass understands the COPY instruction and attempts to rematerialise
an address calculation with 'addvl' between an smstop and a call.
When in streaming mode the 'addvl' instruction may have different
behaviour because the streaming SVE vector length is not guaranteed
to equal the normal SVE vector length.

The new ISD opcode OBSCURE_COPY gets lowered to a new pseudo
instruction also called OBSCURE_COPY. This ensures it cannot be
rematerialised and we expand this into a simple move very late in
the machine instruction pipeline.

A new test is added here:

CodeGen/AArch64/sme-streaming-interface.ll

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

21 months ago[flang] Update to fir::isUnlimitedPolymorphicType and fir::isPolymorphicType functions
Valentin Clement [Wed, 5 Oct 2022 08:04:46 +0000 (10:04 +0200)]
[flang] Update to fir::isUnlimitedPolymorphicType and fir::isPolymorphicType functions

This patch update the fir::isUnlimitedPolymorphicType function
to reflect the chosen design. It adds also a fir::isPolymorphicType
function.

Reviewed By: jeanPerier

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

21 months ago[AArch64] Add missing SEH_Nop when aligning the stack
Martin Storsjö [Sat, 1 Oct 2022 12:30:25 +0000 (15:30 +0300)]
[AArch64] Add missing SEH_Nop when aligning the stack

This makes sure that the instructions of the prologue matches the
SEH opcodes.

Also remove a couple redundant cases of setting HasWinCFI; it was
already set unconditionally after the conditional cases.

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

21 months agoFix LLDB build on old Linux kernels (pre-4.1)
David Spickett [Wed, 5 Oct 2022 07:31:03 +0000 (07:31 +0000)]
Fix LLDB build on old Linux kernels (pre-4.1)

These fields are guarded elsewhere, but were missing here.

Reviewed By: wallace

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

21 months ago[mlir][Linalg] NFC - Add bbarg pretty printing to linalg::generic
Nicolas Vasilache [Tue, 4 Oct 2022 12:14:30 +0000 (05:14 -0700)]
[mlir][Linalg] NFC - Add bbarg pretty printing to linalg::generic

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

21 months ago[clang][Lex] Fix a crash on malformed string literals
Kadir Cetinkaya [Tue, 4 Oct 2022 15:06:24 +0000 (17:06 +0200)]
[clang][Lex] Fix a crash on malformed string literals

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

21 months ago[mlir][Linalg] Retire LinalgStrategyLowerVectorsPass and filter-based patterns
Nicolas Vasilache [Tue, 4 Oct 2022 22:42:41 +0000 (15:42 -0700)]
[mlir][Linalg] Retire LinalgStrategyLowerVectorsPass and filter-based patterns

Context: https://discourse.llvm.org/t/psa-retire-linalg-filter-based-patterns/63785

Depends on D135200

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

21 months ago[compiler-rt][test] Heed COMPILER_RT_DEBUG when compiling unittests
Rainer Orth [Wed, 5 Oct 2022 07:53:26 +0000 (09:53 +0200)]
[compiler-rt][test] Heed COMPILER_RT_DEBUG when compiling unittests

When trying to debug some `compiler-rt` unittests, I initially had a hard
time because

- even in a `Debug` build one needs to set `COMPILER_RT_DEBUG` to get
  debugging info for some of the code and
- even so the unittests used a hardcoded `-O2` which often makes debugging
  impossible.

This patch addresses this by instead using `-O0` if `COMPILER_RT_DEBUG`.
Two tests in `sanitizer_type_traits_test.cpp` need to be disabled since
they have undefined references to `__sanitizer::integral_constant<bool,
true>::value`.

Tested on `sparcv9-sun-solaris2.11`, `amd64-pc-solaris2.11`, and
`x86_64-pc-linux-gnu`.

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

21 months ago[mlir][Linalg] Retire LinalgStrategyPeelPass and filter-based pattern.
Nicolas Vasilache [Tue, 4 Oct 2022 21:35:10 +0000 (14:35 -0700)]
[mlir][Linalg] Retire LinalgStrategyPeelPass and filter-based pattern.

Context: https://discourse.llvm.org/t/psa-retire-linalg-filter-based-patterns/63785

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

21 months ago[mlir] Add attribute constraints for sorted order.
Adrian Kuegel [Tue, 4 Oct 2022 08:51:56 +0000 (10:51 +0200)]
[mlir] Add attribute constraints for sorted order.

We often have constraints for array attributes that they are sorted
non-decreasing or strictly increasing. This change adds AttrConstraint classes
that support DenseArrayAttr for integer types.

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

21 months ago[libc] Add the POSIX waitpid function and the BSD wait4 function.
Siva Chandra Reddy [Tue, 4 Oct 2022 21:17:27 +0000 (21:17 +0000)]
[libc] Add the POSIX waitpid function and the BSD wait4 function.

Reviewed By: lntue, michaelrj

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

21 months ago[VP][NFC] Remove \brief commands from doxygen comments
Fraser Cormack [Wed, 5 Oct 2022 07:08:30 +0000 (08:08 +0100)]
[VP][NFC] Remove \brief commands from doxygen comments

Following a precedent set in D46861.

21 months ago[VP] Add IR expansion for vp.icmp and vp.fcmp
Fraser Cormack [Mon, 14 Mar 2022 11:22:52 +0000 (11:22 +0000)]
[VP] Add IR expansion for vp.icmp and vp.fcmp

These intrinsics are simply expanded to regular icmp/fcmp instructions.

Reviewed By: craig.topper

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

21 months ago[clang-tidy] Fix crashes on `if consteval` in readability checks
Emilia Dreamer [Wed, 5 Oct 2022 06:37:53 +0000 (09:37 +0300)]
[clang-tidy] Fix crashes on `if consteval` in readability checks

The `readability-braces-around-statements` check tries to look at the
closing parens of the if condition to determine where to insert braces,
however, "consteval if" statements don't have a condition, and always
have braces regardless, so the skip can be checked.

The `readability-simplify-boolean-expr` check looks at the condition
of the if statement to determine what could be simplified, but as
"consteval if" statements do not have a condition that could be
simplified, they can also be skipped here.

There may still be more checks that try to look at the conditions of
`if`s that aren't included here

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

Reviewed By: njames93, aaron.ballman

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

21 months ago[RegAllocFast] Clean-up. Remove redundant operations. NFC.
Serguei Katkov [Wed, 5 Oct 2022 03:57:30 +0000 (10:57 +0700)]
[RegAllocFast] Clean-up. Remove redundant operations. NFC.

Reviewed By: MatzeB, arsenm
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D109213

21 months ago[OpenMP] Eliminate the ThreadStates array in favor of indirection
Johannes Doerfert [Sun, 2 Oct 2022 16:45:08 +0000 (09:45 -0700)]
[OpenMP] Eliminate the ThreadStates array in favor of indirection

If we have thread states, the program is going to be rather slow. If we
don't, we want to avoid wasting shared memory. This patch introduces a
slight penalty (malloc + indirection) for the slow path and reduces
resource usage for the fast path.

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

21 months ago[OpenMP] Introduce more atomic operations into the runtime
Johannes Doerfert [Sun, 2 Oct 2022 16:34:41 +0000 (09:34 -0700)]
[OpenMP] Introduce more atomic operations into the runtime

We should use OpenMP atomics but they don't take variable orderings.
Maybe we should expose all of this in the header but that solves only
part of the problem anyway.

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

21 months ago[OpenMP] Replace __ATOMIC_XYZ with atomic::xyz for style
Johannes Doerfert [Sun, 2 Oct 2022 16:21:59 +0000 (09:21 -0700)]
[OpenMP] Replace __ATOMIC_XYZ with atomic::xyz for style

Also fixes one ordering argument not used.

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

21 months ago[Attributor] Qualify variables to avoid clashes in the future
Johannes Doerfert [Sun, 2 Oct 2022 17:19:28 +0000 (10:19 -0700)]
[Attributor] Qualify variables to avoid clashes in the future

21 months ago[OpenMP] Replace pointer comparison with `isSharedMemPtr` check
Johannes Doerfert [Tue, 4 Oct 2022 12:50:45 +0000 (05:50 -0700)]
[OpenMP] Replace pointer comparison with `isSharedMemPtr` check

The pointer comparison was causing confusion for capture tracking, let's
avoid confusion.

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

21 months ago[NVVM] Mark the pointer argument of `llvm.nvvm.isspace.*` `nocapture`
Johannes Doerfert [Tue, 4 Oct 2022 16:04:25 +0000 (09:04 -0700)]
[NVVM] Mark the pointer argument of `llvm.nvvm.isspace.*` `nocapture`

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

21 months ago[RISCV] Add isel patterns for vfmacc, vfnmacc, vfmsac and vfnmsac.
Yeting Kuo [Mon, 3 Oct 2022 12:09:23 +0000 (20:09 +0800)]
[RISCV] Add isel patterns for vfmacc, vfnmacc, vfmsac and vfnmsac.

The patch selects VSELECT_VL/VP_MERGE_VL that uses VF(N)M(ACC|SAC) as its
true operand and the adden of the true operand as its false operand.

Reviewed By: craig.topper

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

21 months ago[AArch64][Windows] Add llvm-readobj support for save_any_reg unwind opcode.
Eli Friedman [Wed, 5 Oct 2022 01:55:01 +0000 (18:55 -0700)]
[AArch64][Windows] Add llvm-readobj support for save_any_reg unwind opcode.

This is primarily used for Arm64EC, but it could be used for other
non-standard calling conventions. The testcase is based on an Arm64EC
thunk generated by MSVC.

The name save_any_reg comes from Microsoft documentation, but the full
encoding isn't specified there; this is reverse-engineered from the
behavior of the unwinder. (Thanks to Martin Storsjö for his example of
how to write simple unwinder testcases by directly calling
RtlVirtualUnwind.)

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

21 months ago[PowerPC] Fix the register allocation hints for ACC registers.
Stefan Pintilie [Tue, 4 Oct 2022 18:29:55 +0000 (13:29 -0500)]
[PowerPC] Fix the register allocation hints for ACC registers.

The allocation hints for copies of ACC registers assumed that we would only be
copying between VSRp and UACC registers. In reality it is also possible to copy
between UACC and ACC registers.

This patch adds a new case for the ACC copy to fix that issue.
Note that the test case added with this patch will hit an assert without the
fix.

Reviewed By: lei, amyk

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

21 months ago[clang-format] Handle C# interpolated verbatim string prefix @$
owenca [Sun, 2 Oct 2022 08:25:10 +0000 (01:25 -0700)]
[clang-format] Handle C# interpolated verbatim string prefix @$

Fixes #58062.

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

21 months ago[mlir][bufferization][NFC] Move EmptyTensorToAllocTensorPass
Matthias Springer [Wed, 5 Oct 2022 00:14:38 +0000 (09:14 +0900)]
[mlir][bufferization][NFC] Move EmptyTensorToAllocTensorPass

This change moves the pass from the Linalg dialect to the bufferization dialect.

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

21 months agoAdd APFloat and MLIR type support for fp8 (e5m2).
Stella Laurenzo [Wed, 27 Jul 2022 02:02:37 +0000 (19:02 -0700)]
Add APFloat and MLIR type support for fp8 (e5m2).

(Re-Apply with fixes to clang MicrosoftMangle.cpp)

This is a first step towards high level representation for fp8 types
that have been built in to hardware with near term roadmaps. Like the
BFLOAT16 type, the family of fp8 types are inspired by IEEE-754 binary
floating point formats but, due to the size limits, have been tweaked in
various ways in order to maximally use the range/precision in various
scenarios. The list of variants is small/finite and bounded by real
hardware.

This patch introduces the E5M2 FP8 format as proposed by Nvidia, ARM,
and Intel in the paper: https://arxiv.org/pdf/2209.05433.pdf

As the more conformant of the two implemented datatypes, we are plumbing
it through LLVM's APFloat type and MLIR's type system first as a
template. It will be followed by the range optimized E4M3 FP8 format
described in the paper. Since that format deviates further from the
IEEE-754 norms, it may require more debate and implementation
complexity.

Given that we see two parts of the FP8 implementation space represented
by these cases, we are recommending naming of:

* `F8M<N>` : For FP8 types that can be conceived of as following the
  same rules as FP16 but with a smaller number of mantissa/exponent
  bits. Including the number of mantissa bits in the type name is enough
  to fully specify the type. This naming scheme is used to represent
  the E5M2 type described in the paper.
* `F8M<N>F` : For FP8 types such as E4M3 which only support finite
  values.

The first of these (this patch) seems fairly non-controversial. The
second is previewed here to illustrate options for extending to the
other known variant (but can be discussed in detail in the patch
which implements it).

Many conversations about these types focus on the Machine-Learning
ecosystem where they are used to represent mixed-datatype computations
at a high level. At that level (which is why we also expose them in
MLIR), it is important to retain the actual type definition so that when
lowering to actual kernels or target specific code, the correct
promotions, casts and rescalings can be done as needed. We expect that
most LLVM backends will only experience these types as opaque `I8`
values that are applicable to some instructions.

MLIR does not make it particularly easy to add new floating point types
(i.e. the FloatType hierarchy is not open). Given the need to fully
model FloatTypes and make them interop with tooling, such types will
always be "heavy-weight" and it is not expected that a highly open type
system will be particularly helpful. There are also a bounded number of
floating point types in use for current and upcoming hardware, and we
can just implement them like this (perhaps looking for some cosmetic
ways to reduce the number of places that need to change). Creating a
more generic mechanism for extending floating point types seems like it
wouldn't be worth it and we should just deal with defining them one by
one on an as-needed basis when real hardware implements a new scheme.
Hopefully, with some additional production use and complete software
stacks, hardware makers will converge on a set of such types that is not
terribly divergent at the level that the compiler cares about.

(I cleaned up some old formatting and sorted some items for this case:
If we converge on landing this in some form, I will NFC commit format
only changes as a separate commit)

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

21 months ago[WebAssembly][MC] Fix missing `else` after `return` due to type checker bug
Sam Clegg [Tue, 4 Oct 2022 20:50:58 +0000 (13:50 -0700)]
[WebAssembly][MC] Fix missing `else` after `return` due to type checker bug

Once we are in the `Unreachable` we want to disable type checking, but
we were unconditionally returning `true` here which means we encountered
and error.  Instead we unconditionally return false to signal no error.

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

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

21 months ago[GlobalISel] Add computeNumSignBits() support for compares.
Amara Emerson [Tue, 4 Oct 2022 15:50:57 +0000 (16:50 +0100)]
[GlobalISel] Add computeNumSignBits() support for compares.

Doing so allows G_SEXT_INREG to be combined away for many vector cases.

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

21 months ago[AArch64][GlobalISel] Make vector G_SEXT_INREG legal and allow combining.
Amara Emerson [Tue, 4 Oct 2022 13:26:04 +0000 (14:26 +0100)]
[AArch64][GlobalISel] Make vector G_SEXT_INREG legal and allow combining.

As a result of making these legal, and tweaking the combine to allow vectors,
we generate vector G_SEXT_INREG during legalization.

The reason we want to make these legal in the first place is to allow for
more combine opportunities. Once those have been done, we can just lower them
back to shifts in the post-legalizer lowering.

This needs to be one commit otherwise we start causing tests to fail due to
incomplete support for selection etc.

21 months ago[flang] Add -fpass-plugin option to Flang frontend
Tarun Prabhu [Tue, 4 Oct 2022 23:02:45 +0000 (17:02 -0600)]
[flang] Add -fpass-plugin option to Flang frontend

Add the -fpass-plugin option to flang which dynamically loads LLVM passes from the
shared object passed as the argument to the flag. The behavior of the option is
designed to replicate that of the same option in clang and thus has the same
capabilities and limitations.

- Multiple instances of -fpass-plugin=path-to-file can be specified and each of the
  files will be loaded in that order.

- The flag can be passed to both flang-new and flang-new -fc1.

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