platform/upstream/llvm.git
13 months ago[RISCV] Minor style changes to performCombineVMergeAndVOps [nfc]
Philip Reames [Wed, 14 Jun 2023 00:07:17 +0000 (17:07 -0700)]
[RISCV] Minor style changes to performCombineVMergeAndVOps [nfc]

Making the code a bit easier to follow, so that merging an upcoming change is more straight forward.

13 months ago[mlir][Vector] Add basic scalable vectorization support to Linalg vectorizer
Diego Caballero [Sat, 10 Jun 2023 00:36:33 +0000 (00:36 +0000)]
[mlir][Vector] Add basic scalable vectorization support to Linalg vectorizer

For now, only elementwise operations are supported. Operations that perform any
kind of data permutation require changes in the representation of scalable
dimensions in VectorType.

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

13 months ago[SLP][NFC] Precommit test that exposes a bug in ShuffleBuilder.
Vasileios Porpodas [Tue, 13 Jun 2023 19:39:23 +0000 (12:39 -0700)]
[SLP][NFC] Precommit test that exposes a bug in ShuffleBuilder.

ShuffleBuilder generates a zero mask here:
`[[TMP6:%.*]] = shufflevector <2 x float> [[TMP3]], <2 x float> poison, <4 x i32> zeroinitializer`
But the correct mask is `0,0,1,1`, or we should have reused `TMP4`.

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

13 months ago[Attributor][NFC] Make the MustBeExecutedContextExplorer optional
Johannes Doerfert [Tue, 13 Jun 2023 23:39:49 +0000 (16:39 -0700)]
[Attributor][NFC] Make the MustBeExecutedContextExplorer optional

For a lightweight pass we do not want to instantiate or use the
MustBeExecutedContextExplorer. This simply allows such a configuration.
While at it, the explorer is now allocated with the bump allocator.

13 months ago[RISCV] Canonicalize towards vmerge w/passthrough representation
Philip Reames [Tue, 13 Jun 2023 23:19:02 +0000 (16:19 -0700)]
[RISCV] Canonicalize towards vmerge w/passthrough representation

This is the first patch in a series to change how we represent tail agnostic, tail undefined, and tail undisturbed operations. In current code, we tend to use an unsuffixed pseudo for undefined (despite calling it TA most places in code), and the _TU form for both agnostic and undisturbed (via the policy operand).

The key observation behind this patch is that we can represent tail undefined via a pseudo with a passthrough operand if that operand is IMPLICIT_DEF (aka undef). We already have a few instances of this in tree - see vmv.s.x and vslide* - but we can do this more universally. Once complete, we will be able to delete roughly ~1/3 of our vector pseudo classes.

A bit more information on the overall goal can be found in this discourse post: https://discourse.llvm.org/t/riscv-transition-in-vector-pseudo-structure-policy-variants/71295.

This patch doesn't actually remove the legacy unsuffixed pseudo as there's still some path from intrinsic lowering which uses it. (I have not yet located it.) This also means we don't have to modify any of the lookup tables which makes the migration simpler. We can defer deleting the tables and pseudos until one final change once all the instructions have been migrated.

There are a couple of regressions in the tests. At first, these concerned me, but it turns out that all of them are differences in expansion of a single source level instruction. I think we can safely ignore this for the moment. I did explore changing the handling of IMPLICIT_DEF in ScheduleDAG, but that causes an absolutely *massive* test diff with minimal profit. I really don't think it's worth doing.

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

13 months ago[Attributor][FIX] Ensure unknown accesses are honored
Johannes Doerfert [Tue, 13 Jun 2023 21:47:14 +0000 (14:47 -0700)]
[Attributor][FIX] Ensure unknown accesses are honored

If we had an unknown access but already some prior knowledge (known), we
could have ended up ignoring the unknown access all together. The
problem is that we track unknown not as all locations but separately.
This patch bridges the gap and expands the unknown bits to "all bits"
when we add an access.

Fixes: https://github.com/llvm/llvm-project/issues/63291

13 months ago[Attributor][NFC] Precommit test for #63291
Johannes Doerfert [Tue, 13 Jun 2023 21:55:51 +0000 (14:55 -0700)]
[Attributor][NFC] Precommit test for #63291

See: https://github.com/llvm/llvm-project/issues/63291

13 months ago[RISCV] Introduce the concept of DLEN(data path width) into getLMULCost.
Craig Topper [Tue, 13 Jun 2023 23:09:25 +0000 (16:09 -0700)]
[RISCV] Introduce the concept of DLEN(data path width) into getLMULCost.

SiFive's x280 CPU has a vector unit that VLEN/2 bits wide. This
means that LMUL=1 operations take 2 to process all VLEN bits.

This patch adds a DLenFactor tuning parameter and applies it to
TuneSiFive7. getLMULCost has been updated to use this factor in
its calculations. I've added an x280 command line to one cost
model test to demonstrate the effect.

Reviewed By: arcbbb

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

13 months ago[lldb][NFCI] Remove StructuredData::Dictionary::GetValueForKeyAsString overloads...
Alex Langford [Sat, 10 Jun 2023 00:06:22 +0000 (17:06 -0700)]
[lldb][NFCI] Remove StructuredData::Dictionary::GetValueForKeyAsString overloads involving ConstString

In an effort to keep the ConstString StringPool small, I plan on
removing use of ConstString in StructuredData. The only class that
really uses it is StructuredData::Dictionary.

This one was fairly easy to remove, I plan on removing the others in
follow-up changes.

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

13 months ago[lldb] Default can_create to true in GetChildAtIndex (NFC)
Dave Lee [Mon, 29 May 2023 02:16:49 +0000 (19:16 -0700)]
[lldb] Default can_create to true in GetChildAtIndex (NFC)

Existing callers of `GetChildAtIndex` pass true for can_create. This change
makes true the default value, callers don't have to pass an opaque true.

