Tobias Hieta [Wed, 17 May 2023 14:59:41 +0000 (16:59 +0200)]
[NFC][Py Reformat] Reformat python files in the rest of the dirs
This is an ongoing series of commits that are reformatting our
Python code. This catches the last of the python files to
reformat. Since they where so few I bunched them together.
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: jhenderson, #libc, Mordante, sivachandra
Differential Revision: https://reviews.llvm.org/D150784
Tobias Hieta [Thu, 25 May 2023 09:16:01 +0000 (11:16 +0200)]
[NFC] Add libcxx python reformat SHA to .git-blame-ignore-revs
Tobias Hieta [Wed, 17 May 2023 09:09:29 +0000 (11:09 +0200)]
[NFC][Py Reformat] Reformat python files in libcxx/libcxxabi
This is an ongoing series of commits that are reformatting our
Python code.
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: #libc, kwk, Mordante
Differential Revision: https://reviews.llvm.org/D150763
Nikita Popov [Thu, 25 May 2023 09:11:42 +0000 (11:11 +0200)]
Revert "[SelectionDAG] Handle NSW for ADD/SUB in computeKnownBits()"
This reverts commit
b66551370fdfc6f357ae0d77237119d2b1077b62.
This has exposed a pre-existing miscompile, reported in
https://reviews.llvm.org/D150769#4370467.
Douglas Yung [Thu, 25 May 2023 09:01:50 +0000 (02:01 -0700)]
Revert "[-Wunsafe-buffer-usage] Group variables associated by pointer assignments"
This reverts commit
ee6b08e99375fc48d1e5848704a66c2e8e57eb3b.
One of the added tests warn-unsafe-buffer-usage-multi-decl-warnings.cpp does
not seem to be deterministic, and seems to be especially problematic on Windows.
Failures of this one test on llvm-clang-x86_64-sie-win:
- https://lab.llvm.org/buildbot/#/builders/216/builds/21758
- https://lab.llvm.org/buildbot/#/builders/216/builds/21761
- https://lab.llvm.org/buildbot/#/builders/216/builds/21762
- https://lab.llvm.org/buildbot/#/builders/216/builds/21765
- https://lab.llvm.org/buildbot/#/builders/216/builds/21770
- https://lab.llvm.org/buildbot/#/builders/216/builds/21771
- https://lab.llvm.org/buildbot/#/builders/216/builds/21773
- https://lab.llvm.org/buildbot/#/builders/216/builds/21776
- https://lab.llvm.org/buildbot/#/builders/216/builds/21777
- https://lab.llvm.org/buildbot/#/builders/216/builds/21778
- https://lab.llvm.org/buildbot/#/builders/216/builds/21779
Other random bot failures:
- https://lab.llvm.org/buildbot/#/builders/65/builds/9821
- https://lab.llvm.org/buildbot/#/builders/65/builds/9822
- https://lab.llvm.org/buildbot/#/builders/65/builds/9824
- https://lab.llvm.org/buildbot/#/builders/119/builds/13440
- https://lab.llvm.org/buildbot/#/builders/119/builds/13442
- https://lab.llvm.org/buildbot/#/builders/119/builds/13444
- https://lab.llvm.org/buildbot/#/builders/119/builds/13445
- https://lab.llvm.org/buildbot/#/builders/60/builds/12156
- https://lab.llvm.org/buildbot/#/builders/60/builds/12157
- https://lab.llvm.org/buildbot/#/builders/60/builds/12160
Alexandros Lamprineas [Wed, 24 May 2023 11:31:05 +0000 (12:31 +0100)]
[FuncSpec] Enable specialization of literal constants.
To do so we have to tweak the cost model such that specialization
does not trigger excessively.
Differential Revision: https://reviews.llvm.org/D150649
Martin Braenne [Tue, 23 May 2023 09:35:52 +0000 (09:35 +0000)]
[clang][dataflow] Add support for return values of reference type.
This patch changes the way `Environment::ReturnLoc` is set: Whereas previously it was set by the caller, it is now set by the callee (obviously, as we otherwise would not be able to return references).
The patch also introduces `Environment::ReturnVal`, which is used for non-reference-type return values. This allows these to be handled with the correct value category semantics; see also https://discourse.llvm.org/t/70086, which describes the ongoing migration to strict value category semantics.
Depends On D150776
Reviewed By: ymandel, xazax.hun
Differential Revision: https://reviews.llvm.org/D151194
Luke Lau [Wed, 24 May 2023 23:48:56 +0000 (00:48 +0100)]
[RISCV] Don't reduce vslidedown's VL in rotations
Even though we only need to write to the bottom NumElts - Rotation
elements for the vslidedown.vi, we can save an extra vsetivli toggle if
we just keep the wide VL.
(I may be missing something here: is there a reason why we want to explicitly keep the vslidedown narrow?)
Reviewed By: craig.topper
Differential Revision: https://reviews.llvm.org/D151390
sgokhale [Thu, 25 May 2023 08:24:47 +0000 (13:54 +0530)]
[CodeGen][ShrinkWrap] Enable PostShrinkWrap by default
This is an attempt to reland D42600 and enabling this optimisation by default.
This also resolves the issue pointed out in the context of PGO build.
Differential Revision: https://reviews.llvm.org/D42600
Simon Tatham [Wed, 24 May 2023 08:28:33 +0000 (09:28 +0100)]
-fsanitize=function: fix alignment fault on Arm targets.
Function pointers are checked by loading a prefix structure from just
before the function's entry point. However, on Arm, the function
pointer is not always exactly equal to the address of the entry point,
because Thumb function pointers have the low bit set to tell the BX
instruction to enter them in Thumb state. So the generated code loads
from an odd address and suffers an alignment fault.
Fixed by clearing the low bit of the function pointer before
subtracting 8.
Differential Revision: https://reviews.llvm.org/D151308
Nikita Popov [Mon, 22 May 2023 12:21:56 +0000 (14:21 +0200)]
[KnownBits] Add support for nuw/nsw on shifts
Implement precise nuw/nsw support in the KnownBits implementation,
replacing the rather crude handling in ValueTracking.
Differential Revision: https://reviews.llvm.org/D151208
John Demme [Thu, 25 May 2023 08:01:51 +0000 (08:01 +0000)]
[mlir] Removing unnecessary includes from Memref dialect
`MemRefMemorySlot.cpp` had two unused includes without a cmake
dependency on the dialects they were in. Led to build failures.
Nikita Popov [Thu, 27 Apr 2023 13:11:02 +0000 (15:11 +0200)]
Reapply [SCEV] Replace IsAvailableOnEntry with block disposition
This exposed an issue in SCEVExpander/LCSSA, which has been fixed
in D150681.
-----
As far as I understand, the IsAvailableOnEntry() function basically
implements the same functionality as the properlyDominates() block
disposition. The primary difference (apart from a weaker
implementation) seems to be in this comment at the top:
// Checks if the SCEV S is available at BB. S is considered available at BB
// if S can be materialized at BB without introducing a fault.
However, I don't really understand why there would be such a
requirement. It's my understanding that SCEV explicitly does not
care about trapping udiv instructions itself, and it's the job of
SCEVExpander's isSafeToExpand() to make sure these don't get
expanded if they may trap.
Differential Revision: https://reviews.llvm.org/D149344
Kadir Cetinkaya [Wed, 24 May 2023 12:22:43 +0000 (14:22 +0200)]
[clangd] Dont run raw-lexer for OOB source locations
We can get stale source locations from preamble, make sure we don't
access those locations without checking first.
Fixes https://github.com/clangd/clangd/issues/1636.
Differential Revision: https://reviews.llvm.org/D151321
Nikita Popov [Tue, 16 May 2023 15:05:58 +0000 (17:05 +0200)]
[SCEVExpander] Remember phi nodes inserted by LCSSA construction
SCEVExpander keeps track of all instructions it inserted. However,
it currently misses some phi nodes created during LCSSA construction.
Fix this by collecting these into another argument.
This also removes the IRBuilder argument, which was added for
essentially the same purpose, but only handles the root LCSSA nodes,
not those inserted by SSAUpdater.
This was reported as a regression on D149344, but the reduced test
case also reproduces without it.
Differential Revision: https://reviews.llvm.org/D150681
Mehdi Amini [Thu, 25 May 2023 04:52:05 +0000 (21:52 -0700)]
Fix MLIR bytecode loading of resources
The bytecode reader didn't handle properly the case where resource names
conflicted and were renamed, leading to orphan handles in the IR as well
as overwriting the exiting resources.
Differential Revision: https://reviews.llvm.org/D151408
Mehdi Amini [Thu, 25 May 2023 05:01:48 +0000 (22:01 -0700)]
Specialize OwningOpRef::operator-> to work with pointers like Operation*
This just simplifies user code.
Differential Revision: https://reviews.llvm.org/D151407
Mehdi Amini [Wed, 24 May 2023 23:13:02 +0000 (16:13 -0700)]
Fix MLIR bytecode reader for unregistered dialects
At the moment we accept (in tests) unregistered dialects and in particular:
"new_processor_id_and_range"()
where there is no `.` separator. We probably will remove support for this
from the parser, but for now we're adding compatibility support in the
reader.
Differential Revision: https://reviews.llvm.org/D151386
Matthias Springer [Thu, 25 May 2023 07:22:19 +0000 (09:22 +0200)]
[mlir][IR] Improve `clone` function return type of shaped types
There are `clone` overloads that take a shape as a parameter. These overloads are guaranteed to return a ranked shaped type.
`TensorType::clone`/`BaseMemRefType::clone` used to always return a `TensorType`/`BaseMemRefType`. The variants that take a shape parameter now return a `RankedTensorType`/`MemRefType`. Better static type information can make extra casts at the call site obsolete.
E.g.:
```
{TensorType/RankedTensorType} t;
t.clone({1, 2}) // now returns RankedTensorType instead of TensorType
```
Also improve documentation for `clone`.
Differential Revision: https://reviews.llvm.org/D150865
wangpc [Thu, 25 May 2023 07:22:12 +0000 (15:22 +0800)]
[RISCV][NFC] Simplify decoding code of disassembler
The decoding parts are reduplicative, we add a macro to simplify
the code.
Reviewed By: craig.topper, kito-cheng
Differential Revision: https://reviews.llvm.org/D151309
Hristo Hristov [Tue, 23 May 2023 20:03:35 +0000 (23:03 +0300)]
[libc++][spaceship][NFC] Improved consistency - removed `inline` specifier for `operator<=>`
Removed `inline` specifier for consistency as discussed in D148416 previously.
Reviewed By: #libc, Mordante
Differential Revision: https://reviews.llvm.org/D151248
Martin Braenne [Tue, 23 May 2023 07:32:10 +0000 (07:32 +0000)]
[clang][dataflow] Add a `ControlFlowContext::build()` overload taking a `FunctionDecl`.
This is the most common use case, so it makes sense to have a specific overload for it.
Reviewed By: xazax.hun
Differential Revision: https://reviews.llvm.org/D151183
Matthias Springer [Thu, 25 May 2023 07:12:06 +0000 (09:12 +0200)]
[mlir][Transforms][NFC] GreedyPatternRewriteDriver: Add worklist class
Encapsulate all worklist-related functionality in a separate `Worklist` class. This makes the remaining code more readable and allows for custom worklist implementations (e.g., a randomized worklist for fuzzing pattern application: D142447).
Differential Revision: https://reviews.llvm.org/D151345
Petr Hosek [Tue, 16 May 2023 07:18:26 +0000 (07:18 +0000)]
[lld][ELF] Implement –print-memory-usage
This option was introduced in GNU ld in
https://sourceware.org/legacy-ml/binutils/2015-06/msg00086.html and is
often used in embedded development. This change implements this option
in LLD matching the GNU ld output verbatim.
Differential Revision: https://reviews.llvm.org/D150644
Matthias Springer [Thu, 25 May 2023 06:45:05 +0000 (08:45 +0200)]
[mlir][sparse] Fix incorrect API usage in RewritePatterns
Incorrect API usage was detected by
`MLIR_ENABLE_EXPENSIVE_PATTERN_API_CHECKS`.
Differential Revision: https://reviews.llvm.org/D151302
eopXD [Thu, 25 May 2023 06:47:04 +0000 (23:47 -0700)]
[Clang][RISCV] Update all RVV intrinsic auto-generated test case with new script. NFC
This commit updates all intrinsics under
`clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated` because the
new script of `update_llc_test_checks.py` is generating many new lines
differently.
This NFC commit updates the test cases in a whole batch.
Signed-off by: eop Chen <eop.chen@sifive.com>
Siva Chandra Reddy [Wed, 24 May 2023 17:42:40 +0000 (17:42 +0000)]
[libc][bazel] Add targets for fmod* and scalbn*.
Reviewed By: lntue
Differential Revision: https://reviews.llvm.org/D151354
Siva Chandra Reddy [Wed, 24 May 2023 05:22:40 +0000 (05:22 +0000)]
[libc] Make hermetic test depend on the unit test if it exists.
We want to do this so that build system like ninja don't end up running
the hermetic and unit tests in parallel. Running in parallel can cause
problems for tests which read/write disk files as the hermetic and unit
tests can end up stepping on each other.
Reviewed By: jhuber6
Differential Revision: https://reviews.llvm.org/D151291
Shao-Ce SUN [Thu, 25 May 2023 06:04:02 +0000 (14:04 +0800)]
[RISCV][CodeGen] Support Zdinx on RV32 codegen
This patch was split from D122918 .
Co-Author: @StephenFan @liaolucy @realqhc
Reviewed By: craig.topper
Differential Revision: https://reviews.llvm.org/D149743
Sergei Barannikov [Wed, 24 May 2023 04:12:53 +0000 (07:12 +0300)]
[MC] Check if register is non-null before calling isSubRegisterEq (NFCI)
D151036 adds an assertions that prohibits iterating over sub- and
super-registers of a null register. This is already the case when
iterating over register units of a null register, and worked by
accident for sub- and super-registers.
Reviewed By: Amir
Differential Revision: https://reviews.llvm.org/D151285
Siva Chandra Reddy [Wed, 24 May 2023 07:28:50 +0000 (07:28 +0000)]
[libc] Rearrange error and signal tables.
This is largely a cosmetic change done with a few goals:
1. Reduce the conditionals in picking the correct set of tables for the
platform.
2. Avoid exposing, for example Linux errors, when building for non-Linux
platforms. This also prevents build failures when Linux errors are not
defined on the target non-Linux platform.
3. Some "_table" suffixes have been removed to avoid repeated
occurance of "table" like "tables/linux_error_table.h".
Reviewed By: michaelrj
Differential Revision: https://reviews.llvm.org/D151367
Aart Bik [Thu, 25 May 2023 03:47:54 +0000 (20:47 -0700)]
[mlir][sparse][gpu] various cuSparse refinements
(1) keep all cuSparse ops on single stream without wait() in right order
(2) use more type precise memref types for COO
(3) use ToTensor on resulting memref (even though it folds away again)
Reviewed By: K-Wu
Differential Revision: https://reviews.llvm.org/D151404
Md Abdullah Shahneous Bari [Thu, 25 May 2023 04:35:08 +0000 (21:35 -0700)]
[mlir][spirv] Add OpConvertPtrToU and OpConvertUToPtr ops
Add the definitions and necessary verifications of these Ops.
Reviewed By: antiagainst
Differential Revision: https://reviews.llvm.org/D151074
Thurston Dang [Thu, 25 May 2023 04:09:35 +0000 (04:09 +0000)]
sanitizer-common: fix buildbot by temporarily disabling release_to_os test for tsan
This has been causing substantial redness in the buildbots e.g.,
https://lab.llvm.org/buildbot/#/builders/239/builds/2405
which already contained a commit to deflake the test
(https://github.com/llvm/llvm-project/commit/
3afd1b2c357fb5353084a736d885af60115d6acb).
Temporarily disabling the test to prevent this error from
hiding other potential problems.
Sergei Barannikov [Wed, 24 May 2023 05:02:50 +0000 (08:02 +0300)]
[MIPS] Check if register is non-null before calling isSuperOrSubRegisterEq (NFCI)
D151036 adds an assertions that prohibits iterating over sub- and
super-registers of a null register. This is already the case when
iterating over register units of a null register, and worked by
accident for sub- and super-registers.
Reviewed By: MaskRay
Differential Revision: https://reviews.llvm.org/D151288
Sergei Barannikov [Wed, 24 May 2023 09:57:07 +0000 (12:57 +0300)]
[CodeGen] Skip null physical register in AntiDepBreaker (NFCI)
D151036 adds an assertions that prohibits iterating over sub- and
super-registers of a null register. This is already the case when
iterating over register units of a null register, and worked by
accident for sub- and super-registers.
The only place where the assertion is currently triggering is in
CriticalAntiDepBreaker::ScanInstruction. Other places are changed
in case new assertions are added and should be harmless otherwise.
Sergei Barannikov [Thu, 25 May 2023 02:47:00 +0000 (05:47 +0300)]
Revert "[CodeGen] Skip null physical register in AntiDepBreaker (NFCI)"
This reverts commit
d41f6cff030369d99ad62bbdba732552c08d48a6.
The commit contained wrong phabricator link.
Manna, Soumi [Thu, 25 May 2023 02:13:12 +0000 (19:13 -0700)]
[NFC][CLANG] Fix issue with dereference null return value found by Coverity
Reported by Static Analyzer Tool, Coverity:
Inside "SemaDeclCXX.cpp" file, in clang::Sema::CheckExplicitlyDefaultedSpecialMember(clang::CXXMethodDecl *, clang::Sema::CXXSpecialMember, clang::SourceLocation): Return value of function which returns null is dereferenced without checking.
//returned_null: getAs returns nullptr (checked 117 out of 143 times).
// var_assigned: Assigning: Type = nullptr return value from getAs.
const FunctionProtoType *Type = MD->getType()->getAs<FunctionProtoType>();
//Dereference null return value (NULL_RETURNS)
//dereference: Dereferencing a pointer that might be nullptr Type when calling getReturnType.
ReturnType = Type->getReturnType();
//Dereference null return value (NULL_RETURNS)
//dereference: Dereferencing a pointer that might be nullptr Type when calling getParamType.
QualType ArgType = ExpectedParams ? Type->getParamType(0) : QualType();
This patch uses castAs instead of getAs which will assert if the type doesn't match.
Reviewed By: erichkeane
Differential Revision: https://reviews.llvm.org/D151281
Rahul Kayaith [Thu, 25 May 2023 02:05:06 +0000 (22:05 -0400)]
[mlir][python] Hook up PyRegionList.__iter__ to PyRegionIterator
This fixes a -Wunused-member-function warning, at the moment
`PyRegionIterator` is never constructed by anything (the only use was
removed in D111697), and iterating over region lists is just falling
back to a generic python iterator object.
Reviewed By: stellaraccident
Differential Revision: https://reviews.llvm.org/D150244
Enna1 [Thu, 25 May 2023 02:11:02 +0000 (10:11 +0800)]
[gcov] Add nosanitize metadata to memory access instructions inserted by emitProfileNotes()
This patch adds nosantize metadata to memory access instructions inserted by gcov emitProfileNotes(), making sanitizers skip these instructions when gcov and sanitizer are used together.
Reviewed By: nickdesaulniers
Differential Revision: https://reviews.llvm.org/D150460
Rahul Kayaith [Thu, 25 May 2023 01:51:36 +0000 (21:51 -0400)]
[mlir][python] Allow specifying block arg locations
Currently blocks are always created with UnknownLoc's for their arguments. This
adds an `arg_locs` argument to all block creation APIs, which takes an optional
sequence of locations to use, one per block argument. If no locations are
supplied, the current Location context is used.
Reviewed By: ftynse
Differential Revision: https://reviews.llvm.org/D150084
Vitaly Buka [Thu, 11 May 2023 23:53:30 +0000 (16:53 -0700)]
[NFC][sanitizer] Rename *ThreadRegistry functions
Reviewed By: thurston
Differential Revision: https://reviews.llvm.org/D150407
Hanhan Wang [Thu, 25 May 2023 00:41:29 +0000 (17:41 -0700)]
[mlir][linalg] Only apply masking on xfer_write when needed.
If the input vector sizes are as same as tensor.pad result shape, the
masking is not needed. Otherwise, the masking is needed and the masking
operands should be as same as tensor.empty op.
Reviewed By: dcaballe
Differential Revision: https://reviews.llvm.org/D151391
Vitaly Buka [Wed, 24 May 2023 23:51:12 +0000 (16:51 -0700)]
[hwasan] Fix allocator_interface implementation
__sanitizer_get_current_allocated_bytes had as body, but allocator
caches were not registered to collect stats. It's done by
SizeClassAllocator64LocalCache::Init().
Reviewed By: thurston
Differential Revision: https://reviews.llvm.org/D151389
Aart Bik [Wed, 24 May 2023 20:09:59 +0000 (13:09 -0700)]
[mlir][sparse][gpu] fixed typo in CUDA test
Test was printing same result twice
Reviewed By: K-Wu
Differential Revision: https://reviews.llvm.org/D151370
Kai Sasaki [Thu, 25 May 2023 00:19:32 +0000 (09:19 +0900)]
[mlir][linalg] Treat quant dialect type as unsupported in named conversion
Since the tosa-to-linalg conversion does not support the quant dialect type, we can treat it as unsupported instead of crash. Issue was reported https://github.com/llvm/llvm-project/issues/62367
Reviewed By: springerm
Differential Revision: https://reviews.llvm.org/D151296
Craig Topper [Thu, 25 May 2023 00:25:33 +0000 (17:25 -0700)]
[RISCV] Add a special caes to performVFMADD_VLCombine to support the multiplicand being the same value.
The one use check will fail if there are two uses in the same
instruction. Add a special case for this.
Thurston Dang [Wed, 24 May 2023 20:19:34 +0000 (20:19 +0000)]
hwasan: refactor order of macros in hwasan_platform_interceptors.h [NFC]
Currently, the header file contains all the undefs, followed by all the
define X 0. This will be inconvenient for re-enabling interceptors,
because we would need to comment out (or delete) the corresponding macros
in two different places.
This patch groups together the macros for each function.
Additionally, it adds the suggestion that interceptors should be
re-enabled by commenting out (not deleting) the macros.
Differential Revision: https://reviews.llvm.org/D151371
Vitaly Buka [Sat, 13 May 2023 01:43:53 +0000 (18:43 -0700)]
[AST] Construct Capture objects before use
Msan reports https://reviews.llvm.org/P8308
The reason is if PointerIntPair is not properly
constructed, setPointer uses Info::updatePointer
on uninitialized value.
Reviewed By: #clang, rsmith
Differential Revision: https://reviews.llvm.org/D150504
Md Abdullah Shahneous Bari [Thu, 25 May 2023 00:08:30 +0000 (17:08 -0700)]
[mlir][spirv] Support import/export Functions and GlobalVariables
"LinkageAttributes" decoration allow a SPIR-V module to import
external functions and global variables, or export functions or
global variables for other SPIR-V modules to link against and use.
Import/export capability is extremely important when using outside
libraries (e.g., intrinsic libraries).
Added decorations:
- LinkageAttributes
Reviewed By: antiagainst
Differential Revision: https://reviews.llvm.org/D148749
eopXD [Thu, 25 May 2023 00:02:48 +0000 (17:02 -0700)]
[Clang][RISCV] Update vaadd.c test case with new script. NFC
Vitaly Buka [Wed, 24 May 2023 23:48:01 +0000 (16:48 -0700)]
[sanitizer] Deflake test
Craig Topper [Wed, 24 May 2023 23:37:16 +0000 (16:37 -0700)]
[RISCV] Remove some unneeded vmacc isel patterns.
The patterns are for a vpmerge with an all 1s mask, but we are
able to handle that with a post-isel peephole recently.
Slava Zakharin [Wed, 24 May 2023 20:53:25 +0000 (13:53 -0700)]
[flang][hlfir][NFC] Make BOZ lowering a TODO.
This change just turns the unhandled BOZ fatal error into TODO
like in non-HLFIR path.
Vitaly Buka [Wed, 24 May 2023 23:19:30 +0000 (16:19 -0700)]
[sanitizer] Use atomic_fetch_add instead of load/store
Vitaly Buka [Wed, 24 May 2023 23:12:00 +0000 (16:12 -0700)]
[NFC][sanitizer] Remove unused method
Rashmi Mudduluru [Wed, 24 May 2023 22:45:56 +0000 (15:45 -0700)]
[-Wunsafe-buffer-usage] Group variables associated by pointer assignments
Differential Revision: https://reviews.llvm.org/D145739
Vitaly Buka [Wed, 24 May 2023 22:59:26 +0000 (15:59 -0700)]
[sanitizer] Lazy initialize AllocatorGlobalStats
This allow to have no InitLinkerInitialized and let AllocatorGlobalStats
accept registration before allocator initialization.
Lei Zhang [Wed, 24 May 2023 22:48:54 +0000 (17:48 -0500)]
[mlir][capi] Drop mlirShapedTypeGetTypeID
ShapedType is a virtual type rather than a concrete one.
We don't have an implmentation for this API too.
Reviewed By: makslevental
Differential Revision: https://reviews.llvm.org/D151376
Peng Sun [Wed, 24 May 2023 22:20:56 +0000 (15:20 -0700)]
[mlir][tosa] Update the limit of 62 on shift.
Aligns the shift requirement with the TOSA specification.
Reviewed By: eric-k256
Differential Revision: https://reviews.llvm.org/D151113
Nikolas Klauser [Wed, 24 May 2023 22:33:38 +0000 (15:33 -0700)]
[libc++][PSTL] Add a simple std::thread backend
This is just to test that the PSTL works with parallelization. This is not supposed to be a production-ready backend.
Reviewed By: ldionne, #libc
Spies: EricWF, arichardson, libcxx-commits
Differential Revision: https://reviews.llvm.org/D150284
Nishant Patel [Wed, 24 May 2023 22:23:19 +0000 (15:23 -0700)]
[mlir][spirv] Add a missing pattern to MathToSPIRV Conversion pass
The MathToSPIRV conversion pass missed out a pattern for converting
math::AbsIOP to spirv::CLSAbsOp
Reviewed By: antiagainst
Differential Revision: https://reviews.llvm.org/D151378
Sterling Augustine [Wed, 24 May 2023 22:11:07 +0000 (15:11 -0700)]
remove useless visibility spec from bazel build.
Amara Emerson [Wed, 24 May 2023 21:46:20 +0000 (14:46 -0700)]
Pre-commit a min/max idiom breakage test for D149918
Tai Ly [Wed, 24 May 2023 21:43:02 +0000 (14:43 -0700)]
[TOSA] Refactor TosaMakeBroadcastable pass
This refactors and exposes EqualizeRanks utility function
from within TosaMakeBroadcastable pass so it may be used to
reshape operator inputs to equal ranks.
Signed-off-by: Tai Ly <tai.ly@arm.com>
Differential Revision: https://reviews.llvm.org/D150283
Advenam Tacet [Wed, 24 May 2023 21:26:14 +0000 (14:26 -0700)]
[2a/3][ASan][libcxx] std::deque annotations
This revision is a part of a series of patches extending AddressSanitizer C++ container overflow detection capabilities by adding annotations, similar to those existing in std::vector, to std::string and `std::deque` collections. These changes allow ASan to detect cases when the instrumented program accesses memory which is internally allocated by the collection but is still not in-use (accesses before or after the stored elements for `std::deque`, or between the size and capacity bounds for `std::string`).
The motivation for the research and those changes was a bug, found by Trail of Bits, in a real code where an out-of-bounds read could happen as two strings were compared via a std::equals function that took `iter1_begin`, `iter1_end`, `iter2_begin` iterators (with a custom comparison function). When object `iter1` was longer than `iter2`, read out-of-bounds on `iter2` could happen. Container sanitization would detect it.
This revision introduces annotations for `std::deque`. Each chunk of the container can now be annotated using the `__sanitizer_annotate_double_ended_contiguous_container` function, which was added in the rG1c5ad6d2c01294a0decde43a88e9c27d7437d157. Any attempt to access poisoned memory will trigger an ASan error. Although false negatives are rare, they are possible due to limitations in the ASan API, where a few (usually up to 7) bytes before the container may remain unpoisoned. There are no false positives in the same way as with `std::vector` annotations.
This patch only supports objects (deques) that use the standard allocator. However, it can be easily extended to support all allocators, as suggested in the D146815 revision.
Furthermore, the patch includes the addition of the `is_double_ended_contiguous_container_asan_correct` function to libcxx/test/support/asan_testing.h. This function can be used to verify whether a `std::deque` object has been correctly annotated.
Finally, the patch extends the unit tests to verify ASan annotations (added LIBCPP_ASSERTs).
If a program is compiled without ASan, all helper functions will be no-ops. In binaries with ASan, there is a negligible performance impact since the code from the change is only executed when the deque container changes in size and it’s proportional to the change. It is important to note that regardless of whether or not these changes are in use, every access to the container's memory is instrumented.
Reviewed By: #libc, philnik
Spies: vitalybuka, hans, mikhail.ramalho, Enna1, #sanitizers, philnik, libcxx-commits
Differential Revision: https://reviews.llvm.org/D132092
Valentin Clement [Wed, 24 May 2023 21:00:24 +0000 (14:00 -0700)]
[flang][openacc][NFC] Remove unused function
Now that operands have moved to the new data operands lowering, this
function is not used anymore.
Reviewed By: vzakhari
Differential Revision: https://reviews.llvm.org/D151357
Matt Arsenault [Sat, 10 Dec 2022 13:28:11 +0000 (08:28 -0500)]
AMDGPU: Replace certain llvm.amdgcn.class uses with llvm.is.fpclass
Most transforms should now be performed on llvm.is.fpclass. Unlike the
generic intrinsic, this supports variable test masks.
Mehdi Amini [Wed, 24 May 2023 20:30:49 +0000 (13:30 -0700)]
Fix MLIR bytecode reading of i0 IntegerAttr
The move of the bytecode serialization to be tablegen driven in
https://reviews.llvm.org/D144820 added a new condition in the reading
path that forbid 0-sized integer, even though we still produce them.
Fix #62920
Differential Revision: https://reviews.llvm.org/D151372
AdityaK [Wed, 17 May 2023 18:30:13 +0000 (11:30 -0700)]
[libc++, std::vector] call the optimized version of __uninitialized_allocator_copy for trivial types
See: https://github.com/llvm/llvm-project/issues/61987
Fix suggested by: @philnik and @var-const
Reviewers: philnik, ldionne, EricWF, var-const
Differential Revision: https://reviews.llvm.org/D147741
Testing:
ninja check-cxx check-clang check-llvm
Benchmark Testcases (BM_CopyConstruct, and BM_Assignment) added.
performance improvement:
Run on (8 X 4800 MHz CPU s)
CPU Caches:
L1 Data 48 KiB (x4)
L1 Instruction 32 KiB (x4)
L2 Unified 1280 KiB (x4)
L3 Unified 12288 KiB (x1)
Load Average: 1.66, 3.02, 2.43
Comparing build-runtimes-base/libcxx/benchmarks/vector_operations.libcxx.out to build-runtimes/libcxx/benchmarks/vector_operations.libcxx.out
Benchmark Time CPU Time Old Time New CPU Old CPU New
----------------------------------------------------------------------------------------------------------------------------------------
BM_ConstructSize/vector_byte/5140480 +0.0362 +0.0362 116906 121132 116902 121131
BM_CopyConstruct/vector_int/5140480 -0.4563 -0.4577 1755224 954241 1755330 951987
BM_Assignment/vector_int/5140480 -0.0222 -0.0220 990045 968095 989917 968125
BM_ConstructSizeValue/vector_byte/5140480 +0.0308 +0.0307 116970 120567 116977 120573
BM_ConstructIterIter/vector_char/1024 -0.0831 -0.0831 19 17 19 17
BM_ConstructIterIter/vector_size_t/1024 +0.0129 +0.0131 88 89 88 89
BM_ConstructIterIter/vector_string/1024 -0.0064 -0.0018 54455 54109 54208 54112
OVERALL_GEOMEAN -0.0845 -0.0842 0 0 0 0
FYI, the perf improvements for BM_CopyConstruct due to this patch is mostly subsumed by the https://reviews.llvm.org/D149826. However this patch still adds value by converting copy to memmove (the second testcase).
Before the patch:
```
define linkonce_odr dso_local void @_ZNSt3__16vectorIiNS_9allocatorIiEEE18__construct_at_endIPiS5_EEvT_T0_m(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef %1, ptr noundef %2, i64 noundef %3) local_unnamed_addr #4 comdat align 2 {
%5 = getelementptr inbounds %"class.std::__1::vector", ptr %0, i64 0, i32 1
%6 = load ptr, ptr %5, align 8, !tbaa !12
%7 = icmp eq ptr %1, %2
br i1 %7, label %16, label %8
8: ; preds = %4, %8
%9 = phi ptr [ %13, %8 ], [ %1, %4 ]
%10 = phi ptr [ %14, %8 ], [ %6, %4 ]
%11 = icmp ne ptr %10, null
tail call void @llvm.assume(i1 %11)
%12 = load i32, ptr %9, align 4, !tbaa !14
store i32 %12, ptr %10, align 4, !tbaa !14
%13 = getelementptr inbounds i32, ptr %9, i64 1
%14 = getelementptr inbounds i32, ptr %10, i64 1
%15 = icmp eq ptr %13, %2
br i1 %15, label %16, label %8, !llvm.loop !16
16: ; preds = %8, %4
%17 = phi ptr [ %6, %4 ], [ %14, %8 ]
store ptr %17, ptr %5, align 8, !tbaa !12
ret void
}
```
After the patch:
```
define linkonce_odr dso_local void @_ZNSt3__16vectorIiNS_9allocatorIiEEE18__construct_at_endIPiS5_EEvT_T0_m(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef %1, ptr noundef %2, i64 noundef %3) local_unnamed_addr #4 comdat align 2 {
%5 = getelementptr inbounds %"class.std::__1::vector", ptr %0, i64 0, i32 1
%6 = load ptr, ptr %5, align 8, !tbaa !12
%7 = ptrtoint ptr %2 to i64
%8 = ptrtoint ptr %1 to i64
%9 = sub i64 %7, %8
%10 = ashr exact i64 %9, 2
tail call void @llvm.memmove.p0.p0.i64(ptr align 4 %6, ptr align 4 %1, i64 %9, i1 false)
%11 = getelementptr inbounds i32, ptr %6, i64 %10
store ptr %11, ptr %5, align 8, !tbaa !12
ret void
}
```
This is due to the optimized version of uninitialized_allocator_copy function.
Vitaly Buka [Wed, 24 May 2023 20:23:10 +0000 (13:23 -0700)]
[NFC][HWASAN] Rename AllocatorSwallowThreadLocalCache
Vitaly Buka [Wed, 24 May 2023 07:31:15 +0000 (00:31 -0700)]
[lsan] Fix allocator_interface implementation
__sanitizer_get_current_allocated_bytes had as body, but allocator
caches were not registered to collect stats. It's done by
SizeClassAllocator64LocalCache::Init().
Reviewed By: thurston
Differential Revision: https://reviews.llvm.org/D151355
Ramkumar Ramachandra [Thu, 1 Dec 2022 10:28:51 +0000 (11:28 +0100)]
mlir/tosa: supply better documentation for tosa.pad
This patch modifies the description in TosaOps.td, taking into account
all the arguments, and supplying examples.
Signed-off-by: Ramkumar Ramachandra <r@artagnon.com>
Differential Revision: https://reviews.llvm.org/D139089
Eugene Burmako [Wed, 24 May 2023 20:03:36 +0000 (22:03 +0200)]
[MLIR] Update Bazel build to finish moving PDL-related transform ops into an extension
https://reviews.llvm.org/D151104 moved PDL-related transform ops into an extension and updated the Bazel build, but one tiny thing fell through the cracks - TransformOpsPyFiles also needs to include the newly introduced `mlir/python/mlir/dialects/_transform_pdl_extension_ops_ext.py`.
Reviewed By: saugustine, bkramer
Differential Revision: https://reviews.llvm.org/D151368
Craig Topper [Wed, 24 May 2023 19:15:23 +0000 (12:15 -0700)]
LLVM_FALLTHROUGH => [[fallthrough]]. NFC
Reviewed By: MaskRay
Differential Revision: https://reviews.llvm.org/D150996
Thurston Dang [Fri, 19 May 2023 21:32:54 +0000 (21:32 +0000)]
sanitizer_common: add test that calls wcslen
This is a very simple test that calls wsclen. There are currently no other HWASan tests that call wsclen, which is why the wcslen interceptor issue (triggered by https://reviews.llvm.org/D150708 and fixed in https://reviews.llvm.org/D150909) was only detected by stage2/hwasan check on the buildbots. With this test, the issue would have been caught by stage1 check-sanitizer, with a more obvious diagnosis.
Reviewed By: vitalybuka
Differential Revision: https://reviews.llvm.org/D151000
Florian Hahn [Wed, 24 May 2023 19:16:41 +0000 (20:16 +0100)]
[IRGen] Handle infinite cycles in findDominatingStoreToReturnValue.
If there is an infinite cycle in the IR, the loop will never exit. Keep
track of visited basic blocks in a set and return nullptr if a block is
visited again.
Fixes #62830.
Reviewed By: rjmccall
Differential Revision: https://reviews.llvm.org/D151076
Slava Zakharin [Wed, 24 May 2023 18:18:43 +0000 (11:18 -0700)]
[flang][hlfir] Create temporary for passing constant expression for actual arg.
Even though the constant expression actual argument is not definable,
and the associated dummy argument is not definable, the compiler may produce
implicit copies into the memory storage associated with the constant expression.
For example, a constant expression storage passed by reference to a subprogram
may be used for implicit copy-out:
```
subroutine sub(i, n)
interface
subroutine sub2(i)
integer :: i(*)
end subroutine sub2
end interface
integer :: i(n)
call sub2(i(3::2)) ! copy-out after the call will write to 'i'
end subroutine sub
subroutine test
call sub((/1,2,3,4,5/), 5)
end subroutine test
```
If we pass a reference to constant expression storage to 'sub' directly,
the copy-out inside 'sub' will try to write into readonly memory.
Reviewed By: jeanPerier
Differential Revision: https://reviews.llvm.org/D151271
Artem Belevich [Tue, 23 May 2023 19:17:50 +0000 (12:17 -0700)]
[CUDA] Fix wrappers for sm_80 functions
Previous implementation provided wrappers for the internal implementations used
by CUDA headers. However, clang does not include those, so we need to provide
the public functions instead.
Differential Revision: https://reviews.llvm.org/D151243
Erich Keane [Thu, 18 May 2023 15:26:25 +0000 (08:26 -0700)]
Make dereferencing a void* a hard-error instead of warn-as-error
Clang 16 changed to consider dereferencing a void* to be a
warning-as-error, plus made this an error in SFINAE contexts, since this
resulted in incorrect template instantiation. When doing so, the Clang
16 documentation was updated to reflect that this was likely to change
again to a non-disablable error in the next version.
As there has been no response to changing from a warning to an error, I
believe this is a non-controversial change.
This patch changes this to be an Error, consistent with the standard and
other compilers.
This was discussed in this RFC:
https://discourse.llvm.org/t/rfc-can-we-stop-the-extension-to-allow-dereferencing-void-in-c/65708
Differential Revision: https://reviews.llvm.org/D150875
Michael Liao [Wed, 24 May 2023 18:08:43 +0000 (14:08 -0400)]
Fix shared library build again from 1c9a800. NFC
Sterling Augustine [Wed, 24 May 2023 18:04:42 +0000 (11:04 -0700)]
Disable MLIR_ENABLE_EXPENSIVE_PATTERN_API_CHECKS for bazel builds.
Med Ismail Bennani [Wed, 24 May 2023 17:52:47 +0000 (10:52 -0700)]
[lldb] Disable `watchpoint_callback.test` temporarily on darwin
This test started failing on the green-dragon bot, but after some
investigation, it doesn't have anything to do with Lua.
If we use a variable watchpoint with a condition using a scope variable,
if we go out-of-scope, the watpoint remains active which can the
expression evaluator to fail to parse the watchpoint condition (because
of the missing varible bindings).
For now, we should disable this test until we come up with a fix for it.
rdar://
109574319
Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
Vitaly Buka [Wed, 24 May 2023 17:41:56 +0000 (10:41 -0700)]
[NFC] New line in test
Valentin Clement [Wed, 24 May 2023 17:44:40 +0000 (10:44 -0700)]
[mlir][openacc] Use new reduction design in acc.loop
Use the new reduction design in acc.loop operation.
Depends on D151146
Reviewed By: razvanlupusoru, jeanPerier
Differential Revision: https://reviews.llvm.org/D151164
Vitaly Buka [Wed, 24 May 2023 17:35:34 +0000 (10:35 -0700)]
[msan] Implement __sanitizer_get_current_allocated_bytes
__sanitizer_get_current_allocated_bytes had as body, but allocator
caches were not registered to collect stats. It's done by
SizeClassAllocator64LocalCache::Init().
Reviewed By: kstoimenov
Differential Revision: https://reviews.llvm.org/D151352
Philip Reames [Wed, 24 May 2023 17:40:06 +0000 (10:40 -0700)]
[RISCV] Use vfslide1down for build_vectors of non-constant floats
This adds the vfslide1down (and vfslide1up for consistency) nodes. These mostly parallel the existing vslide1down/up nodes. (See note below on instruction semantics.) We then use the vfslide1down in build_vector lowering instead of going through the stack.
The specification is more than a bit vague on the meaning of these instructions. All we're given is "The vfslide1down instruction is defined analogously, but sources its scalar argument from an f register."
We have to combine this with a general note at the beginning of section 10. Vector Arithmetic Instruction Formats which reads: "For floating-point operations, the scalar can be taken from a scalar f register. If FLEN > SEW, the value in the f registers is checked for a valid NaN-boxed value, in which case the least-signicant SEW bits of the f register are used, else the canonical NaN value is used. Vector instructions where any floating-point vector operand’s EEW is not a supported floating-point type width (which includes when FLEN < SEW) are reserved.".
Note that floats are NaN-boxed when D is implemented.
Combining that all together, we're fine as long as the element type matches the vector type - which is does by construction. We shouldn't have legal vectors which hit the reserved encoding case. An assert is included, just to be careful.
Differential Revision: https://reviews.llvm.org/D151347
Valentin Clement [Wed, 24 May 2023 17:39:00 +0000 (10:39 -0700)]
[mlir][openacc] Add check for the private list in acc.serial
Add the missing check on private list information. The
check is the same than the one done for acc.parallel.
Depends on D151146
Reviewed By: razvanlupusoru, jeanPerier
Differential Revision: https://reviews.llvm.org/D151149
Valentin Clement [Wed, 24 May 2023 17:39:00 +0000 (10:39 -0700)]
[mlir][openacc] Add check for the private list in acc.serial
Add the missing check on private list information. The
check is the same than the one done for acc.parallel.
Depends on D151146
Reviewed By: razvanlupusoru, jeanPerier
Differential Revision: https://reviews.llvm.org/D151149
Aaron Ballman [Wed, 24 May 2023 17:38:27 +0000 (13:38 -0400)]
Publicly document the C & C++ Language WG meetings
We've been hosting these meetings regularly for a while now, so this
begins advertising the meetings more widely.
Valentin Clement [Wed, 24 May 2023 17:38:01 +0000 (10:38 -0700)]
[mlir][openacc] Use new reduction design in acc.parallel
After D150818 the reduction clause is represented
with a acc.reduction.recipe operation and an operand.
This patch updates the acc.parallel op for the new design.
Reviewed By: razvanlupusoru, jeanPerier
Differential Revision: https://reviews.llvm.org/D151146
Philip Reames [Wed, 24 May 2023 17:31:54 +0000 (10:31 -0700)]
[RISCV][InsertVSETVLI] Support constant VLs larger than immediate encoding
The immediate field on the vsetivli is fairly limited. For larger vectors, we end up having to materialize a constant in a register. We hadn't plumbed the infrastructure to treat such materialized constants as constants for purpose of vsetvli elimination.
I only bothered to handle LI. We could extend this to LUI sequences, but well, 2048 elements is probably enough for all practical fixed length vector codegen. :)
The test delta does point out a related problem. At LMUL8, we see increased register allocation pressure, and we should probably either a) address register allocation remat, or b) be less aggressive about eliminating vsetvlis at high lmul. Note that high LMUL code is not generated much by default.
Differential Revision: https://reviews.llvm.org/D151212
Kazu Hirata [Wed, 24 May 2023 17:36:38 +0000 (10:36 -0700)]
[mlir] Fix a warning
This patch fixes:
mlir/lib/Dialect/GPU/IR/GPUDialect.cpp:175:2: error: extra ';'
outside of a function is incompatible with C++98
[-Werror,-Wc++98-compat-extra-semi]
Amy Kwan [Wed, 24 May 2023 17:09:19 +0000 (12:09 -0500)]
Fix shared library build from 1c9a800.
Fix the shared library build failure on clang-ppc64le-rhel from 1c9a800 as seen
in: https://lab.llvm.org/buildbot/#/builders/57/builds/27080/steps/6/logs/stdio
Stefan Pintilie [Wed, 24 May 2023 16:33:54 +0000 (12:33 -0400)]
[PowerPC] Remove asserts from the disassembler.
My previous patch had added a couple of asserts to the disassembler.
The problem with this is that the disassembler is not just used for the
text section it is also used to disassemble the data section of an
object where the bytes do not necessarily represent instructions. If the
data in the data section happens to look like an illegal instruction
then llvm-objdump will assert on data because it is finding an illegal
instruction that is not actually an instruction at all.
Reviewed By: nemanjai, #powerpc
Differential Revision: https://reviews.llvm.org/D149711
Vitaly Buka [Wed, 24 May 2023 17:21:03 +0000 (10:21 -0700)]
[tsan] Implement __sanitizer_purge_allocator
Alex Langford [Tue, 23 May 2023 17:20:35 +0000 (10:20 -0700)]
[DebugInfo] Follow-up to D151001
I landed D151001 before it had gotten sign-off from all the reviewers.
This is a follow-up to address the additional feedback.
Differential Revision: https://reviews.llvm.org/D151233
Kun Wu [Wed, 24 May 2023 16:43:38 +0000 (09:43 -0700)]
[mlir] [gpu] [sparse] refined SparseHandle type
Reviewed By: aartbik
Differential Revision: https://reviews.llvm.org/D151014
Kelvin Li [Tue, 23 May 2023 23:02:49 +0000 (19:02 -0400)]
[flang] Support for PowerPC vector type
The following PowerPC vector type syntax is added:
VECTOR ( element-type-spec )
where element-type-sec is integer-type-spec, real-type-sec or unsigned-type-spec.
Two opaque types (__VECTOR_PAIR and __VECTOR_QUAD) are also added.
A finite set of functionalities are implemented in order to support the new types:
1. declare objects
2. declare function result
3. declare type dummy arguments
4. intrinsic assignment between the new type objects (e.g. v1=v2)
5. reference functions that return the new types
Submit on behalf of @tislam @danielcchen
Authors: @tislam @danielcchen
Differential Revision: https://reviews.llvm.org/D150876
Vitaly Buka [Wed, 24 May 2023 16:58:32 +0000 (09:58 -0700)]
Revert "[PowerPC] Simplify fp-to-int store optimization"
Breaks https://lab.llvm.org/buildbot/#/builders/18/builds/9118
This reverts commit
8064caf83fb166b709bfe0e7641c5181341cb064.