platform/upstream/llvm.git
21 months agoReturn a shared_ptr from ScratchTypeSystemClang::GetForTarget()
Adrian Prantl [Mon, 9 Jan 2023 22:47:42 +0000 (14:47 -0800)]
Return a shared_ptr from ScratchTypeSystemClang::GetForTarget()

The current interface theoretically could lead to a use-after-free
when a client holds on to the returned pointer. Fix this by returning
a shared_ptr to the scratch typesystem.

rdar://103619233

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

21 months ago[libc++][test] Make some string tests MSVC-friendly
Casey Carter [Mon, 9 Jan 2023 05:58:56 +0000 (21:58 -0800)]
[libc++][test] Make some string tests MSVC-friendly

* Using one-or-two letter names for globals is asking for shadowing warnings.
* MSVCSTL's container proxy allocations strike again
* MSVCSTL's `<string>` doesn't define `std::out_of_range`
* `basic_string::substr` takes two arguments of type `size_type`. Let's use that type instead of `size_t` and `ptrdiff_t` to avoid narrowing warnings.

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

21 months ago[ProfileData] Fix a warning
Kazu Hirata [Mon, 9 Jan 2023 22:59:25 +0000 (14:59 -0800)]
[ProfileData] Fix a warning

This patch fixes:

  llvm/lib/ProfileData/SampleProfWriter.cpp:100:10: error: unused
  variable 'OriginalFunctionCount' [-Werror,-Wunused-variable]

21 months ago[AMDGPU] More tests for vector_shuffle.packed.ll. NFC.
Stanislav Mekhanoshin [Mon, 9 Jan 2023 22:53:02 +0000 (14:53 -0800)]
[AMDGPU] More tests for vector_shuffle.packed.ll. NFC.

Pre-commit tests before the next patch. Subtest shuffle_v16f16_concat
exposes the problem with suboptimal lowering.

21 months ago[JumpThreading] Fix test to require asserts
Alex Brachet [Mon, 9 Jan 2023 22:51:08 +0000 (22:51 +0000)]
[JumpThreading] Fix test to require asserts

21 months ago[mlir][sparse] Improve the rewriting for NewOp with dimension ordering.
bixia1 [Mon, 9 Jan 2023 16:45:18 +0000 (08:45 -0800)]
[mlir][sparse] Improve the rewriting for NewOp with dimension ordering.

Previously, we use a temporary tensor with identity ordering. We now use a
temporary tensor with the destination dimension ordering, to enable the use of
sort_coo for sorting the tensor.

Reviewed By: Peiming

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

21 months ago[lldb] Trust the arange accelerator tables in dSYMs
Jonas Devlieghere [Mon, 9 Jan 2023 22:33:39 +0000 (14:33 -0800)]
[lldb] Trust the arange accelerator tables in dSYMs

When ingesting aranges from a dSYM, always trust the contents of the
accelerator table since it always comes from dsymutil.

According to Instruments, skipping the decoding of all CU DIEs to get at
the DW_AT_ranges attribute removes ~3.5 seconds from setting a
breakpoint by file/line when debugging clang with a dSYM. Interestingly
on the wall clock the speedup is less noticeable, but still present.

rdar://problem/56057688

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

21 months ago[MemProf] Fix combined index handling for locals
Teresa Johnson [Fri, 30 Dec 2022 15:47:12 +0000 (07:47 -0800)]
[MemProf] Fix combined index handling for locals

Since the linker does not resolve local symbols, we cannot look up
whether they are prevailing. The prior check was blocking all locals
from getting memprof summaries in the combined index.

Modified the existing test case to contain a local. This necessitated
some other fixes as the order of summary entries changed.

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

21 months ago[llvm-profdata] Add option to cap profile output size
William Huang [Thu, 29 Dec 2022 00:35:06 +0000 (00:35 +0000)]
[llvm-profdata] Add option to cap profile output size

Allow user to specify `--output-size-limit=n` to cap the size of generated profile to be strictly under n. Functions with the lowest total sample count are dropped first if necessary. Due to using a heuristic, excessive functions may be dropped to satisfy the size requirement

Reviewed By: snehasish

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

21 months agoOpenMPOpt: Check nested parallelism in target region
Rafael A Herrera Guaitero [Mon, 9 Jan 2023 21:54:35 +0000 (15:54 -0600)]
OpenMPOpt: Check nested parallelism in target region

Analysis that determines if a parallel region can reach another parallel region in any target region of the TU.
A new global var is emitted with the name of the kernel + "_nested_parallelism", which is either 0 or 1 depending on the result.

Reviewed By: jdoerfert

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

21 months ago[InstCombine] limit zext-of-icmp folds to bit-hacks
Sanjay Patel [Mon, 9 Jan 2023 21:29:24 +0000 (16:29 -0500)]
[InstCombine] limit zext-of-icmp folds to bit-hacks

In the changed tests, we avoid creating extra instructions,
and there are no obvious regressions in IR tests at least.

Codegen should be able to create the shift+mask form if that
is profitable.

This is a more general fix for issue #59897 than 0eedc9e56712 .

21 months ago[InstCombine] simplify code and fix formatting; NFC
Sanjay Patel [Mon, 9 Jan 2023 21:27:44 +0000 (16:27 -0500)]
[InstCombine] simplify code and fix formatting; NFC

21 months ago[InstCombine] add tests for zext-of-icmp; NFC
Sanjay Patel [Mon, 9 Jan 2023 20:59:56 +0000 (15:59 -0500)]
[InstCombine] add tests for zext-of-icmp; NFC

