platform/upstream/llvm.git
16 months ago[Demangle] make llvm::demangle take std::string_view rather than const std::string&
Nick Desaulniers [Tue, 2 May 2023 18:10:43 +0000 (11:10 -0700)]
[Demangle] make llvm::demangle take std::string_view rather than const std::string&

As suggested by @erichkeane in
https://reviews.llvm.org/D141451#inline-1429549

There's potential for a lot more cleanups around these APIs. This is
just a start.

Callers need to be more careful about sub-expressions producing strings
that don't outlast the expression using ``llvm::demangle``. Add a
release note.

Reviewed By: MaskRay, #lld-macho

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

16 months agoAdd amissing REQUIRES: to test
Adrian Prantl [Tue, 2 May 2023 18:15:29 +0000 (11:15 -0700)]
Add amissing REQUIRES: to test

16 months ago[NFC][SLP] Fix typo
Vasileios Porpodas [Tue, 2 May 2023 17:14:53 +0000 (10:14 -0700)]
[NFC][SLP] Fix typo

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

16 months ago[lldb] Fix 8be139fc1251 for propery value changes
Jonas Devlieghere [Tue, 2 May 2023 18:09:48 +0000 (11:09 -0700)]
[lldb] Fix 8be139fc1251 for propery value changes

Fix 8be139fc1251 for mid-air collision with the propery value changes.

16 months ago[lldb] Add settings for expression evaluation memory allocations.
Ilya Kuklin [Tue, 2 May 2023 18:02:30 +0000 (11:02 -0700)]
[lldb] Add settings for expression evaluation memory allocations.

Expression evaluation allocates memory for storing intermediate data during evaluation. For it to work properly it has to be allocated within target's available address space, for example within first 0xFFFF bytes for the 16-bit MSP430. The memory for such targets can be very tightly packed, but not all targets support GetMemoryRegionInfo API to pick an unused region, like MSP430 with MSPDebug GDB server.

These settings allow the programmer to manually pick precisely where and how much memory to allocate for expression evaluation in order not to overlap with existing data in process memory.

Reviewed By: bulbazord

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

16 months ago[libc++] Add _LIBCPP_HIDE_FROM_ABI to the unsequenced_policy constructor
Nikolas Klauser [Tue, 2 May 2023 17:48:00 +0000 (10:48 -0700)]
[libc++] Add _LIBCPP_HIDE_FROM_ABI to the unsequenced_policy constructor

16 months ago[lldb] Make exe_ctx an optional argument in OptionValueProperties (NFC)
Jonas Devlieghere [Tue, 2 May 2023 17:31:21 +0000 (10:31 -0700)]
[lldb] Make exe_ctx an optional argument in OptionValueProperties (NFC)

The majority of call sites are nullptr as the execution context.
Refactor OptionValueProperties to make the argument optional and
simplify all the callers.

16 months ago[X86] Remove stale checks after a30c17aba9.
Florian Hahn [Tue, 2 May 2023 17:22:04 +0000 (18:22 +0100)]
[X86] Remove stale checks after a30c17aba9.

16 months agoTemporary fix for `MVT::getSizeInBits()` to handle `aarch64svcount`
NAKAMURA Takumi [Tue, 2 May 2023 17:18:03 +0000 (02:18 +0900)]
Temporary fix for `MVT::getSizeInBits()` to handle `aarch64svcount`

Support/MVTTest.cpp was missing text matrix for it.

FIXME: `aarch64svcount` should be in the td.

16 months ago[X86] Auto-generate checks for file.
Florian Hahn [Tue, 2 May 2023 17:21:11 +0000 (18:21 +0100)]
[X86] Auto-generate checks for file.

This makes it easier to update the test checks and also adds better
coverage.

16 months ago[lldb] Refactor SBFileSpec::GetDirectory
Alex Langford [Tue, 2 May 2023 00:29:28 +0000 (17:29 -0700)]
[lldb] Refactor SBFileSpec::GetDirectory

There's no reason to create an entire new filespec to mutate and grab
data from when we can just grab the data directly.

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

16 months ago[Support][Parallel] Initialize threadIndex and add assertion checking its usage.
Alexey Lapshin [Thu, 20 Apr 2023 21:03:21 +0000 (23:03 +0200)]
[Support][Parallel] Initialize threadIndex and add assertion checking its usage.

That patch adds a check for threadIndex being used with only threads
created by ThreadPoolExecutor. This helps catch two types of errors:

1. If a thread is created not by ThreadPoolExecutor its index may clash
   with the index of another thread. Using threadIndex, in that case, may
   lead to a data race.

2. Index of the main thread(threadIndex == 0) currently clashes with
   the index of thread0 in ThreadPoolExecutor threads. That may lead
   to a data race if main thread and thread0 are executed concurrently.

This patch allows execution tasks on the main thread only in case
parallel::strategy.ThreadsRequested == 1. In all other cases,
assertions check that threadIndex != UINT_MAX(i.e. that task
is executed on a thread created by ThreadPoolExecutor).

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

16 months ago[llvm][vfs] Avoid silent fallback to process-wide working directory
Ben Langmuir [Tue, 25 Apr 2023 18:04:06 +0000 (11:04 -0700)]
[llvm][vfs] Avoid silent fallback to process-wide working directory

In createPhysicalFileSystem, preserve the per-instance working
directory, even after the first call to getcwd fails.

rdar://108213753

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

