platform/upstream/llvm.git
2 years ago[SimplifyCFG] Add test for PR49839 (NFC)
Nikita Popov [Mon, 13 Jun 2022 12:34:47 +0000 (14:34 +0200)]
[SimplifyCFG] Add test for PR49839 (NFC)

2 years ago[InstCombine] Only fold trunc(ext) pairs to bitcast if the source and destination...
Benjamin Kramer [Mon, 13 Jun 2022 12:31:43 +0000 (14:31 +0200)]
[InstCombine] Only fold trunc(ext) pairs to bitcast if the source and destination types are the same

This used to be always the case, but the addition of bfloat to the type
matrix makes this invalid.

2 years agoAdd `createDynamicDimValues` to tensor dialect utils
Frederik Gossen [Mon, 13 Jun 2022 12:25:13 +0000 (08:25 -0400)]
Add `createDynamicDimValues` to tensor dialect utils

The function creates dim ops for each dynamic dimension of the raked tensor
argument and returns these as values.

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

2 years ago[flang][NFC] Fix typo
Valentin Clement [Mon, 13 Jun 2022 12:19:45 +0000 (14:19 +0200)]
[flang][NFC] Fix typo

2 years ago[gn build] Port e183bf8e1599
LLVM GN Syncbot [Mon, 13 Jun 2022 12:03:48 +0000 (12:03 +0000)]
[gn build] Port e183bf8e1599

2 years ago[clang][driver] Only run multi-arch tests on Darwin
Jan Svoboda [Mon, 13 Jun 2022 12:03:02 +0000 (14:03 +0200)]
[clang][driver] Only run multi-arch tests on Darwin

This fixes the test introduced in a85670001ba2487988839656299771915ebc7633 that causes failures on non-Darwin systems.

2 years ago[lld-macho][reland] Support EH frames under arm64
Jez Ng [Mon, 13 Jun 2022 11:32:49 +0000 (07:32 -0400)]
[lld-macho][reland] Support EH frames under arm64

This reverts commit 10641a42e2286679e0d36ca827e1a40d95ae8ef1.

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

2 years ago[lld-macho][reland] Initial support for EH Frames
Jez Ng [Mon, 13 Jun 2022 01:56:45 +0000 (21:56 -0400)]
[lld-macho][reland] Initial support for EH Frames

This reverts commit 942f4e3a7cc9a9f8b2654817cff12907d1276031.

The additional change required to avoid the assertion errors seen
previously is:

  --- a/lld/MachO/ICF.cpp
  +++ b/lld/MachO/ICF.cpp
  @@ -443,7 +443,9 @@ void macho::foldIdenticalSections() {
                                 /*relocVA=*/0);
           isec->data = copy;
         }
  -    } else {
  +    } else if (!isEhFrameSection(isec)) {
  +      // EH frames are gathered as hashables from unwindEntry above; give a
  +      // unique ID to everything else.
         isec->icfEqClass[0] = ++icfUniqueID;
       }
     }

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

2 years ago[MC] Fix likely uninitialized memory bug
Jez Ng [Mon, 13 Jun 2022 11:41:17 +0000 (07:41 -0400)]
[MC] Fix likely uninitialized memory bug

See https://reviews.llvm.org/D122258#inline-1223493. I can't repro the
issue locally but this seems like the likely culprit.

Reviewed By: uabelho

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

2 years agoRevert "[RISCV] Add vread_csr and vwrite_csr to riscv_vector.h"
wangpc [Mon, 13 Jun 2022 11:28:22 +0000 (19:28 +0800)]
Revert "[RISCV] Add vread_csr and vwrite_csr to riscv_vector.h"

This reverts commit aebe24a856d2f40284d940970d4e159319dbb90f.

`REQUIRES` for RISCV target is needed in tests.

2 years ago[clang][driver] Fix compilation database dump with multiple architectures
Jan Svoboda [Thu, 9 Jun 2022 14:58:09 +0000 (16:58 +0200)]
[clang][driver] Fix compilation database dump with multiple architectures

Command lines with multiple `-arch` arguments expand into multiple entries in the compilation database. However, the file writes are not appending, meaning subsequent writes end up overwriting the previous ones, resulting in garbled output.

This patch fixes that by always appending to the file.

rdar://90165004

Reviewed By: dexonsmith

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

2 years ago[clang][driver] Introduce new -fdriver-only flag
Jan Svoboda [Thu, 9 Jun 2022 14:58:09 +0000 (16:58 +0200)]
[clang][driver] Introduce new -fdriver-only flag

This patch introduces the new -fdriver-only flag which instructs Clang to only execute the driver logic without running individual jobs. In a way, this is very similar to -###, with the following differences:
 * it doesn't automatically print all jobs,
 * it doesn't avoid side effects (e.g. it will generate compilation database when -MJ is specified).

This flag will be useful in testing D121997.

Reviewed By: dexonsmith, egorzhdan

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

2 years ago[flang]Add support for do concurrent
Mats Petersson [Tue, 7 Jun 2022 13:00:08 +0000 (14:00 +0100)]
[flang]Add support for do concurrent

[flang]Add support for do concurrent

Upstreaming from fir-dev on https://github.com/flang-compiler/f18-llvm-project

Support for concurrent execution in do-loops.

A selection of tests are also added.

Co-authored-by: V Donaldson <vdonaldson@nvidia.com>
Reviewed By: kiranchandramohan

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

