platform/upstream/llvm.git
21 months ago[WebAssembly] Fix return type of __builtin_return_address under wasm64
Sam Clegg [Sat, 1 Oct 2022 01:28:58 +0000 (18:28 -0700)]
[WebAssembly] Fix return type of __builtin_return_address under wasm64

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

21 months ago[OpenMP][libomp] Allow unused-but-set warnings
Jonathan Peyton [Thu, 8 Sep 2022 20:51:56 +0000 (15:51 -0500)]
[OpenMP][libomp] Allow unused-but-set warnings

Only a few remaining which are taken care of by this patch.

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

21 months agoRevert "[InstSimplify] reduce code duplication for fmul folds; NFC"
Sanjay Patel [Mon, 3 Oct 2022 15:20:33 +0000 (11:20 -0400)]
Revert "[InstSimplify] reduce code duplication for fmul folds; NFC"

This reverts commit 7b7940f9da80de6aa0b8f28a0ef809dafe4cdffc.
This missed a test update.

21 months ago[ConstraintElimination] Add tests for chained GEPs with const offsets.
Florian Hahn [Mon, 3 Oct 2022 14:55:35 +0000 (15:55 +0100)]
[ConstraintElimination] Add tests for chained GEPs with const offsets.

Add extra tests for chained GEPs where the second GEP has a constant
offset. Inspired by missed optimizations from #51358.

21 months agoFix compilation of CodeLayout.cpp for MacOS
Yevgeny Rouban [Mon, 3 Oct 2022 14:47:43 +0000 (21:47 +0700)]
Fix compilation of CodeLayout.cpp for MacOS

llvm/lib/Transforms/Utils/CodeLayout.cpp uses std::abs() with double argument,
which is provided by cmath header, which is not explicitly included into CodeLayout.cpp.
The implicit include in llvm/include/llvm/Support/MathExtras.h was removed in
commit 16544cbe64b81a50800a88296ef37f4873a37b25

Inserting explicit include of cmath into CodeLayout.cpp in order to fix build on MacOS.

Committed on behalf of alsemenov (Aleksei Semenov)
Reviewed By: thieta
Differential Revision: https://reviews.llvm.org/D135072

21 months ago[InstSimplify] reduce code duplication for fmul folds; NFC
Sanjay Patel [Mon, 3 Oct 2022 13:17:23 +0000 (09:17 -0400)]
[InstSimplify] reduce code duplication for fmul folds; NFC

The constant is already commuted for an fmul opcode,
but this code can be called more directly for fma,
so we have to swap for that caller. There are tests
in InstSimplify and InstCombine to verify that this
works as expected.

21 months ago[ARM][AArch64] Dont use macros for half instrinsics in NeonEmitter
David Green [Mon, 3 Oct 2022 14:27:23 +0000 (15:27 +0100)]
[ARM][AArch64] Dont use macros for half instrinsics in NeonEmitter

We don't require arm_neon.h fp16 intrinsics to be treated as macros any
more.

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

21 months ago[AArch64] Add pr58109 tests, one showing incorrect lowering of SUBS. NFC
David Green [Mon, 3 Oct 2022 14:08:46 +0000 (15:08 +0100)]
[AArch64] Add pr58109 tests, one showing incorrect lowering of SUBS. NFC

Also added global-isel coverage for the same file.

21 months ago[LoopVectorize] Add missing test for D133687
Igor Kirillov [Mon, 3 Oct 2022 13:37:08 +0000 (14:37 +0100)]
[LoopVectorize] Add missing test for D133687

21 months ago[mlir][shape] fix test added in 9f77909.
Christian Sigg [Mon, 3 Oct 2022 13:45:33 +0000 (15:45 +0200)]
[mlir][shape] fix test added in 9f77909.

The stderr to stdout piping results in the two streams being interleaved on Windows.
Write stderr to a temp-file instead and run separate FileCheck on it.

21 months ago[analyzer][NFC] Add tests for D132236
Tomasz Kamiński [Mon, 3 Oct 2022 13:14:04 +0000 (15:14 +0200)]
[analyzer][NFC] Add tests for D132236

D132236 would have introduced regressions in the symbol lifetime
handling. However, the testsuite did not catch this, so here we have
some tests, which would have break if D132236 had landed.

This patch addresses the comment https://reviews.llvm.org/D132236#3753238

Co-authored-by: Balazs Benics <balazs.benics@sonarsource.com>
Reviewed By: martong

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

