platform/upstream/llvm.git
2 years ago[ConstantFold] Simplify type check in reinterpret load folding (NFC)
Nikita Popov [Fri, 21 Jan 2022 08:06:35 +0000 (09:06 +0100)]
[ConstantFold] Simplify type check in reinterpret load folding (NFC)

Keep a list of allowed types, but then always construct the map
type the same way. We need an integer with the same width as the
original type.

2 years ago[mlir][Linalg] Avoid generating illegal operations during elementwise fusion.
MaheshRavishankar [Fri, 21 Jan 2022 06:27:06 +0000 (22:27 -0800)]
[mlir][Linalg] Avoid generating illegal operations during elementwise fusion.

In some cases, fusion can produce illegal operations if after fusion
the range of some of the loops cannot be computed from shapes of its
operands. Check for this case and abort the fusion if this happens.

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

2 years ago[RISCV] Bump rvv-related extensions from 0.10 to 1.0
eopXD [Thu, 20 Jan 2022 10:24:10 +0000 (02:24 -0800)]
[RISCV] Bump rvv-related extensions from 0.10 to 1.0

Reviewed By: craig.topper

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

2 years ago[libc][NFC] Add 'struct_' prefix to type headers defining struct types.
Siva Chandra Reddy [Fri, 21 Jan 2022 06:28:42 +0000 (06:28 +0000)]
[libc][NFC] Add 'struct_' prefix to type headers defining struct types.

This allows header generator to generate type inclusion boiler plate in
a straightforward manner.

2 years ago[DebugInfo][NFC] Do not call 'isRootFile' for DWARF Version < 5
Igor Kudrin [Fri, 21 Jan 2022 06:04:44 +0000 (13:04 +0700)]
[DebugInfo][NFC] Do not call 'isRootFile' for DWARF Version < 5

A quicker comparison should be done first.

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

2 years ago[DebugInfo] Fix handling '# line "file"' for DWARFv5
Igor Kudrin [Fri, 21 Jan 2022 06:04:32 +0000 (13:04 +0700)]
[DebugInfo] Fix handling '# line "file"' for DWARFv5

`CppHashInfo.Filename` is a `StringRef` that references a part of the
source file and it is not null-terminated at the end of the file name.
`AsmParser::parseAndMatchAndEmitTargetInstruction()` passes it to
`getStreamer().emitDwarfFileDirective()`, and it eventually comes to
`isRootFile()`. The comparison fails because `FileName.data()` is not
properly terminated.

In addition, the old code might cause a significant speed degradation
for long source files. The `operator!=()` for `std::string` and
`const char *` can be implemented in a way that it finds the length of
the second argument first, which slows the comparison for long data.
`parseAndMatchAndEmitTargetInstruction()` calls
`emitDwarfFileDirective()` every time if `CppHashInfo.Filename` is not
empty. As a result, the longer the source file is, the slower the
compilation wend, and for a very long file, it might take hours instead
of a couple of seconds normally.

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

2 years ago[RISCV] Set CostPerUse to 1 iff RVC is enabled
wangpc [Fri, 21 Jan 2022 05:54:09 +0000 (13:54 +0800)]
[RISCV] Set CostPerUse to 1 iff RVC is enabled

After D86836, we can define multiple cost values for
different cost models. So here we set CostPerUse to
1 iff RVC is enabled to avoid potential impact on RA.

Reviewed By: craig.topper

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

2 years ago[CSKY] Add codegen support of GlobalTLSAddress lowering
Zi Xuan Wu [Thu, 20 Jan 2022 09:44:53 +0000 (17:44 +0800)]
[CSKY] Add codegen support of GlobalTLSAddress lowering

There are static and dynamic TLS address lowering in DAG stage according to different TLS model.
It needs PseudoTLSLA32 pseudo to get address of TLS-related entry which resides in constant pool.

2 years ago[clang-tidy] Fix wrong FixIt in performance-move-const-arg
Sockke [Fri, 21 Jan 2022 06:23:52 +0000 (14:23 +0800)]
[clang-tidy] Fix wrong FixIt in performance-move-const-arg

There are incorrect Fixit and missing warnings:
case :
A trivially-copyable object wrapped by std::move is passed to the function with rvalue reference parameters. Removing std::move will cause compilation errors.
```
void showInt(int&&) {}
void testInt() {
    int a = 10;
    // expect: warning + nofix
    showInt(std::move(a));  // showInt(a) <--- wrong fix
}

struct Tmp {};
void showTmp(Tmp&&) {}
void testTmp() {
    Tmp t;
    // expect: warning + nofix
    showTmp(std::move(t));  // showTmp(t) <--- wrong fix
}
```

Reviewed By: aaron.ballman, Quuxplusone

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

2 years agoRemove obsolete `getAsmResultNames` from OpAsmDialectInterface
Mehdi Amini [Fri, 21 Jan 2022 05:45:48 +0000 (05:45 +0000)]
Remove obsolete `getAsmResultNames` from OpAsmDialectInterface

This is superseded by the same method on OpAsmOpInterface, which is
available on the Dialect through the Fallback mechanism,

Reviewed By: rriddle

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

2 years ago[mlir][python] 8b/16b DenseIntElements access
Rahul Kayaith [Fri, 21 Jan 2022 05:21:00 +0000 (05:21 +0000)]
[mlir][python] 8b/16b DenseIntElements access

This extends dense attribute element access to support 8b and 16b ints.
Also extends the corresponding parts of the C api.

Reviewed By: ftynse

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

2 years agoPrint the `// ----` separator between modules when using -split-input-file with mlir-opt
Mehdi Amini [Fri, 21 Jan 2022 05:15:46 +0000 (05:15 +0000)]
Print the `// ----` separator between modules when using -split-input-file with mlir-opt

This allows to pipe sequences of `mlir-opt -split-input-file | mlir-opt -split-input-file`.

Depends On D117750

Reviewed By: rriddle

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

2 years ago[RISCV] Add isel patterns for grevi, shfli, and unshfli to brev8/zip/unzip instructions.
Craig Topper [Fri, 21 Jan 2022 04:43:48 +0000 (20:43 -0800)]
[RISCV] Add isel patterns for grevi, shfli, and unshfli to brev8/zip/unzip instructions.