2 years ago[RISCV] Add vread_csr and vwrite_csr to riscv_vector.h
wangpc [Mon, 13 Jun 2022 11:11:05 +0000 (19:11 +0800)]
[RISCV] Add vread_csr and vwrite_csr to riscv_vector.h

These two functions are described in RVV intrinsics doc
to read/write RVV CSRs. This matches what GCC does.

Reviewed By: craig.topper

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

2 years ago[DAG] visitINSERT_VECTOR_ELT - attempt to reconstruct BUILD_VECTOR before other fold...
Simon Pilgrim [Mon, 13 Jun 2022 10:47:14 +0000 (11:47 +0100)]
[DAG] visitINSERT_VECTOR_ELT - attempt to reconstruct BUILD_VECTOR before other fold interfere

Another issue unearthed by D127115

We take a long time to canonicalize an insert_vector_elt chain before being able to convert it into a build_vector - even if they are already in ascending insertion order, we fold the nodes one at a time into the build_vector 'seed', leaving plenty of time for other folds to alter it (in particular recognising when they come from extract_vector_elt resulting in a shuffle_vector that is much harder to fold with).

D127115 makes this particularly difficult as we're almost guaranteed to have the lost the sequence before all possible insertions have been folded.

This patch proposes to begin at the last insertion and attempt to collect all the (oneuse) insertions right away and create the build_vector before its too late.

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

2 years ago[ARM] Fix "local variable is initialized but not referenced" MSVX warning. NFC
Simon Pilgrim [Mon, 13 Jun 2022 10:47:58 +0000 (11:47 +0100)]
[ARM] Fix "local variable is initialized but not referenced" MSVX warning. NFC

2 years ago[test] Add test for D126700 NFC
zhongyunde [Mon, 13 Jun 2022 10:37:06 +0000 (18:37 +0800)]
[test] Add test for D126700 NFC

2 years ago[InstSimplify][IR] Handle trapping constant aggregate (PR49839)
Nikita Popov [Mon, 13 Jun 2022 10:32:22 +0000 (12:32 +0200)]
[InstSimplify][IR] Handle trapping constant aggregate (PR49839)

Unfortunately, it's not just constant expressions that can trap,
we might also have a trapping constant expression nested inside
a constant aggregate.

Perform the check during phi folding on Constant rather than
ConstantExpr, and extend the Constant::mayTrap() implementation
to also recursive into ConstantAggregates, not just ConstantExprs.

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

2 years ago[gn build] Port 988682a3892e
LLVM GN Syncbot [Mon, 13 Jun 2022 10:23:45 +0000 (10:23 +0000)]
[gn build] Port 988682a3892e

2 years ago[InstSimplify] Add additional test for PR49839 (NFC)
Nikita Popov [Mon, 13 Jun 2022 10:22:56 +0000 (12:22 +0200)]
[InstSimplify] Add additional test for PR49839 (NFC)

This is a variant involving an aggregate constant, which was not
covered by the previous patch.

2 years ago[clang][AArch64][SVE] Implicit conversions for vector-scalar operations
David Truby [Mon, 13 Jun 2022 09:54:26 +0000 (09:54 +0000)]
[clang][AArch64][SVE] Implicit conversions for vector-scalar operations

This patch allows the same implicit conversions for vector-scalar
operations in SVE that are allowed for NEON.

Depends on D126377

Reviewed By: c-rhodes

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

2 years ago[libc++] Fix std::lower_bound with C++20-hostile iterators
Nikolas Klauser [Mon, 13 Jun 2022 08:43:43 +0000 (10:43 +0200)]
[libc++] Fix std::lower_bound with C++20-hostile iterators

Reviewed By: EricWF, #libc

Spies: sstefan1, libcxx-commits, mgorny

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

2 years ago[NFC][Alignment] Convert MemCpyOptimizer.cpp
Guillaume Chatelet [Mon, 13 Jun 2022 08:52:45 +0000 (08:52 +0000)]
[NFC][Alignment] Convert MemCpyOptimizer.cpp

2 years agoRevert "[ARM][Thumb] Command-line option to ensure AAPCS compliant Frame Records"
Lucas Prates [Mon, 13 Jun 2022 10:00:49 +0000 (11:00 +0100)]
Revert "[ARM][Thumb] Command-line option to ensure AAPCS compliant Frame Records"

Reverting change due to test failure.

This reverts commit 6119053dab67129eb1700dbf36db3524dd3e421f.

2 years ago[NFC][InstCombine] Refactor InstCombinerImpl::foldSelectIntoOp
David Sherwood [Fri, 10 Jun 2022 12:41:53 +0000 (13:41 +0100)]
[NFC][InstCombine] Refactor InstCombinerImpl::foldSelectIntoOp

Introduce a lambda function so that we remove a lot of code
duplication.

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

2 years ago[MachineScheduler] Order more stores by ascending address
zhongyunde [Mon, 13 Jun 2022 09:24:59 +0000 (17:24 +0800)]
[MachineScheduler] Order more stores by ascending address

According D125377, we order STP Q's by ascending address. While on some
targets, paired 128 bit loads and stores are slow, so the STP will split
into STRQ and STUR, so I hope these stores will also be ordered.
Also add subtarget feature ascend-store-address to control the aggressive order.

Reviewed By: dmgreen, fhahn

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