21 months ago[OpenMP] Ignore schedule modifier in static scheduling
Hansang Bae [Fri, 30 Sep 2022 19:16:16 +0000 (14:16 -0500)]
[OpenMP] Ignore schedule modifier in static scheduling

The modifier bits in the schedule type is not used/supported in the
static scheduler, so it should be ignored.

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

21 months ago[ARM64EC][clang-cl] Add /arm64EC flag
chenglin.bi [Mon, 3 Oct 2022 13:20:33 +0000 (21:20 +0800)]
[ARM64EC][clang-cl] Add /arm64EC flag

Reviewed By: DavidSpickett

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

21 months ago[lld/mac] Extract a reportUndefinedSymbol function
Nico Weber [Sun, 2 Oct 2022 13:20:22 +0000 (09:20 -0400)]
[lld/mac] Extract a reportUndefinedSymbol function

Makes things look more similar to the ELF port, and removes some
slightly deep nesting.

No behavior change.

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

21 months ago[mlir] fix markdown headers in structured ops doc
Alex Zinenko [Mon, 3 Oct 2022 13:17:10 +0000 (13:17 +0000)]
[mlir] fix markdown headers in structured ops doc

21 months ago[SelectionDAG] Fix use-after-free introduced in D130881
Markus Böck [Mon, 3 Oct 2022 13:09:14 +0000 (15:09 +0200)]
[SelectionDAG] Fix use-after-free introduced in D130881

The code introduced in https://reviews.llvm.org/D130881 has a bug as it may cause a use-after-free error that can be caught by ASAN.
The bug essentially boils down to iterator invalidation of `DenseMap`. The expression `SDEI[To] = I->second;` may cause `SDEI` to grow if `To` is inserted for the very first time. When that happens, all existing iterators to the map are invalidated as their backing storage has been freed. Accessing `I->second` is then invalid and attempts to access freed memory (as `I` is an iterator of `SDEI`).

This patch fixes that quite simply by first making a copy of `I->second`, and then moving into the possibly newly inserted KV of the ` DenseMap`.

No test attached as I am not sure it is practible to test.

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

21 months agoRevert "[CMake] Use libcxx-abi-* targets for in-tree sanitizer C++ ABI"
Hans Wennborg [Mon, 3 Oct 2022 12:56:07 +0000 (14:56 +0200)]
Revert "[CMake] Use libcxx-abi-* targets for in-tree sanitizer C++ ABI"

It casued some runtimes builds to fail with cmake error

  No target "libcxx-abi-static"

see code review.

> When in-tree libcxx is selected as the sanitizer C++ ABI, use
> libcxx-abi-* targets rather than libcxxabi and libunwind directly.
>
> Differential Revision: https://reviews.llvm.org/D134855

This reverts commit 414f9b7d2f45670019dc8ec284b685a9e238718f.

21 months ago[libc++] Avoid relying on non-portable behaviour in std::align
Alex Richardson [Mon, 3 Oct 2022 09:39:21 +0000 (09:39 +0000)]
[libc++] Avoid relying on non-portable behaviour in std::align

Round-tripping pointers via size_t is not portable, the C/C++ standards
only require this to be valid when using (u)intptr_t.
Originally committed to the CHERI fork of LLVM as
https://github.com/CTSRD-CHERI/llvm-project/commit/dd01245185ab9e71b70b418bee8f11ea0199e1a3,
but I forgot to upstream the change. I rediscovered this issue due to a
compiler warning when building libc++ on a Arm Morello system.

Reviewed By: #libc, ldionne, philnik

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

21 months ago[mlir][llvmir] Add filename debug info when converting from LLVMIR.
Tobias Gysi [Mon, 3 Oct 2022 12:13:26 +0000 (15:13 +0300)]
[mlir][llvmir] Add filename debug info when converting from LLVMIR.

The revision enriches the debug locations generated during LLVMIR to MLIR translation with file name information and adds a separate test to exercise the debug location translation.

Reviewed By: ftynse

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

21 months ago[flang] Add Sparc support to Optimizer/CodeGen/Target.cpp
Rainer Orth [Mon, 3 Oct 2022 12:03:35 +0000 (14:03 +0200)]
[flang] Add Sparc support to Optimizer/CodeGen/Target.cpp

As described in Issue #57642, `flang` currently lacks SPARC support in
`Optimizer/CodeGen/Target.cpp`, which causes a considerable number of tests
to `FAIL` with

  error: flang/lib/Optimizer/CodeGen/Target.cpp:310: not yet implemented:
target not implemented

This patch fixes this by following GCC`s documentation of the ABI described
in the Issue.

Tested on `sparcv9-sun-solaris2.11`.

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

21 months ago[SelectionDAG] Add check for BUILD_VECTOR in isKnownNeverNaN
Petar Avramovic [Mon, 3 Oct 2022 10:34:12 +0000 (12:34 +0200)]
[SelectionDAG] Add check for BUILD_VECTOR in isKnownNeverNaN

Includes handling of constants with vector type in isKnownNeverNaN.
For AMDGPU results in not making fcanonicalize during legalization
for vector inputs to fmaxnum_ieee and fminnum_ieee. Does not affect
end result since there is a combine that eliminates fcanonicalize.

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

21 months ago[Analysis][SimplifyLibCalls] Refactor code related to size_t in lib func signatures...
Bjorn Pettersson [Wed, 28 Sep 2022 12:23:52 +0000 (14:23 +0200)]
[Analysis][SimplifyLibCalls] Refactor code related to size_t in lib func signatures. NFC

Added a helper in TargetLibraryInfo to get size of "size_t" in bits,
given a Module reference. The new getSizeTSize helper is using the
same strategy as for example isValidProtoForLibFunc has been using
in the past, assuming that the size can be derived by asking
DataLayout about the size/type of a pointer to int.

FortifiedLibCallSimplifier::optimizeStrpCpyChk was changed to use
the new getSizeTSize helper instead of assuming that sizeof(size_t)
is equal to sizeof(int*) by itself (that is the assumption used in
TargetLibraryInfoImpl::getSizeTSize so the result will be the same).

Having a common helper for this ensure that we use the same strategy
when deriving the size of "size_t" in different parts of the code.
One bonus with this refactoring (basing it on Module instead of just
DataLayout) is that it makes it easier to override this for a specific
target triple, in case the assumption of using getPointerSizeInBits
wouldn't hold.

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

21 months ago[mlir][Affine] Add pass options to supervectorizer
Javier Setoain [Mon, 26 Sep 2022 09:14:01 +0000 (10:14 +0100)]
[mlir][Affine] Add pass options to supervectorizer

The only current options to create a supervectorization pass from an
external dialect is to use `createSuperVectorizePass` with the virtual
vector dimensions as a parameter, but the pass accepts other parameters.

This patch enables external users to create a supervectorizer pass
exposing all available option.

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

21 months ago[flang] Do not resolve TRIM/REPEAT length to its argument length
Jean Perier [Mon, 3 Oct 2022 09:41:33 +0000 (11:41 +0200)]
[flang] Do not resolve TRIM/REPEAT length to its argument length

For TRIM and REPEAT calls, semantics was creating ProcedureDesignators
using the length parameter of the arguments. This caused bugs when
folding LEN(TRIM(char_explicit_constant_length)). The same did not
appeared in folding for REPEAT because it is rewritten at a higher
level to LEN(c)*N.

This is not only a folding issue since any place (like lowering) may
try to use the bad length parameter from the created ProcedureDesignator.

Update intrinsic resolution to not copy the length parameter for TRIM
and REPEAT.

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

21 months ago[Test] Add test showing that Constraint Elimination can deal with case where SCEV...
Max Kazantsev [Mon, 3 Oct 2022 09:40:41 +0000 (16:40 +0700)]
[Test] Add test showing that Constraint Elimination can deal with case where SCEV fails

21 months ago[DebugInfo][test] XFAIL DebugInfo/Generic/missing-abstract-variable.ll on LoongArch
Weining Lu [Fri, 30 Sep 2022 01:29:43 +0000 (09:29 +0800)]
[DebugInfo][test] XFAIL DebugInfo/Generic/missing-abstract-variable.ll on LoongArch

The same as SPARC and RISCV. See D119122.

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

21 months ago[flang][NFC] Use prefixed accessors for fircg dialect
Valentin Clement [Mon, 3 Oct 2022 09:02:23 +0000 (11:02 +0200)]
[flang][NFC] Use prefixed accessors for fircg dialect

The raw accessor is going away soon so switch to prefixed accessors in the
fircg dialect. The main dialect was switched some months ago.

https://github.com/llvm/llvm-project/issues/58090

Reviewed By: rriddle

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

21 months ago[Clang][MinGW][cygwin] Fix __declspec with -fdeclspec enabled
Alvin Wong [Mon, 3 Oct 2022 07:40:16 +0000 (10:40 +0300)]
[Clang][MinGW][cygwin] Fix __declspec with -fdeclspec enabled

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

Reviewed By: rnk

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

21 months ago[LLD][COFF] Reduce chance of symbol name collision with delay-load
Alvin Wong [Mon, 3 Oct 2022 07:40:01 +0000 (10:40 +0300)]
[LLD][COFF] Reduce chance of symbol name collision with delay-load

Delay-loaded imports creats a load thunk with a symbol name. Before this
change, the name uses a `__imp_load_` prefix. On the other hand, normal
import uses the `__imp_` prefix for the import address pointer. If an
import symbol named `load_func` is imported normally and another named
`func` is imported using delay-load, this can cause a symbol name
collision.

This patch changes delay-load imports to use `__imp___load_` prefix.
Because it is less likely for normal imports to have a name starting in
`__load_` this should reduce the chance of a name collision.

Reviewed By: mstorsjo

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

21 months ago[LLD][COFF] Set OrdinalBase to 1 for export table
Alvin Wong [Mon, 3 Oct 2022 07:39:48 +0000 (10:39 +0300)]
[LLD][COFF] Set OrdinalBase to 1 for export table

Before this, LLD sets OrdinalBase to 0, which deviates from usual
practices. This technically would allow LLD to export a symbol using
ordinal 0, however LLD never use export ordinal 0, which results in
binaries with export tables always having an empty export at ordinal 0.

This change makes LLD set OrdinalBase to 1 and not create the empty
export with ordinal 0, which makes its behaviour more in line with both
the MSVC linker and the GNU linker.

Reviewed By: mstorsjo

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

21 months ago[libc++] Remove a part of reverted D131898 or D130695
Vitaly Buka [Mon, 3 Oct 2022 07:49:52 +0000 (00:49 -0700)]
[libc++] Remove a part of reverted D131898 or D130695

21 months agoRevert "[libc++] Updates generated transitve includes."
Vitaly Buka [Mon, 3 Oct 2022 07:39:19 +0000 (00:39 -0700)]
Revert "[libc++] Updates generated transitve includes."

Looks like a part of reverted D131898.

This reverts commit cfd5b8f11195f5c23ae6d4aa2df2d95cae9b976e.

21 months ago[flang] Make real type of kind 10 target dependent
Peixin Qiao [Mon, 3 Oct 2022 07:24:39 +0000 (15:24 +0800)]
[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

21 months ago[Bazel] fixes for 9f77909.
Christian Sigg [Mon, 3 Oct 2022 07:06:42 +0000 (09:06 +0200)]
[Bazel] fixes for 9f77909.

21 months ago[mlir][bufferize][NFC] Fix FileCheck capture
Matthias Springer [Mon, 3 Oct 2022 07:05:39 +0000 (16:05 +0900)]
[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

21 months ago[GlobalISel] Allow prelegalizer combiners to have access to LegalizerInfo.
Amara Emerson [Sun, 2 Oct 2022 21:28:29 +0000 (22:28 +0100)]
[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

21 months ago[mlir][interfaces] Add ShapedDimOpInterface
Matthias Springer [Mon, 3 Oct 2022 04:53:16 +0000 (13:53 +0900)]
[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

21 months ago[ELF] Replace some config->ekind with file->ekind. NFC
Fangrui Song [Mon, 3 Oct 2022 04:27:41 +0000 (21:27 -0700)]
[ELF] Replace some config->ekind with file->ekind. NFC

21 months agoRevert "Add APFloat and MLIR type support for fp8 (e5m2)."
Vitaly Buka [Mon, 3 Oct 2022 04:21:51 +0000 (21:21 -0700)]
Revert "Add APFloat and MLIR type support for fp8 (e5m2)."

Breaks bots https://lab.llvm.org/buildbot/#/builders/37/builds/17086

This reverts commit 2dc68b5398258c7a0cf91f10192d058e787afcdf.

21 months ago[ELF] Move init from ELFFileBase constructor to a separate function. NFC
Fangrui Song [Mon, 3 Oct 2022 04:10:28 +0000 (21:10 -0700)]
[ELF] Move init from ELFFileBase constructor to a separate function. NFC

21 months ago[mlir][shape] add outline-shape-computation pass
Yuanqiang Liu [Mon, 3 Oct 2022 03:24:49 +0000 (20:24 -0700)]
[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

21 months ago[ELF] Remove redundant getELFKind call. NFC
Fangrui Song [Mon, 3 Oct 2022 03:16:13 +0000 (20:16 -0700)]
[ELF] Remove redundant getELFKind call. NFC

21 months ago[ELF] Simplify addFile. NFC
Fangrui Song [Mon, 3 Oct 2022 02:49:17 +0000 (19:49 -0700)]
[ELF] Simplify addFile. NFC

21 months ago[mlir][linalg][NFC] Drop emitAccessorPrefix from Linalg dialect
Matthias Springer [Mon, 3 Oct 2022 02:29:47 +0000 (11:29 +0900)]
[mlir][linalg][NFC] Drop emitAccessorPrefix from Linalg dialect

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

21 months ago[gn build] Port 71410fd2c065
LLVM GN Syncbot [Mon, 3 Oct 2022 01:41:14 +0000 (01:41 +0000)]
[gn build] Port 71410fd2c065

21 months agoRevert "[libc++] Implement P0591R4 (Utility functions to implement uses-allocator...
Vitaly Buka [Mon, 3 Oct 2022 01:39:11 +0000 (18:39 -0700)]
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 099384dcea49f5f4b0dc7e615c9845bf9baad4bc.

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).

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[RISCV] Add a LocalStackSlotAllocation test
luxufan [Wed, 28 Sep 2022 23:32:34 +0000 (23:32 +0000)]
[RISCV] Add a LocalStackSlotAllocation test

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

21 months ago[gn build] Port a6e1080b87db
LLVM GN Syncbot [Sun, 2 Oct 2022 23:53:57 +0000 (23:53 +0000)]
[gn build] Port a6e1080b87db

21 months agoRevert "[libc++][ranges]Refactor `copy{,_backward}` and `move{,_backward}`"
Vitaly Buka [Sun, 2 Oct 2022 23:23:35 +0000 (16:23 -0700)]
Revert "[libc++][ranges]Refactor `copy{,_backward}` and `move{,_backward}`"

Breaks msan, asan

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

This reverts commit 005916de58f73aa5c4264c084ba7b0e21040d88f.

21 months ago[ELF] Add LLVM_LIBRARY_VISIBILITY to some global variables. NFC
Fangrui Song [Sun, 2 Oct 2022 20:23:52 +0000 (13:23 -0700)]
[ELF] Add LLVM_LIBRARY_VISIBILITY to some global variables. NFC

21 months ago[flang] Introduce fir.class type
Valentin Clement [Sun, 2 Oct 2022 18:11:57 +0000 (20:11 +0200)]
[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

21 months ago[flang] Introduce BaseBoxType
Valentin Clement [Sun, 2 Oct 2022 18:07:18 +0000 (20:07 +0200)]
[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

21 months ago[llvm-objdump][test] Improve address test
Fangrui Song [Sun, 2 Oct 2022 17:49:52 +0000 (10:49 -0700)]
[llvm-objdump][test] Improve address test

21 months ago[libc++] Updates generated transitve includes.
Mark de Wever [Sun, 2 Oct 2022 17:37:21 +0000 (19:37 +0200)]
[libc++] Updates generated transitve includes.

This should fix the CI.

21 months ago[InstCombine] convert mul by negative-pow2 to negate and shift
Sanjay Patel [Sun, 2 Oct 2022 16:22:25 +0000 (12:22 -0400)]
[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

21 months ago[ValueTracking] peek through fpext in isKnownNeverInfinity()
Sanjay Patel [Sun, 2 Oct 2022 15:19:05 +0000 (11:19 -0400)]
[ValueTracking] peek through fpext in isKnownNeverInfinity()

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

21 months ago[InstSimplify] add tests for FP infinity compare with fpext; NFC
Sanjay Patel [Sun, 2 Oct 2022 14:49:56 +0000 (10:49 -0400)]
[InstSimplify] add tests for FP infinity compare with fpext; NFC

21 months ago[ARM] Add lowering for bf16 neon vtrn, vzup and vuzp.
David Green [Sun, 2 Oct 2022 14:34:37 +0000 (15:34 +0100)]
[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.

21 months ago[ARM] More bf16 shuffle handling, including perfect shuffles.
David Green [Sun, 2 Oct 2022 13:31:51 +0000 (14:31 +0100)]
[ARM] More bf16 shuffle handling, including perfect shuffles.

21 months ago[ConstraintElimination] Update Changed status in ssub simplification.
Florian Hahn [Sun, 2 Oct 2022 13:25:51 +0000 (14:25 +0100)]
[ConstraintElimination] Update Changed status in ssub simplification.

Update tryToSimplifyOverflowMath to indicate whether the function made
any changes to the IR.

21 months ago[ARM] Add tablegen patterns for bf16 vrev
David Green [Sun, 2 Oct 2022 12:42:14 +0000 (13:42 +0100)]
[ARM] Add tablegen patterns for bf16 vrev

21 months ago[ARM] Add tablegen patterns for bf16 vext
David Green [Sun, 2 Oct 2022 11:45:58 +0000 (12:45 +0100)]
[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.

21 months ago[ARM][DAG] BF16 constant handling.
David Green [Sun, 2 Oct 2022 10:51:08 +0000 (11:51 +0100)]
[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.

21 months agoRevert "[flang] Make real type of kind 10 target dependent"
Peixin Qiao [Sun, 2 Oct 2022 09:45:03 +0000 (17:45 +0800)]
Revert "[flang] Make real type of kind 10 target dependent"

This reverts commit d11e406e369fc90be5e2e2a0798ea7b7d2625882.

21 months ago[test] Make Linux/sem_init_glibc.cpp robust
Fangrui Song [Sun, 2 Oct 2022 07:47:10 +0000 (00:47 -0700)]
[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

21 months ago[flang][OpenMP] Fix resolve common block in data-sharing clauses
Peixin Qiao [Sun, 2 Oct 2022 02:38:27 +0000 (10:38 +0800)]
[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

21 months ago[flang] Make real type of kind 10 target dependent
Peixin Qiao [Sun, 2 Oct 2022 02:26:55 +0000 (10:26 +0800)]
[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

21 months ago[clang][auto-init] Deprecate -enable-trivial-auto-var-init-zero-knowing-it-will-be...
Kees Cook [Fri, 6 May 2022 19:47:43 +0000 (12:47 -0700)]
[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

21 months ago[gn build] Port 005916de58f7
LLVM GN Syncbot [Sun, 2 Oct 2022 00:35:45 +0000 (00:35 +0000)]
[gn build] Port 005916de58f7

21 months ago[libc++][ranges]Refactor `copy{,_backward}` and `move{,_backward}`
Konstantin Varlamov [Sun, 2 Oct 2022 00:28:57 +0000 (17:28 -0700)]
[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

21 months ago[mlir] Use std::enable_if_t (NFC)
Kazu Hirata [Sun, 2 Oct 2022 00:24:56 +0000 (17:24 -0700)]
[mlir] Use std::enable_if_t (NFC)

21 months ago[clang] Use std::enable_if_t (NFC)
Kazu Hirata [Sun, 2 Oct 2022 00:24:54 +0000 (17:24 -0700)]
[clang] Use std::enable_if_t (NFC)

21 months ago[ADT] Use std::common_type_t (NFC)
Kazu Hirata [Sun, 2 Oct 2022 00:24:52 +0000 (17:24 -0700)]
[ADT] Use std::common_type_t (NFC)

21 months ago[mlir] Remove ReferTo attr constraint
Jacques Pienaar [Sun, 2 Oct 2022 00:19:14 +0000 (17:19 -0700)]
[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

21 months ago[llvm] Migrate PAEval to new pass manager
Arthur Eubanks [Sat, 1 Oct 2022 23:40:58 +0000 (16:40 -0700)]
[llvm] Migrate PAEval to new pass manager

21 months ago[RISCV] Use _TIED form of VWADD(U)_WX/VWSUB(U)_WX to avoid early clobber.
Craig Topper [Sat, 1 Oct 2022 23:31:23 +0000 (16:31 -0700)]
[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.

21 months ago[RISCV] Minor tablegen formatting cleanup. NFC
Craig Topper [Sat, 1 Oct 2022 22:59:25 +0000 (15:59 -0700)]
[RISCV] Minor tablegen formatting cleanup. NFC

21 months ago[ELF] --check-sections: allow address 0xffffffff for ELFCLASS32
Fangrui Song [Sat, 1 Oct 2022 22:37:07 +0000 (15:37 -0700)]
[ELF] --check-sections: allow address 0xffffffff for ELFCLASS32

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

21 months ago[ELF] Rename LinkerScript::ctx to state. NFC
Fangrui Song [Sat, 1 Oct 2022 22:27:39 +0000 (15:27 -0700)]
[ELF] Rename LinkerScript::ctx to state. NFC

To avoid name conflict with `elf::ctx`.

21 months ago[GlobalISel] Combine abs(undef) -> 0
Jessica Paquette [Sat, 1 Oct 2022 21:13:28 +0000 (14:13 -0700)]
[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

21 months ago[ELF] Move driver into ctx and remove indirection. NFC
Fangrui Song [Sat, 1 Oct 2022 22:12:50 +0000 (15:12 -0700)]
[ELF] Move driver into ctx and remove indirection. NFC

This removes one global variable and removes GOT and unique_ptr indirection.

21 months ago[ELF] Remove symtab indirection. NFC
Fangrui Song [Sat, 1 Oct 2022 21:46:49 +0000 (14:46 -0700)]
[ELF] Remove symtab indirection. NFC

Add LLVM_LIBRARY_VISIBILITY to remove unneeded GOT and unique_ptr indirection.

21 months agoUpdate missing test after 24553df57dcc7bb2567697d8697b37ffbbac
Jessica Paquette [Sat, 1 Oct 2022 21:00:01 +0000 (14:00 -0700)]
Update missing test after 24553df57dcc7bb2567697d8697b37ffbbac

21 months ago[libc++] Enable libc++-specific tests for constexpr string
Nikolas Klauser [Sat, 1 Oct 2022 13:37:24 +0000 (15:37 +0200)]
[libc++] Enable libc++-specific tests for constexpr string

Reviewed By: ldionne, Mordante, #libc

Spies: libcxx-commits

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

21 months ago[libc++][NFC] Prefer type aliases over structs
Nikolas Klauser [Sat, 1 Oct 2022 13:42:00 +0000 (15:42 +0200)]
[libc++][NFC] Prefer type aliases over structs

Reviewed By: ldionne, #libc

Spies: sstefan1, libcxx-commits, jeroen.dobbelaere

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

21 months ago[GlobalISel] Combine `undef / X -> 0` and `undef % X -> 0`
Jessica Paquette [Sat, 1 Oct 2022 20:36:39 +0000 (13:36 -0700)]
[GlobalISel] Combine `undef / X -> 0` and `undef % X -> 0`

This fixes the `urem_undef_lhs` case in the following:

https://gcc.godbolt.org/z/Wo9x7o679

Also see https://github.com/llvm/llvm-project/issues/57256 for more related
bugs.

This is equivalent to the undef bits in `simplifyDivRem` in the DAGCombiner.

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

21 months ago[llvm-driver] Support single distributions
Alex Brachet [Sat, 1 Oct 2022 20:20:28 +0000 (20:20 +0000)]
[llvm-driver] Support single distributions

`LLVM_DISTRIBUTION_COMPONENTS` now influences the llvm binary in the
normal cmake output directory when it is set. This allows for
distribution targets to only include tools they want in the llvm
binary. It must be done this way because only one target can be
associated with a specific output name.

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

21 months ago[llvm-driver][NFC] Simplify handling of tool symlinks
Alex Brachet [Sat, 1 Oct 2022 20:18:49 +0000 (20:18 +0000)]
[llvm-driver][NFC] Simplify handling of tool symlinks

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

21 months ago[ELF] Remove ctx indirection. NFC
Fangrui Song [Sat, 1 Oct 2022 19:06:33 +0000 (12:06 -0700)]
[ELF] Remove ctx indirection. NFC

Add LLVM_LIBRARY_VISIBILITY to remove unneeded GOT and unique_ptr
indirection. We can move other global variables into ctx without
indirection concern. In the long term we may consider passing Ctx
as a parameter to various functions and eliminate global state as
much as possible and then remove `Ctx::reset`.

21 months ago[ELF] Remove elf::config indirection. NFC
Fangrui Song [Sat, 1 Oct 2022 18:39:45 +0000 (11:39 -0700)]
[ELF] Remove elf::config indirection. NFC

`config` has 1000+ uses so we try to avoid changing `config->foo`. Define a
wrapper with LLVM_LIBRARY_VISIBILITY to remove unneeded GOT and unique_ptr
indirection.

My x86-64 lld executable is 11+KiB smaller.

21 months ago[Clang] Move ParsedTargetAttr to TargetInfo.h
David Green [Sat, 1 Oct 2022 17:26:42 +0000 (18:26 +0100)]
[Clang] Move ParsedTargetAttr to TargetInfo.h

This moves the struct, as it is now parsed by TargetInfo, so avoiding
some includes of AST in Basic.

21 months ago[lldb] Remove scoped timer from high firing and fast running ExtractUnitDIENoDwoIfNeeded
Dave Lee [Thu, 29 Sep 2022 23:01:49 +0000 (16:01 -0700)]
[lldb] Remove scoped timer from high firing and fast running ExtractUnitDIENoDwoIfNeeded

Profiles show that `DWARFUnit::ExtractUnitDIENoDwoIfNeeded` is both high firing (tens of thousands of calls) and fast running (15 µs mean).

Timers like this are noise and load for profiling systems, and can be removed.

rdar://100326595

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

21 months ago[lldb] Remove scoped timer from high firing and fast running SymbolFileDWARF::FindFun...
Dave Lee [Thu, 29 Sep 2022 23:23:22 +0000 (16:23 -0700)]
[lldb] Remove scoped timer from high firing and fast running SymbolFileDWARF::FindFunctions

Profiles show that `SymbolFileDWARF::FindFunctions` is both high firing (many thousands of calls) and fast running (35 µs mean).

Timers like this are noise and load for profiling systems, and can be removed.

rdar://100326595

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

21 months ago[SimpleLoopUnswitch] Pass -verify-cfg-preserved to test.
Florian Hahn [Sat, 1 Oct 2022 16:19:02 +0000 (17:19 +0100)]
[SimpleLoopUnswitch] Pass -verify-cfg-preserved to test.

This ensures PreservedCFGCheckerAnalysis is always added, independent of
whether opt was built with assertions enabled or not.

This fixes a few buildbot failures for bots that don't have assertions
enabled.

21 months agoFoward declare ParsedTargetAttr as a struct.
David Green [Sat, 1 Oct 2022 15:14:00 +0000 (16:14 +0100)]
Foward declare ParsedTargetAttr as a struct.

21 months ago[DAGCombine] Add tests for D57317
Paweł Bylica [Sat, 1 Oct 2022 14:42:30 +0000 (14:42 +0000)]
[DAGCombine] Add tests for D57317

Add two tests for D57317: Deduplicate addcarry node using commutativity.
https://reviews.llvm.org/D57317

21 months ago[LAA] Change to function analysis for new PM.
Florian Hahn [Sat, 1 Oct 2022 14:44:26 +0000 (15:44 +0100)]
[LAA] Change to function analysis for new PM.

At the moment, LoopAccessAnalysis is a loop analysis for the new pass
manager. The issue with that is that LAI caches SCEV expressions and
modifications in a loop may impact SCEV expressions in other loops, but
we do not have a convenient way to invalidate LAI for other loops
withing a loop pipeline.

To avoid this issue, turn it into a function analysis which returns a
manager object that keeps track of the individual LAI objects per loop.

Fixes #50940.

Fixes #51669.

Reviewed By: aeubanks

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

21 months ago[Clang][AArch64] Support AArch64 target(..) attribute formats.
David Green [Sat, 1 Oct 2022 14:40:59 +0000 (15:40 +0100)]
[Clang][AArch64] Support AArch64 target(..) attribute formats.

This adds support under AArch64 for the target("..") attributes. The
current parsing is very X86-shaped, this patch attempts to bring it line
with the GCC implementation from
https://gcc.gnu.org/onlinedocs/gcc/AArch64-Function-Attributes.html#AArch64-Function-Attributes.

The supported formats are:
- "arch=<arch>" strings, that specify the architecture features for a
  function as per the -march=arch+feature option.
- "cpu=<cpu>" strings, that specify the target-cpu and any implied
  atributes as per the -mcpu=cpu+feature option.
- "tune=<cpu>" strings, that specify the tune-cpu cpu for a function as
  per -mtune.
- "+<feature>", "+no<feature>" enables/disables the specific feature, for
  compatibility with GCC target attributes.
- "<feature>", "no-<feature>" enabled/disables the specific feature, for
  backward compatibility with previous releases.

To do this, the parsing of target attributes has been moved into
TargetInfo to give the target the opportunity to override the existing
parsing. The only non-aarch64 change should be a minor alteration to the
error message, specifying using "CPU" to describe the cpu, not
"architecture", and the DuplicateArch/Tune from ParsedTargetAttr have
been combined into a single option.

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

21 months ago[AArch64] Lower multiplication by a negative constant to shl+sub+shl
zhongyunde [Sat, 1 Oct 2022 07:36:46 +0000 (15:36 +0800)]
[AArch64] Lower multiplication by a negative constant to shl+sub+shl

Change the costmodel to lower a = b * C where C = -(2^n - 2^m) to
            lsl     w8, w0, m
            sub     w0, w8, w0, lsl n
Reviewed By: efriedma
Differential Revision: https://reviews.llvm.org/D134934