platform/upstream/llvm.git
23 months ago[gn build] Port 9823d42557eb
LLVM GN Syncbot [Tue, 6 Sep 2022 11:10:44 +0000 (11:10 +0000)]
[gn build] Port 9823d42557eb

23 months ago[lldb] [Core] Split read thread support into ThreadedCommunication
Michał Górny [Sat, 3 Sep 2022 08:25:42 +0000 (10:25 +0200)]
[lldb] [Core] Split read thread support into ThreadedCommunication

Split the read thread support from Communication into a dedicated
ThreadedCommunication subclass.  The read thread support is used only
by a subset of Communication consumers, and it adds a lot of complexity
to the base class.  Furthermore, having a dedicated subclass makes it
clear whether a particular consumer needs to account for the possibility
of read thread being running or not.

The modules currently calling `StartReadThread()` are updated to use
`ThreadedCommunication`.  The remaining modules use the simplified
`Communication` class.

`SBCommunication` is changed to use `ThreadedCommunication` in order
to avoid changing the public API.

`CommunicationKDP` is updated in order to (hopefully) compile with
the new code.  However, I do not have a Darwin box to test it, so I've
limited the changes to the bare minimum.

`GDBRemoteCommunication` is updated to become a `Broadcaster` directly.
Since it does not inherit from `ThreadedCommunication`, its event
support no longer collides with the one used for read thread and can
be implemented cleanly.  The support for
`eBroadcastBitReadThreadDidExit` is removed from the code -- since
the read thread was not used, this event was never reported.

Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.llvm.org/D133251

23 months ago[CostModel][X86] Add CostKinds handling for SSE FCMP_ONE/FCMP_UEQ predicates
Simon Pilgrim [Tue, 6 Sep 2022 10:58:29 +0000 (11:58 +0100)]
[CostModel][X86] Add CostKinds handling for SSE FCMP_ONE/FCMP_UEQ predicates

These require special handling to account for their expansion in lowering.

I'm trying very hard not to have to add predicate specific costs - but it might be inevitable.....

23 months ago[MLIR] Fix for commit 0f2ec35
Christian Sigg [Tue, 6 Sep 2022 10:52:37 +0000 (12:52 +0200)]
[MLIR] Fix for commit 0f2ec35

Fix incorrectly formatted python file.

23 months ago[AMDGPU][MC][GFX11][NFC] Update assembler tests for MIMG instructions
Dmitry Preobrazhensky [Tue, 6 Sep 2022 10:34:28 +0000 (13:34 +0300)]
[AMDGPU][MC][GFX11][NFC] Update assembler tests for MIMG instructions

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

23 months ago[ARM] Constant pools need 4-byte alignment if we only have tADR
John Brawn [Thu, 1 Sep 2022 14:58:24 +0000 (15:58 +0100)]
[ARM] Constant pools need 4-byte alignment if we only have tADR

When the only ADR instruction we have is the 16-bit thumb one then all
constant pool entries need to be 4-byte aligned, as tADR has an offset
that's a multiple of 4.

It looks like previously there happened to be no situations in which
we encountered a constant pool entry with alignment less than 4, so
failing to do this didn't cause any problems, but the expansion of
cttz to a table added by D128911 does use a constant pool with
alignment 1, so we now need to handle it correctly.

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

23 months ago[MLIR] Switch lit tests to %mlir_lib_dir and %mlir_src_dir replacements.
Christian Sigg [Sun, 4 Sep 2022 08:18:31 +0000 (10:18 +0200)]
[MLIR] Switch lit tests to %mlir_lib_dir and %mlir_src_dir replacements.

The old replacements will be removed soon:
- `%linalg_test_lib_dir`
- `%cuda_wrapper_library_dir`
- `%spirv_wrapper_library_dir`
- `%vulkan_wrapper_library_dir`
- `%mlir_runner_utils_dir`
- `%mlir_integration_test_dir`

Reviewed By: herhut

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

23 months ago[clang-format] Change heuristic for locating lambda template arguments
Emilia Dreamer [Tue, 6 Sep 2022 10:22:34 +0000 (12:22 +0200)]
[clang-format] Change heuristic for locating lambda template arguments

Previously, the heuristic was simply to look for template argument-
specific keywords, such as typename, class, template and auto
that are preceded by a left angle bracket <.

This changes the heuristic to instead look for a left angle bracket <
preceded by a right square bracket ], since according to the C++
grammar, the template arguments must *directly* follow the introducer.
(This sort of check might just end up being *too* aggressive)

This patch also adds a bunch more token annotator tests for lambdas,
specifically for some of the stranger forms of lambdas now allowed as
of C++20 or soon-to-be-allowed as part of C++23.

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

This does NOT resolve the FIXME regarding explicit template lists, but
perhaps it gets closer

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

23 months ago[clang-format] [doc] Fix example of wrapping class definitions
Passw [Tue, 6 Sep 2022 10:21:17 +0000 (12:21 +0200)]
[clang-format] [doc] Fix example of wrapping class definitions

Example of

BraceWrapping
  AfterClass
is wrong

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

23 months agoApply clang-tidy fixes for readability-identifier-naming in OpenMPDialect.cpp (NFC)
Mehdi Amini [Mon, 29 Aug 2022 11:04:41 +0000 (11:04 +0000)]
Apply clang-tidy fixes for readability-identifier-naming in OpenMPDialect.cpp (NFC)

23 months agoApply clang-tidy fixes for readability-identifier-naming in OptimizeSharedMemory...
Mehdi Amini [Mon, 29 Aug 2022 11:02:45 +0000 (11:02 +0000)]
Apply clang-tidy fixes for readability-identifier-naming in OptimizeSharedMemory.cpp (NFC)