21 months ago[RISCV] Add -experimental-ztso test coverage
Philip Reames [Mon, 9 Jan 2023 21:01:26 +0000 (13:01 -0800)]
[RISCV] Add -experimental-ztso test coverage

For the moment, this is the same as the default memory model.

21 months ago[mlir][spirv] Fix MLIR code snippet marker in TD files
Lei Zhang [Mon, 9 Jan 2023 20:58:26 +0000 (12:58 -0800)]
[mlir][spirv] Fix MLIR code snippet marker in TD files

Reviewed By: kuhar

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

21 months ago[libc][Obvious] Re-enable log10 tests.
Tue Ly [Mon, 9 Jan 2023 20:54:50 +0000 (15:54 -0500)]
[libc][Obvious] Re-enable log10 tests.

21 months ago[libc][Obvious] Address few GCC warnings.
Siva Chandra Reddy [Mon, 9 Jan 2023 20:25:52 +0000 (20:25 +0000)]
[libc][Obvious] Address few GCC warnings.

21 months ago[libc][Obvious] Fix typos in LLVMLibCArchitectures.cmake defining target architectures.
Tue Ly [Mon, 9 Jan 2023 20:11:24 +0000 (15:11 -0500)]
[libc][Obvious] Fix typos in LLVMLibCArchitectures.cmake defining target architectures.

Fix typos in LLVMLibCArchitectures.cmake defining target architectures.

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

21 months ago[sanitizer] Don't intercept LFS64 symbols on musl
Fangrui Song [Mon, 9 Jan 2023 20:43:23 +0000 (12:43 -0800)]
[sanitizer] Don't intercept LFS64 symbols on musl

LFS64 symbols in musl are for glibc-ABI-compat and not intended for linking
(correct usage will not create LFS64 references). The next release 1.2.4 will
disallow linking against LFS64 symbols[1].

For sanitizers, let's just remove LFS64 interceptors. In case of erroneous LFS64
references, asan/tsan will detect fewer problems and msan may have false
positives.

[1]: https://git.musl-libc.org/cgit/musl/commit/?id=246f1c811448f37a44b41cd8df8d0ef9736d95f4

Reviewed By: thesamesam

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

21 months agoRevert "[libc] Templatize str{,n}cmp"
Alex Brachet [Mon, 9 Jan 2023 20:24:16 +0000 (20:24 +0000)]
Revert "[libc] Templatize str{,n}cmp"

This reverts commit c6dcbed2e5327f0c11962bdbbcd02f1b5c570fea.

Broke tests on arm and aarch64

21 months ago[Clang] Correctly capture bindings in dependent lambdas.
Corentin Jabot [Wed, 2 Nov 2022 11:54:46 +0000 (12:54 +0100)]
[Clang] Correctly capture bindings in dependent lambdas.

Structured bindings were not properly marked odr-used
and therefore captured in generic lambddas.

Fixes #57826

It is unclear to me if further simplification can be gained
through the allowance described in
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0588r1.html.

Either way, I think this makes support for P0588 completes,
but we probably want to add test for that in a separate PR.
(and I lack confidence I understand P0588 sufficiently to assert
the completeness of our cnformance).

Reviewed By: aaron.ballman, #clang-language-wg

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

21 months ago[libc] Move b* string functions to strings.h
Alex Brachet [Mon, 9 Jan 2023 20:16:20 +0000 (20:16 +0000)]
[libc] Move b* string functions to strings.h

Traditionally these functions are exposed in string*s*.h not string.h

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

21 months ago[libc] Templatize str{,n}cmp
Alex Brachet [Mon, 9 Jan 2023 20:13:02 +0000 (20:13 +0000)]
[libc] Templatize str{,n}cmp

This will be used to implement the case insensitive str{,n}casecmp

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

21 months ago[BOLT] introducing profi params
spupyrev [Tue, 27 Sep 2022 18:50:42 +0000 (11:50 -0700)]
[BOLT] introducing profi params

We want to use profile inference (**profi**) in BOLT for stale profile matching.
To this end, I am making a few changes modifying the interface of the algorithm.
This is the first change for existing usages of profi (e.g., CSSPGO):
- introducing an object holding the algorithmic parameters;
- some renaming of existing options;
- dropped unused option, SampleProfileInferEntryCount, as we don't plan to change its default value;
- no changes in the output / tests.

Reviewed By: hoy

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

21 months ago[msan] Use SizeClassAllocator64 for AArch64
Fangrui Song [Mon, 9 Jan 2023 19:49:08 +0000 (19:49 +0000)]
[msan] Use SizeClassAllocator64 for AArch64

Now that D137666 requires 48-bit VMA for AArch64, we can switch to
SizeClassAllocator64 for a slightly more efficient allocator
(asan/lsan already switched by default).

It seems that we can pick kSpaceBeg = 0xE00000000000ULL to support both Linux
("app-15") and FreeBSD ("high memory").

Reviewed By: #sanitizers, vitalybuka

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

21 months agoRevert "Revert "[clang][dataflow] Only model struct fields that are used in the funct...
Yitzhak Mandelbaum [Fri, 6 Jan 2023 13:34:12 +0000 (13:34 +0000)]
Revert "Revert "[clang][dataflow] Only model struct fields that are used in the function being analyzed.""

