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.
Sterling Augustine [Wed, 24 May 2023 16:35:53 +0000 (09:35 -0700)]
Fix bazel build for https://reviews.llvm.org/D144552
Differential Revision: https://reviews.llvm.org/D151346
Jay Foad [Wed, 24 May 2023 11:00:01 +0000 (12:00 +0100)]
[MachineVerifier] Try harder to verify LiveIntervals
Verify the LiveIntervals analysis after a pass that claims to preserve
it, even if there are no further passes (apart from the verifier itself)
that would use the analysis.
Fixes https://github.com/llvm/llvm-project/issues/46217
Differential Revision: https://reviews.llvm.org/D129208
John Brawn [Wed, 17 May 2023 15:52:26 +0000 (16:52 +0100)]
[clang] Don't define predefined macros multiple times
Fix several instances of macros being defined multiple times
in several targets. Most of these are just simple duplication in a
TargetInfo or OSTargetInfo of things already defined in
InitializePredefinedMacros or InitializeStandardPredefinedMacros,
but there are a few that aren't:
* AArch64 defines a couple of feature macros for armv8.1a that are
handled generically by getTargetDefines.
* CSKY needs to take care when CPUName and ArchName are the same.
* Many os/target combinations result in __ELF__ being defined twice.
Instead define __ELF__ just once in InitPreprocessor based on
the Triple, which already knows what the object format is based
on os and target.
These changes shouldn't change the final result of which macros are
defined, with the exception of the changes to __ELF__ where if you
explicitly specify the object type in the triple then this affects
if __ELF__ is defined, e.g. --target=i686-windows-elf results in it
being defined where it wasn't before, but this is more accurate as an
ELF file is in fact generated.
Differential Revision: https://reviews.llvm.org/D150966
Marco Elver [Wed, 24 May 2023 16:24:55 +0000 (18:24 +0200)]
Fix "[HWASan] Use ASM_WRAPPER_NAME instead of __interceptor_*"
Fix typo introduced in
2f1e2a6b1ca2.
Reported-by: RamNalamothu
Tom Eccles [Wed, 24 May 2023 16:05:25 +0000 (16:05 +0000)]
Revert "[flang] use greedy mlir driver for stack arrays pass"
This reverts commit
74c2ec50f393bad8b31d0dd0bd8b2ff44d361198.
This caused a regression building spec2017 with -Ofast.
Matthias Braun [Fri, 19 May 2023 19:47:37 +0000 (12:47 -0700)]
Bump coalescing limit
This bumps the "large-interval-freq-threshold" limit in the register
coalescer to 256. The limit was introduced in
https://reviews.llvm.org/D59143 without much justify for the particular
value "100", so I hope bumping it is ok.
This change is motivated by bad codegen for the popular crc32c
algorithm; the code is often based/copied from this implementation:
https://github.com/htot/crc32c/blob/master/crc32c/crc32intelc.cc which
uses a duffs-device pattern with 128 switch-cases. There are examples in
RocksDB (https://github.com/facebook/rocksdb/blob/main/util/crc32c.cc)
and Folly
(https://github.com/facebook/folly/blob/main/folly/hash/detail/Crc32cDetail.cpp)
which are important use cases for us.
Differential Revision: https://reviews.llvm.org/D150994
Nemanja Ivanovic [Wed, 24 May 2023 16:12:19 +0000 (11:12 -0500)]
[PowerPC] Do not attempt to combine fptoui without FPCVT
Commit
8064caf83fb166b709bfe0e7641c5181341cb064 added a call
to a function that performs this combine without checking whether
the target supports FPCVT. This caused asserts to trip on BE bots
as the default target does not have this feature.
Mark de Wever [Tue, 23 May 2023 15:22:12 +0000 (17:22 +0200)]
[libc++] Fixes clang-tidy plugin for clang-tidy 17.
When using with clang-tidy 17 Node.getAttrName() sometimes returns a
nullptr. This caused segfaults in the CI.
Reviewed By: philnik, #libc
Differential Revision: https://reviews.llvm.org/D151224
Kazu Hirata [Wed, 24 May 2023 16:05:50 +0000 (09:05 -0700)]
[ARM] Remove unused functions isExpImmValue, isExpImm, and isInvertedExpImm
The last uses were removed by:
commit
772e4931932270a82f38c83d4344c800b2f54eff
Author: Simon Tatham <simon.tatham@arm.com>
Date: Thu Jan 23 11:53:27 2020 +0000
Differential Revision: https://reviews.llvm.org/D151299
Matt Arsenault [Wed, 24 May 2023 14:59:42 +0000 (15:59 +0100)]
AMDGPU: Add some new tests for class undef/poison handling
Nikolas Klauser [Wed, 24 May 2023 15:46:13 +0000 (08:46 -0700)]
Revert "[libc++] Apply _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION only in classes that we have instantiated externally"
This reverts commit
b3c9150062dc4264afb4a3d2790f071c1ebe0743.
There were unexpected breakages downstream. @EricWF is investigating.
Harsh Menon [Wed, 24 May 2023 01:03:59 +0000 (18:03 -0700)]
[mlir] Add support for multiple uses in transform.structured.fuse_into_containing_op
In the tile and fuse of the first extract use, we add support
for scenarios where the results of the tiled op have uses
that are dominated by the scf.for_all. Specifically, we replace
the scf.for_all with a new scf.for_all that has an additional
shared_out and add the appropriate parallel insert slice op.
Differential Revision: https://reviews.llvm.org/D151275
Vitaly Buka [Wed, 24 May 2023 07:31:15 +0000 (00:31 -0700)]
[sanitizer] Add allocator_interface test
Hooks are in malloc_hook.cpp.
Mark de Wever [Wed, 17 May 2023 17:17:52 +0000 (19:17 +0200)]
[libc++][format] Removes the experimental status.
The code has been quite ready for a while now and there are no more ABI
breaking papers. So this is a good time to mark the feature as stable.
Reviewed By: #libc, ldionne
Differential Revision: https://reviews.llvm.org/D150802
Guillaume Chatelet [Wed, 24 May 2023 14:43:00 +0000 (14:43 +0000)]
[libc] simplify test for getrandom
`getrandom` is implemented as a syscall.
We don't want to test linux implementation of the syscall. We just want to verify that it reacts as expected to sensible values.
Runtime before
```
[ RUN ] LlvmLibcGetRandomTest.InvalidFlag
[ OK ] LlvmLibcGetRandomTest.InvalidFlag (took 0 ms)
[ RUN ] LlvmLibcGetRandomTest.InvalidBuffer
[ OK ] LlvmLibcGetRandomTest.InvalidBuffer (took 0 ms)
[ RUN ] LlvmLibcGetRandomTest.ReturnsSize
[ OK ] LlvmLibcGetRandomTest.ReturnsSize (took 83 ms)
[ RUN ] LlvmLibcGetRandomTest.PiEstimation
[ OK ] LlvmLibcGetRandomTest.PiEstimation (took 9882 ms)
```
Runtime after
```
[ RUN ] LlvmLibcGetRandomTest.InvalidFlag
[ OK ] LlvmLibcGetRandomTest.InvalidFlag (took 0 ms)
[ RUN ] LlvmLibcGetRandomTest.InvalidBuffer
[ OK ] LlvmLibcGetRandomTest.InvalidBuffer (took 0 ms)
[ RUN ] LlvmLibcGetRandomTest.ReturnsSize
[ OK ] LlvmLibcGetRandomTest.ReturnsSize (took 0 ms)
[ RUN ] LlvmLibcGetRandomTest.CheckValue
[ OK ] LlvmLibcGetRandomTest.CheckValue (took 0 ms)
```
Reviewed By: lntue
Differential Revision: https://reviews.llvm.org/D151336
Peter Klausler [Tue, 23 May 2023 20:55:23 +0000 (13:55 -0700)]
[flang] Fix SPACING() of very small values
SPACING() must return TINY() for zero arguments (which we do)
and also for subnormal values smaller than TINY() in absolute value,
which we get wrong. Fix folding and the runtime.
Differential Revision: https://reviews.llvm.org/D151272
Christian Ulmann [Wed, 24 May 2023 14:52:54 +0000 (14:52 +0000)]
[mlir][LLVM] Fix aliasing in intrinsic base class
This commit fixes a bug in the intrinsic base class that caused the
declaration of alias analysis attributes under a wrong condition.
Valentin Clement [Wed, 24 May 2023 14:57:38 +0000 (07:57 -0700)]
[mlir][openacc] destroy region on firstprivate.recipe is optional
The destroy region is optional but the verifier was enforcing it.
Update the verifier and make it clear in the definition.
Reviewed By: razvanlupusoru
Differential Revision: https://reviews.llvm.org/D151239
Luke Lau [Mon, 22 May 2023 16:51:32 +0000 (17:51 +0100)]
[RISCV] Scalarize constant stores of fixed vectors if small enough
For stores of small fixed-length vector constants, we can store them
with a sequence of lui/addi/sh/sw to avoid the cost of building the
vector and the vsetivli toggle, provided the constant materialization
cost isn't too high.
This subsumes the optimisation for stores of zeroes in
4dc9a2c5b93682c12d7a80bbe790b14ddb301877
(This is a reapply of
0ca13f9d2701e23af2d000a5d8f48b33fe0878b7)
Reviewed By: reames
Differential Revision: https://reviews.llvm.org/D151221
Luke Lau [Wed, 24 May 2023 14:52:19 +0000 (15:52 +0100)]
Revert "[RISCV] Scalarize constant stores of fixed vectors up to 32 bits"
This reverts commit
0ca13f9d2701e23af2d000a5d8f48b33fe0878b7.
Philip Reames [Wed, 24 May 2023 14:43:52 +0000 (07:43 -0700)]
[RISCV] Add test coverage for buildvector of FP values
Matt Arsenault [Wed, 24 May 2023 07:52:22 +0000 (08:52 +0100)]
Inline: Convert test to generated checks
Matt Arsenault [Wed, 24 May 2023 13:24:49 +0000 (14:24 +0100)]
IR: Avoid include in FMF header
Matthias Springer [Wed, 24 May 2023 14:30:57 +0000 (16:30 +0200)]
[mlir][Transforms] Fix mlir-config flag check
Boolean compiler flags (such as `DMLIR_ENABLE_EXPENSIVE_PATTERN_API_CHECKS`) show up in `mlir-config.h` as preprocessor defines that are either 0 or 1. Use `#if` instead of `#ifdef`.
This should have been part of D144552.
Luke Lau [Mon, 22 May 2023 16:51:32 +0000 (17:51 +0100)]
[RISCV] Scalarize constant stores of fixed vectors up to 32 bits
For stores of small fixed-length vector constants, we can store them
with a sequence of lui/addi/sh/sw to avoid the cost of building the
vector and the vsetivli toggle.
Note that this only handles vectors that are 32 bits or smaller, but
could be expanded to 64 bits if we know that the constant
materialization cost isn't too high.
Reviewed By: reames
Differential Revision: https://reviews.llvm.org/D151221
Luke Lau [Mon, 22 May 2023 16:49:45 +0000 (17:49 +0100)]
[RISCV] Add test cases for storing small constant vectors
Reviewed By: craig.topper
Differential Revision: https://reviews.llvm.org/D151220
Doru Bercea [Wed, 24 May 2023 14:14:43 +0000 (10:14 -0400)]
Enable up to 64 arguments for outlined regions in OpenMP device code.
Co-Author: Fabio Luporini <fabio@devitocodes.com>
Review: https://reviews.llvm.org/D150134
Jie Fu [Wed, 24 May 2023 14:21:56 +0000 (22:21 +0800)]
[MergeICmps] Fix -Wsign-compare and typos (NFC)
/data/llvm-project/llvm/lib/Transforms/Scalar/MergeICmps.cpp:623:21: error: comparison of integers of different signs: 'int' and 'size_t' (aka 'unsigne
d long') [-Werror,-Wsign-compare]
for (int i = 0; i < Comparisons.size(); i++) {
~ ^ ~~~~~~~~~~~~~~~~~~
1 error generated.
Matthias Springer [Wed, 24 May 2023 14:14:47 +0000 (16:14 +0200)]
[mlir][Transforms] GreedyPatternRewriteDriver debugging: Detect faulty patterns
Compute operation finger prints to detect incorrect API usage in RewritePatterns. Does not work for dialect conversion patterns.
Detect patterns that:
* Returned `failure` but changed the IR.
* Returned `success` but did not change the IR.
* Inserted/removed/modified ops, bypassing the rewriter. Not all cases are detected.
These new checks are quite expensive, so they are only enabled with `-DMLIR_ENABLE_EXPENSIVE_PATTERN_API_CHECKS=ON`. Failures manifest as fatal errors (`llvm::report_fatal_error`) or crashes (accessing deallocated memory). To get better debugging information, run `mlir-opt -debug` (to see which pattern is broken) with ASAN (to see where memory was deallocated).
Differential Revision: https://reviews.llvm.org/D144552
Jay Foad [Wed, 24 May 2023 11:00:01 +0000 (12:00 +0100)]
[RegisterCoalescer] Fix updating LiveIntervals in joinReservedPhysReg
Live intervals for physical registers are calculated lazily on demand.
In a case like this:
16B %0:gpr32 = IMPLICIT_DEF
32B $wzr = COPY %0
if the live interval for $wzr did not already exist then the update code
in joinReservedPhysReg would create it with a definition at 32B, which
would remain even after the COPY was deleted.
Differential Revision: https://reviews.llvm.org/D151314
Jay Foad [Fri, 5 May 2023 09:51:28 +0000 (10:51 +0100)]
[MachineVerifier] Verify liveins for live-through segments
Differential Revision: https://reviews.llvm.org/D149947
Zhongyunde [Wed, 24 May 2023 13:16:41 +0000 (21:16 +0800)]
Reland [MergeICmps] Adapt to non-eq comparisons, bugfix
1.Fix the last runtime issue as some sequent comparisons need be spilted.
For the origin equal comparisons chain, the new spilted Icmp chain will
still be end with equal, while for the new not-equal comparisons chain,
the new spilted Icmp chain will still be end with equal, so should address
this carefully, see detail wih case partial_sequent_ne
2. Fix the mismatch of last link comparison
Thanks for @aeubanks, @glandium and @ayzhao report the runtime issue
and carefully examine.
Fix https://github.com/llvm/llvm-project/issues/59740.
Reviewed By: vitalybuka
Differential Revision: https://reviews.llvm.org/D141188
Matthias Springer [Wed, 24 May 2023 13:59:29 +0000 (15:59 +0200)]
[mlir][Transforms][NFC] GreedyPatternRewriteDriver: Reformat debug logic
Do not duplicate code that is performing actual work, put debug code around it.
Differential Revision: https://reviews.llvm.org/D151207
Jay Foad [Wed, 24 May 2023 12:28:07 +0000 (13:28 +0100)]
[AMDGPU] Switch to backwards scavenging in non-spill cases
When the scavenger is not allowed to spill, the only difference between
forward and backward should be the heuristics used to pick an available
register. Forwards scavenging tries to pick a register that can be used
again later in the BB; backwards scavenging tries to pick one that can
be used earlier.
Backwards scavenging is preferred because it does not rely on accurate
kill flags.
Differential Revision: https://reviews.llvm.org/D151323
Sheng [Wed, 24 May 2023 14:02:41 +0000 (22:02 +0800)]
[clang][NFC] Add a blank line in ReleaseNotes.rst
A buildbot has failed on the absence of the blank line at the end of the bullet list.
Sheng [Wed, 24 May 2023 13:45:03 +0000 (21:45 +0800)]
[clang][Sema] Fix a crash when instantiating a non-type template argument in a dependent scope.
The type alias template is not diagnosed when instantiating an expected non-type template argument in a dependent scope, causing ICE.
Besides that, the diagnostic message has been updated to account for the fact that the function template is not the only non-type template.
Fixes #62533
Reviewed By: #clang-language-wg, erichkeane
Differential Revision: https://reviews.llvm.org/D151062
Hansang Bae [Thu, 4 May 2023 16:06:12 +0000 (11:06 -0500)]
[OpenMP][libomp] Implement KMP_DLSYM_NEXT on Windows
The interop API routines try to invoke external entries, but we did
not have support for KMP_DLSYM_NEXT on Windows. Also added proper
guards for STUB build.
Differential Revision: https://reviews.llvm.org/D149892
Clement Courbet [Wed, 24 May 2023 13:21:50 +0000 (15:21 +0200)]
[clang-tidy] Really fix rG9182c679dde7
Correct link is clang-tidy/checks/performance/no-automatic-move
Clement Courbet [Wed, 24 May 2023 13:18:11 +0000 (15:18 +0200)]
[clang-tidy]Fix rG9182c679dde7cb6480e66b9231a53d43ad03908b
Fix bad link to documentation.
Matthias Springer [Wed, 24 May 2023 13:02:56 +0000 (15:02 +0200)]
[mlir][transform] Expose transform op from TrackingListener
This allows subclasses (such as the ErrorCheckingTrackingListener in IREE) to produce better error messages.
Differential Revision: https://reviews.llvm.org/D151322
Krzysztof Parzyszek [Tue, 23 May 2023 20:08:34 +0000 (13:08 -0700)]
[Hexagon] Add more debugging options and dumps to HVC
Krzysztof Parzyszek [Tue, 23 May 2023 20:01:24 +0000 (13:01 -0700)]
[Hexagon] Remap all instructions generated for aligned address/value in HVC
Only the last instruction was remapped before.
Clement Courbet [Mon, 22 May 2023 13:05:06 +0000 (15:05 +0200)]
[clang-tidy]performance-no-automatic-move: fix false negative on `const T&&` ctors.
We were only handling `const T&`/`T&&` ctor pairs, and we were missing uref-based ctors.
Differential Revision: https://reviews.llvm.org/D151092
Matthias Springer [Wed, 24 May 2023 12:55:09 +0000 (14:55 +0200)]
[mlir][IR] Hash nesting structure in OperationFingerPrint
The following ops currently have the same finger print, even though they are different:
```
func.func @test() {
"test.foo"() ({
"test.bar"() : () -> ()
}) : () -> ()
}
```
And:
```
func.func @test() {
"test.bar"() : () -> ()
"test.foo"() ({ }) : () -> ()
}
```
The SHA1 hash used in OperationFingerPrint is order-sensitive, but the ops are hashed in the same order (post-order traversal), so the hash is the same. Switching to pre-order traversal does not solve the issue; a similar example, where IR differs just in its nesting structure, can be constructed.
The problem is solved by hashing the parent op pointer. (Alternatively, a traversal over the IR that hashes scope markers (`{}`) could be used.)
Differential Revision: https://reviews.llvm.org/D151306
Tue Ly [Tue, 23 May 2023 20:47:38 +0000 (16:47 -0400)]
[libc] Reduce the sizes of some math tests that take longest time.
Reviewed By: gchatelet
Differential Revision: https://reviews.llvm.org/D151256
Takuya Shimizu [Wed, 24 May 2023 12:11:56 +0000 (21:11 +0900)]
[clang][Sema] `-Wshadow` warns about shadowings by static local variables
This patch makes `-Wshadow` warn about the shadowings by static local variables.
Fixes https://github.com/llvm/llvm-project/issues/62850
Differential Revision: https://reviews.llvm.org/D151214
Takuya Shimizu [Wed, 24 May 2023 12:21:23 +0000 (21:21 +0900)]
Reland: [clang][AST] Print name instead of type when diagnosing uninitialized subobject in constexpr variables
This patch improves the diagnostic on uninitialized subobjects in constexpr variables by modifying the diagnostic message to display the subobject's name instead of its type.
Fixes https://github.com/llvm/llvm-project/issues/58601
Differential Revision: https://reviews.llvm.org/D146358
Alex Zinenko [Mon, 22 May 2023 14:36:58 +0000 (14:36 +0000)]
[mlir] move PDL-related transform ops into an extension
The initial bring-up of the Transform dialect relied on PDL to provide
the default handle type (`!pdl.operation`) and the matching capability.
Both are now provided natively by the Transform dialect removing the
reason to have a hard dependency on the PDL dialect and its interpreter.
Move PDL-related transform operations into a separate extension.
This requires us to introduce a dialect state extension mechanism into
the Transform dialect so it no longer needs to know about PDL constraint
functions that may be injected by extensions similarly to operations and
types. This mechanism will be reused to connect pattern application
drivers and the Transform dialect.
This completes the restructuring of the Transform dialect to remove
overrilance on PDL.
Note to downstreams: flow that are using `!pdl.operation` with Transform
dialect operations will now require `transform::PDLExtension` to be
applied to the transform dialect in order to provide the transform
handle type interface for `!pdl.operation`.
Reviewed By: springerm
Differential Revision: https://reviews.llvm.org/D151104
Joseph Huber [Mon, 22 May 2023 20:50:55 +0000 (15:50 -0500)]
[AMDGPU] Add attribute to AMDGPU ctor / dtor to indicate single threadedness
We only expect these ctor / dtor functions to be called with a single
thread. Add the appropriate attributes to indicate this to the backend.
Reviewed By: arsenm
Differential Revision: https://reviews.llvm.org/D151153
Michael Buch [Tue, 23 May 2023 23:01:47 +0000 (00:01 +0100)]
[lldb][DataFormatter] Add dereference support to libstdcpp std::shared_ptr formatter
This mimicks the implementation of the libstdcpp std::unique_ptr
formatter.
This has been attempted several years ago in
`
0789722d85cf1f1fdbe2ffb2245ea0ba034a9f94` but was reverted in
`
e7dd3972094c2f2fb42dc9d4d5344e54a431e2ce`.
The difference to the original patch is that we now maintain
a `$$dereference$$` member and we only store weak pointers
to the other children inside the synthetic frontend. This is
what the libc++ formatters do to prevent the recursion mentioned
in the revert commit.
Tue Ly [Tue, 23 May 2023 20:20:47 +0000 (16:20 -0400)]
[libc][bazel] Add log, log2, log10, log1p to bazel layout.
Add log, log2, log10, log1p and their unit tests to bazel layout.
Reviewed By: gchatelet
Differential Revision: https://reviews.llvm.org/D151252
LLVM GN Syncbot [Wed, 24 May 2023 10:54:20 +0000 (10:54 +0000)]
[gn build] Port
ced90d1ff64a
Alexandros Lamprineas [Thu, 11 May 2023 23:07:49 +0000 (00:07 +0100)]
[FuncSpec] Improve the accuracy of the cost model.
Instead of blindly traversing the use-def chain of constant arguments,
compute known constants along the way. Stop as soon as a user cannot
be replaced by a constant. Keep it light-weight by handling some basic
instruction types.
Differential Revision: https://reviews.llvm.org/D150464
Kiran Chandramohan [Wed, 24 May 2023 08:34:47 +0000 (09:34 +0100)]
Add OpenMPToLLVM conversion pattern for taskgroup
Fixes part of the issue in https://github.com/llvm/llvm-project/issues/62013
Reviewed By: psoni2628
Differential Revision: https://reviews.llvm.org/D151206
donald chen [Wed, 24 May 2023 10:05:34 +0000 (12:05 +0200)]
[mlir] [scf] Add RegionBranchOpInterface to scf.forall and scf.parallel op
Add RegionBranchOpIntefface to scf.forall and scf.parallel op to make analysis trace through subregions.
Differential Revision: https://reviews.llvm.org/D151287
Dominik Montada [Mon, 15 May 2023 09:51:30 +0000 (09:51 +0000)]
[TOSA] Fold consecutive concats on same axis
Consecutive concats that happen on the same axis can be folded into a
single, bigger concat. This patch implements this folding by
implementing the tosa::ConcatOp::fold method.
Differential Revision: https://reviews.llvm.org/D151210
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.
Differential Revision: https://reviews.llvm.org/D151288
Marco Elver [Wed, 24 May 2023 09:32:33 +0000 (11:32 +0200)]
[compiler-rt] Always use INTERCEPTOR()+ALIAS()+WRAP() to create interceptor alias
Do not open code creation of an interceptor alias to another
interceptor. Instead, use INTERCEPTOR() + ALIAS() + WRAP.
Reviewed By: dvyukov
Differential Revision: https://reviews.llvm.org/D151219
Marco Elver [Wed, 24 May 2023 09:32:28 +0000 (11:32 +0200)]
[TSan] Remove unused setjmp definitions
The __interceptor_*setjmp() definitions appear to have been defined for
the purpose of TSAN_INTERCEPT(), but on non-Mac systems, it seems
TSAN_INTERCEPT() isn't even being used anymore for setjmp.
Remove them. Nothing should call them anyway (due to CHECK-fail), so
having the linker fail is better than failing at runtime.
Reviewed By: dvyukov
Differential Revision: https://reviews.llvm.org/D151218
Marco Elver [Wed, 24 May 2023 09:32:21 +0000 (11:32 +0200)]
[HWASan] Use ASM_WRAPPER_NAME instead of __interceptor_*
Use ASM_WRAPPER_NAME to produce the name of the __interceptor_*
functions.
NFC.
Reviewed By: dvyukov
Differential Revision: https://reviews.llvm.org/D151217
Marco Elver [Wed, 24 May 2023 09:31:40 +0000 (11:31 +0200)]
[compiler-rt] Simplify ALIAS() attribute macro
Most uses of ALIAS() are in conjunction with WRAPPER_NAME().
Simplify the code and just make ALIAS() turn its argument into a string
(similar to Linux kernel's __alias macro). This in turn allows removing
WRAPPER_NAME().
NFC.
Reviewed By: dvyukov
Differential Revision: https://reviews.llvm.org/D151216
Christian Ulmann [Wed, 24 May 2023 09:05:21 +0000 (09:05 +0000)]
[mlir][transform] Fix merge_handle asm format
This commit ensures that the merge_handles operation prints its
`deduplicate` attribute as an optional keyword instead of "unit".
Reviewed By: ftynse
Differential Revision: https://reviews.llvm.org/D151310
bipmis [Wed, 24 May 2023 09:36:11 +0000 (10:36 +0100)]
[AggressiveInstCombine] Handle the nested GEP/BitCast scenario in Load Merge.
This seems to be an issue currently where there are nested/chained GEP/BitCast Pointers.
The patch generates a new GEP for the wider load to avoid dominance problems.
Differential Revision: https://reviews.llvm.org/D150864
Luke Lau [Mon, 22 May 2023 14:34:51 +0000 (15:34 +0100)]
[RISCV] Scalarize small fixed vector copies < XLEN
For small fixed-length vector copies like
vsetivli zero, 2, e16, m1, ta, ma
vle16.v v8, (a0)
vse16.v v8, (a1)
We can scalarize them if the total vector size < XLEN:
lw a0, 0(a0)
sw a0, 0(a1)
This patch adds a DAG combine to do so, reusing much of the existing
logic in https://reviews.llvm.org/D150717
Reviewed By: reames
Differential Revision: https://reviews.llvm.org/D151103
Luke Lau [Mon, 22 May 2023 14:32:24 +0000 (15:32 +0100)]
[RISCV] Add test for small vector copies
Reviewed By: reames
Differential Revision: https://reviews.llvm.org/D151211