23 months ago[SelectionDAG] Rewrite bfloat16 softening to use the "half promotion" path
Benjamin Kramer [Fri, 2 Sep 2022 14:09:05 +0000 (16:09 +0200)]
[SelectionDAG] Rewrite bfloat16 softening to use the "half promotion" path

The main difference is that this preserves intermediate rounding steps,
which the other route doesn't. This aligns bfloat16 more with half
floats, which use this path on most targets.

I didn't understand what the difference was between these softening
approaches when I first added bfloat lowerings, would be nice if we only
had one of them.

Based on @pengfei 's D131502

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

23 months ago[OpenCL] Remove argument names from atomic/fence builtins
Sven van Haastregt [Tue, 6 Sep 2022 09:50:57 +0000 (10:50 +0100)]
[OpenCL] Remove argument names from atomic/fence builtins

This simplifies completeness comparisons against OpenCLBuiltins.td and
also makes the header no longer "claim" the argument name identifiers.

Continues the direction set out in D119560.

23 months ago[CostModel][X86] Add CostKinds handling for fcmp ops
Simon Pilgrim [Tue, 6 Sep 2022 09:34:53 +0000 (10:34 +0100)]
[CostModel][X86] Add CostKinds handling for fcmp ops

This was achieved with an updated version of the 'cost-tables vs llvm-mca' script D103695 (although it still struggles with avx512 predicate numbers which had to be done manually)

SSE numbers are still too low for FCMP_ONE/FCMP_UEQ cases which expand to a more complex sequence than the existing 'ExtraCost' system can manage.

23 months ago[lldb] Enable the insertion of "pending callbacks" to MainLoops from other threads
Pavel Labath [Thu, 4 Aug 2022 11:00:58 +0000 (13:00 +0200)]
[lldb] Enable the insertion of "pending callbacks" to MainLoops from other threads

This will be used as a replacement for selecting over a pipe fd, which
does not work on windows. The posix implementation still uses a pipe
under the hood, while the windows version uses windows event handles.

The idea is that, instead of writing to a pipe, one just inserts a
callback, which does whatever you wanted to do after the bytes come out
the read end of the pipe.

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

23 months ago[MemorySSA][NFC] Simplify if condition
luxufan [Mon, 5 Sep 2022 04:44:55 +0000 (04:44 +0000)]
[MemorySSA][NFC] Simplify if condition

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

23 months ago[OpenMP] Mark -fopenmp-implicit-rpath as NoArgumentUnused
Nikita Popov [Fri, 2 Sep 2022 14:30:15 +0000 (16:30 +0200)]
[OpenMP] Mark -fopenmp-implicit-rpath as NoArgumentUnused

This matches the behavior for all the other -fopenmp options,
as well as -frtlib-add-rpath.

For context, Fedora passes this flag by default in case OpenMP is
used, and this results in a warning if it (usually) isn't, which
causes build failures for some programs with unnecessarily strict
build systems (like Ruby).

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

23 months ago[CMake][MLGO] Fix cmake for MLGO
eopXD [Tue, 6 Sep 2022 07:31:58 +0000 (00:31 -0700)]
[CMake][MLGO] Fix cmake for MLGO

The if-statement should check whehter TFLITE is on or not rather than if the variable is specified.

Reviewed By: mtrofin

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

23 months ago[NFC] [Coroutines] Add tests for looking up deallocation
Chuanqi Xu [Tue, 6 Sep 2022 06:56:58 +0000 (14:56 +0800)]
[NFC] [Coroutines] Add tests for looking up deallocation

According to [dcl.fct.def.coroutine]p12, the program should be
ill-formed if the promise_type contains operator delete but none of them
are available. But this behavior was not tested before. This commit adds
the tests for it.

23 months ago[NFC] Add test of sized deallocation for coroutines
Chuanqi Xu [Tue, 6 Sep 2022 06:44:14 +0000 (14:44 +0800)]
[NFC] Add test of sized deallocation for coroutines

[dcl.fct.def.coroutine]p12 says:

> If both a usual deallocation function with only a pointer parameter
> and a usual deallocation function with both a pointer parameter and a
> size parameter are found, then the selected deallocation function
> shall be the one with two parameters.

However, the sized deallocation function is disabled by default for ABI
reasons. This leads the sentence never get tested and covered. This
commit tries to add a test for it

23 months ago[lld-macho] Simplify linker optimization hint processing
Daniel Bertalan [Sat, 3 Sep 2022 13:29:00 +0000 (15:29 +0200)]
[lld-macho] Simplify linker optimization hint processing

This commit removes the `relocTargets` vector, and instead makes the
code reconstruct the referent addresses from the relocated instructions.
This will allow us to move `applyOptimizationHints` from
`ConcatInputSection::writeTo` to a separate pass that parses and applies
LOHs in one step, on a per-file basis. This will improve performance, as
parsing is currently done serially in `ObjFile::parse`.

I opted to remove the sanity check that ensures that all relocations
within a LOH point to the same symbol. This completely eliminates the
need to search through relocations. It is my understanding that
mismatched relocation targets should not be present in valid object
files, so it's unlikely that the removal will lead to mislinks.

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

23 months ago[OpenMP][OMPD] GDB plugin code to leverage libompd to provide debugging
Vignesh Balasubramanian [Tue, 6 Sep 2022 05:05:44 +0000 (10:35 +0530)]
[OpenMP][OMPD] GDB plugin code to leverage libompd to provide debugging
support for OpenMP programs.

This is 5th of 6 patches started from https://reviews.llvm.org/D100181
This plugin code, when loaded in gdb, adds a few commands like
ompd icv, ompd bt, ompd parallel.
These commands create an interface for GDB to read the OpenMP
runtime through libompd.

