platform/upstream/llvm.git
2 years ago[libc][obvious] fix missed rename
Michael Jones [Wed, 8 Dec 2021 00:07:24 +0000 (16:07 -0800)]
[libc][obvious] fix missed rename

In https://reviews.llvm.org/D114302 I renamed ForLoopCopy to
for_loop_copy, but these got missed.

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

2 years ago[compiler-rt] Use the runtimes build for custom libc++
Petr Hosek [Wed, 1 Dec 2021 09:07:14 +0000 (01:07 -0800)]
[compiler-rt] Use the runtimes build for custom libc++

Some of the compiler-rt runtimes use custom instrumented libc++ build.
Use the runtimes build for building this custom libc++.

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

2 years ago[libc] fix the .yaml files not being tracked
Michael Jones [Tue, 7 Dec 2021 22:48:28 +0000 (14:48 -0800)]
[libc] fix the .yaml files not being tracked

adds the .yaml files clang-tidy generates as byproducts, which means
that they will be updated properly and cleaned by `ninja -t clean`

Reviewed By: lntue

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

2 years ago[mlir][sparse] add a few more sparse output tests (for generated IR)
Aart Bik [Tue, 7 Dec 2021 22:33:39 +0000 (14:33 -0800)]
[mlir][sparse] add a few more sparse output tests (for generated IR)

also fixes two typos in IR doc

Reviewed By: bixia

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

2 years agoRevert "Revert "Use VersionTuple for parsing versions in Triple, fixing issues that...
James Farrell [Mon, 6 Dec 2021 17:41:26 +0000 (17:41 +0000)]
Revert "Revert "Use VersionTuple for parsing versions in Triple, fixing issues that caused the original change to be reverted. This makes it possible to distinguish between "16" and "16.0" after parsing, which previously was not possible.""

This reverts commit 63a6348cad6caccf285c1661bc60d8ba5a40c972.

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

2 years agoRevert "[RISCV] Add target specific loop unrolling and peeling preferences"
Michael Berg [Tue, 7 Dec 2021 23:13:42 +0000 (15:13 -0800)]
Revert "[RISCV] Add target specific loop unrolling and peeling preferences"

This reverts commit 8487981a7249f7c080d5395ebee0e8b969c6f47c.

2 years ago[CUDA][HIP] Add pre-defined macro `__CLANG_RDC__`
Yaxun (Sam) Liu [Tue, 30 Nov 2021 19:45:16 +0000 (14:45 -0500)]
[CUDA][HIP] Add pre-defined macro `__CLANG_RDC__`