Zbkb supports some encodings of the general grevi, shfli, and
unshfli instructions legal, so we added separate instructions for
those encodings to improve the diagnostics for assembler and
disassembler. To be consistent we should always use these separate
instructions whenever those specific encodings of grevi/shfli/unshfli
occur. So this patch adds specific isel patterns to override the generic
isel patterns for these cases. Similar was done for rev8 and zext.h
for Zbb previously.

2 years ago[RISCV][RFC] add inst support of zbkb
Wu Xinlong [Thu, 20 Jan 2022 08:35:55 +0000 (16:35 +0800)]
[RISCV][RFC] add inst support of zbkb

This commit add instructions supports of `zbkb` which defined in scalar cryptography extension version v1.0.0 (has been ratified already).

Most of the zbkb directives reuse parts of the zbp and zbb directives, so this patch just modified some of the inst aliases and predicates.

Reviewed By: craig.topper

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

2 years ago[X86] Enable ibt-seal optimization when LTO is used in Kernel
Joao Moreira [Fri, 21 Jan 2022 01:31:21 +0000 (09:31 +0800)]
[X86] Enable ibt-seal optimization when LTO is used in Kernel

Intel's CET/IBT requires every indirect branch target to be an ENDBR instruction. Because of that, the compiler needs to correctly emit these instruction on function's prologues. Because this is a security feature, it is desirable that only actual indirect-branch-targeted functions are emitted with ENDBRs. While it is possible to identify address-taken functions through LTO, minimizing these ENDBR instructions remains a hard task for user-space binaries because exported functions may end being reachable through PLT entries, that will use an indirect branch for such. Because this cannot be determined during compilation-time, the compiler currently emits ENDBRs to every non-local-linkage function.

Despite the challenge presented for user-space, the kernel landscape is different as no PLTs are used. With the intent of providing the most fit ENDBR emission for the kernel, kernel developers proposed an optimization named "ibt-seal" which replaces the ENDBRs for NOPs directly in the binary. The discussion of this feature can be seen in [1].

This diff brings the enablement of the flag -mibt-seal, which in combination with LTO enforces a different policy for ENDBR placement in when the code-model is set to "kernel". In this scenario, the compiler will only emit ENDBRs to address taken functions, ignoring non-address taken functions that are don't have local linkage.

A comparison between an LTO-compiled kernel binaries without and with the -mibt-seal feature enabled shows that when -mibt-seal was used, the number of ENDBRs in the vmlinux.o binary patched by objtool decreased from 44383 to 33192, and that the number of superfluous ENDBR instructions nopped-out decreased from 11730 to 540.

The 540 missed superfluous ENDBRs need to be investigated further, but hypotheses are: assembly code not being taken care of by the compiler, kernel exported symbols mechanisms creating bogus address taken situations or even these being removed due to other binary optimizations like kernel's static_calls. For now, I assume that the large drop in the number of ENDBR instructions already justifies the feature being merged.

[1] - https://lkml.org/lkml/2021/11/22/591

Reviewed By: xiangzhangllvm

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

2 years agoRevert "[llvm][cmake] Make `llvm_install_symlink` robust to absolute dirs."
John Ericson [Fri, 21 Jan 2022 02:48:10 +0000 (02:48 +0000)]
Revert "[llvm][cmake] Make `llvm_install_symlink` robust to absolute dirs."

https://lab.llvm.org/buildbot/#/builders/36/builds/16668 was the sort of
thing I saw before when this was part of D99484, and it makes some sense
now this would have something to do with it.

This reverts commit 58580e922a69d94859a2506c3053d8c066a1e38c.

2 years ago[lldb] Update the modulemap
Jonas Devlieghere [Fri, 21 Jan 2022 02:28:17 +0000 (18:28 -0800)]
[lldb] Update the modulemap

2 years ago[gn build] Port 1755f5b1d7b7
LLVM GN Syncbot [Fri, 21 Jan 2022 02:11:31 +0000 (02:11 +0000)]
[gn build] Port 1755f5b1d7b7

2 years ago[llvm][cmake] Make `llvm_install_symlink` robust to absolute dirs.
John Ericson [Thu, 20 Jan 2022 22:20:24 +0000 (22:20 +0000)]
[llvm][cmake] Make `llvm_install_symlink` robust to absolute dirs.

If `CMAKE_INSTALL_BINDIR` is a different absolute path per project, as
it is with NixOS when we install every package to its own prefix, the
old way fails when the absolute path gets prepended.

There are still some issues with dowstream packages using `LLVM_TOOLS_INSTALL_DIR` which also may be absolute and just for LLVM proper, but that will be addressed in a future commit.

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

2 years ago[Libomptarget] Change visibility to hidden for device RTL
Joseph Huber [Thu, 20 Jan 2022 18:06:22 +0000 (13:06 -0500)]
[Libomptarget] Change visibility to hidden for device RTL

This patch changes the visibility for all construct in the new device
RTL to be hidden by default. This is done after the changes introduced
in D117806 changed the visibility from being hidden by default for all
device compilations. This asserts that the visibility for the device
runtime library will be hidden except for the internal environment
variable. This is done to aid optimization and linking of the device
library.

Reviewed By: JonChesterfield

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

2 years ago[OpenMP] Change default visibility to protected for device declarations
Joseph Huber [Thu, 20 Jan 2022 17:06:47 +0000 (12:06 -0500)]
[OpenMP] Change default visibility to protected for device declarations

This patch changes the special-case handling of visibility when
compiling for an OpenMP target offloading device. This was orignally
added as a precaution against the bug encountered in PR41826 when
symbols in the device were being preempted by shared library symbols.
This should instead be done by making the visibility protected by default.
With protected visibility we are asserting that the symbols on the device
will never be preempted or preempt another symbol pending a shared library
load.

Reviewed By: JonChesterfield

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

2 years ago[lldb] Instrument SB API with signposts
Jonas Devlieghere [Thu, 20 Jan 2022 23:50:27 +0000 (15:50 -0800)]
[lldb] Instrument SB API with signposts

Instrument the SB API with signposts on Darwin. This gives us a time
profile on whose behalf LLDB spends time (particularly when run via the
SBAPI from an IDE).

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