2 years ago[ARM][Thumb] Command-line option to ensure AAPCS compliant Frame Records
Lucas Prates [Fri, 6 May 2022 09:31:11 +0000 (10:31 +0100)]
[ARM][Thumb] Command-line option to ensure AAPCS compliant Frame Records

Currently the a AAPCS compliant frame record is not always created for
functions when it should. Although a consistent frame record might not
be required in some cases, there are still scenarios where applications
may want to make use of the call hierarchy made available trough it.

In order to enable the use of AAPCS compliant frame records whilst keep
backwards compatibility, this patch introduces a new command-line option
(`-mframe-chain=[none|aapcs|aapcs+leaf]`) for Aarch32 and Thumb backends.
The option allows users to explicitly select when to use it, and is also
useful to ensure the extra overhead introduced by the frame records is
only introduced when necessary, in particular for Thumb targets.

Reviewed By: efriedma

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

2 years ago[NFC][Thumb1] Use FrameDestroy flag to identify epilog instructions
Lucas Prates [Mon, 23 May 2022 15:40:38 +0000 (16:40 +0100)]
[NFC][Thumb1] Use FrameDestroy flag to identify epilog instructions

Simiarly to what's done on both ARM's and AArch64's frame lowering code,
this updates Thumb1FrameLowering to use the FrameDestroy Machine
Instruction flag to identify instructions inserted as part of the epilog
instead of relying on assumptions about specific machine instructions.

Reviewed By: efriedma

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

2 years ago[mlir] Fix ClangTidyPerformance finding (NFC).
Adrian Kuegel [Mon, 13 Jun 2022 08:48:17 +0000 (10:48 +0200)]
[mlir] Fix ClangTidyPerformance finding (NFC).

2 years ago[InstCombine] Don't push operation across loop phi
Nikita Popov [Fri, 10 Jun 2022 14:17:19 +0000 (16:17 +0200)]
[InstCombine] Don't push operation across loop phi

When pushing an operation across a phi node, we should avoid doing
so across a loop backedge. This is generally non-profitable, because
it does not reduce the number of times the operation is executed,
and could lead to an infinite combine loop.

The code was already guarding against this, but using an
insufficiently strong condition, which did not cover the case where
the operation was originally outside the loop (in which case the
transform moves the operation from outside the loop into the loop,
which is particularly undesirable).

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

2 years ago[InstSimplify] Update GEP test to use opaque pointers (NFC)
Nikita Popov [Fri, 10 Jun 2022 15:18:33 +0000 (17:18 +0200)]
[InstSimplify] Update GEP test to use opaque pointers (NFC)

With opaque pointers, we end up merging these GEPs and dropping
the inrange attribute (in the last two cases). This did not happen
previously, because typed pointers use less powerful GEP folding logic.

I'm a bit unsure whether this is something we need to be concerned
about or not. I believe that generally our stance is that we should
perform folds even if this requires losing poison-generating flags
like inrange.

We can either a) accept this as-is, b) try to inhibit folding if it
requires dropping inrange or c) try to fold to poison if we know
that inrange is going to be violated.

For now, we accept it as-is.

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

2 years ago[AArch64] Mark smull and umull as commutative.
David Green [Mon, 13 Jun 2022 08:24:15 +0000 (09:24 +0100)]
[AArch64] Mark smull and umull as commutative.

2 years ago[NFC] Remove straight UB from SROA tests
Nuno Lopes [Mon, 13 Jun 2022 07:59:07 +0000 (08:59 +0100)]
[NFC] Remove straight UB from SROA tests
Including 'br undef', store/load to undef pointers.
Plus some cosmetics: select undef, insertvalue undef -> poison.

Recommit c1b6103 with fix.

2 years ago[NFC][polly] Removed dead code
Guillaume Chatelet [Mon, 13 Jun 2022 07:50:35 +0000 (07:50 +0000)]
[NFC][polly] Removed dead code

2 years ago[X86][Disassembler] Fix displacement operand size for symbolizer
Maksim Panchenko [Tue, 31 May 2022 21:50:19 +0000 (14:50 -0700)]
[X86][Disassembler] Fix displacement operand size for symbolizer

On 64-bit X86, 0x66 operand-size override prefix will change the size of
the instruction operand, e.g. from 32 bits to 16 bits, but it will not
modify the size of the displacement operand used for memory addressing,
which will always be 32 bits.

Reviewed By: skan, rafauler

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

2 years ago[clang-format] Handle deprecated options in dump_format_style.py
owenca [Sat, 11 Jun 2022 20:06:58 +0000 (13:06 -0700)]
[clang-format] Handle deprecated options in dump_format_style.py

Also add two deprecated options as comments back to Format.h.

2 years ago[ELF] Change getRISCVPCRelHi20 error to conventional errorOrWarn
Fangrui Song [Mon, 13 Jun 2022 04:15:06 +0000 (21:15 -0700)]
[ELF] Change getRISCVPCRelHi20 error to conventional errorOrWarn

2 years ago[RISCV] Use isShiftedInt to improve readability. NFC
Craig Topper [Mon, 13 Jun 2022 03:34:14 +0000 (20:34 -0700)]
[RISCV] Use isShiftedInt to improve readability. NFC

2 years agoRevert "[NFC] Remove 'br i1 undef' from SROA tests"
Kazushi (Jam) Marukawa [Mon, 13 Jun 2022 03:32:25 +0000 (12:32 +0900)]
Revert "[NFC] Remove 'br i1 undef' from SROA tests"

