platform/upstream/llvm.git
2 years ago[lld-macho][nfc] Rearrange order of statements to clarify data dependencies
Jez Ng [Thu, 7 Apr 2022 04:00:41 +0000 (00:00 -0400)]
[lld-macho][nfc] Rearrange order of statements to clarify data dependencies

2 years ago[Driver][test] Fix csky-toolchain.c to be CLANG_DEFAULT_PIE_ON_LINUX agnostic
Fangrui Song [Thu, 7 Apr 2022 03:41:39 +0000 (20:41 -0700)]
[Driver][test] Fix csky-toolchain.c to be CLANG_DEFAULT_PIE_ON_LINUX agnostic

2 years agoReland "[Driver] Default CLANG_DEFAULT_PIE_ON_LINUX to ON""
Fangrui Song [Thu, 7 Apr 2022 03:19:07 +0000 (20:19 -0700)]
Reland "[Driver] Default CLANG_DEFAULT_PIE_ON_LINUX to ON""

(The upgrade of the ppc64le bot and D121257 have fixed compiler-rt failures. Tested by nemanjai.)

Default the option introduced in D113372 to ON to match all(?) major Linux
distros. This matches GCC and improves consistency with Android and linux-musl
which always default to PIE.
Note: CLANG_DEFAULT_PIE_ON_LINUX may be removed in the future.

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

2 years ago[CSKY] Fix some Clang warnings. NFC
Fangrui Song [Thu, 7 Apr 2022 03:09:32 +0000 (20:09 -0700)]
[CSKY] Fix some Clang warnings. NFC

Reviewed By: zixuan-wu

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

2 years agoLink aganist clangSema to fix broken build.
Jun Zhang [Thu, 7 Apr 2022 02:45:56 +0000 (10:45 +0800)]
Link aganist clangSema to fix broken build.

Signed-off-by: Jun Zhang <jun@junz.org>
2 years agoAMDGPU: Handle private atomics
Matt Arsenault [Tue, 5 Apr 2022 22:42:39 +0000 (18:42 -0400)]
AMDGPU: Handle private atomics

Use new NotAtomic expansion to turn these into the equivalent
non-atomic operations. Independent lanes cannot access the private
memory of other lanes, so there's no possibility for synchronization.

These don't really appear directly in user code, but
InferAddressSpaces can make these appear after optimizations.

Fixes issues 54693 and 54274.

2 years agoAtomicExpand: Add NotAtomic lowering strategy
Matt Arsenault [Tue, 5 Apr 2022 20:38:19 +0000 (16:38 -0400)]
AtomicExpand: Add NotAtomic lowering strategy

Currently LowerAtomics exists as a separate pass which blindly
replaces all atomics. Add a new lowering strategy option to eliminate
the atomics which the target can control on a per-instruction level.

2 years agoAtomicExpand: Change return type for shouldExpandAtomicStoreInIR
Matt Arsenault [Tue, 5 Apr 2022 21:48:50 +0000 (17:48 -0400)]
AtomicExpand: Change return type for shouldExpandAtomicStoreInIR

Use the same enum as the other atomic instructions for consistency, in
preparation for addition of another strategy.

Introduce a new "Expand" option, since the store expansion does not
use cmpxchg. Alternatively, the existing CmpXChg strategy could be
renamed to Expand.

2 years ago[RISCV] Supplement patterns for vnsrl.wx/vnsra.wx when splat shift is sext or zext
Lian Wang [Thu, 31 Mar 2022 07:07:42 +0000 (07:07 +0000)]
[RISCV] Supplement patterns for vnsrl.wx/vnsra.wx when splat shift is sext or zext

Reviewed By: craig.topper

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

2 years ago[clang-format][docs] Fix incorrect 'clang-format 11' option markers
Krystian Kuzniarek [Thu, 7 Apr 2022 01:33:18 +0000 (18:33 -0700)]
[clang-format][docs] Fix incorrect 'clang-format 11' option markers

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

2 years ago[mlir:Parser][NFC] Replace SSAUseInfo with OpAsmParser::UnresolvedOperand
River Riddle [Thu, 7 Apr 2022 01:24:31 +0000 (18:24 -0700)]
[mlir:Parser][NFC] Replace SSAUseInfo with OpAsmParser::UnresolvedOperand

These are functionally identical, and merging the two removes the number of
redundant conversions within the parser.

2 years ago[AMDGPU] Check SI LDS offset bug in the allowsMisalignedMemoryAccesses
Stanislav Mekhanoshin [Wed, 6 Apr 2022 23:02:46 +0000 (16:02 -0700)]
[AMDGPU] Check SI LDS offset bug in the allowsMisalignedMemoryAccesses

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

2 years ago[libomptarget] Add device RTL to regression test dependencies.
Michael Kruse [Thu, 7 Apr 2022 00:20:07 +0000 (19:20 -0500)]
[libomptarget] Add device RTL to regression test dependencies.

In a clean build directory, `check-openmp` or `check-libomptarget` will fail because of missing device RTL .bc files. Ensure that the new targets new custom targets `omptarget.devicertl.nvptx` and `omptarget.devicertl.amdgpu` (corresponding to the plugin rtl targets `omptarget.rtl.cuda`, respectively `omptarget.rlt.amdgpu` ) are dependencies of the regression tests.

Reviewed By: JonChesterfield

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

2 years ago[gn build] Port 39f156863392
LLVM GN Syncbot [Thu, 7 Apr 2022 00:55:44 +0000 (00:55 +0000)]
[gn build] Port 39f156863392

2 years agoTransforms: Split LowerAtomics into separate Utils and pass
Matt Arsenault [Tue, 5 Apr 2022 20:37:58 +0000 (16:37 -0400)]
Transforms: Split LowerAtomics into separate Utils and pass

This will allow code sharing from AtomicExpandPass. Not entirely sure
why these exist as separate passes though.