16 months agoSemaRISCVVectorLookup.cpp: Prune `default:` block. [-Wcovered-switch-default]
NAKAMURA Takumi [Tue, 2 May 2023 16:30:03 +0000 (01:30 +0900)]
SemaRISCVVectorLookup.cpp: Prune `default:` block. [-Wcovered-switch-default]

16 months ago[OpenMP] [OMPT] [amdgpu] [4/8] Implemented callback registration in nextgen plugins
Dhruva Chakrabarti [Thu, 27 Apr 2023 16:56:25 +0000 (18:56 +0200)]
[OpenMP] [OMPT] [amdgpu] [4/8] Implemented callback registration in nextgen plugins

The purpose of this patch is to Implement registration of callback functions in the generic plugin by looking up corresponding callbacks in libomptarget. The overall design document is https://rice.app.box.com/s/pf3gix2hs4d4o1aatwir1set05xmjljc

Defined an object of type OmptDeviceCallbacksTy in the amdgpu plugin for holding the tool-provided callback functions. Implemented a global constructor in the plugin that creates a connector object to connect with libomptarget. The callbacks that are already registered with libomptarget are looked up and registered with the plugin.

Combined with an internal patch from Dhruva Chakrabarti, which fixes the OMPT initialization ordering.
Achieved through removal of the constructor attribute from ompt_init.

Patch from John Mellor-Crummey <johnmc@rice.edu>
With contributions from:
Dhruva Chakrabarti <Dhruva.Chakrabarti@amd.com>
Michael Halkenhaeuser <MichaelGerald.Halkenhauser@amd.com>

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

16 months ago[ELF] Name MergeSyntheticSection using an input section instead of the output section
Fangrui Song [Tue, 2 May 2023 16:35:00 +0000 (09:35 -0700)]
[ELF] Name MergeSyntheticSection using an input section instead of the output section

In a link map, the input section name gives more information. See the updated
merge-entsize.s for an example. The output file is unchanged.

Compiler generated input sections with the SHF_MERGE flag have names such as
.rodata.str1.1 and .rodata.cstN, and are not affected by -fdata-sections.

Reviewed By: peter.smith

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

16 months ago[mlir][linalg] Allow outer dims perm and untiled dims in pack/unpack generalization
Quinn Dawkins [Sun, 2 Apr 2023 19:46:32 +0000 (15:46 -0400)]
[mlir][linalg] Allow outer dims perm and untiled dims in pack/unpack generalization

Extends the pack/unpack generalization patterns to work for any packing
op with only full tiles. This produces a combination of rank-reduced
insert/extract slice ops paired with a transpose on the reduced shape,
similar to what the pattern currently produces for fully tiled
pack/unpacks. Note that only the outer dims are rank-reduced in this
pattern, leaving the shape of the inner tile intact.

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

16 months ago[sanitizer][asan][win] Only unmap unneeded shadow memory on x86_64
Alvin Wong [Sun, 23 Apr 2023 15:42:21 +0000 (23:42 +0800)]
[sanitizer][asan][win] Only unmap unneeded shadow memory on x86_64

D21942 / 1128db8fe1c13800ebc77206efc50d0a219b8750 added support for
committing shadow memory on demand on Win 64-bit. The reason it is not
enabled on 32-bit wasn't clear but the page table overhead on Windows 7
may be a contributing factor.

In `AsanMapUnmapCallback::OnUnmap`, `FlushUnneededASanShadowMemory` is
called to release shadow memory. It calls `ReleaseMemoryPagesToOS`,
which had been a no-op on Windows, until D95892 /
81b1d3da094c54ffd75e05c8d4683792edf17f4c in which it was changed to
unmap full pages that the memory region covers. This was done on both
32-bit and 64-bit.

AddressSanitizerInterface.GetHeapSizeTest appears to fail on i686
targets as a side effect of this. This test allocates and frees a huge
chunk of memory which causes shadow memory to be unmapped immediately.
When the test allocates the chunk of memory a second time, asan tries to
reuse the same shadow memory region, but because the shadow memory has
now been unmapped, it causes an access violation and crashes the test.

x86_64 is not affected, because the code that handles commiting shadow
memory on demand also handles this situation, allowing the test to work
without crashing.

Therefore, this patch changes `FlushUnneededASanShadowMemory` on Windows
to only release/unmap the shadow memory on x86_64 to stop this from
happening on i686.

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

16 months ago[tests] Add missing REQUIRES: riscv-registered-target to clang test
4vtomat [Tue, 2 May 2023 15:24:44 +0000 (08:24 -0700)]
[tests] Add missing REQUIRES: riscv-registered-target to clang test

16 months ago[RISCV][CodeGen] Support Zfinx codegen
Shao-Ce SUN [Sun, 30 Apr 2023 18:25:51 +0000 (02:25 +0800)]
[RISCV][CodeGen] Support Zfinx codegen

This patch was split from D122918 . Co-Author: @liaolucy @realqhc

Reviewed By: craig.topper

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

16 months agoTry to fix CodeGenTypes issues in mlir
NAKAMURA Takumi [Tue, 2 May 2023 15:42:24 +0000 (00:42 +0900)]
Try to fix CodeGenTypes issues in mlir

16 months agoCall printName to get name of Decl
Dan McGregor [Tue, 2 May 2023 15:53:48 +0000 (11:53 -0400)]
Call printName to get name of Decl

Rather than sending a name directly to the stream, use printName
to preserve any PrintingPolicy. This ensures that names are properly
affected by path remapping.

Fixes: https://github.com/llvm/llvm-project/issues/62192
Differential Revision: https://reviews.llvm.org/D149272