nvcc defines __CUDACC_RDC__ for both host and
device compilation when -rdc=true is specified
(https://docs.nvidia.com/cuda/cuda-compiler-driver-nvcc/index.html#nvcc-identification-macro)

This patch defines __CLANG_RDC__ when -fgpu-rdc
is specified for CUDA/HIP.

Reviewed by: Artem Belevich

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

2 years agoFix error reporting for "process load" and add a test for it.
Jim Ingham [Tue, 7 Dec 2021 19:56:36 +0000 (11:56 -0800)]
Fix error reporting for "process load" and add a test for it.

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

2 years ago[RISCV] Add target specific loop unrolling and peeling preferences
Michael Berg [Tue, 7 Dec 2021 23:06:24 +0000 (15:06 -0800)]
[RISCV] Add target specific loop unrolling and peeling preferences

Both these preference helper functions have initial support with
this change. The loop unrolling preferences are set with initial
settings to control thresholds, size and attributes of loops to
unroll with some tuning done.  The peeling preferences may need
some tuning as well as the initial support looks much like what
other architectures utilize.

Reviewed By: craig.topper

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

2 years ago[OpenMP][AMDGPU] Switch host-device memory copy to asynchronous version
Carlo Bertolli [Tue, 7 Dec 2021 23:04:50 +0000 (23:04 +0000)]
[OpenMP][AMDGPU] Switch host-device memory copy to asynchronous version

Prepare amdgpu plugin for asynchronous implementation. This patch switches to using HSA API for asynchronous memory copy.
Moving away from hsa_memory_copy means that plugin is responsible for locking/unlocking host memory pointers.

Reviewed By: JonChesterfield

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

2 years agoConvert fir.allocmem and fir.freemem operations to calls to malloc and free, respectively
AlexisPerry [Tue, 2 Nov 2021 21:46:21 +0000 (15:46 -0600)]
Convert fir.allocmem and fir.freemem operations to calls to malloc and free, respectively

This patch is part of the upstreaming effort from the fir-dev branch.

Address review comments
- move CHECK blocks to after the mlir code in the test file
- fix style with respect to anonymous namespaces: only include class definitions in the namespace and make functions static and outside the namespace
- fix a few nits
- remove TODO in favor of notifyMatchFailure
- removed unnecessary CHECK line from convert-to-llvm.fir
- rebase on main - add TODO back in
- get successfull test of TODO in AllocMemOp converion of derived type with LEN params
- clearer comments and reduced use of auto
- move defintion of computeDerivedTypeSize to fix build error

Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
Co-authored-by: Jean Perier <jperier@nvidia.com>
Reviewed By: awarzynski, clementval, kiranchandramohan, schweitz

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

2 years ago[ASan] Removed ASAN_SHADOW_SCALE.
Kirill Stoimenov [Tue, 7 Dec 2021 22:28:22 +0000 (22:28 +0000)]
[ASan] Removed ASAN_SHADOW_SCALE.

This is additional cleanup as follow-up of D104279.

Reviewed By: vitalybuka

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

2 years agoReapply [runtimes] Fix building initial libunwind+libcxxabi+libcxx with compiler...
Martin Storsjö [Sat, 23 Oct 2021 22:11:20 +0000 (01:11 +0300)]
Reapply [runtimes] Fix building initial libunwind+libcxxabi+libcxx with compiler implied -lunwind

This does mostly the same as D112126, but for the runtimes cmake files.
Most of that is straightforward, but the interdependency between
libcxx and libunwind is tricky:

Libunwind is built at the same time as libcxx, but libunwind is not
installed yet. LIBCXXABI_USE_LLVM_UNWINDER makes libcxx link directly
against the just-built libunwind, but the compiler implicit -lunwind
isn't found. This patch avoids that by adding --unwindlib=none if
supported, if we are going to link explicitly against a newly built
unwinder anyway.

Reapplying this after
db32c4f45625dddc2c5cb683adf3d9cab7a9732f, which should fix the issues
that were reported last time this was applied.

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

2 years ago[Flang] Upstream conversion of the XRebox Op
Kiran Chandramohan [Tue, 7 Dec 2021 13:01:28 +0000 (13:01 +0000)]
[Flang] Upstream conversion of the XRebox Op

The XRebox Op is formed by the codegen rewrite which makes it easier to
convert the operation to LLVM. The XRebox op includes the information
from the rebox op and the associated slice, shift, and shape ops.

During the conversion process a new descriptor is created for reboxing.

Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
Co-authored-by: Val Donaldson <vdonaldson@nvidia.com>
Reviewed By: clementval

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

2 years agoRevert "[ASan] Removed ASAN_SHADOW_SCALE."
Kirill Stoimenov [Tue, 7 Dec 2021 22:17:58 +0000 (22:17 +0000)]
Revert "[ASan] Removed ASAN_SHADOW_SCALE."

This reverts commit e4800fc099ad204f88c432276e6488772042bffc.

Reviewed By: kstoimenov

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

2 years ago[ASan] Removed ASAN_SHADOW_SCALE.
Kirill Stoimenov [Tue, 7 Dec 2021 19:08:52 +0000 (19:08 +0000)]
[ASan] Removed ASAN_SHADOW_SCALE.

This is additional cleanup as follow-up of D104279.

Reviewed By: vitalybuka

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

2 years ago[libc++] Remove _LIBCPP_DEFAULT
Nikolas Klauser [Tue, 7 Dec 2021 19:29:35 +0000 (20:29 +0100)]
[libc++] Remove _LIBCPP_DEFAULT

clang has `= default` as an extension in c++03, so just use it.

Reviewed By: ldionne, Quuxplusone, #libc

Spies: libcxx-commits

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

2 years ago[gn build] Port 02940d6d2202
LLVM GN Syncbot [Tue, 7 Dec 2021 21:08:05 +0000 (21:08 +0000)]
[gn build] Port 02940d6d2202

2 years agoRevert "CycleInfo: Introduce cycles as a generalization of loops"
Jonas Devlieghere [Tue, 7 Dec 2021 18:50:08 +0000 (10:50 -0800)]
Revert "CycleInfo: Introduce cycles as a generalization of loops"

This reverts commit 0fe61ecc2cef333250a152cd90d80d0b802b27db because it
breaks the modules build.

https://green.lab.llvm.org/green/job/clang-stage2-rthinlto/4858/
https://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/39112/

2 years ago[NFC][OpenMP] Prepare amdgpu plugin for asynchronous implementation of target region...
Carlo Bertolli [Tue, 7 Dec 2021 21:00:11 +0000 (21:00 +0000)]
[NFC][OpenMP] Prepare amdgpu plugin for asynchronous implementation of target region launch

At present, amdgpu plugin merges both asynchronous and synchronous kernel launch implementations into a single synchronous version.
This patch prepares the plugin for asynchronous implementation by:
- Privatizing actual kernel launch code (valid in both cases) into an anonymous namespace base function

Actual separation of kernel launch code (async vs sync) is a following patch.

Reviewed By: JonChesterfield

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

2 years ago[InstCombine] try to fold rem with constant dividend and select-of-constants divisor
Sanjay Patel [Tue, 7 Dec 2021 20:48:45 +0000 (15:48 -0500)]
[InstCombine] try to fold rem with constant dividend and select-of-constants divisor

We avoid this fold in the more general cases where we use `FoldOpIntoSelect`.
That's because -- unlike most binary opcodes -- 'rem' can't usually be
speculated with a variable divisor since it can have immediate UB. But in
the case where both arms of the select are constants, we can safely evaluate
both sides and eliminate 'rem' completely.

This should fix:
https://llvm.org/PR52102

The same optimization for 'div' is planned as a follow-up patch.

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

2 years ago[InstCombine] add tests for div/rem with 0 select arm; NFC
Sanjay Patel [Tue, 7 Dec 2021 20:28:42 +0000 (15:28 -0500)]
[InstCombine] add tests for div/rem with 0 select arm; NFC

More coverage for D115173 and its div sibling. These are
existing transforms handled by simplifyDivRemOfSelectWithZeroOp().

2 years ago[InstCombine] add tests for div with select-of-constants divisor; NFC
Sanjay Patel [Tue, 7 Dec 2021 16:28:23 +0000 (11:28 -0500)]
[InstCombine] add tests for div with select-of-constants divisor; NFC

Similar patterns as tests for:
D115173
(and we might want to make a single patch for all of these).

2 years ago[OpenMP] Disable libomptarget profiling by default if built via the "runtimes" setup
Martin Storsjö [Wed, 17 Nov 2021 13:06:15 +0000 (15:06 +0200)]
[OpenMP] Disable libomptarget profiling by default if built via the "runtimes" setup

In the "runtimes" setup, the runtime (e.g. OpenMP) can be built for
a target entirely different from the current host build (where LLVM
and Clang are built). If profiling is enabled, libomptarget links
against LLVMSupport (which only has been built for the host).

Thus, don't enable profiling by default in this setup.

This should allow relanding D113253.

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

2 years ago[flang][runtime] Add ragged array runtime functions
Valentin Clement [Tue, 7 Dec 2021 20:19:34 +0000 (21:19 +0100)]
[flang][runtime] Add ragged array runtime functions

This patch adds the runtime function to allocate and
deallocate ragged arrays.

This patch is part of the upstreaming effort from fir-dev branch.

Reviewed By: klausler

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

Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
2 years agoFix buildbots after https://reviews.llvm.org/D115073.
Greg Clayton [Tue, 7 Dec 2021 20:19:00 +0000 (12:19 -0800)]
Fix buildbots after https://reviews.llvm.org/D115073.

2 years agoFix buildbot after https://reviews.llvm.org/D115073.
Greg Clayton [Tue, 7 Dec 2021 20:03:45 +0000 (12:03 -0800)]
Fix buildbot after https://reviews.llvm.org/D115073.

2 years ago[Analysis] Ignore casts and unary ops for uninitialized values
Bill Wendling [Tue, 7 Dec 2021 07:14:19 +0000 (23:14 -0800)]
[Analysis] Ignore casts and unary ops for uninitialized values

A series of unary operators and casts may obscure the variable we're
trying to analyze. Ignore them for the uninitialized value analysis.
Other checks determine if the unary operators result in a valid l-value.

Link: https://github.com/ClangBuiltLinux/linux/issues/1521
Reviewed By: nickdesaulniers

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

2 years ago[ASan] Replaced constants for SHADOW_OFFSET with defines.
Kirill Stoimenov [Tue, 7 Dec 2021 02:47:11 +0000 (02:47 +0000)]
[ASan] Replaced constants for SHADOW_OFFSET with defines.

Reviewed By: vitalybuka

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

2 years ago[VP] Cost model for VPMemory operations on PowerPC.
Bardia Mahjour [Mon, 6 Dec 2021 16:33:42 +0000 (11:33 -0500)]
[VP] Cost model for VPMemory operations on PowerPC.

PPC Implementation of getVPMemoryOpCost and hasActiveVectorLength.

Reviewed By: Roland Froese

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

2 years ago[sanitizer] Lock/Unlock stack store on fork
Vitaly Buka [Tue, 7 Dec 2021 01:58:52 +0000 (17:58 -0800)]
[sanitizer] Lock/Unlock stack store on fork

Reviewed By: dvyukov

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

2 years ago[mlir][sparse] fix broken build
Aart Bik [Tue, 7 Dec 2021 19:05:45 +0000 (11:05 -0800)]
[mlir][sparse] fix broken build

rebase and commit crossed the getFunc change

Reviewed By: Chia-hungDuan

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

2 years ago[libc++] [test] Rationalize the nodiscard tests for range adaptors.
Arthur O'Dwyer [Mon, 6 Dec 2021 22:16:34 +0000 (17:16 -0500)]
[libc++] [test] Rationalize the nodiscard tests for range adaptors.

Reviewed as part of D115177.

2 years ago[libc++] [ranges] SFINAE-friendly "write it three times" in views::counted.
Arthur O'Dwyer [Mon, 6 Dec 2021 20:39:08 +0000 (15:39 -0500)]
[libc++] [ranges] SFINAE-friendly "write it three times" in views::counted.

Before this patch, the new test's `CountedInvocable<int*, int*>`
would hard-error instead of SFINAEing and cleanly returning false.

Notice that views::counted specifically does NOT work with pipes;
`counted(42)` is ill-formed. This is because `counted`'s first argument
is supposed to be an iterator, not a range.

Also, mark `views::counted(it, n)` as [[nodiscard]], and test that.
(We have a general policy now that range adaptors are consistently
marked [[nodiscard]], so that people don't accidentally think that
they have side effects. This matters mostly for `reverse` and
`transform`, arguably `drop`, and just generally let's be consistent.)

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

2 years ago[libc++] Remove unneeded `std::` qualifications from <compare>. NFCI.
Arthur O'Dwyer [Mon, 6 Dec 2021 18:28:33 +0000 (13:28 -0500)]
[libc++] Remove unneeded `std::` qualifications from <compare>. NFCI.

Reviewed as part of D115177.

2 years ago[libc++] std::move should be _VSTD::move in one place. NFCI.
Arthur O'Dwyer [Mon, 6 Dec 2021 18:25:27 +0000 (13:25 -0500)]
[libc++] std::move should be _VSTD::move in one place. NFCI.

Reviewed as part of D115177.

2 years ago[mlir][sparse] finalize sparse output in the presence of reductions
Aart Bik [Sat, 4 Dec 2021 00:55:43 +0000 (16:55 -0800)]
[mlir][sparse] finalize sparse output in the presence of reductions

This revision implements sparse outputs (from scratch) in all cases where
the loops can be reordered with all but one parallel loops outer. If the
inner parallel loop appears inside one or more reductions loops, then an
access pattern expansion is required (aka. workspaces in TACO speak).

Reviewed By: bixia

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

2 years agoFormat lsan.h
Clemens Wasser [Tue, 7 Dec 2021 18:44:24 +0000 (10:44 -0800)]
Format lsan.h

Reviewed By: vitalybuka

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

2 years ago[libc] apply new lint rules
Michael Jones [Fri, 19 Nov 2021 21:56:16 +0000 (13:56 -0800)]
[libc] apply new lint rules

This patch applies the lint rules described in the previous patch. There
was also a significant amount of effort put into manually fixing things,
since all of the templated functions, or structs defined in /spec, were
not updated and had to be handled manually.

Reviewed By: sivachandra, lntue

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

2 years ago[libc] update tidy rules to fix variable formatting
Michael Jones [Fri, 19 Nov 2021 21:54:35 +0000 (13:54 -0800)]
[libc] update tidy rules to fix variable formatting

This commit changes the clang-tidy rules for LLVM-libc to follow the new
format. The next commit applies these rules to the codebase.

The rules are as follows:

CamelCase for classes
lower_case for variables
lower_case for functions
UPPER_CASE for constexpr variables

There are also some exceptions, but the most important one is that any
function or variable that starts with an underscore is exempt from the
formatting.

Reviewed By: sivachandra, lntue

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

2 years ago[NFC][CodeView] Use one unified access to the module in beginModule.
Chih-Ping Chen [Tue, 7 Dec 2021 16:26:28 +0000 (11:26 -0500)]
[NFC][CodeView] Use one unified access to the module in beginModule.

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

2 years ago[LLDB][NativePDB] Fix function decl creation for class methods
Zequan Wu [Mon, 15 Nov 2021 20:23:04 +0000 (12:23 -0800)]
[LLDB][NativePDB] Fix function decl creation for class methods

This is a split of D113724. Calling `TypeSystemClang::AddMethodToCXXRecordType`
to create function decls for class methods.

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

2 years agoChange __lsan::kMaxAllowedMallocSize literal types to unsigned long long
Clemens Wasser [Tue, 7 Dec 2021 18:27:59 +0000 (10:27 -0800)]
Change __lsan::kMaxAllowedMallocSize literal types to unsigned long long

It is required for the [Leak Sanitizer port to Windows](https://reviews.llvm.org/D115103).
The currently used `unsigned long` type is 64 bits wide on UNIX like systems but only 32 bits wide on Windows.
Because of that, the literal `8UL << 30` causes an integer overflow on Windows.
By changing the type of the literals to `unsigned long long`, we have consistent behavior and no overflows on all Platforms.

Reviewed By: vitalybuka

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

2 years agoRemove unused variable. NFC.
Simon Pilgrim [Tue, 7 Dec 2021 18:36:50 +0000 (18:36 +0000)]
Remove unused variable. NFC.

2 years ago[mlir][tosa] Disable tosa.depthwise_conv2d canonicalizer for quantized case
Rob Suderman [Tue, 7 Dec 2021 18:03:31 +0000 (10:03 -0800)]
[mlir][tosa] Disable tosa.depthwise_conv2d canonicalizer for quantized case

Quantized case needs to include zero-point corrections before the tosa.mul.
Disabled for the quantized use-case.

Reviewed By: NatashaKnk

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

2 years ago[SystemZ] Add range checks for PC-relative fixups.
Jonas Paulsson [Thu, 18 Nov 2021 21:40:12 +0000 (22:40 +0100)]
[SystemZ] Add range checks for PC-relative fixups.

The AsmParser checks the range of a PC-relative operand, but only if it is
immediate.

This patch adds range checks for operands in applyFixup(), at which point the
offset to a label is known.

The diagnostic message for an operand that is out of range is explicit (with
given value and min/max limits). This is now also done for displacement
fixups.

Review: Ulrich Weigand

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

2 years agoFix MSVC "not all control paths return a value" warning. NFC.
Simon Pilgrim [Tue, 7 Dec 2021 18:09:18 +0000 (18:09 +0000)]
Fix MSVC "not all control paths return a value" warning. NFC.

2 years ago[DAG] Update expandFunnelShift/expandROT to return the expansion directly. NFCI.
Simon Pilgrim [Tue, 7 Dec 2021 17:57:32 +0000 (17:57 +0000)]
[DAG] Update expandFunnelShift/expandROT to return the expansion directly. NFCI.

Don't return a bool to indicate if the expansion was successful, just return the SDValue result directly, like we do for most other basic expansions.

2 years ago[NFC] Clarify comment about LoopDeletionPass in the optimization pipeline
Arthur Eubanks [Mon, 6 Dec 2021 21:04:57 +0000 (13:04 -0800)]
[NFC] Clarify comment about LoopDeletionPass in the optimization pipeline

Reviewed By: lebedev.ri

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

2 years ago[ASan] Refactored SHADOW_OFFSET implementation to use SHADOW_OFFSET_CONST.
Kirill Stoimenov [Tue, 7 Dec 2021 02:47:11 +0000 (02:47 +0000)]
[ASan] Refactored SHADOW_OFFSET implementation to use SHADOW_OFFSET_CONST.

Reviewed By: vitalybuka

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

2 years agoModify DataEncoder to be able to encode data in an object owned buffer.
Greg Clayton [Tue, 7 Dec 2021 17:44:22 +0000 (09:44 -0800)]
Modify DataEncoder to be able to encode data in an object owned buffer.

DataEncoder was previously made to modify data within an existing buffer. As the code progressed, new clients started using DataEncoder to create binary data. In these cases the use of this class was possibly, but only if you knew exactly how large your buffer would be ahead of time. This patchs adds the ability for DataEncoder to own a buffer that can be dynamically resized as data is appended to the buffer.

Change in this patch:
- Allow a DataEncoder object to be created that owns a DataBufferHeap object that can dynamically grow as data is appended
- Add new methods that start with "Append" to append data to the buffer and grow it as needed
- Adds full testing of the API to assure modifications don't regress any functionality
- Has two constructors: one that uses caller owned data and one that creates an object with object owned data
- "Append" methods only work if the object owns it own data
- Removes the ability to specify a shared memory buffer as no one was using this functionality. This allows us to switch to a case where the object owns its own data in a DataBufferHeap that can be resized as data is added

"Put" methods work on both caller and object owned data.
"Append" methods work on only object owned data where we can grow the buffer. These methods will return false if called on a DataEncoder object that has caller owned data.

The main reason for these modifications is to be able to use the DateEncoder objects instead of llvm::gsym::FileWriter in https://reviews.llvm.org/D113789. This patch wants to add the ability to create symbol table caching to LLDB and the code needs to build binary caches and save them to disk.

Reviewed By: labath

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

2 years ago[flang] Remove runtime check from OpenFile::Close()
Peter Klausler [Mon, 6 Dec 2021 15:42:13 +0000 (07:42 -0800)]
[flang] Remove runtime check from OpenFile::Close()

In error cases it is possible to CLOSE a unit that has not
been successfully connected, so don't crash when the file descriptor
is negative.

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

2 years ago[flang] Avoid potential deadlock in CloseAll()
Peter Klausler [Sat, 4 Dec 2021 19:30:01 +0000 (11:30 -0800)]
[flang] Avoid potential deadlock in CloseAll()

When closing all open units, don't hold the unit map lock
over the actual close operations; if one of those aborts,
CloseAll() may be called and then deadlock.

Differential Review: https://reviews.llvm.org/D115184

2 years ago[RISCV] Revise RISCVInstPrinter::printVTypeI to not assume there are 3 invalid vtype...
Craig Topper [Tue, 7 Dec 2021 15:12:04 +0000 (07:12 -0800)]
[RISCV] Revise RISCVInstPrinter::printVTypeI to not assume there are 3 invalid vtype bits.

Instead of checking [10:8]. Check for non-zero in 8 and above.

Addresses a post-commit comment from @jrtc27 in D114581.

2 years ago[clangd] Print type for VarTemplateDecl in hover.
lh123 [Tue, 7 Dec 2021 17:16:38 +0000 (01:16 +0800)]
[clangd] Print type for VarTemplateDecl in hover.

Print type for VarTemplateDecl in hover.

Reviewed By: sammccall

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

2 years ago[llvm] Use range-based for loops (NFC)
Kazu Hirata [Tue, 7 Dec 2021 17:17:03 +0000 (09:17 -0800)]
[llvm] Use range-based for loops (NFC)

2 years agoDo not check if we are in a discared context in non-immediate contexts
Corentin Jabot [Tue, 7 Dec 2021 17:13:35 +0000 (12:13 -0500)]
Do not check if we are in a discared context in non-immediate contexts

This fixes in a regression introduced by 6eeda06c1.

When deducing the return type of nested function calls, only the
return type of the outermost expression should be ignored.

Instead of assuming all contextes nested in a discared statements
are themselves discarded, only assume that in immediate contexts.

Similarly, only consider contextes immediately in an immediate or
discarded statement as being themselves immediate.

2 years ago[gn build] Port fa99cb64ff0e
LLVM GN Syncbot [Tue, 7 Dec 2021 17:01:16 +0000 (17:01 +0000)]
[gn build] Port fa99cb64ff0e

2 years ago[mlgo][regalloc] Add score calculation for training
Mircea Trofin [Mon, 6 Dec 2021 22:59:19 +0000 (14:59 -0800)]
[mlgo][regalloc] Add score calculation for training

Add the calculation of a score, which will be used during ML training. The
score qualifies the quality of a regalloc policy, and is independent of
what we train (currently, just eviction), or the regalloc algo itself.
We can then use scores to guide training (which happens offline), by
formulating a reward based on score variation - the goal being lowering
scores (currently, that reward is percentage reduction relative to
Greedy's heuristic)

Currently, we compute the score by factoring different instruction
counts (loads, stores, etc) with the machine basic block frequency,
regardless of the instructions' provenance - i.e. they could be due to
the regalloc policy or be introduced previously. This is different from
RAGreedy::reportStats, which accummulates the effects of the allocator
alone. We explored this alternative but found (at least currently) that
the more naive alternative introduced here produces better policies. We
do intend to consolidate the two, however, as we are actively
investigating improvements to our reward function, and will likely want
to re-explore scoring just the effects of the allocator.

In either case, we want to decouple score calculation from allocation
algorighm, as we currently evaluate it after a few more passes after
allocation (also, because score calculation should be reusable
regardless of allocation algorithm).

We intentionally accummulate counts independently because it facilitates
per-block reporting, which we found useful for debugging - for instance,
we can easily report the counts indepdently, and then cross-reference
with perf counter measurements.

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

2 years agoAdd diagnostic groups for attribute extensions
Aaron Ballman [Tue, 7 Dec 2021 16:48:07 +0000 (11:48 -0500)]
Add diagnostic groups for attribute extensions

Some users have a need to control attribute extension diagnostics
independent of other extension diagnostics. Consider something like use
of [[nodiscard]] within C++11:
```
[[nodiscard]]
int f();
```
If compiled with -Wc++17-extensions enabled, this will produce warning:
use of the 'nodiscard' attribute is a C++17 extension. This diagnostic
is correct -- using [[nodiscard]] in C++11 mode is a C++17 extension.
And the behavior of __has_cpp_attribute(nodiscard) is also correct --
we support [[nodiscard]] in C++11 mode as a conforming extension. But
this makes use of -Werror or -pedantic-errors` builds more onerous.

This patch adds diagnostic groups for attribute extensions so that
users can selectively disable attribute extension diagnostics. I
believe this is preferable to requiring users to specify additional
flags because it means -Wc++17-extensions continues to be the way we
enable all C++17-related extension diagnostics. It would be quite easy
for someone to use that flag thinking they're protected from some
portability issues without realizing it skipped attribute extensions if
we went the other way.

This addresses PR33518.

2 years agofixing a broken ext-tsp test
spupyrev [Tue, 7 Dec 2021 16:22:29 +0000 (08:22 -0800)]
fixing a broken ext-tsp test

the test requires debug build

example of a failed buildbot:
https://lab.llvm.org/buildbot/#/builders/91/builds/211/steps/8/logs/stdio

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

2 years ago[VPlan] Verify plan entry and exit blocks, set correct exit block.
Florian Hahn [Tue, 7 Dec 2021 16:26:31 +0000 (16:26 +0000)]
[VPlan] Verify plan entry and exit blocks, set correct exit block.

Both the entry and exit blocks of the top-region of a plan must be
VPBasicBlocks. They also must have no predecessors or successors
respectively.

This invariant was broken when splitting a block for sink-after. To fix
the issue, set the exit block of the region *after* sink-after is done.

Reviewed By: Ayal

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

2 years ago[AMDGPU] Mark time intrinsics as nomem, hassideeffects
Jay Foad [Tue, 7 Dec 2021 09:35:59 +0000 (09:35 +0000)]
[AMDGPU] Mark time intrinsics as nomem, hassideeffects

Adding IntrHasSideEffects to @llvm.amdgcn.s.memtime and
@llvm.amdgcn.s.memrealtime means that we can stop pretending they read
and write memory, and similarly for the corresponding pseudo
instructions.

This should stop these intrinsics from being rescheduled past all other
instructions, even ones which don't load or store.

See also https://reviews.llvm.org/D58635.

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

2 years ago[flang] Fix INQUIRE(FILE=,NAME=)
Peter Klausler [Mon, 6 Dec 2021 21:26:56 +0000 (13:26 -0800)]
[flang] Fix INQUIRE(FILE=,NAME=)

The file name output was not being copied back to the program
from the runtime.

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

2 years ago[InstSimplify] add logic fold for 'or' with 'xor'+'and'
Sanjay Patel [Tue, 7 Dec 2021 15:43:45 +0000 (10:43 -0500)]
[InstSimplify] add logic fold for 'or' with 'xor'+'and'

This replaces the 'or' from 4b30076f16fc with an 'and'.
We have to guard against propagating undef elements from
vector 'not' values:
https://alive2.llvm.org/ce/z/irMwRc

2 years ago[InstCombine] add tests for rem with select operand; NFC
Sanjay Patel [Mon, 6 Dec 2021 18:16:08 +0000 (13:16 -0500)]
[InstCombine] add tests for rem with select operand; NFC

2 years ago[RISCV] Replace uses of RISCVOpcode<0b0010011> and RISCVOpcode<0b0011011> with existi...
Craig Topper [Tue, 7 Dec 2021 15:12:04 +0000 (07:12 -0800)]
[RISCV] Replace uses of RISCVOpcode<0b0010011> and RISCVOpcode<0b0011011> with existing named objects. NFC

These are already instantiated with names as OPC_OP_IMM and
OPC_OP_IMM_32.

Reviewed By: frasercrmck

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

2 years ago[mlir][scf] NFC: create dedicated files for affine utils
Lei Zhang [Tue, 7 Dec 2021 15:52:09 +0000 (10:52 -0500)]
[mlir][scf] NFC: create dedicated files for affine utils

These functions are generic utility functions that operates on
affine ops within SCF regions. Moving them to their own files
for a better code structure, instead of mixing with loop
specialization logic.

Reviewed By: nicolasvasilache

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

2 years ago[gn build] Port f573f6866e18
LLVM GN Syncbot [Tue, 7 Dec 2021 15:31:37 +0000 (15:31 +0000)]
[gn build] Port f573f6866e18

2 years agoext-tsp basic block layout
spupyrev [Mon, 8 Nov 2021 15:02:33 +0000 (07:02 -0800)]
ext-tsp basic block layout

A new basic block ordering improving existing MachineBlockPlacement.

The algorithm tries to find a layout of nodes (basic blocks) of a given CFG
optimizing jump locality and thus processor I-cache utilization. This is
achieved via increasing the number of fall-through jumps and co-locating
frequently executed nodes together. The name follows the underlying
optimization problem, Extended-TSP, which is a generalization of classical
(maximum) Traveling Salesmen Problem.

The algorithm is a greedy heuristic that works with chains (ordered lists)
of basic blocks. Initially all chains are isolated basic blocks. On every
iteration, we pick a pair of chains whose merging yields the biggest increase
in the ExtTSP value, which models how i-cache "friendly" a specific chain is.
A pair of chains giving the maximum gain is merged into a new chain. The
procedure stops when there is only one chain left, or when merging does not
increase ExtTSP. In the latter case, the remaining chains are sorted by
density in decreasing order.

An important aspect is the way two chains are merged. Unlike earlier
algorithms (e.g., based on the approach of Pettis-Hansen), two
chains, X and Y, are first split into three, X1, X2, and Y. Then we
consider all possible ways of gluing the three chains (e.g., X1YX2, X1X2Y,
X2X1Y, X2YX1, YX1X2, YX2X1) and choose the one producing the largest score.
This improves the quality of the final result (the search space is larger)
while keeping the implementation sufficiently fast.

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

2 years ago[clangd] Dex Trigrams: Improve query trigram generation
Kirill Bobyrev [Tue, 7 Dec 2021 14:46:12 +0000 (15:46 +0100)]
[clangd] Dex Trigrams: Improve query trigram generation

These are the trigrams for queries right now:

- "va" -> {Trigram("va")}
- "va_" -> {} (empty)

This is suboptimal since the resulting query will discard the query information
and return all symbols, some of which will be later be scored expensively
(fuzzy matching score). This is related to
https://github.com/clangd/clangd/issues/39 but does not fix it. Accidentally,
because of that incorrect behavior, when user types "tok::va" there are no
results (the issue is that `tok::kw___builtin_va_arg` does not have "va" token)
but when "tok::va_" is typed, expected result (`tok::kw___builtin_va_arg`)
shows up by accident. This is because the dex query transformer will only
lookup symbols within the `tok::` namespace. There won't be many, so the
returned results will contain symbol we need; this symbol will be filtered out
by the expensive checks and that will be displayed in the editor.

Reviewed By: sammccall

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

2 years ago[llvm-symbolizer][docs] Update --output-style=JSON example
gbreynoo [Tue, 7 Dec 2021 14:18:42 +0000 (14:18 +0000)]
[llvm-symbolizer][docs] Update --output-style=JSON example

The fields output when using --output-style=JSON has changed but the
guide wasn't updated. This change fixes up the example.

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

2 years ago[ARM] Additional tests for qr instructions with constant operands. NFC
David Green [Tue, 7 Dec 2021 14:18:32 +0000 (14:18 +0000)]
[ARM] Additional tests for qr instructions with constant operands. NFC

2 years ago[EarlyCSE] Add test case with inbounds gep where flags can be retained.
Florian Hahn [Tue, 7 Dec 2021 13:46:24 +0000 (13:46 +0000)]
[EarlyCSE] Add test case with inbounds gep where flags can be retained.

2 years ago[EarlyCSE] Auto-generate check lines for flags.ll.
Florian Hahn [Tue, 7 Dec 2021 13:46:13 +0000 (13:46 +0000)]
[EarlyCSE] Auto-generate check lines for flags.ll.

The test already checks the full IR. To make updating easier,
auto-generate the check lines.

2 years ago[doc] Fix namespace comment style in Coding Guidelines
Carlos Galvez [Tue, 7 Dec 2021 13:35:38 +0000 (13:35 +0000)]
[doc] Fix namespace comment style in Coding Guidelines

The Coding Guidelines specify that the ending brace of a
namespace shall have a comment like:

}  // end namespace clang

However the majority of the code uses a different style:

}  // namespace clang

Indeed:

$ git grep '// end' | wc -l
6724
$ git grep '// namespace' | wc -l
14348

Besides, this is the style enforced automatically by clang-format,
via the FixNamespaceComments option.

Having inconsistencies between the Coding Guidelines and the
code/tooling creates confusion, can lead to bikeshedding during
reviews and overall delays merging code. Therefore, update the
guidelines to reflect current usage. Updating legacy code to the
new standard should be done in a separate patch, if wanted.

Reviewed By: jyknight

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

2 years ago[lldb] Fix flakyness in TestQemuLaunch.test_stdio_redirect
Pavel Labath [Tue, 7 Dec 2021 13:10:43 +0000 (14:10 +0100)]
[lldb] Fix flakyness in TestQemuLaunch.test_stdio_redirect

The test was flaky because it was trying to read from the (redirected)
stdout file before the data was been flushed to it. This would not be a
problem for a "normal" debug session, but since here the emulator and
the target binary coexist in the same process (and this is true both for
real qemu and our fake implementation), there
is a window of time between the stub returning an exit packet (which is
the event that the test is waiting for) and the process really exiting
(which is when the normal flushing happens).

This patch adds an explicit flush to work around this. Theoretically,
it's possible that real code could run into this issue as well, but such
a use case is not very likely. If we wanted to fix this for real, we
could add some code which waits for the host process to terminate (in
addition to receiving the termination packet), but this is somewhat
complicated by the fact that this code lives in the gdb-remote process
plugin.

2 years ago[lldb/qemu] Add emulator-args setting
Pavel Labath [Fri, 26 Nov 2021 14:51:09 +0000 (15:51 +0100)]
[lldb/qemu] Add emulator-args setting

This setting allows the user to pass additional arguments to the qemu instance.
While we may want to introduce dedicated settings for the most common qemu
arguments (-cpu, for one), having this setting allows us to avoid creating a
setting for every possible argument.

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

2 years ago[mlir][Linalg] NFC - Extend the TilingInterface to allow better composition with...
Nicolas Vasilache [Tue, 7 Dec 2021 13:03:24 +0000 (13:03 +0000)]
[mlir][Linalg] NFC - Extend the TilingInterface to allow better composition with out-of-tree dialects.

Reviewed By: gysit

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

2 years ago[MIPS] Add FPU Delay Slot for MIPS1/2/3
Djordje Todorovic [Tue, 7 Dec 2021 12:48:22 +0000 (04:48 -0800)]
[MIPS] Add FPU Delay Slot for MIPS1/2/3

MIPS I, II, and III have delay slots for floating point
comparisons and floating point register transfers (mtc1, mfc1).
Currently, these are not taken into account and thus broken code
may be generated on these targets. This patch inserts nops
as necessary, while attempting to leave the current instruction
if it is safe to stay.

The tests in this patch were updated by @sajattack

Patch by @overdrivenpotato (Marko Mijalkovic <marko.mijalkovic97@gmail.com>)

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

2 years agoFix Sphinx formatting in release notes
Aaron Ballman [Tue, 7 Dec 2021 12:56:40 +0000 (07:56 -0500)]
Fix Sphinx formatting in release notes

2 years ago[mlir][linalg][bufferize] Add FuncOp bufferization pass
Matthias Springer [Tue, 7 Dec 2021 11:07:13 +0000 (20:07 +0900)]
[mlir][linalg][bufferize] Add FuncOp bufferization pass

This passes bufferizes FuncOp bodies, but not FuncOp boundaries.

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

2 years ago[libc++] Bump Dockerfile
Louis Dionne [Tue, 7 Dec 2021 12:30:46 +0000 (07:30 -0500)]
[libc++] Bump Dockerfile

2 years ago[libc++] Fix atomic test for _BitInt
Louis Dionne [Mon, 6 Dec 2021 23:09:47 +0000 (18:09 -0500)]
[libc++] Fix atomic test for _BitInt

In 6c75ab5f66b4, Clang deprecated _ExtInt in favor of _BitInt, which
made this test fail. This patch disables the test on older compilers
and uses the new _BitInt type instead.

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

2 years ago[MCA] Remove the warning about experimental support for in-order CPU
Andrew Savonichev [Mon, 29 Nov 2021 12:59:45 +0000 (15:59 +0300)]
[MCA] Remove the warning about experimental support for in-order CPU

There are not a lot of bug reports for this feature, so let's mark it
stable.

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

2 years ago[NVPTX] Auto-generate tests for sufrace and texture instructions
Andrew Savonichev [Mon, 15 Nov 2021 10:30:24 +0000 (13:30 +0300)]
[NVPTX] Auto-generate tests for sufrace and texture instructions

The patch adds LIT tests for SULD, SUST, TEX and TLD4 instructions as
a follow up for D112232. There are a number of FIXME marks that
highlight possible bugs or missed instruction variants.

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

2 years ago[WebAssembly] Implement table instruction intrinsics
Paulo Matos [Mon, 6 Dec 2021 08:51:39 +0000 (09:51 +0100)]
[WebAssembly] Implement table instruction intrinsics

This change implements intrinsics for table.grow, table.fill,
table.size, and table.copy.

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

2 years ago[AArch64][SVE] Fix fptrunc store for fixed len vector
Peter Waller [Mon, 6 Dec 2021 17:12:55 +0000 (17:12 +0000)]
[AArch64][SVE] Fix fptrunc store for fixed len vector

Restrict duplicate FP_EXTEND/FP_TRUNC -> LOAD/STORE DAG combines to only
larger than NEON types, as these are the ones for which there is custom
lowering.

Update tests so that they go through memory to improve validation.

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

2 years ago[X86] LowerRotate - pull out repeated splitVectorIntBinary call. NFC.
Simon Pilgrim [Tue, 7 Dec 2021 12:05:23 +0000 (12:05 +0000)]
[X86] LowerRotate - pull out repeated splitVectorIntBinary call. NFC.

2 years ago[compiler-rt][libFuzzer] Disable counters test on arm
David Spickett [Tue, 7 Dec 2021 11:55:11 +0000 (11:55 +0000)]
[compiler-rt][libFuzzer] Disable counters test on arm

This test is either very slow or loops forever on 32 bit Arm.

One of a few tests causing timeouts on our buildbots:
https://lab.llvm.org/buildbot/#/builders/190/builds/513

2 years ago[mlir][linalg][bufferize] Fix forward declaration
Matthias Springer [Tue, 7 Dec 2021 11:13:24 +0000 (20:13 +0900)]
[mlir][linalg][bufferize] Fix forward declaration

2 years ago[SelectionDAG] Use UnknownSize for VP memory ops
Fraser Cormack [Fri, 3 Dec 2021 11:52:33 +0000 (11:52 +0000)]
[SelectionDAG] Use UnknownSize for VP memory ops

In the style of D113888, this patch updates the various VP memory
operations (load, store, gather, scatter) to use UnknownSize. This is
for the same reason as for masked loads and stores: the number of
elements accessed is not generally known at compile time.

This is somewhat pessimistic in the sense that we may still find
un-canonicalized intrinsics featuring both an all-true mask and an EVL
equal to the vector size. Arguably those should be canonicalized before
the SelectionDAG, so those have been left for future work.

Reviewed By: craig.topper

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

2 years ago[mlir][linalg][bufferize] Bufferize Operation* instead of FuncOp
Matthias Springer [Tue, 7 Dec 2021 08:53:45 +0000 (17:53 +0900)]
[mlir][linalg][bufferize] Bufferize Operation* instead of FuncOp

This change mainly changes the API. There is no mentioning of FuncOps in ComprehensiveBufferize anymore.

Also, bufferize methods of the op interface are called for ops without tensor operands/results if they have a region.

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

2 years ago[X86] Add test where block placement separates call from RV marker.
Florian Hahn [Tue, 7 Dec 2021 10:52:54 +0000 (10:52 +0000)]
[X86] Add test where block placement separates call from RV marker.

The test shows how block placement can separate a call from the marker
instruction and the ObjC call after CALL_RVMARKER expansion.

2 years ago[IR] Split vscale_range interface
Cullen Rhodes [Tue, 7 Dec 2021 09:53:16 +0000 (09:53 +0000)]
[IR] Split vscale_range interface

Interface is split from:

  std::pair<unsigned, unsigned> getVScaleRangeArgs()

into separate functions for min/max:

  unsigned getVScaleRangeMin();
  Optional<unsigned> getVScaleRangeMax();

Reviewed By: sdesmalen, paulwalker-arm

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

2 years ago[VP] Propagate align parameter attr on VP load/store to ISel
Fraser Cormack [Fri, 19 Nov 2021 20:21:47 +0000 (20:21 +0000)]
[VP] Propagate align parameter attr on VP load/store to ISel

This patch fixes a case where the 'align' parameter attribute on the
pointer operands to llvm.vp.load and llvm.vp.store was being dropped
during the conversion to the SelectionDAG. The default alignment
equal to the ABI type alignment of the vector type was kept. It also
updates the documentation to reflect the fact that the parameter
attribute is now properly supported.

Reviewed By: simoll

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

2 years ago[lldb] Fix windows path guessing for root paths
Jaroslav Sevcik [Sat, 4 Dec 2021 20:32:09 +0000 (21:32 +0100)]
[lldb] Fix windows path guessing for root paths

Fix recognizing "<letter>:\" as a windows path.

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

2 years ago[ARM] Implement PAC return address signing mechanism for PACBTI-M
Ties Stuij [Tue, 7 Dec 2021 10:13:17 +0000 (10:13 +0000)]
[ARM] Implement PAC return address signing mechanism for PACBTI-M

This patch implements PAC return address signing for armv8-m. This patch roughly
accomplishes the following things:

- PAC and AUT instructions are generated.
- They're part of the stack frame setup, so that shrink-wrapping can move them
inwards to cover only part of a function
- The auth code generated by PAC is saved across subroutine calls so that AUT
can find it again to check
- PAC is emitted before stacking registers (so that the SP it signs is the one
on function entry).
- The new pseudo-register ra_auth_code is mentioned in the DWARF frame data
- With CMSE also in use: PAC is emitted before stacking FPCXTNS, and AUT
validates the corresponding value of SP
- Emit correct unwind information when PAC is replaced by PACBTI
- Handle tail calls correctly

Some notes:

We make the assembler accept the `.save {ra_auth_code}` directive that is
emitted by the compiler when it saves a register that contains a
return address authentication code.

For EHABI we need to have the `FrameSetup` flag on the instruction and
handle the `t2PACBTI` opcode (identically to `t2PAC`), so we can emit
`.save {ra_auth_code}`, instead of `.save {r12}`.

For PACBTI-M, the instruction which computes return address PAC should use SP
value before adjustment for the argument registers save are (used for variadic
functions and when a parameter is is split between stack and register), but at
the same it should be after the instruction that saves FPCXT when compiling a
CMSE entry function.

This patch moves the varargs SP adjustment after the FPCXT save (they are never
enabled at the same time), so in a following patch handling of the `PAC`
instruction can be placed between them.

Epilogue emission code adjusted in a similar manner.

PACBTI-M code generation should not emit any instructions for architectures
v6-m, v8-m.base, and for A- and R-class cores. Diagnostic message for such cases
is handled separately by a future ticket.

note on tail calls:

If the called function has four arguments that occupy registers `r0`-`r3`, the
only option for holding the function pointer itself is `r12`, but this register
is used to keep the PAC during function/prologue epilogue and clobbers the
function pointer.

When we do the tail call we need the five registers (`r0`-`r3` and `r12`) to
keep six values - the four function arguments, the function pointer and the PAC,
which is obviously impossible.

One option would be to authenticate the return address before all callee-saved
registers are restored, so we have a scratch register to temporarily keep the
value of `r12`. The issue with this approach is that it violates a fundamental
invariant that PAC is computed using CFA as a modifier. It would also mean using
separate instructions to pop `lr` and the rest of the callee-saved registers,
which would offset the advantages of doing a tail call.

Instead, this patch disables indirect tail calls when the called function take
four or more arguments and the return address sign and authentication is enabled
for the caller function, conservatively assuming the caller function would spill
LR.

This patch is part of a series that adds support for the PACBTI-M extension of
the Armv8.1-M architecture, as detailed here:

https://community.arm.com/arm-community-blogs/b/architectures-and-processors-blog/posts/armv8-1-m-pointer-authentication-and-branch-target-identification-extension

The PACBTI-M specification can be found in the Armv8-M Architecture Reference
Manual:

https://developer.arm.com/documentation/ddi0553/latest

The following people contributed to this patch:

- Momchil Velikov
- Ties Stuij

Reviewed By: danielkiss

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

2 years ago[llvm][X86] Add x86 triple to fentry test
David Spickett [Tue, 7 Dec 2021 10:02:44 +0000 (10:02 +0000)]
[llvm][X86] Add x86 triple to fentry test

When run on AArch64 hardware llc would default to native
arch.

2 years ago[AMDGPU] Remove redundant mayLoad = 0, mayStore = 0. NFC.
Jay Foad [Tue, 7 Dec 2021 09:53:40 +0000 (09:53 +0000)]
[AMDGPU] Remove redundant mayLoad = 0, mayStore = 0. NFC.

Almost everything in this file is mayLoad = 0, mayStore = 0 by
default anyway.