2 years ago[mlir:PDL] Expand how native constraint/rewrite functions can be defined
River Riddle [Sat, 19 Mar 2022 22:08:09 +0000 (15:08 -0700)]
[mlir:PDL] Expand how native constraint/rewrite functions can be defined

This commit refactors the expected form of native constraint and rewrite
functions, and greatly reduces the necessary user complexity required when
defining a native function. Namely, this commit adds in automatic processing
of the necessary PDLValue glue code, and allows for users to define
constraint/rewrite functions using the C++ types that they actually want to
use.

As an example, lets see a simple example rewrite defined today:

```
static void rewriteFn(PatternRewriter &rewriter, PDLResultList &results,
                      ArrayRef<PDLValue> args) {
  ValueRange operandValues = args[0].cast<ValueRange>();
  TypeRange typeValues = args[1].cast<TypeRange>();
  ...
  // Create an operation at some point and pass it back to PDL.
  Operation *op = rewriter.create<SomeOp>(...);
  results.push_back(op);
}
```

After this commit, that same rewrite could be defined as:

```
static Operation *rewriteFn(PatternRewriter &rewriter ValueRange operandValues,
                            TypeRange typeValues) {
  ...
  // Create an operation at some point and pass it back to PDL.
  return rewriter.create<SomeOp>(...);
}
```

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

2 years ago[CMake][compiler-rt] Include the missing variables
Petr Hosek [Thu, 7 Apr 2022 00:40:29 +0000 (17:40 -0700)]
[CMake][compiler-rt] Include the missing variables

This includes the missing variables as pointed out in
https://reviews.llvm.org/rGb0e2ffe151c3

2 years ago[mlir][sparse] replace stack-based access pattern with dyn-alloc
Aart Bik [Wed, 6 Apr 2022 20:22:08 +0000 (13:22 -0700)]
[mlir][sparse] replace stack-based access pattern with dyn-alloc

Rationale:
Allocating the temporary buffers for access pattern expansion on the stack
(using alloca) is a bit too agressive, since it easily runs out of stack space
for large enveloping tensor dimensions. This revision changes the dynamic
allocation of these buffers with explicit alloc/dealloc pairs.

Reviewed By: bixia, wrengr

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

2 years ago[MIPS] Initial support for MIPS-I load delay slots
Simon Dardis [Wed, 6 Apr 2022 23:31:33 +0000 (00:31 +0100)]
[MIPS] Initial support for MIPS-I load delay slots

LLVM so far has only supported the MIPS-II and above architectures. MIPS-II is pretty close to MIPS-I, the major difference
being that "load" instructions always take one extra instruction slot to propogate to registers. This patch adds support for
MIPS-I by adding hazard handling for load delay slots, alongside MIPSR6 forbidden slots and FPU slots, inserting a NOP
instruction between a load and any instruction immediately following that reads the load's destination register. I also
included a simple regression test. Since no existing tests target MIPS-I, those all still pass.

Issue ref: https://github.com/simias/psx-sdk-rs/issues/1

I also tested by building a simple demo app with Clang and running it in an emulator.

Patch by: @impiaaa

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

2 years ago[AMDGPU] Regenerate global isel lds ops test checks. NFC.
Stanislav Mekhanoshin [Wed, 6 Apr 2022 23:14:08 +0000 (16:14 -0700)]
[AMDGPU] Regenerate global isel lds ops test checks. NFC.

2 years ago[libc++abi] Remove XFAIL on arm64
Louis Dionne [Wed, 6 Apr 2022 23:01:39 +0000 (19:01 -0400)]
[libc++abi] Remove XFAIL on arm64

The underlying TLS destruction order bug has been fixed in the OS. This
would technically still fail when running on top of macOS < 12, however
we don't have a good way of encoding that using Lit features. Indeed,
the existing target=<FOO> Lit feature encodes the deployment target,
not the actual runtime system that the tests are being run on.

If this test starts failing on your machine after this patch, upgrading
to macOS 12 should solve the problem.

2 years ago[MSSA] Print memory phis when inspecting walker.
Alina Sbirlea [Wed, 6 Apr 2022 21:22:52 +0000 (14:22 -0700)]
[MSSA] Print memory phis when inspecting walker.

This makes the MemorySSA and MemorySSA Walker printers consistent.
Invokation `-print<memoryssa-walker>` should also have the MemoryPhis.

2 years agoRevert f7381a795ab235d34c94eaf01dc880eb5b89619d
Alina Sbirlea [Tue, 29 Mar 2022 23:05:08 +0000 (16:05 -0700)]
Revert f7381a795ab235d34c94eaf01dc880eb5b89619d

Roll-forward 29fada4a3d3db309f11f7fa7a0c61cd4021e9947.
Issue triggered was due to UB.

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

2 years ago[mips] Remove stale comment (NFC)
Simon Dardis [Wed, 6 Apr 2022 22:18:26 +0000 (23:18 +0100)]
[mips] Remove stale comment (NFC)

Test commit for my current email address.

2 years ago[Darwin][ASan] Fix "interceptor working?" check for DriverKit platform
Blue Gaston [Wed, 6 Apr 2022 22:47:18 +0000 (15:47 -0700)]
[Darwin][ASan] Fix "interceptor working?" check for DriverKit platform

The previous check for interceptors used `pthread_create()` which is not
available on DriverKit.  We need an intercepted symbol that satisfies
the following constraints:

- Symbol is available in DriverKit
- Symbol is provided by simulator runtime dylibs (`dlsym()` fails to
  look up host-provided symbols)

`puts()` satisfies all of the above constraints.

rdar://87895539

Reviewed By: yln

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

2 years agogn build: Fix some tests for host_os to instead check current_os.
Peter Collingbourne [Wed, 6 Apr 2022 22:40:09 +0000 (15:40 -0700)]
gn build: Fix some tests for host_os to instead check current_os.

