Commit Graph

437777 Commits

Author SHA1 Message Date
Peixin Qiao c4f04a126a [flang] Make real type of kind 10 target dependent
The real(10) is supported on x86_64. On aarch64, the value of
selected_real_kind(16) should be 16 rather than 10 since real(10)
is not supported on x86_64. Previously, the real type support check
is not target dependent. Support it now through the target triple
information.

Reviewed By: clementval

Differential Revision: https://reviews.llvm.org/D134021
2022-10-03 15:24:39 +08:00
Christian Sigg 2ddbe56b34 [Bazel] fixes for 9f77909. 2022-10-03 09:12:21 +02:00
Matthias Springer 90dac71a9a [mlir][bufferize][NFC] Fix FileCheck capture
One of the test cases matched IR from a subsequent test case. For this reason, the test case appeared to pass while it is actually broken.

This change does not fix the test case itself. It will be fixed when we overhaul the buffer deallocation implementation. (The memory leak in this test case is an edge case.)

Differential Revision: https://reviews.llvm.org/D135046
2022-10-03 16:06:10 +09:00
Amara Emerson 3daf7ddaef [GlobalISel] Allow prelegalizer combiners to have access to LegalizerInfo.
Before, the isPreLegalize() query in CombinerHelper only checked for the
presence of a LegalizerInfo object. This is problematic when we want to have
a combine actually check for legality in a pre-legalizer combine pass, since
if we pass a LegalizerInfo object to the constructor it causes the combines to
think that we're running *post* legalizer, which isn't true.

This change fixes it to instead check an explicit bool that passes to signal
whether the pass will be run before or after legalization.

Doing so exposed a bug in the extending loads combine, which tried to check for
legality of candidate extending loads if LegalizerInfo was present. Since we
only ran it pre-legalizer and therefore with a null LegalizerInfo, it never
actually ran. Also fixes the legality checks to keep the tests passing.

Differential Revision: https://reviews.llvm.org/D135044
2022-10-03 07:36:18 +01:00
Matthias Springer 598f5275c1 [mlir][interfaces] Add ShapedDimOpInterface
This interface is implemented by memref.dim and tensor.dim. This change makes it possible to remove a build dependency of the Affine dialect on the Tensor dialect (and maybe also the MemRef dialect in the future).

Differential Revision: https://reviews.llvm.org/D133595
2022-10-03 13:58:52 +09:00
Fangrui Song 9f9bab19e3 [ELF] Replace some config->ekind with file->ekind. NFC 2022-10-02 21:27:41 -07:00
Vitaly Buka e68c7a9917 Revert "Add APFloat and MLIR type support for fp8 (e5m2)."
Breaks bots https://lab.llvm.org/buildbot/#/builders/37/builds/17086

This reverts commit 2dc68b5398.
2022-10-02 21:22:44 -07:00
Fangrui Song d9dbf9e30a [ELF] Move init from ELFFileBase constructor to a separate function. NFC 2022-10-02 21:10:28 -07:00
Yuanqiang Liu 9f77909a5e [mlir][shape] add outline-shape-computation pass
Add outline-shape-computation pass. This pass his pass outlines the
shape computation part in high level IR by adding shape.func and
populate corresponding mapping information into ShapeMappingAnalysis.

Reviewed By: jpienaar

Differential Revision: https://reviews.llvm.org/D131810
2022-10-02 20:24:49 -07:00
Fangrui Song 8bcf22e318 [ELF] Remove redundant getELFKind call. NFC 2022-10-02 20:16:13 -07:00
Fangrui Song c171250e38 [ELF] Simplify addFile. NFC 2022-10-02 19:49:17 -07:00
Matthias Springer 2d2737667e [mlir][linalg][NFC] Drop emitAccessorPrefix from Linalg dialect
Differential Revision: https://reviews.llvm.org/D135048
2022-10-03 11:35:41 +09:00
LLVM GN Syncbot 2d27b56be5 [gn build] Port 71410fd2c0 2022-10-03 01:41:14 +00:00
Vitaly Buka 71410fd2c0 Revert "[libc++] Implement P0591R4 (Utility functions to implement uses-allocator construction)"
Breaks ubsan tests https://lab.llvm.org/buildbot/#/builders/85/builds/11131

This reverts commit 099384dcea.
2022-10-02 18:40:43 -07:00
Stella Laurenzo 2dc68b5398 Add APFloat and MLIR type support for fp8 (e5m2).
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
2022-10-02 17:17:08 -07:00
luxufan 069d7ef084 [RISCV] Add a LocalStackSlotAllocation test
Differential Revision: https://reviews.llvm.org/D134884
2022-09-30 22:36:03 +00:00
LLVM GN Syncbot 7578d337b5 [gn build] Port a6e1080b87 2022-10-02 23:53:57 +00:00
Vitaly Buka a6e1080b87 Revert "[libc++][ranges]Refactor `copy{,_backward}` and `move{,_backward}`"
Breaks msan, asan