This reverts commit 2b1a517a92bfdfa3b692a660e19a2bb22513a567. It's a fix forward
with two memory errors fixed, one of which was the cause of the build breakage
in the buildbots.

Original message:

Previously, the model for structs modeled all fields in a struct when
`createValue` was called for that type. This patch adds a prepass on the
function under analysis to discover the fields referenced in the scope and then
limits modeling to only those fields. This reduces wasted memory usage
(modeling unused fields) which can be important for programs that use large
structs.

Note: This patch obviates the need for https://reviews.llvm.org/D123032.

21 months ago[RISCV] Minor style cleanup in advance of D141311 [nfc]
Philip Reames [Mon, 9 Jan 2023 19:31:28 +0000 (11:31 -0800)]
[RISCV] Minor style cleanup in advance of D141311 [nfc]

21 months ago[LLDB] Change formatting to use llvm::formatv
Alexander Yermolovich [Mon, 9 Jan 2023 19:29:03 +0000 (11:29 -0800)]
[LLDB] Change formatting to use llvm::formatv

In preparation for eanbling 64bit support in LLDB switching to use llvm::formatv
instead of format MACROs.

Reviewed By: labath, JDevlieghere

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

21 months ago[WebAssembly] Ensure 'end_function' in functions
Heejin Ahn [Thu, 5 Jan 2023 23:04:02 +0000 (15:04 -0800)]
[WebAssembly] Ensure 'end_function' in functions

Local info is supposed to be emitted in the start of every function.
When there are locals, `.local` section should be present, and we emit
local info according to the section.

If there is no locals, empty local info should be emitted. This empty
local info is emitted whenever a first instruction is emitted within a
function without encountering a `.local` section. If there is no
instruction, `end_function` pseudo instruction should be present and the
empty local info will be emitted when parsing the pseudo instruction.

The following assembly is malformed because the function `test` doesn't
have an `end_function` at the end, and the parser doesn't end up
emitting the empty local info needed. But currently we don't error out
and silently produce an invalid binary.
```
.functype test () -> ()
test:
```

This patch adds one extra state to the Wasm assembly parser,
`FunctionLabel` to detect whether a function label is parsed but not
ended properly when the next function starts or the file ends.

It is somewhat tricky to distinguish `FunctionLabel` and
`FunctionStart`, because it is not always possible to ensure the state
goes from `FunctionLabel` -> `FunctionStart`. `.functype` directive does
not seem to be mandated before a function label, in which case we don't
know if the label is a function at the time of parsing. But when we do
know the label is function, we would like to ensure it ends with an
`end_function` properly. Also we would like to error out when it does
not.

For example,
```
.functype test() -> ()
test:
```
We should error out for this because we know `test` is a function and it
doesn't end with an `end_function`. This PR fixes this.

```
test:
```
We don't error out for this because there is no info that `test` is a
function, so we don't know whether there should be an `end_function` or
not.

```
test:
.functype test() -> ()
```
We error out for this currently already, because we currently switch to
`FunctionStart` state when we first see `.functype` directive after its
label definition.

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

Reviewed By: sbc100

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

21 months agoAMDGPU: Use DataExtractor for printf string extraction
Matt Arsenault [Mon, 9 Jan 2023 18:48:55 +0000 (13:48 -0500)]
AMDGPU: Use DataExtractor for printf string extraction

Attempt 2 to fix big endian bot failures.

21 months ago[mlir][sparse] remove redundant template parameter (NFC)
Peiming Liu [Mon, 9 Jan 2023 17:45:00 +0000 (17:45 +0000)]
[mlir][sparse] remove redundant template parameter (NFC)

The template parameter is no longer needed after MutSparseTensorDescriptor
is implemented as a subclass of SparseTensorDescriptorImpl. The only purpose
for it was to enable SFINAE.

Reviewed By: bixia

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

21 months ago[RISCV] Consolidate test lines in fence lowering test
Philip Reames [Mon, 9 Jan 2023 19:00:11 +0000 (11:00 -0800)]
[RISCV] Consolidate test lines in fence lowering test

These are identical for RV32 and RV64.

21 months agotsan: increase app mappings for aarch64 48-bit
Thurston Dang [Tue, 3 Jan 2023 21:47:51 +0000 (21:47 +0000)]
tsan: increase app mappings for aarch64 48-bit

Currently, tsan's memory mappings include 4GB
for high app, 20GB for mid app, and 8GB for low
app. The high app and mid app mappings are
too small for large programs, especially if ASLR
entropy (mmap_rnd_bits) is set higher. The low app
region (for non-PIE) is too small for some of tcmalloc's
internal tests (this does not affect normal apps,
since tsan will replace malloc).

This CL increases the memory mappings to 4TB for
high app, 1.3TB for mid app, and 10TB for low app. Note
that tsan's 44-bit pointer compression/decompression imposes
a 16TB limit on the combined size of the app mappings, making
this set of mappings more or less maximal.

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

21 months ago[lldb] Fix symbol table use after free
Augusto Noronha [Fri, 6 Jan 2023 23:17:25 +0000 (15:17 -0800)]
[lldb] Fix symbol table use after free

The symbol file stores a raw pointer to the main object file's symbol
table. This pointer, however, can be freed, if ObjectFile::ClearSymtab
is ever called. This patch makes sure out pointer to the symbol file
is valid before using it.

21 months ago[RISCV] Add test coverage for singlethread fences
Philip Reames [Mon, 9 Jan 2023 18:07:17 +0000 (10:07 -0800)]
[RISCV] Add test coverage for singlethread fences