Reviewed By: @dreachem
Differential Revision: https://reviews.llvm.org/D100185

23 months ago[RegisterCoalescer] Fix crash on early clobbered subreg operands.
Daniil Fukalov [Tue, 6 Sep 2022 05:42:27 +0000 (08:42 +0300)]
[RegisterCoalescer] Fix crash on early clobbered subreg operands.

The issue was with processing two subregs of the same reg are used in the same
instruction (e.g. inline asm): "def early-clobber" and other just "def".
Register coalescer ran in bad recursion if the early clobbered subreg is second
in the following sequence of COPYs.

Reviewed By: arsenm

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

23 months ago[X86] Support SAE for VCVTPS2PH from intrinsic.
Freddy Ye [Tue, 6 Sep 2022 02:05:45 +0000 (10:05 +0800)]
[X86] Support SAE for VCVTPS2PH from intrinsic.

For now, clang and gcc both failed to generate sae version from _mm512_cvt_roundps_ph:
https://godbolt.org/z/oh7eTGY5z. Intrinsic guide description is also wrong, which will be
update soon.

Reviewed By: pengfei

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

23 months ago[NFC] Remove invisible character in Diagnostic message and tests
Chuanqi Xu [Tue, 6 Sep 2022 03:08:42 +0000 (11:08 +0800)]
[NFC] Remove invisible character in Diagnostic message and tests

23 months ago[RISCV] Improve vector fceil/ffloor lowering by changing FRM.
Craig Topper [Tue, 6 Sep 2022 02:03:44 +0000 (19:03 -0700)]
[RISCV] Improve vector fceil/ffloor lowering by changing FRM.

This adds new VFCVT pseudoinstructions that take a rounding mode operand. A custom inserter is used to insert additional instructions to change FRM around the
VFCVT.

Some of this is borrowed from D122860, but takes a somewhat different direction. We may migrate to that patch, but for now I was trying to keep this as independent from
RVV intrinsics as I could.

A followup patch will use this approach for FROUND too.

Still need to fix the cost model.

Reviewed By: arcbbb

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

23 months ago[LoongArch] Fix annotations not matching predicates. NFC.
gonglingqin [Mon, 5 Sep 2022 12:43:11 +0000 (20:43 +0800)]
[LoongArch] Fix annotations not matching predicates. NFC.

23 months ago[flang] Support lowering of intrinsic module procedure C_F_POINTER
Peixin Qiao [Tue, 6 Sep 2022 00:15:01 +0000 (08:15 +0800)]
[flang] Support lowering of intrinsic module procedure C_F_POINTER

As Fortran 2018 18.2.3.3, the intrinsic module procedure
C_F_POINTER(CPTR, FPTR [, SHAPE]) associates a data pointer with the
target of a C pointer and specify its shape. CPTR shall be a scalar of
type C_PTR, and its value is the C address or the result of a reference
to C_LOC. FPTR is one pointer, either scalar or array. SHAPE is a
rank-one integer array, and it shall be present if and only if FPTR is
an array.

C_PTR is the derived type with only one component of integer 64, and the
integer 64 component value is the address. Build the right "source"
fir::ExtendedValue based on the address and shape, and use
associateMutableBox to associate the pointer with the target of the C
pointer.

Refactor the getting the address of C_PTR to reuse the code.

Reviewed By: jeanPerier

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

23 months agoRevert "[LoopPassManager] Implement and use LoopNestAnalysis::run() instead of manual...
Arthur Eubanks [Mon, 5 Sep 2022 22:41:35 +0000 (15:41 -0700)]
Revert "[LoopPassManager] Implement and use LoopNestAnalysis::run() instead of manually creating LoopNests"

This reverts commit 57fd8665516161c3d2dbe3f0ad8461552967692a.

Causes crashes, see comments in D132581.

23 months agoRevert "Use llvm::none_of (NFC)"
Kazu Hirata [Mon, 5 Sep 2022 21:42:34 +0000 (14:42 -0700)]
Revert "Use llvm::none_of (NFC)"

This partially reverts commit
f5a68feab30a529280c2912dc464e3a81e276f9a.

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

23 months ago[AArch64] Update checks in call lowering test for signext in prep for bug fix.
Amara Emerson [Mon, 5 Sep 2022 20:39:20 +0000 (21:39 +0100)]
[AArch64] Update checks in call lowering test for signext in prep for bug fix.

23 months ago[ARM64EC 5/?] Fix names of __chkstk and __security_check_cookie.
Eli Friedman [Mon, 5 Sep 2022 20:19:42 +0000 (13:19 -0700)]
[ARM64EC 5/?] Fix names of __chkstk and __security_check_cookie.

Part of initial Arm64EC patchset.

Arm64EC code needs to use functions with a different name, to avoid
using the x64 versions.

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

23 months ago[X86] Add test cases for PR57549. NFC
Craig Topper [Mon, 5 Sep 2022 20:12:18 +0000 (13:12 -0700)]
[X86] Add test cases for PR57549. NFC

23 months ago[ARM64EC 4/?] Add LLVM support for varargs calling convention.
Eli Friedman [Mon, 5 Sep 2022 20:05:48 +0000 (13:05 -0700)]
[ARM64EC 4/?] Add LLVM support for varargs calling convention.

Part of patchset to add initial support for ARM64EC.

The ARM64EC calling convention is the same as ARM64 for non-varargs
functions, but for varargs, the convention is significantly different.
Basically, only x0-x3 registers are used for passing arguments, and x4
and x5 describe the address/size of the arguments passed in memory. (See
https://docs.microsoft.com/en-us/windows/uwp/porting/arm64ec-abi for
more details; see
https://docs.microsoft.com/en-us/cpp/build/x64-calling-convention for
the x64 calling convention rules, which this convention needs to match.)