Transforms/SROA/vector-promotion-different-size.ll causes errors.

This reverts commit c1b610307df22d12687bde26919e45752c33ab0b.

2 years ago[AArch64] Use default member initialization (NFC)
Kazu Hirata [Mon, 13 Jun 2022 01:52:02 +0000 (18:52 -0700)]
[AArch64] Use default member initialization (NFC)

Identified with modernize-use-default-member-init.

2 years ago[Support] Use default member initialization (NFC)
Kazu Hirata [Mon, 13 Jun 2022 01:46:25 +0000 (18:46 -0700)]
[Support] Use default member initialization (NFC)

Identified with modernize-use-default-member-init.

2 years ago[Transforms] Use default member initialization (NFC)
Kazu Hirata [Mon, 13 Jun 2022 01:39:05 +0000 (18:39 -0700)]
[Transforms] Use default member initialization (NFC)

Identified with modernize-use-default-member-init.

2 years ago[X86] Use default member initialization (NFC)
Kazu Hirata [Mon, 13 Jun 2022 01:30:45 +0000 (18:30 -0700)]
[X86] Use default member initialization (NFC)

Identified with modernize-use-default-member-init.

2 years ago[CMake][libcxx] Use target_include_directories for libc++ headers
Petr Hosek [Mon, 28 Mar 2022 21:12:23 +0000 (14:12 -0700)]
[CMake][libcxx] Use target_include_directories for libc++ headers

This is the idiomatic way to handle include directories in CMake.

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

2 years ago[lld-macho] Make `--icf=safe` work with LTO
Jez Ng [Sun, 12 Jun 2022 21:26:08 +0000 (17:26 -0400)]
[lld-macho] Make `--icf=safe` work with LTO

Just matter of enabling the config option.

(Also changed the platform of the input test file to macOS, since that's
the default that we specify in the `%lld` substitution. The conflict was
causing errors when linking with LTO.)

Reviewed By: #lld-macho, thakis

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

2 years ago[MC][re-land] Omit DWARF unwind info if compact unwind is present where eligible
Jez Ng [Sun, 12 Jun 2022 21:15:56 +0000 (17:15 -0400)]
[MC][re-land] Omit DWARF unwind info if compact unwind is present where eligible

This reverts commit d941d597837d9e1405086f008c9bd6a71e7263c9.

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

2 years ago[NFC] Remove unused variable `MF`
Hubert Tong [Sun, 12 Jun 2022 20:31:55 +0000 (16:31 -0400)]
[NFC] Remove unused variable `MF`

https://reviews.llvm.org/D127583 removed the only use of this variable
and broke builds with warnings-as-errors.

2 years ago[libc++] Use unsigned char in basic_string::__short again
Nikolas Klauser [Sat, 11 Jun 2022 21:43:00 +0000 (23:43 +0200)]
[libc++] Use unsigned char in basic_string::__short again

D125496 changed the string layout on windows. Change `__is_long_` and `__size_` back to using `unsigned char` to fix the issue.

Reviewed By: Mordante, #libc

Spies: jloser, libcxx-commits, ayzhao

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

2 years agofix test expected output (fixes arm buildbot failure) [NFC]
Nuno Lopes [Sun, 12 Jun 2022 18:29:00 +0000 (19:29 +0100)]
fix test expected output (fixes arm buildbot failure) [NFC]

2 years ago[DAG] Enable ISD::FSHL/R SimplifyMultipleUseDemandedBits handling inside SimplifyDema...
Simon Pilgrim [Sun, 12 Jun 2022 17:56:24 +0000 (18:56 +0100)]
[DAG] Enable ISD::FSHL/R SimplifyMultipleUseDemandedBits handling inside SimplifyDemandedBits

This patch allows SimplifyDemandedBits to call SimplifyMultipleUseDemandedBits in cases where the source operand has other uses, enabling us to peek through the shifted value if we don't demand all the bits/elts.

This helps with several of the regressions from D125836

2 years ago[clang][CodeGen] Switch a few placeholders from UndefValue to PoisonValue
Nuno Lopes [Sun, 12 Jun 2022 18:03:47 +0000 (19:03 +0100)]
[clang][CodeGen] Switch a few placeholders from UndefValue to PoisonValue
This change is cosmetic, as these are dummy values that are not observable, but it
gets us closer to removing undef.
NFC

2 years ago[RISCV] Move some methods out of RISCVInstrInfo and into RISCV namespace.
Craig Topper [Sun, 12 Jun 2022 17:38:29 +0000 (10:38 -0700)]
[RISCV] Move some methods out of RISCVInstrInfo and into RISCV namespace.

These methods don't access any state from RISCVInstrInfo. Make them
free functions in the RISCV namespace.

Reviewed By: frasercrmck

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

2 years ago[IR] Call DenseMap::erase directly (NFC)
Kazu Hirata [Sun, 12 Jun 2022 17:47:06 +0000 (10:47 -0700)]
[IR] Call DenseMap::erase directly (NFC)

We can erase an item in DenseMap without checking its membership first.

2 years ago[clang] Use any_of and none_of (NFC)
Kazu Hirata [Sun, 12 Jun 2022 17:17:12 +0000 (10:17 -0700)]
[clang] Use any_of and none_of (NFC)

2 years ago[SimplifyCFG,EarlyCSE] Update 2 tests to not branch on undef (NFC).
Florian Hahn [Sun, 12 Jun 2022 17:03:26 +0000 (18:03 +0100)]
[SimplifyCFG,EarlyCSE] Update 2 tests to not branch on undef (NFC).

