Thomas Preud'homme [Mon, 23 Jan 2023 14:01:08 +0000 (14:01 +0000)]
[MLIR] Fix tensor shapes in Toy chapter 1
In Toy tutorial chapter 1, multiply_transpose() is called with b<2, 3>
and c<3, 2> when both parameters should have the same shape. This commit
fixes this by instead using c and d as parameters and fix a comment typo
where c and d are mentioned to have shape <2, 2> when they actually have
shape <3, 2>.
Reviewed By: mehdi_amini
Differential Revision: https://reviews.llvm.org/D142622
Matthias Springer [Fri, 27 Jan 2023 09:49:16 +0000 (10:49 +0100)]
[mlir] GreedyPatternRewriteDriver: Make classes single-use
Less mutable state, more `const`. This is to address a concern about complexity of state in D140304.
Differential Revision: https://reviews.llvm.org/D141949
Matthias Springer [Fri, 27 Jan 2023 09:41:45 +0000 (10:41 +0100)]
[mlir][NFC] GreedyPatternRewriteDriver: Remove OpPatternRewriteDriver
The `MultiOpPatternRewriteDriver` can be reused. This gives us better debug messages and more code reuse. Debug messages such as `** Replace: (op name)` were previously not printed when using the `applyOpPatternsAndFold(Operation *, ...)` overload.
Differential Revision: https://reviews.llvm.org/D142613
Matthias Springer [Fri, 27 Jan 2023 09:19:50 +0000 (10:19 +0100)]
[mlir] GreedyPatternRewriteDriver: Enqueue ancestors in MultiOpPatternRewriteDriver
The `GreedyPatternRewriteDriver` was extended to enqueue ancestors in D140304. With this change, `MultiOpPatternRewriteDriver` behaves the same way.
Note: `MultiOpPatternRewriteDriver` now also has a scope that limits how far we go when checking ancestors. By default, this is the first common region of all given ops.
Differential Revision: https://reviews.llvm.org/D141945
Quentin Colombet [Tue, 24 Jan 2023 13:05:47 +0000 (13:05 +0000)]
[mlir][Conversion] Rename the MemRefToLLVM pass
Since the recent MemRef refactoring that centralizes the lowering of
complex MemRef operations outside of the conversion framework, the
MemRefToLLVM pass doesn't directly convert these complex operations.
Instead, to fully convert the whole MemRef dialect space, MemRefToLLVM
needs to run after `expand-strided-metadata`.
Make this more obvious by changing the name of the pass and the option
associated with it from `convert-memref-to-llvm` to
`finalize-memref-to-llvm`.
The word "finalize" conveys that this pass needs to run after something
else and that something else is documented in its tablegen description.
This is a follow-up patch related to the conversation at:
https://discourse.llvm.org/t/psa-you-need-to-run-expand-strided-metadata-before-memref-to-llvm-now/66956/14
Differential Revision: https://reviews.llvm.org/D142463
Alex Zinenko [Thu, 26 Jan 2023 14:02:34 +0000 (14:02 +0000)]
[mlir] fail gracefull in CallOpSignatureConversion
Previously, the CallOpSignatureConversion pattern would assert if
function signature change affected the number of results. Fail the
pattern instead and let the caller propagate failure.
Fixes #60186.
Reviewed By: mehdi_amini
Differential Revision: https://reviews.llvm.org/D142624
Evgeniy Brevnov [Fri, 27 Jan 2023 08:35:32 +0000 (15:35 +0700)]
Revert "[JT][CT] Preserve exisiting BPI/BFI during JumpThreading"
This reverts commit
26e7cb24cb5dfa560683064d37f560558f00aa67.
Andrzej Warzynski [Mon, 23 Jan 2023 19:01:04 +0000 (19:01 +0000)]
[mlir][linalg] Make Linalg vectorizer lower affine.apply
It is possible that the input to the Linalg vectorizer contains
`affine.apply` ops (see the example in [1]). Such operations are not
vectarizable at the moment, but this can be fixed by simply converting
them to arithmetic operations. This is basically what this patch
introduces.
The IR change enabled in this patch could be part of a larger set of
"linalgOp pre-processing" transformations that happens right before
vectorization starts but after we know we can vectorize the op. I am
leaving this as a TODO.
[1] https://github.com/iree-org/iree/issues/10876.
Differential Revision: https://reviews.llvm.org/D142371
Timm Bäder [Thu, 26 Jan 2023 11:47:08 +0000 (12:47 +0100)]
[clang][Interp][NFC] Print parent class name of methods
in Function::dump().
Timm Bäder [Tue, 24 Jan 2023 18:58:09 +0000 (19:58 +0100)]
[clang][Interp][NFC] Remove an unnecessary isArray() check
We already do an isPrimitiveArray() check, so no need for the isArray()
check.
Evgeniy Brevnov [Fri, 25 Nov 2022 10:29:27 +0000 (17:29 +0700)]
[JT][CT] Preserve exisiting BPI/BFI during JumpThreading
Currently, JT creates and updates local instances of BPI\BFI. As a result global ones have to be invalidated if JT made any changes.
In fact, JT doesn't use any information from BPI/BFI for the sake of the transformation itself. It only creates BPI/BFI to keep them up to date. But since it updates local copies (besides cases when it updates profile metadata) it just waste of time.
Current patch is a rework of D124439. D124439 makes one step and replaces local copies with global ones retrieved through AnalysisPassManager. Here we do one more step and don't create BPI/BFI if the only reason of creation is to keep BPI/BFI up to date. Overall logic is the following. If there is cached BPI/BFI then update it along the transformations. If there is no existing BPI/BFI, then create it only if it is required to update profile metadata.
Please note if BPI/BFI exists on exit from JT (either cached or created) it is always up to date and no reason to invalidate it.
Reviewed By: mkazantsev
Differential Revision: https://reviews.llvm.org/D136827
Timm Bäder [Thu, 5 Jan 2023 11:55:29 +0000 (12:55 +0100)]
[clang][Interp][NFC] Add GetPtrBasePop opcode
Change GetPtrBase to *not* pop the base pointer and add a *Pop variant.
This will be used in later patches.
Timm Bäder [Sat, 7 Jan 2023 11:05:05 +0000 (12:05 +0100)]
[clang][Interp] Implement __builtin_assume
Just ignore it.
As part of this, move the Ret and RetVoid implementation to Interp.h, so
they can be shared with InterpBuiltin.cpp.
Differential Revision: https://reviews.llvm.org/D141193
Shilei Tian [Fri, 27 Jan 2023 04:45:02 +0000 (23:45 -0500)]
[OpenMP] Fix stack overflow for test bug54082.c
When `N` is 1024, `int result[N][N]` is obviously large stack that Windows cannot support...
Fix #60326.
Reviewed By: jdoerfert
Differential Revision: https://reviews.llvm.org/D142684
Michael Buch [Fri, 27 Jan 2023 03:25:16 +0000 (03:25 +0000)]
[lldb][Test][NFC] TestCreateClassTemplateDecl: make variable names more readable
Suggested in https://reviews.llvm.org/D140030
Michael Buch [Fri, 27 Jan 2023 03:08:39 +0000 (03:08 +0000)]
[lldb][NFC] Build fix: use TemplateParameterInfos public APIs instead of accessing private members
Fixes build failures caused by a faulty rebase
in `
a29e06bbeaad7012ac85b221f1aaba3fe1d5fd35`
Differential Revision: https://reviews.llvm.org/D140030
Michael Buch [Thu, 26 Jan 2023 17:52:09 +0000 (17:52 +0000)]
[ReleaseNotes] Add release notes for LLDB/Clang changes to handling of defaulted template arguments
Differential Revision: https://reviews.llvm.org/D142653
Michael Buch [Sun, 15 Jan 2023 03:26:41 +0000 (03:26 +0000)]
[lldb] Add support for DW_AT_default_value in template params
**Summary**
This patch makes LLDB understand the `DW_AT_default_value` on
template argument DIEs. As a result, type summaries will no
longer contain the defaulted template arguments, reducing
noise substantially. E.g.,
Before:
```
(lldb) v nested
(std::vector<std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >, std::allocator<std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator <char> > > > > >) nested = size=0 {}
```
After:
```
(lldb) v nested
(std::vector<std::vector<std::basic_string<char> > >) nested = size=0 {}
```
See discussion in https://reviews.llvm.org/D140423
**Testing**
* Adjust API tests
* Added unit-test
Differential Revision: https://reviews.llvm.org/D141828
Michael Buch [Sat, 17 Dec 2022 17:32:51 +0000 (17:32 +0000)]
[lldb][TypeSystemClang][NFC] Make TemplateParameterInfos members private
This patch makes the members of `TemplateParameterInfos` only accessible
via public APIs. The motivation for this is that
`TemplateParameterInfos` attempts to maintain two vectors in tandem
(`args` for the template arguments and `names` for the corresponding
name). Working with this structure as it's currently designed makes
it easy to run into out-of-bounds accesses later down the line.
This patch proposes to introduce a new
`TemplateParameterInfos::InsertArg` which is the only way to
set the `TemplateArgument` and name of an entry and since we
require both to be specified we maintain the vectors in sync
out-of-the-box.
To avoid adding non-const getters just for unit-tests a new
`TemplateParameterInfosManipulatorForTests` is introduced
that can be used to control internal state from tests.
Michael Buch [Sat, 21 Jan 2023 01:49:14 +0000 (01:49 +0000)]
[clang][DebugInfo] Check TemplateArgument::IsDefaulted
Since `ClassTemplateSpecializationDecl`s now set the
`TemplateArgument::IsDefaulted` bit, there's no need
to derive it here.
Differential Revision: https://reviews.llvm.org/D142333
Michael Buch [Sun, 15 Jan 2023 03:37:09 +0000 (03:37 +0000)]
[clang][TypePrinter] Test TemplateArgument::IsDefaulted when omitting default arguments
**Summary**
This patch allows clients who can't properly construct
a `ClassTemplateDecl` to still benefit from the `clang::TypePrinter`s
ability to skip printing defaulted template arguments. The
clients simply have to call `TemplateArgument::setIsDefaulted`
in advance.
See discussion in https://reviews.llvm.org/D140423
Differential Revision: https://reviews.llvm.org/D141827
Michael Buch [Sun, 15 Jan 2023 03:36:50 +0000 (03:36 +0000)]
[clang][TemplateBase] Add IsDefaulted bit to TemplateArgument
**Summary**
This patch adds a `IsDefaulted` field to `clang::TemplateArgument`.
To prevent memory footprint increase we still 1 bit from `ArgKind`.
**Changes**
1. `getIsDefaulted`/`setIsDefaulted` to allow clients to communicate
an argument's defaulted-ness to the TypePrinter
2. The `TemplateArgument` properties description had to be changed
to make sure we correctly mark the defaulted-ness of arguments
that came from a deserialized AST (caught by the HLSL test-suite)
3. The `TemplateArgument` constructors now accept a `IsDefaulted`
parameter to simplify construction from the tablegen description.
Though if people don't want to clutter the constructors we can
instead call `setIsDefaulted` from tablegen
4. When `clang::Sema` checks the template arguments against template
parameters we now call `setIsDefaulted`. This makes sure that
whenever a specialization decl gets constructed, the defaulted-ness
of the associated `TemplateArgument`s has already been deduced.
This preserves the immutability of `TemplateArgumentList`s
**Background**
In LLDB we construct ASTs from debug-info and hand it to clang
to perform actions such as printing/formatting a typenames.
Some debug formats, specifically DWARF, may only encode information
about class template instantiations, losing the structure of the generic
class definition. However, the `clang::TypePrinter` needs a properly
constructed `ClassTemplateDecl` with generic default argument decls
to be able to deduce whether a `ClassTemplateSpecializationDecl` was
instantiatiated with `TemplateArgument`s that correspond to the
defaults. LLDB does know whether a particular template argument was
defaulted, but can't currently tell clang about it.
This patch allows LLDB to set the defaulted-ness of a `TemplateArgument`
and thus benefit more from `clang::TypePrinter`.
See discussion in https://reviews.llvm.org/D140423
**Testing**
* Added unit-test
* LLDB/clang/llvm test-suite passes
Differential Revision: https://reviews.llvm.org/D141826
Michael Buch [Wed, 25 Jan 2023 17:09:06 +0000 (17:09 +0000)]
[clang][TypePrinter] Support expression template arguments when checking defaultedness
This patch adds support for `TemplateArgument`s of kind
`TemplateArgument::Expression` to `clang::isSubstitutedDefaultArgument`.
We do so by evaluating both the `Pattern` and `Arg` expression to an
`APInt`, if we can, and comparing the results.
This will be useful in an upcoming change where
`clang::isSubstitutedDefaultArgument` gets called from `clang::Sema`
where the `TemplateArgument`s are instantiated as expressions (without
being evaluted to `APInt` beforehand).
**Testing**
- Added unit-tests
Differential Revision: https://reviews.llvm.org/D142632
Jordan Rupprecht [Fri, 27 Jan 2023 02:23:23 +0000 (18:23 -0800)]
[test] Remove unused `unittest2` import from concurrent_base.py
Phoebe Wang [Fri, 27 Jan 2023 01:24:57 +0000 (09:24 +0800)]
[X86][ConstraintFP] Model `MXCSR` for function call
This patch is inspired by D111433. It would affect the performance under
strict FP mode. But it preserves the correct rounding behavior accross
function calls.
Fixes #59305
Reviewed By: sepavloff
Differential Revision: https://reviews.llvm.org/D139549
Jordan Rupprecht [Fri, 27 Jan 2023 02:02:16 +0000 (18:02 -0800)]
[test] Remove unused `unittest2` import
Emilia Dreamer [Fri, 27 Jan 2023 01:56:11 +0000 (03:56 +0200)]
[clang-format] Disallow templates to be followed by literal
There should not be any cases where the angle brackets of template
parameters are directly followed by a literal. It is more likely that a
comparison is taking place instead.
This patch makes the TokenAnnotator prefer to annotate < and > as
operators when directly followed by a literal. A similar check already
exists for literals directly *before* potential template args.
Fixes https://github.com/llvm/llvm-project/issues/60140
Reviewed By: HazardyKnusperkeks, owenpan, MyDeveloperDay
Differential Revision: https://reviews.llvm.org/D142139
Hanhan Wang [Wed, 18 Jan 2023 00:44:32 +0000 (16:44 -0800)]
[mlir][tensor] Add a tiling interface registration for pack/unpack only.
Reviewed By: mravishankar
Differential Revision: https://reviews.llvm.org/D141977
Jez Ng [Fri, 27 Jan 2023 01:28:58 +0000 (20:28 -0500)]
[NFC] Optimize vector usage in lld
By using emplace_back, as well as converting some loops to for-each, we can do more efficient vectorization.
Make copy constructor for TemporaryFile noexcept.
Reviewed By: #lld-macho, int3
Differential Revision: https://reviews.llvm.org/D139552
Tom Stellard [Thu, 26 Jan 2023 23:18:58 +0000 (15:18 -0800)]
test-release.sh: Use parallel xz for packaging the binaries
Reviewed By: amyk, dim, hans
Differential Revision: https://reviews.llvm.org/D142417
Jordan Rupprecht [Thu, 26 Jan 2023 22:29:48 +0000 (14:29 -0800)]
[test][lldb-vscode] Fix unclean shutdown in test_terminate_commands
This test manually sends `terminateCommands` to shutdown, but then the test attempts another `terminateCommands` request in test tear down, which fails since it's already torn down. This error is ignored in LLDB's old fork of unittest2, but will be reported as a test failure in `unittest` from the Python standard library. Use `disconnectAutomatically` to avoid terminating twice.
Benjamin Kramer [Thu, 26 Jan 2023 22:25:15 +0000 (23:25 +0100)]
[bazel] Add missing dependency after
55cf0de35e
Slava Zakharin [Thu, 26 Jan 2023 22:20:47 +0000 (14:20 -0800)]
[flang] Fixed restrictions checking for OpenACC loop-associated constructs.
CheckDoConcurrentClauseRestriction and CheckTileClauseRestriction expect
that the construct has associated DoConstruct, while it is not set
when the do-loop has no loop control. The change is to skip the clauses
checks, when the do-loop does not have the loop control.
An alternative fix would be to associate the DoConstruct even when
the do-loop has no loop control and let Check*ClauseRestriction run their
checks, but I am not sure if associating invalid DoConstruct is a good idea.
This fixes failure in Semantics/OpenACC/acc-canonicalization-validity.f90
reported in D142279.
Reviewed By: clementval
Differential Revision: https://reviews.llvm.org/D142652
Slava Zakharin [Thu, 26 Jan 2023 22:17:13 +0000 (14:17 -0800)]
[flang] Fixed uninitialized std::unique_ptr dereference.
This fixes unittest failures reported in D142279:
flang-Unit :: Frontend/./FlangFrontendTests/5/7
flang-Unit :: Frontend/./FlangFrontendTests/6/7
Nicolas Vasilache [Thu, 26 Jan 2023 20:30:54 +0000 (12:30 -0800)]
[mlir][Linalg] Adding a greedy packing transform dialect op.
This PR adds a `pack_greedily` transform operation that infers the packing for gemm
subcomputations embedded within in any LinalgOp and packs accordingly.
A normalization step guarantees that we get the innermost op dimensions in one of `8`
possible `(m, n, k)` orders, specified as a parameter, from which we can emit all
packed forms.
The current implementation takes an arbitrary LinalgOp and tries to pack it along
the specified dimensions with specified sizes and inner dim permutation.
This achieves a new level of normalization and generalization for any `n-D`
LinalgOp that contains a gemm embedded within it:
we will always see a predictable packed form for any of these ops.
Differential Revision: https://reviews.llvm.org/D142661
Elizabeth Andrews [Thu, 26 Jan 2023 21:51:56 +0000 (13:51 -0800)]
[SYCL] Fix test to conform to SYCL2020
Dominik Adamski [Tue, 17 Jan 2023 09:51:48 +0000 (03:51 -0600)]
[OpenMP][OMPIRBuilder]Move SIMD alignment calculation to LLVM Frontend
Currently default simd alignment is defined by Clang specific TargetInfo class.
This class cannot be reused for LLVM Flang. That's why default simd alignment
calculation has been moved to OMPIRBuilder which is common for Flang and Clang.
Previous attempt: https://reviews.llvm.org/D138496 was wrong because
the default alignment depended on the number of built LLVM targets.
If we wanted to calculate the default alignment for PPC and we hadn't specified
PPC LLVM target to build, then we would get 0 as the alignment because
OMPIRBuilder couldn't create PPCTargetMachine object and it returned 0 as
the default value.
If PPC LLVM target had been built earlier, then OMPIRBuilder could have created
PPCTargetMachine object and it would have returned 128.
Differential Revision: https://reviews.llvm.org/D141910
Reviewed By: jdoerfert
Joseph Huber [Thu, 26 Jan 2023 21:00:24 +0000 (15:00 -0600)]
[LinkerWrapper] Fix `-Bsymbolic` being sent to the compiler and not the linker
Summary:
Clang doesn't warn on `-B` options passed to it. This one is not
forwarded to the linker which results in some tests failing when
offloading to x86_64 with the `bfd` linker.
Daniel Thornburgh [Mon, 24 Oct 2022 22:35:00 +0000 (15:35 -0700)]
Reland: [llvm-cov] Look up object files using debuginfod
Reviewed By: gulfem
Differential Revision: https://reviews.llvm.org/D136702
WuXinlong [Thu, 26 Jan 2023 20:54:00 +0000 (12:54 -0800)]
[RISCV] Add MC support of RISCV Zcb Extension
This patch add the instructions of Zcb extension.
Instructions in zcb extensions shorten part of bit manipulation instructions.
Co-authored-by: Craig Topper <craig.topper@sifive.com>
Reviewed By: craig.topper
Differential Revision: https://reviews.llvm.org/D131141
Kazu Hirata [Thu, 26 Jan 2023 20:29:48 +0000 (12:29 -0800)]
[Support] Remove findFirstSet and findLastSet
This patch removes findFirstSet and findLastSet as there are no uses
left in LLVM.
I am not aware of any uses of findFirstSet and findLastSet in the
open-source world outside LLVM, so I am skipping the deprecation step.
Differential Revision: https://reviews.llvm.org/D142603
Mike Hommey [Thu, 26 Jan 2023 20:28:09 +0000 (21:28 +0100)]
[extract_symbols.py] Filter out more symbols for MSVC
This strips out about 5k symbols.
Fixes https://github.com/llvm/llvm-project/issues/60109
Reviewed By: john.brawn
Differential Revision: https://reviews.llvm.org/D142431
Louis Dionne [Wed, 25 Jan 2023 18:09:39 +0000 (13:09 -0500)]
[libc++] Add documentation for reproducing CI issues locally
Differential Revision: https://reviews.llvm.org/D142566
LLVM GN Syncbot [Thu, 26 Jan 2023 19:41:53 +0000 (19:41 +0000)]
[gn build] Port
36080434a885
Louis Dionne [Fri, 2 Dec 2022 21:45:49 +0000 (13:45 -0800)]
[libc++] Move the definition of aligned allocation helpers outside of <new>
They are not needed in <new> -- in fact they are only needed in .cpp files.
Getting those out of the way makes the headers smaller and also makes it
easier to use the library on platforms where aligned allocation is not
available.
Differential Revision: https://reviews.llvm.org/D139231
Ivan Kosarev [Thu, 26 Jan 2023 17:44:43 +0000 (17:44 +0000)]
[CMake] Support undefined LLVM_NATIVE_ARCH in llvm_map_components_to_libnames().
https://reviews.llvm.org/D142405 made this function relying on the
LLVM_NATIVE_ARCH be defined, which is not necessarily the case for
third-party projects that include LLVM as their part.
Reviewed By: beanz
Differential Revision: https://reviews.llvm.org/D142610
Paul Kirth [Thu, 26 Jan 2023 17:53:19 +0000 (17:53 +0000)]
[llvm][docs] Update old metadata syntax in examples
This patch updates examples in the documentation to match the existing
convention. Calls to intrinsics that have metadata arguments were not
included.
Reviewed By: dexonsmith
Differential Revision: https://reviews.llvm.org/D142651
Artem Belevich [Wed, 25 Jan 2023 20:12:32 +0000 (12:12 -0800)]
[NVPTX] Do not addrspacecast AS-specific kernel arguments.
Fixes https://github.com/llvm/llvm-project/issues/46954
The assumption that generic pointers passed to a CUDA kernel is CUDA-specific
and should not be applied to non-CUDA compilations. Addrspacecasts to global AS
and back should never be applied to AS-specific pointers.
In order to make tests actually do the testing for non-CUDA compilation, we need
to get TargetMachine from the TargetPassConfig, instead of passing it explicitly
as a pass constructor argument.
Differential Revision: https://reviews.llvm.org/D142581
Joseph Huber [Thu, 26 Jan 2023 17:23:21 +0000 (11:23 -0600)]
[OpenMP] Run an extra 'OpenMPOpt' pass in LTO-mode
The `OpenMPOpt` pass is pivotal to the performance of many OpenMP
offloading programs. When we perform non-LTO builds with OpenMP we used
to link the OpenMP deviceRTL individually for each TU. This lead to us
getting an additional attributor run on the combined runtime and user
code. When we used LTO we lost a run and suffered a large performance
degradation. This patch simply adds in the extra `OpenMPOpt` pass that
we miss into the LTO pipeline. This patch fixes the performance
regression shown in applications that used OpenMP offloading in LTO
mode.
Previously, this wasn't legal to do as we could emit new runtime calls
into the module. That was fixed by D142646.
Depends on D142646
Fixes https://github.com/llvm/llvm-project/issues/60300
Reviewed By: jdoerfert
Differential Revision: https://reviews.llvm.org/D142650
Joseph Huber [Thu, 26 Jan 2023 17:13:56 +0000 (11:13 -0600)]
[OpenMP] Make OpenMPOpt aware of the OpenMP runtime's status
The `OpenMPOpt` pass contains optimizations that generate new calls into
the OpenMP runtime. This causes problems if we are in a state where the
runtime has already been linked statically. Generating these new calls
will result in them never being resolved. We should indicate if we are
in a "post-link" LTO phase and prevent OpenMPOpt from generating new
runtime calls.
Generally, it's not desireable for passes to maintain state about the
context in which they're called. But this is the only reasonable
solution to static linking when we have a pass that generates new
runtime calls.
Reviewed By: jdoerfert
Differential Revision: https://reviews.llvm.org/D142646
Zahira Ammarguellat [Wed, 25 Jan 2023 22:11:07 +0000 (17:11 -0500)]
__arithmetic_fence enforces ordering on expression evaluation when fast-math
is enabled.
In fast math mode some floating-point optimizations are performed such as
reassociation and distribution.
For example, the compiler may transform (a+b)+c into a+(b+c). Although these
two expressions are equivalent in integer arithmetic, they may not be in
floating-point arithmetic. The builtin tells the compiler that the expression
in parenthesis can’t be re-associated or distributed.
__arithmetic_fence(a+b)+c is not equivalent to a+(b+c).
This patch adds the support of the builtin to SPIR target.
Differential Revision: https://reviews.llvm.org/D142583
Erich Keane [Thu, 26 Jan 2023 19:11:29 +0000 (11:11 -0800)]
[NFC][Concepts] Change the Source Range of Concepts ParamMatching
As came up in the discussion on
https://reviews.llvm.org/rG12cb1cb3720de8d164196010123ce1a8901d8122
We were asserting because the attempt to print a note found that our
source range for a immediately declared constraint (as a part of
Parameter Mapping Substitution) wasn't in order.
However, it doesn't really make sense to have the location of this be
the whole list of template arguments, as that would result in the range
being:
bool func(std::thing<char*> auto foo) {}
^^^^^^^^^^^^^^^
Even if done correctly. Instead, this patch makes the range be just
'foo' in this case (or a pointer right after 'auto' if unnamed).
Arthur Eubanks [Wed, 25 Jan 2023 19:25:35 +0000 (11:25 -0800)]
[lld] Remove transitional legacy pass manager flags
Reviewed By: asbirlea
Differential Revision: https://reviews.llvm.org/D142571
Joseph Huber [Thu, 26 Jan 2023 19:02:22 +0000 (13:02 -0600)]
[Clang][NFC] Fix out-of-date comments on 'clang-offload-bundler'
Summary:
These comments are confusing as the `clang-offload-bundler` is no longer
used by these toolchains.
einvbri [Thu, 26 Jan 2023 14:23:22 +0000 (08:23 -0600)]
[analyzer] Fix crash exposed by D140059
Change https://reviews.llvm.org/D140059 exposed the following crash in
Z3Solver, where bit widths were not checked consistently with that
change. This change makes the check consistent, and fixes the crash.
```
clang: <root>/llvm/include/llvm/ADT/APSInt.h:99:
int64_t llvm::APSInt::getExtValue() const: Assertion
`isRepresentableByInt64() && "Too many bits for int64_t"' failed.
...
Stack dump:
0. Program arguments: clang -cc1 -internal-isystem <root>/lib/clang/16/include
-nostdsysteminc -analyze -analyzer-checker=core,unix.Malloc,debug.ExprInspection
-analyzer-config crosscheck-with-z3=true -verify reproducer.c
#0 0x00000000045b3476 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int)
<root>/llvm/lib/Support/Unix/Signals.inc:567:22
#1 0x00000000045b3862 PrintStackTraceSignalHandler(void*)
<root>/llvm/lib/Support/Unix/Signals.inc:641:1
#2 0x00000000045b14a5 llvm::sys::RunSignalHandlers()
<root>/llvm/lib/Support/Signals.cpp:104:20
#3 0x00000000045b2eb4 SignalHandler(int)
<root>/llvm/lib/Support/Unix/Signals.inc:412:1
...
#9 0x0000000004be2eb3 llvm::APSInt::getExtValue() const
<root>/llvm/include/llvm/ADT/APSInt.h:99:5
<root>/llvm/lib/Support/Z3Solver.cpp:740:53
clang::ASTContext&, clang::ento::SymExpr const*, llvm::APSInt const&, llvm::APSInt const&, bool)
<root>/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConv.h:552:61
```
Reviewed By: steakhal
Differential Revision: https://reviews.llvm.org/D142627
Sanjay Patel [Thu, 26 Jan 2023 18:03:46 +0000 (13:03 -0500)]
[InstSimplify] X && !(X || Y) --> false
https://alive2.llvm.org/ce/z/7J8Exr
This is a commuted variant that was not included in:
D138853 /
f2973327496fc966c4e89597
Sanjay Patel [Thu, 26 Jan 2023 17:30:37 +0000 (12:30 -0500)]
[InstSimplify] add commuted variants of logical and/or pattern; NFC
Existing tests were added with D138853, but that patch failed
to handle all of the commutes. The poison-safety behavior is
symmetric, so I'm not duplicating all of the tests that were
added with that patch.
Stanislav Mekhanoshin [Wed, 25 Jan 2023 20:07:30 +0000 (12:07 -0800)]
[AMDGPU] Split dot7 feature
Differential Revision: https://reviews.llvm.org/D142507
Jonas Paulsson [Thu, 19 Jan 2023 18:46:34 +0000 (12:46 -0600)]
[SystemZ] Add atomicrmw tests for i128 (NFC).
Review: Ulrich Weigand
Alex Brachet [Thu, 26 Jan 2023 18:18:21 +0000 (18:18 +0000)]
[CMake] Remove libLTO from Fuchsia toolchain
Differential Revision: https://reviews.llvm.org/D142649
Paul Kirth [Tue, 19 Jul 2022 22:55:41 +0000 (22:55 +0000)]
[clang-doc] Reduce duplicate code with template
Reviewed By: phosek
Differential Revision: https://reviews.llvm.org/D142564
Jay Foad [Thu, 26 Jan 2023 17:27:56 +0000 (17:27 +0000)]
[flang] Fix dereference of std::optional with no value
Differential Revision: https://reviews.llvm.org/D142648
Shivam Gupta [Thu, 26 Jan 2023 17:21:44 +0000 (22:51 +0530)]
[MLIR][NFC] Fix a checked after used case in ReshapeOpsUtils.cpp
Found by PVS-Studio - https://pvs-studio.com/en/blog/posts/cpp/1003/, N18.
The value of the 'sourceDim' index is checked after it was used.
Reviewed By: zero9178
Differential Revision: https://reviews.llvm.org/D142312
Benjamin Kramer [Tue, 24 Jan 2023 17:01:26 +0000 (18:01 +0100)]
[mlir][vector] Allow transposing multi_reduction when the parallel dim is in the middle
The check for the outer lowering wasn't quite right.
Differential Revision: https://reviews.llvm.org/D142483
Caroline Concatto [Thu, 26 Jan 2023 16:50:25 +0000 (16:50 +0000)]
[AArch64][SME2] Add Multi-vector add vector intrinsics
Add the following intrinsic:
ADD vectors
NOTE: These intrinsics are still in development and are subject to future changes.
Reviewed By: david-arm
Differential Revision: https://reviews.llvm.org/D142455
Francesco Petrogalli [Mon, 23 Jan 2023 16:35:52 +0000 (17:35 +0100)]
[MISched] Dump the execution trace of the schedule.
The traces are printed only for bottom-up and top-down scheduling
because the values of TopReadyCycle and BottomReadyCycle are
inconsistent when obtained via bidirectional scheduling (see
`BIDIRECTIONAL` checks in the test).
Differential Revision: https://reviews.llvm.org/D142529
Nicolas Vasilache [Thu, 26 Jan 2023 15:58:59 +0000 (07:58 -0800)]
[mlir][Linalg] Put a proper type on transform.structured.match op
This allows much better verification messages in consuming ops that properly declare
`TransformHandleTypeInterface` on their operands.
Downstream tests can be updated with a command resembling:
```
git grep -l "structured\.match" mlir/test | xargs -i sed -i {} -e "s/\(structured.match.*\)/\1 : (\!pdl.operation) -> \!pdl.operation/g"
```
Differential Revision: https://reviews.llvm.org/D142643
Paul Robinson [Thu, 26 Jan 2023 15:47:37 +0000 (07:47 -0800)]
[unittests] Use GTEST_SKIP() instead of return when appropriate
Basically NFC: A TEST/TEST_F/etc that bails out early (usually because
setup failed or some other runtime condition wasn't met) generally
should use GTEST_SKIP() to report its status correctly, unless it
takes steps to report another status (e.g., FAIL()).
Tomasz Kamiński [Thu, 26 Jan 2023 16:33:48 +0000 (17:33 +0100)]
[analyzer] Fix assertion failure in SMT conversion for unary operator on floats
In the handling of the Symbols from the RangExpr, the code assumed that
the operands of the unary operators need to have integral type.
However, the CSA can create SymExpr with a floating point operand, when
the integer value is cast into it, like `(float)h == (float)l` where
both of `h` and `l` are integers.
This patch handles such situations, by using `fromFloatUnOp()` instead
of `fromUnOp()`, when the operand have a floating point type.
I have investigated all other calls of `fromUnOp()`, and for one in:
- `getZeroExpr()` is applied only on boolean types, so it correct
- `fromBinOp()` is not invoked for floating points
- `fromFloatUnOp()` I am uncertain about this case and I was not able
to produce a test that would reach this point, as a negation of
floating points numbers seem to produce `Unknown` symbols.
This issue exists since the introduction of `UnarySymExpr` in D125318
and their handling for Z3 in D125547.
Patch by Tomasz Kamiński.
Reviewed By: mikhail.ramalho
Differential Revision: https://reviews.llvm.org/D140891
Arseniy Zaostrovnykh [Thu, 26 Jan 2023 16:19:04 +0000 (17:19 +0100)]
Fix assertion failure "PathDiagnosticSpotPiece's must have a valid location." in ReturnPtrRange checker on builtin functions
Builtin functions (such as `std::move`, `std::forward`, `std::as_const`)
have a body generated during the analysis not related to any source file
so their statements have no valid source locations.
`ReturnPtrRange` checker should not report issues for these builtin
functions because they only forward its parameter and do not create any
new pointers.
Fixes #55347
Patch by Arseniy Zaostrovnykh.
Reviewed By: NoQ
Differential Revision: https://reviews.llvm.org/D138713
Mariya Podchishchaeva [Thu, 26 Jan 2023 15:43:27 +0000 (10:43 -0500)]
[clang] Fix sizeof of boolean vector
Ensure it is at least 8 bits.
Fixes #59801
Reviewed By: erichkeane
Differential Revision: https://reviews.llvm.org/D142550
Florian Hahn [Thu, 26 Jan 2023 15:28:49 +0000 (15:28 +0000)]
[SCCP] Regenerate check lines for test.
The auto-generated check lines for the test are missing `align`.
Re-generate the check lines to avoid unrelated changes in upcoming
change.
Martin Fink [Thu, 26 Jan 2023 14:25:58 +0000 (15:25 +0100)]
[SelectionDAG] Add missing setValue calls in visitIntrinsicCall
Add missing setValue calls in SelectionDAGBuilder for mem-transfer
intrinsic calls. These setValue calls are required in order to propagate
pcsections metadata from IR to MIR.
Reviewed By: melver
Differential Revision: https://reviews.llvm.org/D141048
Martin Fink [Thu, 26 Jan 2023 14:25:58 +0000 (15:25 +0100)]
[SelectionDAG] Add pcsections recursively on SDNode values
When adding pcsections to SDNodes, recursively add them to all values of
the node as well.
Reviewed By: melver
Differential Revision: https://reviews.llvm.org/D141048
eopXD [Sun, 15 Jan 2023 17:56:23 +0000 (09:56 -0800)]
[15/15][Clang][RISCV][NFC] Set data member under Policy as constants
The object is now correct by construction.
This is the 15th commit of a patch-set that aims to change the default policy
for RVV intrinsics from TAMU to TAMA.
Please refer to the cover letter in the 1st commit (D141573) for an
overview.
Depends on D141793.
Reviewed By: craig.topper
Differential Revision: https://reviews.llvm.org/D141796
Joachim Protze [Thu, 26 Jan 2023 14:31:24 +0000 (15:31 +0100)]
Re-apply "[OpenMP][Archer] Use dlsym rather than weak symbols for TSan annotations"
Explicitly link libdl this time.
Differential Revision: https://reviews.llvm.org/D142378
Samuel Parker [Thu, 26 Jan 2023 14:25:38 +0000 (14:25 +0000)]
[WebAssembly] Trying to fix expensive buildbot
Johannes de Fine Licht [Thu, 26 Jan 2023 14:03:41 +0000 (15:03 +0100)]
[MLIR][LLVM] Support inlining of LLVM::AllocaOp.
If inlining into an LLVM function, move allocas of constant size from
the callee's entry block to the new entry block, as this will fold into
the prologue/epilogue code during code generation.
We still allow inlining allocas even if we cannot do this
post-processing (i.e., when we are not inlining into an `LLVM::FuncOp`),
since this is an optimization (and thus not necessary for correctness).
Depends on D141682
Reviewed By: gysit
Differential Revision: https://reviews.llvm.org/D142436
Nikita Popov [Thu, 26 Jan 2023 14:09:48 +0000 (15:09 +0100)]
[LVI] Use !range metadata for supported intrinsics
Even if the intrinsic is supported by ConstantRange, we should
still make use of !range metadata. This doesn't matter much now,
but is important if we want to support ctlz style intrinsics,
which always have KnownBits-based !range metadata attached, which
might be better than what we can compute using ranges.
Nikita Popov [Thu, 26 Jan 2023 14:06:19 +0000 (15:06 +0100)]
[CVP] Add test for !range being ignored on supported intrinsic (NFC)
Sanjay Patel [Wed, 25 Jan 2023 21:27:29 +0000 (16:27 -0500)]
[InstCombine] reduce compare of signbits of 2 values, signed variant
(X s>> BitWidth - 1) == sext (Y s> -1) --> (X ^ Y) < 0
(X s>> BitWidth - 1) != sext (Y s> -1) --> (X ^ Y) > -1
This is the same logic as:
7cbfc39c77ca
...extended to deal with "signed" cast+shift instructions.
https://alive2.llvm.org/ce/z/LLidya
Sanjay Patel [Wed, 25 Jan 2023 20:10:41 +0000 (15:10 -0500)]
[InstCombine] improve description of not+shift transform; NFC
This was added recently with:
e44a305690add9f75
Sanjay Patel [Wed, 25 Jan 2023 20:08:17 +0000 (15:08 -0500)]
[InstCombine] add tests for cmp-of-signbits using sext+ashr; NFC
These are copied from the zext+lshr variants from:
e76c95fb40b108
d1511ed8d19ac
David Spickett [Thu, 26 Jan 2023 13:54:38 +0000 (13:54 +0000)]
[llvm][TableGen][Jupyter] Add notebook links to README
This folder contains the kernel and notebooks
so let's make that obvious and list them in the
readme.
Nikita Popov [Tue, 24 Jan 2023 09:43:40 +0000 (10:43 +0100)]
[Docs] Add best practices for regression tests
There are a lot of conventions for writing tests that don't seem
to be documented anywhere right now, so this takes a stab at
writing down some "best practices".
Differential Revision: https://reviews.llvm.org/D142441
Tim Northover [Thu, 26 Jan 2023 13:26:10 +0000 (13:26 +0000)]
Revert "ARM: skip debug instructions when matching jump-table patterns."
This reverts commit
ce4fcea59e1d5829b4355b6401d7265be23f617a.
I committed it accidentally.
Tim Northover [Thu, 26 Jan 2023 12:52:59 +0000 (12:52 +0000)]
AArch64: remove SM4 support from Apple CPUs.
The CPUs never supported SM4 instructions, but until recently I think crypto
was folded into the baseline architecture as a monolithic feature so it was
difficult to represent that. Now it's split we can, and the CPUs that support
v8.4 onwards only handle AES, SHA2, SHA3 by way of crypto instructions.
Tim Northover [Wed, 18 Jan 2023 15:12:29 +0000 (15:12 +0000)]
ARM: skip debug instructions when matching jump-table patterns.
When working out whether we can see a compressible jump-table pattern during
ConstantIslands, we were stopping when we saw a debug instruction. Instead it's
better to keep iterating backwards to the first real instruction.
Samuel Parker [Thu, 26 Jan 2023 11:52:24 +0000 (11:52 +0000)]
[DAGCombine] fp_to_sint isSaturatingMinMax
Check for single smax pattern against zero when converting from a
small enough float.
Differential Revision: https://reviews.llvm.org/D142481
Paul Walker [Thu, 26 Jan 2023 12:33:10 +0000 (12:33 +0000)]
[SVE] Move isel for casting between NEON and SVE vector types into tablegen.
This is purely refactoring to remove some unecessary C++ code.
Differential Revision: https://reviews.llvm.org/D142516
David Spickett [Wed, 14 Dec 2022 13:46:27 +0000 (13:46 +0000)]
[LLVM][TableGen] Notebook describing how to write a Python backend
This tutorial uses the dump json option to write a backend for
SQL queries.
It is based on the work of Min-Yih Hsu:
* https://github.com/mshockwave/SQLGen
* https://www.youtube.com/watch?v=UP-LBRbvI_U
I hope that having the same concepts in 3 forms will allow people
to choose the style that fits them.
The main drawback here being that it's in Python. C++ can be used
in a notebook (https://github.com/jupyter-xeus/xeus-cling) but I
decided against it for a few reasons:
* Python is the default for Jupyter, no extra installs needed.
* Having the code in a second language may help people who
know one or the other.
* There is no upstream example of a JSON powered backend.
(and although we would be unlikely to accept one upstream,
I think it's a great option for quick development before
translating into C++)
Reviewed By: myhsu
Differential Revision: https://reviews.llvm.org/D142364
Paul Walker [Wed, 18 Jan 2023 16:33:42 +0000 (16:33 +0000)]
[SVE] Fix incorrect lowering of predicate permute builtins.
When lowering predicate permute builtins we incorrectly assume only
the typically "active" bits for the specified element type play a
role with all other bits zero'd. This is not the case because all
bits are significant, with the element type specifying how they
are grouped:
b8 - permute using a block size of 1 bit
b16 - permute using a block size of 2 bits
b32 - permute using a block size of 4 bits
b64 - permute using a block size of 8 bits
The affected builtins are svrev, svtrn1, svtrn2, svuzp1, svuzp2,
svzip1 and svzip2.
This patch adds new intrinsics to support these operations and
changes the builtin lowering code to emit them. The b8 case remains
unchanged because for that operation the existing intrinsics work
as required and their support for other predicate types has been
maintained as useful if only as a way to test the correctness of
their matching ISD nodes that code generation relies on.
Differential Revision: https://reviews.llvm.org/D142065
Florian Hahn [Thu, 26 Jan 2023 12:04:20 +0000 (12:04 +0000)]
[SCCP] Adjust test after
cdeaf5f28c3dca.
Matt Devereau [Thu, 26 Jan 2023 12:02:16 +0000 (12:02 +0000)]
Revert "[LoopVectorize] Enable integer Mul and Add as select reduction patterns"
This reverts commit
f90103851f9a381bbf7ed6da250217577afd00d2.
Florian Hahn [Thu, 26 Jan 2023 11:45:10 +0000 (11:45 +0000)]
Recommit "[SCCP] Use range info to prove AddInst has NUW flag."
This reverts commit
531756b9544b3e164b9ab998292fce3ebbc7c746.
The recommitted version fixes a crash when one of the operands is a
constant other than a ConstantInt. Test for that case have been added
in
5b16cd97b8e1c273.
It splits off the new logic into a separate function because setting the
flags is quite different compared to the other cases handled in replaceSignedInst
which all require replacing an existing instruction.
It also guards makeGuaranteedNoWrapRegion by `if (!Inst.hasNoUnsignedWrap())`
as discussed in the review.
Fixes #60280.
Fixes #60278.
Original message:
This patch updates SCCP to use the value ranges of AddInst operands to
try to prove the AddInst does not overflow in the unsigned sense and
adds the NUW flag. The reasoning is done with
makeGuaranteedNoWrapRegion (thanks @nikic for point it out!).
Follow-ups will include adding NSW and extension to more
OverflowingBinaryOperators.
Reviewed By: nikic
Differential Revision: https://reviews.llvm.org/D142387
Jannik Silvanus [Thu, 26 Jan 2023 11:42:08 +0000 (12:42 +0100)]
[Coroutine] Fix typos in comment
Vlad Serebrennikov [Thu, 26 Jan 2023 11:07:30 +0000 (14:07 +0300)]
[clang] Add test for CWG1960
P1787: "CWG1960 (currently closed as NAD) is resolved by removing the rule in question (which is widely ignored by implementations and gives subtle interactions between using-declarations)."
Wording: "In a using-declarator that does not name a constructor, every declaration named shall be accessible."
Reviewed By: #clang-language-wg, erichkeane, shafik
Differential Revision: https://reviews.llvm.org/D142381
Luke Lau [Wed, 25 Jan 2023 16:19:11 +0000 (16:19 +0000)]
[RISCV][NFC] Rename narrowing patterns to use W suffix
To match up with the pseudo instruction names
Reviewed By: craig.topper
Differential Revision: https://reviews.llvm.org/D142553
Kerry McLaughlin [Thu, 26 Jan 2023 10:55:06 +0000 (10:55 +0000)]
[AArch64][SME2] Add multi-vector saturating rounding shift right intrinsics
Adds IR intrinsics for the following SME2 instructions:
- sqrshr (2 and 4 vector)
- uqrshr (2 and 4 vector)
- sqrshru (2 and 4 vector)
- sqrshrn (4 vector)
- uqrshrn (4 vector)
- sqrshrun (4 vector)
Also adds intrinsics for the following SVE2p1 instructions:
- sqrshrn (2 vector)
- uqrshrn (2 vector)
- sqrshrun (2 vector)
NOTE: These intrinsics are still in development and are subject to future changes.
Reviewed By: CarolineConcatto
Differential Revision: https://reviews.llvm.org/D142466
Akash Banerjee [Tue, 24 Jan 2023 11:29:50 +0000 (11:29 +0000)]
[MLIR][OpenMP] Add Lowering support for OpenMP Target Data, Exit Data and Enter Data directives
This patch adds Fortran Lowering support for the OpenMP Target Data, Target Exit Data and Target Enter Data constructs.
operation.
Differential Revision: https://reviews.llvm.org/D142357