Philip Reames [Mon, 3 Apr 2023 18:03:14 +0000 (11:03 -0700)]
[LV] Remmove unused default argument to isLegalGatherOrScatter [nfc]
Joseph Huber [Mon, 27 Mar 2023 15:01:12 +0000 (10:01 -0500)]
[Clang] Implicitly include LLVM libc headers for the GPU
There is currently work to support basic `libc` functionality on the
GPU. Some basic information about the projects can be found at
https://libc.llvm.org/gpu_mode.html. Typically, including the system
headers on the GPU will result in an error. For this reason the LLVM
`libc` project will generate its own headers that can be used with the
GPU.
The problem is that these headers will use the same name as the system headers.
For that reason, D146970 places it in the `llvm-libc` subfolder. In order to
still pick these files up, this patch adds changes in clang to default to
searching this directory when targeting the GPU. This lets offloading languages
such as OpenMP use the system `string.h` when compiling for the host and then
the LLVM libc `string.h` when targeting the GPU.
Depends on D146970
Reviewed By: tra
Differential Revision: https://reviews.llvm.org/D146973
Mahesh Ravishankar [Mon, 3 Apr 2023 17:31:36 +0000 (17:31 +0000)]
[mlir][MemRef] Add pattern to resolve strided metadata of `memref.get_global` operation.
This changes adds patterns to resolve the base pointer, offset, sizes
and strides of the result of a `memref.get_global` operation. Since
the operation can only result in static shaped memrefs, current
resolution kicks in only for non-zero offsets, and identity strides.
Also
- Add a separate `populateResolveExtractStridedMetadata` method that
adds just the pattern to resolve `<memref op>` ->
`memref.extract_strided_metadata` operations.
- Refactor the `SubviewFolder` pattern to allow resolving
`memref.subview` -> `memref.extract_strided_metadata`.
This allows using these patterns for cases where there are already
existing `memref.extract_strided_metadata` operations.
Reviewed By: qcolombet
Differential Revision: https://reviews.llvm.org/D147393
Mathieu Fehr [Mon, 3 Apr 2023 16:42:53 +0000 (09:42 -0700)]
[mlir] Introduce IRDL dialect
This patch introduces the IRDL dialect, which allow users to represent
dynamic dialect definitions as an MLIR program.
The IRDL dialect defines operations, attributes, and types, using
attribute constraints. For example:
```
module {
irdl.dialect @cmath {
irdl.type @complex {
%0 = irdl.is f32
%1 = irdl.is f64
%2 = irdl.any_of(%0, %1)
irdl.parameters(%2)
}
irdl.operation @norm {
%0 = irdl.any
%1 = irdl.parametric @complex<%0>
irdl.operands(%1)
irdl.results(%0)
}
}
```
This program will define a new `cmath.complex` type, which expects a single
parameter, which is either an `f32` or an `f64`. It also defines an
`cmath.norm` operation, which expects a single `cmath.complex` type as operand,
and returns a value of the underlying type. Note that like PDL (which IRDL is
heavily inspired from), both uses of `%0` are expected to be of the same attribute.
IRDL handles attributes and types with the same operations, and does this by always
wrapping types in a `TypeAttr`. This is to simplify the language.
Depends on D144690
Reviewed By: rriddle, mehdi_amini
Differential Revision: https://reviews.llvm.org/D144692
Logan Gnanapragasam [Mon, 3 Apr 2023 16:37:56 +0000 (16:37 +0000)]
[clang-tidy] ignore NRVO const variables in performance-no-automatic-move.
In the following code:
```cc
struct Obj {
Obj();
Obj(const Obj &);
Obj(Obj &&);
virtual ~Obj();
};
Obj ConstNrvo() {
const Obj obj;
return obj;
}
```
performance-no-automatic-move warns about the constness of `obj`. However, NRVO
is applied to `obj`, so the `const` should have no effect on performance.
This change modifies the matcher to exclude NRVO variables.
#clang-tidy
Reviewed By: courbet, PiotrZSL
Differential Revision: https://reviews.llvm.org/D147419
Noah Goldstein [Mon, 3 Apr 2023 16:59:32 +0000 (11:59 -0500)]
Revert "[X86] Simplify some `pternlog` intrinsics"
This reverts commit
cacc0033b12b2e6400eedd6e449644e87ec3099b.
Joseph Huber [Mon, 3 Apr 2023 16:54:48 +0000 (11:54 -0500)]
[libc] Free the GPU memory allocated in the device loaders
Summary:
This part was ignored and we just hoped that shutting down the runtime
freed these correctly. But it's best to be specific and free the memory
we've allocated.
Simon Pilgrim [Mon, 3 Apr 2023 16:17:52 +0000 (17:17 +0100)]
[X86] combineMOVMSK - merge movmsk(icmp_eq(and(x,c1),c1)) and movmsk(icmp_eq(and(x,c1),0)) folds
Use the same value tracking implementation for both, removing hardcoded PCMPEQ(AND(X,C),C) pattern so to handle bitcasted logic/constants.
Simon Pilgrim [Mon, 3 Apr 2023 16:12:11 +0000 (17:12 +0100)]
Fix MSVC "not all control paths return a value" warning. NFC.
Peter Klausler [Thu, 30 Mar 2023 20:34:32 +0000 (13:34 -0700)]
[flang] Don't allow CALL RANDOM_NUMBER(assumed-size-array)
The extents, if any, of the HARVEST= actual argument must be known
at execution time for the call to be implemented.
Differential Revision: https://reviews.llvm.org/D147391
Noah Goldstein [Mon, 3 Apr 2023 04:40:38 +0000 (23:40 -0500)]
[X86] Simplify some `pternlog` intrinsics
Currently `pternlog` intrinsics stay as a function call and are unable
to merge with other bin-ops / constant-fold.
This commit adds support for reducing all `pternlog` intrinsics to
their base logic-ops so that they can be further reduced in other
passes.
Since the x86 backend doesn't do a great job creating `vpternlog`
instructions from stray logic ops, the current logic only simplifies
in the cases were we obviously will be able to do as good or
better. As the x86 backend improves, more cases can be simplified.
Reviewed By: pengfei
Differential Revision: https://reviews.llvm.org/D145220
Noah Goldstein [Fri, 3 Mar 2023 04:12:35 +0000 (22:12 -0600)]
[X86] Add tests for simplifying pternlog intrinsics; NFC
Differential Revision: https://reviews.llvm.org/D145219
Noah Goldstein [Mon, 3 Apr 2023 04:40:08 +0000 (23:40 -0500)]
[InstSimplify] Extend simplifications for `(icmp ({z|s}ext X), C)` where `C` is vector
Previous logic only applied for `ConstantInt` which misses all vector
cases. New code works for splat/non-splat vectors as well. No change
to the underlying simplifications.
Reviewed By: nikic
Differential Revision: https://reviews.llvm.org/D147275
Noah Goldstein [Thu, 30 Mar 2023 21:16:46 +0000 (16:16 -0500)]
[InstSimplify] Add tests for simplifying `(icmp ({z|s}ext X), C)` where `C` is vector; NFC
Differential Revision: https://reviews.llvm.org/D147274
Peter Klausler [Thu, 30 Mar 2023 19:43:47 +0000 (12:43 -0700)]
[flang] NORM2(DIM=) argument can't be dynamically optional
The intrinsic function table entry for NORM2 treats its DIM=
argument as if it can be dynamically optional; this is wrong,
and it should be treated in the same way as DIM= is for other
transformational intrinsic functions like SUM.
Differential Revision: https://reviews.llvm.org/D147390
Peter Klausler [Wed, 29 Mar 2023 15:56:31 +0000 (08:56 -0700)]
[flang] Resolve USE vs IMPORT conflicts
When the same name is pulled into a scope more than once via
USE and IMPORT, emit an error if its resolutions are ambiguous,
or (as an extension like some other compilers) emit a portability
warning when the names all resolve to the same symbol.
Differential Revision: https://reviews.llvm.org/D147388
Jon Chesterfield [Mon, 3 Apr 2023 12:44:11 +0000 (13:44 +0100)]
[amdgpu][nfc] Refactor prior to D144233 to remove noise from diff
Cyndy Ishida [Mon, 3 Apr 2023 14:29:25 +0000 (07:29 -0700)]
[llvm][TextAPI] Ignore deployment version in target comparator
Timm Bäder [Mon, 3 Apr 2023 15:11:31 +0000 (17:11 +0200)]
[clang][Interp] Add missing static_assert message
This broke builders, e.g:
https://lab.llvm.org/buildbot/#builders/139/builds/38457
Joseph Huber [Mon, 3 Apr 2023 15:08:32 +0000 (10:08 -0500)]
[libc] Improve copying system vectors to the GPU
Summary:
This implementation was buggy and inefficient. Fine-grained memory can
only be allocated on a page-level granularity. Which means that each
allocated string used about 4096 bytes. This is wasteful in general, and
also allowed for buggy behaviour. The previous copying of the
environment vector only worked because the large buffer size meant that
we would typically have a null byte after the allocated memory. However
this would break if the vector was larger than a page. This patch
allocates everything into a single buffer. It makes it easier to free,
use, and it more correct.
Timm Bäder [Fri, 17 Feb 2023 15:56:47 +0000 (16:56 +0100)]
[clang][Interp] Ignore StaticAssertDecls
They have already been handled before, but we can't just return false
when we encounter one.
Differential Revision: https://reviews.llvm.org/D144272
Alexey Bataev [Mon, 3 Apr 2023 13:50:07 +0000 (06:50 -0700)]
[SLP]Reorder counters for same values, if the root node is reordered.
The counters for the repeated scalars are ordered in the natural order,
but the original scalars might be reordered during SLP graph reordering
and this order can be dropped. Need to use the scalars after the
reordering, not the original ones, to emit correct code for same value
counters.
Timm Bäder [Sun, 5 Feb 2023 07:39:40 +0000 (08:39 +0100)]
[clang][Interp][NFC] Refactor VisitDeclRefExpr
Make it clearer that we only need to check for variables and parameters
if we don't have the easy case. Also only do the IsReference check if
necessary.
Nikita Popov [Mon, 3 Apr 2023 14:32:59 +0000 (16:32 +0200)]
[Clang] Update test checks (NFC)
These were affected by
9b5ff4436e446e9df97ee37b3bcf9ba029c7d9aa.
Kadir Cetinkaya [Mon, 3 Apr 2023 14:26:06 +0000 (16:26 +0200)]
[include-cleaner] Treat member operator calls as implicit
26ff268b80c589fd9f71c1c214af77cd972642ca treated member operator calls
as explicit, while trying to treat them the same way as regular member
expressions, which should've been implicit.
Alexey Bataev [Mon, 3 Apr 2023 14:15:14 +0000 (07:15 -0700)]
[SLP][NFC]Add a test for reordered scalars with not reordered reuse coefficient.
Simon Pilgrim [Mon, 3 Apr 2023 14:07:11 +0000 (15:07 +0100)]
[X86] combineMOVMSK - fold movmsk(icmp_eq(and(x,c1),c1)) -> movmsk(shl(x,c2)) iff pow2splat(c1)
We already have a similar fold for movmsk(icmp_eq(and(x,c1),0)) which we can probably merge this with, but it will involve generalizing a lot of the knownbits code
Simon Pilgrim [Mon, 3 Apr 2023 13:30:32 +0000 (14:30 +0100)]
[X86] MatchVectorAllZeroTest - handle icmp_eq(bitcast(vXi1 trunc(Y)),0) style reduction patterns
If we've truncated from a wider vector, then perform the all vector comparison on that with a suitable mask
There's a minor pre-SSE41 regression due to a missing movmsk(icmp_eq(and(x,c1pow2),c1pow2)) -> movmsk(shl(x,c2)) fold that will be addressed in a followup commit
Nikita Popov [Mon, 3 Apr 2023 13:51:10 +0000 (15:51 +0200)]
[EarlyCSE] Call combineMetadataForCSE() when CSEing loads
We may have to adjust metadata on the replacement load if the
metadata is poison-generating.
Nikita Popov [Mon, 3 Apr 2023 14:03:11 +0000 (16:03 +0200)]
[Local] Preserve !invariant.load of dominating instruction
Per LangRef:
> If a load instruction tagged with the !invariant.load metadata
> is executed, the memory location referenced by the load has to
> contain the same value at all points in the program where the
> memory location is dereferenceable; otherwise, the behavior is
> undefined.
As invariant.load violation is immediate undefined behavior, it
is sufficient for it to be present on the dominating load (for
the case where K does not move).
Nikita Popov [Mon, 3 Apr 2023 13:58:12 +0000 (15:58 +0200)]
[GVN] Regenerate test checks (NFC)
And add an additional metadata preservation test.
Peter Klausler [Thu, 30 Mar 2023 17:26:16 +0000 (10:26 -0700)]
[flang] Use definability tests for better PURE constraint checking
Many semantic checks for constraints related to PURE subprograms
can be implemented in terms of Semantics' "definable.h" utilities,
slightly expanded. Replace some particular PURE constraint
checks with calls to WhyNotDefinable(), except for cases that
had better specific error messages, and start checking some
missing constraints with DEALLOCATE statements and local
variable declarations.
Differential Revision: https://reviews.llvm.org/D147389
Timm Bäder [Sun, 12 Mar 2023 06:43:53 +0000 (07:43 +0100)]
[clang][Interp] Fix initializing fields after base class members
Differential Revision: https://reviews.llvm.org/D145860
Nikita Popov [Mon, 3 Apr 2023 13:51:56 +0000 (15:51 +0200)]
[EarlyCSE] Regenerate test checks (NFC)
Nikita Popov [Mon, 3 Apr 2023 13:40:56 +0000 (15:40 +0200)]
[EarlyCSE] Add metadata preservation tests (NFC)
Kadir Cetinkaya [Wed, 29 Mar 2023 12:04:45 +0000 (14:04 +0200)]
[include-cleaner] Report references to operator calls as implicit
Missing these references can result in false negatives in the used-ness
analysis and break builds.
Differential Revision: https://reviews.llvm.org/D147144
serge-sans-paille [Mon, 3 Apr 2023 13:45:55 +0000 (15:45 +0200)]
Revert "Move "auto-init" instructions to the dominator of their users"
This reverts commit
cca01008cc31a891d0ec70aff2201b25d05d8f1b.
This change breaks memory ssa checks, see https://lab.llvm.org/buildbot#builders/109/builds/60970
Timm Bäder [Sat, 11 Mar 2023 08:55:22 +0000 (09:55 +0100)]
[clang][Interp] Fix diagnostics for calling non-constexpr constructors
Differential Revision: https://reviews.llvm.org/D145841
Stefan Gränitz [Mon, 3 Apr 2023 09:41:37 +0000 (11:41 +0200)]
[Orc] Add AutoRegisterCode option for DebugObjectManagerPlugin
Configure the plugin to automatically call the debugger rendezvous breakpoint `__jit_debug_register_code()` for every translation unit (enabled) or never at all (disabled). Default API and behavior remain unchanged.
If AutoRegisterCode is turned off, it's the client's own responsibility to call the rendezvous breakpoint function at an appropriate time.
Depending on the complexity of the debugger's rendezvous breakpoint implementation, this can provide significant performance improvements in cases where many debug objects are added in sequence.
Reviewed By: lhames
Differential Revision: https://reviews.llvm.org/D147310
Nikita Popov [Mon, 3 Apr 2023 13:30:21 +0000 (15:30 +0200)]
[Local] Use combineMetadataForCSE() in patchReplacementInstruction()
patchReplacementInstruction() is used for CSE-style transforms.
Avoid the need to maintain two separate lists of known metadata IDs,
which can and do go out of sync.
Nikita Popov [Mon, 3 Apr 2023 13:26:51 +0000 (15:26 +0200)]
[Local] Add MD_fpmath to combineMetadataForCSE()
This was present in patchReplacementInstruction() but not
combineMetadataForCSE(). combineMetadata() already knows how to
merge these properly.
serge-sans-paille [Wed, 2 Nov 2022 07:52:29 +0000 (08:52 +0100)]
Move "auto-init" instructions to the dominator of their users
As a result of -ftrivial-auto-var-init, clang generates instructions to
set alloca'd memory to a given pattern, right after the allocation site.
In some cases, this (somehow costly) operation could be delayed, leading
to conditional execution in some cases.
This is not an uncommon situation: it happens ~500 times on the cPython
code base, and much more on the LLVM codebase. The benefit greatly
varies on the execution path, but it should not regress on performance.
Differential Revision: https://reviews.llvm.org/D137707
Zain Jaffal [Mon, 3 Apr 2023 13:16:46 +0000 (14:16 +0100)]
[ConstraintElimination] Add function arguments to constraint system before solving
If there is an optimisation opportunity and the function argument hasn’t been added to constraint
system through previous facts we fail to optimise it.
It might be a good idea to start the constraint system with all the function arguments added to the system
Reviewed By: fhahn
Differential Revision: https://reviews.llvm.org/D144879
David Sherwood [Wed, 29 Mar 2023 10:57:40 +0000 (10:57 +0000)]
[NFC][LoopVectorize] Add zext/sext cost tests when there is type shrinkage
Differential Revision: https://reviews.llvm.org/D147151
Guillaume Chatelet [Mon, 3 Apr 2023 13:09:39 +0000 (13:09 +0000)]
[re-reland][libc] Adds string and TestLogger classes, use them in LibcTest
This is an implementation of https://discourse.llvm.org/t/rfc-running-libc-unit-tests-as-integration-tests/69461.
Differential Revision: https://reviews.llvm.org/D147231
Emilia Dreamer [Mon, 3 Apr 2023 12:54:17 +0000 (15:54 +0300)]
[clang-format] Don't allow variable decls to have trailing return arrows
The heuristic for determining if an arrow is a trailing return arrow
looks for the auto keyword, along with parentheses. This isn't
sufficient, since it also triggers on variable declarations with an auto
type, and with an arrow operator.
This patch makes sure a function declaration is being parsed, instead of
any other declaration.
Fixes https://github.com/llvm/llvm-project/issues/61469
Reviewed By: HazardyKnusperkeks, owenpan, MyDeveloperDay
Differential Revision: https://reviews.llvm.org/D147377
Nikita Popov [Thu, 16 Mar 2023 15:59:19 +0000 (16:59 +0100)]
[LICM] Don't promote store to global even in single-thread mode
Even if there are no thread-safety concerns, we should not promote
(not guaranteed-to-execute) stores to globals without further
analysis: While the global may be writable, we may not have
provenance to perform the write. The @promote_global_noalias test
case illustrates a miscompile in the presence of a noalias pointer
to the global.
Worth noting that the load-only promotion may also not be well-defined
depending on precise semantics (we don't specify whether load
violating noalias is poison or UB -- though I believe the general
inclination is to make it poison, and only stores UB), but that's
a more general issue.
This is inspired by https://github.com/llvm/llvm-project/issues/60860,
which is a related issue with TBAA metadata.
Differential Revision: https://reviews.llvm.org/D146233
Simon Pilgrim [Mon, 3 Apr 2023 11:37:53 +0000 (12:37 +0100)]
[X86] Test coverage for icmp_eq(bitcast(vXi1 trunc(Y)),0) style reduction patterns
Add SSE41 test coverage as well
ibricchi [Mon, 3 Apr 2023 12:13:46 +0000 (14:13 +0200)]
[Pass Builder] Allow Module Inliner for full LTO
Currently there is no way to enable the module inliner when
linking with full lto. This patch enables that option.
Differential Revision: https://reviews.llvm.org/D146805
Timm Bäder [Tue, 7 Feb 2023 07:20:59 +0000 (08:20 +0100)]
[clang][Interp] Fix initializing base class members
For the given test case, we were trying to initialize a member of C,
which doesn't have any. Get the proper base pointer instead and
initialize the members there.
Differential Revision: https://reviews.llvm.org/D143466
Florian Hahn [Mon, 3 Apr 2023 11:50:01 +0000 (12:50 +0100)]
[Matrix] Fix shapes in dot product tests.
The shape arguments for the @llvm.matrix.column.major.load where
incorrect. Flip them so they are in sync with the shape of the
multiplications.
Dmitri Gribenko [Mon, 3 Apr 2023 11:04:17 +0000 (13:04 +0200)]
[bazel][libc] Add a missing string_view dependency
The dependency was introduced in
https://github.com/llvm/llvm-project/commit/
9a99afb455601aaa3a28d307c7bbcfdaad3fa4fc
Dmitri Gribenko [Mon, 3 Apr 2023 11:03:14 +0000 (13:03 +0200)]
[bazel] Run an autoformatter on libc/BUILD.bazel
Congcong Cai [Mon, 3 Apr 2023 10:41:29 +0000 (12:41 +0200)]
[clang-tidy] support unscoped enumerations in readability-static-accessed-through-instance
fixed [60810](https://github.com/llvm/llvm-project/issues/60810)
unscoped enumerations in class can also be checked by `readability-static-accessed-through-instance`
add matcher for `enumConstantDecl` to match format
```
struct {
enum { E1 };
};
```
The filter of member expression and the fix hint should be same as other condition.
Reviewed By: PiotrZSL
Differential Revision: https://reviews.llvm.org/D147315
Adrian Kuegel [Mon, 3 Apr 2023 10:52:49 +0000 (12:52 +0200)]
[mlir][spirv-cpu-runner] Add missing call to registerPassManagerCLOptions().
Also fix tests, they were not calling FileCheck.
Serguei Katkov [Mon, 3 Apr 2023 09:29:39 +0000 (16:29 +0700)]
[GuardWidening] Fix the crash while replacing the users of poison.
When we replace poison with freeze poison it might appear
that user of poison is a constant (for example vector constant).
In this case we will get that constant will get non-constant operand.
Moreover replacing poison and GlobalValue everywhere in module seems
to be overkill. So the solution will be just make a replacement
only in instructions we visited (contributing to hoisted condition).
Moreover if user of posion is constant, this constant also should need
a freeze and it does not make sense to replace poison with frozen version,
just freeze another constant.
Reviewed By: mkazantsev
Differential Revision: https://reviews.llvm.org/D147429
Nikita Popov [Mon, 3 Apr 2023 10:06:01 +0000 (12:06 +0200)]
Revert "Reland "[compiler-rt] Drop -Werror in compiler flag checks""
This reverts commit
cc90ca6f0fb8e29c8a12d15c93abb9e3839a23ca.
This still breaks the GCC build in the same way as the previous
version.
Nikita Popov [Mon, 3 Apr 2023 10:01:53 +0000 (12:01 +0200)]
[LICM] Extract helper for getClobberingMemoryAccess()
Extract a helper that does the clobber walk while taking into
account the cap. Slightly reflow things to check this first in
the store case, before we start walking over all accesses in the
loop.
Jingu Kang [Mon, 3 Apr 2023 08:25:09 +0000 (09:25 +0100)]
[AArch64] Remove redundant `mov 0` instruction for high 64-bits
If MI sets zero for high 64-bits implicitly, remove `mov 0` for high 64-bits.
For example,
%1:fpr64 = nofpexcept FCVTNv4i16 %0:fpr128, implicit $fpcr
%2:fpr64 = MOVID 0
%4:fpr128 = IMPLICIT_DEF
%3:fpr128 = INSERT_SUBREG %4:fpr128(tied-def 0), killed %2:fpr64, %subreg.dsub
%6:fpr128 = IMPLICIT_DEF
%5:fpr128 = INSERT_SUBREG %6:fpr128(tied-def 0), killed %1:fpr64, %subreg.dsub
%7:fpr128 = INSvi64lane %5:fpr128(tied-def 0), 1, killed %3:fpr128, 0
==>
%1:fpr64 = nofpexcept FCVTNv4i16 %0:fpr128, implicit $fpcr
%6:fpr128 = IMPLICIT_DEF
%7:fpr128 = INSERT_SUBREG %6:fpr128(tied-def 0), killed %1:fpr64, %subreg.dsub
Differential Revision: https://reviews.llvm.org/D147235
Stefan Gränitz [Fri, 31 Mar 2023 12:27:55 +0000 (14:27 +0200)]
[Orc] Print section load-addresses for debug objects as hex again
Apparently, the refactor in
8b1771bd9f304be39d4dcbdcccedb6d3bcd18200 broke the logic behind formatv here:
```
140736272011264 .rodata
140736272015360 .text
140736272011424 .eh_frame
```
Timm Bäder [Tue, 7 Feb 2023 09:56:53 +0000 (10:56 +0100)]
[clang][Interp] Fix derived-to-base casts for >1 levels
The GetPtrBasePop op we were using only works for direct base classes.
Differential Revision: https://reviews.llvm.org/D143480
Johannes de Fine Licht [Mon, 3 Apr 2023 09:07:55 +0000 (09:07 +0000)]
[MLIR][LLVM] Put byval static allocas in the entry block.
Reviewed By: gysit
Differential Revision: https://reviews.llvm.org/D147311
Sergei Barannikov [Sat, 1 Apr 2023 15:40:47 +0000 (18:40 +0300)]
Reland "[compiler-rt] Drop -Werror in compiler flag checks"
-Werror is redundant because CMake not only checks the
exit status, but also parses the output of try_compile.
-Wformat-security is a special case, because specifying it
without -Wformat causes gcc to emit a warning in a format
not recognized by CMake, which makes the check pass.
Jun Zhang [Mon, 3 Apr 2023 08:22:38 +0000 (16:22 +0800)]
[DAGCombiner] Fold avg(x, x) --> x
Signed-off-by: Jun Zhang <jun@junz.org>
Differential Revision: https://reviews.llvm.org/D147404
Jun Zhang [Sun, 2 Apr 2023 09:34:20 +0000 (17:34 +0800)]
Add baseline tests for D147404
Differential Revision: https://reviews.llvm.org/D147409
Signed-off-by: Jun Zhang <jun@junz.org>
Victor Perez [Fri, 31 Mar 2023 17:01:06 +0000 (18:01 +0100)]
[mlir][llvm] Drop `ResumeOp::verify()` function
In patch https://reviews.llvm.org/rG478bd0735fc094d3af37e9791df5118a402ae7a7,
this function was changed so that it always returns `success()`. Drop this
and explicitly state it won't be generated in the `.td` file and explain
`llvm.resume` restrictions will be checked in `LLVMFuncOp::verify()`.
Differential Revision: https://reviews.llvm.org/D147342
Martin Braenne [Mon, 3 Apr 2023 07:02:48 +0000 (07:02 +0000)]
[clang][dataflow][NFC] Share code between Environment ctor and pushCallInternal().
The deduplicated code is moved into initVars().
As an added bonus, pushCallInternal() now also gets the "Add all fields
mentioned in default member initializers" behavior, which apparently had been
added to the Environment ctor but not pushCallInternal().
Reviewed By: xazax.hun, ymandel
Differential Revision: https://reviews.llvm.org/D147326
Nikita Popov [Mon, 3 Apr 2023 08:17:38 +0000 (10:17 +0200)]
Revert "[compiler-rt] Quote multiple warning flags in check_cxx_compiler_flag invocation"
This reverts commit
88c744e7dfaa9ce67dc2b30dea7713e054399d17.
This breaks the GCC build and is already discussed on the revision.
Guillaume Chatelet [Mon, 3 Apr 2023 07:47:15 +0000 (07:47 +0000)]
Revert D147231 "[reland][libc] Adds string and TestLogger classes, use them in LibcTest"
Build bot detected a memory leak.
This reverts commit
b82d04ea4b4f26037be369f101ae7011975df486.
Guillaume Chatelet [Mon, 3 Apr 2023 07:34:35 +0000 (07:34 +0000)]
[reland][libc] Adds string and TestLogger classes, use them in LibcTest
This is an implementation of https://discourse.llvm.org/t/rfc-running-libc-unit-tests-as-integration-tests/69461.
Differential Revision: https://reviews.llvm.org/D147231
Job Noorman [Mon, 3 Apr 2023 07:30:32 +0000 (09:30 +0200)]
[JITLink][NFC] Make Block const in alignToBlock
Block is not mutated so can be made const.
Reviewed By: lhames
Differential Revision: https://reviews.llvm.org/D147316
Jean Perier [Mon, 3 Apr 2023 07:21:01 +0000 (09:21 +0200)]
[flang] Add TODO for creation of polymorphic temporary
The current code is wrong: it is doing an alloca with the declared
type instead of the dynamic type, leading to undefined behavior
when the dynamic type and declared type differ and the temporary
is later used.
This also introduces some `fir.alloca none` for unlimited polymorphic that
are not allocating the right thing at all.
Add TODOs for now, the correct thing to do will probably be to use the
runtime (like AssignTemporary), but since this happens in code doing
"mold" temp allocation, I first need to check if there is a need for "mold"
temporary creation not followed by an assign, or if this can be combined
with the assign instead (for HLFIR, it is pretty easy combine this from as_expr
codegen, not sure for the current lowering).
Differential Revision: https://reviews.llvm.org/D147333
Jean Perier [Mon, 3 Apr 2023 07:18:41 +0000 (09:18 +0200)]
[flang] preserve pointer rank in polymorphic_pointer => NULL()
The current lowering for polymorphic pointer association was not
dealing with NULL in a "context aware" fashion: it was calling the
`PointerAssociate` runtime entry point with a fir.box<none> target.
But the fir.box<none> is a descriptor for a scalar, this lead the
runtime to set the pointer rank to zero, regardless of its actual
rank.
I do not think there is a way to expose this problem with the Fortran
code currently supported by flang, because most further manipulation of
the pointer would either set the rank correctly, or do not rely on the
rank in the runtime descriptor.
However, this is incorrect, and when assumed rank are supported, the
following would have failed:
```
subroutine check_rank(p)
class(*), pointer :: p(..)
p => null()
select rank(p)
rank (1)
print *, "OK"
rank default
print *, "FAILED"
end select
end subroutine
class(*), pointer :: p(:)
p => null()
call check_rank(p)
end
```
Instead, detect NULL() in polymorphic pointer lowering and trigger the
deallocation of the pointer.
Differential Revision: https://reviews.llvm.org/D147317
Tobias Gysi [Mon, 3 Apr 2023 06:38:04 +0000 (06:38 +0000)]
[mlir] Add stack alignment to the data layout dialect.
The revision adds the stack alignment to the
data layout dialect and it extends the LLVM dialect
import and export to support the new data layout
entry.
One possible use case for the flag is the LLVM dialect
inliner. The LLVM inliner queries the flag to
determine if it is safe to update the alignment of an
existing alloca. We may want to perform the same
optimization inside of MLIR.
Reviewed By: Dinistro
Differential Revision: https://reviews.llvm.org/D147332
Ben Shi [Mon, 3 Apr 2023 05:14:43 +0000 (13:14 +0800)]
[LoongArch] Optimize 32-bit addition with ALSL_W on LoongArch64
Optimize 32-bit 'x+(y<<i)' to (ALSL_W y, x, i) on LoongArch64,
in which 'i' is in [1, 2, 3, 4].
Reviewed By: xen0n, SixWeining
Differential Revision: https://reviews.llvm.org/D147423
Adrian Kuegel [Mon, 3 Apr 2023 06:27:29 +0000 (08:27 +0200)]
[mlir] Fix ignoring return value warning.
Sheng [Mon, 3 Apr 2023 05:56:25 +0000 (13:56 +0800)]
[m68k][NFC] Remove out-of-date comment
Ben Shi [Mon, 3 Apr 2023 01:54:43 +0000 (09:54 +0800)]
[LoongArch] Optimize bitwise and with immediates
Optimize bitfield extractions retaining bit positions
from 'lu12i + addi + and' to 'bstrpick + slli'.
Reviewed By: xen0n, SixWeining
Differential Revision: https://reviews.llvm.org/D147368
Ben Shi [Sat, 1 Apr 2023 03:57:49 +0000 (11:57 +0800)]
[LoongArch][NFC] Add tests of bitwise and with immediates (for D147368)
Reviewed By: SixWeining, xen0n
Differential Revision: https://reviews.llvm.org/D147367
Qiu Chaofan [Mon, 3 Apr 2023 03:37:17 +0000 (11:37 +0800)]
[PowerPC] Lower IS_FPCLASS by test data class instruction
Power ISA 3.0 introduced new 'test data class' instructions, which
accept flags for: NaN/Infinity/Zero/Denormal. This instruction can be
used to implement custom lowering for llvm.is.fpclass, but some extra
bits provided by the intrinsic are missing (normal and QNaN/SNaN).
For those categories not natively supported, this patch uses a two-way
or three-way combination to implement correct behavior.
Reviewed By: sepavloff, shchenz
Differential Revision: https://reviews.llvm.org/D140381
Ben Shi [Sun, 2 Apr 2023 08:47:37 +0000 (16:47 +0800)]
[LoongArch] Optimize multiplication with immediates
Optimize 'x * c' to (ALSL x, (SLLI x, i0), i1) in which
c = (1 << i0) | (1 << i1).
Reviewed By: xen0n, SixWeining
Differential Revision: https://reviews.llvm.org/D147406
Ben Shi [Sun, 2 Apr 2023 08:04:23 +0000 (16:04 +0800)]
[LoongArch][NFC] Add tests of multiplication with immediates
Reviewed By: xen0n, SixWeining
Differential Revision: https://reviews.llvm.org/D147405
Craig Topper [Mon, 3 Apr 2023 02:45:36 +0000 (19:45 -0700)]
[SelectionDAG] Rename Flag->Glue. NFC
Craig Topper [Mon, 3 Apr 2023 02:14:31 +0000 (19:14 -0700)]
[Targets] Rename Flag->Glue. NFC
Long long ago Glue was called Flag, and it was never completely
renamed.
Craig Topper [Mon, 3 Apr 2023 02:14:22 +0000 (19:14 -0700)]
[X86] Rename Flag->Glue in SelectionDAG. NFC
Long long ago Glue was called Flag, and it was never completely
renamed.
More patches for other targets will follow.
Differential Revision: https://reviews.llvm.org/D147418
Kai Sasaki [Sun, 2 Apr 2023 21:36:56 +0000 (06:36 +0900)]
[mlir] Fix ignoring return value warning for Toy CLIs
After [the change](https://github.com/llvm/llvm-project/commit/
470f3cee3557974bb1820722bf82d86b8909199b) returning LogicalResult from applyPassManagerCLIOptions, the warning message is shown in the Toy CLIs saying it's not using the returned values. We can check the result and return non-zero value as the pass failure.
```
/Users/sasaki/dev/llvm-project/mlir/examples/toy/Ch3/toyc.cpp:118:5: warning: ignoring return value of function declared with 'nodiscard' attribute [-Wunused-result]
applyPassManagerCLOptions(pm);
^~~~~~~~~~~~~~~~~~~~~~~~~ ~~
1 warning generated.
[473/485] Building CXX object tools/mlir/examples/toy/Ch4/CMakeFiles/toyc-ch4.dir/toyc.cpp.o
/Users/sasaki/dev/llvm-project/mlir/examples/toy/Ch4/toyc.cpp:119:5: warning: ignoring return value of function declared with 'nodiscard' attribute [-Wunused-result]
applyPassManagerCLOptions(pm);
^~~~~~~~~~~~~~~~~~~~~~~~~ ~~
1 warning generated.
[477/485] Building CXX object tools/mlir/examples/toy/Ch5/CMakeFiles/toyc-ch5.dir/toyc.cpp.o
/Users/sasaki/dev/llvm-project/mlir/examples/toy/Ch5/toyc.cpp:122:3: warning: ignoring return value of function declared with 'nodiscard' attribute [-Wunused-result]
applyPassManagerCLOptions(pm);
^~~~~~~~~~~~~~~~~~~~~~~~~ ~~
1 warning generated.
[479/485] Building CXX object tools/mlir/examples/toy/Ch6/CMakeFiles/toyc-ch6.dir/toyc.cpp.o
/Users/sasaki/dev/llvm-project/mlir/examples/toy/Ch6/toyc.cpp:139:3: warning: ignoring return value of function declared with 'nodiscard' attribute [-Wunused-result]
applyPassManagerCLOptions(pm);
^~~~~~~~~~~~~~~~~~~~~~~~~ ~~
1 warning generated.
[481/485] Building CXX object tools/mlir/examples/toy/Ch7/CMakeFiles/toyc-ch7.dir/toyc.cpp.o
/Users/sasaki/dev/llvm-project/mlir/examples/toy/Ch7/toyc.cpp:139:3: warning: ignoring return value of function declared with 'nodiscard' attribute [-Wunused-result]
applyPassManagerCLOptions(pm);
^~~~~~~~~~~~~~~~~~~~~~~~~ ~~
1 warning generated.
```
Reviewed By: mehdi_amini
Differential Revision: https://reviews.llvm.org/D147402
Craig Topper [Sun, 2 Apr 2023 21:12:08 +0000 (14:12 -0700)]
[TableGen] Rename InFlag/OutFlag->InGlue/OutGlue. NFC
Flag was renamed to Glue a long time ago, but rename was incomplete.
Craig Topper [Sun, 2 Apr 2023 21:04:56 +0000 (14:04 -0700)]
[TableGen] clang-format DAGISelMatcherOpt.cpp. NFC
Joshua Cao [Sun, 2 Apr 2023 20:58:51 +0000 (13:58 -0700)]
[mlir][doc] rename MemRefDataFlowOpt -> AffineScalarReplacement
Renamed in https://reviews.llvm.org/D104190, but missed in docs
Felix Schneider [Sun, 2 Apr 2023 20:24:36 +0000 (13:24 -0700)]
[mlir] [Linalg] Limit Detensorize pass to FunctionOpInterface
The linalg-detensorize Pass can only be run on FunctionOpInterface Ops and will crash when run on other ops. The TableGen definition of the pass did not enforce that.
Github issue here: https://github.com/llvm/llvm-project/issues/61845
Reviewed By: mehdi_amini
Differential Revision: https://reviews.llvm.org/D147384
Simon Pilgrim [Sun, 2 Apr 2023 19:56:54 +0000 (20:56 +0100)]
[X86] truncateAVX512SetCCNoBWI - pass SDLoc argument by const-ref
Craig Topper [Sun, 2 Apr 2023 18:38:26 +0000 (11:38 -0700)]
[TableGen] Avoid creating a ScopeMatcher full of nullptrs.
The call to FactorNodes will catch it and remove it, but it's easy
to catch at creation.
Remove the now unnecessary null checks from a loop in factor nodes.
Simon Pilgrim [Sun, 2 Apr 2023 18:16:24 +0000 (19:16 +0100)]
[X86] combineX86ShufflesConstants - move hasOneUse check as late as possible. NFC.
We only need to check hasOneUse if we're optimizing for size, so move the call at the end of the if check.
Simon Pilgrim [Sun, 2 Apr 2023 17:29:37 +0000 (18:29 +0100)]
[X86] lowerShuffleOfExtractsAsVperm - move hasOneUse checks to the end of the match. NFCI.
Check the cheap parts of the pattern first, and make the more expensive hasOneUse() call as late as possible.
Prem Chintalapudi [Sun, 2 Apr 2023 17:29:52 +0000 (10:29 -0700)]
[MCJIT] Set VMA to code address in PerfJITEventListener.
VMA should default to CodeAddr, not 0, as specified here:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/tools/perf/Documentation/jitdump-specification.txt
Reviewed By: lhames
Differential Revision: https://reviews.llvm.org/D146496
Simon Pilgrim [Sun, 2 Apr 2023 17:07:01 +0000 (18:07 +0100)]
[X86] Move hasOneUse check on PCMPGT(X,-1) -> PCMPGT(0,X) inversion folds to the end of the match. NFCI.
Check the cheap parts of the pattern first, and make the more expensive hasOneUse() call as late as possible.
Lang Hames [Sun, 2 Apr 2023 16:41:47 +0000 (09:41 -0700)]
[ORC] Add a generic bootstrap key-value store to SimpleRemoteEPC.
SimpleRemoteEPC already included a "bootstrap symbols map" that could be used
to communicate the addresses of symbols needed for JIT bootstrap. The new
bootstrap map can be used to communicate arbitrary bootstrap values (encoded as
SPS buffers).
The bootstrap symbols map is kept as distinct becasue bootstrap symbols are
significant, and having a known value type for them allows for better debug
logging (we know how to render the values) and tooling (e.g. utils for adding
all bootstrap symbols to a JITDylib).
Simon Pilgrim [Sun, 2 Apr 2023 16:43:16 +0000 (17:43 +0100)]
[X86] combineExtractVectorElt - call hasOneUse() as late as possible. NFCI.
MMX conversion is very unlikely, so check the value types first, and make the more expensive hasOneUse() call as late as possible.
Piotr Zegar [Sun, 2 Apr 2023 15:49:27 +0000 (15:49 +0000)]
[clang-tidy] Fix findNextTokenSkippingComments & rangeContainsExpansionsOrDirectives
findNextTokenSkippingComments is actually a endless loop,
implementing it correctly.
rangeContainsExpansionsOrDirectives were skiping every second
token, if there were no whitespaces bettwen tokens.
Reviewed By: carlosgalvezp
Differential Revision: https://reviews.llvm.org/D146881
Guillaume Chatelet [Sun, 2 Apr 2023 16:02:00 +0000 (16:02 +0000)]
Revert D147231 "[libc] Adds string and TestLogger classes, use them in LibcTest"
Does not build with gcc.
This reverts commit
fc5ae0a7a45bdb5251f3dad3fc07047f987ca447.