2 years ago[LV] Update test to use GEP so it is not dead.
Florian Hahn [Sun, 12 Jun 2022 15:57:47 +0000 (16:57 +0100)]
[LV] Update test to use GEP so it is not dead.

The test should use the GEP for the store, so it is not dead.

2 years agoRevert "[X86][RFC] Enable `_Float16` type support on X86 following the psABI"
Mehdi Amini [Sun, 12 Jun 2022 15:14:37 +0000 (15:14 +0000)]
Revert "[X86][RFC] Enable `_Float16` type support on X86 following the psABI"

This reverts commit 2d2da259c8726fd5c974c01122a9689981a12196.

This breaks MLIR integration test (JIT crashing), reverting in the
meantime.

2 years agoRevert "[MC] Omit DWARF unwind info if compact unwind is present where eligible"
Jez Ng [Sun, 12 Jun 2022 14:46:49 +0000 (10:46 -0400)]
Revert "[MC] Omit DWARF unwind info if compact unwind is present where eligible"

This reverts commit ef501bf85d8c869248e51371f0e74bcec0e7b229.

2 years ago[X86] combineConcatVectorOps - add support for concatenation of VSELECT/BLENDV nodes...
Simon Pilgrim [Sun, 12 Jun 2022 14:40:24 +0000 (15:40 +0100)]
[X86] combineConcatVectorOps - add support for concatenation of VSELECT/BLENDV nodes (REAPPLIED)

If the LHS/RHS selection operands can be cheaply concatenated back together then replace 2 x 128-bit selection nodes with 1 x 256-bit node

Addresses the regression introduced in the bug fix from rGd5af6a38082b39ae520a328e44dc29ebcb036bb2

REAPPLIED with for bug identified in rGea8fb3b60196

2 years ago[X86] Add regression test for rGea8fb3b60196
Simon Pilgrim [Sun, 12 Jun 2022 14:27:11 +0000 (15:27 +0100)]
[X86] Add regression test for rGea8fb3b60196

Reduced from test case reported by @srj for the concatenation of VSELECT/BLENDV nodes

2 years ago[NFC] Remove 'br i1 undef' from SROA tests
Nuno Lopes [Sun, 12 Jun 2022 14:29:59 +0000 (15:29 +0100)]
[NFC] Remove 'br i1 undef' from SROA tests

2 years agoFix endian conversion of sub-byte types
Ulrich Weigand [Sun, 12 Jun 2022 14:03:30 +0000 (16:03 +0200)]
Fix endian conversion of sub-byte types

When convertEndianOfCharForBEmachine is called with elementBitWidth
smaller than CHAR_BIT, the default case is invoked, but this does
nothing at all and leaves the output array unchanged.

Fix DenseIntOrFPElementsAttr::convertEndianOfArrayRefForBEmachine
by not calling convertEndianOfCharForBEmachine in this case, and
instead simply copying the input to the output (for sub-byte types,
endian conversion is in fact a no-op).

Reviewed By: rriddle

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

2 years ago[MC] Omit DWARF unwind info if compact unwind is present where eligible
Jez Ng [Sun, 12 Jun 2022 14:03:56 +0000 (10:03 -0400)]
[MC] Omit DWARF unwind info if compact unwind is present where eligible

Previously, omitting unnecessary DWARF unwinds was only done in two
cases:
* For Darwin + aarch64, if no DWARF unwind info is needed for all the
  functions in a TU, then the `__eh_frame` section would be omitted
  entirely. If any one function needed DWARF unwind, then MC would emit
  DWARF unwind entries for all the functions in the TU.
* For watchOS, MC would omit DWARF unwind on a per-function basis, as
  long as compact unwind was available for that function.

This diff makes it so that we omit DWARF unwind on a per-function basis
for Darwin + aarch64 as well. In addition, we introduce the flag
`--emit-dwarf-unwind=` which can toggle between `always`,
`no-compact-unwind` (only emit DWARF when CU cannot be emitted for a
given function), and the target platform `default`.  `no-compact-unwind`
is particularly useful for newer x86_64 platforms: we don't want to omit
DWARF unwind for x86_64 in general due to possible backwards compat
issues, but we should make it possible for people to opt into this
behavior if they are only targeting newer platforms.

**Motivation:** I'm working on adding support for `__eh_frame` to LLD,
but I'm concerned that we would suffer a perf hit. Processing compact
unwind is already expensive, and that's a simpler format than EH frames.
Given that MC currently produces one EH frame entry for every compact
unwind entry, I don't think processing them will be cheap. I tried to do
something clever on LLD's end to drop the unnecessary EH frames at parse
time, but this made the code significantly more complex. So I'm looking
at fixing this at the MC level instead.

**Addendum:** It turns out that there was a latent bug in the X86
backend when `OmitDwarfIfHaveCompactUnwind` is naively enabled, which is
not too surprising given that this combination has not been heretofore
used.

For functions that have unwind info that cannot be encoded with CU, MC
would end up dropping both the compact unwind entry (OK; existing
behavior) as well as the DWARF entries (not OK).  This diff fixes things
so that we emit the DWARF entry, as well as a CU entry with encoding
`UNWIND_X86_MODE_DWARF` -- this basically tells the unwinder to look for
the DWARF entry. I'm not 100% sure the `UNWIND_X86_MODE_DWARF` CU entry
is necessary, this was the simplest fix. ld64 seems to be able to handle
both the absence and presence of this CU entry. Ultimately ld64 (and
LLD) will synthesize `UNWIND_X86_MODE_DWARF` if it is absent, so there
is no impact to the final binary size.