21 months ago[SLP][NFC]Move getExtractIndex function for future changes, NFC.
Alexey Bataev [Mon, 9 Jan 2023 17:49:12 +0000 (09:49 -0800)]
[SLP][NFC]Move getExtractIndex function for future changes, NFC.

21 months ago[mlir] Fix a warning
Kazu Hirata [Mon, 9 Jan 2023 17:51:17 +0000 (09:51 -0800)]
[mlir] Fix a warning

This patch fixes:

  mlir/lib/Dialect/Vector/Transforms/VectorDistribute.cpp:947:13:
  error: variable 'distributedDim' set but not used
  [-Werror,-Wunused-but-set-variable]

21 months ago[lld-macho] Prevent assertions for aliases to weak_def_can_be_hidden symbols
Paul Kirth [Thu, 5 Jan 2023 20:32:25 +0000 (20:32 +0000)]
[lld-macho] Prevent assertions for aliases to weak_def_can_be_hidden symbols

In https://reviews.llvm.org/D137982 we found that on Mach-O private
aliases could trigger an assert in lld when the aliasee was a
weak_def_can_be_hidden symbol.

This appears to be incorrect, and should be allowed in Mach-O.
Disallowing this behavior is also inconsistent with how ld64 handles
a private alias to weak_def_can_be_hidden symbols.

This patch removes the assert and tests that LLD handles such aliases
gracefully.

Reviewed By: #lld-macho, int3

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

21 months ago[LocalStackSlotAllocation] Minor simplifications. NFC
Craig Topper [Mon, 9 Jan 2023 17:45:22 +0000 (09:45 -0800)]
[LocalStackSlotAllocation] Minor simplifications. NFC

Instead of maintaining a separate valid flag for BaseReg, Use
BaseReg.isValid(). I think this is left over from an older
implementation that maintained a vector of base registers.

The other change is not do a speculative assignment to BaseOffset
that needs to be reverted. Only commit it after we do the check.

Reviewed By: arsenm

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

21 months ago[mlir] Print a newline when dumping Type
Theodore Luo Wang [Mon, 9 Jan 2023 17:33:22 +0000 (17:33 +0000)]
[mlir] Print a newline when dumping Type

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

Reviewed By: mehdi_amini, Mogball

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

21 months ago[InstCombine] bitrev (zext i1 X) --> select X, SMinC, 0
Sanjay Patel [Mon, 9 Jan 2023 17:25:02 +0000 (12:25 -0500)]
[InstCombine] bitrev (zext i1 X) --> select X, SMinC, 0

https://alive2.llvm.org/ce/z/ZXCtgi

This breaks the infinite combine loop for issue #59897,
but we may still need more changes to avoid those loops.

21 months ago[InstCombine] add tests for bitreverse of i1; NFC
Sanjay Patel [Mon, 9 Jan 2023 17:20:32 +0000 (12:20 -0500)]
[InstCombine] add tests for bitreverse of i1; NFC

21 months ago[libc++] Use %{clang-query} when calling clang-query
Nikolas Klauser [Mon, 9 Jan 2023 17:15:17 +0000 (18:15 +0100)]
[libc++] Use %{clang-query} when calling clang-query

21 months ago[AMDGPU][NFC] Rename GFX10A16 operands.
Ivan Kosarev [Mon, 9 Jan 2023 16:45:29 +0000 (16:45 +0000)]
[AMDGPU][NFC] Rename GFX10A16 operands.

They do not seem to be GFX10-specific anymore. Also renames the
corresponding feature.

Reviewed By: dp

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

21 months ago[flang] Add runtime default initialization for polymorphic intent(out) dummy
Valentin Clement [Mon, 9 Jan 2023 16:53:16 +0000 (17:53 +0100)]
[flang] Add runtime default initialization for polymorphic intent(out) dummy

This patch adds runtime default initialization for polymorphic
dummy argument. The dynamic type might require default initialization
but not the declared type.

Reviewed By: jeanPerier, PeteSteinfeld

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

21 months ago[flang] Handle emboxing of a fir.ref<none> to an unlimited polymorphic box
Valentin Clement [Mon, 9 Jan 2023 16:52:14 +0000 (17:52 +0100)]
[flang] Handle emboxing of a fir.ref<none> to an unlimited polymorphic box

When an array element is extracted from an unlimited polymorphic array, the
emboxing of this element has to retrive the type code and element size from
the initial array. This patch retrive this information through the extracted
type descriptor.

This situation can be found in code like:

```
subroutine sub1(a)
  class(*) :: a(:)
  select type (x=>a(1))
  type is (integer)
    x = 10
  end select
end subroutine
```

Reviewed By: jeanPerier, PeteSteinfeld

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

21 months ago[AArch64] Add additional reassociation test.
Florian Hahn [Mon, 9 Jan 2023 16:38:19 +0000 (16:38 +0000)]
[AArch64] Add additional reassociation test.

Add a test where the reassociation candidates are split across 2 blocks.

21 months ago[mlir][spirv] Account for type conversion failures in scf-to-spirv
Jakub Kuderski [Mon, 9 Jan 2023 16:35:46 +0000 (11:35 -0500)]
[mlir][spirv] Account for type conversion failures in scf-to-spirv

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

Reviewed By: antiagainst

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

21 months ago[OpenMP] Fix some tests failing with 'libgomp' as the default library
Joseph Huber [Mon, 9 Jan 2023 16:02:28 +0000 (10:02 -0600)]
[OpenMP] Fix some tests failing with 'libgomp' as the default library