See also D151966 for the same change to `GetChildMemberWithName`.

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

13 months ago[Bazel] Fix build
Pranav Kant [Tue, 13 Jun 2023 22:43:56 +0000 (22:43 +0000)]
[Bazel] Fix build

13 months ago[lldb][NFCI] Change return type of Properties::GetExperimentalSettingsName
Alex Langford [Fri, 2 Jun 2023 00:06:06 +0000 (17:06 -0700)]
[lldb][NFCI] Change return type of Properties::GetExperimentalSettingsName

Most users of this stick it into a StringRef. The one user that doesn't
just tries to get the length out of it, which we can precompute by
putting it in a constexpr StringLiteral.

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

13 months ago[sanitizer] Adjust code path of ChooseExternalSymbolizer for Windows
Wu, Yingcong [Tue, 13 Jun 2023 21:51:46 +0000 (14:51 -0700)]
[sanitizer] Adjust code path of ChooseExternalSymbolizer for Windows

If `path` is null, `user_path` must also be null. With the current code path, the message of explicitly disabling symbolizer will never be reported. This patch adjusts the if-else structure to make that message can be reported.

Reviewed By: cchen15, MaskRay

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

13 months ago[-Wtcb-enforcement] Disable on unevaluated code.
Artem Dergachev [Tue, 13 Jun 2023 20:39:45 +0000 (13:39 -0700)]
[-Wtcb-enforcement] Disable on unevaluated code.

It doesn't make sense for this warning to warn about things
that don't impact runtime behavior.

13 months ago[llvm-objdump/mac] Add support for LC_ATOM_INFO
Keith Smiley [Tue, 13 Jun 2023 18:32:30 +0000 (11:32 -0700)]
[llvm-objdump/mac] Add support for LC_ATOM_INFO

This is a new load command first supported in Xcode 15's tools

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

13 months ago[libc++] Refactor __debug_three_way_comp
Louis Dionne [Mon, 12 Jun 2023 21:16:32 +0000 (14:16 -0700)]
[libc++] Refactor __debug_three_way_comp

This makes __debug_three_way_comp consistent with __debug_less and
in particular gets rid of a potential use-after-move caused by the
use of std::forward. In the previous version of the code, we would
call `__do_compare_assert` after forwarding the arguments into the
comparator, which could end up using the arguments after they've been
moved from.

This also simplifies how we call `__do_compare_assert` by using
`if constexpr` and adds a missing test for proxy iterators in
lexicographical_compare_three_way, which could have found this
issue.

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

13 months ago[InstSimplify] Fold all global variables with initializers
Anshil Gandhi [Tue, 13 Jun 2023 21:14:11 +0000 (15:14 -0600)]
[InstSimplify] Fold all global variables with initializers

Allow computing size of interposable or externally initializable global variables.

Reviewed By: nikic

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

13 months ago[RDF] Allow individual units in PhysicalRegisterInfo::alias
Krzysztof Parzyszek [Sat, 3 Jun 2023 17:32:45 +0000 (10:32 -0700)]
[RDF] Allow individual units in PhysicalRegisterInfo::alias

13 months ago[test][asan] Remove XFAIL after D152604
Vitaly Buka [Tue, 13 Jun 2023 21:03:32 +0000 (14:03 -0700)]
[test][asan] Remove XFAIL after D152604

13 months ago[flang][openacc] Relax rule for end directive on combined construct
Valentin Clement [Tue, 13 Jun 2023 20:57:43 +0000 (13:57 -0700)]
[flang][openacc] Relax rule for end directive on combined construct

Make the keyword `loop` optional for the end driective on combined
construct. This done to extend compatibility with other compiler that
allow this.

Reviewed By: razvanlupusoru

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

13 months agoUpdated the 'getting involved' documentation for Flang to correct the technical call...
Anton Rydahl [Tue, 13 Jun 2023 19:40:11 +0000 (20:40 +0100)]
Updated the 'getting involved' documentation for Flang to correct the technical call details

modified:   flang/docs/GettingInvolved.md

Reviewed By: NimishMishra

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

13 months agoRevert "[lldb] Fix failure in TestStackCoreScriptedProcess on x86_64"
Med Ismail Bennani [Tue, 13 Jun 2023 20:45:59 +0000 (13:45 -0700)]
Revert "[lldb] Fix failure in TestStackCoreScriptedProcess on x86_64"

This reverts commit 4177b490358432a457935ba5d6d076ae60de588f, since I
landed it by mistake.

13 months ago[lldb] Fix failure in TestStackCoreScriptedProcess on x86_64
Med Ismail Bennani [Tue, 13 Jun 2023 18:43:17 +0000 (11:43 -0700)]
[lldb] Fix failure in TestStackCoreScriptedProcess on x86_64

This patch should address the failure of TestStackCoreScriptedProcess
that is happening specifically on x86_64.

It turns out that in 1370a1cb5b97, I changed the way we extract integers
from a `StructuredData::Dictionary` and in order to get a stop info from
the scripted process, we call a method that returns a `SBStructuredData`
containing the stop reason data.