16 months ago[libc++][ranges] Fixes as_rvalue's linkage.
Mark de Wever [Mon, 1 May 2023 15:50:55 +0000 (17:50 +0200)]
[libc++][ranges] Fixes as_rvalue's linkage.

This was discovered while working on modules. They can't export
declarations with internal linkage.

Reviewed By: #libc, philnik

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

16 months agoAdd missing include
Adrian Prantl [Tue, 2 May 2023 15:37:40 +0000 (08:37 -0700)]
Add missing include

16 months ago[mlir][tosa] Fix crash when inferring shape of tosa.equal
Spenser Bauman [Tue, 2 May 2023 15:17:45 +0000 (08:17 -0700)]
[mlir][tosa] Fix crash when inferring shape of tosa.equal

The tosa-infer-shapes pass crashes when trying to infer the output shape
of tosa.equal when the input shape is unranked.
This is due to tosa-infer-shapes requiring at least information on the
base type of the resulting operation from inferReturnTypeComponents.
This change enhances EqualOp::inferReturnTypeComponents to always supply
the inferred elementType.

Reviewed By: eric-k256

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

16 months agoSwitch `llvm/CodeGen/MachineValueType.h` to the generated one
NAKAMURA Takumi [Mon, 17 Apr 2023 14:46:47 +0000 (23:46 +0900)]
Switch `llvm/CodeGen/MachineValueType.h` to the generated one

Prune `SupportTests/MVTTest` since it is no longer needed.

Depends on D148769

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

16 months agoSplit out `CodeGenTypes` from `CodeGen` for LLT/MVT
NAKAMURA Takumi [Mon, 17 Apr 2023 14:46:47 +0000 (23:46 +0900)]
Split out `CodeGenTypes` from `CodeGen` for LLT/MVT

This reduces dependencies on `llvm-tblgen` so much.

`CodeGenTypes` depends on `Support` at the moment.
Be careful to append deps on this, since Targets' tablegens
depend on this.

Depends on D149024

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

16 months agoRestore CodeGen/MachineValueType.h from `Support`
NAKAMURA Takumi [Mon, 10 Apr 2023 15:05:24 +0000 (00:05 +0900)]
Restore CodeGen/MachineValueType.h from `Support`

This is rework of;

  - rG13e77db2df94 (r328395; MVT)

Since `LowLevelType.h` has been restored to `CodeGen`, `MachinveValueType.h`
can be restored as well.

Depends on D148767

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

16 months agoRestore CodeGen/LowLevelType from `Support`
NAKAMURA Takumi [Mon, 10 Apr 2023 15:05:24 +0000 (00:05 +0900)]
Restore CodeGen/LowLevelType from `Support`

This is rework of;
  - D30046 (LLT)

Since I have introduced `llvm-min-tblgen` as D146352, `llvm-tblgen`
may depend on `CodeGen`.

`LowLevlType.h` originally belonged to `CodeGen`. Almost all userse are
still under `CodeGen` or `Target`. I think `CodeGen` is the right place
to put `LowLevelType.h`.

`MachineValueType.h` may be moved as well. (later, D149024)

I have made many modules depend on `CodeGen`. It is consistent but
inefficient. It will be split out later, D148769

Besides, I had to isolate MVT and LLT in modmap, since
`llvm::PredicateInfo` clashes between `TableGen/CodeGenSchedule.h`
and `Transforms/Utils/PredicateInfo.h`.
(I think better to introduce namespace llvm::TableGen)

Depends on D145937, D146352, and D148768.

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

16 months ago[Bazel] Update for D148308 (riscv-sifive)
NAKAMURA Takumi [Tue, 2 May 2023 15:09:30 +0000 (00:09 +0900)]
[Bazel] Update for D148308 (riscv-sifive)

16 months agoRevert "[Clang][Sema] Fix comparison of constraint expressions"
Erich Keane [Tue, 2 May 2023 15:09:26 +0000 (08:09 -0700)]
Revert "[Clang][Sema] Fix comparison of constraint expressions"

This reverts commit e3b1083e00e62f5d157d15cb8c63a1c3dfdf12e2.

This was reverted because it breaks a number of libstdc++ examples, AND
required a workaround that causes hiding of legitimate bugs.

16 months agoRevert "[Clang][Sema] Add a temporary workaround in SemaConcept.cpp"
Erich Keane [Tue, 2 May 2023 15:09:01 +0000 (08:09 -0700)]
Revert "[Clang][Sema] Add a temporary workaround in SemaConcept.cpp"

This reverts commit ce861ec782ae3f41807b61e855512aaccf3c2149.

16 months ago[mlir][arith] Add narrowing patterns for `max*i` and `min*i`
Jakub Kuderski [Tue, 2 May 2023 14:48:01 +0000 (10:48 -0400)]
[mlir][arith] Add narrowing patterns for `max*i` and `min*i`

Reviewed By: antiagainst

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

16 months ago[ThinLTO] Loosen up variable importing correctness checks
Teresa Johnson [Tue, 2 May 2023 02:04:00 +0000 (19:04 -0700)]
[ThinLTO] Loosen up variable importing correctness checks

After importing variables, we do some checking to ensure that variables
marked read or write only, which have been marked exported (e.g.
because a referencing function has been exported), are on at least one
module's imports list. This is because the read or write only variables
will be internalized, so we need a copy any any module that references
it.