Summary:
There's some static checks on the library, we can't do offloading with
`libgomp` for OpenMP. This patch specifies the library for the tests to
avoid this breaking tests.

21 months ago[ConstantRange] Test 1 bit ranges in exhaustive tests (NFC)
Nikita Popov [Mon, 9 Jan 2023 15:51:43 +0000 (16:51 +0100)]
[ConstantRange] Test 1 bit ranges in exhaustive tests (NFC)

There have been multiple cases where range calculations were wrong
in the 1 bit case. Make sure we catch these by not specifying the
bit width explicitly, and letting the test framework pick it (which
will now always test 1 and 4 bits both).

21 months ago[compiler-rt] Move up undefined macro checks
Alex Brachet [Mon, 9 Jan 2023 15:54:11 +0000 (15:54 +0000)]
[compiler-rt] Move up undefined macro checks

Previously HWCAP_ATOMIC and others were being used before checking if
they were defined. This moves up all the ifndef checks to define these
macros if they are not yet defined.

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

21 months ago[mlir][spirv] Clean up transform pass definitions. NFC.
Jakub Kuderski [Mon, 9 Jan 2023 15:50:06 +0000 (10:50 -0500)]
[mlir][spirv] Clean up transform pass definitions. NFC.

- Make naming more consistent.
- Drop unnecessary custom constructors definitions.
- Move pass documentation to pass descriptions.

Reviewed By: antiagainst

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

21 months ago[mlir][vector] Distribute vector.insert op
Matthias Springer [Mon, 9 Jan 2023 15:46:01 +0000 (16:46 +0100)]
[mlir][vector] Distribute vector.insert op

In case the distributed dim of the dest vector is also a dim of the src vector, each lane inserts a smaller part of the source vector. Otherwise, one lane inserts the entire src vector and the other lanes do nothing.

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

21 months ago[AMDGPU] S_MULK_I32 does not define SCC. NFCI.
Jay Foad [Mon, 9 Jan 2023 14:47:09 +0000 (14:47 +0000)]
[AMDGPU] S_MULK_I32 does not define SCC. NFCI.

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

21 months ago[mlir][vector] Distribute vector.insertelement op
Matthias Springer [Mon, 9 Jan 2023 15:40:32 +0000 (16:40 +0100)]
[mlir][vector] Distribute vector.insertelement op

In case of a distribution, only one lane inserts the scalar value. In case of a broadcast, every lane inserts the scalar.

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

21 months ago[mlir][vector] Support vector.extract distribution of >1D vectors
Matthias Springer [Mon, 9 Jan 2023 15:35:29 +0000 (16:35 +0100)]
[mlir][vector] Support vector.extract distribution of >1D vectors

Ops such as `%1 = vector.extract %0[2] : vector<5x96xf32>`.

Distribute the source vector, then extract. In case of a 1d extract, rewrite to vector.extractelement.

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

21 months ago[libc++] Add missing include in __format/unicode.h
Nikolas Klauser [Mon, 9 Jan 2023 15:37:31 +0000 (16:37 +0100)]
[libc++] Add missing include in __format/unicode.h

21 months ago[ConstantRange] Fix single bit abs range (PR59887)
Nikita Popov [Mon, 9 Jan 2023 15:29:37 +0000 (16:29 +0100)]
[ConstantRange] Fix single bit abs range (PR59887)

For a full range input, we would produce an empty range instead
of a full range. The change to the SMin.isNonNegative() branch is
an optimality fix, because we should account for the potentially
discarded SMin value in the IntMinIsPoison case.

Change TestUnaryOpExhaustive to test both 4 and 1 bits, to both
cover this specific case in unit tests, and make sure all other
unary operations deal with 1-bit inputs correctly.

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

21 months ago[libc++][test] Fix missing include in `bit_ceil.fail.cpp`
Joe Loser [Mon, 9 Jan 2023 15:13:38 +0000 (08:13 -0700)]
[libc++][test] Fix missing include in `bit_ceil.fail.cpp`

The test uses `size_t` but does not include a header defining it.  Include
`<cstddef>` which provides `size_t`.

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

21 months ago[libc++] Remove HIDE_FROM_ABI from virtual functions
Louis Dionne [Wed, 21 Dec 2022 15:08:54 +0000 (10:08 -0500)]
[libc++] Remove HIDE_FROM_ABI from virtual functions

_LIBCPP_HIDE_FROM_ABI (which is what _LIBCPP_INLINE_VISIBILITY is) uses
ABI tags to avoid ODR violations when linking together object files
compiled against different versions of libc++. However, pointer
authentication uses the mangled name of the function to sign the
function pointer in the vtable, which means that the ABI tag effectively
changes how the pointers are signed.

This leads to PAC failures when passing an object that holds one of these
pointers in its vtable across an ABI boundary: one side will sign the
pointer using one function mangling (with one ABI tag), and the other
side will authenticate the pointer expecting it to have a different
mangled name, which won't work.

To make sure this does not regress in the future, this patch also adds
a clang-query test to detect incorrect applications of _LIBCPP_HIDE_FROM_ABI.

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

21 months ago[InstCombine] reduce smul.ov with i1 types to 'and'
Sanjay Patel [Mon, 9 Jan 2023 14:53:45 +0000 (09:53 -0500)]
[InstCombine] reduce smul.ov with i1 types to 'and'

https://alive2.llvm.org/ce/z/5tLkW6