TestStackCoreScriptedProcess` was failing specifically on x86_64 because
the stop info dictionary contains the signal number, that the `Scripted
Thread` was trying to extract as a signed integer where it was actually
parsed as an unsigned integer. That caused `GetValueForKeyAsInteger` to
return the default value parameter, `LLDB_INVALID_SIGNAL_NUMBER`.

This patch address the issue by extracting the signal number with the
appropriate type and re-enables the test.

Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
13 months ago[lldb] Improve corefile saving ergonomics
Med Ismail Bennani [Tue, 13 Jun 2023 18:21:08 +0000 (11:21 -0700)]
[lldb] Improve corefile saving ergonomics

This patch improves the way the user can save the process state into a
corefile by adding completion handler that would provide tab completion
for the corefile path and also resolves the corefile path to expand
relative path.

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

Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
13 months ago[mlir][openacc] Add gang dim operand to acc.loop operation
Valentin Clement [Tue, 13 Jun 2023 20:39:06 +0000 (13:39 -0700)]
[mlir][openacc] Add gang dim operand to acc.loop operation

OpenACC 3.3 introduces a dim argument on the gang clause. This patch
adds a new operand for it on the acc.loop and update the custom
gang clause parser/printer for it.

Depends on D151970

Reviewed By: razvanlupusoru, jeanPerier

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

13 months ago[LLD] Allow usage of LLD as a library
Alexandre Ganea [Tue, 13 Jun 2023 20:22:51 +0000 (16:22 -0400)]
[LLD] Allow usage of LLD as a library

As discussed in https://github.com/llvm/llvm-project/issues/53475 this patch allows using LLD-as-a-lib. It also lets clients link only the drivers that they want (see unit tests).

This also adds the unit test infra as in the other LLVM projects. Among the test coverage, I've added the original issue from @krzysz00, see: https://github.com/ROCmSoftwarePlatform/D108850-lld-bug-reproduction

Important note: this doesn't allow (yet) linking in parallel. This will come a bit later, in subsequent patches, for COFF at last.

Differential revision: https://reviews.llvm.org/D119049

13 months ago[Passes] Remove some legacy printer passes
Arthur Eubanks [Tue, 13 Jun 2023 20:17:32 +0000 (13:17 -0700)]
[Passes] Remove some legacy printer passes

MemDepPrinter doesn't have a new PM equivalent, but MemDep is soft deprecated anyway and adding one should be easy if somebody wants to.

13 months ago[BOLT][NFCI] Remove redundant instance of MCAsmBackend
Maksim Panchenko [Tue, 13 Jun 2023 01:21:58 +0000 (18:21 -0700)]
[BOLT][NFCI] Remove redundant instance of MCAsmBackend

Use instance of MCAsmBackend from BinaryContext instead of creating a
new one.

Reviewed By: Amir

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

13 months ago[LoopSink] Allow sinking to PHI-use
Wenlei He [Tue, 13 Jun 2023 04:20:19 +0000 (21:20 -0700)]
[LoopSink] Allow sinking to PHI-use

This change allows sinking defs from loop preheader with PHI-use into loop body. Loop sink can now see through PHI-use and select incoming blocks of value being used as candidate sink destination.

It makes loop sink more effective so more LICM can be undone if proven unprofitable with profile info. It addresses the motivating case in D87551, without resorting to profile guided LICM which breaks canonicalization.

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

13 months ago[flang] Add PowerPC vec_add, vec_and, vec_mul, vec_sub and vec_xor intrinsics
Kelvin Li [Mon, 29 May 2023 20:10:12 +0000 (16:10 -0400)]
[flang] Add PowerPC vec_add, vec_and, vec_mul, vec_sub and vec_xor intrinsics

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

13 months ago[MS] Fix passing aligned records by value in some cases
Reid Kleckner [Mon, 12 Jun 2023 20:50:50 +0000 (13:50 -0700)]
[MS] Fix passing aligned records by value in some cases

It's not exactly clear what the meaning of TypeInfo::AlignRequirement
is, so go directly to the ASTRecordLayout for records and check the
required alignment there. Compare that number with the stack alignment
value of 4.

This fixes cases when the alignment attribute does not appear directly
on the record [1], or when the attribute on the record is underaligned
[2].

[1]: `struct Foo { int __declspec(align(16)) x; };`
[2]: `struct __declspec(align(1)) Bar { int x; };`

Fixes https://llvm.org/pr63257

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

13 months ago[SelectionDAG] Don't allow type legalization to create noop VP_TRUNCATE.
Craig Topper [Tue, 13 Jun 2023 19:46:26 +0000 (12:46 -0700)]
[SelectionDAG] Don't allow type legalization to create noop VP_TRUNCATE.

Type legalization may need to promote the result to the same type
as the input. Instead of forming a vp_truncate with the same
source and dest type, don't create any vp_truncate.

Handling in getNode like is done for ISD::TRUNCATE.

13 months ago[CMake][BLAKE3] Fix unused -mavx512vl warning when CMAKE_OSX_ARCHITECTURES=arm64
Fangrui Song [Tue, 13 Jun 2023 19:45:34 +0000 (12:45 -0700)]
[CMake][BLAKE3] Fix unused -mavx512vl warning when CMAKE_OSX_ARCHITECTURES=arm64

This fixes
```
% ninja -C out/play LLVMSupport
ninja: Entering directory `out/play'
[151/158] Building ASM object lib/Support/BLAKE3/CMakeFiles/LLVMSupportBlake3.dir/blake3_avx512_x86-64_unix.S.o
clang: warning: argument unused during compilation: '-mavx512vl' [-Wunused-command-line-argument]
```

and applies `disable_blake3_x86_simd()`.

This fixes the root cause of commit 5160f6fefb0021a0b23e99c7cf621a330241c211 ("broke cross-builds of llvm from x86_64 to arm64 mac"...)

13 months ago[test][sanitizer] Fix test on windows
Vitaly Buka [Tue, 13 Jun 2023 19:26:41 +0000 (12:26 -0700)]
[test][sanitizer] Fix test on windows

13 months agoEnable zbb for riscv android
AdityaK [Tue, 13 Jun 2023 19:22:46 +0000 (12:22 -0700)]
Enable zbb for riscv android

Differential Revision: https://reviews.llvm.org/D152729
Reviewers: enh, pirama, jrtc27

13 months ago[LLD][COFF] Allow overwriting directives exports with cmd-line exports
Alexandre Ganea [Tue, 13 Jun 2023 19:12:55 +0000 (15:12 -0400)]
[LLD][COFF] Allow overwriting directives exports with cmd-line exports

MSVC link.exe allows overriding exports on the cmd-line with exports seen in OBJ directives. The typical case is what is described in #62329.