This checking is overly conservative in the case of linkonce_odr or
other linkage types where there can already be a duplicate copy in
existence in the importing module, which therefore wouldn't need to
import it. Loosen up the checking for these linkage types.

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

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

16 months ago[mlir][arith] Add narrowing patterns for subi, divsi, and divui
Jakub Kuderski [Tue, 2 May 2023 14:41:05 +0000 (10:41 -0400)]
[mlir][arith] Add narrowing patterns for subi, divsi, and divui

Each of these ops is compatible with only one extension kind and
produces an extra result bit.

I checked these transformation in Alive2:
1. subi + extsi: https://alive2.llvm.org/ce/z/ipmZZA
2. divsi + extsi: https://alive2.llvm.org/ce/z/fAcqUv
3. divui + extui: https://alive2.llvm.org/ce/z/QZJpFp

Reviewed By: antiagainst

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

16 months ago[mlir][SparseTensor][ArmSVE] Fix missing lli substitutions
Cullen Rhodes [Tue, 2 May 2023 14:30:02 +0000 (14:30 +0000)]
[mlir][SparseTensor][ArmSVE] Fix missing lli substitutions

The MLIR SVE integration tests are now enabled in the
clang-aarch64-full-2stage buildbot under emulation (QEMU) and two of the
sparse integration tests are failing [1]:

  * mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_sorted_coo.mlir
  * mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_spmm.mlir

The reason for this is the SVE RUN lines use plain 'lli' rather than the
'%lli_host_or_aarch64_cmd' substitution that's necessary to run under
emulation. The CI doesn't support SVE so the tests will SIGILL unless
run under emulation.

I should note the logs don't show a SIGILL, only the non-descript:

  FileCheck error: '<stdin>' is empty.

but I expect this is what's actually happening.

https://lab.llvm.org/buildbot/#/builders/179/builds/6051/steps/12/logs/stdio

16 months ago[libc] Fix some missing features from the hermetic test support
Joseph Huber [Tue, 2 May 2023 11:39:14 +0000 (06:39 -0500)]
[libc] Fix some missing features from the hermetic test support

This patch addresses some of the flags and features that are currently
missing from the hermetic test support. This mostly just fixes the
`add_libc_test` option failing to find a few dependencies or missing
arguments from the previous unit test support.

Reviewed By: lntue

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

16 months ago[BOLT] Make sure Mach-O binaries are actually linked
Job Noorman [Tue, 2 May 2023 14:22:48 +0000 (16:22 +0200)]
[BOLT] Make sure Mach-O binaries are actually linked

Note that this issue is also solved by D147544.

Reviewed By: alexander-shaposhnikov

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

16 months ago[BOLT] Make sure all section allocations have deterministic contents
Job Noorman [Tue, 2 May 2023 13:43:37 +0000 (15:43 +0200)]
[BOLT] Make sure all section allocations have deterministic contents

For empty sections, RuntimeDyld always allocates 1 byte but leaves it
uninitialized. This causes the contents of some output sections to be
non-deterministic.

Note that this issue is also solved by D147544.

Fixes #59008

Reviewed By: maksfb

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

16 months ago[mlir][arith] Add narrowing patterns for `addi` and `muli`
Jakub Kuderski [Tue, 2 May 2023 14:09:51 +0000 (10:09 -0400)]
[mlir][arith] Add narrowing patterns for `addi` and `muli`

These two ops are handled in a very similar way -- the only difference
in the number result bits produced.

I checked these transformation with Alive2:
1.  addi + sext: https://alive2.llvm.org/ce/z/3NSs9T
2.  addi + zext: https://alive2.llvm.org/ce/z/t7XHOT
3.  muli + sext: https://alive2.llvm.org/ce/z/-7sfW9
4.  muli + zext: https://alive2.llvm.org/ce/z/h4yntF

Reviewed By: antiagainst

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

16 months ago[CodeGen] One more use of MachineBasicBlock::phis. NFC.
Jay Foad [Tue, 2 May 2023 13:38:27 +0000 (14:38 +0100)]
[CodeGen] One more use of MachineBasicBlock::phis. NFC.

16 months ago[OpenMP] In libomptarget, assume alignment at powers of two
Joel E. Denny [Tue, 2 May 2023 13:44:58 +0000 (09:44 -0400)]
[OpenMP] In libomptarget, assume alignment at powers of two

This patch fixes a bug introduced by D142586, which landed as
434992c96ed1.  The fix was to only look for alignments that are powers
of 2.  See the new test case for details.

Reviewed By: jdoerfert, jhuber6

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

16 months ago[DWARFLinker][NFC] Make interfaces to be compatible.
Alexey Lapshin [Fri, 31 Mar 2023 15:10:11 +0000 (17:10 +0200)]
[DWARFLinker][NFC] Make interfaces to be compatible.

This patch makes interface of AddressManager from DWARFLinker
to be compatible with AddressesMap from DWARFLinkerParallel.
This makes both linkers to be interchangeable.

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

16 months ago[RISCV][RISCV][clang] Split out SiFive Vector C intrinsics from riscv_vector.td
4vtomat [Sat, 18 Mar 2023 12:15:24 +0000 (05:15 -0700)]
[RISCV][RISCV][clang] Split out SiFive Vector C intrinsics from riscv_vector.td

Since we don't always need the vendor extension to be in riscv_vector.td,
so it's better to make it be in separated header.

Depends on D148223 and D148680

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

16 months ago[llvm][unittests] Silence warning on MSVC after 5b2423183cb3
Alexandre Ganea [Tue, 2 May 2023 12:49:35 +0000 (08:49 -0400)]
[llvm][unittests] Silence warning on MSVC after 5b2423183cb3

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