Note that this currently doesn't handle i128 arguments correctly; as
noted in review, that's sort of complicated to handle, so I'm leaving it
for a followup.

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

23 months ago[ARM64EC 3/?] Mark reserved registers specific to ARM64EC ABI.
Eli Friedman [Mon, 5 Sep 2022 19:59:39 +0000 (12:59 -0700)]
[ARM64EC 3/?] Mark reserved registers specific to ARM64EC ABI.

Part of patchset to add initial support for ARM64EC.

I'm not completely sure I understand the reason for this restriction,
but Microsoft documentation says that asynchronous signals clobber these
registers, so we can't ever use them.

As far as I know, none of these registers have any hardcoded meaning, so
reserving them shouldn't have any significant side-effects.

Differental Revision: https://reviews.llvm.org/D125413

23 months ago[ARM64EC 2/?] Add target triple, and allow targeting it.
Eli Friedman [Mon, 5 Sep 2022 19:27:10 +0000 (12:27 -0700)]
[ARM64EC 2/?] Add target triple, and allow targeting it.

Part of patchset to add initial support for ARM64EC.

Per discussion on review, using the triple arm64ec-pc-windows-msvc. The
parsing works the same way as Apple's alternate Arm ABI "arm64e".

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

23 months ago[ARM64EC 1/?] Add parsing support to llvm-objdump/llvm-readobj.
Eli Friedman [Mon, 5 Sep 2022 19:25:08 +0000 (12:25 -0700)]
[ARM64EC 1/?] Add parsing support to llvm-objdump/llvm-readobj.

This is the first patch of a patchset to add initial support for
ARM64EC. Basic documentation is available at
https://docs.microsoft.com/en-us/windows/uwp/porting/arm64ec-abi .
(Discourse post:
https://discourse.llvm.org/t/initial-patches-for-arm64ec-windows-11-now-posted/62449
.)

The file format for ARM64EC is basically identical to normal ARM64.
There are a few extra sections, but the existing code for reading ARM64
object files just works.

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

23 months ago[AArch64][GlobalISel] Recognise some CCMPri
David Green [Mon, 5 Sep 2022 18:43:23 +0000 (19:43 +0100)]
[AArch64][GlobalISel] Recognise some CCMPri

This is a simple addition to emitConditionalComparison, to match CCMP
with immediates using getIConstantVRegValWithLookThrough, letting it
select the CCMPri variants of the instructions.

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

23 months ago[Verifier] Reject dllexport with non-default visibility
Fangrui Song [Mon, 5 Sep 2022 17:53:41 +0000 (10:53 -0700)]
[Verifier] Reject dllexport with non-default visibility

Add a visibility check for dllimport and dllexport. Note: dllimport with a
non-default visibility (implicit dso_local) is already rejected, but with a less
clear dso_local error.

The MC level visibility `MCSA_Exported` (D123951) is mapped from IR level
default visibility when dllexport is specified. The D123951 error is now very
difficult to trigger (needs to disable the IR verifier).

Reviewed By: mstorsjo

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

23 months ago[MinGW] Reject explicit non-default visibility applied to dllexport/dllimport declaration
Fangrui Song [Mon, 5 Sep 2022 17:17:19 +0000 (10:17 -0700)]
[MinGW] Reject explicit non-default visibility applied to dllexport/dllimport declaration

dllimport/dllexport is incompatible with protected/hidden visibilities.
(Arguably dllexport semantics is compatible with protected but let's reject the
combo for simplicity.)

When an explicit visibility attribute applies on a dllexport/dllimport
declaration, report a Frontend error (Sema does not compute visibility).

Reviewed By: mstorsjo

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

23 months ago[clangd] Trace preamble throttle time
Sam McCall [Mon, 5 Sep 2022 16:34:41 +0000 (18:34 +0200)]
[clangd] Trace preamble throttle time

23 months ago[ELF] Provide the GNU hash function in libObject
Joseph Huber [Thu, 25 Aug 2022 19:00:07 +0000 (14:00 -0500)]
[ELF] Provide the GNU hash function in libObject

GNU uses a different hashing function compared to the sys-V standard
function already provided in libObject. This is already used internally
in LLD for generating synthetic sections. This patch simply extracts
this definition and makes it availible to other users of `libObject`.
This is done in preparation for supporting symbol name lookups via the
GNU hash table.

Reviewed By: MaskRay, jhenderson

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

23 months ago[InstSimplify][NFC] shortened the code
LiaoChunyu [Mon, 5 Sep 2022 15:57:53 +0000 (23:57 +0800)]
[InstSimplify][NFC] shortened the code

23 months ago[InstSimplify] Odd - X ==/!= X -> false/true
LiaoChunyu [Mon, 5 Sep 2022 15:30:52 +0000 (23:30 +0800)]
[InstSimplify] Odd - X ==/!= X -> false/true

Reviewed By: spatel

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

23 months ago[InstSimplify][NFC][test] Add tests for Odd - X ==/!= X -> false/true
LiaoChunyu [Mon, 5 Sep 2022 15:17:03 +0000 (23:17 +0800)]
[InstSimplify][NFC][test] Add tests for Odd - X ==/!= X -> false/true

testcases will be updated by D132989

Reviewed By: spatel

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

23 months ago[analyzer] Track trivial copy/move constructors and initializer lists in the BugReporter
isuckatcs [Thu, 18 Aug 2022 08:52:16 +0000 (10:52 +0200)]
[analyzer] Track trivial copy/move constructors and initializer lists in the BugReporter