There's still a miscompile bug as shown in issue #59876 / D141214 .

21 months ago[InstCombine] add tests for smul/umul with overflow with i1 types; NFC
Sanjay Patel [Mon, 9 Jan 2023 14:26:28 +0000 (09:26 -0500)]
[InstCombine] add tests for smul/umul with overflow with i1 types; NFC

More coverage for D141214 / issue #59876

21 months ago[AArch64] Add test showing reassociation potential.
Florian Hahn [Mon, 9 Jan 2023 15:20:55 +0000 (15:20 +0000)]
[AArch64] Add test showing reassociation potential.

Add a test case where some ops of a reassociate-able expression are in
an earlier block.

This can appear in practice, e.g. when computing the final reduction
value after vectorization.

21 months ago[CVP] Add test for PR59887 (NFC)
Nikita Popov [Mon, 9 Jan 2023 15:15:36 +0000 (16:15 +0100)]
[CVP] Add test for PR59887 (NFC)

Also fix all the incorrect intrinsic name mangling while here.

21 months ago[AArch64][SME] Improve streaming-compatible codegen for extending loads/truncating...
Sander de Smalen [Mon, 9 Jan 2023 09:45:50 +0000 (09:45 +0000)]
[AArch64][SME] Improve streaming-compatible codegen for extending loads/truncating stores.

This is another step in aligning addTypeForStreamingSVE with addTypeForFixedLengthSVE,
which also improves code quality for extending loads and truncating stores.

Reviewed By: hassnaa-arm

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

21 months ago[clangd] Full support for #import insertions
David Goldman [Tue, 6 Dec 2022 21:33:12 +0000 (16:33 -0500)]
[clangd] Full support for #import insertions

These are still disabled by default, but will work in ObjC code if you
enable the `-import-insertions` flag.

Completion requires ASTSignals to be available; before ASTSignals are
available, we will always use #include. Once they are available, the
behavior varies as follows:

- For source files, use #import if the ObjC language flag is enabled
- For header files:
  - If the ObjC language flag is disabled, use #include
  - If the header file contains any #imports, use #import
  - If the header file references any ObjC decls, use #import
  - Otherwise, use #include

IncludeFixer support is similar, but it does not rely upon ASTSignals,
instead it does the above checks excluding the scan for ObjC symbols.

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

21 months ago[clangd] Add flag to control #import include insertions
David Goldman [Tue, 6 Dec 2022 19:25:46 +0000 (14:25 -0500)]
[clangd] Add flag to control #import include insertions

This will be disabled by default, hopefully we can enable for the next
major release.

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

21 months ago[InstCombine] Preserve alignment in atomicrmw -> store fold
Nikita Popov [Mon, 9 Jan 2023 14:36:32 +0000 (15:36 +0100)]
[InstCombine] Preserve alignment in atomicrmw -> store fold

Preserve the alignment of the original atomicrmw, rather than using
the ABI alignment.

The same problem exists for loads, but that code is being removed
in D141277 anyway.

21 months ago[flang] Disable LTO when building the flang runtime
David Truby [Fri, 18 Nov 2022 16:55:56 +0000 (16:55 +0000)]
[flang] Disable LTO when building the flang runtime

When building the flang runtime if LTO is enabled the archive file
contains LLVM IR rather than object code. Currently flang is not
LTO aware so cannot link this file to compiled Fortran code.

This patch disables LTO when building the flang runtime to avoid
this issue.

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

21 months ago[InstCombine] Test alignment in atomicrmw -> store transform (NFC)
Nikita Popov [Mon, 9 Jan 2023 14:25:15 +0000 (15:25 +0100)]
[InstCombine] Test alignment in atomicrmw -> store transform (NFC)

And regenerate test checks. The current alignment is incorrect.

21 months ago[LLD] [COFF] Add a testcase for the type of autoexported symbols from LTO
Martin Storsjö [Mon, 9 Jan 2023 11:18:19 +0000 (13:18 +0200)]
[LLD] [COFF] Add a testcase for the type of autoexported symbols from LTO

This adds test coverage for the behaviour that broke in
7370ff624d217b0f8f7512ca5b651a9b8095a411.

21 months agoRevert "[LLD] Remove global state in lld/COFF"
Martin Storsjö [Mon, 9 Jan 2023 14:04:09 +0000 (16:04 +0200)]
Revert "[LLD] Remove global state in lld/COFF"

This reverts commit 7370ff624d217b0f8f7512ca5b651a9b8095a411.
(and 47fb8ae2f9a4075de05433ef24f459b6befd1730).

This commit broke the symbol type in import libraries generated
for mingw autoexported symbols, when the source files were built
with LTO. I'll commit a testcase that showcases this issue after
the revert.

21 months ago[RISC-V][HWASAN] Don't explicitly load GOT entry to call hwasan mismatch routine
Alexey Baturo [Wed, 31 Aug 2022 05:21:39 +0000 (08:21 +0300)]
[RISC-V][HWASAN] Don't explicitly load GOT entry to call hwasan mismatch routine

Reviewed by: luismarques

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

21 months ago[ARM] Fold And/Or into CSel if possible
David Green [Mon, 9 Jan 2023 13:28:57 +0000 (13:28 +0000)]
[ARM] Fold And/Or into CSel if possible

This is the ARM equivalent of D141119, where we fold `and x, (csel 0, 1, cc)`
to `csel ZR, x, cc` if we know that x is 0/1 and for `or x, (csel 0, 1, cc)`
emit `csinc x, ZR, cc`. The or pattern gets recognized from a cmov under Arm.

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

