Aart Bik [Thu, 11 May 2023 20:56:34 +0000 (13:56 -0700)]
[mlir][gpu][sparse] add gpu ops for sparse matrix computations
This revision extends the GPU dialect with ops that can be lowered to
host-oriented sparse matrix library calls (in this case cuSparse focused
although the ops could be generalized to support more GPUs in principle).
This will allow the "sparse compiler pipeline" to accelerate sparse operations
(see follow up revisions with examples of this).
For some background;
https://discourse.llvm.org/t/sparse-compiler-and-gpu-code-generation/69786/2
Reviewed By: ThomasRaoux
Differential Revision: https://reviews.llvm.org/D150152
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
Philip Reames [Fri, 12 May 2023 17:30:05 +0000 (10:30 -0700)]
[RISCVGatherScatterLowering] Minor code cleanup [NFC]
Use a switch to avoid repeat tests on the opcode, and factor out some common code out of another switch. (Not all branches had both common bits, but the one which didn't left the values unchanged and their starting value is the respective operand - so storing it back is a nop.)
Vitaly Buka [Fri, 12 May 2023 17:05:46 +0000 (10:05 -0700)]
[sanitizers] Remove assert from ThreadArgRetval::Finish
Bionic uses pthread_exit to set retval, when GLIBC does not.
This cause double call to Finish. Rather then tracking this difference
on interceptor size, we can just relax precondition. It does not make
a difference.
Jeffrey Tan [Wed, 10 May 2023 21:44:16 +0000 (14:44 -0700)]
Fix libstdc++ data formatter for reference/pointer to std::string
This patch fixes libstdc++ data formatter for reference/pointer to std::string.
The failure testcases are added which succeed with the patch.
Differential Revision: https://reviews.llvm.org/D150313
Leandro Lupori [Fri, 12 May 2023 16:32:50 +0000 (13:32 -0300)]
[lldb-vscode] Skip restart tests on ARM
These tests always time out on ARM buildbot. Disabling them for
now, until https://github.com/llvm/llvm-project/issues/62684 is
fixed.
Michael Maitland [Thu, 27 Apr 2023 01:19:46 +0000 (18:19 -0700)]
[RISCV][llvm-mca] Add mca tests for riscv lmul instruments
Add llvm-mca tests for RISCV LMUL instruments to show that llvm-mca RISCV LMUL
instruments work.
This commit was previously reverted in ad8765a. This commit adds a lit.local.cfg
to make RISCV llvm-mca tests unsupported on non-RISCV configurations.
Differential Revision: https://reviews.llvm.org/D149496
Craig Topper [Fri, 12 May 2023 16:31:04 +0000 (09:31 -0700)]
[RISCV] Fix typo in comment. NFC
Nicolas Vasilache [Fri, 12 May 2023 16:12:28 +0000 (09:12 -0700)]
[mlir][Linalg] NFC - Retire dead tilePadOp
Nicolas Vasilache [Fri, 12 May 2023 15:43:10 +0000 (08:43 -0700)]
[mlir][Linalg] NFC - Retire dead FusionOnTensors.cpp
Michael Maitland [Fri, 12 May 2023 16:22:11 +0000 (09:22 -0700)]
Revert "[RISCV][llvm-mca] Add mca tests for riscv lmul instruments"
This commit passed buildable tests in phabricator, but fails once
committed.
This reverts commit
1dedc96d04c82e29fff18ee3b875505a158ff93c.
Krzysztof Drewniak [Tue, 7 Feb 2023 21:46:11 +0000 (21:46 +0000)]
[GlobalISel] Handle ptr size != index size in IRTranslator, CodeGenPrepare
While the original motivation for this patch (address space 7 on
AMDGPU) has been reworked and is not presently planned to reach IR
translation, the incorrect (by the spec) handling of index offset
width in IR translation and CodeGenPrepare is likely to trip someone
- possibly future AMD, since we have a p7:160:256:256:32 now, so we
convert to the other API now.
Reviewed By: aemerson, arsenm
Differential Revision: https://reviews.llvm.org/D143526
Michael Maitland [Thu, 27 Apr 2023 01:19:46 +0000 (18:19 -0700)]
[RISCV][llvm-mca] Add mca tests for riscv lmul instruments
Add llvm-mca tests for RISCV LMUL instruments to show that llvm-mca RISCV LMUL
instruments work.
Differential Revision: https://reviews.llvm.org/D149496
Aart Bik [Fri, 12 May 2023 01:43:47 +0000 (18:43 -0700)]
[mlir][sparse] minor reorg of sparse tensor tablegen defs
Reviewed By: Peiming
Differential Revision: https://reviews.llvm.org/D150414
Craig Topper [Fri, 12 May 2023 16:06:07 +0000 (09:06 -0700)]
[DAGCombiner][AArch64][VE] Teach BuildUDIV/SDIV to use 2x mul when mulh/mul_lohi are not available.
Correct the legality of i32 mul_lohi on AArch64.
Previously, AArch64 incorrectly reported i32 mul_lohi as Legal.
This allowed BuildUDIV/SDIV to use them. A later DAGCombiner would
replace them with MULHS/MULHU because only the high half was used.
This conversion does not check the legality of MULHS/MULHU under
the assumption that LegalizeDAG can turn it back into MUL_LOHI later.
After they are converted to MULHS/MULHU, DAGCombine ran and saw that
these operations aren't supported but an i64 MUL is. So they get
converted to that plus a shift. Without this, LegalizeDAG would
convert back MUL_LOHI and isel would fail to find a pattern.
This patch teaches BuildUDIV/SDIV to create the wide mul and shift
so that we can report the correct operation legality on AArch64. It
also enables div by constant folding for more cases on VE.
I don't know if VE wants this div by constant optimization or not. If they
don't want it, they can use the isIntDivCheap hook to disable it.
Reviewed By: RKSimon
Differential Revision: https://reviews.llvm.org/D150333
Felipe de Azevedo Piovezan [Tue, 2 May 2023 18:05:04 +0000 (14:05 -0400)]
[SelectionDAG][DebugInfo] Implement translation of entry_value vars
This commit implements SelectionDAG lowering of dbg.declare intrinsics targeting
swiftasync Arguments, by putting them in the MachineFunction's table of
variables whose location doesn't change throughout the function.
Depends on D149882
Differential Revision: https://reviews.llvm.org/D149883
Krzysztof Drewniak [Fri, 5 May 2023 22:03:40 +0000 (22:03 +0000)]
[AMDGPU] Fix crash with 160-bit p7's by manually defining getPointerTy
While pointers in address space 7 (128 bit rsrc + 32 bit offset)
should be rewritten out of the code before IR translation on AMDGPU,
higher-level analyses may still call MVT getPointerTy() and the like
on the target machine. Currently, since there is no MVT::i160, this
operation ends up causing crashes.
The changes to the data layout that caused such crashes were D149776.
This patch causes getPointerTy() to return the type MVT::v5i32
and getPointerMemTy() to be MVT::v8i32. These are accurate types,
but mean that we can't use vectors of address space 7 pointers during
codegen. This is mostly OK, since vectors of buffers aren't supported
in LPC anyway, but it's a noticable limitation.
Potential alternative solutions include adjusting getPointerTy() to return
an EVT or adding MVT::i160 and MVT::i256, both of which are rather
disruptive to the rest of the compiler.
Reviewed By: foad
Differential Revision: https://reviews.llvm.org/D150002
Felipe de Azevedo Piovezan [Mon, 1 May 2023 12:18:24 +0000 (08:18 -0400)]
[IRTranslator][DebugInfo] Implement translation of entry_value vars
This commit implements IRTranslator lowering of dbg.declare intrinsics targeting
swiftasync Arguments, by putting them in the MachineFunction's table of
variables whose location doesn't change throughout the function.
Depends on D149881
Differential Revision: https://reviews.llvm.org/D149882
Konstantin Zhuravlyov [Fri, 12 May 2023 15:42:04 +0000 (11:42 -0400)]
AMDGPU: Force sc0 and sc1 on stores for gfx940 and gfx941
Differential Revision: https://reviews.llvm.org/D149986
Mark de Wever [Sat, 6 May 2023 11:28:46 +0000 (13:28 +0200)]
[NFC][libc++][format] Uses uniform member signatures.
The newer formatters for (tuple, vector<bool>::reference) specify the
formatter's parse and format member function. This signature is slightly
different from the signature for existing formatters. Adapt the existing
formatters to the new style.
Reviewed By: ldionne, #libc
Differential Revision: https://reviews.llvm.org/D150034
Mark de Wever [Sun, 7 May 2023 12:56:52 +0000 (14:56 +0200)]
[clang] Restores some -std=c++2b tests.
These tests should have added -std=c++23 instead of replacing -std=c++2b
in D149553.
Reviewed By: aaron.ballman
Differential Revision: https://reviews.llvm.org/D150063
Mark de Wever [Sun, 7 May 2023 12:34:00 +0000 (14:34 +0200)]
[clang][ci] Improves buildkite artifacts.
The financial cost of the network I/O for the Clang install artifacts is
quite significant.
afd3478f37c8 improved this by creating tarballs. This
commit improves the tarball by using xz compression instead of gzip. This
option is the slowest, but gives the smallest size.
size time time
(compression) (decompression)
gzip 51 M 7 s 1.2 s
bz2 44 M 17 s 5.8 s
xz 33 M 76 s 3.1 s
Reviewed By: ldionne, #libc
Differential Revision: https://reviews.llvm.org/D150062
Simon Pilgrim [Fri, 12 May 2023 15:41:12 +0000 (16:41 +0100)]
[X86] narrowShuffle - only narrow from legal vector types
Fixes #62653
Benoit Jacob [Thu, 11 May 2023 15:44:12 +0000 (15:44 +0000)]
DestinationPassingStyle: allow additional non-tensor results
Also some simplifications:
* `outputBufferOperands` was unused.
* The condition that the number of operands equals the number of inputs
plus the number of inits seemed vacuously true (?).
Differential Revision: https://reviews.llvm.org/D150376
Jeffrey Byrnes [Fri, 12 May 2023 15:32:47 +0000 (08:32 -0700)]
Precommit test for D149873
Change-Id: I608f14ac3a504cc668f93f130a17dea3950fa554
Oleg Shyshkov [Fri, 12 May 2023 15:14:50 +0000 (17:14 +0200)]
[mlir][memref] Lower copy of memrefs with outer size-1 dims to intrinsic memcpy.
With this change, more `memref.copy` will be lowered to the efficient `memcpy`. For example,
```
memref.copy %subview, %alloc : memref<1x576xf32, strided<[704, 1]>> to memref<1x576xf32>
```
Differential Revision: https://reviews.llvm.org/D150448
Florian Hahn [Fri, 12 May 2023 15:10:47 +0000 (16:10 +0100)]
[ShrinkWrap] Conservatively treat MIs without memory operands.
As pointed out by @jpenix-quic in D149668 post-commit, machine instructions
without memory operands need to be treated conservatively.
Shengchen Kan [Sun, 7 May 2023 14:20:36 +0000 (22:20 +0800)]
[X86][AsmParser] Refactor code and optimize more instructions from VEX3 to VEX2
1. Share code `optimizeInstFromVEX3ToVEX2` with MCInstLower
2. Move the code of optimization for shift/rotate to a separate file
3. Since the function is shared, a side effect is that more encoding
optimizations are done on the Asmparser side. Considering we already
use reverse-encoding for optimization in AsmParser before this patch,
I believe the change is positive and expected.
This is a reland of D150068 with the fix D150440.
Shengchen Kan [Fri, 12 May 2023 14:41:17 +0000 (22:41 +0800)]
Revert "[X86][AsmParser] Refactor code in AsmParser"
This reverts commit
8d657c461a5aa43e882071b3b5e0496961aa44a1.
Reverts it due to the regression reported in D150068.
Kohei Yamaguchi [Fri, 12 May 2023 14:43:31 +0000 (16:43 +0200)]
[mlir][NFC] Fix broken sidebar and improve documentation
- Added missing TensorTransformOps to the Transform doc
- Added missing AMDGPUPasses to the Passes doc
- Place `async dialect` in alphabetical order in the Passes doc
Reviewed By: ftynse
Differential Revision: https://reviews.llvm.org/D150341
kon72 [Fri, 12 May 2023 14:42:12 +0000 (16:42 +0200)]
[mlir][linalg] Add channel-first variants of convolution
This change adds the following three operations and unit tests for them:
- conv_3d_ncdhw_fcdhw
- depthwise_conv_1d_ncw_cw
- depthwise_conv_3d_ncdhw_cdhw
Reviewed By: nicolasvasilache
Differential Revision: https://reviews.llvm.org/D150054
Florian Hahn [Fri, 12 May 2023 14:38:31 +0000 (15:38 +0100)]
[AArch64] Add shrink-wrapping test with missing memoperands.
The newly added compiler_pop_stack_no_memoperands has no memory operands
on the memory instructions but accesses the same locations as
compiler_pop_stack. At the moment, accesses to the stack are missed by
shrink-wrapping. Test case for the issue pointed out by @jpenix-quic in
D149668 post-commit.
Neumann Hon [Fri, 12 May 2023 13:32:04 +0000 (09:32 -0400)]
[SystemZ][z/OS] Save (and restore) R3 to avoid clobbering parameter when call stack frame extension is invoked
When the stack frame extension routine is used, the contents of r3 is overwritten.
However, if r3 is live in the prologue (ie. one of the function's parameters
resides in r3), it needs to be saved. We save r3 in r0 if r0 is available
(ie. r0 is not used as temporary storage for r4), and in the corresponding
stack slot for the third parameter otherwise.
Differential Revision: https://reviews.llvm.org/D150332
Reviewed By: uweigand
Matthias Springer [Fri, 12 May 2023 08:04:13 +0000 (10:04 +0200)]
[mlir][transform] TrackingListener: Allow existing ops as replacements
The TrackingListener was unnecessarily strict. Existing ops are now allowed when updating payload ops mappings due to `replaceOp` in the TrackingListener.
Differential Revision: https://reviews.llvm.org/D150429
Felipe de Azevedo Piovezan [Thu, 11 May 2023 13:14:52 +0000 (09:14 -0400)]
[lldb][nfc] Simplify DebugRanges class
Most of the code changed here dates back to 2010, when LLDB was first
introduced upstream, as such it benefits from a slight cleanup.
The method "dump" is not used anywhere nor is it tested, so this commit removes
it.
The "findRanges" method returns a boolean which is never checked and indicates
whether the method found anything/assigned a range map to the out parameter.
This commit folds the out parameter into the return type of the method.
A handful of typedefs were also never used and therefore removed.
Differential Revision: https://reviews.llvm.org/D150363
Felipe de Azevedo Piovezan [Mon, 1 May 2023 15:19:49 +0000 (11:19 -0400)]
[AsmPrinter] Use EntryValue object info to emit Dwarf
This patch consumes the EntryValueObjects in a MachineFunction's table, using
them to emit the appropriate debug information for these variables.
Depends on D149880
Differential Revision: https://reviews.llvm.org/D149881
Tobias Gysi [Fri, 12 May 2023 11:36:28 +0000 (11:36 +0000)]
[mlir] Add timings to mlir translate.
The revision adds basic timing to the mlir-translate tool.
Reviewed By: Dinistro
Differential Revision: https://reviews.llvm.org/D150434
Ruiling Song [Wed, 10 May 2023 03:07:00 +0000 (11:07 +0800)]
AMDGPU: Fix issue in shl(or) combine
The code is doing the optimization:
`((a | c1) << c2)` ==> `(a << c2) + (c1 << c2)`
But this is only valid if `a` and `c1` have no common bits being set.
Differential Revision: https://reviews.llvm.org/D150246
Benjamin Kramer [Fri, 12 May 2023 10:26:29 +0000 (12:26 +0200)]
[lldb] Don't write to source directory in test
khei4 [Fri, 12 May 2023 09:41:09 +0000 (18:41 +0900)]
[AggressiveInstCombine] folding load for constant global patterened arrays and structs by GEP-indices
Differential Revision: https://reviews.llvm.org/D146622
Fixes https://github.com/llvm/llvm-project/issues/61615
Reviewed By: nikic
Tres Popp [Thu, 11 May 2023 09:10:46 +0000 (11:10 +0200)]
[mlir] Update method cast calls to function calls
The MLIR classes Type/Attribute/Operation/Op/Value support
cast/dyn_cast/isa/dyn_cast_or_null functionality through llvm's doCast
functionality in addition to defining methods with the same name.
This change begins the migration of uses of the method to the
corresponding function call as has been decided as more consistent.
Note that there still exist classes that only define methods directly,
such as AffineExpr, and this does not include work currently to support
a functional cast/isa call.
Context:
* https://mlir.llvm.org/deprecation/ at "Use the free function variants for dyn_cast/cast/isa/…"
* Original discussion at https://discourse.llvm.org/t/preferred-casting-style-going-forward/68443
Implementation:
This follows a previous patch that updated calls
`op.cast<T>()-> cast<T>(op)`. However some cases could not handle an
unprefixed `cast` call due to occurrences of variables named cast, or
occurring inside of class definitions which would resolve to the method.
All C++ files that did not work automatically with `cast<T>()` are
updated here to `llvm::cast` and similar with the intention that they
can be easily updated after the methods are removed through a
find-replace.
See https://github.com/llvm/llvm-project/compare/main...tpopp:llvm-project:tidy-cast-check
for the clang-tidy check that is used and then update printed
occurrences of the function to include `llvm::` before.
One can then run the following:
```
ninja -C $BUILD_DIR clang-tidy
run-clang-tidy -clang-tidy-binary=$BUILD_DIR/bin/clang-tidy -checks='-*,misc-cast-functions'\
-export-fixes /tmp/cast/casts.yaml mlir/*\
-header-filter=mlir/ -fix
rm -rf $BUILD_DIR/tools/mlir/**/*.inc
```
Differential Revision: https://reviews.llvm.org/D150348
Tres Popp [Mon, 8 May 2023 14:33:54 +0000 (16:33 +0200)]
[mlir] Move casting calls from methods to function calls
The MLIR classes Type/Attribute/Operation/Op/Value support
cast/dyn_cast/isa/dyn_cast_or_null functionality through llvm's doCast
functionality in addition to defining methods with the same name.
This change begins the migration of uses of the method to the
corresponding function call as has been decided as more consistent.
Note that there still exist classes that only define methods directly,
such as AffineExpr, and this does not include work currently to support
a functional cast/isa call.
Caveats include:
- This clang-tidy script probably has more problems.
- This only touches C++ code, so nothing that is being generated.
Context:
- https://mlir.llvm.org/deprecation/ at "Use the free function variants
for dyn_cast/cast/isa/…"
- Original discussion at https://discourse.llvm.org/t/preferred-casting-style-going-forward/68443
Implementation:
This first patch was created with the following steps. The intention is
to only do automated changes at first, so I waste less time if it's
reverted, and so the first mass change is more clear as an example to
other teams that will need to follow similar steps.
Steps are described per line, as comments are removed by git:
0. Retrieve the change from the following to build clang-tidy with an
additional check:
https://github.com/llvm/llvm-project/compare/main...tpopp:llvm-project:tidy-cast-check
1. Build clang-tidy
2. Run clang-tidy over your entire codebase while disabling all checks
and enabling the one relevant one. Run on all header files also.
3. Delete .inc files that were also modified, so the next build rebuilds
them to a pure state.
4. Some changes have been deleted for the following reasons:
- Some files had a variable also named cast
- Some files had not included a header file that defines the cast
functions
- Some files are definitions of the classes that have the casting
methods, so the code still refers to the method instead of the
function without adding a prefix or removing the method declaration
at the same time.
```
ninja -C $BUILD_DIR clang-tidy
run-clang-tidy -clang-tidy-binary=$BUILD_DIR/bin/clang-tidy -checks='-*,misc-cast-functions'\
-header-filter=mlir/ mlir/* -fix
rm -rf $BUILD_DIR/tools/mlir/**/*.inc
git restore mlir/lib/IR mlir/lib/Dialect/DLTI/DLTI.cpp\
mlir/lib/Dialect/Complex/IR/ComplexDialect.cpp\
mlir/lib/**/IR/\
mlir/lib/Dialect/SparseTensor/Transforms/SparseVectorization.cpp\
mlir/lib/Dialect/Vector/Transforms/LowerVectorMultiReduction.cpp\
mlir/test/lib/Dialect/Test/TestTypes.cpp\
mlir/test/lib/Dialect/Transform/TestTransformDialectExtension.cpp\
mlir/test/lib/Dialect/Test/TestAttributes.cpp\
mlir/unittests/TableGen/EnumsGenTest.cpp\
mlir/test/python/lib/PythonTestCAPI.cpp\
mlir/include/mlir/IR/
```
Differential Revision: https://reviews.llvm.org/D150123
Tres Popp [Tue, 9 May 2023 13:56:42 +0000 (15:56 +0200)]
[mlir] Move casting method calls to function calls
The MLIR classes Type/Attribute/Operation/Op/Value support
cast/dyn_cast/isa/dyn_cast_or_null functionality through llvm's doCast
functionality in addition to defining methods with the same name.
This change continues the migration of uses of the method to the
corresponding function call as has been decided as more consistent.
This commit attempts to update all occurrences of the casts in .td
files, although it is likely that a couple were missed.
Context:
- https://mlir.llvm.org/deprecation/ at "Use the free function variants for dyn_cast/cast/isa/…"
- Original discussion at https://discourse.llvm.org/t/preferred-casting-style-going-forward/68443
Implementation:
Unfortunatley, this was not automated, but was handled by mindlessly
going to next occurrences of patterns, selecting the piece of code to
be moved into the function call, and running a vim macro over the span
of around 4 hours.
Differential Revision: https://reviews.llvm.org/D150199
Sander de Smalen [Fri, 12 May 2023 08:22:21 +0000 (08:22 +0000)]
[AArch64][SME2/SVE2p1] Add predicate-as-counter intrinsics for while*
These intrinsics are used to implement the while intrinsics that result
in a predicate-as-counter value, e.g.
__attribute__((arm_streaming))
svcount_t svwhilelt_c8(int64_t rn, int64_t rm, uint64_t vl)
As described in https://github.com/ARM-software/acle/pull/217
Reviewed By: hassnaa-arm
Differential Revision: https://reviews.llvm.org/D150265
Sander de Smalen [Fri, 12 May 2023 08:21:54 +0000 (08:21 +0000)]
[AArch64][SME2/SVE2p1] Add predicate-as-counter intrinsics for ptrue/cntp
These intrinsics are used to implement:
* svptrue_c8(), svptrue_c16(), etc.
* svcntp_c8(svcount_t pnn, uint64_t vl), svcntp_c16(...), etc.
As described in https://github.com/ARM-software/acle/pull/217
Reviewed By: david-arm
Differential Revision: https://reviews.llvm.org/D150263
Qihan Cai [Fri, 12 May 2023 08:29:30 +0000 (18:29 +1000)]
[RISCV][CodeGen] Support Zhinx and Zhinxmin
This patch was split from D122918.
Co-Author: @liaolucy @sunshaoce
Reviewed By: craig.topper
Differential Revision: https://reviews.llvm.org/D149811
Nicolas Vasilache [Fri, 12 May 2023 08:11:20 +0000 (01:11 -0700)]
[mlir][Linalg] NFC - fail gracefully instead of asserting in HoistPadding
Balázs Kéri [Fri, 12 May 2023 07:20:35 +0000 (09:20 +0200)]
[clang][analyzer] Cleanup tests of StdCLibraryFunctionsChecker (NFC)
Function declarations are moved into common header that can be reused
to avoid repetitions in different test files.
Some small problems in the tests were found and fixed.
Reviewed By: steakhal
Differential Revision: https://reviews.llvm.org/D149158
Yingwei Zheng [Fri, 12 May 2023 07:06:58 +0000 (15:06 +0800)]
[RISCV] Fold (select setcc, setcc, setcc) into and/or instructions
This patch folds `(select setcc, setcc, setcc)` into and/or instructions when truev/falsev is equal to or the inverse of condv.
(select x, x, y) -> x | y https://alive2.llvm.org/ce/z/36Ud3Z
(select !x, x, y) -> x & y https://alive2.llvm.org/ce/z/mYYoGF
(select x, y, x) -> x & y https://alive2.llvm.org/ce/z/MAZ--X
(select !x, y, x) -> x | y https://alive2.llvm.org/ce/z/ct7By5
It is the follow-up improvement of D150177, which optimizes the code of signed truncation check patterns without Zbb.
Reviewed By: craig.topper
Differential Revision: https://reviews.llvm.org/D150286
Vitaly Buka [Fri, 12 May 2023 06:56:41 +0000 (23:56 -0700)]
Revert "[NFC][xray] Initialize XRayFileHeader"
Revert "[xray] Ignore -Wc++20-extensions in xray_records.h [NFC]"
Not needed. The fix is
3826a74fc7ad589e268b267d9323d4d416c5f6e9.
This reverts commit
231c1d4134513e5a97cfdc874e8bda488ad59699.
This reverts commit
7f191e6d2c9ec4af1819c4e80a5453583cd72f08.
Serge Pavlov [Fri, 12 May 2023 06:30:36 +0000 (13:30 +0700)]
[test] Use autogenerated assertions
Chuanqi Xu [Fri, 12 May 2023 02:20:13 +0000 (10:20 +0800)]
[Serialization] Don't try to complete the redeclaration chain in
ASTReader after we start writing
This is intended to mitigate
https://github.com/llvm/llvm-project/issues/61447.
Before the patch, it takes 5s to compile test.cppm in the above
reproducer. After the patch it takes 3s to compile it. Although this
patch didn't solve the problem completely, it should mitigate the
problem for sure. Noted that the behavior of the patch is consistent
with the comment of the originally empty function
ASTReader::finalizeForWriting. So the change should be consistent with
the original design.
Tomasz Kuchta [Fri, 12 May 2023 05:28:53 +0000 (05:28 +0000)]
[DFSAN] Add support for strnlen
This patch adds a support for the libc strnlen() function in DFSAN
Reviewed by: browneee
Differential Revision: https://reviews.llvm.org/D149459
Fangrui Song [Fri, 12 May 2023 06:06:01 +0000 (23:06 -0700)]
[test] Remove Python<3.3 workaround without shlex.quote
Python>=3.6 has been the requirement since D93097 (2020).
Remove old workarounds.
Remove unused imports from compiler-rt/test/memprof/lit.cfg.py
Reviewed By: serge-sans-paille
Differential Revision: https://reviews.llvm.org/D150410
Vitaly Buka [Fri, 12 May 2023 05:56:27 +0000 (22:56 -0700)]
[ASAN][LSAN] Ignore main or uninitialized thead in pthread_exit
Fix crash on CHECK in ThreadArgRetval::Finish().
Vitaly Buka [Fri, 12 May 2023 03:38:08 +0000 (20:38 -0700)]
[NFC][xray] Initialize XRayFileHeader
Avoids reports with msan -fno-inline.
Lang Hames [Fri, 12 May 2023 00:41:30 +0000 (10:41 +1000)]
[lli] Add new testcases for lli.
These are an attempt to more systematically test the features covered by the
MCJIT regression tests (though these tests apply to lli's default mode, which
is now -jit-kind=orc).
This first batch of tests includes a basic smoke test (trivial-return-zero),
tests for single function calls and data references, and alignment handling.
Jessica Paquette [Fri, 12 May 2023 05:24:29 +0000 (22:24 -0700)]
[NFC] SuffixTree: Move advance() into SuffixTree.cpp + more cleanup
Allows us to knock out a couple more includes from the header file.
Also clang-format SuffixTree.cpp while we're here.
Also use SuffixTreeNode::EmptyIdx in a couple more places.
Joshua Cao [Thu, 11 May 2023 05:38:02 +0000 (22:38 -0700)]
[SimpleLoopUnswitch][reland 2] unswitch selects
The old LoopUnswitch pass unswitched selects, but the changes were
never ported to the new SimpleLoopUnswitch.
We unswitch by turning:
``` S = select %cond, %a, %b ```
into:
``` head: br %cond, label %then, label %tail
then: br label %tail
tail: S = phi [ %a, %then ], [ %b, %head ] ```
Unswitch selects are always nontrivial, since the successors do not
exit the loop and the loop body always needs to be cloned.
Unswitch selects always need to freeze the conditional if the
conditional could be poison or undef. Selects don't propagate
poison/undef, and branches on poison/undef causes UB.
Reland 1 - Fix the insertion of freeze instructions. The original
implementation inserts a dead freeze instruction that is not used by the
unswitched branch.
Reland 2 - Include https://reviews.llvm.org/D149560 in the same patch,
which was originally reverted along with this patch. The patch prevents
unswitching of selects with a vector conditional. This could have been
caught in SimpleLoopUnswitch/crash.ll if it included tests for
nontrivial unswitching. This reland also adds a run for the test file
with nontrivial unswitching.
Reviewed By: nikic, kachkov98, vitalybuka
Differential Revision: https://reviews.llvm.org/D138526
Jessica Paquette [Fri, 12 May 2023 05:11:05 +0000 (22:11 -0700)]
SuffixTree: Don't save entire leaf nodes in advance()
All we need is the suffix indices.
Just store those instead.
Also improve code readability a little while we're here.
Jessica Paquette [Fri, 12 May 2023 04:35:26 +0000 (21:35 -0700)]
[NFC] Tidy SuffixTree.h
- Move comment to top of file
- Remove unused vector include
LLVM GN Syncbot [Fri, 12 May 2023 04:34:40 +0000 (04:34 +0000)]
[gn build] Port
6cf993e59bd2
Jessica Paquette [Fri, 12 May 2023 04:32:12 +0000 (21:32 -0700)]
[NFC] SuffixTree: Split out SuffixTreeNodes into their own files
Add:
- SuffixTreeNode.h
- SuffixTreeNode.cpp
The SuffixTree file was getting too long.
Jessica Paquette [Fri, 12 May 2023 03:41:00 +0000 (20:41 -0700)]
[NFC] SuffixTree: Move EmptyIdx into SuffixTreeNode and add a root allocator
This makes it clearer that EmptyIdx is related to the node.
Also add an allocator for the root so that in the main SuffixTree code we don't
see gross stuff like a nullptr parent etc.
Jie Fu [Fri, 12 May 2023 03:10:08 +0000 (11:10 +0800)]
[xray] Ignore -Wc++20-extensions in xray_records.h [NFC]
/data/llvm-project/compiler-rt/lib/xray/../../include/xray/xray_records.h:48:24: error: default member initializer for bit-field is a C++20 extension [
-Werror,-Wc++20-extensions]
bool ConstantTSC : 1 = false;
^
/data/llvm-project/compiler-rt/lib/xray/../../include/xray/xray_records.h:49:23: error: default member initializer for bit-field is a C++20 extension [
-Werror,-Wc++20-extensions]
bool NonstopTSC : 1 = false;
^
2 errors generated.
Kai Sasaki [Fri, 12 May 2023 02:40:00 +0000 (11:40 +0900)]
[mlir][tosa] Fold exp(log) operation into no-op
Element-wise exp(log) can be canonicalized as no-op.
Reviewed By: eric-k256
Differential Revision: https://reviews.llvm.org/D150342
jinge90 [Fri, 12 May 2023 03:12:36 +0000 (11:12 +0800)]
This patch adds doc for __builtin_flt_rounds and __builtin_set_flt_rounds
and also adds description for default fp environment.
Reviewed By:rjmccall, sepavloff
Differential Revision: https://reviews.llvm.org/D146188
John Demme [Fri, 12 May 2023 02:43:29 +0000 (02:43 +0000)]
[MLIR][Memref] Remove unnecessary #include
MemRefMem2Ref was unnecessarily including a header from Complex and not
including it as a cmake dep (causing some builds to fail).
Vitaly Buka [Fri, 12 May 2023 02:42:08 +0000 (19:42 -0700)]
[NFC][LiveDebugValues] Clang-format
b135df08
Vitaly Buka [Fri, 12 May 2023 02:35:12 +0000 (19:35 -0700)]
[LiveDebugValues] Temporarily initialize MLocTracker::CurBB
Looks like code assumes that it will be always set, but it's not true:
https://reviews.llvm.org/D150420. This is temporarily suppression to enabled
stricter msan on a bot.
Neumann Hon [Fri, 12 May 2023 02:32:16 +0000 (22:32 -0400)]
Revert "[SystemZ][z/OS] Save (and restore) R3 to avoid clobbering parameter when call stack frame extension is invoked"
This reverts commit
1aec3d15aaa25c39fae026688708d7353d488974.
Weining Lu [Fri, 12 May 2023 02:09:39 +0000 (10:09 +0800)]
[LoongArch] clang-format LoongArchISelLowering.cpp. NFC
Vitaly Buka [Fri, 12 May 2023 02:07:29 +0000 (19:07 -0700)]
[NFC][LLLexer] Consistently initialize *Val fields
LLParser::parseInstruction speculatively getUIntVal()
but uses that only in some branches.
APFloatVal, TyVal and StrVal were already initialized, when
UIntVal and APSIntVal were not.
Jianjian GUAN [Thu, 11 May 2023 09:30:30 +0000 (17:30 +0800)]
[RISCV][NFC] Remove unused class defination.
Reviewed By: craig.topper
Differential Revision: https://reviews.llvm.org/D150350
Vitaly Buka [Fri, 12 May 2023 01:49:39 +0000 (18:49 -0700)]
[NFC][xray] Initialize XRayFileHeader
Avoids reports with msan -fno-inline.
Eli Kobrin [Fri, 12 May 2023 01:33:44 +0000 (18:33 -0700)]
[CMake][fuzzer] Add riscv64 to fuzzer supported arch list
I tried to build libFuzzer for RISC-V and succeeded. All the libFuzzer
targets were successfully built. I tested this on the small hello world code
with a few branches to check the instrumentation; all of them were covered by
libFuzzer on RISC-V arch. So I suppose it makes sense to enable libFuzzer
build for RISC-V.
Reviewed By: phosek, thetruestblue, MaskRay
Differential Revision: https://reviews.llvm.org/D147788
Neumann Hon [Fri, 12 May 2023 01:25:05 +0000 (21:25 -0400)]
[SystemZ][z/OS] Save (and restore) R3 to avoid clobbering parameter when call stack frame extension is invoked
When the stack frame extension routine is used, the contents of r3 is
overwritten. However, if r3 is live in the prologue (ie. one of the
function's parameters resides in r3), it needs to be saved. We save
r3 in r0 if r0 is available (ie. r0 is not used as temporary storage
for r4), and in the corresponding stack slot for the third parameter otherwise.
Reviewed By: uweigand
Differential Revision: https://reviews.llvm.org/D150332
Jessica Paquette [Thu, 11 May 2023 21:52:53 +0000 (14:52 -0700)]
[NFC] Refactor SuffixTree to use LLVM-style RTTI
Following guidelines in
https://llvm.org/docs/HowToSetUpLLVMStyleRTTI.html
This allows us to
* Quickly discern between leaf and internal nodes
* Be more idiomatic with the rest of LLVM
* Save some size on node structs
* Reduce the number of allocations (because end indices for internal nodes no
longer need to be pointers to be compatible with leaf nodes)
Also object orientify the code some more. This allows for more asserts and
checks.
This shouldn't impact code size on the MachineOutliner.
- All unit tests pass (outliner lit + llvm-unit)
- No code size changes on CTMark @ -Oz for AArch64
Nico Weber [Fri, 12 May 2023 00:31:52 +0000 (02:31 +0200)]
Akira Hatanaka [Fri, 12 May 2023 00:22:49 +0000 (17:22 -0700)]
Declare _availability_version_check as weak_import instead of looking it
up at runtime using dlsym
Calling dlsym with RTLD_DEFAULT can be very slow as all images in the
process are searched for the symbol.
Differential Revision: https://reviews.llvm.org/D150397
Vitaly Buka [Fri, 12 May 2023 00:11:49 +0000 (17:11 -0700)]
[NFC][AST] Return void from setUseQualifiedLookup
It uses to initialize the class. If so, it returns uninitalized value.
This is UB and msan with -fno-inline will complain.
Craig Topper [Thu, 11 May 2023 23:49:55 +0000 (16:49 -0700)]
[RISCV] Fix crash if you use an immediate as part of a vtype operand list.
Craig Topper [Thu, 11 May 2023 23:28:47 +0000 (16:28 -0700)]
[SelectionDAG] Correct AddNodeIDCustom for MemIntrinsicSDNodes.
We were missing any support for ISD::INTRINSIC_W_CHAIN/INTRINSIC_VOID
used for memory operations.
For ISD::PREFETCH and target memory nodes we didn't add the subclass
data.
This patch handles all MemIntrinsicSDNode in one place and adds the
missing subclass data.
Note. Unlike load/stores we don't add the memory VT in AddNodeIDCustom or getMemIntrinsicNode. Not sure why.
Reviewed By: efriedma
Differential Revision: https://reviews.llvm.org/D150387
Vitaly Buka [Mon, 8 May 2023 21:57:03 +0000 (14:57 -0700)]
[NFC][LSAN] Move ThreadCreate into child thread
Vitaly Buka [Thu, 11 May 2023 17:30:20 +0000 (10:30 -0700)]
[HWASAN] Prevent crashes on thread exit
I can't figure out how to reproduce this for test, but I see the case on
random binaries.
The known issue is with GLIBC, others may have a workaround, e.g. Bionic,
https://cs.android.com/android/platform/superproject/+/master:bionic/libc/bionic/pthread_exit.cpp;l=149
see signals blocked above.
Reviewed By: eugenis
Differential Revision: https://reviews.llvm.org/D150401
Vitaly Buka [Mon, 8 May 2023 19:42:50 +0000 (12:42 -0700)]
[LSAN] Use ThreadArgRetval in LSAN
Fixes false leaks on thread retval.
Reviewed By: thurston
Differential Revision: https://reviews.llvm.org/D150165
Mircea Trofin [Mon, 8 May 2023 22:31:27 +0000 (15:31 -0700)]
[IPO] Opt-in local clones for thinlto imports
ThinLTO imports (which appear as `available_externally`) that survive
inlining get deleted. With today's inliner that's reasonable, because
the way the function would be inlined into in other modules would be the
same - because of the bottom-up traversal assumption, and the fact that
the inliner doesn't take into account surrounding context [*]. The
ModuleInliner invalidates the first assumption, and the ML inliner the
second.
This patch adds a way to opt-in a module to keep its variant of an
imported function, even if it survived past inlining.
[*] Almost. Deferred inlining is an exception which can lead to
(empirically) infrequent discrepancies.
Differential Revision: https://reviews.llvm.org/D150148
Vitaly Buka [Mon, 8 May 2023 07:50:26 +0000 (00:50 -0700)]
[ASAN] Use ThreadArgRetval in ASAN
Fixes false leaks on thread retval.
Reviewed By: thurston
Differential Revision: https://reviews.llvm.org/D150106
Peiming Liu [Thu, 11 May 2023 22:31:09 +0000 (22:31 +0000)]
[bazel] fix bazel
Reviewed By: wrengr
Differential Revision: https://reviews.llvm.org/D150405
Adrian Vogelsgesang [Thu, 4 May 2023 12:20:29 +0000 (12:20 +0000)]
[ADT][NFC] Fix compilation of headers under C++23
`DoubleAPFloat` has a `unique_ptr<APFloat[]>` member. In
`DoubleAPFloat::operator=` and `DoubleAPFloat::get{First,Second}`,
the methods of this unique_ptr are getting instantiated. At that
point `APFloat` is still only a forward declaration.
This triggers undefined behavior. So far, we were probaly just
lucky and the code compiled fine. However, with C++23
`std::unique_ptr` became constexpr, and clang (and other compilers) are
now diagnosing this latent bug as an error.
This commit fixes the issue by moving the function definitions
out of the class definition of `DoubleAPFloat`, after the declaration
of `APFloat`.
A similar issue exists in `ModuleSummaryIndex.h`, the fix is pretty
much identical.
Fixes #59784
Differential Revision: https://reviews.llvm.org/D149854
Valentin Clement [Thu, 11 May 2023 22:14:46 +0000 (15:14 -0700)]
[flang][openacc][NFC] Update _OPENACC definition to 202011
Update _OPENACC definition to be consistent with the flang-new
driver. Currently set to 202011 which is OpenACC 3.1 specification and
is the current parser/semantic status.
Reviewed By: razvanlupusoru
Differential Revision: https://reviews.llvm.org/D150400
Vitaly Buka [Mon, 8 May 2023 23:18:32 +0000 (16:18 -0700)]
[HWSAN] Use ThreadArgRetval in HWSAN
Fixes false leaks on thread arg, retval.
Reviewed By: Enna1
Differential Revision: https://reviews.llvm.org/D150166
Lei Zhang [Thu, 11 May 2023 22:13:19 +0000 (22:13 +0000)]
[mlir][spirv] Support sub-byte integer types in type conversion
Typically GPUs cannot access memory in sub-byte manner. So for
sub-byte integer type values, we need to either expand them to
full bytes or tightly pack them. This commit adds support for
tightly packed power-of-two sub-byte types.
Sub-byte types aren't allowed in SPIR-V spec, so there are no
compute/storage capability for them like other supported integer
types. So we don't recognize sub-byte types in `spirv::ScalarType`.
We just special case them in type converter and always convert
to use i32 under the hood.
Reviewed By: kuhar
Differential Revision: https://reviews.llvm.org/D150395
Slava Zakharin [Thu, 11 May 2023 18:54:51 +0000 (11:54 -0700)]
[flang][hlfir] Fixed invalid fir.convert generated by AssociateOp codegen.
Differential Revision: https://reviews.llvm.org/D150393
Valentin Clement [Thu, 11 May 2023 21:53:19 +0000 (14:53 -0700)]
[mlir][openacc] Add host_data operation
The acc.host_data operation models the OpenACC
host_data construct (2.8). The host_data construct
defines a region where the address of data in device memory
available on the host. The operation is modeled in a similar way
than acc.data operation.
Reviewed By: razvanlupusoru, jeanPerier
Differential Revision: https://reviews.llvm.org/D150289
Razvan Lupusoru [Thu, 11 May 2023 17:42:37 +0000 (10:42 -0700)]
[flang] Inline array size call when dim is compile time constant
Instead of calling _FortranASizeDim, we can instead load extent
directly from descriptor. Add this support for cases where dim
is a known constant at compile time.
Reviewed By: clementval
Differential Revision: https://reviews.llvm.org/D150385
Jim Ingham [Thu, 11 May 2023 00:48:48 +0000 (17:48 -0700)]
We can't let GetStackFrameCount get interrupted or it will give the
wrong answer. Plus, it's useful in some places to have a way to force
the full stack to be created even in the face of
interruption. Moreover, most of the time when you're just getting
frames, you don't need to know the number of frames in the stack to
start with. You just keep calling
Thread::GetStackFrameAtIndex(index++) and when you get a null
StackFrameSP back, you're done. That's also more amenable to
interruption if you are doing some work frame by frame.
So this patch makes GetStackFrameCount always return the full count,
suspending interruption. I also went through all the places that use
GetStackFrameCount to make sure that they really needed the full stack
walk. In many cases, they did not. For instance frame select -r 10 was
getting the number of frames just to check whether cur_frame_idx + 10
was within the stack. It's better in that case to see if that frame
exists first, since that doesn't force a full stack walk, and only
deal with walking off the end of the stack if it doesn't...
I also added a test for some of these behaviors.
Differential Revision: https://reviews.llvm.org/D150236
Vitaly Buka [Mon, 8 May 2023 07:10:03 +0000 (00:10 -0700)]
[NFC][sanitizer] Add class to track thread arg and retval
We need something to keep arg and retval pointers for leak checking.
Pointers should keept alive even after thread exited, until the thread
is detached or joined.
We should not put this logic into ThreadRegistry as we need the the
same for the ThreadList of HWASAN.
Reviewed By: thurston
Differential Revision: https://reviews.llvm.org/D150104
LLVM GN Syncbot [Thu, 11 May 2023 21:33:57 +0000 (21:33 +0000)]
[gn build] Port
8e2d09c33938
Vitaly Buka [Thu, 11 May 2023 17:13:08 +0000 (10:13 -0700)]
[NFC][sanitizers] Extract BlockSignals function