If an object has a trivial copy/move constructor, it's not inlined
on invocation but a trivial copy is performed instead. This patch
handles trivial copies in the bug reporter by matching the field
regions of the 2 objects involved in the copy/move construction,
and tracking the appropriate region further. This patch also
introduces some support for tracking values in initializer lists.

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

23 months ago[GlobalISel] Update combine-build-vector.mir test checks before patch.
Amara Emerson [Mon, 5 Sep 2022 15:05:44 +0000 (16:05 +0100)]
[GlobalISel] Update combine-build-vector.mir test checks before patch.

23 months ago[lld-macho] Diagnose unaligned arm64 PAGEOFF12 relocations
Daniel Bertalan [Sat, 3 Sep 2022 17:21:12 +0000 (19:21 +0200)]
[lld-macho] Diagnose unaligned arm64 PAGEOFF12 relocations

The LDR and STR instructions store their immediate offsets as a multiple
of the load/store's size. Therefore, if the target address is not
aligned, the relocation is not representable. We now emit an error if
that happens, similarly to ld64.

This commit removes a test case from loh-adrp-ldr.s that contained an
unaligned LDR.

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

23 months ago[gn build] Port 2d52c6bfae80
LLVM GN Syncbot [Mon, 5 Sep 2022 14:41:45 +0000 (14:41 +0000)]
[gn build] Port 2d52c6bfae80

23 months ago[clang-format] Use utf-8 for JSON object load
Amy Wang [Mon, 5 Sep 2022 14:36:36 +0000 (15:36 +0100)]
[clang-format] Use utf-8 for JSON object load

From Python 3.6 and above, it should be able to automatically select a
decoding for json.loads. However, with a vim encoding that defaults
to utf-8, clang-format.py runs into the following error

    TypeError: the JSON object must be str, not 'bytes'

This patch explicitly specifies utf-8 decoding for the header.

Reviewed by: ldrumm, sammcall

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

23 months ago[libc++] Granularize __tuple
Nikolas Klauser [Mon, 5 Sep 2022 12:38:24 +0000 (14:38 +0200)]
[libc++] Granularize __tuple

Reviewed By: ldionne, #libc

Spies: libcxx-commits, mgorny

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

23 months ago[GlobalISel] Update test checks before a patch.
Amara Emerson [Mon, 5 Sep 2022 14:17:55 +0000 (15:17 +0100)]
[GlobalISel] Update test checks before a patch.

23 months ago[SimplifyCFG] Allow SimplifyCFG hoisting to skip over non-matching instructions
Momchil Velikov [Mon, 5 Sep 2022 11:25:03 +0000 (12:25 +0100)]
[SimplifyCFG] Allow SimplifyCFG hoisting to skip over non-matching instructions

SimplifyCFG does some common code hoisting, which is limited
to hoisting a sequence of identical instruction in identical
order and stops at the first non-identical instruction.

This patch allows hoisting instruction pairs over
same-length sequences of non-matching instructions. The
linear asymptotic complexity of the algorithm stays the
same, there's an extra parameter
`simplifycfg-hoist-common-skip-limit` serving to limit
compilation time and/or the size of the hoisted live ranges.

The patch improves SPECv6/525.x264_r by about 10%.

Reviewed By: nikic, dmgreen

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

23 months ago[MachineVerifier] Fix crash on early clobbered subreg operands.
Daniil Fukalov [Mon, 5 Sep 2022 14:07:55 +0000 (17:07 +0300)]
[MachineVerifier] Fix crash on early clobbered subreg operands.

MachineVerifier tried to checkLivenessAtDef() ignoring it is actually a subreg.

The issue was with processing two subregs of the same reg are used in the same
instruction (e.g. inline asm): "def early-clobber" and other just "def".

Reviewed By: foad

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

23 months ago[CodeGen] Support extracting fixed-length vectors from illegal scalable vectors
David Sherwood [Mon, 17 Jan 2022 15:43:55 +0000 (15:43 +0000)]
[CodeGen] Support extracting fixed-length vectors from illegal scalable vectors

For some indices we can simply extract the fixed-length subvector from the
low half of the scalable vector, for example when the index is less than the
minimum number of elements in the low half. For all other cases we can
expand the operation through the stack by storing out the vector and
reloading the fixed-length part we need.

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

Tests added here:

  CodeGen/AArch64/sve-extract-fixed-from-scalable-vector.ll

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

23 months ago[clangd] Fix LineFoldingOnly flag is not propagated correctly to ClangdServer.
Haojian Wu [Mon, 5 Sep 2022 12:55:13 +0000 (14:55 +0200)]
[clangd] Fix LineFoldingOnly flag is not propagated correctly to ClangdServer.

The Opts.LineFoldingOnly must be set before the clangdServer
construction, otherwise this flag is always false when using clangd in VSCode.

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

23 months ago[InstCombine] reduce test-for-overflow of shifted value
Tian Zhou [Mon, 5 Sep 2022 13:50:40 +0000 (09:50 -0400)]
[InstCombine] reduce test-for-overflow of shifted value

Fixes #57338.

The added code makes the following transformations:

For unsigned predicates / eq / ne:
icmp pred (x << 1), x --> icmp getSignedPredicate(pred) x, 0
icmp pred x, (x << 1) --> icmp getSignedPredicate(pred) 0, x

Some examples:
https://alive2.llvm.org/ce/z/ckn4cj
https://alive2.llvm.org/ce/z/h-4bAQ

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

23 months ago[AMDGPU][CodeGen] Support (base | offset) SMEM loads.
Ivan Kosarev [Mon, 5 Sep 2022 13:13:12 +0000 (14:13 +0100)]
[AMDGPU][CodeGen] Support (base | offset) SMEM loads.