2 years ago[lldb] Decouple instrumentation from the reproducers
Jonas Devlieghere [Wed, 19 Jan 2022 19:38:26 +0000 (11:38 -0800)]
[lldb] Decouple instrumentation from the reproducers

Remove the last remaining references to the reproducers from the
instrumentation. This patch renames the relevant files and macros.

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

2 years ago[lldb] Revive lldb-instr
Jonas Devlieghere [Thu, 20 Jan 2022 20:08:20 +0000 (12:08 -0800)]
[lldb] Revive lldb-instr

I revived lldb-instr to update the macros for D117712. I think the new
macros are simple enough that we add them by hand, but this tool can do
it automatically for you.

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

2 years ago[RISCV] Fix the bug in the register allocator caused by reserved BP.
Hsiangkai Wang [Wed, 19 Jan 2022 11:32:27 +0000 (11:32 +0000)]
[RISCV] Fix the bug in the register allocator caused by reserved BP.

Originally, hasRVVFrameObject() will scan all the stack objects to check
whether if there is any scalable vector object on the stack or not.
However, it causes errors in the register allocator. In issue 53016, it
returns false before RA because there is no RVV stack objects. After RA,
it returns true because there are spilling slots for RVV values during RA.
The compiler will not reserve BP during register allocation and generate BP
access in the PEI pass due to the inconsistent behavior of the function.

The function is changed to use hasStdExtV() as the return value. It is
not precise, but it can make the register allocation correct.

Refer to https://github.com/llvm/llvm-project/issues/53016.

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

2 years ago[flang] Extension: skip over NAMELIST groups
Peter Klausler [Thu, 13 Jan 2022 01:34:52 +0000 (17:34 -0800)]
[flang] Extension: skip over NAMELIST groups

Implements a near-universal extension in which NAMELIST
input will skip over unrelated namelist groups in the
input stream until the group with the requested name appears.

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

2 years ago[flang] Allow explicit '+' in NAMELIST input subscripts
Peter Klausler [Wed, 12 Jan 2022 23:10:20 +0000 (15:10 -0800)]
[flang] Allow explicit '+' in NAMELIST input subscripts

Array subscripts and substring limits in NAMELIST input are
allowed to bear an explicit plus sign.

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

2 years ago[RISCV] Factor Zve32 support into RISCVSubtarget::getMaxELENForFixedLengthVectors.
Craig Topper [Thu, 20 Jan 2022 23:24:06 +0000 (15:24 -0800)]
[RISCV] Factor Zve32 support into RISCVSubtarget::getMaxELENForFixedLengthVectors.

This is needed to properly limit fractional LMULs for Zve32.

Add new RUN Zve32 RUN lines to the existing tests for the
-riscv-v-fixed-length-vector-elen-max command line option.

2 years ago[InstCombine] Simplify bswap -> shift
Pawe Bylica [Thu, 20 Jan 2022 23:56:38 +0000 (00:56 +0100)]
[InstCombine] Simplify bswap -> shift

Simplify bswap(x) to shl(x) or lshr(x) if x has exactly one
"active byte", i.e. all active bits are contained in boundaries
of a single byte of x.

https://alive2.llvm.org/ce/z/nvbbU5
https://alive2.llvm.org/ce/z/KiiL3J

Reviewed By: spatel, craig.topper, lebedev.ri

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

2 years ago[Attributor][FIX] AAValueConstantRange should not loop unconstrained
Johannes Doerfert [Thu, 20 Jan 2022 23:52:41 +0000 (17:52 -0600)]
[Attributor][FIX] AAValueConstantRange should not loop unconstrained

The old method to avoid unconstrained expansion of the constant range in
a loop did not work as soon as there were multiple instructions in
between the phi and its input. We now take a generic approach and limit
the number of updates as a fallback. The old method is kept as it
catches "the common case" early.

2 years ago[Attributor][NFC] Clang format
Johannes Doerfert [Fri, 21 Jan 2022 00:04:32 +0000 (18:04 -0600)]
[Attributor][NFC] Clang format

2 years ago[clang-tidy] Include constructor initializers in `bugprone-exception-escape` check
Fabian Wolff [Thu, 20 Jan 2022 21:51:53 +0000 (22:51 +0100)]
[clang-tidy] Include constructor initializers in `bugprone-exception-escape` check

Fixes PR#52435.

Reviewed By: aaron.ballman

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

2 years ago[OpenCL] opencl-c.h: add __opencl_c_images and __opencl_c_read_write_images
Dave Airlie [Thu, 20 Jan 2022 23:49:41 +0000 (09:49 +1000)]
[OpenCL] opencl-c.h: add __opencl_c_images and  __opencl_c_read_write_images

This wraps the image and rw images usages in the correct macros

Reviewed By: Anastasia

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

2 years ago[flang] Handle FLUSH(unknown unit)
Peter Klausler [Wed, 12 Jan 2022 23:48:06 +0000 (15:48 -0800)]
[flang] Handle FLUSH(unknown unit)

The unit number passed to a FLUSH statement is not required to
be a valid open unit; nothing happens (esp. not the creation of
an empty fort.n file) in this case.

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

2 years ago[flang] Fix OPEN/WRITE(SIGN='SUPPRESS')
Peter Klausler [Tue, 11 Jan 2022 22:54:31 +0000 (14:54 -0800)]
[flang] Fix OPEN/WRITE(SIGN='SUPPRESS')

The keyword value was misspelled in the runtime.

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

2 years ago[libc] Use __builtin_clz to find leading 1 in hypot
Clint Caywood [Thu, 20 Jan 2022 23:27:05 +0000 (23:27 +0000)]
[libc] Use __builtin_clz to find leading 1 in hypot

This is an optimization that using a single CPU instruction on supported
architectures (amd64 and aarch64, but possibly others) to replace what was
previously an iterative look-up-table algorithm.

Originally I suggested using inline assembly for this in
https://reviews.llvm.org/D117584.

Reviewed By: lntue, sivachandra

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

2 years ago[lld][WebAssembly] Remove redundant config setting
Sam Clegg [Thu, 20 Jan 2022 02:17:08 +0000 (18:17 -0800)]
[lld][WebAssembly] Remove redundant config setting

Unresolved symbols are not currently reported when building with
`-shared` or `-pie` so setting unresolvedSymbols doesn't have any
effect.

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

