Amanda Tang [Tue, 18 Jul 2023 20:34:08 +0000 (20:34 +0000)]
[ODS] Quick fix
Quick fix for a failing test in https://reviews.llvm.org/rG5267ed05bc4612e91409d63b4dbc4e01751acb75
Reviewed By: jpienaar
Differential Revision: https://reviews.llvm.org/D155637
Fangrui Song [Tue, 18 Jul 2023 20:36:11 +0000 (13:36 -0700)]
[Support] Add llvm::xxh3_64bits
ld.lld SHF_MERGE|SHF_STRINGS duplicate elimination is computation heavy
and utilitizes llvm::xxHash64, a simplified version of XXH64.
Externally many sources confirm that a new variant XXH3 is much faster.
I have picked a few hash implementations and computed the
proportion of time spent on hashing in the overall link time (a debug
build of clang 16 on a machine using AMD Zen 2 architecture):
* llvm::xxHash64: 3.63%
* official XXH64 (`#define XXH_VECTOR XXH_SCALAR`): 3.53%
* official XXH3_64bits (`#define XXH_VECTOR XXH_SCALAR`): 1.21%
* official XXH3_64bits (default, essentially `XXH_SSE2`): 1.22%
* this patch llvm::xxh3_64bits: 1.19%
The remaining part of lld remains unchanged. Consequently, a lower ratio
indicates that hashing is faster. Therefore, it is evident that XXH3 from xxhash
is significantly faster than both the official version and our llvm::xxHash64.
(
string length: count
1-3: 393434
4-8: 2084056
9-16: 2846249
17-128: 5598928
129-240: 1317989
241-: 328058
)
This patch adds heavily simplified https://github.com/Cyan4973/xxHash,
taking account of many simplification ideas from Devin Hussey's xxhash-clean.
Important x86-64 optimization ideas:
* Make XXH3_len_129to240_64b and XXH3_hashLong_64b noinline
* Unroll XXH3_len_17to128_64b
* __restrict does not affect Clang code generation
Beside SHF_MERGE|SHF_STRINGS duplicate elimination, llvm/ADT/StringMap.h
StringMapImpl::LookupBucketFor and a few places in lld can potentially be
accelerated by switching to llvm::xxh3_64bits.
Link: https://github.com/llvm/llvm-project/issues/63750
Reviewed By: serge-sans-paille
Differential Revision: https://reviews.llvm.org/D154812
Sedenion [Tue, 18 Jul 2023 20:23:45 +0000 (13:23 -0700)]
[clang-format] Refactoring and asserts in LevelIndentTracker. (NFC)
adjustToUnmodifiedLine: The code does something only for non-PP-directives.
This is now reflected by putting the if-check to the top. This also ensures
that the assert() there is executed only if IndentForLevel is actually
accessed.
getIndent(): assert valid index into IndentForLevel.
Added explanation regarding the intention of IndentForLevel.
Differential Revision: https://reviews.llvm.org/D155094
Alexey Bataev [Mon, 17 Jul 2023 16:47:01 +0000 (09:47 -0700)]
[SLP][NFC]Improve compile-time by using map {TreeEntry *, Instruction *}
in getLastInstructionInBundle(), NFC.
Instead of building EntryToLastInstruction before the vectorization,
build it automatically during the calls to getLastInstructionInBundle()
function.
Mark de Wever [Tue, 18 Jul 2023 20:21:10 +0000 (22:21 +0200)]
[libc++][test] Fixes transitives includes.
Andrew Gozillon [Tue, 18 Jul 2023 20:08:58 +0000 (15:08 -0500)]
[Flang][OpenMP] Disable function filtering for host
This should be a temporary fix while we work
towards enabling function filtering for host
again via a future patch.
Mikhail Goncharov [Tue, 18 Jul 2023 20:05:14 +0000 (22:05 +0200)]
[bazel] fix layering check to run bazel with 16.x
Preparation to update bazel builder to use LLVM 16 release
where layering check was enabled https://reviews.llvm.org/D132779
Current setup missed some backsliding in layering check as it has
only on for projects with the check enforced.
Disabled it completely for libc and fixed for DWARFLinkerParallel.
It would be great to re-enable it for libc later.
Craig Topper [Tue, 18 Jul 2023 19:55:26 +0000 (12:55 -0700)]
[RISCV] Remove unnecessary _32 and _64 suffixes from some scalar crypto builtins.
The names of these builtins aren't ambiguous so they don't need the suffix.
Mark de Wever [Tue, 18 Jul 2023 19:49:26 +0000 (21:49 +0200)]
[libc++][print] Fixes tests.
The exception message improvements for `<format>` were not applied to
print. The issue has been reported by Ian Anderson.
River Riddle [Tue, 18 Jul 2023 08:34:57 +0000 (01:34 -0700)]
[mlir-lsp] Add client information to the InitializationParams
This is specified in the spec, but we just never really needed it. This
allows for users of the LSP libraries to inspect information about the
client that is connected to the server.
Differential Revision: https://reviews.llvm.org/D155566
Philip Reames [Tue, 18 Jul 2023 19:22:08 +0000 (12:22 -0700)]
[RISCV] Minor style cleanups in post ISEL combines
Mark de Wever [Mon, 10 Jul 2023 05:59:58 +0000 (07:59 +0200)]
[libc++][format] Fixes times before epoch.
The number of days should be rounded down, for both positive and
negative times since epoch. The original code truncated, which is
correct for positive values, but wrong for negative values.
Depends on D138826
Reviewed By: #libc, ldionne
Differential Revision: https://reviews.llvm.org/D154865
Tulio Magno Quites Machado Filho [Tue, 18 Jul 2023 19:09:50 +0000 (16:09 -0300)]
[clang] scan-view: Remove unused python import
Python's module imp is not being used and is not available on Python
3.12 anymore.
Reviewed By: tbaeder
Differential Revision: https://reviews.llvm.org/D155192
Mark de Wever [Sun, 4 Jun 2023 19:32:10 +0000 (21:32 +0200)]
[libc++][format] Improves diagnostics.
Improves both the compile-time and run-time errors.
At compile-time it does a bit more work to get more specific errors.
This could be done at run-time too, but that has a performance penalty.
Since it's expected most use-cases use format* instead of vformat* the
compile-time errors are more common.
For example when using
std::format_to("{:-c}", 42);
Before compile output would contain
std::__throw_format_error("The format-spec should consume the input or end with a '}'");
Now it contains
std::__throw_format_error("The format specifier does not allow the sign option");
Given a better indication the sign option is not allowed. Note the
output is still not user-friendly; C++ doesn't have good facilities to
generate nice messages from the library.
In general all messages have been reviewed and improved, using a more
consistent style and using less terms used in the standard. For example
format-spec -> format specifier
arg-id -> argument index
Reviewed By: #libc, ldionne
Differential Revision: https://reviews.llvm.org/D152624
Craig Topper [Tue, 18 Jul 2023 18:15:44 +0000 (11:15 -0700)]
[RISCV] Remove 'Z' from Zbb builtin type strings. NFC
'Z' means uint32_t, but 'i' is always 32 bits for RISC-V so
we don't need this.
Kirill Stoimenov [Fri, 14 Jul 2023 20:07:29 +0000 (20:07 +0000)]
[HWASAN][LSAN] Fix false positive memory leak reports on X86_64
Before this patch when running HWASAN on x86_64 with with memory tagging support we got a bunch of false memory leak reports. The reason for that is that the heuristic used to detect if an 8 bytes could be a user pointer was not valid when memory tagging is used as the top byte could contain non-zero information.
Reviewed By: vitalybuka
Differential Revision: https://reviews.llvm.org/D155338
Mark de Wever [Sun, 4 Jun 2023 19:32:10 +0000 (21:32 +0200)]
[libc++][format] Improves run-time diagnostics.
After parsing a std-format-spec it's validated, depending on the type used some
format options are not allowed. This improves the error messages in the
exceptions thrown upon failure.
Depends on D155364
Reviewed By: #libc, ldionne
Differential Revision: https://reviews.llvm.org/D155366
Philip Reames [Tue, 18 Jul 2023 16:46:15 +0000 (09:46 -0700)]
[RISCV][CostModel] Model vrgather.vv as being quadradic in LMUL
vrgather.vv across multiple vector registers (i.e. LMUL > 1) requires all to all data movement. This includes two conceptual sets of changes:
For permutes, we were modeling these as being linear in LMUL.
For reverse, we were modeling them as being fixed cost in LMUL.
Both were wrong, and have been adjusted to O(LMUL^2). Noticed via code inspection while looking at something else.
Its worth asking whether we should be lowering reverse to something other than a vrgather at high LMULs. That shuffle is quite expensive. (Future work)
Differential Revision: https://reviews.llvm.org/D152019
Joseph Huber [Tue, 18 Jul 2023 15:27:54 +0000 (10:27 -0500)]
[Clang] Only emit CUDA version warnings when creating the CUDA toolchain
This warning primarily applies to users of the CUDA langues as there may
be new features we rely on. The other two users of the toolchain are
OpenMP via `-fopenmp --offload-arch=sm_70` and a cross-compiled build
via `--target=nvptx64-nvida-cuda -march=sm_70`. Both of these do not
rely directly on things that would change significantly between CUDA
versions, and the way they are built can sometims make this warning
print many times.
This patch changees the behaiour to only check for the version when
building for CUDA offloading specifically, the other two will not have
this check.
Reviewed By: tra
Differential Revision: https://reviews.llvm.org/D155606
Mark de Wever [Sun, 4 Jun 2023 19:32:10 +0000 (21:32 +0200)]
[libc++][format] Improves compile-time diagnostics.
Then a std-format-spec option is invalid for a type the compile-time
validation will detect its usage and issue a diagnostic. Before it
validated after parsing the entire std-format-spec, which meant the
diagnostic was less precise. It would be possible to do this validation
run-time but that has a performance overhead. When using the format
family of functions, this would be unneeded overhead; the validation was
done at run-time. For the vformat family it would give better
diagnostics.
To avoid paying what you don't use, it has been decided to aim for the
better performance. It's more likely users will use the format family of
functions.
Depends on D155264
Reviewed By: #libc, ldionne
Differential Revision: https://reviews.llvm.org/D155364
Razvan Lupusoru [Tue, 18 Jul 2023 15:18:36 +0000 (08:18 -0700)]
[flang][openacc] Update data clause attribute in tests
Update Fortran OpenACC tests to use the updated data clause
attribute format for better readability.
Depends on D155605
Reviewed By: clementval
Differential Revision: https://reviews.llvm.org/D155603
Razvan Lupusoru [Tue, 18 Jul 2023 15:13:39 +0000 (08:13 -0700)]
[openacc] Update data clause attribute definition
Instead of using the I64EnumAttr for the DataClause, now use
EnumAttr instead. This makes tests more readable since now
one can use the format #acc<data_clause acc_copyin> instead of
just the number.
Reviewed By: clementval, vzakhari
Differential Revision: https://reviews.llvm.org/D155605
Mark de Wever [Sun, 4 Jun 2023 19:32:10 +0000 (21:32 +0200)]
[NFC][libc++][format] Generalizes bracket parsing.
Both the tuple formatter and range formatter parse a bracket. Instead of
implementing this twice do it in the generic parser. This is preparation
to improve the diagnostics in the format library.
Reviewed By: #libc, ldionne
Differential Revision: https://reviews.llvm.org/D155264
Han Shen [Tue, 18 Jul 2023 17:30:06 +0000 (10:30 -0700)]
[CodeGen] Separate MachineFunctionSplitter logic for different profile types.
In D152577 @xur has a post-submit comment regarding to an awkward usage
of MFS for Autofdo - instead of just using -fsplit-machine-function, the
user needs to add "-mllvm -mfs-psi-cutoff=0" to choose the right logic
for AutoFDO. The compiler should choose the right default values for
such case.
This CL separate MFS logic for different profile types.
Reviewed By: xur, wenlei
Differential Revision: https://reviews.llvm.org/D155253
Mark de Wever [Fri, 21 Apr 2023 06:09:06 +0000 (08:09 +0200)]
[libc++][print] Adds FILE functions.
Drive-by fix to make sure the __retarget_buffer works correctly whan
using a hint of 1. This was discovered in one of the new tests.
Drive-by fixes __retarget_buffer when initialized with size 1.
Implements parts of
- P2093R14 Formatted output
- P2539R4 Should the output of std::print to a terminal be
synchronized with the underlying stream?
Reviewed By: #libc, ldionne
Differential Revision: https://reviews.llvm.org/D150044
Louis Dionne [Tue, 11 Jul 2023 22:40:14 +0000 (18:40 -0400)]
[libc++] Encode the version in the ReleaseNotes file
This way, we don't need to remove the contents of the ReleaseNotes file
after the branch. This should make it much easier and natural to cherry-pick
changes onto the release branch. Typically, we need two patches for those.
First, we need the code changes against `main`, and then we need a patch
that updates the release notes on the just-created branch.
By versioning the release notes, it becomes easy to author a change
against `main` that targets a just-branched LLVM release by simply
adding it to the release notes for the right version. This has been
a pain point in previous releases.
Differential Revision: https://reviews.llvm.org/D155024
Jack Wolfard [Sat, 15 Jul 2023 09:44:42 +0000 (02:44 -0700)]
[mlir][python] Add install target for MLIR Python sources.
Differential Revision: https://reviews.llvm.org/D155362
pateldeev [Tue, 18 Jul 2023 15:48:53 +0000 (17:48 +0200)]
[libc++][LWG 2996] Implement c++20 shared_ptr rvalue overloads.
Implement c++20 `shared_ptr` rvalue overloads for aliasing constructor and pointer casts. See https://cplusplus.github.io/LWG/issue2996
Commit from
"patedeev" <dkp10000@gmail.com>
Reviewed By: philnik, #libc, ldionne, pateldeev
Differential Revision: https://reviews.llvm.org/D135548
varconst [Tue, 11 Jul 2023 00:16:56 +0000 (17:16 -0700)]
[libc++][ranges] Implement the changes to node-based containers 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/D149830
Amanda Tang [Wed, 12 Jul 2023 20:13:25 +0000 (20:13 +0000)]
[ODS] Use Adaptor Traits for Type Inference
Author inferReturnTypes methods with the Op Adaptor by using the InferTypeOpAdaptor.
Reviewed By: jpienaar
Differential Revision: https://reviews.llvm.org/D155115
David Green [Tue, 18 Jul 2023 17:52:19 +0000 (18:52 +0100)]
[AArch64][GISel] Additional FPTrunc vector lowering
I was attempting to add llvm.reduce.fminimum/fmaximum support for GlobalISel.
In the process I noticed that llvm.reduce.fmin/fmax was missing, and could do
with being added first. That led on to adding additional vector support for
minnum/maxnum, which in turn led to needing to handle fptrunc and fpext for
some of the fp16 types. So this patch extends the vector handling for fptrunc,
adding support for f16 types which are clamped to 4 elements, and scalarizing
the rest.
I went round in circles a little with how smaller than legal vectors should be
handled, but this seems simple and seems to work, if not always optimally yet.
Differential Revision: https://reviews.llvm.org/D155311
Aiden Grossman [Sat, 1 Jul 2023 00:05:37 +0000 (17:05 -0700)]
[llvm-exegesis] Support older kernel versions in subprocess executor
This patch switches from moving the performance counter file descriptor
to the child process to socket calls rather than using the pidfd_getfd
system call which was introduced in kernel 5.6. This significantly
expands the range of kernel versions that are supported.
Reviewed By: courbet
Differential Revision: https://reviews.llvm.org/D154275
Craig Topper [Tue, 18 Jul 2023 17:39:25 +0000 (10:39 -0700)]
[RISCV] Improve type promotion for i32 clmulr/clmulh on RV64.
Instead of zero extending the inputs by masking. We can shift them
left instead. This is cheaper when we don't zext.w instruction.
This does make the case where the inputs are already zero extended
or freely zero extendable worse though.
Reviewed By: wangpc
Differential Revision: https://reviews.llvm.org/D155530
Simon Pilgrim [Tue, 18 Jul 2023 17:12:02 +0000 (18:12 +0100)]
[DAG] SimplifyDemandedBits - attempt to use SimplifyMultipleUseDemandedBits for bitcasts from larger element types
Attempt to avoid multi-use ops if the bitcast doesn't need anything from them.
Peter Klausler [Mon, 17 Jul 2023 20:10:36 +0000 (13:10 -0700)]
[flang][unittests] Fix recent snprintf() changes to use correct buffer lengths
A recent patch replaced two sprintf() calls with snprintf(), but didn't
use the right length for the remaining space in the buffer.
Differential Revision: https://reviews.llvm.org/D155224
Aiden Grossman [Mon, 19 Jun 2023 09:03:12 +0000 (09:03 +0000)]
[Docs][llvm-exegesis] Add documentation for memory annotations
Reviewed By: gchatelet
Differential Revision: https://reviews.llvm.org/D151039
Haojian Wu [Tue, 18 Jul 2023 17:19:03 +0000 (19:19 +0200)]
Craig Topper [Tue, 18 Jul 2023 17:05:11 +0000 (10:05 -0700)]
[RISCV] Use RISCVISD::CZERO_EQZ/CZERO_NEZ for XVentanaCondOps.
This makes Zicond and XVentanaCondOps use the same code path.
The instructions have identical semantics.
Reviewed By: wangpc
Differential Revision: https://reviews.llvm.org/D155391
Quentin Colombet [Mon, 3 Jul 2023 16:20:32 +0000 (18:20 +0200)]
[mlir][Linalg] Add an interface to decompose complex ops
This patch adds an interface, named AggregatedOpInterface, that decomposes
complex operations into simpler ones.
For now, make the interface specific to Linalg because although the concept
is general, the way to materialize it needs some maturing.
Use that interface with the softmax operator.
Differential Revision: https://reviews.llvm.org/D154363
Craig Topper [Tue, 18 Jul 2023 16:50:30 +0000 (09:50 -0700)]
[RISCV][AArch64][IRGen] Add a special case to CodeGenFunction::EmitCall for scalable vector return being coerced to fixed vector.
Before falling back to CreateCoercedStore, detect a scalable vector
return being coerced to fixed vector. Handle it using a vector.extract
intrinsic without going through memory.
Reviewed By: c-rhodes
Differential Revision: https://reviews.llvm.org/D155495
eopXD [Tue, 18 Jul 2023 07:08:39 +0000 (00:08 -0700)]
[RISCV] Add test coverage for peephole vmerge optimization of unmasked rvv instruction with a rounding mode (NFC)
No functional change intended.
Reviewed By: fakepaper56
Differential Revision: https://reviews.llvm.org/D155550
eopXD [Mon, 17 Jul 2023 18:29:12 +0000 (11:29 -0700)]
[RISCV] Do not use FPR registers for fastcc if zfh/f/d is not specified in the architecture
Resolves #63917.
Also lets the compiler check for available GPR before hitting the stack.
Reviewed By: asb
Differential Revision: https://reviews.llvm.org/D155502
Arthur Eubanks [Tue, 18 Jul 2023 16:53:18 +0000 (09:53 -0700)]
[gn build] Manually port
2c651184
Craig Topper [Tue, 18 Jul 2023 16:34:25 +0000 (09:34 -0700)]
[RISCV] Add isMoveReg to vmv1r/vmv2r/vmv4r/vmv8r.v.
This allows TII isCopyInstrImpl to consider them copies.
Reviewed By: wangpc
Differential Revision: https://reviews.llvm.org/D155140
Craig Topper [Tue, 18 Jul 2023 16:34:15 +0000 (09:34 -0700)]
[RISCV] Test for D155140. NFC
The vmv1r.v v8, v9 in the last block can be removed by late
copy propagation.
Reviewed By: wangpc
Differential Revision: https://reviews.llvm.org/D155527
Alan Zhao [Mon, 17 Jul 2023 22:27:32 +0000 (15:27 -0700)]
[clang] Fix a crash when casting to an array type
In C++20, if Clang fails to perform constructor overload on a
RecordType, then Clang will try to perform parentesized aggregate
initialization. If that fails and the initialization was attempted as
part of a cast, then we should get the diagnostics from the failed
constructor overload attempt. However, we don't attempt constructor
overloading for arrays, so previously, if we try to diagnose an
overloaded cast for a parenthesized aggregate initialization of an
array, we crash. To fix this, we now exit tryDiagnoseOverloadedCast(...)
for failed parentesized list initialization if the destination type is
an array.
Fixes #63758
Reviewed By: aaron.ballman
Differential Revision: https://reviews.llvm.org/D155523
Zhuojia Shen [Fri, 23 Jun 2023 19:49:05 +0000 (12:49 -0700)]
[AArch64] Merge LDRSWpre-LD[U]RSW pair into LDPSWpre
This patch optimizes a pair of LDRSWpre and LDRSWui (or LDURSWi)
instructions into a single LDPSWpre instruction. This is a missing case
in D99272.
MIR test cases in D152564 are updated to verify the optimization.
Differential Revision: https://reviews.llvm.org/D152407
Zhuojia Shen [Fri, 23 Jun 2023 19:44:42 +0000 (12:44 -0700)]
[AArch64] Add tests for merging LDRSWpre-LDR pairs
This patch adds MIR test cases that test merging an LDRSWpre-LDR
instruction pair into an LDPSWpre instruction. This optimization is
currently missing and will be added a subsequent patch (D152407), so all
test cases are no merge for now.
Differential Revision: https://reviews.llvm.org/D152564
Alexander Batashev [Tue, 18 Jul 2023 16:43:36 +0000 (19:43 +0300)]
[NFC] Fix builds on recent GCC with C++20 enabled
The following pattern fails on recent GCC versions with -std=c++20 flag passed
and succeeds with -std=c++17. Such behavior is not observed on Clang 16.0.
```c++
template <typename T>
struct Foo {
Foo<T>(int a) {}
};
```
This patch removes template parameter from constructor in two occurences to
make the following command complete successfully:
bazel build -c fastbuild --cxxopt=-std=c++20 --host_cxxopt=-std=c++20 @llvm-project//llvm/...
Reviewed By: arsenm
Differential Revision: https://reviews.llvm.org/D154782
Joseph Huber [Tue, 18 Jul 2023 16:41:24 +0000 (11:41 -0500)]
[Clangd] Fix ambiguous use of 'Range'
Summary:
The changes in D155173 caused build failures on some configruations due
to the use of `Range` which conflicts with other definitions. Explicitly
use `clangd::Range`.
Joseph Huber [Tue, 18 Jul 2023 15:22:01 +0000 (10:22 -0500)]
[libc] Treat the locks array as a bitfield
Currently we keep an internal buffer of device memory that is used to
indicate ownership of a port. Since we only use this as a single bit we
can simply turn this into a bitfield. I did this manually rather than
having a separate type as we need very special handling of the masks
used to interact with the locks.
Reviewed By: JonChesterfield
Differential Revision: https://reviews.llvm.org/D155511
Simon Pilgrim [Tue, 18 Jul 2023 15:49:54 +0000 (16:49 +0100)]
[DAG] More aggressively (extract_vector_elt (build_vector x, y), c) iff element is zero constant
We currently don't extract vector elements from multi-use build vectors unless TLI.aggressivelyPreferBuildVectorSources accepts them, which seems a little extreme for constant build vectors (especially as under some cases ComputeKnownBits will indirectly extract the data for us).
This is causing a few regressions in some upcoming SimplifyDemandedBits work I'm looking at, all of which just need to know that the element is zero, so I've tweaked the fold to accept zero elements as well, which will typically fold very easily.
Differential Revision: https://reviews.llvm.org/D155582
Simon Pilgrim [Tue, 18 Jul 2023 11:41:09 +0000 (12:41 +0100)]
[Sparc] Regenerate float-constants.ll test checks
Rahul Kayaith [Wed, 5 Jul 2023 02:21:26 +0000 (22:21 -0400)]
[mlir][python] Remove PythonAttr mapping functionality
This functionality has been replaced by TypeCasters (see D151840)
depends on D154468
Reviewed By: ftynse
Differential Revision: https://reviews.llvm.org/D154469
Dinar Temirbulatov [Tue, 18 Jul 2023 15:57:16 +0000 (15:57 +0000)]
[AArch64] Regenerate a couple of vector-shuffle tests. NFC
As a request in https://reviews.llvm.org/D152205
Joseph Huber [Tue, 18 Jul 2023 16:00:14 +0000 (11:00 -0500)]
Revert "[libc] Default the GPU build to the default memory utilities"
This reverts commit
eca8b54a5f76c65a055bac05556b70c2a0ec63a1.
Another user reverted the patch this was based on leaving this one in a
broken state.
Slava Zakharin [Tue, 18 Jul 2023 15:19:44 +0000 (08:19 -0700)]
[flang][hlfir] Support polymorphic hlfir.expr values.
This patch sets 'polymorphic' attribute of hlfir::ExprType when
the value is created from a polymorphic entity.
Memoization of such ExprType involves creating a mutable descriptor
on the stack, which is initialized (as a null box) and passed to
AllocatableApplyMold with the mold being the entity from which
the ExprType value is being created.
This patch fixes "creating polymorphic temporary" TODO and also
several cases of "'fir.convert' op invalid type conversion" error.
Reviewed By: tblah
Differential Revision: https://reviews.llvm.org/D155541
Joseph Huber [Tue, 18 Jul 2023 15:48:31 +0000 (10:48 -0500)]
[libc] Default the GPU build to the default memory utilities
A previous patch made this cause an error on the GPU. We have not yet
dedicated time towards an optimial implementaiton there but we do not
want it to cause an error. We simply use the fallback routines.
Differential Revision: https://reviews.llvm.org/D155615
Jens Carl [Tue, 18 Jul 2023 15:48:22 +0000 (15:48 +0000)]
[clang-tidy][NFC] Update path of main translation unit
The forcing of the linker for a new module was moved from file
clang-tidy/tools/ClangTidyModule.cpp to
clang-tidy/ClangTidyForceLinker.h.
Reviewed By: PiotrZSL
Differential Revision: https://reviews.llvm.org/D76477
Jon Chesterfield [Tue, 18 Jul 2023 15:41:47 +0000 (16:41 +0100)]
Revert "[libc][memfunctions] Explicit error when platform in not supported"
Broke amdgpu libc bot
This reverts commit
a39c951730aa92894e27da038e834229d4613db1.
Mark de Wever [Mon, 17 Jul 2023 18:25:01 +0000 (20:25 +0200)]
[libc++][chrono] Fixes month inc and dec operations.
The operator++, operator++(int), operator--, and operator--(int) need to
change the month to a valid value. The wording is specified in terms of
operator+(const month& x, const months& y) noexcept;
which has the correct behavior. The aforementioned operators instead
used ++/-- on the internal value direction, resulting in incorrect
behaviour.
As a drive-by improve the unit tests:
- use the typical constexpr test method
- test whether the month is valid after the operations
- format the tests
Fixes: https://llvm.org/PR63912
Reviewed By: #libc, ldionne
Differential Revision: https://reviews.llvm.org/D155504
Haojian Wu [Sat, 8 Jul 2023 20:55:00 +0000 (22:55 +0200)]
[clangd] Refine the workflow for diagnostic Fixits.
- No longer store the diagnostic fixits in the clangdLSPServer
- When propagating the fixit via the code action, we use the Diag
information stored in the ParsedAST (in clangdServer.cpp)
Differential Revision: https://reviews.llvm.org/D155173
Martin Storsjö [Tue, 18 Jul 2023 15:21:23 +0000 (18:21 +0300)]
Revert "[AArch64] Fix an immediate out of range for large realignments on Windows"
This reverts commit
b1d0bc0f4395c69097bc11b6ba8f821f621272a9.
Builds with expensive checks show that 'sp' isn't a valid register
in ADDXrr - an object file built without exprnsive checks enabled
disassembles as "add x15, xzr, x16", instead of the intended
"add x15, sp, x16".
Razvan Lupusoru [Fri, 14 Jul 2023 17:40:57 +0000 (10:40 -0700)]
[openacc] Add dialect definition for acc declare
A declare directive is used to specify the creation of a visible device
copy of a variable for the duration of the implicit data region as it
relates to the scope in which the variable is declared.
In order to support this, the following new operations were added:
1) `acc.global_ctor` and `acc.global_dtor`. These are used whenever the
declare directive applies to a global.
2) `acc.declare_enter` and `acc.declare_exit`. These operations are
modeled similarly to `acc.enter_data` and `acc.exit_data`. The reason
they are not modeled like `acc.data` is so that these operations can be
used both for globals and regions like functions.
3) `acc.declare_device_resident` and `acc.declare_link`. These
operations are modeled in a manner consistent with previously defined
data entry operation model.
The `acc.getdeviceptr` was generalized so that it can be used with
acc.declare_exit.
Reviewed By: clementval, vzakhari
Differential Revision: https://reviews.llvm.org/D155322
Markus Böck [Tue, 18 Jul 2023 13:23:27 +0000 (15:23 +0200)]
[mlir][LLVM] Append call ops alias scopes to inlined operations
Currently when inlining, any alias scope information previously attached to the call op is lost. This leads to a loss of information that could be used by alias analysis to determine that two memory access operations do not alias.
This patch fixes this issue by also taking any alias scopes of the call operation into account. These can then simply be appended onto any inlined operations.
This is analogous to the following code in LLVM: https://github.com/llvm/llvm-project/blob/
1768c4597e70477af2d69f576f33400181a5f945/llvm/lib/Transforms/Utils/InlineFunction.cpp#L940
Differential Revision: https://reviews.llvm.org/D155595
Ingo Müller [Tue, 18 Jul 2023 08:15:53 +0000 (08:15 +0000)]
[mlir][transform][bufferization][python] Add .td file for bindings.
Reviewed By: springerm, ftynse
Differential Revision: https://reviews.llvm.org/D155564
Adrian Kuegel [Tue, 18 Jul 2023 14:10:48 +0000 (16:10 +0200)]
[mlir][Bazel] Add missing dependency.
Adrian Kuegel [Tue, 18 Jul 2023 14:02:15 +0000 (16:02 +0200)]
[mlir][Bazel] Add VectorToArmSME target.
Guillaume Chatelet [Tue, 18 Jul 2023 13:30:01 +0000 (13:30 +0000)]
[libc][memfunctions] Explicit error when platform in not supported
Reviewed By: gchatelet
Differential Revision: https://reviews.llvm.org/D155597
Adrian Kuegel [Tue, 18 Jul 2023 13:51:49 +0000 (15:51 +0200)]
[mlir][Bazel] Add missing dependency.
iambrj [Tue, 18 Jul 2023 13:36:30 +0000 (19:06 +0530)]
[MLIR][Presburger] Implement domain and range restriction for PresburgerRelation
This patch implements domain and range restriction for PresburgerRelation
Reviewed By: Groverkss
Differential Revision: https://reviews.llvm.org/D154798
Martin Braenne [Tue, 18 Jul 2023 11:28:09 +0000 (11:28 +0000)]
[clang][dataflow] Strengthen flow condition assertions.
Instead of asserting merely that the flow condition doesn't imply that a variable is true, make the stronger assertion that the flow condition implies that the variable is false.
Reviewed By: ymandel, xazax.hun
Differential Revision: https://reviews.llvm.org/D155067
Paweł Bylica [Tue, 18 Jul 2023 13:40:28 +0000 (15:40 +0200)]
[clang][NFC] Fix typos in sema builtins test
Christoph Stiller [Tue, 18 Jul 2023 12:36:37 +0000 (13:36 +0100)]
[MCA] Document behaviour of ResourceRef
Differential Revision: https://reviews.llvm.org/D155347
Alexey Bataev [Fri, 5 May 2023 14:49:15 +0000 (07:49 -0700)]
[SLP]Include cost of the reshuffling for same nodes with resizing.
Need to account reshuffling, required for the reused elements in the
buildvector nodes, which are copies (perfect match) of other nodes, but
include reused elements.
Differential Revision: https://reviews.llvm.org/D149966
John Brawn [Fri, 14 Jul 2023 12:49:33 +0000 (13:49 +0100)]
[ARM] Replace TransferImpOps with copyImplicitOps
In most places where TransferImpOps is currently used we just have one
machine instruction, so it's doing the same thing as copyImplicitOps
anyway. In those cases where we have more than one machine
instruction the destination is written to in each instruction so any
implicit defs should appear on all of them (and we shouldn't see any
implicit refs as these pseudo-instruction don't have any register
inputs), meaning the current use of TransferImpOps is incorrect and
we should be using copyImplicitOps on all of the generated
instructions.
Differential Revision: https://reviews.llvm.org/D155301
wanglei [Tue, 18 Jul 2023 12:41:56 +0000 (20:41 +0800)]
[LoongArch][NFC] Revise instruction format to match lsx and lasx styles
Replace lengthy `0b...` binary form with a unified 32-bit hexadecimal
representation for opcode. This reduces complexity when dealing with
opcode discontinuities.
Martin Storsjö [Mon, 17 Jul 2023 12:19:14 +0000 (15:19 +0300)]
[AArch64] Fix an immediate out of range for large realignments on Windows
Also add a missing FrameSetup flag on the existing add instruction.
This fixes https://github.com/llvm/llvm-project/issues/63701.
Differential Revision: https://reviews.llvm.org/D155447
Luke Lau [Mon, 17 Jul 2023 10:23:16 +0000 (11:23 +0100)]
[RISCV] Add VP patterns for vandn.[vv,vx]
This builds upon D155433
Reviewed By: craig.topper
Differential Revision: https://reviews.llvm.org/D155434
Luke Lau [Mon, 17 Jul 2023 10:12:43 +0000 (11:12 +0100)]
[RISCV] Add SDNode patterns for vandn.[vv,vx]
Unfortunately we can't use the standard splat_vector and vnot PatFrags because
they are preprocessed to vmv.v.x's, so we need to define helpers to catch
those. We can't use SplatPat either because we need to nest another fragment
inside of it.
Reviewed By: craig.topper
Differential Revision: https://reviews.llvm.org/D155433
Matthias Springer [Tue, 18 Jul 2023 12:13:31 +0000 (14:13 +0200)]
[mlir][NVGPU][transform] Add `create_async_groups` transform op
This transform looks for suitable vector transfers from global memory to shared memory and converts them to async device copies.
Differential Revision: https://reviews.llvm.org/D155569
Guillaume Chatelet [Mon, 17 Jul 2023 21:35:03 +0000 (21:35 +0000)]
[libc][NFC] Split memmove implementations per platform
This is a follow up on D154800 and D154770 to make the code structure more principled and avoid too many nested #ifdef/#endif.
Reviewed By: courbet
Differential Revision: https://reviews.llvm.org/D155515
Jie Fu [Tue, 18 Jul 2023 12:17:18 +0000 (20:17 +0800)]
[Flang] Remove unused variable 'converter' in genCustomIntrinsicRefCore
/data/workspace/llvm-project/flang/lib/Lower/ConvertCall.cpp:1281:9: error: unused variable 'converter' [-Werror,-Wunused-variable]
auto &converter = callContext.converter;
^
1 error generated.
Nikita Popov [Tue, 18 Jul 2023 10:37:35 +0000 (12:37 +0200)]
[Constants] Use getGEPReturnType() (NFC)
This reimplements essentially the same logic.
dingfei [Tue, 18 Jul 2023 11:55:34 +0000 (19:55 +0800)]
[NFC][clang-extdef-mapping] fix test failure on unsupported targets
ms-stlye asm block is not supported on targets like arm/hexagon.
Specify a working target as POC.
Introduced by https://reviews.llvm.org/D154983
Differential Revision: https://reviews.llvm.org/D155576
Alex Zinenko [Mon, 17 Jul 2023 12:57:55 +0000 (12:57 +0000)]
[mlir] NFC: untangle SCF Patterns.h and Transforms.h
These two headers both contained a strange mix of definitions related to
both patterns and non-pattern transforms. Put patterns and "populate"
functions into Patterns.h and standalone transforms into Transforms.h.
Depends On: D155223
Reviewed By: nicolasvasilache
Differential Revision: https://reviews.llvm.org/D155454
Markus Böck [Mon, 17 Jul 2023 16:01:17 +0000 (18:01 +0200)]
[mlir][LLVM] Perform deep clone of alias scopes during inlining
This is the first and most basic and important step for inlining memory operations with alias scopes.
For correctness, it is required that any alias scopes of inlined operations are replaced with deep copies. This is necessary as otherwise the same function could be inlined twice in one function, and suddenly the alias scopes extended.
A simple example would be `foo(a, b); foo(a2, b2)`. `a` and `a2` may alias. If `foo` is inlined in both instances, the store and load operations from `foo` may suddenly claim that `a` and `a2` do not alias if we were to keep the original alias scopes.
This is analogous to the following class/code in LLVM: https://github.com/llvm/llvm-project/blob/
4eef2e30d6f89328a16d4f1d6b37f1c79afe850c/llvm/lib/Transforms/Utils/InlineFunction.cpp#L985
Differential Revision: https://reviews.llvm.org/D155479
Haojian Wu [Thu, 13 Jul 2023 12:03:24 +0000 (14:03 +0200)]
[include-cleaner] Avoid a caching issue when running --edit mode on multiple files.
Snapshot all analysing files before running the tool, this makes sure
that we analyse all files statelessly and avoid the FileManager caching issue
when running `-edit` on multiple files.
Differential Revision: https://reviews.llvm.org/D155195
Kiran Chandramohan [Tue, 18 Jul 2023 10:33:57 +0000 (10:33 +0000)]
[Flang] Include logical default with default-integer-8
Other compilers include the logical default also with the
default-integer-8 setting. This patch does the same for
flang.
Reviewed By: awarzynski, sscalpone
Differential Revision: https://reviews.llvm.org/D155279
Tom Eccles [Mon, 17 Jul 2023 15:52:54 +0000 (15:52 +0000)]
[flang][hlfir][NFC] catch dynamically optional args with no lowering
These should be lowered with genOptionalValue as in D154897, but I
haven't found any cases where this code path is actually hit (flang
tests, gfortran test suite), so I don't think it would be testable.
Adding an assertion for if this code path ever becomes live.
Differential Revision: https://reviews.llvm.org/D155477
Tom Eccles [Thu, 13 Jul 2023 15:36:22 +0000 (15:36 +0000)]
[flang][hlfir] support dynamically optional array arguments to intrinsics with custom handling
The previous code path created the elemental kernel by generating a
scalar intrinsic call using pre-prepared arguments using genIntrinsicRefCore,
which then generated the intrinsic call using genIntrinsicCall().
The problem with this approach was that the dynamically optional
arguments were marked as having no argLowering, which meant that they
were unconditionally passed by value without any check to see if they
were present.
It would be nice to put an if operation in the path for !argLowering,
doing something similar to genOptionalValue(). However, this can't be
done because it isn't clear what value should be used for the default.
If zero was used (like in genOptionalValue) this could effect the result
of MIN or MAX.
Instead, this patch re-uses the implementation for scalar dynamically
optional arguments (in non-elemental calls). This does the correct
thing, entirely ignoring absent optional arguments.
Depends On: D155292
Differential Revision: https://reviews.llvm.org/D155293
Tom Eccles [Tue, 11 Jul 2023 14:40:29 +0000 (14:40 +0000)]
[flang][hlfir] add support for elemental intrinsics with custom handling
Only minimal argument processing is needed here because they will be
lowered properly either by the elemental intrinsic call builder or the
lowering of the scalar call inside the elemental kernel.
Dynamically optional arrays are coming in the next patch.
Depends On: D155291
Differential Revision: https://reviews.llvm.org/D155292
Tom Eccles [Mon, 10 Jul 2023 16:48:01 +0000 (16:48 +0000)]
[flang][hlfir] custom intrinsic handling for scalar arguments
This should produce the same results as the FIR lowering
Differential Revision: https://reviews.llvm.org/D155291
Paulo Matos [Mon, 17 Jul 2023 06:41:43 +0000 (08:41 +0200)]
[InstCombine] Allow KnownBits to be propagated
Bug #63699 shows a hang on arm in instcombine because we do not
propagate known bits for fshl/fshr rotates. We perform the propagation
and add regression test.
Differential Revision: https://reviews.llvm.org/D155307
Matt Arsenault [Sun, 16 Jul 2023 18:51:17 +0000 (14:51 -0400)]
AMDGPU: Preserve flags in fdiv_fast lowering
We were dropping the flags and thus blocking contract into potential
fadd users. GlobalISel was already preserving the flags here.
https://reviews.llvm.org/D155443
Matt Arsenault [Sun, 16 Jul 2023 18:08:45 +0000 (14:08 -0400)]
AMDGPU: Generate and add fdiv tests
Prepare for new lowering strategies because we somehow didn't have
enough of them already.
Matt Arsenault [Sun, 16 Jul 2023 13:38:23 +0000 (09:38 -0400)]
ValueTracking: Fix computeKnownFPClass canonicalize handling
This mostly manifested as broken constant folding. This was
mishandling the dynamic denormal mode. It was also mishandling literal
signaling nans, such that they would also be treated as poison.
https://reviews.llvm.org/D155437
Matt Arsenault [Sun, 16 Jul 2023 13:48:59 +0000 (09:48 -0400)]
ValueTracking: Add more tests for canonicalize class handling
Matt Arsenault [Sat, 15 Jul 2023 14:03:07 +0000 (10:03 -0400)]
AMDGPU: Add some additional rcp/rsq tests
Nikita Popov [Tue, 18 Jul 2023 10:17:29 +0000 (12:17 +0200)]
[IR] Remove typed pointer handling from getGEPReturnType() (NFC)