Should fix Windows build:
http://45.33.8.238/win/55809/step_4.txt

2 years ago[pseudo] Include missing `count` in test deps.
Sam McCall [Wed, 6 Apr 2022 22:13:59 +0000 (00:13 +0200)]
[pseudo] Include missing `count` in test deps.

We don't use this for testing, but one of the lit python modules requires it :-\

After this, check-clang-pseudo passes with a clean build tree.

2 years ago[AArch64][AMDGPU][WebAssembly] Use static_cast instead of a reinterpret_cast to downc...
Craig Topper [Wed, 6 Apr 2022 21:50:49 +0000 (14:50 -0700)]
[AArch64][AMDGPU][WebAssembly] Use static_cast instead of a reinterpret_cast to downcast in parseMachineFunctionInfo. NFC

static_cast is a little safer here since the compiler will
ensure we're casting to a class derived from
yaml::MachineFunctionInfo.

I believe this first appeared on AMDGPU and was copied to the
other two targets.

Spotted when it was being copied to RISCV in D123178.

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

2 years ago[lldb] Remove duplicate "warning:"
Jonas Devlieghere [Wed, 6 Apr 2022 22:04:02 +0000 (15:04 -0700)]
[lldb] Remove duplicate "warning:"

Remove "warning:" from the warning message itself. The default event
handler is already emitting the appropriate prefix.

2 years agoRemove unused FileEntry::operator<. NFC
Sam McCall [Wed, 6 Apr 2022 21:39:17 +0000 (23:39 +0200)]
Remove unused FileEntry::operator<. NFC

2 years ago[demangler] Node precision dumper
Nathan Sidwell [Wed, 30 Mar 2022 14:21:42 +0000 (07:21 -0700)]
[demangler] Node precision dumper

Add contents to the demangler node dumper's print(Prec) functions.

Reviewed By: dblaikie

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

2 years agoReland "gn build: Fix support for building the builtins for baremetal."
Peter Collingbourne [Fri, 1 Apr 2022 03:34:05 +0000 (20:34 -0700)]
Reland "gn build: Fix support for building the builtins for baremetal."

Our support for building for baremetal was conditional on a default
off arg and would have failed to build if you had somehow arranged
to pass the correct --target flag; presumably nobody noticed because
nobody was turning it on. A better approach is to model baremetal
as a separate "OS" called "baremetal" and build it in the same way
as we cross-compile for other targets. That's what this patch does.
I only hooked up the arm64 target but others can be added.

Relanding after fixing Mac build breakage in D123244.

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

2 years agogn build: Use target OS to control whether to use/depend on llvm-ar.
Peter Collingbourne [Wed, 6 Apr 2022 19:46:05 +0000 (12:46 -0700)]
gn build: Use target OS to control whether to use/depend on llvm-ar.

When cross-compiling from Mac to non-Mac, we need to use the just-built
llvm-ar instead of libtool. We're currently doing the right thing
when determining which archiver command to use, but the path to ar
and the toolchain dependencies were being set based on the host OS
(current_os evaluated in host OS toolchain), instead of the target
OS. Fix the problem by looking up current_os inside toolchain_args.

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

2 years ago[NFC][trace][intelpt] Remove unneeded import
Walter Erquinigo [Wed, 6 Apr 2022 19:24:50 +0000 (12:24 -0700)]
[NFC][trace][intelpt] Remove unneeded import

Remove an unnecessary import to silence a compiler warning.

2 years ago[MLIR] Add block detach func to CAPI and use it in Python bindings
John Demme [Wed, 6 Apr 2022 17:06:30 +0000 (10:06 -0700)]
[MLIR] Add block detach func to CAPI and use it in Python bindings

Adds `mlirBlockDetach` to the CAPI to remove a block from its parent
region. Use it in the Python bindings to implement
`Block.append_to(region)`.

Reviewed By: mehdi_amini

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

2 years ago[demangler][NFC] Rename SwapAndRestore to ScopedOverride
Nathan Sidwell [Mon, 28 Feb 2022 18:18:14 +0000 (10:18 -0800)]
[demangler][NFC] Rename SwapAndRestore to ScopedOverride

The demangler has a utility class 'SwapAndRestore'. That name is
confusing. It's not swapping anything, and the restore part happens at
the object's destruction. What it's actually doing is allowing a
override of some value that is dynamically accessible within the
lifetime of a lexical scope. Thus rename it to ScopedOverride, and
tweak it's member variable names.

Reviewed By: dblaikie

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

2 years ago[libcxx] [test] Stop defining LIBCXX-WINDOWS-FIXME
Martin Storsjö [Fri, 25 Feb 2022 10:03:34 +0000 (12:03 +0200)]
[libcxx] [test] Stop defining LIBCXX-WINDOWS-FIXME

There are no such markings left - all of them have been fixed or
analyzed.