2 years ago[test] Add tests for bswap combining. NFC
Paweł Bylica [Thu, 20 Jan 2022 20:16:46 +0000 (21:16 +0100)]
[test] Add tests for bswap combining. NFC

2 years ago[clang-tidy] Update bugprone-stringview-nullptr to consistently prefer the empty...
CJ Johnson [Thu, 20 Jan 2022 23:05:07 +0000 (18:05 -0500)]
[clang-tidy] Update bugprone-stringview-nullptr to consistently prefer the empty string when passing arguments to constructors/functions

Previously, function(nullptr) would have been fixed with function({}). This unfortunately can change overload resolution and even become ambiguous. T(nullptr) was already being fixed with T(""), so this change just brings function calls in line with that.

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

2 years ago[RISCV] Remove RISCVSubtarget::hasStdExtV() and hasStdExtZve*(). NFC
Craig Topper [Thu, 20 Jan 2022 22:57:31 +0000 (14:57 -0800)]
[RISCV] Remove RISCVSubtarget::hasStdExtV() and hasStdExtZve*(). NFC

All code should use one of the cleaner named hasVInstructions*
functions. Fix the two uses that weren't and delete the methods
so no new uses can be created.

2 years ago[libc] Move the remaining public types to their own type headers.
Siva Chandra Reddy [Thu, 20 Jan 2022 08:11:54 +0000 (08:11 +0000)]
[libc] Move the remaining public types to their own type headers.

Reviewed By: michaelrj

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

2 years ago[RISCV] Optimize vector_shuffles that are interleaving the lowest elements of two...
Craig Topper [Thu, 20 Jan 2022 22:16:37 +0000 (14:16 -0800)]
[RISCV] Optimize vector_shuffles that are interleaving the lowest elements of two vectors.

RISCV only has a unary shuffle that requires places indices in a
register. For interleaving two vectors this means we need at least
two vrgathers and a vmerge to do a shuffle of two vectors.

This patch teaches shuffle lowering to use a widening addu followed
by a widening vmaccu to implement the interleave. First we extract
the low half of both V1 and V2. Then we implement
(zext(V1) + zext(V2)) + (zext(V2) * zext(2^eltbits - 1)) which
simplifies to (zext(V1) + zext(V2) * 2^eltbits). This further
simplifies to (zext(V1) + zext(V2) << eltbits). Then we bitcast the
result back to the original type splitting the wide elements in half.

We can only do this if we have a type with wider elements available.
Because we're using extends we also have to be careful with fractional
lmuls. Floating point types are supported by bitcasting to/from integer.

The tests test a varied combination of LMULs split across VLEN>=128 and
VLEN>=512 tests. There a few tests with shuffle indices commuted as well
as tests for undef indices. There's one test for a vXi64/vXf64 vector which
we can't optimize, but verifies we don't crash.

Reviewed By: rogfer01

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

2 years ago[mlir][tosa] Limit right-shift to 31 bits
Rob Suderman [Thu, 20 Jan 2022 22:32:19 +0000 (14:32 -0800)]
[mlir][tosa] Limit right-shift to 31 bits

Right shift can occur that is a 32-bit right shift. This is undefined behavior.

Reviewed By: mehdi_amini

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

2 years ago[clang-format][NFC] Clean up tryMergeLessLess()
owenca [Thu, 20 Jan 2022 09:59:52 +0000 (01:59 -0800)]
[clang-format][NFC] Clean up tryMergeLessLess()

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

2 years ago[clang-tidy][NFC] Remove redundant string creation for comparison
Nathan James [Thu, 20 Jan 2022 22:20:10 +0000 (22:20 +0000)]
[clang-tidy][NFC] Remove redundant string creation for comparison

2 years ago[OpenMPIRBuilder] Detect ambiguous InsertPoints for apply*WorkshareLoop. NFC.
Michael Kruse [Thu, 20 Jan 2022 16:42:17 +0000 (10:42 -0600)]
[OpenMPIRBuilder] Detect ambiguous InsertPoints for apply*WorkshareLoop. NFC.

Follow-up on D117226 for applyStaticWorkshareLoop and
applyDynamicWorkshareLoop checking for conflicting InertPoints via an
assert. There is no in-tree code that violates this assertion, hence
nothing changes.

2 years ago[SLP] Remove stray semicolon to make bots happy
Philip Reames [Thu, 20 Jan 2022 22:07:46 +0000 (14:07 -0800)]
[SLP] Remove stray semicolon to make bots happy

Certain bots (e.g. sanitizer-x86_64-linux-android) appear to be running with strict c++98 flags which disallow ; at global scope.

2 years ago[AMDGPU] Do not ignore exec use where exec is read as data
Stanislav Mekhanoshin [Wed, 1 Dec 2021 21:44:42 +0000 (13:44 -0800)]
[AMDGPU] Do not ignore exec use where exec is read as data

Compares, v_cndmask_b32, and v_readfirstlane_b32 use EXEC
in a way which modifies the result. This implicit EXEC use
shall not be ignored for the purposes of instruction moves.

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

2 years ago[SLP] Kill an unused param and use a for-loop in calculateDependencies [NFC]
Philip Reames [Thu, 20 Jan 2022 21:58:13 +0000 (13:58 -0800)]
[SLP] Kill an unused param and use a for-loop in calculateDependencies [NFC]

2 years agoWork around a module build failure on the bots.
Adrian Prantl [Thu, 20 Jan 2022 21:36:55 +0000 (13:36 -0800)]
Work around a module build failure on the bots.

This patch works around what looks like a bug in Clang itself.

The error on the bot is:

https://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/40466/consoleText

