platform/upstream/llvm.git
15 months ago[X86] combineMOVMSK - merge movmsk(icmp_eq(and(x,c1),c1)) and movmsk(icmp_eq(and...
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.

15 months agoFix MSVC "not all control paths return a value" warning. NFC.
Simon Pilgrim [Mon, 3 Apr 2023 16:12:11 +0000 (17:12 +0100)]
Fix MSVC "not all control paths return a value" warning. NFC.

15 months ago[flang] Don't allow CALL RANDOM_NUMBER(assumed-size-array)
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

15 months ago[X86] Simplify some `pternlog` intrinsics
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

15 months ago[X86] Add tests for simplifying pternlog intrinsics; NFC
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

15 months ago[InstSimplify] Extend simplifications for `(icmp ({z|s}ext X), C)` where `C` is vector
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

15 months ago[InstSimplify] Add tests for simplifying `(icmp ({z|s}ext X), C)` where `C` is vector...
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

15 months ago[flang] NORM2(DIM=) argument can't be dynamically optional
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

15 months ago[flang] Resolve USE vs IMPORT conflicts
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

15 months ago[amdgpu][nfc] Refactor prior to D144233 to remove noise from diff
Jon Chesterfield [Mon, 3 Apr 2023 12:44:11 +0000 (13:44 +0100)]
[amdgpu][nfc] Refactor prior to D144233 to remove noise from diff

15 months ago[llvm][TextAPI] Ignore deployment version in target comparator
Cyndy Ishida [Mon, 3 Apr 2023 14:29:25 +0000 (07:29 -0700)]
[llvm][TextAPI] Ignore deployment version in target comparator

15 months ago[clang][Interp] Add missing static_assert message
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

15 months ago[libc] Improve copying system vectors to the GPU
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.

15 months ago[clang][Interp] Ignore StaticAssertDecls
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

15 months ago[SLP]Reorder counters for same values, if the root node is reordered.
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.

15 months ago[clang][Interp][NFC] Refactor VisitDeclRefExpr
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.

15 months ago[Clang] Update test checks (NFC)
Nikita Popov [Mon, 3 Apr 2023 14:32:59 +0000 (16:32 +0200)]
[Clang] Update test checks (NFC)

These were affected by 9b5ff4436e446e9df97ee37b3bcf9ba029c7d9aa.

15 months ago[include-cleaner] Treat member operator calls as implicit
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.

15 months ago[SLP][NFC]Add a test for reordered scalars with not reordered reuse coefficient.
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.

15 months ago[X86] combineMOVMSK - fold movmsk(icmp_eq(and(x,c1),c1)) -> movmsk(shl(x,c2)) iff...
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

15 months ago[X86] MatchVectorAllZeroTest - handle icmp_eq(bitcast(vXi1 trunc(Y)),0) style reducti...
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

15 months ago[EarlyCSE] Call combineMetadataForCSE() when CSEing loads
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.

15 months ago[Local] Preserve !invariant.load of dominating instruction
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).

15 months ago[GVN] Regenerate test checks (NFC)
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.

15 months ago[flang] Use definability tests for better PURE constraint checking
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

15 months ago[clang][Interp] Fix initializing fields after base class members
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

15 months ago[EarlyCSE] Regenerate test checks (NFC)
Nikita Popov [Mon, 3 Apr 2023 13:51:56 +0000 (15:51 +0200)]
[EarlyCSE] Regenerate test checks (NFC)

15 months ago[EarlyCSE] Add metadata preservation tests (NFC)
Nikita Popov [Mon, 3 Apr 2023 13:40:56 +0000 (15:40 +0200)]
[EarlyCSE] Add metadata preservation tests (NFC)

15 months ago[include-cleaner] Report references to operator calls as implicit
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

15 months agoRevert "Move "auto-init" instructions to the dominator of their users"
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

15 months ago[clang][Interp] Fix diagnostics for calling non-constexpr constructors
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

15 months ago[Orc] Add AutoRegisterCode option for DebugObjectManagerPlugin
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

15 months ago[Local] Use combineMetadataForCSE() in patchReplacementInstruction()
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.

15 months ago[Local] Add MD_fpmath to combineMetadataForCSE()
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.

15 months agoMove "auto-init" instructions to the dominator of their users
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

15 months ago[ConstraintElimination] Add function arguments to constraint system before solving
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

15 months ago[NFC][LoopVectorize] Add zext/sext cost tests when there is type shrinkage
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

15 months ago[re-reland][libc] Adds string and TestLogger classes, use them in LibcTest
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

15 months ago[clang-format] Don't allow variable decls to have trailing return arrows
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

15 months ago[LICM] Don't promote store to global even in single-thread mode
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

15 months ago[X86] Test coverage for icmp_eq(bitcast(vXi1 trunc(Y)),0) style reduction patterns
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

15 months ago[Pass Builder] Allow Module Inliner for full LTO
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

15 months ago[clang][Interp] Fix initializing base class members
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

15 months ago[Matrix] Fix shapes in dot product tests.
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.

15 months ago[bazel][libc] Add a missing string_view dependency
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

15 months ago[bazel] Run an autoformatter on libc/BUILD.bazel
Dmitri Gribenko [Mon, 3 Apr 2023 11:03:14 +0000 (13:03 +0200)]
[bazel] Run an autoformatter on libc/BUILD.bazel

15 months ago[clang-tidy] support unscoped enumerations in readability-static-accessed-through...
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

15 months ago[mlir][spirv-cpu-runner] Add missing call to registerPassManagerCLOptions().
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.

15 months ago[GuardWidening] Fix the crash while replacing the users of poison.
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

15 months agoRevert "Reland "[compiler-rt] Drop -Werror in compiler flag checks""
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.

15 months ago[LICM] Extract helper for getClobberingMemoryAccess()
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.

15 months ago[AArch64] Remove redundant `mov 0` instruction for high 64-bits
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

15 months ago[Orc] Print section load-addresses for debug objects as hex again
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
```

15 months ago[clang][Interp] Fix derived-to-base casts for >1 levels
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

15 months ago[MLIR][LLVM] Put byval static allocas in the entry block.
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

15 months agoReland "[compiler-rt] Drop -Werror in compiler flag checks"
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.

15 months ago[DAGCombiner] Fold avg(x, x) --> x
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

15 months agoAdd baseline tests for 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>
15 months ago[mlir][llvm] Drop `ResumeOp::verify()` function
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

15 months ago[clang][dataflow][NFC] Share code between Environment ctor and pushCallInternal().
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

15 months agoRevert "[compiler-rt] Quote multiple warning flags in check_cxx_compiler_flag invocation"
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.

15 months agoRevert D147231 "[reland][libc] Adds string and TestLogger classes, use them in LibcTest"
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.

15 months ago[reland][libc] Adds string and TestLogger classes, use them in LibcTest
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

15 months ago[JITLink][NFC] Make Block const in alignToBlock
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

15 months ago[flang] Add TODO for creation of polymorphic temporary
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

15 months ago[flang] preserve pointer rank in polymorphic_pointer => NULL()
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

15 months ago[mlir] Add stack alignment to the data layout dialect.
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

15 months ago[LoongArch] Optimize 32-bit addition with ALSL_W on LoongArch64
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

15 months ago[mlir] Fix ignoring return value warning.
Adrian Kuegel [Mon, 3 Apr 2023 06:27:29 +0000 (08:27 +0200)]
[mlir] Fix ignoring return value warning.

15 months ago[m68k][NFC] Remove out-of-date comment
Sheng [Mon, 3 Apr 2023 05:56:25 +0000 (13:56 +0800)]
[m68k][NFC] Remove out-of-date comment

15 months ago[LoongArch] Optimize bitwise and with immediates
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

15 months ago[LoongArch][NFC] Add tests of bitwise and with immediates (for 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

15 months ago[PowerPC] Lower IS_FPCLASS by test data class instruction
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

15 months ago[LoongArch] Optimize multiplication with immediates
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

15 months ago[LoongArch][NFC] Add tests of multiplication with immediates
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

15 months ago[SelectionDAG] Rename Flag->Glue. NFC
Craig Topper [Mon, 3 Apr 2023 02:45:36 +0000 (19:45 -0700)]
[SelectionDAG] Rename Flag->Glue. NFC

15 months ago[Targets] 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.

15 months ago[X86] Rename Flag->Glue in SelectionDAG. NFC
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

15 months ago[mlir] Fix ignoring return value warning for Toy CLIs
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

15 months ago[TableGen] Rename InFlag/OutFlag->InGlue/OutGlue. NFC
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.

15 months ago[TableGen] clang-format DAGISelMatcherOpt.cpp. NFC
Craig Topper [Sun, 2 Apr 2023 21:04:56 +0000 (14:04 -0700)]
[TableGen] clang-format DAGISelMatcherOpt.cpp. NFC

15 months ago[mlir][doc] rename MemRefDataFlowOpt -> AffineScalarReplacement
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

15 months ago[mlir] [Linalg] Limit Detensorize pass to FunctionOpInterface
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

15 months ago[X86] truncateAVX512SetCCNoBWI - pass SDLoc argument by const-ref
Simon Pilgrim [Sun, 2 Apr 2023 19:56:54 +0000 (20:56 +0100)]
[X86] truncateAVX512SetCCNoBWI - pass SDLoc argument by const-ref

15 months ago[TableGen] Avoid creating a ScopeMatcher full of nullptrs.
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.

15 months ago[X86] combineX86ShufflesConstants - move hasOneUse check as late as possible. NFC.
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.

15 months ago[X86] lowerShuffleOfExtractsAsVperm - move hasOneUse checks to the end of the match...
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.

15 months ago[MCJIT] Set VMA to code address in PerfJITEventListener.
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

15 months ago[X86] Move hasOneUse check on PCMPGT(X,-1) -> PCMPGT(0,X) inversion folds to the...
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.

15 months ago[ORC] Add a generic bootstrap key-value store to SimpleRemoteEPC.
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).

15 months ago[X86] combineExtractVectorElt - call hasOneUse() as late as possible. NFCI.
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.

15 months ago[clang-tidy] Fix findNextTokenSkippingComments & rangeContainsExpansionsOrDirectives
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

15 months agoRevert D147231 "[libc] Adds string and TestLogger classes, use them in LibcTest"
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.

15 months ago[RISCV] Lower fixed length interleaved accesses via vssegN/vlsegN
Luke Lau [Wed, 1 Mar 2023 18:25:48 +0000 (18:25 +0000)]
[RISCV] Lower fixed length interleaved accesses via vssegN/vlsegN

This enables the interleaved access pass on O1 and above, and causes
interleaving/deinterleaving shuffles of fixed length vectors with
stores/loads to be lowered into vssegN/vlsegN.

We need to be careful and make sure that we only lower vsseg/vlseg
whenever we know the fixed vector type will fit within the minimum vlen,
and that the interleaving factor is supported for the given LMUL.

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D145085

15 months ago[mlir][StorageUniquer] Fix build with LLVM_ENABLE_THREADS=OFF
Alexandre Ganea [Sun, 2 Apr 2023 15:38:58 +0000 (11:38 -0400)]
[mlir][StorageUniquer] Fix build with LLVM_ENABLE_THREADS=OFF

15 months ago[compiler-rt] Avoid double-prefixing aliases with __USER_LABEL_PREFIX__
Sergei Barannikov [Sun, 2 Apr 2023 15:33:27 +0000 (18:33 +0300)]
[compiler-rt] Avoid double-prefixing aliases with __USER_LABEL_PREFIX__

The prefix is added by DECLARE_SYMBOL_VISIBILITY. Calling SYMBOL_NAME
resulted in adding the prefix twice.

Reviewed By: dim

Differential Revision: https://reviews.llvm.org/D147077

15 months ago[libc] Adds string and TestLogger classes, use them in LibcTest
Guillaume Chatelet [Thu, 30 Mar 2023 13:13:27 +0000 (13:13 +0000)]
[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

15 months ago[DAG] canCreateUndefOrPoison - add ISD::INSERT_VECTOR_ELT handling
Simon Pilgrim [Sun, 2 Apr 2023 15:28:20 +0000 (16:28 +0100)]
[DAG] canCreateUndefOrPoison - add ISD::INSERT_VECTOR_ELT handling

If the inserted element index is guaranteed to be inbounds then a ISD::INSERT_VECTOR_ELT will not create poison/undef.

15 months ago[X86] Add test case showing failure to fold freeze through a ISD::INSERT_VECTOR_ELT...
Simon Pilgrim [Sun, 2 Apr 2023 15:03:14 +0000 (16:03 +0100)]
[X86] Add test case showing failure to fold freeze through a ISD::INSERT_VECTOR_ELT node

15 months ago[libc] Fix missing include for pthread tests
Guillaume Chatelet [Sun, 2 Apr 2023 15:06:15 +0000 (15:06 +0000)]
[libc] Fix missing include for pthread tests