Prevents generation of unnecessary s_or_b32 instructions.

Reviewed By: foad

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

23 months ago[clangd] NFC, correct template argument type for two RetiredFlags.
Haojian Wu [Mon, 5 Sep 2022 13:12:19 +0000 (15:12 +0200)]
[clangd] NFC, correct template argument type for two RetiredFlags.

23 months ago[SPIRV] Add tests to improve test coverage
Andrey Tretyakov [Sun, 4 Sep 2022 01:09:02 +0000 (04:09 +0300)]
[SPIRV] Add tests to improve test coverage

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

23 months ago[X86] Cleanup SLM SSE shift and CMPGTQ scheduler model numbers
Simon Pilgrim [Mon, 5 Sep 2022 12:43:56 +0000 (13:43 +0100)]
[X86] Cleanup SLM SSE shift and CMPGTQ scheduler model numbers

These were causing weird mismatches for the D103695 script report as I'm trying to enable cost kinds support for vector shift and integer comparisons.

The SSE shifts by (non-constant) scalar are half-rate but still only 1uop and PCMPGT is half-rate and only on Pipe0 (although not as slow as PCMPEQQ which we already handle).

23 months ago[mlir][bufferize] Add new debug flag: copy-before-write
Matthias Springer [Mon, 5 Sep 2022 11:49:27 +0000 (13:49 +0200)]
[mlir][bufferize] Add new debug flag: copy-before-write

If this flag is set, the analysis is skipped and buffers are copied before every write.

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

23 months ago[libc++] Enable rvalue overloads for pair in C++03
Nikolas Klauser [Mon, 5 Sep 2022 10:44:28 +0000 (12:44 +0200)]
[libc++] Enable rvalue overloads for pair in C++03

We require rvalue support anyways, so let's use it.

Reviewed By: ldionne, #libc

Spies: libcxx-commits

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

23 months agoApply clang-tidy fixes for readability-simplify-boolean-expr in NVGPUDialect.cpp...
Mehdi Amini [Mon, 29 Aug 2022 11:01:52 +0000 (11:01 +0000)]
Apply clang-tidy fixes for readability-simplify-boolean-expr in NVGPUDialect.cpp (NFC)

23 months agoApply clang-tidy fixes for performance-unnecessary-value-param in FoldMemRefAliasOps...
Mehdi Amini [Mon, 29 Aug 2022 11:00:29 +0000 (11:00 +0000)]
Apply clang-tidy fixes for performance-unnecessary-value-param in FoldMemRefAliasOps.cpp (NFC)

23 months ago[AMDGPU][CodeGen] Pre-commit a test on (base | offset) SMEM loads for D132552.
Ivan Kosarev [Mon, 5 Sep 2022 12:10:14 +0000 (13:10 +0100)]
[AMDGPU][CodeGen] Pre-commit a test on (base | offset) SMEM loads for D132552.

Reviewed By: foad

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

23 months ago[FLANG][NFC]Use RTNAME instead of hard-coding for simplify intrinsics
Mats Petersson [Thu, 25 Aug 2022 12:03:21 +0000 (13:03 +0100)]
[FLANG][NFC]Use RTNAME instead of hard-coding for simplify intrinsics

Use the RTNMAE macro (via stringify macros) to generate the name
strings for runtime functions, instead of using strings.
The sequence of macros generate exactly the same string as the
ones used previously, but this will support future changes in
runtime function names.

No functional change.

Reviewed By: vzakhari

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

23 months agoPlumb write_bytecode to the Python API
Mehdi Amini [Mon, 5 Sep 2022 11:54:19 +0000 (11:54 +0000)]
Plumb write_bytecode to the Python API

This adds a `write_bytecode` method to the Operation class.
The method takes a file handle and writes the binary blob to it.

Reviewed By: ftynse

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

23 months ago[AMDGPU][CodeGen] Support (soffset + offset) s_buffer_load's.
Ivan Kosarev [Mon, 5 Sep 2022 11:52:06 +0000 (12:52 +0100)]
[AMDGPU][CodeGen] Support (soffset + offset) s_buffer_load's.

Reviewed By: foad

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

23 months ago[flang] Create a box instead of a temp to write to a char array
Valentin Clement [Mon, 5 Sep 2022 11:28:19 +0000 (13:28 +0200)]
[flang] Create a box instead of a temp to write to a char array

Reviewed By: jeanPerier

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

23 months ago[GlobalISel] Fix a combine crash due to a negative G_INSERT_VECTOR_ELT idx.
Amara Emerson [Mon, 5 Sep 2022 11:09:17 +0000 (12:09 +0100)]
[GlobalISel] Fix a combine crash due to a negative G_INSERT_VECTOR_ELT idx.

These should really be folded away to undef but we shouldn't crash in any case.

23 months ago[mlir][NFC] Move CodeGenHelpers.cpp from mlir-tblgen to TableGen library
Markus Böck [Mon, 5 Sep 2022 11:05:57 +0000 (13:05 +0200)]
[mlir][NFC] Move CodeGenHelpers.cpp from mlir-tblgen to TableGen library

Its header was already part of the TableGen library, but unusable as uses of its functions or classes would lead to undefined references when linking. This fixes that.

23 months ago[DAG] getFreeze()/getNode() - account for operand depth when calling isGuaranteedNotT...
Simon Pilgrim [Mon, 5 Sep 2022 10:46:38 +0000 (11:46 +0100)]
[DAG] getFreeze()/getNode() - account for operand depth when calling isGuaranteedNotToBeUndefOrPoison (PR57554)