https://lab.llvm.org/buildbot/#/builders/5/builds/27904

This reverts commit 005916de58.
2022-10-02 16:23:35 -07:00
Fangrui Song 961439cd7e [ELF] Add LLVM_LIBRARY_VISIBILITY to some global variables. NFC 2022-10-02 13:23:52 -07:00
Valentin Clement 262c23d2ca
[flang] Introduce fir.class type
Introduce a new ClassType for polymorphic
entities. A fir.class type is similar to a fir.box type in
many ways and is also base on the BaseBoxType.

This patch is part of the implementation of the poltymorphic
entities.
https://github.com/llvm/llvm-project/blob/main/flang/docs/PolymorphicEntities.md

Depends on D134956

Reviewed By: jeanPerier

Differential Revision: https://reviews.llvm.org/D134957
2022-10-02 20:13:51 +02:00
Valentin Clement ceff415a1a
[flang] Introduce BaseBoxType
Introduce a BaseBoxType to be used by BoxType and
the a new ClassType that is introduced in a follow up patch.

This patch is part of the implementation of the poltymorphic
entities.
https://github.com/llvm/llvm-project/blob/main/flang/docs/PolymorphicEntities.md

Reviewed By: PeteSteinfeld

Differential Revision: https://reviews.llvm.org/D134956
2022-10-02 20:08:54 +02:00
Fangrui Song fd9fd4fa08 [llvm-objdump][test] Improve address test 2022-10-02 10:49:52 -07:00
Mark de Wever cfd5b8f111 [libc++] Updates generated transitve includes.
This should fix the CI.
2022-10-02 19:37:21 +02:00
Sanjay Patel 2e87333bfe [InstCombine] convert mul by negative-pow2 to negate and shift
This is an unusual canonicalization because we create an extra instruction,
but it's likely better for analysis and codegen (similar reasoning as D133399).

InstCombine::Negator may create this kind of multiply from negate and shift,
but this should not conflict because of the narrow negation.

I don't know how to create a fully general proof for this kind of transform in
Alive2, but here's an example with bitwidths similar to one of the regression
tests:
https://alive2.llvm.org/ce/z/J3jTjR

Differential Revision: https://reviews.llvm.org/D133667
2022-10-02 12:22:25 -04:00
Sanjay Patel 4490cfbaf4 [ValueTracking] peek through fpext in isKnownNeverInfinity()
https://alive2.llvm.org/ce/z/BkNoRW
2022-10-02 11:20:23 -04:00
Sanjay Patel 0243b424d7 [InstSimplify] add tests for FP infinity compare with fpext; NFC 2022-10-02 11:20:23 -04:00
David Green 5e1a9d319d [ARM] Add lowering for bf16 neon vtrn, vzup and vuzp.
These go via Dag2Dag, which are better based on element sizes not the
exact element types.
2022-10-02 15:34:37 +01:00
David Green f2fde99461 [ARM] More bf16 shuffle handling, including perfect shuffles. 2022-10-02 14:31:51 +01:00
Florian Hahn 3fe6ddd999
[ConstraintElimination] Update Changed status in ssub simplification.
Update tryToSimplifyOverflowMath to indicate whether the function made
any changes to the IR.
2022-10-02 14:25:51 +01:00
David Green 8193f0d1d2 [ARM] Add tablegen patterns for bf16 vrev 2022-10-02 13:42:14 +01:00
David Green 58369c8631 [ARM] Add tablegen patterns for bf16 vext
This adds missing tablegen patterns for VEXT, identical to the fp16
patterns as they only use baseline Neon operations.
Part of fixing #57770.
2022-10-02 12:45:58 +01:00
David Green 3651635eca [ARM][DAG] BF16 constant handling.
Much like f16 and f32, we shouldn't try to shrink bf16 to smaller fp
constant.  The code may not be optimal, but this allows us to legalize
bf16 constants under Arm without errors.
2022-10-02 11:51:08 +01:00
Peixin Qiao 3f0ad8558a Revert "[flang] Make real type of kind 10 target dependent"
This reverts commit d11e406e36.
2022-10-02 17:45:03 +08:00
Fangrui Song 6f46ff3765 [test] Make Linux/sem_init_glibc.cpp robust
and fix it for 32-bit ports defining sem_init@GLIBC_2.0 (i386, mips32, powerpc32) for glibc>=2.36.

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

Reviewed By: mgorny

Differential Revision: https://reviews.llvm.org/D135023
2022-10-02 00:47:10 -07:00
Peixin Qiao 4e43a14bdb [flang][OpenMP] Fix resolve common block in data-sharing clauses
The previous resolve only creates the host associated varaibles for
common block members, but does not replace the original objects with
the new created ones. Fix it and also compute the sizes and offsets
for the host common block members if they are host associated.

