Valentin Clement [Wed, 17 May 2023 18:06:07 +0000 (11:06 -0700)]
[mlir][openacc] Add private representation
Currently privatization is not well represented in the OpenACC dialect. This
patch is a prototype to model privatization with a dedicated operation that
declares how the private value is created and destroyed.
The newly introduced operation is `acc.private.recipe` and it declares
an OpenACC privatization. The operation requires one mandatory and
one optional region.
1. The initializer region specifies how to create and initialize a new
private value. For example in Fortran, a derived-type might have a
default initialization. The region has an argument that contains the
value that need to be privatized. This is useful if the type is not
a known at compile time and the private value is needed to create its
copy.
2. The destroy region specifies how to destruct the value when it reaches
its end of life. It takes the privatized value as argument.
A same privatization can be used for multiple operand if they have the same
type and do not require a specific default initialization.
Example:
```mlir
acc.private.recipe @privatization_f32 : f32 init {
^bb0(%0: f32):
// init region contains a sequence of operations to create and initialize the
// copy if needed.
} destroy {
^bb0(%0: f32):
// destroy region contains a sequences of operations to destruct the created
// copy.
}
// The privatization symbol is then used in the corresponding operation.
acc.parallel private(@privatization_f32 -> %a : f32) {
}
```
Reviewed By: razvanlupusoru, jeanPerier
Differential Revision: https://reviews.llvm.org/D150622
Jon Roelofs [Tue, 16 May 2023 20:43:34 +0000 (13:43 -0700)]
builtins: fix a -Wshorten-64-to-32 in gcc_personality_v0
Differential revision: https://reviews.llvm.org/D150720
Amir Ayupov [Tue, 16 May 2023 20:57:41 +0000 (13:57 -0700)]
[BOLT][NFC] Use llvm::make_range
Use `llvm::make_range` convenience wrapper from ADT.
Reviewed By: #bolt, rafauler
Differential Revision: https://reviews.llvm.org/D145887
Krzysztof Parzyszek [Wed, 17 May 2023 17:41:46 +0000 (10:41 -0700)]
[Hexagon] Split SETCC on float16/float32 HVX pairs
Craig Topper [Wed, 17 May 2023 17:31:39 +0000 (10:31 -0700)]
[RISCV] Refactor parseVTypeI and use ParseFail if we parsed more than one identifier.
Previously we lexed into a SmallVector and unlexed the tokens if
the parsing failed.
This patch gets rid of the SmallVector and the unlexing.
If the first token fails to parse, return MatchFail. This allows us
to fallback to parsing as an immediate. If we successfully parsed the
first token, use ParseFail if any later tokens fail to parse. This
avoids needing to UnLex the tokens.
I've used a state machine to keep track of what component we've
parsed so far.
Reviewed By: asb
Differential Revision: https://reviews.llvm.org/D150753
Alex Brachet [Wed, 17 May 2023 17:24:58 +0000 (17:24 +0000)]
[Fuchsia] Correctly pass lists from STAGE2_ vars
Differential Revision: https://reviews.llvm.org/D150799
Pranav Kant [Wed, 10 May 2023 00:38:59 +0000 (00:38 +0000)]
[AArch64] Sink operands for faster bitselect vector instructions
Differential Revision: https://reviews.llvm.org/D150237
Mats Petersson [Tue, 16 May 2023 16:15:17 +0000 (17:15 +0100)]
[OpenMP]Fix trivial build failure in MacOS
MacOS build of LLVM with OpenMP enabled fails with an error
that it doesn't know what std::abs is. Fix by including <cmath>
so that the relevant function declaration is included.
No functional change intended.
Reviewed By: tianshilei1992
Differential Revision: https://reviews.llvm.org/D150687
yronglin [Wed, 17 May 2023 17:05:13 +0000 (01:05 +0800)]
[libc++] Implement P2505R5(Monadic operations for std::expected).
Implement P2505R5(https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p2505r5.html)
Reviewed By: #libc, philnik, ldionne
Differential Revision: https://reviews.llvm.org/D140911
yronglin [Wed, 17 May 2023 16:55:03 +0000 (00:55 +0800)]
Revert "[libc++] Implement P2505R5(Monadic operations for std::expected)."
This reverts commit
ebc111b08bddca55d5f7e560a20bdb2c913d80cb.
Sorry, I forgot to append Phabricator reversion when land D140911, I try to revert this change and reland.
Reviewed By: #libc, ldionne, EricWF
Differential Revision: https://reviews.llvm.org/D150793
Louis Dionne [Tue, 16 May 2023 14:48:13 +0000 (07:48 -0700)]
[libc++][NFC] Rename the 'noexceptions' CI config to 'no-exceptions' for consistency
Differential Revision: https://reviews.llvm.org/D150672
Kazu Hirata [Wed, 17 May 2023 16:45:03 +0000 (09:45 -0700)]
[flang] Fix an unused variable warning
This patch fixes:
flang/lib/Semantics/runtime-type-info.cpp:1275:12: error: unused
variable 'name' [-Werror,-Wunused-variable]
Nick Desaulniers [Wed, 17 May 2023 16:30:30 +0000 (09:30 -0700)]
[libcxxabi] define _LIBCPP_VERBOSE_ABORT
libc++ may be built with or without assertions. This causes definitions
of various methods of std::string_view to contain assertions and calls
to __libcpp_verbose_abort which libcxxabi does not provide. libcxxabi
does provide abort_message with the same interface, so define
_LIBCPP_VERBOSE_ABORT to use that. Otherwise D148566 will trigger
linkage failures for the missing symbol __libcpp_verbose_abort.
Link: https://libcxx.llvm.org/UsingLibcxx.html#enabling-the-safe-libc-mode
Reviewed By: #libc_abi, philnik, ldionne
Differential Revision: https://reviews.llvm.org/D149092
Nikita Popov [Wed, 17 May 2023 16:39:26 +0000 (18:39 +0200)]
[InstCombine] Return poison for known bits conflict
I suspect that this case is not actually reachable in practice
(because it gets folded away by other code before), but if we do
reach it, we should return poison, not undef.
Philip Reames [Wed, 17 May 2023 16:29:21 +0000 (09:29 -0700)]
[RISCV] Expand testing for store merging of constant stores
Nikita Popov [Wed, 17 May 2023 16:30:40 +0000 (18:30 +0200)]
[InstCombine] Compute bits of first operand for multi-use sub
Otherwise the result will always be unknown anyway. This fixes one
of the last inconsistencies in results between computeKnownBits()
and SimplifyDemandedBits().
V Donaldson [Tue, 16 May 2023 20:34:57 +0000 (13:34 -0700)]
[flang] Non-type-bound defined IO lowering
Generate supporting data structures and calls to new runtime IO functions
for defined IO that accesses non-type-bound procedures, such as `wft` in:
module m1
type t
integer n
end type
interface write(formatted)
module procedure wft
end interface
contains
subroutine wft(dtv, unit, iotype, v_list, iostat, iomsg)
class(t), intent(in) :: dtv
integer, intent(in) :: unit
character(*), intent(in) :: iotype
integer, intent(in) :: v_list(:)
integer, intent(out) :: iostat
character(*), intent(inout) :: iomsg
iostat = 0
write(unit,*,iostat=iostat,iomsg=iomsg) 'wft was called: ', dtv%n
end subroutine
end module
module m2
contains
subroutine test1
use m1
print *, 'test1, should call wft: ', t(1)
end subroutine
subroutine test2
use m1, only: t
print *, 'test2, should not call wft: ', t(2)
end subroutine
end module
use m1
use m2
call test1
call test2
print *, 'main, should call wft: ', t(3)
end
Azat Khuzhin [Wed, 17 May 2023 16:16:54 +0000 (09:16 -0700)]
[libcxx] Fix crash in std::stringstream with payload >= INT_MAX
stringstream does works for payload > INT_MAX, however
stringstream::gcount() can break the internal field (__nout_) and this
breaks the stringstream itself, and so the program will crash.
Fix this, by using __pbump(streamsize) over pbump(int)
Note, libstdc++ does not have this bug.
Reviewed By: #libc, ldionne, Mordante
Spies: arichardson, Mordante, philnik, ldionne, libcxx-commits, mikhail.ramalho
Differential Revision: https://reviews.llvm.org/D146294
Philip Reames [Wed, 17 May 2023 14:35:47 +0000 (07:35 -0700)]
[TLI] Add IsZero parameter to storeOfVectorConstantIsCheap [nfc]
Make the decision to consider zero constant stores cheap target specific. Will be used in an upcoming change for RISCV.
zijunzhao [Tue, 16 May 2023 22:49:48 +0000 (22:49 +0000)]
[libc++] Improve ranges::starts_with
Fix some nits in ranges::starts_with
Kazu Hirata [Wed, 17 May 2023 16:12:16 +0000 (09:12 -0700)]
[Inliner] Remove unused forward declarations (NFC)
Nikita Popov [Wed, 17 May 2023 16:05:01 +0000 (18:05 +0200)]
[InstCombine] Use canonical index type in more places
Also fixes an issue with
80cd3e4e2059f8deda735c32bf7dfa5b9d75c4e0
pointed out by Roman Divacky: For one of the occurrences I only
changed the name of the type variable, without actually changing
the type...
Lei Zhang [Wed, 17 May 2023 15:57:13 +0000 (08:57 -0700)]
[mlir][vector] Separate out vector transfer + tensor slice patterns
These patterns touches the structure generated from tiling so it
affects later steps like bufferization and vector hoisting.
Instead of putting them in canonicalization, this commit creates
separate entry points for them to be called explicitly.
This is NFC regarding the functionality and tests of those patterns.
It also addresses two TODO items in the codebase.
Reviewed By: ThomasRaoux
Differential Revision: https://reviews.llvm.org/D150702
Slava Zakharin [Wed, 17 May 2023 03:05:22 +0000 (20:05 -0700)]
[flang][hlfir] Fixed symbol lookup for character returns.
Symbols corresponding to entries returning character results
must be mapped to EmboxCharOp, first, before we can map them
to DeclareOp. The code may be reworked after HLFIR is enabled
by default, but right now it seems like an acceptable solution to me.
Differential Revision: https://reviews.llvm.org/D150749
LLVM GN Syncbot [Wed, 17 May 2023 15:51:46 +0000 (15:51 +0000)]
[gn build] Port
7f3047219cf5
Nikita Popov [Wed, 17 May 2023 15:36:05 +0000 (17:36 +0200)]
[InstCombine] Compute known bits for multi-use add/sub
We were failing to set the known bits for add/sub in the multi-use
case, resulting in odd behavioral differences depending on the
number of uses. Noticed while adding a consistency assertion.
The test changes are essentially a revert to the state before
d6498ab. These changes are not really desirable, but if we don't
want them, that needs to be handled as part of the heuristic for
demanded constant shrinking, not by artifically suppressing the
known bits in one specific case.
yronglin [Tue, 16 May 2023 17:40:03 +0000 (01:40 +0800)]
[libc++] Implement P2505R5(Monadic operations for std::expected).
Signed-off-by: yronglin <yronglin777@gmail.com>
Kazu Hirata [Wed, 17 May 2023 15:39:48 +0000 (08:39 -0700)]
[Analysis] Remove AliasAnalysisSummary.cpp
The last use was removed by:
commit
8005332835246c54a4a6b026eede930ed559deb4
Author: Nikita Popov <npopov@redhat.com>
Date: Fri Dec 9 11:57:50 2022 +0100
Differential Revision: https://reviews.llvm.org/D150748
Nikita Popov [Wed, 17 May 2023 15:12:32 +0000 (17:12 +0200)]
[InstCombine] Use KnownBits::urem() helper
This provides more precise results than the ad-hoc implementation.
Noticed while trying to add a consistency assertion.
To be honest I'm not sure why this code exists at all -- the
recursive calls are done with all bits demanded, so this should
be equivalent to just using the default case.
Alex Zinenko [Wed, 17 May 2023 14:01:08 +0000 (14:01 +0000)]
[mlir] don't hardcode PDL_Operation in Transform dialect extensions
Update operations in Transform dialect extensions defined in the Affine,
GPU, MemRef and Tensor dialects to use the more generic
`TransformHandleTypeInterface` type constraint instead of hardcoding
`PDL_Operation`. See
https://discourse.llvm.org/t/rfc-type-system-for-the-transform-dialect/65702
for motivation.
Remove the dependency on PDLDialect from these extensions.
Update tests to use `!transform.any_op` instead of `!pdl.operation`.
Reviewed By: nicolasvasilache
Differential Revision: https://reviews.llvm.org/D150781
Tobias Hieta [Wed, 17 May 2023 15:05:13 +0000 (17:05 +0200)]
[NFC][Py Reformat] Added more commits to .git-blame-ignore-revs
Nikita Popov [Wed, 17 May 2023 15:01:58 +0000 (17:01 +0200)]
[InstCombine] Use KnownBits::udiv() helper
This produces more precise results than the ad-hoc implementation.
Noticed while trying to add a consistency assertion.
Tobias Hieta [Wed, 17 May 2023 09:01:54 +0000 (11:01 +0200)]
[NFC][Py Reformat] Reformat lit.local.cfg python files in llvm
This is a follow-up to
b71edfaa4ec3c998aadb35255ce2f60bba2940b0
since I forgot the lit.local.cfg files in that one.
Reformatting is done with `black`.
If you end up having problems merging this commit because you
have made changes to a python file, the best way to handle that
is to run git checkout --ours <yourfile> and then reformat it
with black.
If you run into any problems, post to discourse about it and
we will try to help.
RFC Thread below:
https://discourse.llvm.org/t/rfc-document-and-standardize-python-code-style
Reviewed By: barannikov88, kwk
Differential Revision: https://reviews.llvm.org/D150762
Nico Weber [Wed, 17 May 2023 15:00:54 +0000 (11:00 -0400)]
Revert "[Lex] Warn when defining or undefining any builtin macro"
This reverts commit
22e3f587fd1ff97185014cb1ba723579ed2150d3.
Breaks check-clang on arm, see https://reviews.llvm.org/D144654#4349954
Also reverts follow-up "[AArch64] Don't redefine _LP64 and __LP64__"
This reverts commit
e55d52cd34fb7a6a6617639d147b9d0abaceeeab.
Nico Weber [Wed, 17 May 2023 14:46:45 +0000 (10:46 -0400)]
Revert "Reland "[CMake] Bumps minimum version to 3.20.0.""
This reverts commit
65429b9af6a2c99d340ab2dcddd41dab201f399c.
Broke several projects, see https://reviews.llvm.org/D144509#4347562 onwards.
Also reverts follow-up commit "[OpenMP] Compile assembly files as ASM, not C"
This reverts commit
4072c8aee4c89c4457f4f30d01dc9bb4dfa52559.
Also reverts fix attempt "[cmake] Set CMP0091 to fix Windows builds after the cmake_minimum_required bump"
This reverts commit
7d47dac5f828efd1d378ba44a97559114f00fb64.
Shengchen Kan [Wed, 17 May 2023 14:45:07 +0000 (22:45 +0800)]
[X86][MC] Move the code about MOVSX encoding optimization to X86EncodingOptimization.cpp, NFCI
Philip Reames [Wed, 17 May 2023 14:21:25 +0000 (07:21 -0700)]
[RISCV] Use scalar stores for splats of zero to memory up to XLen
The direct motivation here is to undo an unprofitable vectorization performed by SLP, but the transform seems generally useful as well. If we are storing a zero to memory, we can use a single scalar store (from X0) for all power of two sizes up to XLen.
Differential Revision: https://reviews.llvm.org/D150717
Martin Braenne [Wed, 17 May 2023 07:07:52 +0000 (07:07 +0000)]
[clang][dataflow] Remove unused parameter from `diagnoseUnwrapCall()`.
Reviewed By: sammccall
Differential Revision: https://reviews.llvm.org/D150756
John Brawn [Wed, 17 May 2023 13:25:50 +0000 (14:25 +0100)]
[AArch64] Don't redefine _LP64 and __LP64__
Don't define these macros in AArch64TargetInfo::getTargetDefines, as
they're already defined in InitializePredefinedMacros and the
redefinition causes unwanted warnings with -Wsystem-headers.
Shengchen Kan [Wed, 17 May 2023 14:08:48 +0000 (22:08 +0800)]
[X86][MC] Move the code about VPCMP encoding optimization to X86EncodingOptimization.cpp, NFCI
Nikita Popov [Wed, 17 May 2023 13:54:11 +0000 (15:54 +0200)]
[InstCombine] Use computeKnownBits() for srem SimplifyDemandedBits()
For the case of a non-constant operand, fall back to
computeKnownBits() rather than trying to reimplement logic.
Found while testing a consistency assertion for both functions.
Alexey Lapshin [Wed, 17 May 2023 13:21:15 +0000 (15:21 +0200)]
Addition to Fddf5bfd6e6e2fc5b94718a29e718b4f821a3b853
Fix test bot breakage from
bd0dd27bb5be0fbf60c1b2a4ce15188812388574
This addresses the issue found by: https://lab.llvm.org/buildbot/#/builders/93/builds/14929
Nikita Popov [Wed, 17 May 2023 13:34:31 +0000 (15:34 +0200)]
[InstCombine] Don't create bitcast when simplifying round-trip
The bitcast was not being added to the worklist. I could switch
this to use the IRBuilder instead, but this bitcast is not relevant
with opaque pointers anyway, so just drop it entirely.
Alex Bradbury [Wed, 17 May 2023 13:43:56 +0000 (14:43 +0100)]
[clang][test][RISCV] Precommit zhinx coverage in Float16-arith.c test
Now codegen support is present, we should set HasLeftHalfType=true if
zhinx is present. This adds test coverage prior to making that change.
Alexey Bataev [Wed, 17 May 2023 12:41:34 +0000 (05:41 -0700)]
[SLP]Fix crash for scalarized vectors.
Need to remove insertion of the nodes to the InVector in case of
scalarized vectors too to avoid compiler crashes.
Peter Klausler [Thu, 11 May 2023 21:28:58 +0000 (14:28 -0700)]
[flang] Catch (and fix) attempts to create an invalid source range for a Scope
When Scope::AddSourceRange() is called to extend the scope's source range to
include another snippet from a cooked character stream, add a check to ensure
that the new range is part of the same cooked character stream as the rest
of the scope.
And fix the bug that was causing such invalid source ranges to be created:
a submodule's Scope is a children of its parent's in the Scope tree, but
it may or may not be part of the same source file, and it is certainly
not enclosed in the parent's source range. So don't propagate Scope
source range expansion from a submodule to its parent.
Differential Revision: https://reviews.llvm.org/D150714
Nikita Popov [Wed, 17 May 2023 13:19:35 +0000 (15:19 +0200)]
[InstCombine] Create store using IRBuilder
This ensures it gets reprocessed in the same iteration. In
particular the alignment will be increased (which is quite
pointless, of course).
Jonas Hahnfeld [Wed, 17 May 2023 12:44:02 +0000 (14:44 +0200)]
[clang][modules] Add features for recent C++ versions
Add cplusplus20, cplusplus23, and cplusplus26 (but don't document
the latter, following the current policy).
Differential Revision: https://reviews.llvm.org/D150773
Dhruv Chawla [Wed, 17 May 2023 13:12:11 +0000 (15:12 +0200)]
[SelectionDAG] Handle NSW for ADD/SUB in computeKnownBits()
This patch is a continuation of D150110. It separates the cases for
ADD and SUB into their own cases so that computeForAddSub can be
directly called and the NSW flag passed. This allows better
optimization when the NSW flag is enabled, and allows fixing up the
TODO that was there previously in SimplifyDemandedBits.
Differential Revision: https://reviews.llvm.org/D150769
Nico Weber [Wed, 17 May 2023 13:13:28 +0000 (09:13 -0400)]
Nabeel Omer [Wed, 17 May 2023 13:12:16 +0000 (13:12 +0000)]
[llvm-debuginfo-analyzer] Include linkage names while evaluating `--select`
This patch allows mangled names to be passed to --select.
Differential Revision: https://reviews.llvm.org/D150190
Nico Weber [Wed, 17 May 2023 13:07:22 +0000 (09:07 -0400)]
[gn] port
ed90cf1873aa6 (RISCVTests)
Nico Weber [Wed, 17 May 2023 13:07:40 +0000 (09:07 -0400)]
Nikita Popov [Wed, 17 May 2023 13:04:42 +0000 (15:04 +0200)]
[InstCombine] Use IRBuilder in evaluateInDifferentElementOrder()
This ensures that the new instructions get reprocessed in the same
iteration.
This should be largely NFC, apart from worklist order effects and
naming changes, as seen in the test diff.
Thorsten Schütt [Wed, 17 May 2023 07:07:08 +0000 (09:07 +0200)]
[GlobalIsel][x86] Legalize G_CTPOP and G_CTLZ II
check plan: ninja check-llvm-codegen-x86
Reviewed By: arsenm
Differential Revision: https://reviews.llvm.org/D150755
Nikita Popov [Wed, 17 May 2023 12:31:21 +0000 (14:31 +0200)]
[InstCombine] Fix worklist management for multi-use demanded element fold
Add the old instruction to the worklist, so it can be DCEd in the
same iteration.
Benjamin Kramer [Wed, 17 May 2023 12:50:01 +0000 (14:50 +0200)]
Michael Buch [Wed, 17 May 2023 12:38:05 +0000 (13:38 +0100)]
[lldb][SymbolFileDWARF] Fix format specifier when logging FindDefinitionTypeForDWARFDeclContext
Before:
```
(arm64)
/Users/michaelbuch/Git/lldb-build-main-modules/module.cache/295JG6LDUQX5Z/Clang_AST-39AVV87GST1ON.pcm:
SymbolFileDWARF::FindDefinitionTypeForDWARFDeclContext(tag=%s, name='DW_TAG_class_type')
```
After:
```
(arm64)
/Users/michaelbuch/Git/lldb-build-main-modules/module.cache/295JG6LDUQX5Z/std-XGBT2D5Y2D6X.pcm:
SymbolFileDWARF::FindDefinitionTypeForDWARFDeclContext(tag=DW_TAG_class_type, name='reverse_iterator<std::__1::__wrap_iter<char *> >')
```
Nikita Popov [Wed, 17 May 2023 12:36:50 +0000 (14:36 +0200)]
[InstCombine] Use canonical type in insertelement (NFC)
We can directly create these with the correct type.
Mathieu Fehr [Wed, 8 Mar 2023 22:16:02 +0000 (23:16 +0100)]
[mlir][irdl] Add verification of IRDL ops
This patch adds verification on registered IRDL operations, types,
and attributes.
This is done through an interface implemented by operations from the
`irdl` dialect, which translate the operations into `Constraint`.
This interface is then use in the `registerDialect` function to
generate verifiers for the entire operation/type/attribute.
Depends on D145733
Reviewed By: Mogball
Differential Revision: https://reviews.llvm.org/D145734
Jean Perier [Wed, 17 May 2023 12:20:21 +0000 (14:20 +0200)]
[flang][hlfir] Implement the scheduling part of hlfir.forall codegen
The lowering of hlfir.forall to loops (and later hlfir.where) requires
doing a data dependency analysis to avoid creating temporary storage for
every control/mask/rhs/lhs expressions.
The added code implements a data dependency analysis for the hlfir
ordered assignment trees (it is not specific to Forall since these nodes
includes Where, user defined assignments, and assignment to vector
subscripted entities, but the added code is only plugged and tested
with hlfir.forall in this patch).
This data dependency analysis returns a "schedule", which is a list of
runs containing actions. Each runs will result in a single loop nest
evaluating all its action "at the same time" inside the loop body.
Actions may either evaluating an assignment, or saving some expression
evaluation (the value yielded inside the ordered assignment hlfir operations)
in a temporary storage before doing the assignment that requires this
expression value but may "conflict" with it.
A "conflict" is a read in an expression E to a variable that is, or may
be (analysis is conservative), written by an assignment that depends on
E.
The analysis is based on MLIR SideEffectInterface and fir AliasAnalysis
which makes it generic.
For now, the codegen that will apply the schedule and rewrite the
hlfir.forall into a set of loops is not implemented, but the scheduling
is tested on its own (from Fortran, because it allows testing many cases
in very readable fashions).
The current scheduling has limitations, for instance
"forall(i=1, 10) x(i)=2*x(i)" does not require saving the RHS values for
all "i" before doing the assignments since the RHS does not depend
on values computed during previous iterations. Any user call will also
trigger a conservative assumption that there is a conflict. Finally,
a lot of operations are missing memory effect interfaces (especially
in HLFIR). This patch adds a few so that it can be tested, but more
will be added in later patches.
Differential Revision: https://reviews.llvm.org/D150455
Luke Lau [Tue, 16 May 2023 12:10:54 +0000 (13:10 +0100)]
[SLP] Rename IsUniformStride to IsUnitStride. NFCI
IsUniformStride is only used when the stride is a unit-stride, i.e. in a
plain wide vector load. This tightens the condition and renames it to
isUnitStride. It removes the old unused getUniformStrided() variant, as
isUnitStride should now imply that the stride is known.
Reviewed By: vdmitrie, ABataev
Differential Revision: https://reviews.llvm.org/D150662
Dmitri Gribenko [Wed, 17 May 2023 12:18:08 +0000 (14:18 +0200)]
[bazel] Fix missing deps for layering check
Dependency was introduced by
https://github.com/llvm/llvm-project/commit/
2c874d2128e35bb38817f349cfdfe9eca7281c9d
Job Noorman [Wed, 17 May 2023 11:55:31 +0000 (13:55 +0200)]
[JITLink][RISCV] Disable some relaxation tests on no-asserts builds
Some tests used `-debug-only` which only exists on builds with asserts
enabled.
Stefan Gränitz [Wed, 17 May 2023 08:40:40 +0000 (10:40 +0200)]
[lldb][gnustep] Add minimal GNUstepObjCRuntime plugin for LanguageTypeObjC on non-Apple platforms
This is the next patch after D146058. We can now parse expressions to print instance variables from ObjC classes. Until now the expression parser would bail out with an error like this:
```
error: expression failed to parse:
error: Error [IRForTarget]: Couldn't find Objective-C indirect ivar symbol OBJC_IVAR_$_TestObj._int
```
Reviewed By: aprantl
Differential Revision: https://reviews.llvm.org/D146154
Shengchen Kan [Tue, 16 May 2023 14:30:21 +0000 (22:30 +0800)]
[X86] Remove patterns for shift/rotate with immediate 1 and optimize during MC lowering
It's first suggested by @craig.topper in D150068. I think there are at least three pros
1. This can reduce the patterns during ISEL, as a result, reducing the bytes in X86GenDAGISel.inc
2. The patterns for shift/rotate with immediate 1 look quite similar to shift/rotate with immediate 8. So this can be seen as eliminating "duplicate" code.
3. Delay the optimization from imm8 to imm1, so that the previous optimization passes do not need to handle the version of imm1
It improves fast isel code and makes X86DomainReassignment work for shifts by 1, but regressed global isel, though no one should care.
Reviewed By: craig.topper
Differential Revision: https://reviews.llvm.org/D150107
Krzysztof Parzyszek [Tue, 16 May 2023 15:16:52 +0000 (08:16 -0700)]
[Hexagon] Improve safety of aligned loads/stores in HVC
Generate a predicated variant of the last load/store in a group to
avoid accessing OOB memory. Disable vector alignment on HVX prior
to v62, since v62 does not have predicated vector loads.
Simon Pilgrim [Wed, 17 May 2023 11:31:03 +0000 (12:31 +0100)]
Fix MSVC "result of 32-bit shift implicitly converted to 64 bits" warning. NFC.
Tobias Gysi [Wed, 17 May 2023 11:25:24 +0000 (11:25 +0000)]
[mlir][llvm] Mark additional ops as pure.
The revision marks the overflow arithmetic intrinsics
and the freeze operation as pure. This change enables
inlining and possible other optimizations for these
operations.
Reviewed By: Dinistro
Differential Revision: https://reviews.llvm.org/D150679
Jay Foad [Wed, 17 May 2023 11:04:54 +0000 (12:04 +0100)]
[AMDGPU] Regenerate test checks after D149986
Nitin John Raj [Wed, 10 May 2023 00:46:43 +0000 (17:46 -0700)]
[RISCV][NFC] Remove LMUL from vmv.s.x and vmv.x.s scheduler classes
These instructions don't read or write register groups. We only pretend they do in intrinsics and pseudoinstructions.
Differential Revision: https://reviews.llvm.org/D150238
John Brawn [Mon, 23 Jan 2023 17:40:59 +0000 (17:40 +0000)]
[Lex] Warn when defining or undefining any builtin macro
Currently we warn when MI->isBuiltinMacro, but this is only true for
builtin macros that require processing when expanding. Checking
SourceMgr.isWrittenInBuiltinFile in addition to this will mean that
we catch all builtin macros, though we shouldn't warn on feature test
macros.
As part of doing this I've also moved the handling of undefining from
CheckMacroName to HandleUndefDirective, as it doesn't really make
sense to handle undefining in CheckMacroName but defining in
HandleDefineDirective. It would be nice to instead handle both in
CheckMacroName, but that isn't possible as the handling of defines
requires looking at what the name is being defined to.
Differential Revision: https://reviews.llvm.org/D144654
Zhongyunde [Wed, 17 May 2023 10:36:16 +0000 (18:36 +0800)]
[Instsimplfy] X == Y ? 0 : X ^ Y --> X ^ Y
Alive2: https://alive2.llvm.org/ce/z/cykffE
Fixes: https://github.com/llvm/llvm-project/issues/62753
Reviewed By: nikic
Differential Revision: https://reviews.llvm.org/D150750
Nikita Popov [Wed, 17 May 2023 10:20:21 +0000 (12:20 +0200)]
[ValueTracking] Fix i1 abs range (PR62760)
For i1 operations, we may end up returning an empty range instead
of a full one. Make sure to use the getNonEmpty constructor.
Fixes https://github.com/llvm/llvm-project/issues/62760.
Nikita Popov [Wed, 17 May 2023 10:17:16 +0000 (12:17 +0200)]
[InstSimplify] Add tests for PR62760 (NFC)
Tom Weaver [Wed, 17 May 2023 10:19:55 +0000 (11:19 +0100)]
Revert "[Driver][gcov] Derive .gcno .gcda file names from -o and -dumpdir"
This reverts commit
d515b8125364ef85fb100f1430b2174ed816cc18.
Caused buildbot failures:
https://lab.llvm.org/buildbot/#/builders/197/builds/5464
Please fix before recommitting.
Alex Bradbury [Wed, 17 May 2023 10:16:15 +0000 (11:16 +0100)]
[Support] Forward GenCrashDiag argument from report_fatal_error(Error, bool)
The boolean GenCrashDiag argument was previous just discarded, which
seems to be an oversight that existed when this overload was first
added.
Differential Revision: https://reviews.llvm.org/D150669
Chuanqi Xu [Wed, 17 May 2023 09:51:07 +0000 (17:51 +0800)]
[C++20] [Modules] Emit a warning if the we load the modules by implicit generated path
A step to address https://github.com/llvm/llvm-project/issues/62707.
It is not user friendly enough to drop the implicitly generated path
directly. Let's emit the warning first and drop it in the next version.
Job Noorman [Wed, 17 May 2023 09:43:38 +0000 (11:43 +0200)]
[RISCV][MC] Refine MCInstrAnalysis based on registers used
MCInstrAnalysis provides a number of methods to query properties of
instructions (e.g., isTerminator(), isCall(),...). The default
implementation of these methods forwards the query to MCInstrDesc which
returns information based on various RISCVInstrInfo*.td files.
Since the info in MCInstrDesc is based on opcodes only, it is often
quite inaccurate. For example, JAL/JALR are never recognized as
terminators or branches while they certainly can be. However,
MCInstrAnalysis has access to the full MCInst so can improve accuracy by
inspecting registers used by the instruction.
This patch refines the following MCInstrAnalysis methods:
- isTerminator: JAL/JALR with RD=X0;
- isCall: JAL/JALR with RD!=X0
- isReturn: JALR/C_JR with RD=X0, RS1 in {X1, X5}
- isBranch: JAL/JALR/C_JR with RD=X0, RS1 not in {X1, X5};
- isUnconditionalBranch: JAL/JALR/C_JR with RD=X0, RS1 not in {X1, X5};
- isIndirectBranch: JALR/C_JR with RD=X0, RS1 not in {X1, X5};
Note that the reason for this patch is to simplify the RISCV target in
BOLT. While it's possible to implement everything there, it seems more
logical to implement it directly in the RISCV backend as other tools
might also be able to benefit from it.
Reviewed By: craig.topper, MaskRay
Differential Revision: https://reviews.llvm.org/D146438
Job Noorman [Wed, 17 May 2023 09:27:06 +0000 (11:27 +0200)]
[RISCV] Allow LI with symbol difference as constant
This patch lets the assembler accept code like the following:
.Lbuf: ...
.set .Lbuf_len, . - .Lbuf
li a0, .Lbuf_len
It works by translating such instances of LI into an ADDI and inserting
the correct constant value via a new fixup.
Note that this means that the constant value is restricted to 12 bits
since we cannot insert new instructions during the relaxation stage.
Binutils seems to have the same restriction though.
This patch also fixes a small issue where the SMLoc of an LI wasn't
propagated when translated to ADDI. While this is technically unrelated
to the main functionality of this patch, it improves error messages
related to the new use of LI.
This patch does _not_ allow I-type instructions to take such symbolic
constants as well. While technically possible (and allowed by binutils),
it's probably better to implement this in another patch.
Fixes #57461
Reviewed By: asb
Differential Revision: https://reviews.llvm.org/D135960
Job Noorman [Wed, 17 May 2023 09:24:48 +0000 (11:24 +0200)]
[JITLink][RISCV] Implement linker relaxation
This patch is essentially an adaption of LLD's algorithm to JITLink.
Currently, only relaxing R_RISCV_CALL(_PLT) and R_RISCV_ALIGN is
implemented, other relocations can follow later.
From a high level, the algorithm works as follows. In the first phase
(relaxBlock), we iteratively try to relax all instructions that have a
R_RISCV_RELAX relocation:
- If, based on the current symbol values, an instruction sequence can be
relaxed (i.e., replaced by a shorter instruction), we record how many
bytes would be removed, the new instruction (Writes), and the new
relocation type (EdgeKinds).
- We keep track of the total number of bytes that got removed up to each
relocation in the RelocDeltas array. This is the cumulative sum of the
number of bytes removed for each relocation.
- Symbol values and sizes are updated based on the number of removed
bytes.
- If for any relocation, the current RelocDeltas value doesn't match the
one from the previous iteration, something changed and we need to run
another iteration as some symbols might now have different values.
In the second phase (finalizeBlockRelax), all code is moved based on
RelocDeltas, the relaxed instructions are rewritten using Writes, and
R_RISCV_ALIGN is handled (moving instructions to ensure alignment and
inserting the correct NOP-sequence if needed). Finally, edge kinds and
offsets are updated and all R_RISCV_RELAX and R_RISCV_ALIGN edges are
removed (they are not needed anymore for the fixup linking stage).
Linker relaxation is implemented as a pass and added to PreFixupPasses
in the default configuration on RISC-V.
Since linker relaxation removes instructions, the memory for blocks
should ideally be reallocated. However, I believe this is currently not
possible in JITLink. Therefore, relaxation directly modifies the memory
of blocks, reducing the number of instructions but not the size of
blocks. I'm not very familiar with JITLink's memory allocators so I
might be overlooking something here, though.
Note on testing: some of the tests rely on the debug output of
llvm-jitlink. The main reason for this is the verification of symbol
sizes (which may change due to relaxation). I don't believe this can be
done using jitlink-check checks alone.
Note that there is a slightly unrelated change that makes
Symbol::setOffset public to be able to update symbol offsets during
relaxation.
Reviewed By: lhames
Differential Revision: https://reviews.llvm.org/D149526
Job Noorman [Wed, 17 May 2023 09:23:43 +0000 (11:23 +0200)]
[JITLink] Add target features to LinkGraph
This patch adds SubtargetFeatures to LinkGraph. Similar to Triple, some
targets might use this information while linking.
One example, and the reason this patch was written, is linker relaxation
on RISC-V: different relaxations are possible depending on if the C
extension is enabled.
Note that the features are stored as `std::vector<std::string>` to prevent a
public dependency on MC. There is still a private dependency to be able to
convert SubtargetFeatures to a vector.
Reviewed By: lhames
Differential Revision: https://reviews.llvm.org/D149522
Martin Braenne [Wed, 17 May 2023 09:12:46 +0000 (09:12 +0000)]
[clang][dataflow] Add `Strict` versions of `Value` and `StorageLocation` accessors.
This is part of the gradual migration to strict handling of value categories, as described in the RFC at https://discourse.llvm.org/t/70086.
This patch migrates some representative calls of the newly deprecated accessors to the new `Strict` functions. Followup patches will migrate the remaining callers. (There are a large number of callers, with some subtlety involved in some of them, so it makes sense to split this up into multiple patches rather than migrating all callers in one go.)
The `Strict` accessors as implemented here have some differences in semantics compared to the semantics originally proposed in the RFC; specifically:
* `setStorageLocationStrict()`: The RFC proposes to create an intermediate
`ReferenceValue` that then refers to the `StorageLocation` for the glvalue.
It turns out though that, even today, most places in the code are not doing
this but are instead associating glvalues directly with their
`StorageLocation`. It therefore didn't seem to make sense to introduce new
`ReferenceValue`s where there were none previously, so I have chosen to
instead make `setStorageLocationStrict()` simply call through to
`setStorageLocation(const Expr &, StorageLocation &)` and merely add the
assertion that the expression must be a glvalue.
* `getStorageLocationStrict()`: The RFC proposes that this should assert that
the storage location for the glvalue expression is associated with an
intermediate `ReferenceValue`, but, as explained, this is often not true.
The current state is inconsistent: Sometimes the intermediate
`ReferenceValue` is there, sometimes it isn't. For this reason,
`getStorageLocationStrict()` skips past a `ReferenceValue` if it is there but
otherwise directly returns the storage location associated with the
expression. This behavior is equivalent to the existing behavior of
`SkipPast::Reference`.
* `setValueStrict()`: The RFC proposes that this should always create the same
`StorageLocation` for a given `Value`, but, in fact, the transfer functions
that exist today don't guarantee this; almost all transfer functions
unconditionally create a new `StorageLocation` when associating an expression
with a `Value`.
There appears to be one special case:
`TerminatorVisitor::extendFlowCondition()` checks whether the expression is
already associated with a `StorageLocation` and, if so, reuses the existing
`StorageLocation` instead of creating a new one.
For this reason, `setValueStrict()` implements this logic (preserve an
existing `StorageLocation`) but makes no attempt to always associate the same
`StorageLocation` with a given `Value`, as nothing in the framework appers to
require this.
As `TerminatorVisitor::extendFlowCondition()` is an interesting special case,
the `setValue()` call there is among the ones that this patch migrates to
`setValueStrict()`.
Reviewed By: sammccall, ymandel, xazax.hun
Differential Revision: https://reviews.llvm.org/D150653
Guillaume Chatelet [Wed, 17 May 2023 09:15:10 +0000 (09:15 +0000)]
[bazel] Fix missing dependencies for OpenMP
Differential Revision: https://reviews.llvm.org/D150764
Alexey Lapshin [Wed, 17 May 2023 08:27:56 +0000 (10:27 +0200)]
Fix test bot breakage from
bd0dd27bb5be0fbf60c1b2a4ce15188812388574
This addresses the issue found by: https://lab.llvm.org/buildbot/#/builders/93/builds/14929
Tobias Hieta [Wed, 17 May 2023 08:49:50 +0000 (10:49 +0200)]
[NFC] Update .git-blame-ignore-revs with python reformatting
Tobias Hieta [Mon, 15 May 2023 09:02:42 +0000 (11:02 +0200)]
[NFC][Py Reformat] Reformat python files in llvm
This is the first commit in a series that will reformat
all the python files in the LLVM repository.
Reformatting is done with `black`.
See more information here:
https://discourse.llvm.org/t/rfc-document-and-standardize-python-code-style
Reviewed By: jhenderson, JDevlieghere, MatzeB
Differential Revision: https://reviews.llvm.org/D150545
David Sherwood [Thu, 20 Apr 2023 12:34:55 +0000 (12:34 +0000)]
[AArch64][NFC] Refactor the tail-folding option
This patch does simple refactoring of the tail-folding
option in preparation for enabling tail-folding by
default for neoverse-v1. It adds a default tail-folding
option field to the AArch64Subtarget class that can
be set on a per-CPU.
Differential Revision: https://reviews.llvm.org/D149659
Stefan Gränitz [Tue, 16 May 2023 13:22:49 +0000 (15:22 +0200)]
[lldb][gnustep] Add basic test and infrastructure for GNUstep ObjC runtime
This patch adds test infrastructure to utilize the GNUstep runtime in the LLDB test suite and adds coverage for features that already work on Linux. These seem accidental in parts, but it's a good early baseline. On Windows nothing works yet. Please find the repository for the GNUstep ObjC runtime here: https://github.com/gnustep/libobjc2
GNUstep support is disabled by default. CMake configuration involves two variables:
* `LLDB_TEST_OBJC_GNUSTEP=On` enables GNUstep support in the test suite. It requires the libobjc2 shared library and headers to be found.
* `LLDB_TEST_OBJC_GNUSTEP=Off` disables GNUstep support in the test suite and resets associated cache values if necessary (default).
* `LLDB_TEST_OBJC_GNUSTEP_DIR` allows to pass a custom installation root.
Differential Revision: https://reviews.llvm.org/D146058
Dmitry Vyukov [Wed, 17 May 2023 08:23:41 +0000 (10:23 +0200)]
tsan: fix string comparison in Go build script
Some bots failed with:
buildgo.sh: 173: [: linux: unexpected operator
Unknown platform
https://lab.llvm.org/buildbot/#/builders/247/builds/4603
Reviewed By: dyung
Differential Revision: https://reviews.llvm.org/D150760
Jonas Hahnfeld [Wed, 17 May 2023 08:28:58 +0000 (10:28 +0200)]
[cmake] Correct option to LLVM_FORCE_USE_OLD_TOOLCHAIN
This option was renamed a long time ago in commit
388cefa78d.
Dmitri Gribenko [Thu, 27 Apr 2023 16:08:38 +0000 (18:08 +0200)]
[ClangTidy] Fix markup in comments
Timm Bäder [Wed, 17 May 2023 08:26:50 +0000 (10:26 +0200)]
[clang][Interp][NFC] Move dyn_cast check into if condition
M is not used anywhere else.
varconst [Wed, 17 May 2023 07:48:24 +0000 (00:48 -0700)]
[libc++][ranges] Implement the changes to `deque` from P1206 (`ranges::to`):
- add the `from_range_t` constructors and the related deduction guides;
- add the `insert_range`/`assign_range`/etc. member functions.
(Note: this patch is split from https://reviews.llvm.org/D142335)
Differential Revision: https://reviews.llvm.org/D149827
Fangrui Song [Wed, 17 May 2023 07:43:00 +0000 (00:43 -0700)]
[Driver][gcov] Derive .gcno .gcda file names from -o and -dumpdir
Resolve a FIXME.
When -ftest-profile, -fprofile-arcs, or --coverage is specified and the
driver performs both compilation and linking phases, derive the .gcno &
.gcda file names from -o and -dumpdir.
`clang --coverage d/a.c d/b.c -o e/x && e/x` will now emit
`e/x-[ab].gc{no,da}` like GCC.
For -fprofile-dir=, we make the deliberate decision to not mangle the
input filename if relative.
The following script demonstrates the .gcno and .gcda filenames.
```
PATH=/tmp/Rel/bin:$PATH # adapt according to your build directory
mkdir -p d e f
echo 'int main() {}' > d/a.c
echo > d/b.c
a() { rm $@ || exit 1; }
clang --coverage d/a.c d/b.c && ./a.out
a a-[ab].gc{no,da}
clang --coverage d/a.c d/b.c -o e/x && e/x
a e/x-[ab].gc{no,da}
clang --coverage d/a.c d/b.c -o e/x -dumpdir f/ && e/x
a f/[ab].gc{no,da}
clang --coverage -fprofile-dir=f d/a.c d/b.c -o e/x && e/x
a e/x-[ab].gcno f/e/x-[ab].gcda
clang -c --coverage d/a.c d/b.c && clang --coverage a.o b.o && ./a.out
a [ab].gc{no,da}
clang -c --coverage -fprofile-dir=f d/a.c d/b.c && clang --coverage a.o b.o && ./a.out
a [ab].gcno f/[ab].gcda
clang -c --coverage d/a.c -o e/xa.o && clang --coverage e/xa.o && ./a.out
a e/xa.gc{no,da}
clang -c --coverage d/a.c -o e/xa.o -dumpdir f/g && clang --coverage e/xa.o && ./a.out
a f/ga.gc{no,da}
```
The gcov code accidentally claims -c and -S, so -fsyntax-only -c/-S and
-E -c/-S don't leave to a -Wunused-command-line-argument warning. Keep
the unintended code for now.
Guozhi Wei [Wed, 17 May 2023 07:38:22 +0000 (07:38 +0000)]
Revert "[GVN] Improve PRE on load instructions"
This reverts commit
d6811826371d82de074d0c3e10040114eee69897.
It caused sanitized bootstrap failure.
Balázs Kéri [Wed, 17 May 2023 06:50:23 +0000 (08:50 +0200)]
[clang][analyzer] Display buffer sizes in StdCLibraryFunctionArgs checker
If a wrong (too small) buffer argument is found, the dynamic buffer size and
values of connected arguments are displayed in the warning message, if
these are simple known integer values.
Reviewed By: Szelethus
Differential Revision: https://reviews.llvm.org/D149321
Dmitry Vyukov [Tue, 16 May 2023 09:10:29 +0000 (11:10 +0200)]
tsan: allow to cross-build Go runtime
Allow user to provide target GOOS/GOARCH.
If not provided, use the host GOOS/GOARCH as we do now.
This allows to cross-compile the runtime.
Also provide SKIP_TEST knob for cross-compilation
since the test will most likely not run on host.
Reviewed By: vitalybuka
Differential Revision: https://reviews.llvm.org/D150650
Carl Ritson [Wed, 17 May 2023 06:55:22 +0000 (15:55 +0900)]
[AMDGPU] Add missing whitespace in SIInstrInfo header (NFC)
Carl Ritson [Wed, 17 May 2023 06:52:13 +0000 (15:52 +0900)]
[AMDGPU][UniformityAnalysis] Fix typos in test comment (NFC)