Before this patch, trying to override an export with `/export` or `/def` would generate a duplicate warning. This patches tries to replicate the MSVC behavior. A second override on the cmd-line would still generate the warning.

There's still a case which we don't cover: MSVC link.exe is able to demangle an exported OBJ directive function, and match it with a unmangled export function in a .def file. In the meanwhile, one can use the mangled export in the .def to cover that case.

This fixes #62329

Differential revision: https://reviews.llvm.org/D149611

13 months ago[test][sanitizer] Fix test on windows
Vitaly Buka [Tue, 13 Jun 2023 19:26:41 +0000 (12:26 -0700)]
[test][sanitizer] Fix test on windows

13 months ago[BOLT][NFC] Change signature of MCPlusBuilder::isUnsupportedBranch()
Maksim Panchenko [Sat, 6 May 2023 20:27:48 +0000 (13:27 -0700)]
[BOLT][NFC] Change signature of MCPlusBuilder::isUnsupportedBranch()

Make MCPlusBuilder::isUnsupportedBranch() take MCInst, not opcode.

Reviewed By: Amir

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

13 months agoScalarizer: limit scalarization for small element types
Nicolai Hähnle [Fri, 2 Dec 2022 02:15:13 +0000 (03:15 +0100)]
Scalarizer: limit scalarization for small element types

Scalarization can expose optimization opportunities for the individual
elements of a vector, and can therefore be beneficial on targets like
GPUs that tend to operate on scalars anyway.

However, notably with 16-bit operations it is often beneficial to keep
<2 x i16 / half> vectors around since there are packed instructions for
those.

Refactor the code to operate on "fragments" of split vectors. The
fragments are usually scalars, but may themselves be smaller vectors
when the scalarizer-min-bits option is used. If the split is uneven,
the last fragment is a shorter remainder.

This is almost NFC when the new option is unused, but it happens to
clean up some code in the fully scalarized case as well.

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

13 months ago[gn build] Port 474a2b9367ad
LLVM GN Syncbot [Tue, 13 Jun 2023 19:06:20 +0000 (19:06 +0000)]
[gn build] Port 474a2b9367ad

13 months ago[clang-tidy] Add more checks for functions which should be noexcept
AMS21 [Tue, 13 Jun 2023 18:56:54 +0000 (18:56 +0000)]
[clang-tidy] Add more checks for functions which should be noexcept

Added new checks
- `performance-noexcept-destructor`
- `performance-noexcept-swap`

Also added cppcoreguidlines aliases for the 2 new checks as well as `performance-noexcept-move-constructor`

This fixes llvm#62154

Reviewed By: PiotrZSL

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

13 months ago[clang-tidy] Move formatDereference to FixitHintUtils
Mike Crowe [Tue, 13 Jun 2023 18:15:13 +0000 (18:15 +0000)]
[clang-tidy] Move formatDereference to FixitHintUtils

I'd like to use RedundantStringCStrCheck's formatDereference function
from the up-coming modernize-use-std-print check. Let's move it to
FixItHintUtils so that the implementation can be shared.

Reviewed By: PiotrZSL

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

13 months ago[lldb] Default can_create to true in GetChildMemberWithName (NFC)
Dave Lee [Mon, 29 May 2023 01:48:32 +0000 (18:48 -0700)]
[lldb] Default can_create to true in GetChildMemberWithName (NFC)

It turns out all existing callers of `GetChildMemberWithName` pass true for `can_create`.
This change makes `true` the default value, callers don't have to pass an opaque true.

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

13 months ago[mlir][openacc][NFC] Fix current gang clause parser
Valentin Clement [Tue, 13 Jun 2023 18:16:31 +0000 (11:16 -0700)]
[mlir][openacc][NFC] Fix current gang clause parser

The custom parser for the gang values was not implemented correctly.
This patch fixes the noted issue and allows the num/static values
to appear in any order.

Reviewed By: razvanlupusoru, jeanPerier

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

13 months ago[clang-tidy] Fix crash in `modernize-use-default-member-init`
AMS21 [Tue, 13 Jun 2023 18:00:03 +0000 (18:00 +0000)]
[clang-tidy] Fix crash in `modernize-use-default-member-init`

This was causes by `getValueOfValueInit` unconditionally calling
`getScalarTypeKind` on the member type, which would then trigger an
assertions since arrays are not scalar type.

This fixes llvm#63285

Reviewed By: PiotrZSL

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

13 months ago[clang-tidy] Fix false positive in `readability-named-parameter` for defaulted out...
AMS21 [Tue, 13 Jun 2023 17:58:16 +0000 (17:58 +0000)]
[clang-tidy] Fix false positive in `readability-named-parameter` for defaulted out-of-line special member functions

This fixes llvm#63056

Reviewed By: PiotrZSL

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

13 months ago[lldb] Never print children if the max depth has been reached
Augusto Noronha [Wed, 7 Jun 2023 23:17:37 +0000 (16:17 -0700)]
[lldb] Never print children if the max depth has been reached

When formatting a variable, the max depth would potentially be ignored
if the current value object failed to print itself. Change that to
always respect the max depth, even if failure occurs.

rdar://109855463

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

13 months ago[RISCV] Remove RISCVII::hasMergeOp. NFC
Craig Topper [Tue, 13 Jun 2023 17:54:00 +0000 (10:54 -0700)]
[RISCV] Remove RISCVII::hasMergeOp. NFC

We can mostly get this from the operand info in MCInstrDesc.
The exception is the _TIED pseudos so I've added a new flag for those.

Reviewed By: frasercrmck

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

13 months ago[AMDGPU][AsmParser][NFC] Simplify the EndpgmImm operand definition.
Ivan Kosarev [Tue, 13 Jun 2023 17:38:49 +0000 (18:38 +0100)]
[AMDGPU][AsmParser][NFC] Simplify the EndpgmImm operand definition.

Clears the road to eliminating custom default operand handlers. Also
unifies naming of related entities.