This closes llvm.org/PR32730 (github issue #32077).

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

2 years ago[Support] [BLAKE3] Fix building for Cygwin
Martin Storsjö [Wed, 6 Apr 2022 07:13:31 +0000 (10:13 +0300)]
[Support] [BLAKE3] Fix building for Cygwin

Use the windows-gnu assembly files on x86_64 Cygwin too.

This fixes https://github.com/llvm/llvm-project/issues/54685.

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

2 years ago[AArch64] Fix the upper limit for folded address offsets for COFF
Martin Storsjö [Tue, 5 Apr 2022 21:44:38 +0000 (00:44 +0300)]
[AArch64] Fix the upper limit for folded address offsets for COFF

In COFF, the immediates in IMAGE_REL_ARM64_PAGEBASE_REL21 relocations
are limited to 21 bit signed, i.e. the offset has to be less than
(1 << 20). The previous limit did intend to cover for this case, but
had missed that the 21 bit field was signed.

This fixes issue https://github.com/llvm/llvm-project/issues/54753.

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

2 years ago[lldb] Silence GCC/glibc warnings about ignoring the return value of write(). NFC.
Martin Storsjö [Wed, 6 Apr 2022 11:11:49 +0000 (14:11 +0300)]
[lldb] Silence GCC/glibc warnings about ignoring the return value of write(). NFC.

This matches how another similar warning is silenced in
Host/posix/ProcessLauncherPosixFork.cpp.

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

2 years ago[lldb] Silence GCC warnings about missing returns after fully covered switches. NFC.
Martin Storsjö [Wed, 6 Apr 2022 11:09:22 +0000 (14:09 +0300)]
[lldb] Silence GCC warnings about missing returns after fully covered switches. NFC.

This silences warnings like this:

lldb/source/Core/DebuggerEvents.cpp: In member function ‘llvm::StringRef lldb_private::DiagnosticEventData::GetPrefix() const’:
lldb/source/Core/DebuggerEvents.cpp:55:1: warning: control reaches end of non-void function [-Wreturn-type]
   55 | }

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

2 years ago[lldb] Fix detecting warning options for GCC
Martin Storsjö [Wed, 6 Apr 2022 10:45:20 +0000 (13:45 +0300)]
[lldb] Fix detecting warning options for GCC

If testing for a warning option like -Wno-<foo> with GCC, GCC won't
print any diagnostic at all, leading to the options being accepted
incorrectly. However later, if compiling a file that actually prints
another warning, GCC will also print warnings about these -Wno-<foo>
options being unrecognized.

This avoids warning spam like this, for every lldb source file that
produces build warnings with GCC:

    At global scope:
    cc1plus: warning: unrecognized command line option ‘-Wno-vla-extension’
    cc1plus: warning: unrecognized command line option ‘-Wno-deprecated-register’

This matches how such warning options are detected and added in
llvm/cmake/modules/HandleLLVMOptions.cmake, e.g. like this:

    check_cxx_compiler_flag("-Wclass-memaccess" CXX_SUPPORTS_CLASS_MEMACCESS_FLAG)
    append_if(CXX_SUPPORTS_CLASS_MEMACCESS_FLAG "-Wno-class-memaccess" CMAKE_CXX_FLAGS)

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

2 years ago[gn build] Port c03d6257c58f
LLVM GN Syncbot [Wed, 6 Apr 2022 19:38:53 +0000 (19:38 +0000)]
[gn build] Port c03d6257c58f

2 years ago[pseudo] Rename DirectiveMap -> DirectiveTree. NFC
Sam McCall [Wed, 6 Apr 2022 15:48:52 +0000 (17:48 +0200)]
[pseudo] Rename DirectiveMap -> DirectiveTree. NFC

Addressing comment from previous review
https://reviews.llvm.org/D121165?id=413636#inline-1160757

2 years ago[LoopInterchange] Try to achieve the most optimal access pattern after interchange
Congzhe Cao [Wed, 6 Apr 2022 19:15:37 +0000 (15:15 -0400)]
[LoopInterchange] Try to achieve the most optimal access pattern after interchange