In module 'LLVM_Utils' imported from /Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/lldb/source/Plugins/ScriptInterpreter/Python/lldb-python.h:18:
/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/llvm/include/llvm/Support/Error.h:720:3: error: 'llvm::Expected<bool>::(anonymous)' from module 'LLVM_Utils.Support.Error' is not present in definition of 'llvm::Expected<bool>' in module 'LLVM_Utils.Support.Error'
  union {
  ^
/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/llvm/include/llvm/Support/Error.h:720:3: note: declaration of '' does not match
/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/llvm/include/llvm/Support/Error.h:720:3: note: declaration of '' does not match
1 error generated.

The intention is to revert this as soon as a proper fix has been identified!

rdar://87845391

2 years ago[cmake] Duplicate `{llvm,compiler_rt}_check_linker_flag` for runtime libs and llvm
John Ericson [Tue, 18 Jan 2022 23:34:54 +0000 (23:34 +0000)]
[cmake] Duplicate `{llvm,compiler_rt}_check_linker_flag` for runtime libs and llvm

We previously had a few varied definitions of this floating around. I made the one installed with LLVM handle all the cases, and then made the others use it.

This issue was reported to me in https://reviews.llvm.org/D116521#3248117 as
D116521 made clang and llvm use the common cmake utils.

Reviewed By: sebastian-ne, phosek, #libunwind, #libc, #libc_abi, ldionne

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

2 years ago[compiler-rt][cmake] Use HandleOutOfTreeLLVM like libcxx and friends
John Ericson [Thu, 20 Jan 2022 19:04:15 +0000 (19:04 +0000)]
[compiler-rt][cmake] Use HandleOutOfTreeLLVM like libcxx and friends

This gives us the option of using CMake modules from LLVM, and other
things. We will use that to deduplicate code later.

Reviewed By: phosek

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

2 years ago[libc] Make log2f correctly rounded for all rounding modes when FMA is not available.
Tue Ly [Thu, 20 Jan 2022 18:51:04 +0000 (13:51 -0500)]
[libc] Make log2f correctly rounded for all rounding modes when FMA is not available.

Add to log2f 2 more exceptional cases got when not using fma for polyeval.

Reviewed By: sivachandra

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

2 years ago[mlir:TiingInterface] Remove unnecessary include of Tensor.h
River Riddle [Thu, 20 Jan 2022 20:54:03 +0000 (12:54 -0800)]
[mlir:TiingInterface] Remove unnecessary include of Tensor.h

Interfaces in Interfaces/ should not depend on any dialects, and this include
is unnecessary anyways.

2 years ago[SLP] Extract formBundle helper for readability [NFC]
Philip Reames [Thu, 20 Jan 2022 21:06:55 +0000 (13:06 -0800)]
[SLP] Extract formBundle helper for readability [NFC]

2 years ago[InstCombine] convert mul with sexted bool and constant to select
Sanjay Patel [Thu, 20 Jan 2022 19:51:45 +0000 (14:51 -0500)]
[InstCombine] convert mul with sexted bool and constant to select

We already have the related folds for zext-of-bool, so it
should make things more consistent to have this transform
to select for sext-of-bool too:
https://alive2.llvm.org/ce/z/YikdfA

Fixes #53319

2 years ago[InstCombine] add/adjust tests for multiply with extended bool; NFC
Sanjay Patel [Thu, 20 Jan 2022 19:41:01 +0000 (14:41 -0500)]
[InstCombine] add/adjust tests for multiply with extended bool; NFC

2 years ago[RISCV] Remove HadStdExtV and HasStdZve* Predicates from tablegen.
Craig Topper [Thu, 20 Jan 2022 20:53:12 +0000 (12:53 -0800)]
[RISCV] Remove HadStdExtV and HasStdZve* Predicates from tablegen.

No instructions should be using these. Everything should use
HasVInstructions* Predicates. Remove them so that they can't be
used by accident.

2 years ago[MLIR][GPU] Add debug output to enable dumping GPU assembly
Krzysztof Drewniak [Mon, 10 Jan 2022 23:53:58 +0000 (23:53 +0000)]
[MLIR][GPU] Add debug output to enable dumping GPU assembly

- Set the DEBUG_TYPE of SerializeToBlob to serialize-to-blob
- Add debug output to print the assembly or PTX for GPU modules before
  they are assembled and linked

Note that, as SerializeToBlob is a superclass of SerializeToCubin and
SerializeToHsaco, --debug-only=serialize-to-blom will dump the
intermediate compiler result for both of these passes.

In addition, if LLVM options such as --stop-after are used to control
the GPU kernel compilation process, the debug output will contain the
appropriate intermediate IR.

Reviewed By: herhut

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

2 years ago[SLP] Use for loops for walking bundle elements
Philip Reames [Thu, 20 Jan 2022 20:44:20 +0000 (12:44 -0800)]
[SLP] Use for loops for walking bundle elements

2 years ago[RISCV] Remove Zvlsseg extension.
Craig Topper [Thu, 20 Jan 2022 19:49:35 +0000 (11:49 -0800)]
[RISCV] Remove Zvlsseg extension.

This string no longer appears in the Vector Extension specification.
The segment load/store instructions are just part of the vector
instruction set.

Reviewed By: asb

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

2 years ago[mlir][pdl] Make `pdl` the default dialect when parsing/printing
Mogball [Thu, 20 Jan 2022 20:17:40 +0000 (20:17 +0000)]
[mlir][pdl] Make `pdl` the default dialect when parsing/printing

PDLDialect being a somewhat user-facing dialect and whose ops contain exclusively other PDL ops in their regions can take advantage of `OpAsmOpInterface` to provide nicer IR.

Reviewed By: rriddle

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

2 years ago[mlir][pdl] OperationOp should not be side-effect free
Mogball [Thu, 20 Jan 2022 20:17:26 +0000 (20:17 +0000)]
[mlir][pdl] OperationOp should not be side-effect free

Unbound OperationOp in the matcher (i.e. one with no uses) is already disallowed by the verifier. However, an OperationOp in the rewriter is not side-effect free -- it's creating an op!

Reviewed By: rriddle

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

2 years ago[mlir][pdl] Some ops are missing `NoSideEffect`
Mogball [Thu, 20 Jan 2022 20:17:14 +0000 (20:17 +0000)]
[mlir][pdl] Some ops are missing `NoSideEffect`

Querying or building constraints on types, operands, results, and attributes are side-effect free in both the matcher and rewriter. The ops should be marked as such.

Reviewed By: rriddle

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

2 years ago[libcxx][test] view_interface need not derive from view_base
Casey Carter [Wed, 29 Dec 2021 23:58:25 +0000 (15:58 -0800)]
[libcxx][test] view_interface need not derive from view_base

... after LWG-3549.

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

2 years ago[lld][macho] Stop grouping symbols by sections in mapfile.
Roger Kim [Thu, 20 Jan 2022 20:13:04 +0000 (12:13 -0800)]
[lld][macho] Stop grouping symbols by sections in mapfile.

As per [Bug 50689](https://bugs.llvm.org/show_bug.cgi?id=50689),

```
2. getSectionSyms() puts all the symbols into a map of section -> symbols, but this seems unnecessary. This was likely copied from the ELF port, which prints a section header before the list of symbols it contains. But the Mach-O map file doesn't print these headers.
```

This diff removes `getSectionSyms()` and keeps all symbols in a flat vector.

What does ld64's mapfile look like?
```
$ llvm-mc -filetype=obj -triple=x86_64-apple-darwin test.s -o test.o
$ llvm-mc -filetype=obj -triple=x86_64-apple-darwin foo.s -o foo.o
$ ld -map map test.o foo.o -o out -L/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib -lSystem
```

```
[  0] linker synthesized
[  1] test.o
[  2] foo.o
0x100003FB7     0x00000001      __TEXT  __text
0x100003FB8     0x00000000      __TEXT  obj
0x100003FB8     0x00000048      __TEXT  __unwind_info
0x100004000     0x00000001      __DATA  __common
0x100003FB7     0x00000001      [  1] _main
0x100003FB8     0x00000000      [  2] _foo
0x100003FB8     0x00000048      [  0] compact unwind info
0x100004000     0x00000001      [  1] _number
```

Perf numbers when linking chromium framework on a 16-Core Intel Xeon W Mac Pro:
```
base           diff           difference (95% CI)
sys_time   1.406 ± 0.020  1.388 ± 0.019  [  -1.9% ..   -0.6%]
user_time  5.557 ± 0.023  5.914 ± 0.020  [  +6.2% ..   +6.6%]
wall_time  4.455 ± 0.041  4.436 ± 0.035  [  -0.8% ..   -0.0%]
samples    35             35
```

Reviewed By: #lld-macho, int3

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

2 years ago[clang-format] Refactor: add FormatToken::hasWhitespaceBefore(). NFC.
Marek Kurdej [Thu, 20 Jan 2022 20:05:54 +0000 (21:05 +0100)]
[clang-format] Refactor: add FormatToken::hasWhitespaceBefore(). NFC.

This factors out a pattern that comes up from time to time.

Reviewed By: MyDeveloperDay, HazardyKnusperkeks, owenpan

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

2 years ago[SLP] Rename a couple lambdas to be more clearly separate from method names
Philip Reames [Thu, 20 Jan 2022 20:13:22 +0000 (12:13 -0800)]
[SLP] Rename a couple lambdas to be more clearly separate from method names

2 years ago[gn build] Port 83d59e05b201
LLVM GN Syncbot [Thu, 20 Jan 2022 20:02:50 +0000 (20:02 +0000)]
[gn build] Port 83d59e05b201

2 years ago[gn build] Port 63a991d03589
LLVM GN Syncbot [Thu, 20 Jan 2022 20:02:49 +0000 (20:02 +0000)]
[gn build] Port 63a991d03589

2 years ago[llvm] Remove an old bot cleanup command
Nico Weber [Thu, 20 Jan 2022 20:02:35 +0000 (15:02 -0500)]
[llvm] Remove an old bot cleanup command

2 years agoclang: Auto-cleanup left-over file from before 3da69fb5a26c7b on bots
Nico Weber [Thu, 20 Jan 2022 19:59:30 +0000 (14:59 -0500)]
clang: Auto-cleanup left-over file from before 3da69fb5a26c7b on bots

2 years ago[libc] Use get_round() instead of floating point tricks in generic hypot implementation.
Tue Ly [Thu, 20 Jan 2022 19:43:09 +0000 (14:43 -0500)]
[libc] Use get_round() instead of floating point tricks in generic hypot implementation.

The floating point tricks used to get rounding mode require -frounding-math flag, which behaves differently on aarch64.  Reverting back to use get_round instead.

Reviewed By: sivachandra

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

2 years agoRe-land [LLD] Remove global state in lldCommon
Alexandre Ganea [Thu, 20 Jan 2022 19:53:18 +0000 (14:53 -0500)]
Re-land [LLD] Remove global state in lldCommon

Move all variables at file-scope or function-static-scope into a hosting structure (lld::CommonLinkerContext) that lives at lldMain()-scope. Drivers will inherit from this structure and add their own global state, in the same way as for the existing COFFLinkerContext.

See discussion in https://lists.llvm.org/pipermail/llvm-dev/2021-June/151184.html

The previous land f860fe362282ed69b9d4503a20e5d20b9a041189 caused issues in https://lab.llvm.org/buildbot/#/builders/123/builds/8383, fixed by 22ee510dac9440a74b2e5b3fe3ff13ccdbf55af3.

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

2 years ago[lldb] Surround LLDB_API-defining code with #ifndef LLDB_API
Pavel Labath [Thu, 20 Jan 2022 19:36:14 +0000 (20:36 +0100)]
[lldb] Surround LLDB_API-defining code with #ifndef LLDB_API

This enables power-users to annotate lldb api functions with arbitrary
attributes. The motivation for this is being able to build liblldb as a
static library on windows (see discussion on D117564).

This should not be interpreted to mean that building liblldb is
supported in any way, but this does not cause any problems for us, and
can help users who really know what they are doing (or have no other
choice).

2 years ago[libcxx] chrono::month_weekday should not be default constructible
Casey Carter [Wed, 19 Jan 2022 06:50:15 +0000 (22:50 -0800)]
[libcxx] chrono::month_weekday should not be default constructible

It was not in P0355R7, nor has it ever been so in a working draft.

Drive-by:
* tests should test something: fix loop bounds so initial value is not >= final value
* calender type streaming tests are useless - let's remove them
* don't declare printf, especially if you don't intend to use it

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

2 years ago[demangler][NFC] Small cleanups and sync
Nathan Sidwell [Thu, 20 Jan 2022 15:40:12 +0000 (07:40 -0800)]
[demangler][NFC] Small cleanups and sync

Some precursor work to adding module demangling.

* some mismatched comment and code in the demangler

* a const fn was not marked thusly

* we use std::islower.  A direct range check is smaller code (no function call),
  and we know we're in ASCII-land and later in that same function make the same
  assumption about upper-case contiguity.  Heck, maybe just drop the switch's
  precondition and rely on the optimizer to do its thing?

* the directory is cloned in two places, which had gotten out of sync.

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

2 years ago[InstCombine] Instruction sinking: fix check for function terminating block
Roman Lebedev [Thu, 20 Jan 2022 19:41:31 +0000 (22:41 +0300)]
[InstCombine] Instruction sinking: fix check for function terminating block

Checking for specific function terminating opcodes
means we don't handle other non-hardcoded ones :)

This should probably be generalized to something
similar to the `IsBlockFollowedByDeoptOrUnreachable()`.

Reviewed By: spatel

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

2 years ago[libc++] Eliminate the `__function_like` helper.
Arthur O'Dwyer [Tue, 4 Jan 2022 01:28:00 +0000 (20:28 -0500)]
[libc++] Eliminate the `__function_like` helper.

As prefigured in the comments on D115315.
This gives us one unified style for all niebloids,
and also simplifies the modulemap.

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

2 years ago[RISCV] Add DAG combine to fold (fp_to_int_sat (ffloor X)) -> (select X == nan, 0...
Craig Topper [Thu, 20 Jan 2022 19:32:26 +0000 (11:32 -0800)]
[RISCV] Add DAG combine to fold (fp_to_int_sat (ffloor X)) -> (select X == nan, 0, (fcvt X, rdn))

Similar for ceil, trunc, round, and roundeven. This allows us to use
static rounding modes to avoid a libcall.

This is similar to D116771, but for the saturating conversions.

This optimization is done for AArch64 as isel patterns.
RISCV doesn't have instructions for ceil/floor/trunc/round/roundeven
so the operations don't stick around until isel to enable a pattern
match. Thus I've implemented a DAG combine.

I'm only handling saturating to i64 or i32. This could be extended
to other sizes in the future.

Reviewed By: asb

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

2 years ago[Support] [DebugInfo] Lazily create cache dir.
Daniel Thornburgh [Fri, 14 Jan 2022 23:10:37 +0000 (23:10 +0000)]
[Support] [DebugInfo] Lazily create cache dir.

This change defers creating Support/Caching.cpp's cache directory until
it actually writes to the cache.

This allows using Caching library in a read-only fashion. If read-only,
the cache is guaranteed not to write to disk. This keeps tools using
DebugInfod (currently llvm-symbolizer) hermetic when not configured to
perform remote lookups.

Reviewed By: phosek

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

2 years ago[clang][NFC] Small mangler cleanups
Nathan Sidwell [Thu, 20 Jan 2022 15:39:22 +0000 (07:39 -0800)]
[clang][NFC] Small mangler cleanups

In working on a module mangling problem I noticed a few cleanups to the mangler.

1) Use 'if (auto x = ...' idiom in a couple of places.

2) I noticed both 'isFileContext' and 'isNamespace || isTranslationUnit'
   synonyms. Let's use the former.

3) The control flow in the seqId mangling was misordered. Let's channel Count
   von Count. Also fix the inconsistent bracing.

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