Part of <https://github.com/llvm/llvm-project/issues/62629>.

Reviewed By: arsenm

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

13 months ago[RISCV] Change the immediate argument to Zk* intrinsics/builtins from i8 to i32.
Craig Topper [Tue, 13 Jun 2023 16:52:26 +0000 (09:52 -0700)]
[RISCV] Change the immediate argument to Zk* intrinsics/builtins from i8 to i32.

This matches gcc. It also lets us fix a bug that the byteselect
predicate was not being evaluated in tablegen. We can't have i8
TImmLeaf in tablegen because i8 isn't a type for any register class.

I've added AutoUpgrade support for the IR intrinsics.

Reviewed By: asb

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

13 months ago[FunctionAttrs] Remove errant whitespace; NFC
Noah Goldstein [Tue, 13 Jun 2023 07:42:15 +0000 (02:42 -0500)]
[FunctionAttrs] Remove errant whitespace; NFC

13 months ago[libc++][NFC] Reformat features.py
Louis Dionne [Mon, 12 Jun 2023 18:32:29 +0000 (11:32 -0700)]
[libc++][NFC] Reformat features.py

This file was reformatted using the Black tool, which led to entirely
unreadable code due to how lines are broken. Formatting tools are fine,
but not when they lead to code that humans have trouble reading. In the
case of features.py, a lot of it was meant to be aligned in a repetitive
but consistent way to make the structure of the code stand out.
Reformatting with the tool lost that property.

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

13 months ago[libc++] Mark slow tests as unsupported on GCC
Louis Dionne [Mon, 12 Jun 2023 18:21:47 +0000 (11:21 -0700)]
[libc++] Mark slow tests as unsupported on GCC

Some tests in our test suite are unbelievably slow on GCC due to the
use of the always_inline attribute. See [1] for more details.

This patch introduces the GCC-ALWAYS_INLINE-FIXME lit feature to
disable tests that are plagued by that issue. At the same time, it
moves several existing tests from ad-hoc `UNSUPPORTED: gcc-12` markup
to the new GCC-ALWAYS_INLINE-FIXME feature, and marks the slowest tests
reported by the CI as `UNSUPPORTED: GCC-ALWAYS_INLINE-FIXME`.

[1]: https://discourse.llvm.org/t/rfc-stop-supporting-extern-instantiations-with-gcc/71277/1

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

13 months ago[lldb][NFCI] Remove use of ConstString from Listener
Alex Langford [Fri, 9 Jun 2023 18:46:00 +0000 (11:46 -0700)]
[lldb][NFCI] Remove use of ConstString from Listener

The only place ConstString was used in Listener was for filtering
broadcasters by name when looking for the next event. This functionality
is completely unused from what I can tell (even in downstream forks).

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

13 months agoReland [clang-format] Add the KeepEmptyLinesAtEOF option
Owen Pan [Tue, 13 Jun 2023 16:52:34 +0000 (09:52 -0700)]
Reland [clang-format] Add the KeepEmptyLinesAtEOF option

13 months ago[include-cleaner] Don't apply the PreferredHeader hint for standard headers.
Haojian Wu [Tue, 13 Jun 2023 11:42:36 +0000 (13:42 +0200)]
[include-cleaner] Don't apply the PreferredHeader hint for standard headers.

Fixes https://github.com/llvm/llvm-project/issues/62635

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

13 months ago[RISCV] Add support for llvm.prefetch to use Zicbop instructions.
Craig Topper [Tue, 13 Jun 2023 16:51:30 +0000 (09:51 -0700)]
[RISCV] Add support for llvm.prefetch to use Zicbop instructions.

Reviewed By: asb, reames

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

13 months ago[test][sanitizer] Remove test missing include
Vitaly Buka [Tue, 13 Jun 2023 16:47:36 +0000 (09:47 -0700)]
[test][sanitizer] Remove test missing include

We don't need to test with std::array anyway, as we don't use them in
sanitizers.

13 months agoRemove dead conditionals
Sindhu Chittireddy [Mon, 12 Jun 2023 09:02:04 +0000 (02:02 -0700)]
Remove dead conditionals

13 months ago[Intrinsic] Introduce reduction intrinsics for minimum/maximum
Anna Thomas [Fri, 9 Jun 2023 21:09:12 +0000 (17:09 -0400)]
[Intrinsic] Introduce reduction intrinsics for minimum/maximum

This patch introduces the reduction intrinsic for floating point minimum
and maximum which has the same semantics (for NaN and signed zero) as
llvm.minimum and llvm.maximum.

Reviewed-By: nikic
Differential Revision: https://reviews.llvm.org/D152370

13 months ago[IR] Update to use new shufflevector semantics
ManuelJBrito [Tue, 13 Jun 2023 13:59:38 +0000 (14:59 +0100)]
[IR] Update to use new shufflevector semantics

Update to use new shufflevector semantics for undefined values in the mask

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

13 months ago[DAG][NFC] Update comment on min/max reduction fold.
David Green [Tue, 13 Jun 2023 16:09:22 +0000 (17:09 +0100)]
[DAG][NFC] Update comment on min/max reduction fold.

As pointed out in D141870, this one was incorrectly referencing and.

13 months ago[NFC][sanitizer] Fix build on Windows
Vitaly Buka [Tue, 13 Jun 2023 16:05:11 +0000 (09:05 -0700)]
[NFC][sanitizer] Fix build on Windows

Macro was defined twice.

13 months ago[MLIR][Tests] Update tests so they require assertions
Roger Ferrer Ibanez [Tue, 13 Jun 2023 15:36:11 +0000 (15:36 +0000)]
[MLIR][Tests] Update tests so they require assertions

These tests check statistics results which require assertions enabled.

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

13 months ago[clangd] Initialize local variable
Vitaly Buka [Tue, 13 Jun 2023 15:58:46 +0000 (08:58 -0700)]
[clangd] Initialize local variable