Motivated by pr43326 (https://bugs.llvm.org/show_bug.cgi?id=43326), where a slightly
modified case is as follows.

 void f(int e[10][10][10], int f[10][10][10]) {
   for (int a = 0; a < 10; a++)
     for (int b = 0; b < 10; b++)
       for (int c = 0; c < 10; c++)
         f[c][b][a] = e[c][b][a];
 }

The ideal optimal access pattern after running interchange is supposed to be the following

 void f(int e[10][10][10], int f[10][10][10]) {
   for (int c = 0;  c < 10; c++)
     for (int b = 0; b < 10; b++)
       for (int a = 0; a < 10; a++)
         f[c][b][a] = e[c][b][a];
 }

Currently loop interchange is limited to picking up the innermost loop and finding an order
that is locally optimal for it. However, the pass failed to produce the globally optimal
loop access order. For more complex examples what we get could be quite far from the
globally optimal ordering.

What is proposed in this patch is to do a "bubble-sort" fashion when doing interchange.
By comparing neighbors in `LoopList` in each iteration, we would be able to move each loop
onto a most appropriate place, hence this is an approach that tries to achieve the
globally optimal ordering.

The motivating example above is added as a test case.

Reviewed By: Meinersbur

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

2 years ago[PS4] Fix a buggy cast
Paul Robinson [Wed, 6 Apr 2022 19:28:36 +0000 (12:28 -0700)]
[PS4] Fix a buggy cast

2 years ago[trace][intelpt] Introduce instruction Ids
Walter Erquinigo [Tue, 22 Mar 2022 16:18:53 +0000 (09:18 -0700)]
[trace][intelpt] Introduce instruction Ids

In order to support quick arbitrary access to instructions in the trace, we need
each instruction to have an id. It could be an index or any other value that the
trace plugin defines.

This will be useful for reverse debugging or for creating callstacks, as each
frame will need an instruction id associated with them.

I've updated the `thread trace dump instructions` command accordingly. It now
prints the instruction id instead of relative offset. I've also added a new --id
argument that allows starting the dump from an arbitrary position.

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

2 years ago[RISCV] Merge rv32/rv64 test files. NFC
Craig Topper [Wed, 6 Apr 2022 19:13:26 +0000 (12:13 -0700)]
[RISCV] Merge rv32/rv64 test files. NFC

2 years agoRevert "gn build: Fix support for building the builtins for baremetal."
Peter Collingbourne [Wed, 6 Apr 2022 19:14:47 +0000 (12:14 -0700)]
Revert "gn build: Fix support for building the builtins for baremetal."

This reverts commit b02b9b3dacc8a4afa96e8990f2dda8bc9b959f78.

Broke Mac build: http://45.33.8.238/macm1/32578/step_4.txt

2 years ago[clang][extract-api] Add Objective-C Category support
Zixu Wang [Thu, 31 Mar 2022 00:21:33 +0000 (17:21 -0700)]
[clang][extract-api] Add Objective-C Category support

Add (partial) support for Objective-C category records in ExtractAPI.
The current ExtractAPI collects everything for an Objective-C category,
but not fully serialized in the SymbolGraphSerializer. Categories
extending external interfaces are disgarded during serialization, and
categories extending known interfaces are merged (all members surfaced)
into the interfaces.

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

2 years agoDebugInfo: Make the simplified template names prefix more unique
David Blaikie [Wed, 6 Apr 2022 18:25:16 +0000 (18:25 +0000)]
DebugInfo: Make the simplified template names prefix more unique

2 years ago[gn build] Port 9fc45ca00a19
LLVM GN Syncbot [Wed, 6 Apr 2022 18:21:38 +0000 (18:21 +0000)]
[gn build] Port 9fc45ca00a19

2 years ago[BOLT][test] Fix X86 tests
Vladislav Khmelevsky [Tue, 5 Apr 2022 15:41:17 +0000 (18:41 +0300)]
[BOLT][test] Fix X86 tests

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

2 years ago[clang][extract-api] Add support for typedefs
Daniel Grumberg [Fri, 1 Apr 2022 18:14:23 +0000 (19:14 +0100)]
[clang][extract-api] Add support for typedefs

Typedef records consist of the symbol associated with the underlying
TypedefDecl and a SymbolReference to the underlying type. Additionally
typedefs for anonymous TagTypes use the typedef'd name as the symbol
name in their respective records and USRs. As a result the declaration
fragments for the anonymous TagType are those for the associated
typedef. This means that when the user is defining a typedef to a
typedef to a anonymous type, we use a reference the anonymous TagType
itself and do not emit the typedef to the anonymous type in the
generated symbol graph, including in the type destination of further
typedef symbol records.

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

2 years ago[clang][DOC] Document module mangler changes
Nathan Sidwell [Thu, 17 Feb 2022 15:36:08 +0000 (07:36 -0800)]
[clang][DOC] Document module mangler changes

Note that the mangling has changed and the demangler's learnt a new
trick.  Obviously dependent upon the mangler and demangler patches.

Reviewed By: bruno

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

2 years ago[NFC][CodeGen] Add comments for SDNode debug ID
Daniil Kovalev [Wed, 6 Apr 2022 18:03:58 +0000 (21:03 +0300)]
[NFC][CodeGen] Add comments for SDNode debug ID

Normally, we place fields serving for debug purpose declarations
under `#if LLVM_ENABLE_ABI_BREAKING_CHECKS`. For `SDNode::PersistentId` and
`SelectionDAG::NextPersistentId`, we do not want to do so because it adds
unneeded complexity without noticeable benefits (see discussion with @thakis
in D120714). This patch adds comments describing why we don't place those
fields under `#if` not to confuse anyone more.

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

2 years agoRevert "[gn build] (manually) port 83a798d4b0e1 (abi_breaking_checks in tests)"
Nico Weber [Wed, 6 Apr 2022 18:02:09 +0000 (14:02 -0400)]
Revert "[gn build] (manually) port 83a798d4b0e1 (abi_breaking_checks in tests)"

This reverts commit edddf384c22b039df8d3a31bbc86f9eb4945a65d.
83a798d4b0e1 was reverted in 62a983ebc570e8ffa3d.

2 years agogn build: Fix support for building the builtins for baremetal.
Peter Collingbourne [Fri, 1 Apr 2022 03:34:05 +0000 (20:34 -0700)]
gn build: Fix support for building the builtins for baremetal.

Our support for building for baremetal was conditional on a default
off arg and would have failed to build if you had somehow arranged
to pass the correct --target flag; presumably nobody noticed because
nobody was turning it on. A better approach is to model baremetal
as a separate "OS" called "baremetal" and build it in the same way
as we cross-compile for other targets. That's what this patch does.
I only hooked up the arm64 target but others can be added.

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

2 years ago[LegalizeTypes][VP] Use LoVT/HiVT when splitting VP operations in SplitVecRes_UnaryOp.
Craig Topper [Wed, 6 Apr 2022 17:49:29 +0000 (10:49 -0700)]
[LegalizeTypes][VP] Use LoVT/HiVT when splitting VP operations in SplitVecRes_UnaryOp.

The VP path was using the split source VTs instead of the split
destination VTs. This may not be a problem today because the VP
nodes going through this have the same source and dest VTs.
It will be a problem when we start using this function for legalizing
VP cast operations.

2 years agoAdd the /nologo flag to llvm-ml
Alan Zhao [Wed, 6 Apr 2022 17:43:02 +0000 (19:43 +0200)]
Add the /nologo flag to llvm-ml

This flag is present in MSVC's ml.exe to suppress copyright info output.
LLVM doesn't output copyright info, so this flag does nothing in
llvm-ml. We still add this flag though so that when llvm-ml is used as a
drop-in replacement for MSVC ml.exe, we don't get any extra warnings.
Furthermore, this behavior is also consistent with other llvm binaries
for Windows (e.g. clang-cl, llvm-mt, lld-link, etc.)

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

2 years ago[clang][extract-api] Fix small issues with SymbolGraphSerializer
Daniel Grumberg [Mon, 4 Apr 2022 16:19:03 +0000 (17:19 +0100)]
[clang][extract-api] Fix small issues with SymbolGraphSerializer

This includes:
- replacing "relationhips" with "relationships"
- emitting the "pathComponents" property on symbols
- emitting the "accessLevel" property on symbols

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

2 years ago[OpenMP] Fix warnings
Hansang Bae [Wed, 6 Apr 2022 16:15:01 +0000 (11:15 -0500)]
[OpenMP] Fix warnings

Silenced compiler warnings after pushing the following change.
https://reviews.llvm.org/D122107

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

2 years agoRevert "[CodeGen] Place SDNode debug ID declaration under appropriate #if"
Daniil Kovalev [Wed, 6 Apr 2022 17:30:51 +0000 (20:30 +0300)]
Revert "[CodeGen] Place SDNode debug ID declaration under appropriate #if"

This reverts commit 83a798d4b0e17ac41d5430f1290d3661343eee1e.

As discussed in D120714 with @thakis, the patch added unneeded complexity
without noticeable benefits.

2 years ago[LegalizeTypes] Move SplitVecRes_VECTOR_REVERSE/VECTOR_SPLICE near other SplitVecRes...
Craig Topper [Wed, 6 Apr 2022 17:19:18 +0000 (10:19 -0700)]
[LegalizeTypes] Move SplitVecRes_VECTOR_REVERSE/VECTOR_SPLICE near other SplitVecRes methods. NFC

This file is divided into sections for different legalization actions.
We should keep similar methods together.

2 years ago[AArch64] Format the PerfectShuffle table. NFC
David Green [Wed, 6 Apr 2022 17:27:57 +0000 (18:27 +0100)]
[AArch64] Format the PerfectShuffle table. NFC

2 years ago[demangler] Fix undocumented Local encoding
Nathan Sidwell [Tue, 5 Apr 2022 16:25:47 +0000 (09:25 -0700)]
[demangler] Fix undocumented Local encoding

GCC emits [some] static symbols with an 'L' mangling, which we attempt
to demangle.  But the module mangling changes have exposed that we
were doing so at the wrong level.  Such manglings are outside of the
ABI as they are internal-linkage, so a bit of reverse engineering was
needed.  This adjusts the demangler along the same lines as the
existing gcc demangler (which is not yet module-aware).  'L' is part
of an unqualified name.  As before we merely parse the 'L', and then
ignore it.

Reviewed By: iains

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

2 years ago[LegalizeDAG] Use SelectionDAG::getBoolConstant to simplify some code. NFC
Craig Topper [Wed, 6 Apr 2022 17:06:55 +0000 (10:06 -0700)]
[LegalizeDAG] Use SelectionDAG::getBoolConstant to simplify some code. NFC

2 years ago[RISCV] Add lowering for vp.sext and vp.zext.
Craig Topper [Wed, 6 Apr 2022 16:16:20 +0000 (09:16 -0700)]
[RISCV] Add lowering for vp.sext and vp.zext.

Including mask vector inputs.

Reviewed By: frasercrmck, rogfer01

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

2 years ago[DAGCombiner] Replace call getSExtOrTrunc with a truncate. NFC
Craig Topper [Wed, 6 Apr 2022 16:14:51 +0000 (09:14 -0700)]
[DAGCombiner] Replace call getSExtOrTrunc with a truncate. NFC

The extend case should never occur. The sign extend would be an
arbitrary choice, remove it to avoid confusion.

2 years ago[test][DSE] Precommit test for D123162
Arthur Eubanks [Tue, 5 Apr 2022 21:50:44 +0000 (14:50 -0700)]
[test][DSE] Precommit test for D123162

2 years ago[X86] Add Issue #42433 test case
Simon Pilgrim [Wed, 6 Apr 2022 16:51:47 +0000 (17:51 +0100)]
[X86] Add Issue #42433 test case

2 years ago[dsymutil] Fix a few TODOs about reporting errors to the user
Nico Weber [Wed, 6 Apr 2022 13:23:25 +0000 (09:23 -0400)]
[dsymutil] Fix a few TODOs about reporting errors to the user

I saw the TODOs while reading this file and figured I'd do them.
I haven't seen these happen in practice.

No expected behavior change.

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

2 years ago[dsymutil] Fix O(n^2) behavior when running on ld64.lld's current ICF output
Nico Weber [Wed, 6 Apr 2022 13:30:39 +0000 (09:30 -0400)]
[dsymutil] Fix O(n^2) behavior when running on ld64.lld's current ICF output

STABS information consists of a list of records in the linked binary
that look like this:

  OSO: path/to/some.o
  SO: path/to/some.c
  FUN: sym1
  FUN: sym2
  ...

The linked binary has one such set of records for every .o file linked
into it.

When dsymutil processes the binary's STABS information, it:

1. Reads the .o file mentioned in the OSO line
2. For each FUN entry after it in the main executable's STABS info:
  a) it looks up that symbol in the symbol of that .o file
  b) if it doesn't find it there, it goes through all symbols in the
     main binary at the same address and sees if any of those match