2 years ago[AMDGPU] Regenerate remat-vop.mir. NFC.
Stanislav Mekhanoshin [Thu, 20 Jan 2022 19:05:01 +0000 (11:05 -0800)]
[AMDGPU] Regenerate remat-vop.mir. NFC.

2 years ago[Clang] Separate the 'debug-info-hotpatch' test in two parts: one for ARM and another...
Alexandre Ganea [Thu, 20 Jan 2022 18:38:32 +0000 (13:38 -0500)]
[Clang] Separate the 'debug-info-hotpatch' test in two parts: one for ARM and another for AArch64

After 5af2433e1794ebf7e58e848aa612c7912d71dc78, this shall fix: https://lab.llvm.org/buildbot/#/builders/188/builds/8400 - if not I'll revert this patch and 5af2433e1794ebf7e58e848aa612c7912d71dc78.

2 years ago[SystemZ] Remove the ManipulatesSP flag from backend (NFC).
Jonas Paulsson [Tue, 18 Jan 2022 23:40:26 +0000 (17:40 -0600)]
[SystemZ] Remove the ManipulatesSP flag from backend (NFC).

This flag was set in the presence of stacksave/stackrestore in order to force
a frame pointer.

This should however not be needed per the comment in MachineFrameInfo.h
stating that a a variable sized object "...is the sole condition which
prevents frame pointer elimination", and experiments have also shown that
there seems to be no effect whatsoever on code generation with ManipulatesSP.

