platform/upstream/llvm.git
2 years agotsan: enable clone interceptor only on Linux
Dmitry Vyukov [Thu, 11 Nov 2021 18:17:17 +0000 (19:17 +0100)]
tsan: enable clone interceptor only on Linux

Clone does not exist on Mac.
There are chances it will break on other OSes.
Enable it incrementally starting with Linux only,
other OSes can enable it later as needed.

Reviewed By: melver, thakis

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

2 years ago[NFC][InlineAdvisor] Inform advisor when the module is invalidated
Mircea Trofin [Thu, 11 Nov 2021 18:23:40 +0000 (10:23 -0800)]
[NFC][InlineAdvisor] Inform advisor when the module is invalidated

This avoids unnecessary re-calculation of module-wide features in the
MLInlineAdvisor. In cases where function passes don't invalidate
functions (and, thus, don't invalidate the module), but we re-process a
CGSCC, we currently refreshed module features unnecessarily. The
overhead of fetching cached results (albeit they weren't themselves
invalidated) was noticeable in certain modules' compilations.

We don't want to just invalidate the advisor object, though, via the
analysis manager, because we'd then need to re-create expensive state
(like the model evaluator in the ML 'development' mode).

Reviewed By: phosek

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

2 years ago[AArch64] Add some fp16 cast cost-model tests.
Florian Hahn [Thu, 11 Nov 2021 18:21:44 +0000 (18:21 +0000)]
[AArch64] Add some fp16 cast cost-model tests.

This adds initial tests for cost-modeling {u,s}itofp for fp16 vectors.
At the moment, they are under-estimated in a couple of cases.

2 years ago[libc] tweak strtof errno behavior
Michael Jones [Thu, 11 Nov 2021 00:19:29 +0000 (16:19 -0800)]
[libc] tweak strtof errno behavior

When strtof/d/ld return a subnormal number they may set errno to
ERANGE. This change makes this behavior more consistent by making any
decimal number converting to a subnormal set errno to ERANGE. This
brings it in line with hexadecimals, which currently only set errno to
ERANGE if the number is truncated when converting to a subnormal.

Reviewed By: sivachandra, lntue

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

2 years ago[libc] clean up FPUtil long doubles
Michael Jones [Thu, 11 Nov 2021 00:11:18 +0000 (16:11 -0800)]
[libc] clean up FPUtil long doubles

Add quietNaNMask consts to FloatProperties and make LongDoubleBitsX86
clear the extra bits that aren't set when initializing with an 80 bit
long double.

Reviewed By: sivachandra, lntue

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

2 years ago[flang][CodeGen] Transform `IsPresentOpConversion` and `AbsentOpConversion`
Andrzej Warzynski [Mon, 8 Nov 2021 11:35:48 +0000 (11:35 +0000)]
[flang][CodeGen] Transform `IsPresentOpConversion` and `AbsentOpConversion`

This patch extends the `FIRToLLVMLowering` pass in Flang by adding
hooks to transform `fir.is_present` and `fir.absent` to the LLVM dialect
of MLIR.

This is part of the upstreaming effort from the `fir-dev` branch in [1].

[1] https://github.com/flang-compiler/f18-llvm-project

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

Originally written by:
Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
2 years ago[gn build] (manually) port 57c22ade867
Nico Weber [Thu, 11 Nov 2021 18:07:17 +0000 (13:07 -0500)]
[gn build] (manually) port 57c22ade867

2 years ago[InstCombine] Handle undefs in and of icmp eq zero fold
Nikita Popov [Thu, 11 Nov 2021 17:59:03 +0000 (18:59 +0100)]
[InstCombine] Handle undefs in and of icmp eq zero fold

For the scalar/splat case, this fold is subsumed by
foldLogOpOfMaskedICmps(). However, the conjugated fold for "or"
also supports splats with undef. Make both code paths consistent
by using m_ZeroInt() for the "and" implementation as well.

https://alive2.llvm.org/ce/z/tN63cu
https://alive2.llvm.org/ce/z/ufB_Ue

2 years ago[libc++] Implement P2186R2 (Remove Garbage Collection)
Nikolas Klauser [Thu, 11 Nov 2021 17:57:25 +0000 (18:57 +0100)]
[libc++] Implement P2186R2 (Remove Garbage Collection)

Reviewed By: Quuxplusone, #libc, ldionne

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

2 years ago[InstCombine] Add test for and of icmp ne zero with undefs (NFC)
Nikita Popov [Thu, 11 Nov 2021 17:59:07 +0000 (18:59 +0100)]
[InstCombine] Add test for and of icmp ne zero with undefs (NFC)

We handle this in the conjugated "or" fold, but not for "and".

2 years ago[libc++] Use addressof in list.
Mark de Wever [Wed, 27 Oct 2021 16:50:07 +0000 (18:50 +0200)]
[libc++] Use addressof in list.

This addresses the usage of `operator&` in `<list>`.

(Note there are still more headers with the same issue.)

Reviewed By: #libc, Quuxplusone, ldionne

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

2 years agotsan: intercept clone
Dmitry Vyukov [Thu, 11 Nov 2021 15:17:58 +0000 (16:17 +0100)]
tsan: intercept clone

gtest uses clone for death tests and it needs the same
handling as fork to prevent deadlock (take runtime mutexes
before and release them after).

Reviewed By: melver

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

2 years ago[mlir][Linalg] Add 1-d depthwise conv with opdsl
Nicolas Vasilache [Thu, 11 Nov 2021 17:33:24 +0000 (17:33 +0000)]
[mlir][Linalg] Add 1-d depthwise conv with opdsl

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

2 years ago[mlir][Linalg] Make a LinalgStrategyDecomposePass available.
Nicolas Vasilache [Thu, 11 Nov 2021 14:18:57 +0000 (14:18 +0000)]
[mlir][Linalg] Make a LinalgStrategyDecomposePass available.

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

2 years ago[libc++] Use addressof in forward_list.
Mark de Wever [Wed, 27 Oct 2021 20:27:05 +0000 (22:27 +0200)]
[libc++] Use addressof in forward_list.

This addresses the usage of `operator&` in `<forward_list>`.

(Note there are still more headers with the same issue.)

Reviewed By: #libc, Quuxplusone, ldionne

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

2 years ago[lld][ELF] Support for R_ARM_THM_JUMP8
Petr Hosek [Tue, 9 Nov 2021 20:35:44 +0000 (12:35 -0800)]
[lld][ELF] Support for R_ARM_THM_JUMP8

This change implements support for R_ARM_THM_JUMP8 relocation in
addition to R_ARM_THM_JUMP11 which is already supported by LLD.

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

2 years ago[X86] Honor command line features along with cpu_specific attribute
Craig Topper [Thu, 11 Nov 2021 16:37:11 +0000 (08:37 -0800)]
[X86] Honor command line features along with cpu_specific attribute

If the feature is on the command line we should honor it for all
functions. I don't think we could reliably target a single function
for a less capable processor than what the rest of the program is
compiled for.

Fixes PR52407.

Reviewed By: erichkeane

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

2 years ago[PowerPC][NFC] Ignore unused var in release builds.
Jordan Rupprecht [Thu, 11 Nov 2021 16:57:40 +0000 (08:57 -0800)]
[PowerPC][NFC] Ignore unused var in release builds.

Note we can't inline this call into assert because `isIntS16Immediate` has a side effect. But we only look at the return value in asserts builds.

2 years ago[RISCV] Fix non-sensical intrinsic names in rv64i-single-softfloat.ll. NFC
Craig Topper [Thu, 11 Nov 2021 16:33:29 +0000 (08:33 -0800)]
[RISCV] Fix non-sensical intrinsic names in rv64i-single-softfloat.ll. NFC

Many of these had an extra 'f' at the beginning of their name that
caused them to not be treated as intrinsics.

I'm not sure what fpround was supposed to be so I deleted it.

frem was changed from an intrinsic to an instruction.

Reviewed By: luismarques

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

2 years agoSplit headers from implementations in MLIR C API Bazel build.
Peter Hawkins [Thu, 11 Nov 2021 16:34:18 +0000 (08:34 -0800)]
Split headers from implementations in MLIR C API Bazel build.

This allows clients to build, e.g., the Python bindings against the C API headers, without including the C API implementations. This is useful when distributing software as multiple shared libraries.

Reviewed By: GMNGeoffrey

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

2 years ago[RISCV] Promote f16 ceil/floor/round/roundeven/nearbyint/rint/trunc intrinsics to...
Craig Topper [Thu, 11 Nov 2021 16:27:58 +0000 (08:27 -0800)]
[RISCV] Promote f16 ceil/floor/round/roundeven/nearbyint/rint/trunc intrinsics to f32 libcalls.

Previously these would crash. I don't think these can be generated
directly from C. Not sure if any optimizations can introduce them.

Reviewed By: asb

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

2 years ago[libc++] Implement P1147R1 (Printing volatile T*)
Nikolas Klauser [Tue, 9 Nov 2021 16:41:46 +0000 (11:41 -0500)]
[libc++] Implement P1147R1 (Printing volatile T*)

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

2 years ago[libc++] Fix GDB pretty printer test on 32 bit targets
Louis Dionne [Thu, 11 Nov 2021 16:06:07 +0000 (11:06 -0500)]
[libc++] Fix GDB pretty printer test on 32 bit targets

On 32 bit targets, size_t is unsigned int, not unsigned long, so
std::bitset's template argument gets printed with a `u` suffix,
not `ul`.

2 years ago[PowerPC] PPC backend optimization to lower int_ppc_tdw/int_ppc_tw intrinsics to...
Victor Huang [Wed, 10 Nov 2021 19:58:36 +0000 (13:58 -0600)]
[PowerPC] PPC backend optimization to lower int_ppc_tdw/int_ppc_tw intrinsics to TDI/TWI machine instructions

This patch adds the backend optimization to match XL behavior for the two
builtins __tdw and __tw that when the second input argument is an immediate,
emitting tdi/twi instructions instead of td/tw.

Reviewed By: nemanjai, amyk, PowerPC

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

2 years ago[AIX] Set D111860's test unsupported on AIX
Kai Luo [Thu, 11 Nov 2021 15:50:11 +0000 (15:50 +0000)]
[AIX] Set D111860's test unsupported on AIX

Reviewed By: jsji

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

2 years ago[DAGCombiner] add fold for vselect based on mask of signbit, part 3
Sanjay Patel [Thu, 11 Nov 2021 15:24:24 +0000 (10:24 -0500)]
[DAGCombiner] add fold for vselect based on mask of signbit, part 3

(Cond0 s> -1) ? N1 : 0 --> ~(Cond0 s>> BW-1) & N1

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

This was suggested as a potential enhancement in D113212 (also 7e30404c3b6c ).
There's an improvement for AArch that could be generalized ( X > -1 --> X >= 0 ).
For x86, we have a counter-acting fold for most cases that turns the shift+not
back into a setcc, so that needs a work-around to get more cases to use "pandn":
D113603

Note that this pattern (and a previous one) are not currently canonical forms
in IR:
https://alive2.llvm.org/ce/z/e4o96b

Adding swapped variants is left as a TODO item here, but is planned as
a near-term follow-up patch.

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

2 years ago[AMDGPU] Regenerate some div/rem test checks
Jay Foad [Thu, 11 Nov 2021 15:26:22 +0000 (15:26 +0000)]
[AMDGPU] Regenerate some div/rem test checks

2 years ago[CodeGen] Tweak whitespace in LiveInterval printing
Jay Foad [Thu, 11 Nov 2021 13:31:52 +0000 (13:31 +0000)]
[CodeGen] Tweak whitespace in LiveInterval printing

When printing a LiveInterval, tweak the use of single and double spaces
to try to make it clearer that the valnos are associated with the
preceding range or subrange, not the following subrange.

Compare the output before and then after this patch:
%1 [32r,144r:0)  0@32r L000000000000000C [32r,144r:0)  0@32r L00000000000000F3 [32r,32d:0)  0@32r weight:0.000000e+00
%1 [32r,144r:0) 0@32r  L000000000000000C [32r,144r:0) 0@32r  L00000000000000F3 [32r,32d:0) 0@32r  weight:0.000000e+00

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

2 years ago[AMDGPU] Fix line endings
Jay Foad [Thu, 11 Nov 2021 15:16:57 +0000 (15:16 +0000)]
[AMDGPU] Fix line endings

2 years ago[CodeGen] Use MachineInstr::operands (NFC)
Kazu Hirata [Thu, 11 Nov 2021 15:10:30 +0000 (07:10 -0800)]
[CodeGen] Use MachineInstr::operands (NFC)

2 years ago[mlir][linalg] Avoid illegal elementwise fusion into reductions
Stephan Herhut [Thu, 11 Nov 2021 14:54:26 +0000 (15:54 +0100)]
[mlir][linalg] Avoid illegal elementwise fusion into reductions

Fusing into a reduction is only valid if doing so does not erase information on a reduction dimensions size.

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

2 years ago[fir] Add !fir.field type conversion
Valentin Clement [Thu, 11 Nov 2021 14:39:24 +0000 (15:39 +0100)]
[fir] Add !fir.field type conversion

This patch adds conversion for !fir.field types.

This patch is part of the upstreaming effort from fir-dev branch.

Reviewed By: kiranchandramohan

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

Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
2 years ago[fir] Add fir.select_case conversion
Valentin Clement [Thu, 11 Nov 2021 14:00:18 +0000 (15:00 +0100)]
[fir] Add fir.select_case conversion

The `fir.select_case` operation is converted to a if-then-else ladder.

Conversion of `fir.select_case` operation with character is not
implemented yet.

This patch is part of the upstreaming effort from fir-dev branch.

Reviewed By: kiranchandramohan, mehdi_amini

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

Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
2 years ago[fir] Add placeholder conversion pattern for disptach operations
Valentin Clement [Thu, 11 Nov 2021 12:58:39 +0000 (13:58 +0100)]
[fir] Add placeholder conversion pattern for disptach operations

`fir.dispatch`, `fir.dispatch_table` and `fir.dt_entry` are operations
for type-bound procedures. This patch just adds placeholder conversion
pattern that currently fails since F2003 is not implemented yet.

This patch is part of the upstreaming effort from fir-dev branch.

Reviewed By: kiranchandramohan

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

2 years agoMaking the code compliant to the documentation about Floating Point
Zahira Ammarguellat [Tue, 9 Nov 2021 14:35:25 +0000 (09:35 -0500)]
Making the code compliant to the documentation about Floating Point
support default values for C/C++. FPP-MODEL=PRECISE enables
FFP-CONTRACT(FMA is enabled).

Fix for https://bugs.llvm.org/show_bug.cgi?id=50222

2 years ago[TwoAddressInstruction] Update LiveIntervals after rewriting INSERT_SUBREG to COPY
Jay Foad [Tue, 28 Sep 2021 16:27:28 +0000 (17:27 +0100)]
[TwoAddressInstruction] Update LiveIntervals after rewriting INSERT_SUBREG to COPY

Also add subranges to an existing live interval when introducing a new
subreg def.

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

2 years ago[LiveIntervals] Update subranges in processTiedPairs
Jay Foad [Fri, 24 Sep 2021 12:57:45 +0000 (13:57 +0100)]
[LiveIntervals] Update subranges in processTiedPairs

In TwoAddressInstructionPass::processTiedPairs when updating live
intervals after moving the last use of RegB back to the newly inserted
copy, update any affected subranges as well as the main range.

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

2 years ago[mlir][X86Vector] Fix unused variable warning
Benjamin Kramer [Thu, 11 Nov 2021 12:18:19 +0000 (13:18 +0100)]
[mlir][X86Vector] Fix unused variable warning

2 years ago[mlir][Vector] Silence recently introduced warnings
Nicolas Vasilache [Thu, 11 Nov 2021 12:05:23 +0000 (12:05 +0000)]
[mlir][Vector] Silence recently introduced warnings

2 years ago[DAG] reassociateOpsCommutative - peek through bitcasts to find constants
Simon Pilgrim [Thu, 11 Nov 2021 12:00:12 +0000 (12:00 +0000)]
[DAG] reassociateOpsCommutative - peek through bitcasts to find constants

Now that FoldConstantArithmetic can fold bitcasted constants, we should peek through bitcasts of binop operands to try and find foldable constants

2 years ago[lldb][NFC] Remove commented out code in SymbolFileDWARF
Raphael Isemann [Thu, 11 Nov 2021 11:45:38 +0000 (12:45 +0100)]
[lldb][NFC] Remove commented out code in SymbolFileDWARF

2 years ago[lldb][NFC] Remove no longer valid comment for TypeSystem::SetSymbolFile
Raphael Isemann [Thu, 11 Nov 2021 11:39:54 +0000 (12:39 +0100)]
[lldb][NFC] Remove no longer valid comment for TypeSystem::SetSymbolFile

2 years ago[DAG] FoldConstantArithmetic - fold intop(bitcast(buildvector(c1)),bitcast(buildvecto...
Simon Pilgrim [Thu, 11 Nov 2021 11:35:07 +0000 (11:35 +0000)]
[DAG] FoldConstantArithmetic - fold intop(bitcast(buildvector(c1)),bitcast(buildvector(c1))) -> bitcast(intop(buildvector(c1'),buildvector(c2')))

Enable FoldConstantArithmetic to constant fold bitcasted constant build vectors. These have typically been bitcasted for type legalization purposes.

By extracting the raw constant bit data, performing the constant fold, and then casting the constant bit data back to the (legalized) type, we can perform constant folding on integer types after legalization.

This in particular helps 32-bit targets which need to handle vXi64 build vectors - during legalization the (unsupported) i64 elements are split to create a bitcasted v2Xi32 build vector.

Addresses some regressions in D113192.

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

2 years ago[lldb][AArch64] Add UnwindPlan for Linux sigreturn
David Spickett [Fri, 8 Oct 2021 10:44:23 +0000 (10:44 +0000)]
[lldb][AArch64] Add UnwindPlan for Linux sigreturn

This adds a specific unwind plan for AArch64 Linux sigreturn frames.
Previously we assumed that the fp would be valid here but it is not.

https://github.com/torvalds/linux/blob/master/arch/arm64/kernel/vdso/sigreturn.S

On Ubuntu Bionic it happened to point to an old frame info which meant
you got what looked like a correct backtrace. On Focal, the info is
completely invalid. (probably due to some code shuffling in libc)

This adds an UnwindPlan that knows that the sp in a sigreturn frame
points to an rt_sigframe from which we can offset to get saved
sp and pc values to backtrace correctly.

Based on LibUnwind's change: https://reviews.llvm.org/D90898

A new test is added that sets all compares the frames from the initial
signal catch to the handler break. Ensuring that the stack/frame pointer,
function name and register values match.
(this test is AArch64 Linux specific because it's the only one
with a specific unwind plan for this situation)

Fixes https://bugs.llvm.org/show_bug.cgi?id=52165

Reviewed By: omjavaid, labath

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

2 years ago[fir] Add !fir.alloca conversion
Diana Picus [Mon, 8 Nov 2021 10:59:48 +0000 (10:59 +0000)]
[fir] Add !fir.alloca conversion

Convert !fir.alloca into !llvm.alloca.

This also contains a fix for verifyInType in FIROps.cpp, to make sure we
can handle a !fir.ptr<!fir.array<?xN>>.

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

Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
Co-authored-by: Jean Perier <jperier@nvidia.com>
2 years ago[flang][codegen] Add type conversion for `fir.boxchar`
Andrzej Warzynski [Wed, 10 Nov 2021 16:00:31 +0000 (16:00 +0000)]
[flang][codegen] Add type conversion for `fir.boxchar`

This is part of the upstreaming effort from the `fir-dev` branch in [1].

[1] https://github.com/flang-compiler/f18-llvm-project

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

Patch originally written by:
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
Co-authored-by: Jean Perier <jperier@nvidia.com>
2 years ago[fir] Add !fir.vector type conversion
Valentin Clement [Thu, 11 Nov 2021 10:21:14 +0000 (11:21 +0100)]
[fir] Add !fir.vector type conversion

This patch adds the !fir.vector type conversion. The type is converted
to the builtin vector type.

This patch is part of the upstreaming effort from fir-dev branch.

Reviewed By: kiranchandramohan

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

Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
2 years ago[lldb] Add support for demangling D symbols
Luís Ferreira [Thu, 11 Nov 2021 09:42:14 +0000 (10:42 +0100)]
[lldb] Add support for demangling D symbols

This is part of https://github.com/dlang/projects/issues/81 .

This patch enables support for D programming language demangler by using a
pretty printed stacktrace with demangled D symbols, when present.

Signed-off-by: Luís Ferreira <contact@lsferreira.net>
Reviewed By: JDevlieghere, teemperor

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

2 years ago[flang][nfc] Tidy up in CodeGen.cpp and TypeConverter.h
Andrzej Warzynski [Wed, 10 Nov 2021 15:24:39 +0000 (15:24 +0000)]
[flang][nfc] Tidy up in CodeGen.cpp and TypeConverter.h

Some header `#include`s that belong in TypeConverter.h rather than in
CodeGen.cpp are moved accordingly. As TypeConverter.h is currently only
used in CodeGen.cpp, this wouldn't cause any build issues (ultimately,
all the required headers are included). However, this would become a problem
when including TypeConverter.h elsewhere.

Also, from [1], "(...) include all of the header files that you are
using ". This is currently not the case in TypeConverter.h and hence the
`#include`s should be moved.

I've also added missing namespace qualifiers in a few places in
TypeConverter.h

[1] https://llvm.org/docs/CodingStandards.html#include-as-little-as-possible

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

2 years ago[mlir][linalg][bufferize] Remove remaining linalg dependencies
Matthias Springer [Thu, 11 Nov 2021 09:50:14 +0000 (18:50 +0900)]
[mlir][linalg][bufferize] Remove remaining linalg dependencies

* Move "linalg.inplaceable" attr name literals to BufferizableOpInterface.
* Use `memref.copy` by default. Override to `linalg.copy` in ComprehensiveBufferizePass.

These are the last remaining code dependencies on Linalg in Comprehensive Bufferize. The next commit will make ComprehensiveBufferize independent of the Linalg dialect.

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

2 years ago[fir] Add fir.box_isarray, fir.box_isptr and fir.box_isalloc conversion.
Valentin Clement [Thu, 11 Nov 2021 09:39:02 +0000 (10:39 +0100)]
[fir] Add fir.box_isarray, fir.box_isptr and fir.box_isalloc conversion.

This patch is part of the upstreaming effort from fir-dev branch.

Reviewed By: awarzynski

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

Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
2 years ago[mlir][linalg][bufferize] Group helpers in BufferizationState
Matthias Springer [Thu, 11 Nov 2021 09:23:13 +0000 (18:23 +0900)]
[mlir][linalg][bufferize] Group helpers in BufferizationState

This simplifies the signature of `bufferize`.

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

2 years ago[extract_symbols.py] Fix llvm-readobj options.
Simon Tatham [Thu, 11 Nov 2021 09:12:57 +0000 (09:12 +0000)]
[extract_symbols.py] Fix llvm-readobj options.

As of D105532, a couple of llvm-readobj options have slightly changed
their spellings. '-file-headers' has become '--file-header', and
'-symbols' has become '--symbols'. A modern llvm-readobj will respond
to those single-dash spellings by trying to parse them as combinations
of single-letter options, so that you get "unknown argument '-f'" for
-file-headers, and "unknown argument '-y'" for the second letter of
-symbols.

extract_symbols.py was still invoking llvm-readobj with those old
single-dash spellings. Changed them to the newly canonical ones, which
as far as I can tell still work on llvm-readobj from before the
change.

Reviewed By: MaskRay

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

2 years ago[AArch64] Use custom lowering for {U,S}INT_TO_FP with i8.
Florian Hahn [Thu, 11 Nov 2021 08:47:15 +0000 (08:47 +0000)]
[AArch64] Use custom lowering for {U,S}INT_TO_FP with i8.

With fullfp16, it is cheaper to cast the {U,S}INT_TO_FP operand to i16
first, rather than promoting it to i32. The custom lowering for
{U,S}INT_TO_FP  already supports that, it just needs to be used.

Reviewed By: dmgreen

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

2 years ago[LoopInfo] Fix function getInductionVariable
duanbo.db [Thu, 11 Nov 2021 08:22:42 +0000 (16:22 +0800)]
[LoopInfo] Fix function getInductionVariable

The way function gets the induction variable is by judging whether
StepInst or IndVar in the phi statement is one of the operands of CMP.
But if the LatchCmpOp0/LatchCmpOp1 is a constant,  the subsequent
comparison may result in null == null, which is meaningless. This patch
fixes the typo.

Reviewed By: Whitney

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

2 years ago[Polly][Isl] Fix -Wsign-compare after D113101
Fangrui Song [Thu, 11 Nov 2021 08:17:51 +0000 (00:17 -0800)]
[Polly][Isl] Fix -Wsign-compare after D113101

2 years ago[Driver] Change Linux::isPIEDefault to true for all Android versions
Fangrui Song [Thu, 11 Nov 2021 08:12:07 +0000 (00:12 -0800)]
[Driver] Change Linux::isPIEDefault to true for all Android versions

Currently any API level>=16 uses default PIE.
If API level<16 is too old to be supported, we can clean up some code.

Reviewed By: danalbert

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

2 years ago[ELF] Better resemble GNU ld when placing orphan sections into memory regions
Igor Kudrin [Thu, 11 Nov 2021 08:07:38 +0000 (15:07 +0700)]
[ELF] Better resemble GNU ld when placing orphan sections into memory regions

An orphan section should be placed in the same memory region as its
anchor section if the latter specifies the memory region explicitly.
If there is no explicit assignment for the anchor section in the linker
script, its memory region is selected by matching attributes, and the
same should be done for the orphan section.

Before the patch, some scripts that were handled smoothly in GNU ld
caused an "error: no memory region specified for section" in lld.

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

2 years ago[mlir] Fix build post 34ff8573505e04c75e84a0e515af462f223f2795
Nicolas Vasilache [Thu, 11 Nov 2021 08:05:33 +0000 (08:05 +0000)]
[mlir] Fix build post 34ff8573505e04c75e84a0e515af462f223f2795

2 years ago[NFC] Clean-up typos in PowerPC CodeGen tests
Qiu Chaofan [Thu, 11 Nov 2021 07:42:08 +0000 (15:42 +0800)]
[NFC] Clean-up typos in PowerPC CodeGen tests

2 years ago[mlir][X86Vector] Add specialized vector.transpose lowering patterns for AVX2
Nicolas Vasilache [Wed, 10 Nov 2021 13:19:41 +0000 (13:19 +0000)]
[mlir][X86Vector] Add specialized vector.transpose lowering patterns for AVX2

This revision adds an implementation of 2-D vector.transpose for 4x8 and 8x8 for
AVX2 and surfaces it to the Linalg level of control.

Reviewed By: dcaballe

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

2 years ago[AArch64] Allow FP16 vector fixed point converts
David Green [Thu, 11 Nov 2021 07:32:52 +0000 (07:32 +0000)]
[AArch64] Allow FP16 vector fixed point converts

This extends performFpToIntCombine to work on FP16 vectors as well as
the f32 and f64 vectors it already supported.

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

2 years ago[JITLink] Update Section pointers on Blocks when merging Sections.
Lang Hames [Thu, 11 Nov 2021 05:08:11 +0000 (21:08 -0800)]
[JITLink] Update Section pointers on Blocks when merging Sections.

2 years agoUse base class AsmParser/AsmPrinter in Types and Attribute print/parse method (NFC)
Mehdi Amini [Thu, 11 Nov 2021 06:12:06 +0000 (06:12 +0000)]
Use base class AsmParser/AsmPrinter in Types and Attribute print/parse method (NFC)

This decouples the printing/parsing from the "context" in which the parsing occurs.
This will allow to invoke these methods directly using an OpAsmParser/OpAsmPrinter.

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

2 years ago[BPI] Push exit block rather than exiting ones in getSccExitBlocks
Bin Cheng [Sat, 6 Nov 2021 11:26:39 +0000 (19:26 +0800)]
[BPI] Push exit block rather than exiting ones in getSccExitBlocks

The function BranchProbabilityInfo::SccInfo::getSccExitBlocks is
supposed to collect all exit blocks for SCC rather than all exiting
blocks. This patch fixes the typo.

Reviewed By: ebrevnov

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

2 years ago[TypePromotion] Fix a hardcoded use of 32 as the size being promoted to.
Craig Topper [Thu, 11 Nov 2021 06:08:34 +0000 (22:08 -0800)]
[TypePromotion] Fix a hardcoded use of 32 as the size being promoted to.

At least I think that's what the 32 here is. Use RegisterBitWidth
instead.

While there replace zext with zextOrSelf to simplify the code.

Reviewed By: samparker, dmgreen

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

2 years ago[mlir][linalg][bufferize][NFC] Move `getResultBuffer` to op interface
Matthias Springer [Thu, 11 Nov 2021 05:36:48 +0000 (14:36 +0900)]
[mlir][linalg][bufferize][NFC] Move `getResultBuffer` to op interface

This is in preparation of decoupling Comprehensive Bufferize from the various dialects.

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

2 years ago[NFC] Remove unnecessary check prefix of AIX test
Qiu Chaofan [Thu, 11 Nov 2021 05:27:42 +0000 (13:27 +0800)]
[NFC] Remove unnecessary check prefix of AIX test

9e9b0f4 introduced support for asm-full-reg-names on AIX. Now we can
merge the test check prefix.

2 years ago[ComprehensiveBufferize] Fix a warning
Kazu Hirata [Thu, 11 Nov 2021 05:21:32 +0000 (21:21 -0800)]
[ComprehensiveBufferize] Fix a warning

This patch fixes:

  mlir/lib/Dialect/Linalg/ComprehensiveBufferize/ComprehensiveBufferize.cpp:301:20:
  error: unused function 'printValueInfo' [-Werror,-Wunused-function]

2 years ago[mlir] Fix windows build after D113511
River Riddle [Thu, 11 Nov 2021 05:09:31 +0000 (05:09 +0000)]
[mlir] Fix windows build after D113511

2 years ago[mlir][linalg][bufferize] Move more helper functions/structs to interface
Matthias Springer [Thu, 11 Nov 2021 02:45:06 +0000 (11:45 +0900)]
[mlir][linalg][bufferize] Move more helper functions/structs to interface

Move helper functions for traversing reverse use-def chains. These are useful for implementing custom optimizations (e.g., custom InitTensorOp eliminations).

Also move over the AllocationCallbacks struct. This is in preparation for decoupling ComprehensiveBufferize from various dialects.

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

2 years ago[sanitizer] Fix solaris build
Vitaly Buka [Thu, 11 Nov 2021 04:40:15 +0000 (20:40 -0800)]
[sanitizer] Fix solaris build

2 years ago[llvm] Use make_early_inc_range (NFC)
Kazu Hirata [Thu, 11 Nov 2021 03:56:35 +0000 (19:56 -0800)]
[llvm] Use make_early_inc_range (NFC)

2 years ago[InstCombine][NFC] Pre-commit baseline test for D113442.
Huihui Zhang [Thu, 11 Nov 2021 02:41:41 +0000 (18:41 -0800)]
[InstCombine][NFC] Pre-commit baseline test for D113442.

Add baseline test to check for folding select into binop operand
enabled through D113442.

2 years ago[mlir] Optimize usage of llvm::mapped_iterator
River Riddle [Thu, 11 Nov 2021 03:26:10 +0000 (03:26 +0000)]
[mlir] Optimize usage of llvm::mapped_iterator

mapped_iterator is a useful abstraction for applying a
map function over an existing iterator, but our current
usage ends up allocating storage/making indirect calls
even with the map function is a known function, which
is horribly inefficient. This commit refactors the usage
of mapped_iterator to avoid this, and allows for directly
referencing the map function when dereferencing.

Fixes PR52319

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

2 years ago[compiler-rt] separate lsan, ubsan, stats configuration from SANITIZER_COMMON_SUPPORT...
Emily Shi [Tue, 9 Nov 2021 01:19:57 +0000 (17:19 -0800)]
[compiler-rt] separate lsan, ubsan, stats configuration from SANITIZER_COMMON_SUPPORTED_OS

Currently, SANITIZER_COMMON_SUPPORTED_OS is being used to enable many libraries.
Unfortunately this makes it impossible to selectively disable a library based on the OS.
This patch removes this limitation by adding a separate list of supported OSs for the lsan, ubsan, ubsan_minimal, and stats libraries.

Reviewed By: delcypher

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

2 years ago[mlir][bufferize][linalg] Do not copy tensors that are overwritten
Matthias Springer [Thu, 11 Nov 2021 02:31:54 +0000 (11:31 +0900)]
[mlir][bufferize][linalg] Do not copy tensors that are overwritten

This is a generalization of "do not copy buffers for a LinalgOp output if the output is not used".

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

2 years ago[mlir][linalg][bufferize] Do not copy results of non-writing ops
Matthias Springer [Thu, 11 Nov 2021 02:13:23 +0000 (11:13 +0900)]
[mlir][linalg][bufferize] Do not copy results of non-writing ops

This is a generalization of "do not copy the result of an InitTensorOp". This commit is in preparation of decoupling `getResultBuffer` from the Linalg dialect.

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

2 years ago[mlir] Fix unused variable waraning in OpDocGen
Jacques Pienaar [Thu, 11 Nov 2021 02:18:36 +0000 (18:18 -0800)]
[mlir] Fix unused variable waraning in OpDocGen

2 years ago[NFC][msan] Clang format includes
Vitaly Buka [Thu, 11 Nov 2021 02:13:43 +0000 (18:13 -0800)]
[NFC][msan] Clang format includes

2 years ago[AMDGPU] Small correction in SITargetLowering::performOrCombine().
kpyzhov [Thu, 11 Nov 2021 02:07:27 +0000 (21:07 -0500)]
[AMDGPU] Small correction in SITargetLowering::performOrCombine().
Differential Revision: https://reviews.llvm.org/D113203

2 years ago[mlir] MicroOptimize a few hot StorageUniquer code paths
River Riddle [Thu, 11 Nov 2021 01:46:03 +0000 (01:46 +0000)]
[mlir] MicroOptimize a few hot StorageUniquer code paths

* Sprinkle `inline` on a few small and hot hashing/uniquing methods
* Use the faster DenseMapInfo hash functions instead of
   llvm::hash_value.

This provides a speed up of a few percent in workloads with lots of
attributes.

2 years ago[mlir] Replace usages of Identifier with StringAttr
River Riddle [Thu, 11 Nov 2021 01:44:58 +0000 (01:44 +0000)]
[mlir] Replace usages of Identifier with StringAttr

Identifier and StringAttr essentially serve the same purpose, i.e. to hold a string value. Keeping these seemingly identical pieces of functionality separate has caused problems in certain situations:

* Identifier has nice accessors that StringAttr doesn't
* Identifier can't be used as an Attribute, meaning strings are often duplicated between Identifier/StringAttr (e.g. in PDL)

The only thing that Identifier has that StringAttr doesn't is support for caching a dialect that is referenced by the string (e.g. dialect.foo). This functionality is added to StringAttr, as this is useful for StringAttr in generally the same ways it was useful for Identifier.

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

2 years ago[mlir][linalg][bufferize] Add `isAllocationHoistingBarrier` to op interface
Matthias Springer [Thu, 11 Nov 2021 01:56:42 +0000 (10:56 +0900)]
[mlir][linalg][bufferize] Add `isAllocationHoistingBarrier` to op interface

This make `getResultBuffer` in ComprehensiveBufferize independent of the SCF, Affine and Linalg dialects. This commit is in preparating of decoupling op interface implementations from ComprehensiveBufferize.

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

2 years ago[AIX] XFAIL 2009-03-29-SoftFloatVectorExtract.ll because of no soft float support
Jake Egan [Thu, 11 Nov 2021 01:58:05 +0000 (20:58 -0500)]
[AIX] XFAIL 2009-03-29-SoftFloatVectorExtract.ll because of no soft float support

Soft floats are not currently supported on AIX, so mark this test as XFAIL on AIX for now.

Reviewed By: shchenz

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

2 years ago[mlir](arithmetic) Add ceildivui to the arithmetic dialect
lipracer [Thu, 11 Nov 2021 01:47:47 +0000 (01:47 +0000)]
[mlir](arithmetic) Add ceildivui to the arithmetic dialect

The specific description is [[ https://llvm.discourse.group/t/adding-unsigned-integer-ceil-and-floor-in-std-dialect/4541 | Adding unsigned integer ceil in Std Dialect ]] .

When we lower ceilDivOp this will generate below code, sometimes we know m and n are unsigned intergal.Here are some redundant judgments about positive and negative.
So we need to add some unsigned operations to simplify the instructions.
```
ceilDiv(n, m)
  x = (m > 0) ? -1 : 1
  return (n*m>0) ? ((n+x) / m) + 1 : - (-n / m)
```
unsigned operations:
```
ceilDivU(n, m)
  return n ==0 ?  0 :  ((n - 1) / m) + 1
```

Reviewed By: Mogball

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

2 years ago[AIX] Define WCHAR_T_TYPE as unsigned int on 64-bit AIX for wchar.c test
Jake Egan [Thu, 11 Nov 2021 01:45:57 +0000 (20:45 -0500)]
[AIX] Define WCHAR_T_TYPE as unsigned int on 64-bit AIX for wchar.c test

The default wchar type on 64-bit AIX is `unsigned int`, so this patch sets `WCHAR_T_TYPE` to `unsigned int` rather than `int`.

This patch follows similar reasoning to D110428 except for 64-bit.

Reviewed By: daltenty

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

2 years ago[mlir][linalg][bufferize] Move BufferizationAliasInfo to op interface
Matthias Springer [Thu, 11 Nov 2021 01:42:11 +0000 (10:42 +0900)]
[mlir][linalg][bufferize] Move BufferizationAliasInfo to op interface

BufferizationAliasInfo is used in BufferizationOpInterface::bufferize implementations, so it should be part of the same build target as BufferizableOpInterface.

This commit is in preparation of decoupling the ComprehensiveBufferize from the various dialects.

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

2 years ago[mlir][linalg][bufferize] Store analysis results in BufferizationAliasInfo
Matthias Springer [Thu, 11 Nov 2021 01:35:56 +0000 (10:35 +0900)]
[mlir][linalg][bufferize] Store analysis results in BufferizationAliasInfo

* Store inplace bufferization decisions in `inplaceBufferized`.
* Remove `InPlaceSpec`. Use a bool instead.
* Use `BufferizableOpInterface::bufferizesToWritableMemory` and `bufferizesToWritableMemory` instead of `getInPlace(BlockArgument)`. The analysis does not care about inplacability of block arguments. It only cares whether the buffer can be written to or not.
* The `kInPlaceResultsAttrName` op attribute is for testing purposes only.

This commit further decouples BufferizationAliasInfo from other dialects such as SCF.

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

2 years ago[RISCV] Promote f16 frem with Zfh.
Craig Topper [Thu, 11 Nov 2021 01:20:47 +0000 (17:20 -0800)]
[RISCV] Promote f16 frem with Zfh.

Add riscv64 coverage for f32 and f64 frem.

Reviewed By: luismarques

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

2 years ago[mlir][linalg][bufferize] Fix bug in InitTensor elimination
Matthias Springer [Thu, 11 Nov 2021 01:26:14 +0000 (10:26 +0900)]
[mlir][linalg][bufferize] Fix bug in InitTensor elimination

After replacing then init_tensor with a new value, the new value must be inserted into the corresponding union/equivalence sets.

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

2 years ago[AMDGPU] Fixed stack pointer init with architected flat scratch
Stanislav Mekhanoshin [Thu, 11 Nov 2021 00:31:13 +0000 (16:31 -0800)]
[AMDGPU] Fixed stack pointer init with architected flat scratch

Even if wave offset is not present we still need to do the rest
of the initialization. The mov into s32 was missing in the
kernels.

Fixes: SWDEV-310935

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

2 years ago[mlir] Fix predicate.td ODS test case
Jacques Pienaar [Thu, 11 Nov 2021 01:11:54 +0000 (17:11 -0800)]
[mlir] Fix predicate.td ODS test case

2 years ago[InstCombine] Precommit updated and-xor-or.ll tests. NFC.
Stanislav Mekhanoshin [Wed, 10 Nov 2021 21:12:25 +0000 (13:12 -0800)]
[InstCombine] Precommit updated and-xor-or.ll tests. NFC.

Tests for:
```
(a | ~(b & c)) & ~(a & (b ^ c)) --> ~(a | b) | (a ^ b ^ c)
(~(a & b) | c) & ~(a & (b & c)) -> ~(a & b)
(~(a & b) | c) & ~(b & (a & c)) -> ~(a & b)
(~a | b | c) & ~(a & b & c) -> ~a | (b ^ c)
(~a | b | c) & ~(a & b) -> (c & ~b) | ~a
```

2 years ago[mlir][linalg][bufferize][NFC] Move helper functions to op interface
Matthias Springer [Thu, 11 Nov 2021 01:00:33 +0000 (10:00 +0900)]
[mlir][linalg][bufferize][NFC] Move helper functions to op interface

Also enclose all bufferization code in a new namespace: `comprehensive_bufferize`

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

2 years agoAMDGPU: Report large stack usage for recursive calls
Matt Arsenault [Wed, 10 Nov 2021 23:16:54 +0000 (18:16 -0500)]
AMDGPU: Report large stack usage for recursive calls

We were previously setting an ignored bit in the kernel headers. The
current behavior is to add the large amount on top of the statically
known size of a single stack frame. I'm not sure if we should just use
the large size as the entire reported size instead.

2 years ago[NFC][asan][memprov] Remove dlsym hack from posix_memalign
Vitaly Buka [Thu, 11 Nov 2021 00:33:00 +0000 (16:33 -0800)]
[NFC][asan][memprov] Remove dlsym hack from posix_memalign

It was added for RTEMS which was removed at D104279.

2 years ago[lld-macho] Support renaming of LSDA section
Jez Ng [Thu, 11 Nov 2021 00:31:54 +0000 (19:31 -0500)]
[lld-macho] Support renaming of LSDA section

Previously, our unwind info finalization logic assumed that the LSDA
section referenced by `__compact_unwind` was already finalized before
`__TEXT,__unwind_info` itself. However, that assumption could be broken
by the use of `-rename_section` -- it could be (and is) used to move
`__gcc_except_tab` it into a different segment later in the file.
(__TEXT is always the first non-zerofill segment, so any rename
basically guarantees that the section will be ordered after
`__unwind_info`.)

To handle this case, we compare LSDA relocations instead of their final
values in `UnwindInfoSection::finalize()`, and we actually relocate
those LSDAs in `UnwindInfoSection::writeTo()`. In order to do this, we
need an easy way to track which Symbol a given CUE corresponds to. My
solution was to change our `cuPtrVector` into a vector of indices, with
each index used for both the symbols vector (`symbolsVec`) as well as
the CUE vector (`cuVector`).

This change seems perf neutral. Numbers for linking chromium_framework
on my 16 core Mac Pro:

             base           diff           difference (95% CI)
  sys_time   1.248 ± 0.025  1.245 ± 0.026  [  -1.3% ..   +0.8%]
  user_time  3.588 ± 0.045  3.587 ± 0.037  [  -0.6% ..   +0.5%]
  wall_time  4.605 ± 0.069  4.595 ± 0.069  [  -1.0% ..   +0.5%]
  samples    42             26

Reviewed By: #lld-macho, oontvoo

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

2 years ago[mlir][ods] Use lambda in element type check pred rather than repeated casts
Jacques Pienaar [Thu, 11 Nov 2021 00:27:37 +0000 (16:27 -0800)]
[mlir][ods] Use lambda in element type check pred rather than repeated casts

Avoids multiple cast & getElementType calls. Just a local change for ShapedType
containers but reduces one model case from 24.7 to 24.04s.

Resultant code generated change:
https://gist.github.com/jpienaar/7ffd2e9b0737134ba2ea2729b91c9572

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

2 years ago[RISCV] Fix incorrect CHECK prefixes in rv64zba-aliases-valid.s. NFC
Craig Topper [Thu, 11 Nov 2021 00:09:26 +0000 (16:09 -0800)]
[RISCV] Fix incorrect CHECK prefixes in rv64zba-aliases-valid.s. NFC

This test add check lines using a prefixes that weren't passed to
FileCheck. This may have occurred when the B extension files were
split up.