16 months ago[lldb] Add cstdio include to fix a595b931f1f91897317a4257df313bddfeb029a6
Dmitry Chernenkov [Tue, 2 May 2023 12:45:28 +0000 (12:45 +0000)]
[lldb] Add cstdio include to fix a595b931f1f91897317a4257df313bddfeb029a6

16 months ago[RISCV] Split out part of riscv_vector.td to riscv_vector_common.td
4vtomat [Wed, 19 Apr 2023 02:43:57 +0000 (19:43 -0700)]
[RISCV] Split out part of riscv_vector.td to riscv_vector_common.td

This makes other new targets able to reuse predefined classes
in their own *.td files.

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

16 months ago[SiFive][RISCV][clang] Support C intrinsics for xsfvcp extension.
Nelson Chu [Wed, 18 May 2022 10:03:34 +0000 (03:03 -0700)]
[SiFive][RISCV][clang] Support C intrinsics for xsfvcp extension.

Depends on D147934 and D147935

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

16 months ago[CodeGen] Make use of MachineBasicBlock::phis. NFC.
Jay Foad [Tue, 2 May 2023 12:29:51 +0000 (13:29 +0100)]
[CodeGen] Make use of MachineBasicBlock::phis. NFC.

16 months agoRevert "[OpenMP] Make `libomptarget` link against `libomp`"
Shilei Tian [Tue, 2 May 2023 12:35:55 +0000 (08:35 -0400)]
Revert "[OpenMP] Make `libomptarget` link against `libomp`"

This reverts commit dc049a4ea681b1d0a4880bae3e19ae0ef40f6e80.

It causes issue of export target.

16 months ago[clang] Do not attempt to zero-extend _BitInt(1) when not required
Mariya Podchishchaeva [Tue, 2 May 2023 12:20:29 +0000 (08:20 -0400)]
[clang] Do not attempt to zero-extend _BitInt(1) when not required

`ConvertTypeForMem` doesn't return wider type for _BitInt unless it is
used in a bitfield, so no need to extend when trying to initialize a
global variable.

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

Reviewed By: erichkeane, shafik

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

16 months ago[ARM] Don't allocate memory if free space in segmented stack is just enough
Zhiyao Ma [Tue, 2 May 2023 09:23:19 +0000 (10:23 +0100)]
[ARM] Don't allocate memory if free space in segmented stack is just enough

Assuming that the stack grows downwards, it is fine if the stack
pointer is exactly at the stacklet boundary. We should use
less-or-equal condition when deciding whether to skip new memory
allocation.

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

16 months ago[Flang][OpenMP] Use fir.if instead of scf.if in lastprivate lowering
Kiran Chandramohan [Tue, 2 May 2023 11:29:42 +0000 (11:29 +0000)]
[Flang][OpenMP] Use fir.if instead of scf.if in lastprivate lowering

For finding the last iteration of a loop, or the last section an
if condition is generated. Using scf::if can cause some lowering
issues since the code contained inside it can have branches. Using
fir::if instead ensures that the fir::if is lowered into branches
along with any code contained inside that can generate branches.

Fixes #62458.

Reviewed By: NimishMishra

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

16 months ago[lldb][test] TestCPP20Standard.py: make it a libc++ test
Michael Buch [Mon, 1 May 2023 17:09:54 +0000 (13:09 -0400)]
[lldb][test] TestCPP20Standard.py: make it a libc++ test

We just want to test whether the language switch works.
This is easier to control for libc++, since for bots building
the tests against libstdc++ we might not have the necessary
`<compare>` header available currently.

16 months ago[lldb][DWARFExpression] Fix DW_OP_div to use signed division
LU Hongyi [Mon, 1 May 2023 11:05:47 +0000 (07:05 -0400)]
[lldb][DWARFExpression] Fix DW_OP_div to use signed division

This patch resolves an issue where a value
is incorrectly displayed if it is represented
by DW_OP_div.

This issue is caused by lldb evaluating
operands of DW_OP_div as unsigned
and performed unintended unsigned
division.

This issue is resolved by creating two
temporary signed scalar and performing
signed division.