Reviewed By: davide, lhames

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

2 years ago[docs][clang] Fix a broken link on the APINotes doc
Yuki Okushi [Sat, 28 May 2022 16:59:56 +0000 (01:59 +0900)]
[docs][clang] Fix a broken link on the APINotes doc

This patch replaces a link with a GitHub one.

Fixes llvm#55748

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

2 years ago[DAG] visitSRL - pull out ShiftVT. NFC.
Simon Pilgrim [Sun, 12 Jun 2022 13:02:23 +0000 (14:02 +0100)]
[DAG] visitSRL - pull out ShiftVT. NFC.

2 years ago[AArch64] Look through bitcast when looking for extract_high subvector
David Green [Sun, 12 Jun 2022 09:59:09 +0000 (10:59 +0100)]
[AArch64] Look through bitcast when looking for extract_high subvector

Since D61806, DAGCombiner has folded subvector_extract(bitcast(..)) to
bitcast(subvector_extract(..)), which would place a bitcast between a
subvector_extract and the operation that could be converted to a high
neon instruction (like smull2). This adds better matching for the
subvector_extract, through the tablegen extract_high PatFrags to
optionally skip the bitcast under little ending, still matchings an
extract of the high half of the input vector.

I didn't update the extract_high of a duplicate patterns, as the
ComplexPattern need names operands. I did add a extract_high_dup_v8i16
PatFrag to abstract away the common code, which can be extended in a
future patch.

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

2 years ago[X86][RFC] Enable `_Float16` type support on X86 following the psABI
Phoebe Wang [Sat, 11 Jun 2022 15:19:25 +0000 (23:19 +0800)]
[X86][RFC] Enable `_Float16` type support on X86 following the psABI