21 months ago[InstCombine] Fold zero check followed by decrement to usub.sat
Jamie Hill-Daniel [Mon, 9 Jan 2023 13:21:12 +0000 (14:21 +0100)]
[InstCombine] Fold zero check followed by decrement to usub.sat

Fold (a == 0) : 0 ? a - 1 into usub.sat(a, 1).

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

21 months ago[InstCombine] Add tests for saturating subtract by one (NFC)
Jamie Hill-Daniel [Mon, 9 Jan 2023 13:07:55 +0000 (14:07 +0100)]
[InstCombine] Add tests for saturating subtract by one (NFC)

Tests for D140798.

21 months ago[mlir] verify against nullptr payload in transform dialect
Alex Zinenko [Mon, 9 Jan 2023 13:01:25 +0000 (14:01 +0100)]
[mlir] verify against nullptr payload in transform dialect

When establishing the correspondence between transform values and
payload operations or parameters, check that the latter are non-null and
report errors. This was previously allowed for exotic cases of partially
successfull transformations with "apply each" trait, but was dangerous.
The "apply each" implementation was reworked to remove the need for this
functionality, so this can now be hardned to avoid null pointer
dereferences.

Reviewed By: nicolasvasilache

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

21 months ago[include-cleaner] Don't count references to operators as uses
Haojian Wu [Thu, 22 Dec 2022 10:54:07 +0000 (11:54 +0100)]
[include-cleaner] Don't count references to operators as uses

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

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

21 months ago[include-cleaner] Filter template instantiations from AST roots.
Viktoriia Bakalova [Mon, 9 Jan 2023 10:49:08 +0000 (10:49 +0000)]
[include-cleaner] Filter template instantiations from AST roots.

Fix: https://github.com/llvm/llvm-project/issues/59825
Differential Revision: https://reviews.llvm.org/D141271

21 months ago[mlir][linalg] Reuploading: Apply shortened printing/parsing form to linalg.reduce.
Aliia Khasanova [Mon, 9 Jan 2023 07:25:03 +0000 (08:25 +0100)]
[mlir][linalg] Reuploading: Apply shortened printing/parsing form to linalg.reduce.

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

21 months ago[Test] One more test where check is not replaced to invariant
Max Kazantsev [Mon, 9 Jan 2023 12:23:46 +0000 (19:23 +0700)]
[Test] One more test where check is not replaced to invariant

Irrelevant constant check makes things even more difficult, surprisingly.

21 months agoLower math.cbrt to NVVM/ROCDL.
Johannes Reifferscheid [Mon, 9 Jan 2023 10:48:43 +0000 (11:48 +0100)]
Lower math.cbrt to NVVM/ROCDL.

Reviewed By: pifon2a

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

21 months ago[Attributes] Avoid duplicate hasAttribute() query (NFC)
Nikita Popov [Mon, 9 Jan 2023 11:55:47 +0000 (12:55 +0100)]
[Attributes] Avoid duplicate hasAttribute() query (NFC)

removeAttribute() already performs a hasAttribute() check, so no
need to also do it in the caller. Instead check whether the
attribute set was changed.

This makes the implementations in line with removeAttributesAtIndex().

21 months ago[AArch64] Fold And/Or into CSel if possible
David Green [Mon, 9 Jan 2023 11:52:37 +0000 (11:52 +0000)]
[AArch64] Fold And/Or into CSel if possible

If we have `and x, (csel 0, 1, cc)` and we know that x is 0/1, then we
can emit a `csel ZR, x, cc`. Similarly for `or x, (csel 0, 1, cc)` we
can emit `csinc x, ZR, cc`. This can help where we can not otherwise
general ccmp instructions.

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

21 months ago[InstCombine] Canonicalize (A & B_Pow2) eq/ne B_Pow2 patterns
Noah Goldstein [Mon, 9 Jan 2023 11:44:03 +0000 (12:44 +0100)]
[InstCombine] Canonicalize (A & B_Pow2) eq/ne B_Pow2 patterns

1. A & B_Pow2 != B_Pow2 -> A & B_Pow2 == 0
   https://alive2.llvm.org/ce/z/KVUej4

2. A & B_Pow2 == B_Pow2 -> A & B_Pow2 != 0
   https://alive2.llvm.org/ce/z/PVv9FR

This allows the patterns to more easily be analyzed elsewhere.

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

21 months ago[lld][ARM] don't use short thumb thunks if no branch range extension
Ties Stuij [Mon, 9 Jan 2023 11:06:00 +0000 (11:06 +0000)]
[lld][ARM] don't use short thumb thunks if no branch range extension

In ThumbThunk::isCompatibleWith, we check if we can use short thunks if we are
within branch range. However these short thumb thunks will generate b.w
instructions, and these are not available on pre branch range extension
architectures.

On these architectures (v4, v5, and most of v6), we could replace the b.w with a
Thumb b (2) instruction, but that would in an ideal situation only give us an
extra range of 2048 bytes on top of the 4MB range of a BL, if a thunk section
happens to be placed on the outer range of a BL and the stars are aligned. It
doesn't seem worth it.

What would be worth it is a state change to Arm and a subsequent branch to
either Arm or Thumb code. But that's the subject of another patch.

Reviewed By: MaskRay

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