Review: Ulrich Weigand

2 years ago[cmake] Make include(GNUInstallDirs) always below project(..)
John Ericson [Wed, 19 Jan 2022 06:45:07 +0000 (06:45 +0000)]
[cmake] Make include(GNUInstallDirs) always below project(..)

Its defaulting logic must go after `project(..)` to work correctly,  but `project(..)` is often in a standalone condition making this
awkward, since the rest of the condition code may also need GNUInstallDirs.

The good thing is there are the various standalone booleans, which I had missed before. This makes splitting the conditional blocks less awkward.

Reviewed By: arichardson, phosek, beanz, ldionne, #libunwind, #libc, #libc_abi

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

2 years ago[clang] Improve -Wdeclaration-after-statement
Marco Elver [Thu, 20 Jan 2022 18:36:16 +0000 (19:36 +0100)]
[clang] Improve -Wdeclaration-after-statement

With 118f966b46cf, Clang matches GCC's behaviour and allows enabling
-Wdeclaration-after-statement with C99 and later.

However, the check for mixing declarations and code is not a constant time
algorithm, and therefore should be guarded with Diags.isIgnored().

Furthermore, improve test coverage with: non-pedantic C89 with the
warning; C11 with the warning; and when using -Wall.

Finally, mention the changed behaviour in ReleaseNotes.rst.

Reviewed By: aaron.ballman

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

2 years ago[InstCombine] add one-use check to opposite shift folds
Sanjay Patel [Thu, 20 Jan 2022 18:35:58 +0000 (13:35 -0500)]
[InstCombine] add one-use check to opposite shift folds