Reviewed By: kiranchandramohan

Differential Revision: https://reviews.llvm.org/D127214
2022-10-02 10:38:27 +08:00
Peixin Qiao d11e406e36 [flang] Make real type of kind 10 target dependent
The real(10) is supported on x86_64. On aarch64, the value of
selected_real_kind(16) should be 16 rather than 10 since real(10)
is not supported on x86_64. Previously, the real type support check
is not target dependent. Support it now through the target triple
information.

Reviewed By: clementval

Differential Revision: https://reviews.llvm.org/D134021
2022-10-02 10:30:49 +08:00
Kees Cook aef03c9b3b [clang][auto-init] Deprecate -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang
GCC 12 has been released and contains unconditional support for
-ftrivial-auto-var-init=zero:
https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html#index-ftrivial-auto-var-init

Maintain compatibility with GCC, and remove the -enable flag for "zero"
mode. The flag is left to generate an "unused" warning, though, to not
break all the existing users. The flag will be fully removed in Clang 17.

Link: https://github.com/llvm/llvm-project/issues/44842

Reviewed By: nickdesaulniers, MaskRay, srhines, xbolva00

Differential Revision: https://reviews.llvm.org/D125142
2022-10-01 18:45:45 -07:00
LLVM GN Syncbot facfdbe25b [gn build] Port 005916de58 2022-10-02 00:35:45 +00:00
Konstantin Varlamov 005916de58 [libc++][ranges]Refactor `copy{,_backward}` and `move{,_backward}`
Instead of using `reverse_iterator`, share the optimization between the 4 algorithms. The key observation here that `memmove` applies to both `copy` and `move` identically, and to their `_backward` versions very similarly. All algorithms now follow the same pattern along the lines of:
```
if constexpr (can_memmove<InIter, OutIter>) {
  memmove(first, last, out);
} else {
  naive_implementation(first, last, out);
}
```
A follow-up will delete `unconstrained_reverse_iterator`.

This patch removes duplication and divergence between `std::copy`, `std::move` and `std::move_backward`. It also improves testing:
- the test for whether the optimization is used only applied to `std::copy` and, more importantly, was essentially a no-op because it would still pass if the optimization was not used;
- there were no tests to make sure the optimization is not used when the effect would be visible.

Differential Revision: https://reviews.llvm.org/D130695
2022-10-01 17:35:12 -07:00
Kazu Hirata 240f41c8e4 [mlir] Use std::enable_if_t (NFC) 2022-10-01 17:24:56 -07:00
Kazu Hirata 9d0d4046c0 [clang] Use std::enable_if_t (NFC) 2022-10-01 17:24:54 -07:00
Kazu Hirata 66bb0ac251 [ADT] Use std::common_type_t (NFC) 2022-10-01 17:24:52 -07:00
Jacques Pienaar 765ac6e9df [mlir] Remove ReferTo attr constraint
The current generation is unsafe as it is evaluated during verify
invocation rather than during verifySymbolUses. Remove until this is
safely generated.

Differential Revision: https://reviews.llvm.org/D134558
2022-10-01 17:19:14 -07:00
Arthur Eubanks 5df4ab55f9 [llvm] Migrate PAEval to new pass manager 2022-10-01 16:41:58 -07:00
Craig Topper 5bbc5eb55f [RISCV] Use _TIED form of VWADD(U)_WX/VWSUB(U)_WX to avoid early clobber.
One of the sources is the same size as the destination so that source
doesn't have an overlap with the destination register. By using the _TIED
form we avoid an early clobber contraint for that source.

This matches what was already done for instrinsics. ConvertToThreeAddress
will fix it if it can't stay tied.
2022-10-01 16:34:39 -07:00
Craig Topper 85db4f10e3 [RISCV] Minor tablegen formatting cleanup. NFC 2022-10-01 15:59:25 -07:00
Fangrui Song 1837333dac [ELF] --check-sections: allow address 0xffffffff for ELFCLASS32
Fix https://github.com/llvm/llvm-project/issues/58101
2022-10-01 15:37:07 -07:00
Fangrui Song dd6aea9582 [ELF] Rename LinkerScript::ctx to state. NFC
To avoid name conflict with `elf::ctx`.
2022-10-01 15:27:39 -07:00
Jessica Paquette 8aedb435db [GlobalISel] Combine abs(undef) -> 0
SDAG does this, GISel doesn't.

See https://gcc.godbolt.org/z/sqjMx3Tfv

More context:
https://github.com/llvm/llvm-project/issues/57256

Differential Revision: https://reviews.llvm.org/D135021
2022-10-01 15:16:32 -07:00
Fangrui Song f596d82385 [ELF] Move driver into ctx and remove indirection. NFC
This removes one global variable and removes GOT and unique_ptr indirection.
2022-10-01 15:12:50 -07:00