21 months ago[DebugInfo] Fix jump threading failing to update cloned dbg.values
Ben Mudd [Mon, 9 Jan 2023 11:04:39 +0000 (11:04 +0000)]
[DebugInfo] Fix jump threading failing to update cloned dbg.values

This is a patch to fix duplicated dbg.values in the JumpThreading pass not
pointing towards their local value, and instead towards the variable in the
original block.
JumpThreadingPass::cloneInstructions is the changed function to target metadata
as well as normal cloned values.

Reviewed By: jmorse, StephenTozer

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

21 months ago[libc++] Fix transitive includes list for C++23
Nikolas Klauser [Mon, 9 Jan 2023 11:19:36 +0000 (12:19 +0100)]
[libc++] Fix transitive includes list for C++23

21 months agoMove from llvm::makeArrayRef to ArrayRef deduction guides - clang/ part
serge-sans-paille [Fri, 6 Jan 2023 15:56:23 +0000 (16:56 +0100)]
Move from llvm::makeArrayRef to ArrayRef deduction guides - clang/ part

This is a follow-up to https://reviews.llvm.org/D140896, split into
several parts as it touches a lot of files.

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

21 months agoTailDuplication: do not remove trivial PHIs from addr-taken blocks.
Tim Northover [Mon, 9 Jan 2023 10:52:34 +0000 (10:52 +0000)]
TailDuplication: do not remove trivial PHIs from addr-taken blocks.

Unlike an anonymous block, it will not be removed even though we've resolved
all valid paths to get here. So removing a PHI can leave vregs with no
definition, violating SSA. Instead, this converts it to an IMPLICIT_DEF.

21 months ago[libc++][test] Fix missing include in `endian.pass.cpp`
Joe Loser [Mon, 9 Jan 2023 11:09:45 +0000 (12:09 +0100)]
[libc++][test] Fix missing include in `endian.pass.cpp`

`endian.pass.cpp` uses `std::is_enum` and friends but doesn't include
`<type_traits>`.  Add the missing include.

Reviewed By: philnik, #libc

Spies: libcxx-commits

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

21 months ago[Attributes] Avoid repeated attribute set lookup (NFC)
Nikita Popov [Mon, 9 Jan 2023 10:58:06 +0000 (11:58 +0100)]
[Attributes] Avoid repeated attribute set lookup (NFC)

Perform the hasAttribute() check on the AttributeSet we need to
fetch anyway, rather than going through hasAttributeAtIndex().

21 months ago[InstCombine] Fix potentially buggy code in `((%x & C) == 0) --> %x u< (-C)` transform
Noah Goldstein [Mon, 9 Jan 2023 10:38:36 +0000 (11:38 +0100)]
[InstCombine] Fix potentially buggy code in `((%x & C) == 0) --> %x u< (-C)` transform

While demanded bits constant shrinking appears to prevent this in
practice right now, it is principally possible for C2 to have
set bits that are known not-needed (zeroable). See: D140858

`+` will overflow here, `|` will get the right logic.

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

21 months ago[llvm] Fix an "unused variable" warning when assertions are disabled
Dmitri Gribenko [Mon, 9 Jan 2023 10:31:25 +0000 (11:31 +0100)]
[llvm] Fix an "unused variable" warning when assertions are disabled

21 months ago[TableGen][SourceMgr] Fix obvious mistake in D141220
Markus Böck [Mon, 9 Jan 2023 10:16:56 +0000 (11:16 +0100)]
[TableGen][SourceMgr] Fix obvious mistake in D141220

It now tried to open the IncludedFile instead of the Filename, which was not intended.

21 months ago[AArch64] NFC: Align addTypeForStreamingSVE and addTypeForFixedLengthSVE
Sander de Smalen [Mon, 9 Jan 2023 09:26:20 +0000 (09:26 +0000)]
[AArch64] NFC: Align addTypeForStreamingSVE and addTypeForFixedLengthSVE

This patch is NFC and just moves things around so their implementation is very similar.

21 months ago[bazel] Updates for https://github.com/llvm/llvm-project/commit/496f9a7d8d4b61b6f5dfa...
Dmitri Gribenko [Mon, 9 Jan 2023 09:27:15 +0000 (10:27 +0100)]
[bazel] Updates for https://github.com/llvm/llvm-project/commit/496f9a7d8d4b61b6f5dfa21e2614043a2b27cf67

21 months ago[bazel] Update the mpfr URL to a stable one
Dmitri Gribenko [Mon, 9 Jan 2023 09:26:25 +0000 (10:26 +0100)]
[bazel] Update the mpfr URL to a stable one

mpfr has released a new version, and now the old tar.gz URL does not
work anymore. Update the URL to a stable one.

21 months ago[mlir:LLVM] Rudimentary inlining support for LLVM load store.
Johannes de Fine Licht [Mon, 9 Jan 2023 09:28:10 +0000 (10:28 +0100)]
[mlir:LLVM] Rudimentary inlining support for LLVM load store.

Conservatively only allow inlining for loads and stores that don't carry
any attributes that require handling while inlining. This can later be
relaxed when proper handling is introduced.

Reviewed By: Dinistro, gysit

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

21 months ago[mlir][llvm] Add branch weights to call and invoke
Christian Ulmann [Mon, 9 Jan 2023 09:14:21 +0000 (10:14 +0100)]
[mlir][llvm] Add branch weights to call and invoke

This commit introduces branch weight attributes to the LLVM::CallOp and
LLVM::InvokeOp and adds both import and export of them.

Reviewed By: gysit

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