desugarForDiagnostic only sets value to true.

13 months ago[test][sanitizer] Unsupport test on Android
Vitaly Buka [Tue, 13 Jun 2023 15:52:03 +0000 (08:52 -0700)]
[test][sanitizer] Unsupport test on Android

13 months ago[test][sanitizer] Add ArrayRef tests
Vitaly Buka [Mon, 12 Jun 2023 23:40:48 +0000 (16:40 -0700)]
[test][sanitizer] Add ArrayRef tests

Tests are subset of llvm/unittests/ADT/ArrayRefTest.cpp.
Added more members to match tests and
make class more useful.

Reviewed By: hctim

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

13 months ago[RDF] Do not return register masks in PhysicalRegisterInfo::getAliasSet
Krzysztof Parzyszek [Fri, 2 Jun 2023 23:39:14 +0000 (16:39 -0700)]
[RDF] Do not return register masks in PhysicalRegisterInfo::getAliasSet

13 months ago[RDF] Print regmask index in more user-friendly way
Krzysztof Parzyszek [Fri, 2 Jun 2023 23:24:35 +0000 (16:24 -0700)]
[RDF] Print regmask index in more user-friendly way

13 months ago[SLP][X86] Add test coverage for Issue #62969
Simon Pilgrim [Tue, 13 Jun 2023 15:12:20 +0000 (16:12 +0100)]
[SLP][X86] Add test coverage for Issue #62969

13 months ago[CostModel][X86] Add test coverage for vXi64 multiplies of sign/zero-extended vector
Simon Pilgrim [Tue, 13 Jun 2023 14:16:35 +0000 (15:16 +0100)]
[CostModel][X86] Add test coverage for vXi64 multiplies of sign/zero-extended vector

Part of test coverage for Issue #62969

13 months ago[HIP] Fix HIP path detection
Yaxun (Sam) Liu [Mon, 12 Jun 2023 17:45:19 +0000 (13:45 -0400)]
[HIP] Fix HIP path detection

Fix two issues:

--hip-path should not do rigorous checking, i.e. if .hipVersion exists it
will use it, otherwise it will not error out but assumes the default
HIP version. This is to be consistent with --rocm-path behavior.

when HIP_PATH is empty, it should be ignored. This is to be consistent
with ROCM_PATH behavior.

Reviewed by: Artem Belevich

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

Fixes: SWDEV-404771

13 months ago[libc++] Add [[nodiscard]] extensions to the functions in <bit>
Nikolas Klauser [Tue, 13 Jun 2023 14:57:26 +0000 (07:57 -0700)]
[libc++] Add [[nodiscard]] extensions to the functions in <bit>

Reviewed By: #libc, ldionne, Mordante

Spies: Mordante, ldionne, libcxx-commits

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

13 months ago[gn build] Port cd916108b4c6
LLVM GN Syncbot [Tue, 13 Jun 2023 14:55:33 +0000 (14:55 +0000)]
[gn build] Port cd916108b4c6

13 months ago[libc++][PSTL] Implement std::generate{,_n}
Nikolas Klauser [Fri, 9 Jun 2023 20:45:34 +0000 (13:45 -0700)]
[libc++][PSTL] Implement std::generate{,_n}

Reviewed By: #libc, ldionne

Spies: ldionne, libcxx-commits

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

13 months ago[RISCV][NFC] Improve encoding/decoding tests for Zbb instructions
Venkata Ramanaiah Nalamothu [Tue, 13 Jun 2023 14:36:08 +0000 (20:06 +0530)]
[RISCV][NFC] Improve encoding/decoding tests for Zbb instructions

Currently `llvm/test/MC/RISCV/rv64zbb-valid.s` doesn't cover all
the instructions e.g. `maxu` and `llvm/test/MC/RISCV/rv32zbb-valid.s`
can have rv64 run lines, similar to what Zba instruction tests have.

This patch does the following.
- Add rv64 run lines in `llvm/test/MC/RISCV/rv32zbb-valid.s`
- Keep only rv64 specific instructions in `llvm/test/MC/RISCV/rv64zbb-valid.s`
- Move rv32 instructions, with different encodings from rv64, into
  `llvm/test/MC/RISCV/rv32zbb-only-valid.s`

Reviewed By: asb

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

13 months ago[Support] Remove TaskQueue
Raphael Isemann [Tue, 13 Jun 2023 12:27:20 +0000 (08:27 -0400)]
[Support] Remove TaskQueue

TaskQueue was added several years ago as part of D48240.

There are currently no uses of this class anywhere in LLVM and I don't see
any patch that plans to use this class, so it doesn't seem useful to keep
compiling and testing this class at the moment.

The code itself is fine, so if we actually end up having a use for this code,
then I think it's perfectly fine to just re-commit this class then.

Differential revision: https://reviews.llvm.org/D86338

13 months ago[lldb][test] Re-XFAIL prefer-debug-over-eh-frame.test
Michael Buch [Tue, 13 Jun 2023 12:33:06 +0000 (13:33 +0100)]
[lldb][test] Re-XFAIL prefer-debug-over-eh-frame.test

This was un-XFAILed in `83cb2123be487302070562c45e6eb4955b22c2b4`
due to D144999. Since then D152540 fixed emission of eh_frame's
on Darwin, causing this test to fail again.

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

13 months ago[libc] Add Int<> type and fix (U)Int<128> compatibility issues.
Tue Ly [Thu, 8 Jun 2023 17:25:15 +0000 (13:25 -0400)]
[libc] Add Int<> type and fix (U)Int<128> compatibility issues.

Add Int<> and Int128 types to replace the usage of __int128_t in math
functions.  Clean up to make sure that (U)Int128 and __(u)int128_t are
interchangeable in the code base.

Reviewed By: sivachandra, mikhail.ramalho

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