Similar to #57402 - we were calling isGuaranteedNotToBeUndefOrPoison on the freeze operand (with Depth = 0), but wasn't accounting for the fact that a later isGuaranteedNotToBeUndefOrPoison assertion will call from the new node (with Depth = 0 as well) - which will then recursively call isGuaranteedNotToBeUndefOrPoison for its operands with Depth = 1

Fixes #57554

23 months agoAdd ArithBuilder::sub, make add, mul work with IndexTypes.
Johannes Reifferscheid [Mon, 5 Sep 2022 09:25:58 +0000 (11:25 +0200)]
Add ArithBuilder::sub, make add, mul work with IndexTypes.

sgt and slt already worked with IndexTypes, the others did not.

Reviewed By: pifon2a

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

23 months ago[gn build] Port d5e26775d089
LLVM GN Syncbot [Mon, 5 Sep 2022 10:39:22 +0000 (10:39 +0000)]
[gn build] Port d5e26775d089

23 months ago[libc++] Granularize the rest of memory
Nikolas Klauser [Sun, 4 Sep 2022 22:01:15 +0000 (00:01 +0200)]
[libc++] Granularize the rest of memory

Reviewed By: ldionne, #libc

Spies: vitalybuka, paulkirth, libcxx-commits, mgorny

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

23 months ago[clang-format] Concepts: allow identifiers after negation
Emilia Dreamer [Mon, 5 Sep 2022 10:33:59 +0000 (12:33 +0200)]
[clang-format] Concepts: allow identifiers after negation

Previously, the formatter would refuse to treat identifiers within a
compound concept definition as actually part of the definition, if
they were after the negation operator !. It is now made consistent
with the likes of && and ||.

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

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

23 months ago[clang-format] Allow `throw` to be a keyword in front of casts
Emilia Dreamer [Mon, 5 Sep 2022 10:32:40 +0000 (12:32 +0200)]
[clang-format] Allow `throw` to be a keyword in front of casts

This makes throw more similar to return. However, unlike return,
it has to more strict as to not remove spaces after usages of throw as
a (deprecated) exception specifier.

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

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

23 months ago[clang-format] Don't put `noexcept` on empty line following constructor
Emilia Dreamer [Mon, 5 Sep 2022 10:19:31 +0000 (12:19 +0200)]
[clang-format] Don't put `noexcept` on empty line following constructor

With the AlwaysBreakTemplateDeclarations option, having a constructor
template for a type consisting of all-uppercase letters with a
noexcept specifier would put said noexcept specifier on its own blank
line.

This is because the all-uppercase type is understood as a macro-like
attribute (such as DEPRECATED()), and noexcept is seen as the
declaration. However, noexcept is a keyword and cannot be an
identifier on its own.

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

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

23 months ago[ubsan-minimal] Report the address of an error
Igor Kudrin [Mon, 15 Aug 2022 18:24:08 +0000 (22:24 +0400)]
[ubsan-minimal] Report the address of an error

This implements a FIXME in the runtime library and adds printing the
address at the end of the message as "by 0x123abc". The buffer for the
message is allocated on the stack in a handler, so the stack memory
consumption is slightly increased. No additional external dependencies
are added.

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

23 months ago[VPlan] Move VPWidenCallRecipe to VPlanRecipes.cpp (NFC).
Florian Hahn [Mon, 5 Sep 2022 09:48:29 +0000 (10:48 +0100)]
[VPlan] Move VPWidenCallRecipe to VPlanRecipes.cpp (NFC).

Depends on D132585.

Reviewed By: Ayal

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

23 months ago[mlir][tensor] Add gather/scatter op definitions to the tensor dialect.
Nicolas Vasilache [Thu, 21 Jul 2022 11:38:46 +0000 (04:38 -0700)]
[mlir][tensor] Add gather/scatter op definitions to the tensor dialect.

Gather/Scatter are examined from first principles in light of our recent progress on tensor-based codegen
and in-place bufferization.

In the future, lowering of these abstractions to operate **inplace** on buffers
will likely require a more powerful buffer representation than strided memref.

General context: https://discourse.llvm.org/t/rfc-structured-codegen-beyond-rectangular-arrays/64707
Relevant TL;DR parts of the proposal:
- gather: https://discourse.llvm.org/t/rfc-structured-codegen-beyond-rectangular-arrays/64707#proposal-gatherop-and-friends-10
- need for more expressive types: https://discourse.llvm.org/t/rfc-structured-codegen-beyond-rectangular-arrays/64707#proposal-bufferization-copy-view-and-the-need-for-more-expressive-types-12
- jagged buffer discussion: https://discourse.llvm.org/t/rfc-structured-codegen-beyond-rectangular-arrays/64707#proposal-first-class-jagged-buffer-13

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

23 months agoDriver tests: remove `REQUIRES: x86-registered-target` and set `--sysroot=""` to...
Ying Yi [Fri, 2 Sep 2022 09:25:34 +0000 (10:25 +0100)]
Driver tests: remove `REQUIRES: x86-registered-target` and set `--sysroot=""` to support clang with `DEFAULT_SYSROOT`.

When testing clang that has been compiled with -DDEFAULT_SYSROOT set to some path, ps4-ps5-header-search.c would fail.

The test needs to be updated.

    1. Remove unnecessary REQUIRES: x86-registered-target.
    2. Override sysroot to be empty string for the test to succeed when clang is configured with DEFAULT_SYSROOT.

23 months ago[clang] Fix crash when parsing scanf format string with missing arguments
serge-sans-paille [Fri, 2 Sep 2022 11:36:08 +0000 (13:36 +0200)]
[clang] Fix crash when parsing scanf format string with missing arguments

When parsing a format string with less argument than specified, one should check
argument access because there may be no such argument.

This fixes #57517

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