(Addresses GH#61727)

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

16 months ago[clang][dataflow] Expose DataflowAnalysisContext from DataflowEnvironment.
Samira Bazuzi [Tue, 2 May 2023 00:08:30 +0000 (00:08 +0000)]
[clang][dataflow] Expose DataflowAnalysisContext from DataflowEnvironment.

This will eliminate the need for more pass-through APIs. Also replace pass-through usages with this exposure.

Reviewed By: ymandel, gribozavr2, xazax.hun

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

16 months ago[EarlyCSE] Only combine metadata for load CSE
Nikita Popov [Tue, 2 May 2023 10:43:12 +0000 (12:43 +0200)]
[EarlyCSE] Only combine metadata for load CSE

There is no need to combine metadata if we're performing store to
load forwarding. In that case we would end up combining metadata
on an unrelated load instruction.

16 months ago[EarlyCSE] Add additional metadata preservation test (NFC)
Nikita Popov [Tue, 2 May 2023 10:37:52 +0000 (12:37 +0200)]
[EarlyCSE] Add additional metadata preservation test (NFC)

17 months ago[gn build] Port 852bf52cc957
LLVM GN Syncbot [Tue, 2 May 2023 10:31:09 +0000 (10:31 +0000)]
[gn build] Port 852bf52cc957

17 months ago[clang-tidy] Add check bugprone-multiple-new-in-one-expression.
Balázs Kéri [Tue, 2 May 2023 07:56:57 +0000 (09:56 +0200)]
[clang-tidy] Add check bugprone-multiple-new-in-one-expression.

Reviewed By: donat.nagy
Fixed test failures with previous commit.

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

17 months ago[LCSSA] Remove unused ScalarEvolution argument (NFC)
Nikita Popov [Tue, 2 May 2023 10:13:53 +0000 (12:13 +0200)]
[LCSSA] Remove unused ScalarEvolution argument (NFC)

After D149435, LCSSA formation no longer needs access to
ScalarEvolution, so remove the argument from the utilities.

17 months ago[AArch64] Add sign bits handling for vector compare nodes
David Green [Tue, 2 May 2023 10:05:35 +0000 (11:05 +0100)]
[AArch64] Add sign bits handling for vector compare nodes

This adds ComputeNumSignBits for the NEON vector comparison nodes, which all
either return 0 or -1. Also adds sign_extend_inreg from VASHR+VSHL to show it
performing transforms.

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

17 months agoFix MSVC "truncation of constant value" warnings. NFC.
Simon Pilgrim [Tue, 2 May 2023 09:42:13 +0000 (10:42 +0100)]
Fix MSVC "truncation of constant value" warnings. NFC.

17 months agoFix MSVC "not all control paths return a value" warnings. NFC.
Simon Pilgrim [Tue, 2 May 2023 09:30:29 +0000 (10:30 +0100)]
Fix MSVC "not all control paths return a value" warnings. NFC.

17 months ago[clang-repl] Add a test coverage for nested out-of-line dtor disambiguation.
Vassil Vassilev [Tue, 2 May 2023 09:29:37 +0000 (09:29 +0000)]
[clang-repl] Add a test coverage for nested out-of-line dtor disambiguation.

This came up as a review comment in https://reviews.llvm.org/D148425

17 months ago[AMDGPU] Make use of new tablegen operator !range. NFC.
Jay Foad [Tue, 2 May 2023 09:29:17 +0000 (10:29 +0100)]
[AMDGPU] Make use of new tablegen operator !range. NFC.

17 months ago[gn build] Port 7b7a6b641afd
LLVM GN Syncbot [Tue, 2 May 2023 09:28:16 +0000 (09:28 +0000)]
[gn build] Port 7b7a6b641afd

17 months agoRevert "[clang-tidy] Add check bugprone-multiple-new-in-one-expression."
Balázs Kéri [Tue, 2 May 2023 09:23:31 +0000 (11:23 +0200)]
Revert "[clang-tidy] Add check bugprone-multiple-new-in-one-expression."

This reverts commit 1aa36da15369678d94add0f64809b11f95795efd.

17 months ago[PGO] Avoid potential const_cast UB (NFC)
Christian Ulmann [Tue, 2 May 2023 09:15:29 +0000 (09:15 +0000)]
[PGO] Avoid potential const_cast UB (NFC)

This commit removes potential UB in the PGO instrumentation passes that
was caused by casting away constness and then potentially modifying the
object.

Reviewed By: gysit

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

17 months ago[gn build] Port 1aa36da15369
LLVM GN Syncbot [Tue, 2 May 2023 09:11:37 +0000 (09:11 +0000)]
[gn build] Port 1aa36da15369

17 months ago[mlir][llvm] Add trap intrinsics to the dialect
Victor Perez [Mon, 1 May 2023 08:34:32 +0000 (09:34 +0100)]
[mlir][llvm] Add trap intrinsics to the dialect

Define llvm.trap, llvm.debugtrap, and llvm.ubsantrap intrinsics in the
llvm dialect.

Signed-off-by: Victor Perez <victor.perez@codeplay.com>
Differential Revision: https://reviews.llvm.org/D149574

17 months ago[SCEV] Reuse Accum variable when handling GEP flags
Nikita Popov [Tue, 2 May 2023 09:00:27 +0000 (11:00 +0200)]
[SCEV] Reuse Accum variable when handling GEP flags

The GEP minus the base pointer (which is the pre-inc addrec) is
exactly the Accum value that was already calculated.

17 months ago[clang-tidy] Add check bugprone-multiple-new-in-one-expression.
Balázs Kéri [Tue, 2 May 2023 07:56:57 +0000 (09:56 +0200)]
[clang-tidy] Add check bugprone-multiple-new-in-one-expression.

Reviewed By: donat.nagy

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

17 months agoTypo fix
Hans Wennborg [Tue, 2 May 2023 08:31:37 +0000 (10:31 +0200)]
Typo fix

17 months agoadd_tablegen: Quick fix to reflect LLVM_TABLEGEN to llvm-min-tblgen
NAKAMURA Takumi [Tue, 2 May 2023 08:02:06 +0000 (17:02 +0900)]
add_tablegen: Quick fix to reflect LLVM_TABLEGEN to llvm-min-tblgen

`sanitizer-x86_64-linux-android` uses LLVM_TABLEGEN.

17 months ago[LCSSA] Don't invalidate SCEV
Nikita Popov [Thu, 27 Apr 2023 10:23:11 +0000 (12:23 +0200)]
[LCSSA] Don't invalidate SCEV

LCSSA currently invalidates SCEV for all instructions for which
LCSSA phi nodes are created. This used to be necessary, because
SCEV has historically tried to maintain LCSSA form as well. As
such, some SCEV uses of the value would have to become uses of
the phi node instead.

However, nowadays SCEV itself no longer maintains LCSSA form.
The SCEV of on LCSSA phi node will be the same as the SCEV of its
argument. LCSSA is instead maintained in the SCEVExpander.

As such, I believe it is no longer necessary to perform any SCEV
invalidation during LCSSA construction.

After this patch the ScalarEvolution argument to the LCSSA utilities
is no longer necessary -- I'll remove it in a followup NFC patch to
keep this patch more concise.

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

17 months ago[LLD][MachO] Do not run Mach-O tests on big-endian hosts
Ulrich Weigand [Tue, 2 May 2023 07:33:16 +0000 (09:33 +0200)]
[LLD][MachO] Do not run Mach-O tests on big-endian hosts

Currently, most Mach-O tests fail when executed on a big-endian host. This is
because the Mach-O back-end does not perform the necessary byte swaps when
accessing the (little-endian) binary file format.

For now, simply consider all Mach-O tests unsupported on big-endian hosts,
to enable running the test suite at all on such hosts.

Reviewed by: oontvoo

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

17 months ago[lldb] Remove unused will_modify argument (NFC)
Jonas Devlieghere [Tue, 2 May 2023 07:17:52 +0000 (00:17 -0700)]
[lldb] Remove unused will_modify argument (NFC)

Various OptionValue related classes are passing around will_modify but
the value is never used. This patch simplifies the interfaces by
removing the redundant argument.

17 months ago[mlir][Bazel] Adjust BUILD file for changes in 5e118f933b6590cecd7f1afb30845a1594bc4a5d
Adrian Kuegel [Tue, 2 May 2023 06:37:44 +0000 (08:37 +0200)]
[mlir][Bazel] Adjust BUILD file for changes in 5e118f933b6590cecd7f1afb30845a1594bc4a5d

17 months ago[mlir][mem2reg] Follow-up adjustments (NFC).
Théo Degioanni [Tue, 2 May 2023 06:06:12 +0000 (06:06 +0000)]
[mlir][mem2reg] Follow-up adjustments (NFC).

Ajustments to the MLIR mem2reg changes.

Reviewed By: gysit, kuhar

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

17 months agoIntroduce MLIR Op Properties
Mehdi Amini [Sun, 26 Feb 2023 15:46:01 +0000 (10:46 -0500)]
Introduce MLIR Op Properties

This new features enabled to dedicate custom storage inline within operations.
This storage can be used as an alternative to attributes to store data that is
specific to an operation. Attribute can also be stored inside the properties
storage if desired, but any kind of data can be present as well. This offers
a way to store and mutate data without uniquing in the Context like Attribute.
See the OpPropertiesTest.cpp for an example where a struct with a
std::vector<> is attached to an operation and mutated in-place:

struct TestProperties {
  int a = -1;
  float b = -1.;
  std::vector<int64_t> array = {-33};
};

More complex scheme (including reference-counting) are also possible.

The only constraint to enable storing a C++ object as "properties" on an
operation is to implement three functions:

- convert from the candidate object to an Attribute
- convert from the Attribute to the candidate object
- hash the object

Optional the parsing and printing can also be customized with 2 extra
functions.

A new options is introduced to ODS to allow dialects to specify:

  let usePropertiesForAttributes = 1;

When set to true, the inherent attributes for all the ops in this dialect
will be using properties instead of being stored alongside discardable
attributes.
The TestDialect showcases this feature.

Another change is that we introduce new APIs on the Operation class
to access separately the inherent attributes from the discardable ones.
We envision deprecating and removing the `getAttr()`, `getAttrsDictionary()`,
and other similar method which don't make the distinction explicit, leading
to an entirely separate namespace for discardable attributes.

Recommit d572cd1b067f after fixing python bindings build.

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

17 months ago[SelectionDAG] Use int64_t to store the integer power of llvm.powi
Shengchen Kan [Tue, 2 May 2023 05:49:15 +0000 (13:49 +0800)]
[SelectionDAG] Use int64_t to store the integer power of llvm.powi

https://llvm.org/docs/LangRef.html#llvm-powi-intrinsic
The max length of the integer power of `llvm.powi` intrinsic is 32, and
the value can be negative. If we use `int32_t` to store this value, `-Val`
will underflow when it is `INT32_MIN`

The issue was reported in D149033.

17 months ago[Coverity] Fix unchecked return value, NFC
Phoebe Wang [Mon, 1 May 2023 14:24:24 +0000 (22:24 +0800)]
[Coverity] Fix unchecked return value, NFC

The `ReversePredicate` should have made sure the reverse predicate is
supported by target, but the check comes from early function and might
be invalid by any mistake. So it's better to double confirm it here.

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

17 months ago[MC] Remove dead code, NFC
Phoebe Wang [Mon, 1 May 2023 13:59:01 +0000 (21:59 +0800)]
[MC] Remove dead code, NFC

This code was added in 408b5e660300f9, but neither the return value nor
`Res` was used in the following code.

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

17 months ago[RISCV] Add Smaia and Ssaia extensions support
4vtomat [Wed, 12 Apr 2023 02:49:14 +0000 (19:49 -0700)]
[RISCV] Add Smaia and Ssaia extensions support

This patch implements 1.0-RC3:
https://github.com/riscv/riscv-aia/releases/download/1.0-RC3/riscv-interrupts-1.0-RC3.pdf

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

17 months agoRevert "[SelectionDAG] Use logic right shift to avoid loop hang"
Shengchen Kan [Tue, 2 May 2023 05:13:29 +0000 (13:13 +0800)]
Revert "[SelectionDAG] Use logic right shift to avoid loop hang"

This reverts commit b73229e55543b4ba2b293adcb8b7d6025f01f7d9.

It caused LIT failure on non-X86 targets.

17 months ago[RISCV] Add missing constraints for vwsll
4vtomat [Tue, 25 Apr 2023 06:31:49 +0000 (23:31 -0700)]
[RISCV] Add missing constraints for vwsll

Add missing early clobber and widen constraints for vector crypto instruction: vwsll

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

17 months agoadd_tablegen: Remove LLVM_ENABLE_OBJLIB
NAKAMURA Takumi [Tue, 2 May 2023 04:57:35 +0000 (13:57 +0900)]
add_tablegen: Remove LLVM_ENABLE_OBJLIB

- It doesn't work if `ALL_FILES` has `$<TARGET_OBJECTS>` with Makefile generator.
- It was a micro-optimization in the ancient age. (introduced in rGe6bc093b42ff)

17 months ago[SelectionDAG] Use logic right shift to avoid loop hang
Shengchen Kan [Tue, 2 May 2023 03:46:57 +0000 (11:46 +0800)]
[SelectionDAG] Use logic right shift to avoid loop hang

Issue was reported in D149033, `Val` can be negative value and
arithmetic right shift always keeps the sign bit.

BTW, the redundant code `Val = -Val` is removed by this patch.

17 months ago[lldb] Refactor OptionValueProperties to return a std::optional (NFC)
Jonas Devlieghere [Tue, 2 May 2023 04:04:24 +0000 (21:04 -0700)]
[lldb] Refactor OptionValueProperties to return a std::optional (NFC)

Similar to fdbe7c7faa54, refactor OptionValueProperties to return a
std::optional instead of taking a fail value. This allows the caller to
handle situations where there's no value, instead of being unable to
distinguish between the absence of a value and the value happening the
match the fail value. When a fail value is required,
std::optional::value_or() provides the same functionality.

17 months agoRevert "[SimpleLoopUnswitch] unswitch selects"
Vitaly Buka [Tue, 2 May 2023 04:37:41 +0000 (21:37 -0700)]
Revert "[SimpleLoopUnswitch] unswitch selects"
Revert "Don't loop unswitch vector selects"

Breaks msan. Details in D138526.

This reverts commit bf089732775520624cb4983bfed6c341e1b4c405.
This reverts commit e479ed90b591c18873fda68c12946b9d08cbe02f.

17 months ago[lldb] Remove TestExternalEditor.test
Jonas Devlieghere [Tue, 2 May 2023 04:25:12 +0000 (21:25 -0700)]
[lldb] Remove TestExternalEditor.test

Remove TestExternalEditor.test as the code to open the transcript in an
external editor is conditional on lldb running in a graphical session.
As a result this test passes locally but not on the bots.

17 months ago[lldb] Fix warning: extra ';' outside of a function is incompatible with C++98
Jonas Devlieghere [Tue, 2 May 2023 04:23:47 +0000 (21:23 -0700)]
[lldb] Fix warning: extra ';' outside of a function is incompatible with C++98

Fix warning, remove trailing whitespace and fix formatting.

17 months ago[lldb] Fix bug introduced by fdbe7c7faa54
Jonas Devlieghere [Tue, 2 May 2023 04:22:40 +0000 (21:22 -0700)]
[lldb] Fix bug introduced by fdbe7c7faa54

I didn't account for the scenario where the string was set but was
empty. This commit restores the old behavior and fixes
TestMemoryFind.py.

17 months ago[clang][Interp][NFC] Make OptionScope final
Timm Bäder [Sun, 30 Apr 2023 17:37:03 +0000 (19:37 +0200)]
[clang][Interp][NFC] Make OptionScope final

17 months ago[clang][Interp][NFC] Add documentation for SetLocal
Timm Bäder [Sun, 30 Apr 2023 14:02:46 +0000 (16:02 +0200)]
[clang][Interp][NFC] Add documentation for SetLocal

17 months ago[lldb] Refactor OptionValue to return a std::optional (NFC)
Jonas Devlieghere [Tue, 2 May 2023 03:34:51 +0000 (20:34 -0700)]
[lldb] Refactor OptionValue to return a std::optional (NFC)

Refactor OptionValue to return a std::optional instead of taking a fail
value. This allows the caller to handle situations where there's no
value, instead of being unable to distinguish between the absence of a
value and the value happening the match the fail value. When a fail
value is required, std::optional::value_or() provides the same
functionality.

17 months agoAdd deps on LLVMTableGenCommon even if it is actually unused.
NAKAMURA Takumi [Tue, 2 May 2023 03:43:16 +0000 (12:43 +0900)]
Add deps on LLVMTableGenCommon even if it is actually unused.

17 months agollvm-tblgen: Split out `obj.LLVMTableGenCommon`
NAKAMURA Takumi [Tue, 2 May 2023 03:19:27 +0000 (12:19 +0900)]
llvm-tblgen: Split out `obj.LLVMTableGenCommon`

`$<TARGET_OBJECTS:llvm-min-tblgen>` was too lazy.
It has `rc.res` in the list with MS toolchain.

Fixup for D146352

17 months ago[mlir][tosa] Typo in transpose canonicalization message
Kai Sasaki [Tue, 2 May 2023 02:47:26 +0000 (11:47 +0900)]
[mlir][tosa] Typo in transpose canonicalization message