13 months ago[AArch64] Try to combine MULL with uzp1.
Jingu Kang [Wed, 31 May 2023 09:12:37 +0000 (10:12 +0100)]
[AArch64] Try to combine MULL with uzp1.

For example,

 smull(trunc(x), extract_high(y))
 ==>
 smull(extract_high(uzp1(undef,x)), extract_high(y))

 -> It will be matched to smull2

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

13 months ago[clangd] Unify printing policy for type hints
Younan Zhang [Fri, 9 Jun 2023 10:51:47 +0000 (18:51 +0800)]
[clangd] Unify printing policy for type hints

(This patch addresses the comment from https://reviews.llvm.org/D151785#4402460.)

Previously, we used a special printing policy that enabled `PrintCanonicalTypes`
to print type hints for structure bindings. This was intended to
eliminate type aliases like `tuple_element::type`. However, this also
caused TypePrinter to print default template arguments, which could
result in losing the ability to see types like `std::basic_string<char>`
if the fully expanded template-id exceeded the default inlay hint threshold.

Simply getting the canonical type at the call site could help us get rid of
the side effect.

This also merges overloaded `addTypeHint` into one function without
`PrintingPolicy`.

Reviewed By: nridge

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

13 months ago[LoopVectorize][X86] Regenerate slm-no-vectorize.ll
Simon Pilgrim [Tue, 13 Jun 2023 13:12:13 +0000 (14:12 +0100)]
[LoopVectorize][X86] Regenerate slm-no-vectorize.ll

13 months ago[RDF] Add RegisterRef::idx and make toUnitId constexpr
Krzysztof Parzyszek [Fri, 2 Jun 2023 23:17:39 +0000 (16:17 -0700)]
[RDF] Add RegisterRef::idx and make toUnitId constexpr

13 months ago[MISched][scheduleDump] Use stable_sort to prevent test failures.
Francesco Petrogalli [Tue, 13 Jun 2023 12:04:05 +0000 (14:04 +0200)]
[MISched][scheduleDump] Use stable_sort to prevent test failures.

When building the compiler with -DLLVM_ENABLE_EXPENSIVE_CHECKS=ON,
sometimes resources that are dumped in scheduled traces gets reordered
even if they are booked in the same cycle. Using `stable_sort`
guarantees that such occasional reordering does not happen.

This change should fix failures like the one seen in
https://lab.llvm.org/buildbot/#/builders/16/builds/49592.

Reviewed By: RKSimon

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

13 months agoUse SelectionDAGBuiler::getRoot instead of SelectionDAG::getRoot
Serge Pavlov [Tue, 13 Jun 2023 10:50:03 +0000 (17:50 +0700)]
Use SelectionDAGBuiler::getRoot instead of SelectionDAG::getRoot

13 months ago[compiler-rt] Disable interceptor trampoline for SPARC
Marco Elver [Tue, 13 Jun 2023 11:46:19 +0000 (13:46 +0200)]
[compiler-rt] Disable interceptor trampoline for SPARC

SPARC jmp requires a delay slot after, and without it will likely result
in a crash. For now, just disable interceptor trampolines on SPARC,
because the specific usecase for them (3 interceptors) does not exist on
SPARC (yet). We can revisit, and carefully implement the support for
SPARC when required.

Reported-by: ro
13 months agoReapply D146987 "[Assignment Tracking] Enable by default"
OCHyams [Tue, 13 Jun 2023 11:42:36 +0000 (12:42 +0100)]
Reapply D146987 "[Assignment Tracking] Enable by default"

See https://discourse.llvm.org/t/rfc-enable-assignment-tracking/69399

This sets the -Xclang -fexperimental-assignment-tracking flag to the value
enabled which means it will be enabled so long as none of the following are
true: it's an LTO build, LLDB debugger tuning has been specified, or it's an O0
build (no work is done in any case if -g is not specified or -gmlt is used).

This reverts commit 9e7f14a8211c82dca64bd6b22d1c450d4c6d3e5b which reverts
https://reviews.llvm.org/D146987

13 months ago[Tooling/Inclusion] Add missing PRI family macros.
Haojian Wu [Tue, 13 Jun 2023 09:22:16 +0000 (11:22 +0200)]
[Tooling/Inclusion] Add missing PRI family macros.

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

13 months ago[NFC][BlockFrequency] Move operator definitions into header
Dhruv Chawla [Sun, 11 Jun 2023 08:01:39 +0000 (13:31 +0530)]
[NFC][BlockFrequency] Move operator definitions into header

While BlockFrequency::operator+= is a very simple operation, it's
definition is present in another TU which means that it doesn't get
inlined in non-LTO builds. This means that there is some performance
left on the table in those builds, as this operator is called many
times.

This patch moves that operator (and a few others) into the
BlockFrequency.h header which gives a small speedup (~0.1%):
https://llvm-compile-time-tracker.com/compare.php?from=6ee594be53e7efaa12086ad20f0d0268092a4c73&to=6ac6cd99e211fae5ae5de41ad608604aa22f1882&stat=instructions%3Au

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

13 months ago[NFC] Combine several DW_AT_const_value tests
OCHyams [Tue, 13 Jun 2023 10:07:37 +0000 (11:07 +0100)]
[NFC] Combine several DW_AT_const_value tests

Split from D151795. I'm not sure it's conclusive, but these are all the related
tests I could find easily.

Reviewed By: MaskRay

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

13 months ago[clangd] Desugar template parameter aliases in type hints
Younan Zhang [Wed, 31 May 2023 06:49:32 +0000 (14:49 +0800)]
[clangd] Desugar template parameter aliases in type hints

This patch alleviates https://github.com/clangd/clangd/issues/1298.

Containers in C++ such as `std::vector` or `llvm::SmallVector`,
introduce a series of type aliases to adapt to generic algorithms.

Currently, If we write an declarator involving expressions with
these containers and `auto` placeholder, we probably obtain opaque
type alias like following:

```
std::vector<int> v = {1, 2, 3};
auto value = v[1]; // hint for `value`: value_type
auto *ptr = &v[0]; // hint for `ptr`: value_type *
```

These hints are useless for most of the time. It would be nice if we
desugar the type of `value_type` and print `int`, `int *` respectively
in this situation. But note we can't always prefer desugared type
since user might introduce type-aliases for brevity, where printing
sugared types makes more sense.

This patch introduces a heuristic method that displays the desugared
type that is an alias of template parameter. It merges
analogous method `shouldPrintCanonicalType` into `maybeDesugar` as well.

Previous commit for shouldPrintCanonicalType: dde8a0fe91cc

Reviewed By: nridge

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

13 months ago[X86] X86FixupVectorConstantsPass - attempt to replace full width fp vector constant...
Simon Pilgrim [Tue, 13 Jun 2023 10:55:41 +0000 (11:55 +0100)]
[X86] X86FixupVectorConstantsPass - attempt to replace full width fp vector constant loads with broadcasts on AVX+ targets (REAPPLIED)

lowerBuildVectorAsBroadcast will not broadcast splat constants in all cases, resulting in a lot of situations where a full width vector load that has failed to fold but is loading splat constant values could use a broadcast load instruction just as cheaply, and save constant pool space.

NOTE: SSE3 targets can use MOVDDUP but not all SSE era CPUs can perform this as cheaply as a vector load, we will need to add scheduler model checks if we want to pursue this.

This is an updated commit of 98061013e01207444cfd3980cde17b5e75764fbe after being reverted at a279a09ab9524d1d74ef29b34618102d4b202e2f

13 months agoRevert "[Driver] Mark m_x86_Features_Group options as TargetSpecific"
Hans Wennborg [Tue, 13 Jun 2023 10:50:51 +0000 (12:50 +0200)]
Revert "[Driver] Mark m_x86_Features_Group options as TargetSpecific"

This broke cross-builds of llvm from x86_64 to arm64 mac, see
comment on
https://github.com/llvm/llvm-project/commit/1d6c3e29f6aa45914faa7be00a939b8f550f38e9

> so that they get an error on non-x86 targets.
> Follow-up to D151590.
>
> As a workaround for https://github.com/llvm/llvm-project/issues/63270, we don't
> report an error for -msse4.2.

This reverts commit 1d6c3e29f6aa45914faa7be00a939b8f550f38e9.

13 months agoRemove unused functions in X86LegalizerInfo.cpp (NFC)
Jie Fu [Tue, 13 Jun 2023 10:33:49 +0000 (18:33 +0800)]
Remove unused functions in X86LegalizerInfo.cpp (NFC)

/home/jiefu/llvm-project/llvm/lib/Target/X86/X86LegalizerInfo.cpp:48:1: error: unused function 'widen_1' [-Werror,-Wunused-function]
widen_1(const LegacyLegalizerInfo::SizeAndActionsVec &v) {
^
1 error generated.

13 months ago[AArch64][SVE] Extra patterns for predicated and/or/xor
David Green [Tue, 13 Jun 2023 10:21:18 +0000 (11:21 +0100)]
[AArch64][SVE] Extra patterns for predicated and/or/xor

Similar to the other patterns, this adds predicated and/xor/xor patterns.

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

13 months ago[llvm] Fix include guards
Elliot Goodrich [Tue, 13 Jun 2023 09:00:41 +0000 (10:00 +0100)]
[llvm] Fix include guards

Add missing include guards to LLVM header files that did not previously
have them and update existing include guards to ensure that they enclose
all non-whitespace, non-comment text to enable these headers for the
multiple-include optimization.

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

13 months agoMachineConstantPool::getConstantPoolIndex - don't reuse mismatched constants containe...
Simon Pilgrim [Tue, 13 Jun 2023 09:15:02 +0000 (10:15 +0100)]
MachineConstantPool::getConstantPoolIndex - don't reuse mismatched constants contained undef/poison (Issue #63108)

This patch fixes an issue where we were reusing constant pool entries that contained undef elements, despite the additional uses of the 'equivalent constant' requiring some/all of the elements to be zero.

The CanShareConstantPoolEntry helper function uses ConstantFoldCastOperand to bitcast the type mismatching constants to integer representations to allow comparison, but unfortunately this treats undef elements as zero (which they will be written out as in the final asm). This caused an issue where the original constant pool entry contained undef elements, which was shared with a later constant that required the elements to be zero. This then caused a later analysis pass to incorrectly discard these undef elements.

Ideally we need a more thorough analysis/merging of the constant pool entries so the elements are forced to real zero elements, but for now we just prevent reuse of the constant pool entry entirely if the constants don't have matching undef/poison elements.

Fixes #63108

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

13 months ago[GlobalIsel][X86] Update legalization of G_PHI/G_BRCOND
Simon Pilgrim [Tue, 13 Jun 2023 08:57:23 +0000 (09:57 +0100)]
[GlobalIsel][X86] Update legalization of G_PHI/G_BRCOND

Replace the legacy legalizer versions - still WIP but matches existing features, plus handles legal vector types.

13 months ago[GlobalIsel][X86] Regenerate legalize-phi.mir
Simon Pilgrim [Mon, 12 Jun 2023 19:05:20 +0000 (20:05 +0100)]
[GlobalIsel][X86] Regenerate legalize-phi.mir

13 months ago[CMake] Enable building with UBSAN + clang-cl on windows.
Pierre Gousseau [Tue, 13 Jun 2023 09:14:40 +0000 (10:14 +0100)]
[CMake] Enable building with UBSAN + clang-cl on windows.

Currently both ASAN and UBSAN are supported on Windows but only ASAN is enabled in LLVM build system. This patch enables the option to build LLVM with UBSAN on windows.

Tested with clang-cl released in LLVM16.

Submitting on behalf of @dwang.

Reviewed by: andrewng, pgousseau

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