23 months ago[bazel] NFC: Move licenses declaration from package to function.
Christian Sigg [Mon, 5 Sep 2022 08:43:48 +0000 (10:43 +0200)]
[bazel] NFC: Move licenses declaration from package to function.

The `licences` attribute is deprecated, see https://docs.bazel.build/versions/4.0.0/be/common-definitions.html#common-attributes.

23 months ago[NFC][TypePromotion] Add test
Samuel Parker [Mon, 5 Sep 2022 07:58:16 +0000 (08:58 +0100)]
[NFC][TypePromotion] Add test

23 months agoFix build error in StmtPrinterTest.cpp
Nathan Ridge [Mon, 5 Sep 2022 07:48:17 +0000 (03:48 -0400)]
Fix build error in StmtPrinterTest.cpp

23 months ago[LICM] Separate check for writability and thread-safety (NFCI)
Nikita Popov [Mon, 5 Sep 2022 07:39:59 +0000 (09:39 +0200)]
[LICM] Separate check for writability and thread-safety (NFCI)

This used a single check to make sure that the object is both
writable and thread-local. Separate them out to make the
deficiencies in the current code more obvious.

23 months ago[clangd] Avoid crash when printing call to string literal operator template
Nathan Ridge [Mon, 29 Aug 2022 08:19:19 +0000 (04:19 -0400)]
[clangd] Avoid crash when printing call to string literal operator template

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

23 months ago[clang-format][docs] Fix incorrect 'clang-format 4' option markers
Krystian Kuzniarek [Sun, 4 Sep 2022 20:06:42 +0000 (22:06 +0200)]
[clang-format][docs] Fix incorrect 'clang-format 4' option markers

Introduced by 23a5090c6, some style option markers indicated
'clang-format 4', though their respective options were available in
earlier releases.

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

23 months ago[Coroutines] Use LookupAllocationFunction to find allocation functions for coroutines...
Chuanqi Xu [Mon, 5 Sep 2022 06:17:58 +0000 (14:17 +0800)]
[Coroutines] Use LookupAllocationFunction to find allocation functions for coroutines consistently

Previously we may call Sema::FindAllocationFunctions directly to lookup
allocation functions directly instead of using our wrapped lambda
LookupAllocationFunction, which is slightly incosnsistent. It will be
helpful to refactor this for further changes.

Also previously, when we lookup 'operator new(std::size_t, std::nothrow_t)' in
case we found `get_­return_­object_­on_­allocation_­failure` in the
promise_type, the compiler will try to look at the allocation function
in promise_type. However, this is not wanted actually. According to
[dcl.fct.def.coroutine]p10:

> if a global allocation function is selected, the
> ::operator new(size_­t, nothrow_­t) form is used.

So we should only lookup for `::operator (size_t, nothrow_t)` for the
global allocation function. For the allocation function in the
promise_type, the requirement is that it shouldn't throw, which has
already been checked.

Given users generally include headers from standard libs so it will
generally include the <new> header, so this change should be a trivial
one and shouldn't affect almost any user.

23 months ago[ELF][test] --gc-sections: test SHT_FINI_ARRAY is retained
Fangrui Song [Mon, 5 Sep 2022 07:03:40 +0000 (00:03 -0700)]
[ELF][test] --gc-sections: test SHT_FINI_ARRAY is retained

23 months ago[ELF] MarkLive: remove dead code from D24750. NFC
Fangrui Song [Mon, 5 Sep 2022 07:01:09 +0000 (00:01 -0700)]
[ELF] MarkLive: remove dead code from D24750. NFC

23 months ago[LoongArch] Add more fixups and relocations
wanglei [Mon, 5 Sep 2022 06:27:36 +0000 (14:27 +0800)]
[LoongArch] Add more fixups and relocations

This patch makes the assembler support all modifiers defined in gnu-as.
Also changes some diagnostic information.

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

23 months ago[ASTReader] Fix -Wunused-private-field in non-assertion builds after D128490. NFC
Fangrui Song [Mon, 5 Sep 2022 06:48:54 +0000 (23:48 -0700)]
[ASTReader] Fix -Wunused-private-field in non-assertion builds after D128490. NFC

23 months ago[ELF] Reuse one RelocationScanner to scan all sections. NFC
Fangrui Song [Mon, 5 Sep 2022 06:12:26 +0000 (23:12 -0700)]
[ELF] Reuse one RelocationScanner to scan all sections. NFC

23 months ago[TargetLowering] Use ComputeMaxSignificantBits instead of ComputeNumSignBits in expan...
Craig Topper [Mon, 5 Sep 2022 05:20:52 +0000 (22:20 -0700)]
[TargetLowering] Use ComputeMaxSignificantBits instead of ComputeNumSignBits in expandMUL_LOHI. NFC

The way ComputeNumSignBits was being used was only correct if
OuterBitSize is exactly 2x InnerBitSize. Which is always true,
but not obviously so. Comparing ComputeMaxSignificantBits to
InnerBitSize feels more correct.

23 months ago[ELF] Move scanRelocations into Relocations.cpp. NFC
Fangrui Song [Mon, 5 Sep 2022 04:31:18 +0000 (21:31 -0700)]
[ELF] Move scanRelocations into Relocations.cpp. NFC

23 months ago[ELF] Relocations: set hasDirectReloc only if not ifunc. NFC
Fangrui Song [Mon, 5 Sep 2022 04:30:19 +0000 (21:30 -0700)]
[ELF] Relocations: set hasDirectReloc only if not ifunc. NFC

23 months ago[X86] Pre-commit tests for D130862. NFC
Craig Topper [Mon, 5 Sep 2022 04:18:54 +0000 (21:18 -0700)]
[X86] Pre-commit tests for D130862. NFC