GCC and Clang/LLVM will support `_Float16` on X86 in C/C++, following
the latest X86 psABI. (https://gitlab.com/x86-psABIs)

_Float16 arithmetic will be performed using native half-precision. If
native arithmetic instructions are not available, it will be performed
at a higher precision (currently always float) and then truncated down
to _Float16 immediately after each single arithmetic operation.

Reviewed By: LuoYuanke

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

2 years agoRevert "[lit] Passthrough CLANG_MODULE_CACHE_PATH env var"
Alex Brachet [Sun, 12 Jun 2022 03:01:08 +0000 (03:01 +0000)]
Revert "[lit] Passthrough CLANG_MODULE_CACHE_PATH env var"

This reverts commit 6466c9abf3674bade1f6ee859f24ebc7aaf9cd88.

2 years ago[LoongArch] clang-format some code in LoongArchISelLowering.cpp. NFC
Weining Lu [Sun, 12 Jun 2022 02:41:56 +0000 (10:41 +0800)]
[LoongArch] clang-format some code in LoongArchISelLowering.cpp. NFC

2 years ago[LoongArch] Remove unnecessary `static` keyword as `const` has internal linkage. NFC
Weining Lu [Sun, 12 Jun 2022 02:03:04 +0000 (10:03 +0800)]
[LoongArch] Remove unnecessary `static` keyword as `const` has internal linkage. NFC

See https://reviews.llvm.org/D127199#inline-1222815

2 years agoAutogenerate sve-fixed-length-frame-offests-crash.ll . NFC
Amaury Séchet [Sun, 12 Jun 2022 01:54:10 +0000 (01:54 +0000)]
Autogenerate sve-fixed-length-frame-offests-crash.ll . NFC

2 years agoAutogenerate sve-fixed-length-bitselect.ll . NFC
Amaury Séchet [Sun, 12 Jun 2022 01:50:41 +0000 (01:50 +0000)]
Autogenerate sve-fixed-length-bitselect.ll . NFC

2 years ago[Clang][VE][NFC] Fix a comment
Kazushi (Jam) Marukawa [Sun, 12 Jun 2022 01:26:55 +0000 (10:26 +0900)]
[Clang][VE][NFC] Fix a comment

2 years ago[lld-macho] Add support for -w
Keith Smiley [Sat, 11 Jun 2022 07:10:48 +0000 (00:10 -0700)]
[lld-macho] Add support for -w

This flag suppresses warnings produced by the linker. In ld64 this has
an interesting interaction with -fatal_warnings, it silences the
warnings but the link still fails. Instead of doing that here we still
print the warning and eagerly fail the link in case both are passed,
this seems more reasonable so users can understand why the link fails.

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

2 years ago[libc++][test] Add tuple trivial destructor test
Joe Loser [Sun, 12 Jun 2022 00:11:04 +0000 (18:11 -0600)]
[libc++][test] Add tuple trivial destructor test

There is only compile-time tests in `dtor.pass.cpp`, so it could be made a
`dtor.compile.pass.cpp`. Instead, add a runtime test for testing the trivial
destructor behavior for `tuple`.

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

2 years agofix comment typo to cycle bots
Nico Weber [Sat, 11 Jun 2022 22:55:40 +0000 (18:55 -0400)]
fix comment typo to cycle bots

2 years ago[VPlan] Remove dead OrigLoop argument from removeDeadRecipes (NFC).
Florian Hahn [Sat, 11 Jun 2022 22:33:04 +0000 (23:33 +0100)]
[VPlan] Remove dead OrigLoop argument from removeDeadRecipes (NFC).

The use of the argument has been remove a while ago. Remove the dead
argument.

2 years ago[InstCombine] Remove unnecessary UB from some tests.
Florian Hahn [Sat, 11 Jun 2022 22:22:48 +0000 (23:22 +0100)]
[InstCombine] Remove unnecessary UB from some tests.

2 years ago[lit] Passthrough CLANG_MODULE_CACHE_PATH env var
Alex Brachet [Sat, 11 Jun 2022 21:04:02 +0000 (21:04 +0000)]
[lit] Passthrough CLANG_MODULE_CACHE_PATH env var

This environment variable can be set to control module
caching. It disables caching by setting the variable
empty. As such, it needs to be handled differently
from other environment variables here which are
assumed to not be empty.

2 years ago[DAG] visitVECTOR_SHUFFLE - fold splat(insert_vector_elt()) and splat(scalar_to_vecto...
Simon Pilgrim [Sat, 11 Jun 2022 20:06:37 +0000 (21:06 +0100)]
[DAG] visitVECTOR_SHUFFLE - fold splat(insert_vector_elt()) and splat(scalar_to_vector()) to build_vector splats

Addresses a number of regressions identified in D127115

2 years ago[libc++][test] Refactor SmallBasicString uses in range.lazy.split tests
Joe Loser [Sun, 29 May 2022 01:08:25 +0000 (19:08 -0600)]
[libc++][test] Refactor SmallBasicString uses in range.lazy.split tests

The tests for `std::ranges::lazy_split_view` heavily use a wrapper class around
`std::string` because `std::string` was not `constexpr` until recently. Where
possible, remove the wrapper class and extra functionality no longer needed.
Remove `libcxx/test/std/ranges/range.adaptors/range.lazy.split/small_string.h`
and inline its one use remaining in
`libcxx/test/std/ranges/range.adaptors/range.lazy.split/general.pass.cpp`.

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

2 years ago[clang-tidy][docs] Remove an unintentional paragraph break
Dmitri Gribenko [Fri, 10 Jun 2022 23:43:27 +0000 (01:43 +0200)]
[clang-tidy][docs] Remove an unintentional paragraph break

2 years ago[clang-tidy][docs] Use std::optional instead of absl::optional in examples
Dmitri Gribenko [Fri, 10 Jun 2022 23:41:10 +0000 (01:41 +0200)]
[clang-tidy][docs] Use std::optional instead of absl::optional in examples

The standard type is vastly more popular than the Abseil polyfill, so it
makes more sense to use it in documentation, even though the checker
actually understands both (and that fact is documented already).

2 years ago[BOLT][NFC] Move printDebugInfo out of BC::printInstruction
Amir Ayupov [Sat, 11 Jun 2022 18:58:10 +0000 (11:58 -0700)]
[BOLT][NFC] Move printDebugInfo out of BC::printInstruction

Simplify `BinaryContext::printInstruction`.

Reviewed By: ayermolo

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

2 years ago[llvm] Use contains (NFC)
Kazu Hirata [Sat, 11 Jun 2022 18:46:16 +0000 (11:46 -0700)]
[llvm] Use contains (NFC)

2 years ago[X86][AVX512] Retain pmuldq broadcast loads on 32-bit targets
Simon Pilgrim [Sat, 11 Jun 2022 18:29:56 +0000 (19:29 +0100)]
[X86][AVX512] Retain pmuldq broadcast loads on 32-bit targets

Don't demand just the lower 32-bits on 32-bit AVX512 targets to preserve 64-bit broadcast loads patterns

2 years ago[X86][AVX512] Add tests showing failure to retain pmuldq broadcast loads on 32-bit...
Simon Pilgrim [Sat, 11 Jun 2022 17:48:26 +0000 (18:48 +0100)]
[X86][AVX512] Add tests showing failure to retain pmuldq broadcast loads on 32-bit targets

Noticed while investigating the build vector issues on D127115

2 years ago[DAG] visitINSERT_VECTOR_ELT - add <1 x ???> insert_vector_elt(v0,extract_vector_elt...
Simon Pilgrim [Sat, 11 Jun 2022 14:54:54 +0000 (15:54 +0100)]
[DAG] visitINSERT_VECTOR_ELT - add <1 x ???> insert_vector_elt(v0,extract_vector_elt(v1,0),0) special case handling

Check if we're just replacing one v1x?? vector with another

2 years agoUse getValueOr (NFC)
Kazu Hirata [Sat, 11 Jun 2022 18:24:57 +0000 (11:24 -0700)]
Use getValueOr (NFC)

2 years agoUse isa instead of dyn_cast (NFC)
Kazu Hirata [Sat, 11 Jun 2022 18:15:52 +0000 (11:15 -0700)]
Use isa instead of dyn_cast (NFC)

2 years ago[lldb][bindings] Implement __repr__ instead of __str__
Dave Lee [Thu, 9 Jun 2022 15:37:02 +0000 (08:37 -0700)]
[lldb][bindings] Implement __repr__ instead of __str__

When using the `script` Python repl, SB objects are printed in a way that gives
the user no information. The simplest example is:

```
(lldb) script lldb.debugger
<lldb.SBDebugger; proxy of <Swig Object of type 'lldb::SBDebugger *' at 0x1097a5de0> >
```

This output comes from the Python repl printing the `repr()` of an object.

None of the SB classes implement `__repr__`, and all print like the above.
However, many (most?, all?) SB classes implement `__str__`. Because they
implement `__str__`, a more detailed output can be had by `print`ing the
object, for example:

```
(lldb) script print(lldb.debugger)
Debugger (instance: "debugger_1", id: 1)
```

For convenience, this change switches all SB classes that implement to
`__str__` to instead implement `__repr__`. **The result is that `str()` and
`repr()` will produce the same output**. This is because `str` calls `__repr__`
for classes that have  no `__str__` method.

The benefit being that when writing a `script` invocation, you don't need to
remember to wrap in `print()`. If that isn't enough motivation, consider the
case where your Python expression results in a list of SB objects, in that case
you'd have to `map` or use a list comprehension like `[str(x) for x in <expr>]`
in order to see the details of the objects in the list.

For reference, the docs for `repr` say:

> repr(object)
>   Return a string containing a printable representation of an object. For
>   many types, this function makes an attempt to return a string that would
>   yield an object with the same value when passed to eval(); otherwise, the
>   representation is a string enclosed in angle brackets that contains the
>   name of the type of the object together with additional information often
>   including the name and address of the object. A class can control what this
>   function returns for its instances by defining a __repr__() method.

and the docs for `__repr__` say:

> object.__repr__(self)
>   Called by the repr() built-in function to compute the “official” string
>   representation of an object. If at all possible, this should look like a
>   valid Python expression that could be used to recreate an object with the
>   same value (given an appropriate environment). If this is not possible, a
>   string of the form <...some useful description...> should be returned. The
>   return value must be a string object. If a class defines __repr__() but not
>   __str__(), then __repr__() is also used when an “informal” string
>   representation of instances of that class is required.
>
>   This is typically used for debugging, so it is important that the
>   representation is information-rich and unambiguous.

Even if it were convenient to construct Python expressions for SB classes so
that they could be `eval`'d, however for typical lldb usage, I can't think of a
motivating reason to do so. As it stands, the only action the docs say to do,
that this change doesn't do, is wrap the `repr` string in `<>` angle brackets.

An alternative implementation is to change lldb's python repl to apply `str()`
to the top level result. While this would work well in the case of a single SB
object, it doesn't work for a list of SB objects, since `str([x])` uses `repr`
to convert each list element to a string.

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

2 years ago[mlir:MultiOpDriver] Add operands to worklist should be checked
Chia-hung Duan [Sat, 11 Jun 2022 15:56:21 +0000 (15:56 +0000)]
[mlir:MultiOpDriver] Add operands to worklist should be checked

Operand's defining op may not be valid for adding to the worklist under
stict mode

Reviewed By: rriddle

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

2 years ago[X86] Add __extension__ to f16c macro intrinsics to suppress warnings about compound...
Craig Topper [Sat, 11 Jun 2022 15:28:41 +0000 (08:28 -0700)]
[X86] Add __extension__ to f16c macro intrinsics to suppress warnings about compound literals

This had previously been fixed, but was lost 4 years ago when __extension__
was removed from many intrinsic macros.

Refixes PR32491.

2 years ago[Clang][Doc][SafeStack] Fix deadlink (NFC)
ksyx [Sat, 11 Jun 2022 14:59:51 +0000 (10:59 -0400)]
[Clang][Doc][SafeStack] Fix deadlink (NFC)

2 years ago[DAG] visitINSERT_VECTOR_ELT - fold insert_vector_elt(scalar_to_vector(x),v,i) -...
Simon Pilgrim [Sat, 11 Jun 2022 14:29:18 +0000 (15:29 +0100)]
[DAG] visitINSERT_VECTOR_ELT - fold insert_vector_elt(scalar_to_vector(x),v,i) -> build_vector()

Allow scalar_to_vector nodes to be used for the start of a build_vector creation

2 years ago[libc++][NFC] Update ranges algorithms status page
Nikolas Klauser [Sat, 11 Jun 2022 14:20:47 +0000 (16:20 +0200)]
[libc++][NFC] Update ranges algorithms status page

2 years ago[PowerPC] Regenerate pre-inc-disable.ll checks
Simon Pilgrim [Sat, 11 Jun 2022 14:12:45 +0000 (15:12 +0100)]
[PowerPC] Regenerate pre-inc-disable.ll checks

2 years ago[X86] Replace X32 check prefix with X86
Simon Pilgrim [Sat, 11 Jun 2022 13:30:27 +0000 (14:30 +0100)]
[X86] Replace X32 check prefix with X86

We try to use X32 only for gnux32 triple cases

2 years ago[libc++][format] Implement format-string.
Mark de Wever [Sat, 2 Oct 2021 10:38:46 +0000 (12:38 +0200)]
[libc++][format] Implement format-string.

Implements the compile-time checking of the formatting arguments.

Completes:
- P2216 std::format improvements

Reviewed By: #libc, ldionne

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

2 years ago[AArch64] Generate FADDP from shuffled fadd
David Green [Sat, 11 Jun 2022 13:16:37 +0000 (14:16 +0100)]
[AArch64] Generate FADDP from shuffled fadd

As a follow up to D126686, this does the same fold for floating point
add and shuffle. In this case it is limited to reassoc either x[0]+x[1]
or x[1]+x[0] for both result[0] and results[1].

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