Test comments say this might be intentional, but I don't
see any hard evidence to support it. The extra instruction
shows up as a potential regression in D117680.

One test does show a missed fold that might be recovered
with better demanded bits analysis.

2 years ago[InstCombine] avoid 'tmp' usage in test files; NFC
Sanjay Patel [Thu, 20 Jan 2022 17:29:12 +0000 (12:29 -0500)]
[InstCombine] avoid 'tmp' usage in test files; NFC

The update script ( utils/update_test_checks.py ) warns against this
because it can conflict with the default FileCheck names given to
anonymous values in the IR.

2 years ago[NFC][RISCV] Add end-of-line symbol in target-feature testcases
eopXD [Thu, 20 Jan 2022 18:36:23 +0000 (10:36 -0800)]
[NFC][RISCV] Add end-of-line symbol in target-feature testcases

Reviewed By: craig.topper

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

2 years ago[TargetLowering][InstCombine] Simplify BSwap demanded bits code a little. NFC
Craig Topper [Thu, 20 Jan 2022 18:36:21 +0000 (10:36 -0800)]
[TargetLowering][InstCombine] Simplify BSwap demanded bits code a little. NFC

Use alignDown instead of &= ~7.

Replace ResultBit with NLZ. (BitWidth - NLZ - NTZ == 8) so
(BitWidth - NTZ - 8 == NLZ).

Reviewed By: spatel

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

2 years ago[NFC][InstCombine] Add test showing failure to sink into `resume` block
Roman Lebedev [Thu, 20 Jan 2022 18:37:26 +0000 (21:37 +0300)]
[NFC][InstCombine] Add test showing failure to sink into `resume` block

2 years agoAdd `isConsteval` matcher
Evgeny Shulgin [Thu, 20 Jan 2022 18:34:28 +0000 (13:34 -0500)]
Add `isConsteval` matcher

Support C++20 consteval functions and C++2b if consteval for AST Matchers.

2 years ago[libc] Implement correct rounding with all rounding modes for hypot functions.
Tue Ly [Tue, 18 Jan 2022 18:46:18 +0000 (13:46 -0500)]
[libc] Implement correct rounding with all rounding modes for hypot functions.

Update the rounding logic for generic hypot function so that it will round correctly with all rounding modes.

Reviewed By: sivachandra, zimmermann6

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

2 years ago[OpenMP] Don't pass empty files to nvlink
Joseph Huber [Thu, 20 Jan 2022 13:29:16 +0000 (08:29 -0500)]
[OpenMP] Don't pass empty files to nvlink

This patch adds and exception to the nvlink wrapper tool to not pass
empty cubin files to the nvlink job. If an empty file is passed to
nvlink it will cause an error indicating that the file could not be
opened. This would occur if the user tried to link object files that
contained offloading code with a file that didnt. This will act as a
workaround until the new OpenMP offloading driver becomes the default.

Reviewed By: jdoerfert

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

2 years ago[mlir][vector] Allow values outside of [0; dim-size] in create_mask
Sergei Grechanik [Thu, 20 Jan 2022 16:54:38 +0000 (08:54 -0800)]
[mlir][vector] Allow values outside of [0; dim-size] in create_mask

This commits explicitly states that negative values and values exceeding
vector dimensions are allowed in vector.create_mask (but not in
vector.constant_mask). These values are now truncated when
canonicalizing vector.create_mask to vector.constant_mask.

Reviewed By: aartbik

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

2 years ago[clang-cl] Support the /HOTPATCH flag
Alexandre Ganea [Thu, 20 Jan 2022 16:04:46 +0000 (11:04 -0500)]
[clang-cl] Support the /HOTPATCH flag

This patch adds support for the MSVC /HOTPATCH flag: https://docs.microsoft.com/sv-se/cpp/build/reference/hotpatch-create-hotpatchable-image?view=msvc-170&viewFallbackFrom=vs-2019

The flag is translated to a new -fms-hotpatch flag, which in turn adds a 'patchable-function' attribute for each function in the TU. This is then picked up by the PatchableFunction pass which would generate a TargetOpcode::PATCHABLE_OP of minsize = 2 (which means the target instruction must resolve to at least two bytes). TargetOpcode::PATCHABLE_OP is only implemented for x86/x64. When targetting ARM/ARM64, /HOTPATCH isn't required (instructions are always 2/4 bytes and suitable for hotpatching).

Additionally, when using /Z7, we generate a 'hot patchable' flag in the CodeView debug stream, in the S_COMPILE3 record. This flag is then picked up by LLD (or link.exe) and is used in conjunction with the linker /FUNCTIONPADMIN flag to generate extra space before each function, to accommodate for live patching long jumps. Please see: https://github.com/llvm/llvm-project/blob/d703b922961e0d02a5effdd4bfbb23ad50a3cc9f/lld/COFF/Writer.cpp#L1298

The outcome is that we can finally use Live++ or Recode along with clang-cl.

NOTE: It seems that MSVC cl.exe always enables /HOTPATCH on x64 by default, although if we did the same I thought we might generate sub-optimal code (if this flag was active by default). Additionally, MSVC always generates a .debug$S section and a S_COMPILE3 record, which Clang doesn't do without /Z7. Therefore, the following MSVC command-line "cl /c file.cpp" would have to be written with Clang such as "clang-cl /c file.cpp /HOTPATCH /Z7" in order to obtain the same result.

Depends on D43002, D80833 and D81301 for the full feature.

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

2 years agoAMDGPU: Fix asm in test using wrong IR type for physical register
Matt Arsenault [Wed, 19 Jan 2022 22:39:27 +0000 (17:39 -0500)]
AMDGPU: Fix asm in test using wrong IR type for physical register

2 years agoAMDGPU/GlobalISel: Try to use s_and_b64 in ptrmask selection
Matt Arsenault [Wed, 19 Jan 2022 20:20:39 +0000 (15:20 -0500)]
AMDGPU/GlobalISel: Try to use s_and_b64 in ptrmask selection

Avoids a test diff with SDAG.

2 years agoAMDGPU/GlobalISel: Regenerate test checks with -NEXT
Matt Arsenault [Wed, 19 Jan 2022 21:14:56 +0000 (16:14 -0500)]
AMDGPU/GlobalISel: Regenerate test checks with -NEXT