With ICF, ld64.lld's STABS output claims that all identical functions
that were folded are in the .o file of the one that's deemed the
canonical one. Many small functions might be folded into a single
function, so there are .o OSO entries that end up with many FUN lines,
but almost none of them exist in the .o file's symbol table.

Previously, dsymutil would do a full scan of all symbols in the main
executable _for every of these entries_.

This patch instead scans all aliases once and remembers them per name.
This reduces the alias resolution complexity from
O(number_of_aliases_in_o_file * number_of_symbols_in_main_executable) to
O(number_of_aliases_in_o_file * log(number_of_aliases_in_o_file)).

In practice, it reduces the time spent to run dsymutil on
Chromium Framework from 26 min (after https://reviews.llvm.org/D89444)
or 12 min (before https://reviews.llvm.org/D89444) to ~8m30s.

We probably want to change how ld64.lld writes STABS entries when ICF
is enabled, but making dsymutil not have pathological performance for
this input seems like a good change as well.

No expected behavior change (other than it's faster). I verified that
for Chromium Framework, the generated .dSYM is identical with and
without this patch.

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

2 years ago[DAGCombine] insert_subvector undef, (splat X), N2 -> splat X
Paul Walker [Tue, 22 Feb 2022 15:20:28 +0000 (15:20 +0000)]
[DAGCombine] insert_subvector undef, (splat X), N2 -> splat X

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

2 years ago[RISCV][VP] Add basic RVV codegen for vp.icmp
Fraser Cormack [Wed, 30 Mar 2022 16:01:30 +0000 (17:01 +0100)]
[RISCV][VP] Add basic RVV codegen for vp.icmp

This patch adds the minimum required to successfully lower vp.icmp via
the new ISD::VP_SETCC node to RVV instructions.

Regular ISD::SETCC goes through a lot of canonicalization which targets
may rely on which has not hereto been ported to VP_SETCC. It also
supports expansion of individual condition codes and a non-boolean
return type. Support for all of that will follow in later patches.

In the case of RVV this largely isn't a problem as the vector integer
comparison instructions are plentiful enough that it can lower all
VP_SETCC nodes on legal integer vectors except for boolean vectors,
which regular SETCC folds away immediately into logical operations.

Floating-point VP_SETCC operations aren't as well supported in RVV and
the backend relies on condition code expansion, so support for those
operations will come in later patches.

Portions of this code were taken from the VP reference patches.

Reviewed By: craig.topper

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

2 years ago[gn build] Port d78624975b43
LLVM GN Syncbot [Wed, 6 Apr 2022 15:52:20 +0000 (15:52 +0000)]
[gn build] Port d78624975b43

2 years ago[mlir][bufferize][NFC] Remove caller map and ordered func list from FuncAnalysisState
Matthias Springer [Wed, 6 Apr 2022 14:42:53 +0000 (23:42 +0900)]
[mlir][bufferize][NFC] Remove caller map and ordered func list from FuncAnalysisState

These can be local variables. No need to store them in the struct.

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

2 years ago[mlir][bufferize][NFC] Rename ModuleAnalysisState to FuncAnalysisState
Matthias Springer [Wed, 6 Apr 2022 14:42:31 +0000 (23:42 +0900)]
[mlir][bufferize][NFC] Rename ModuleAnalysisState to FuncAnalysisState

This is for consistency reasons. `*AnalysisState` always starts with the name of the dialect.

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

2 years ago[libc++] Use cpp20_output_iterator in tests.
Mark de Wever [Tue, 5 Apr 2022 16:34:37 +0000 (18:34 +0200)]
[libc++] Use cpp20_output_iterator in tests.

Adds the new cpp20_output_iterator in the ranges::transform test.

Reviewed By: philnik, #libc

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

2 years ago[NFC][libc++] Modularize chrono's calendar.
Mark de Wever [Sun, 3 Apr 2022 13:58:57 +0000 (15:58 +0200)]
[NFC][libc++] Modularize chrono's calendar.

The is a followup of D116965 to split the calendar header. This is a
preparation to add the formatters for the chrono header.

The code is only moved no other changes have been made.

Reviewed By: ldionne, #libc, philnik

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

2 years ago[MLIR][Presburger] Refactor subtraction in preparation for making it iterative
Arjun P [Wed, 6 Apr 2022 13:52:30 +0000 (14:52 +0100)]
[MLIR][Presburger] Refactor subtraction in preparation for making it iterative

Refactor the operation of subtraction by
- removing the usage of SimplexRollbackScopeExit since this
  can't be used in the iterative version
- reducing the number of stack variables to make the
  iterative version easier to follow

Reviewed By: Groverkss

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

2 years ago[X86] `lowerBuildVectorAsBroadcast()`: with AVX512VL, allow i64->XMM broadcasts from...
Roman Lebedev [Wed, 6 Apr 2022 14:32:31 +0000 (17:32 +0300)]
[X86] `lowerBuildVectorAsBroadcast()`: with AVX512VL, allow i64->XMM broadcasts from constant pool

Reviewed By: RKSimon

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

2 years ago[pseudo] Add crude heuristics to choose taken preprocessor branches.
Sam McCall [Mon, 7 Mar 2022 22:33:40 +0000 (23:33 +0100)]
[pseudo] Add crude heuristics to choose taken preprocessor branches.

In files where different preprocessing paths are possible, our goal is to
choose a preprocessed token sequence which we can parse that pins down as much
of the grammatical structure as possible.
This forms the "primary parse", and the not-taken branches get parsed later,
and are constrained to be compatible with the primary parse.

Concretely:
  int x =
    #ifdef // TAKEN
      2 + 2 + 2 // determined during primary parse to be an expression
    #else
      2 // constrained to be an expression during a secondary parse
    #endif
    ;

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

2 years ago[mlir][bufferize] Better analysis for return values of CallOps
Matthias Springer [Wed, 6 Apr 2022 14:41:56 +0000 (23:41 +0900)]
[mlir][bufferize] Better analysis for return values of CallOps

Support returning arbitrary tensors from functions. Even those that are
not equivalent. To that end, additional information is gathered during
the analysis phase. In particular, which function args are aliasing with
which return values.

Also fix bugs in the current implementation when returning equivalent
tensors. Various unit tests are added to ensure that we have better test
coverage.

Note: Returning non-equivalent tensors is only allowed when
allowReturnAllocs is enabled. This functionality is useful for unit
testing and compatibility with other bufferizations such as the sparse
compiler. This is also towards using ModuleBufferization as a
replacement for --func-bufferize.

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

2 years ago[mlir][bufferize] Simplify ModuleBufferization driver
Matthias Springer [Wed, 6 Apr 2022 14:41:33 +0000 (23:41 +0900)]
[mlir][bufferize] Simplify ModuleBufferization driver

* Bufferize FuncOp bodies and boundaries in the same loop. This is in preparation of moving FuncOp bufferization into an external model implementation.
* As a side effect, stop bufferization earlier if there was an error. (Do not continue bufferization, fewer error messages.)
* Run equivalence analysis of CallOps before the main analysis. This is needed so that equialvence info is propagated properly.

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

2 years ago[mlir][bufferize] Fix dropped return type in ModuleBufferization
Matthias Springer [Wed, 6 Apr 2022 14:40:59 +0000 (23:40 +0900)]
[mlir][bufferize] Fix dropped return type in ModuleBufferization

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

2 years ago[NFC] Remove redundant IndexType canonicalisation from DAGTypeLegalizer::PromoteIntOp...
Paul Walker [Wed, 6 Apr 2022 13:58:38 +0000 (14:58 +0100)]
[NFC] Remove redundant IndexType canonicalisation from DAGTypeLegalizer::PromoteIntOp_MSCATTER

Promotion does not affect the base element type and so the original
index type will remain unchanged.  This reflects the behaviour of
DAGTypeLegalizer::PromoteIntOp_MGATHER with no tests affected.

2 years ago[SVE] Add gather/scatter tests to highlight bugs in their generated code.
Paul Walker [Wed, 6 Apr 2022 12:45:26 +0000 (13:45 +0100)]
[SVE] Add gather/scatter tests to highlight bugs in their generated code.

2 years ago[gn build] Port afa94306a8c1
LLVM GN Syncbot [Wed, 6 Apr 2022 14:24:39 +0000 (14:24 +0000)]
[gn build] Port afa94306a8c1

2 years ago[clangd] Add code action to generate a constructor for a C++ class
Sam McCall [Mon, 3 Jan 2022 02:57:14 +0000 (03:57 +0100)]
[clangd] Add code action to generate a constructor for a C++ class

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

2 years ago[gn build] Port 68eac9a6e7a1
LLVM GN Syncbot [Wed, 6 Apr 2022 14:15:16 +0000 (14:15 +0000)]
[gn build] Port 68eac9a6e7a1

2 years ago[clangd] Code action to declare missing move/copy constructor/assignment
Sam McCall [Sun, 2 Jan 2022 04:01:43 +0000 (05:01 +0100)]
[clangd] Code action to declare missing move/copy constructor/assignment

Fixes https://github.com/clangd/clangd/issues/973

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

2 years ago[X86][tablgen] Add one entry manually into the memory folding table
Shengchen Kan [Wed, 6 Apr 2022 14:01:56 +0000 (22:01 +0800)]
[X86][tablgen] Add one entry manually into the memory folding table

```
{"MMX_MOVD64grr", "MMX_MOVD64mr"}
```
This pair has different opcodes.

2 years ago[AArch64] Fold lsr+bfi in tryBitfieldInsertOpFromOr
chenglin.bi [Wed, 6 Apr 2022 13:17:42 +0000 (21:17 +0800)]
[AArch64] Fold lsr+bfi in tryBitfieldInsertOpFromOr

In tryBitfieldInsertOpFromOr, if the new created LSR Node's source
is LSR with Imm shift, try to fold them.

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

Reviewed By: efriedma, benshi001

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

2 years ago[SimplifyLibCalls] Use KnownBits helper APIs (NFC)
Nikita Popov [Wed, 6 Apr 2022 13:59:42 +0000 (15:59 +0200)]
[SimplifyLibCalls] Use KnownBits helper APIs (NFC)

Use helper APIs for isNonNegative() and getMaxValue() instead of
flipping the zero value and having a long comment explaining why
that is necessary.

2 years ago[PS4] clang-format PS4CPU.cpp/.h
Paul Robinson [Wed, 6 Apr 2022 13:52:13 +0000 (06:52 -0700)]
[PS4] clang-format PS4CPU.cpp/.h

2 years agoMemoryBuiltins: getAllocAlignment is now useful for non-allocator funcs
Augie Fackler [Mon, 14 Mar 2022 19:21:04 +0000 (15:21 -0400)]
MemoryBuiltins: getAllocAlignment is now useful for non-allocator funcs

This has been true since dba73135c8b7a02afb535328a7475e0a6890c271, but
didn't matter until now because clang wasn't emitting allocalign
attributes.

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

2 years ago[AMDGPU] Fix unused variable warning after D117484
Jay Foad [Wed, 6 Apr 2022 13:45:38 +0000 (14:45 +0100)]
[AMDGPU] Fix unused variable warning after D117484

2 years ago[flang] Add runtime API to catch unit number out of range
Jean Perier [Wed, 6 Apr 2022 13:37:48 +0000 (15:37 +0200)]
[flang] Add runtime API to catch unit number out of range

Unit numbers must fit on a default integer. It is however possible that
the user provides the unit number in UNIT with a wider integer type.
In such case, lowering was previously silently narrowing
the value and passing the result to the BeginXXX runtime entry points.
Cases where the conversion caused overflow were not reported/caught.
Most existing compilers catch these errors and raise an IO error.
Add a CheckUnitNumberInRange runtime API to do the same in f18.

This runtime API has its own error management interface (i.e., does not
use GetIoMsg, EndIo, and EnableHandlers) because the usual error
management requires BeginXXX to be called to set up the error
management. But in this case, the BeginXXX cannot be called since
the bad unit number that would be provided to it overflew (and in the worst
case scenario, the narrowed value could point to a different valid unit
already in use). Hence I decided to make an API that must be called
before the BeginXXX and should trigger the whole BeginXXX/.../EndIoStatement
to be skipped in case the unit number is too big and the user enabled
error recovery.

Note that CheckUnitNumberInRange accepts negative numbers (as long as
they can fit on a default integer), because unit numbers may be negative
if they were created by NEWUNIT.

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

2 years ago[X86] Fold MMX_MOVD64from64rr + store to MMX_MOVQ64mr instead of MMX_MOVD64from64mr...
Shengchen Kan [Wed, 6 Apr 2022 13:32:30 +0000 (21:32 +0800)]
[X86] Fold MMX_MOVD64from64rr + store to MMX_MOVQ64mr instead of MMX_MOVD64from64mr in auto-generated table

This is a follow-up patch for D122241.