platform/upstream/llvm.git
2 years ago[Docs] Update opaque pointers docs (NFC)
Nikita Popov [Tue, 5 Apr 2022 10:09:10 +0000 (12:09 +0200)]
[Docs] Update opaque pointers docs (NFC)

Point people to the cc1 instead of the mllvm flag, as the mllvm
flag will stop working for clang usage at some point.

Update transition state to mention that support in Clang/LLVM is
complete, and only the default switch is pending.

2 years ago[AArch64] Make PMMIR_EL1 read-only.
Simon Tatham [Tue, 5 Apr 2022 10:09:51 +0000 (11:09 +0100)]
[AArch64] Make PMMIR_EL1 read-only.

The Arm architecture reference manual (ARM DDI 0487H.a section
D13.5.12) lists every field in the register as RO, and does not list
an MSR instruction that writes it. So we should be defining it as an
ROSysReg, not an RWSysReg.

Reviewed By: vhscampos

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

2 years ago[Test] Use cc1 instead of mllvm -opaque-pointers option (NFC)
Nikita Popov [Tue, 5 Apr 2022 10:04:48 +0000 (12:04 +0200)]
[Test] Use cc1 instead of mllvm -opaque-pointers option (NFC)

2 years ago[LLVMContext] Replace enableOpaquePointers() with setOpaquePointers()
Nikita Popov [Tue, 5 Apr 2022 09:36:06 +0000 (11:36 +0200)]
[LLVMContext] Replace enableOpaquePointers() with setOpaquePointers()

This allows both explicitly enabling and explicitly disabling
opaque pointers, in anticipation of the default switching at some
point.

This also slightly changes the rules by allowing calls if either
the opaque pointer mode has not yet been set (explicitly or
implicitly) or if the value remains unchanged.

2 years agoRemove libc++ test from clang lib.
Benjamin Kramer [Tue, 5 Apr 2022 09:33:55 +0000 (11:33 +0200)]
Remove libc++ test from clang lib.

This was added in 3ba8548c8e04bb301c4243887362c54bfbd4af8b

2 years ago[CodeGen] Avoid unnecessary ConstantExpr cast
Nikita Popov [Tue, 5 Apr 2022 09:18:33 +0000 (11:18 +0200)]
[CodeGen] Avoid unnecessary ConstantExpr cast

With opaque pointers, this is not necessarily a ConstantExpr. And
we don't need one here either, just Constant is sufficient.

2 years ago[mlir] Update BUILD.bazel.
Alexander Belyaev [Tue, 5 Apr 2022 09:25:29 +0000 (11:25 +0200)]
[mlir] Update BUILD.bazel.

2 years agoRemove top-level using directives from Transforms/IPO headers
Pavel Labath [Tue, 15 Mar 2022 13:20:44 +0000 (14:20 +0100)]
Remove top-level using directives from Transforms/IPO headers

These directives pollute the namespace of all files which include the
header.

2 years ago[lldb] Avoid duplicate vdso modules when opening core files
Pavel Labath [Tue, 29 Mar 2022 08:47:32 +0000 (10:47 +0200)]
[lldb] Avoid duplicate vdso modules when opening core files

When opening core files (and also in some other situations) we could end
up with two vdso modules. This could happen because the vdso module is
very special, and over the years, we have accumulated various ways to
load it.

In D10800, we added one mechanism for loading it, which took the form of
a generic load-from-memory capability. Unfortunately loading an elf file
from memory is not possible (because the loader never loads the entire
file), and our attempts to do so were causing crashes. So, in D34352, we
partially reverted D10800 and implemented a custom mechanism specific to
the vdso.

Unfortunately, enough of D10800 remained such that, under the right
circumstances, it could end up loading a second (non-functional) copy of
the vdso module. This happened when the process plugin did not support
the extended MemoryRegionInfo query (added in D22219, to workaround a
different bug), which meant that the loader plugin was not able to
recognise that the linux-vdso.so.1 module (this is how the loader calls
it) is in fact the same as the [vdso] module (the name used in
/proc/$PID/maps) we loaded before. This typically happened in a core
file, as they don't store this kind of information.

This patch fixes the issue by completing the revert of D10800 -- the
memory loading code is removed completely. It also reduces the scope of
the hackaround introduced in D22219 -- it isn't completely sound and is
only relevant for fairly old (but still supported) versions of android.

I added the memory loading logic to the wasm dynamic loader, which has
since appeared and is relying on this feature (it even has a test). As
far as I can tell loading wasm modules from memory is possible and
reliable. MachO memory loading is not affected by this patch, as it uses
a completely different code path.

Since the scenarios/patches I described came without test cases, I have
created two new gdb-client tests cases for them. They're not
particularly readable, but right now, this is the best way we can
simulate the behavior (bugs) of a particular dynamic linker.

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

2 years ago[lldb/linux] Handle main thread exits
Pavel Labath [Wed, 30 Mar 2022 09:40:34 +0000 (11:40 +0200)]
[lldb/linux] Handle main thread exits

This patch handles the situation where the main thread exits (through
the SYS_exit syscall). In this case, the process as a whole continues
running until all of the other threads exit, or one of them issues an
exit_group syscall.

The patch consists of two changes:
- a moderate redesign of the handling of thread exit (WIFEXITED) events.
  Previously, we were removing (forgetting) a thread once we received
  the WIFEXITED (or WIFSIGNALED) event. This was problematic for the
  main thread, since the main thread WIFEXITED event (which is better thought
  of as a process-wide event) gets reported only after the entire process
  exits. This resulted in deadlocks, where we were waiting for the
  process to stop (because we still considered the main thread "live").

  This patch changes the logic such that the main thread is removed as
  soon as its PTRACE_EVENT_EXIT (the pre-exit) event is received. At
  this point we can consider the thread gone (for most purposes). As a
  corrolary, I needed to add special logic to catch process-wide exit
  events in the cases where we don't have the main thread around.

- The second part of the patch is the removal of the assumptions that
  the main thread is always available. This generally meant replacing
  the uses of GetThreadByID(process_id) with GetCurrentThread() in
  various process-wide operations (such as memory reads).

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

2 years ago[lldb] Move host platform implementations into the base class
Pavel Labath [Fri, 1 Apr 2022 12:38:55 +0000 (14:38 +0200)]
[lldb] Move host platform implementations into the base class

About half of our host platform code was implemented in the Platform
class, while the rest was it RemoteAwarePlatform. Most of the time, this
did not matter, as nearly all our platforms are also
RemoteAwarePlatforms. It makes a difference for PlatformQemu, which
descends directly from the base class (as it is local-only).

This patch moves all host code paths into the base class, and marks
PlatformQemu as a "host" platform so it can make use of them (it sounds
slightly strange, but that is consistent with what the apple simulator
platforms are doing). Not all of the host implementations make sense for
this platform, but it can always override those that don't.

I add some basic tests using the platform file apis to exercise this
functionality.

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

2 years ago[gn build] Port 3ba8548c8e04
LLVM GN Syncbot [Tue, 5 Apr 2022 09:06:48 +0000 (09:06 +0000)]
[gn build] Port 3ba8548c8e04

2 years ago[libc++][ranges] Implement ranges::transform
Nikolas Klauser [Tue, 5 Apr 2022 09:05:36 +0000 (11:05 +0200)]
[libc++][ranges] Implement ranges::transform

Reviewed By: ldionne, var-const, #libc

Spies: libcxx-commits, mgorny

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

2 years ago[Scudo] enabling anonymous named pages on Linux 5.17 and onwards.
David Carlier [Tue, 5 Apr 2022 08:46:02 +0000 (09:46 +0100)]
[Scudo] enabling anonymous named pages on Linux 5.17 and onwards.

Reviewers: vitalybuka

Reviewed-By: vitalybuka
Differential Revision: https://reviews.llvm.org/D122962

2 years ago[mlir][ods] Add description to Attr and ensure doc generation
Alex Zinenko [Mon, 4 Apr 2022 12:24:54 +0000 (14:24 +0200)]
[mlir][ods] Add description to Attr and ensure doc generation

Add the description textual field to the Attr ODS class to mirror an
identical field in the Type ODS class. Add support for generating
documentation for attribute constraints defined using this field. This
ensures mlir-tblgen produces at least some documentation for dialects
that only define attribute constraints, such as DLTI.

Reviewed By: rriddle

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

2 years ago[gn build] Port 0320115c16fc
LLVM GN Syncbot [Tue, 5 Apr 2022 08:34:08 +0000 (08:34 +0000)]
[gn build] Port 0320115c16fc

2 years ago[LibCalls] Respect TLI.getExtAttrForI32Param() in inferLibFuncAttributes().
Jonas Paulsson [Tue, 5 Apr 2022 07:55:43 +0000 (09:55 +0200)]
[LibCalls] Respect TLI.getExtAttrForI32Param() in inferLibFuncAttributes().

getExtAttrForI32Param() is the method to be used for determining the type of
extension attribute (if any) that is to be added for a signed/unsigned
argument.

Previously, the SExt attribute was always added to the i32 ldexp* argument as
it was expected to be ignored by targets not needing it. This patch now
changes this so that it is only added for the targets that need it in the
first place.

Putchar() argument is now also extended as required by the target (SystemZ in
the test), to fix the issue below. Many more libcalls will be handled
similarly in a following patch.

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

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

Review: Eli Friedman

2 years ago[flang][cmake] Make CMake copy "omp_lib.h" into the build directory
Andrzej Warzynski [Fri, 18 Mar 2022 16:20:56 +0000 (16:20 +0000)]
[flang][cmake] Make CMake copy "omp_lib.h" into the build directory

Any header or module file in the Flang source directory is of no use to
the compiler unless it is copied into the build directory. Indeed, all
compiler search paths are relative to the compiler executable (flang-new
in our case). Hence, "omp_lib.h" should be copied into the build
directory alongside other compiler-provided files that can be "included"
(header files) or "used" (module files).

For now, "omp_lib.h" is copied into "<build-dir>/include/flang/OpenMP".
We may decide to change this in future. For example, Clang copies a
bunch of runtime headers into “<build-dir>/lib/clang/<version-number>”.
We could also consider using a similar header from a different
sub-project.

Flang's driver search path is updated accordingly. A rule for
"installing" the "omp_lib.h" header is _yet to be added_ (we will also
need to determine the suitable location for this).

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

2 years agoApply clang-tidy fixes for readability-redundant-control-flow in FuncToLLVM.cpp ...
Mehdi Amini [Sun, 3 Apr 2022 22:17:39 +0000 (22:17 +0000)]
Apply clang-tidy fixes for readability-redundant-control-flow in FuncToLLVM.cpp (NFC)

2 years ago[OpaquePtrs][Clang] Add -opaque-pointers/-no-opaque-pointers cc1 options
Nikita Popov [Mon, 4 Apr 2022 14:58:42 +0000 (16:58 +0200)]
[OpaquePtrs][Clang] Add -opaque-pointers/-no-opaque-pointers cc1 options

This adds cc1 options for enabling and disabling opaque pointers
on the clang side. This is not super useful now (because
-mllvm -opaque-pointers and -Xclang -opaque-pointers have the same
visible effect) but will be important once opaque pointers are
enabled by default in clang. In that case, it will only be
possible to disable them using the cc1 -no-opaque-pointers option.

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

2 years ago[mlir] Update mlir/BUILD.bazel.
Alexander Belyaev [Tue, 5 Apr 2022 08:14:28 +0000 (10:14 +0200)]
[mlir] Update mlir/BUILD.bazel.

2 years agoRevert "[CodeGen] Async unwind - add a pass to fix CFI information"
Muhammad Omair Javaid [Tue, 5 Apr 2022 08:09:42 +0000 (13:09 +0500)]
Revert "[CodeGen] Async unwind - add a pass to fix CFI information"

This reverts commit 980c3e6dd223a8e628367144b8180117950bb364.

This commit had failing tests with clang crashing across various
AArch64/Linux buildots.

https://lab.llvm.org/buildbot/#/builders/179/builds/3346

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

2 years ago[mlir] Rewrite canonicalization of collapse(expand) and expand(collapse).
Alexander Belyaev [Fri, 1 Apr 2022 15:24:14 +0000 (17:24 +0200)]
[mlir] Rewrite canonicalization of collapse(expand) and expand(collapse).

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

2 years ago[mlir] Fix 1 ClangTidyPerformance finding (NFC)
Adrian Kuegel [Tue, 5 Apr 2022 07:28:42 +0000 (09:28 +0200)]
[mlir] Fix 1 ClangTidyPerformance finding (NFC)

2 years ago[CodeGen][NFC] Hoist budget check out of loop
Max Kazantsev [Tue, 5 Apr 2022 07:10:00 +0000 (14:10 +0700)]
[CodeGen][NFC] Hoist budget check out of loop

Less computations & early exit if we know for sure that the limit will be exceeded.

2 years agoAn attempt to fix problem with building
Evgeniy Brevnov [Tue, 5 Apr 2022 07:09:55 +0000 (14:09 +0700)]
An attempt to fix problem with building
Transforms/Utils/MemTransferLowerTest

2 years agoRevert rG5adc94bb8a23eb819f6ca80e722f5b0e6e41401d "New regression test against expand...
Simon Pilgrim [Tue, 5 Apr 2022 07:11:21 +0000 (08:11 +0100)]
Revert rG5adc94bb8a23eb819f6ca80e722f5b0e6e41401d "New regression test against expandMemCpyAsLoop utility"

This was causing link errors on buildbots (and locally)

2 years ago[lldb][gui] make 'step out' step out of the selected frame
Luboš Luňák [Sun, 3 Apr 2022 18:19:10 +0000 (20:19 +0200)]
[lldb][gui] make 'step out' step out of the selected frame

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

2 years ago[lldb][gui] use just '#2' instead of 'frame #2' in the threads/frame view
Luboš Luňák [Sun, 3 Apr 2022 13:25:10 +0000 (15:25 +0200)]
[lldb][gui] use just '#2' instead of 'frame #2' in the threads/frame view

Since the threads/frame view is taking only a small part on the right side
of the screen, only a part of the function name of each frame is visible.
It seems rather wasteful to spell out 'frame' there when it's obvious
that it is a frame, it's better to use the space for more of the function
name.

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

2 years ago[lldb][gui] do not show the help window on first gui startup
Luboš Luňák [Thu, 30 Jul 2020 15:24:39 +0000 (17:24 +0200)]
[lldb][gui] do not show the help window on first gui startup

It's rather annoying if it's there after every startup,
and that 'Help (F6)' at the top should be enough to help people
who don't know.

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

2 years ago[BOLT][test] Fix AArch64 test
Maksim Panchenko [Tue, 5 Apr 2022 06:20:32 +0000 (23:20 -0700)]
[BOLT][test] Fix AArch64 test

Remove header dependency from cross-platform test.

Reviewed By: yota9

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

2 years agoNew regression test against expandMemCpyAsLoop utility
Evgeniy Brevnov [Wed, 26 Jan 2022 13:29:08 +0000 (20:29 +0700)]
New regression test against expandMemCpyAsLoop utility

Unit test for functionality going to be added by D118441

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

2 years ago[M68k] Adopt VarLenCodeEmitter for move instructions
Min-Yih Hsu [Sat, 18 Dec 2021 12:09:19 +0000 (20:09 +0800)]
[M68k] Adopt VarLenCodeEmitter for move instructions

The `move` instruction has one of the most complicate sets of variants, so
we're refactoring it first before finishing up rest of the data
instructions in a separate patch.

Note that since we're introducing more `move` variants, the codegen
actually got improved in terms of code size.

2 years ago[BOLT][test] Enable cross-target testing
Maksim Panchenko [Tue, 5 Apr 2022 05:30:18 +0000 (22:30 -0700)]
[BOLT][test] Enable cross-target testing

Check for supported target architecture instead of the host arch when
deciding to execute non-runtime tests.

Reviewed By: Amir

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

2 years ago[BOLT][test] Fix X86 cross-platform tests
Maksim Panchenko [Tue, 5 Apr 2022 01:01:10 +0000 (18:01 -0700)]
[BOLT][test] Fix X86 cross-platform tests

Use target-specific flags for building X86 non-runnable tests.

Reviewed By: Amir

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

2 years ago[RISCV] Remove redundant enabling of IAS for Clang, NFC
Brad Smith [Tue, 5 Apr 2022 03:38:18 +0000 (23:38 -0400)]
[RISCV] Remove redundant enabling of IAS for Clang, NFC

Generic_GCC::IsIntegratedAssemblerDefault() already takes care of RISCV.

Reviewed By: kito-cheng, MaskRay

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

2 years ago[X86] Improve x86-partial-reduction to support abs intrinsic
Wei Xiao [Wed, 30 Mar 2022 15:27:17 +0000 (23:27 +0800)]
[X86] Improve x86-partial-reduction to support abs intrinsic

Current implementation only recognizes absolute operation implemented by
select instruction. This patch adds support for abs intrinsic.

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

2 years ago[mlir][sparse] Factoring out `finalizeSegment` and (generic) `appendIndex`
wren romano [Mon, 4 Apr 2022 23:37:38 +0000 (16:37 -0700)]
[mlir][sparse] Factoring out `finalizeSegment` and (generic) `appendIndex`

This change introduces two new methods: `finalizeSegment` and `appendIndex`; and removes three old methods: `endDim`, `appendCurrentPointer`, `appendIndex`.  The two new methods better encapsulate their algorithms, thus allowing to remove repetitious code in several other places.

Depends On D122435

Reviewed By: aartbik

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

2 years ago[modules] Merge ObjC interface ivars with anonymous types.
Volodymyr Sapsai [Sat, 29 Jan 2022 01:08:21 +0000 (17:08 -0800)]
[modules] Merge ObjC interface ivars with anonymous types.

Without the fix ivars with anonymous types can trigger errors like

> error: 'TestClass::structIvar' from module 'Target' is not present in definition of 'TestClass' provided earlier
> [...]
> note: declaration of 'structIvar' does not match

It happens because types of ivars from different modules are considered
to be different. And it is caused by not merging anonymous `TagDecl`
from different modules.

To fix that I've changed `serialization::needsAnonymousDeclarationNumber`
to handle anonymous `TagDecl` inside `ObjCInterfaceDecl`. But that's not
sufficient as C code inside `ObjCInterfaceDecl` doesn't use interface
decl as a decl context but switches to its parent (TranslationUnit in
most cases).  I'm changing that to make `ObjCContainerDecl` the lexical
decl context but keeping the semantic decl context intact.

Test "check-dup-decls-inside-objc.m" doesn't reflect a change in
functionality but captures the existing behavior to prevent regressions.

rdar://85563013

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

2 years ago[docs] Add Loop Opt WG meeting ics.
Michael Kruse [Tue, 5 Apr 2022 01:06:37 +0000 (20:06 -0500)]
[docs] Add Loop Opt WG meeting ics.

Add ics file for biweekly loop optimization meeting.

Reviewed By: #loopoptwg, bmahjour

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

2 years agoRevert "[MLIR][Presburger] IntegerPolyhedron: add support for symbolic integer lexmin"
Arjun P [Mon, 4 Apr 2022 23:31:17 +0000 (00:31 +0100)]
Revert "[MLIR][Presburger] IntegerPolyhedron: add support for symbolic integer lexmin"

This reverts commit da92f92621e28a56fe8ad79d82eb60e436bf1d39.

2 years ago[MLIR][Presburger] IntegerPolyhedron: add support for symbolic integer lexmin
Arjun P [Mon, 4 Apr 2022 22:31:28 +0000 (23:31 +0100)]
[MLIR][Presburger] IntegerPolyhedron: add support for symbolic integer lexmin

Add support for computing the symbolic integer lexmin of a polyhedron.
This finds, for every assignment to the symbols, the lexicographically
minimum value attained by the dimensions. For example, the symbolic lexmin
of the set

`(x, y)[a, b, c] : (a <= x, b <= x, x <= c)`

can be written as

```
x = a if b <= a, a <= c
x = b if a <  b, b <= c
```

This also finds the set of assignments to the symbols that make the lexmin unbounded.

Reviewed By: Groverkss

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

2 years ago[AArch64] Alter mull buildvectors(ext(..)) combine to work on shuffles
David Green [Mon, 4 Apr 2022 22:07:47 +0000 (23:07 +0100)]
[AArch64] Alter mull buildvectors(ext(..)) combine to work on shuffles

D120018 altered this combine to work on buildvectors as opposed to
shuffle dup's. This works well for dups and other things that are
expanded into buildvectors. Some shuffles are legal though, and stay as
vector_shuffle through lowering. This expands the transform to also
handle shuffles, so that we can turn mul(shuffle(sext into
mul(sext(shuffle and more readily make smull/umull instructions. This
can come up from the SLP vectorizer adding shuffles that are costed from
extends.

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

2 years ago[AArch64] Add some tests for mul(shuffle(ext. NFC
David Green [Mon, 4 Apr 2022 21:51:45 +0000 (22:51 +0100)]
[AArch64] Add some tests for mul(shuffle(ext. NFC

2 years ago[libc++] Implement tests for private headers using the new generator
Louis Dionne [Fri, 25 Mar 2022 21:38:04 +0000 (17:38 -0400)]
[libc++] Implement tests for private headers using the new generator

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

2 years ago[mlir] Add MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID to SerializeToCubinPass
River Riddle [Mon, 4 Apr 2022 21:28:10 +0000 (14:28 -0700)]
[mlir] Add MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID to SerializeToCubinPass

This pass is defined in an anonymous namespace and requires an explicit TypeID

2 years ago[mlir][spirv] Check nullptr before usage to fix crash
Lei Zhang [Mon, 4 Apr 2022 21:19:44 +0000 (17:19 -0400)]
[mlir][spirv] Check nullptr before usage to fix crash

Reviewed By: mravishankar, hanchung

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

2 years agoAdd DumpBinaryEscaped method to JSONGenerator, avoid extra copy
Jason Molenda [Mon, 4 Apr 2022 21:11:21 +0000 (14:11 -0700)]
Add DumpBinaryEscaped method to JSONGenerator, avoid extra copy

All uses of JSONGenerator in debugserver would create a JSON text
dump of the object collection, then copy that string into a
binary-escaped string, then send it up to the lldb side or
make a compressed version and send that.

This adds a DumpBinaryEscaped method to JSONGenerator which
does the gdb remote serial protocol binary escaping directly,
and removes the need to pass over the string and have an
additional copy in memory.

Differential Revision: https://reviews.llvm.org/D122882
rdar://91117456

2 years ago[BOLT][NFC] Use X86 mnemonic checks
Amir Ayupov [Mon, 4 Apr 2022 21:04:39 +0000 (14:04 -0700)]
[BOLT][NFC] Use X86 mnemonic checks

Remove switches in X86MCPlusBuilder.cpp, use mnemonic checks instead

Reviewed By: rafauler

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

2 years ago[mlir] Rework the implementation of TypeID
River Riddle [Thu, 31 Mar 2022 00:00:37 +0000 (17:00 -0700)]
[mlir] Rework the implementation of TypeID

This commit restructures how TypeID is implemented to ideally avoid
the current problems related to shared libraries. This is done by changing
the "implicit" fallback path to use the name of the type, instead of using
a static template variable (which breaks shared libraries). The major downside to this
is that it adds some additional initialization costs for the implicit path. Given the
use of type names for uniqueness in the fallback, we also no longer allow types
defined in anonymous namespaces to have an implicit TypeID. To simplify defining
an ID for these classes, a new `MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID` macro
was added to allow for explicitly defining a TypeID directly on an internal class.

To help identify when types are using the fallback, `-debug-only=typeid` can be
used to log which types are using implicit ids.

This change generally only requires changes to the test passes, which are all defined
in anonymous namespaces, and thus can't use the fallback any longer.

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

2 years ago[libcxx] Stop recommending setting LIBCXX_HAS_WIN32_THREAD_API in the MinGW builds
Martin Storsjö [Wed, 23 Mar 2022 13:47:49 +0000 (15:47 +0200)]
[libcxx] Stop recommending setting LIBCXX_HAS_WIN32_THREAD_API in the MinGW builds

Since a8d15a926689c126c4d316788786e0160cfc1d5d / D110975, this is
the default, even if winpthread headers are available, so we don't
need to cargo cult setting this option in all builds.

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

2 years agoRequire C99 for more tests; NFC intended
Aaron Ballman [Mon, 4 Apr 2022 19:57:25 +0000 (15:57 -0400)]
Require C99 for more tests; NFC intended

This augments 5d90004874c7b040cd43597826aabb34757d25ab which got all of
the -verify lines, but accidentally missed all of the -verify= ones.

2 years ago[mlir][sparse] Simplifying code in expInsert
wren romano [Fri, 1 Apr 2022 19:51:39 +0000 (12:51 -0700)]
[mlir][sparse] Simplifying code in expInsert

Just some minor cleanup

Reviewed By: aartbik

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

2 years ago[tosa] Add option to disable tosa.apply_scale lowering in TosaToStandard
Rob Suderman [Mon, 4 Apr 2022 19:22:09 +0000 (12:22 -0700)]
[tosa] Add option to disable tosa.apply_scale lowering in TosaToStandard

Apply scale should be optionally disabled when lowering via TosaToStandard.
In most cases it should persist until the lowering to specific backend.

Reviewed By: jpienaar

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

2 years ago[clangd] Remove trivial uses of FileEntry::getName
Sam McCall [Mon, 4 Apr 2022 18:52:46 +0000 (20:52 +0200)]
[clangd] Remove trivial uses of FileEntry::getName

It's deprecated; migrate to FileEntryRef::getName where it doesn't matter.
Also change one subtle case of implicit FileEntry::getName to be explicit.

After this patch, all the remaining FileEntry::getName calls are subtle
cases where we may be relying on exactly which filename variant is returned
(for indexing, IWYU directive handling, etc).

2 years ago[X86] Add XOR(X, MIN_SIGNED_VALUE) -> ADD(X, MIN_SIGNED_VALUE) isel patterns (PR52267)
Simon Pilgrim [Mon, 4 Apr 2022 18:47:06 +0000 (19:47 +0100)]
[X86] Add XOR(X, MIN_SIGNED_VALUE) -> ADD(X, MIN_SIGNED_VALUE) isel patterns (PR52267)

Improve chances of folding to LEA patterns

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

2 years ago[mlir][capi] Fix leak in test
Daniel Resnick [Mon, 4 Apr 2022 18:26:13 +0000 (12:26 -0600)]
[mlir][capi] Fix leak in test

2 years agoApply clang-tidy fixes for llvm-qualified-auto in FuncToLLVM.cpp (NFC)
Mehdi Amini [Sun, 3 Apr 2022 22:16:53 +0000 (22:16 +0000)]
Apply clang-tidy fixes for llvm-qualified-auto in FuncToLLVM.cpp (NFC)

2 years ago[ELF][MTE] Add --android-memtag-* options to synthesize ELF notes
Mitch Phillips [Wed, 9 Feb 2022 23:43:37 +0000 (15:43 -0800)]
[ELF][MTE] Add --android-memtag-* options to synthesize ELF notes

This ELF note is aarch64 and Android-specific. It specifies to the
dynamic loader that specific work should be scheduled to enable MTE
protection of stack and heap regions.

Current synthesis of the ".note.android.memtag" ELF note is done in the
Android build system. We'd like to move that to the compiler. This patch
adds the --memtag-stack, --memtag-heap, and --memtag-mode={async, sync,
none} flags to the linker, which synthesises the note for us.

Future changes will add -fsanitize=memtag* flags to clang which will
pass these through to lld.

Depends on D119381.

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

2 years ago[AMDGPU] Ignore debug use during PreRARematerialize stage in scheduling pass
Vang Thao [Mon, 4 Apr 2022 16:53:48 +0000 (09:53 -0700)]
[AMDGPU] Ignore debug use during PreRARematerialize stage in scheduling pass

Ignore all debug uses when collecting trivially rematerializable defs. This fixes an issue with difference in codegen when enabling debug info.

Reviewed By: rampitec

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

2 years ago[libc] Add pthread_mutexattr_t type and its setters and getters.
Siva Chandra Reddy [Sat, 2 Apr 2022 00:05:05 +0000 (00:05 +0000)]
[libc] Add pthread_mutexattr_t type and its setters and getters.

A simple implementation of the getters and setters has been added. More
logic can be added to them in future as required.

Reviewed By: michaelrj

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

2 years ago[clang][extract-api][NFC] Add documentation
Daniel Grumberg [Thu, 31 Mar 2022 10:36:53 +0000 (11:36 +0100)]
[clang][extract-api][NFC] Add documentation

Add struct level documentation for MacroDefinitionRecord.

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

2 years ago[libc++] Fix std::is_array<T[0]> and add tests
Louis Dionne [Thu, 31 Mar 2022 13:25:31 +0000 (09:25 -0400)]
[libc++] Fix std::is_array<T[0]> and add tests

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

2 years agoRequire C99 for these tests; NFC intended
Aaron Ballman [Mon, 4 Apr 2022 17:41:10 +0000 (13:41 -0400)]
Require C99 for these tests; NFC intended

The tests are doing -verify and testing a diagnostic behavior, but that
behavior is changing. This ensures the tests continue to run and check
the diagnostic.

The behavior of the tests is expected to remain identical as before.

2 years ago[Attributor] Allow to reproduce instructions for simplification
Johannes Doerfert [Fri, 25 Feb 2022 17:36:24 +0000 (11:36 -0600)]
[Attributor] Allow to reproduce instructions for simplification

When simplify values we might end up with an instruction from a
different scope or just one that does not dominate the use. If the
instruction can be reproduced without side-effect (incl. UB) we can
now do that. For now this is mostly used for speculatable (intrinsic)
calls but as we learn to make things like arguments or loads available
this will become more powerful.

This will also allow us to remove dead stores more easily in a follow
up.

2 years ago[MLIR][NFC] Remove unnecessary cast.
antonio-cortes-perez [Mon, 4 Apr 2022 16:10:27 +0000 (09:10 -0700)]
[MLIR][NFC] Remove unnecessary cast.

I was reading this post:
https://www.fluentcpp.com/2017/05/19/crtp-helper/

And I noticed that most likely this cast is not needed.
Unless it is needed by some compiler versions.
I tested it with:
cmake --build . --target check-mlir

Reviewed By: rriddle

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

2 years ago[LV] Add addiitonal tests for pointer difference memory checks.
Florian Hahn [Mon, 4 Apr 2022 16:58:48 +0000 (17:58 +0100)]
[LV] Add addiitonal tests for pointer difference memory checks.

Additional tests for D119078.

2 years ago[mlir][capi] Unbreak Interfaces CAPI after 2387fadea3
Benjamin Kramer [Mon, 4 Apr 2022 16:51:35 +0000 (18:51 +0200)]
[mlir][capi] Unbreak Interfaces CAPI after 2387fadea3

No idea why check-mlir doesn't build this.

2 years ago[lldb] make ConstStringTable use DenseMap rather than std::map
Luboš Luňák [Sat, 2 Apr 2022 15:06:24 +0000 (17:06 +0200)]
[lldb] make ConstStringTable use DenseMap rather than std::map

The ordering is not needed, and DenseMap is faster. I can measure
time spent in the SaveToCache() calls reduced to ~40% during LLDB
startup (and the total startup cost reduced to ~70%).

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

2 years ago[AArch64] Increase cost of v2i64 multiplies
David Green [Mon, 4 Apr 2022 16:42:20 +0000 (17:42 +0100)]
[AArch64] Increase cost of v2i64 multiplies

The cost of a v2i64 multiply was special cased in D92208 as scalarized
into 4*extract + 2*insert + 2*mul. Scalarizing to/from gpr registers are
expensive though, and the cost wasn't high enough to prevent vectorizing
in places where it can be detrimental for performance. This increases it
so that the costs of copying to/from GPRs is increased to 2 each, with
the total cost increasing to 14. So long as umull/smull are handled
correctly (as in D123006) this seems to lead to better vectorization
factors and better performance.

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

2 years ago[MLIR] Add nested symbols into LangRef
Siddharth Bhat [Mon, 4 Apr 2022 16:35:33 +0000 (22:05 +0530)]
[MLIR] Add nested symbols into LangRef

Add documentation into the LangRef for parsing nested symbols.

Reviewed By: rriddle

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

2 years agoRevert "Reland "[lit] Use sharding for GoogleTest format""
Alex Brachet [Mon, 4 Apr 2022 16:33:33 +0000 (16:33 +0000)]
Revert "Reland "[lit] Use sharding for GoogleTest format""

This reverts commit 948f3deca91a66caf4a618f826ff6de8277bed9c.

2 years agoRevert "[MLIR] Add nested symbols into LangRef"
Groverkss [Mon, 4 Apr 2022 16:31:06 +0000 (22:01 +0530)]
Revert "[MLIR] Add nested symbols into LangRef"

Reverted because commit pushed with wrong author information

This reverts commit b4865dd67f05a4c4680eaa6d257553a48bc704e0.

2 years ago[MLIR] Add booleans to dense element list in LangRef
Siddharth Bhat [Mon, 4 Apr 2022 16:24:17 +0000 (21:54 +0530)]
[MLIR] Add booleans to dense element list in LangRef

Add boolean values as a dense element, as tested in the MLIR parser:

```
  // CHECK: "splatBoolTensor"() {bar = dense<false> : tensor<i1>} : () -> ()
  "splatBoolTensor"(){bar = dense<false> : tensor<i1>} : () -> ()
```

https://github.com/llvm/llvm-project/blob/43d758b142bbdf94a1c55dc0950637ae74f825b9/mlir/test/IR/parser.mlir#L630-L631

Reviewed By: rriddle

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

2 years ago[MLIR] Add nested symbols into LangRef
Groverkss [Mon, 4 Apr 2022 16:23:08 +0000 (21:53 +0530)]
[MLIR] Add nested symbols into LangRef

Add documentation into the LangRef for parsing nested symbols.

Reviewed By: rriddle

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

2 years ago[mlir][capi] Add external pass creation to MLIR C-API
Daniel Resnick [Wed, 16 Mar 2022 22:31:08 +0000 (16:31 -0600)]
[mlir][capi] Add external pass creation to MLIR C-API

Adds the ability to create external passes using the C-API. This allows passes
to be written in C or languages that use the C-bindings.

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

2 years ago[lldb] Prevent object file plugins from changing the data buffer
Jonas Devlieghere [Mon, 4 Apr 2022 16:17:01 +0000 (09:17 -0700)]
[lldb] Prevent object file plugins from changing the data buffer

The current design allows that the object file contents could be mapped
by one object file plugin and then used by another. Presumably the idea
here was to avoid mapping the same file twice.

This becomes an issue when one object file plugin wants to map the file
differently from the others. For example, ObjectFileELF needs to map its
memory as writable while others likeObjectFileMachO needs it to be
mapped read-only.

This patch prevents plugins from changing the buffer by passing them is
by value rather than by reference.

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

2 years ago[MLIR] Fix MLIR vim syntax file
Sergei Grechanik [Mon, 4 Apr 2022 15:48:08 +0000 (08:48 -0700)]
[MLIR] Fix MLIR vim syntax file

This commit fixes several things in the MLIR vim syntax file:
- Spell checking is now on by default only in comments.
- '#' now starts an identifier instead of starting an outline attribute
  declaration, which fixes coloring the rest of the line as a
  preprocessor directive when there is a '#' in the middle.
- '!' and '^' -prefixed identifiers are now colored as types
  and labels.

Reviewed By: bondhugula

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

2 years agoRevert "[DebugInfo] Correctly recognize bitfields when emitting dwarf"
Jeremy Morse [Mon, 4 Apr 2022 16:14:58 +0000 (17:14 +0100)]
Revert "[DebugInfo] Correctly recognize bitfields when emitting dwarf"

This reverts commit 059d1f84d2d59093300a81c246de81b1c1da767b.

Some tests on green dragon failed as a result of this -- see notes on D96334.

2 years agoFix nulltpr typo in comment. NFC
Ilia Diachkov [Mon, 4 Apr 2022 16:05:06 +0000 (09:05 -0700)]
Fix nulltpr typo in comment. NFC

The patch fixes the typo "nulltpr", accidentally found in comments.

Reviewed By: MaskRay

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

2 years agoPrevent GetAugmentedArchSpec() from attaching "unknown" environments
Adrian Prantl [Mon, 4 Apr 2022 15:54:59 +0000 (08:54 -0700)]
Prevent GetAugmentedArchSpec() from attaching "unknown" environments

Environments are optional and a missing environment is distinct from
the default "unknown" environment enumerator.  The test is negative,
because the function uses the host triple and is unpredictable.

rdar://91007207

https://reviews.llvm.org/D122946

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

2 years agoCorrect a typo in a RUN line
Priyansh Singh [Mon, 4 Apr 2022 15:32:05 +0000 (11:32 -0400)]
Correct a typo in a RUN line

2 years ago[llvm-objcopy][docs] Update --update-section description
gbreynoo [Mon, 4 Apr 2022 15:18:17 +0000 (16:18 +0100)]
[llvm-objcopy][docs] Update --update-section description

I noticed that when --update-section was added to llvm-objcopy it was
not added to the command guide, see
25bcd94234530955c58c6530a9271c813827637c. This change adds it to the
docs and updates the help text.

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

2 years ago[flang] Add one semantic check for allocatable/pointer argument association
PeixinQiao [Mon, 4 Apr 2022 15:16:30 +0000 (23:16 +0800)]
[flang] Add one semantic check for allocatable/pointer argument association

The actual argument shall have deferred the same type parameters as
the dummy argument if the argument is allocatable or pointer variable.
Currently programs not following this get one crash during execution.

Reviewed By: Jean Perier

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

2 years ago[Pipeliner] Fix comment typo
Thomas Preud'homme [Mon, 4 Apr 2022 15:09:07 +0000 (16:09 +0100)]
[Pipeliner] Fix comment typo

2 years agoAttempt to re-enable demangle test in mangle-nttp-anon-union
Erich Keane [Mon, 4 Apr 2022 14:28:29 +0000 (07:28 -0700)]
Attempt to re-enable demangle test in mangle-nttp-anon-union

@thakis believes the problem was the lack of -n on my llvm-cxxfilt call,
so hopefully this is the only problem. Committing to see if this makes
all the buildbots happy.

2 years ago[InstSimplify] Fold (ctpop(X) == N) || (X != 0) into X != 0 where N > 0
Hirochika Matsumoto [Wed, 30 Mar 2022 18:53:11 +0000 (03:53 +0900)]
[InstSimplify] Fold (ctpop(X) == N) || (X != 0) into X != 0 where N > 0

(ctpop(X) == N) || (X != 0) --> (X != 0) https://alive2.llvm.org/ce/z/udgUVV
(ctpop(X) != N) && (X == 0) --> (X == 0) https://alive2.llvm.org/ce/z/9dq-cR

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

2 years agofix comment typos to cycle bots
Nico Weber [Mon, 4 Apr 2022 14:18:08 +0000 (10:18 -0400)]
fix comment typos to cycle bots

2 years ago[gn build] Always make symlinks target explicitly depend on base binary
Nico Weber [Mon, 4 Apr 2022 13:23:15 +0000 (09:23 -0400)]
[gn build] Always make symlinks target explicitly depend on base binary

This is a no-op in these files since the symlinks array is never empty
and the dependency to the base binary is added through the loop in these
cases.

But adding them doesn't hurt either, and it:
1. Makes all symlinks targets look the same, independent of symlinks
   are created always or just conditionally based on gn args
2. Makes it less likely that bugs like the one fixed by b0abada8fe7e
   are introduced by copy-pasting an existing symlink target and then
   not being careful enough when tweaking it.

No behavior change.

2 years ago[gn build] Port 980c3e6dd223
LLVM GN Syncbot [Mon, 4 Apr 2022 13:48:25 +0000 (13:48 +0000)]
[gn build] Port 980c3e6dd223

2 years agoReapply"[GH54588]Fix ItaniumMangler for NTTP unnamed unions w/ unnamed structs"
Erich Keane [Mon, 4 Apr 2022 13:25:07 +0000 (06:25 -0700)]
Reapply"[GH54588]Fix ItaniumMangler for NTTP unnamed unions w/ unnamed structs"

AND the followups that fixed builds.

I attempted to get 'cute' and use llvm-cxxfilt to make the test look
nicer, but apparently some of the bots have a version of llvm-cxxfilt
that is not the in-tree one, so it fails to properly demangle the stuff.
I've disabled this "RUN" line.

This reverts commit 50186b63d1807d389f31c515377d94185795ab44.

2 years ago[CodeGen] Async unwind - add a pass to fix CFI information
Momchil Velikov [Mon, 4 Apr 2022 09:01:30 +0000 (10:01 +0100)]
[CodeGen] Async unwind - add a pass to fix CFI information

This pass inserts the necessary CFI instructions to compensate for the
inconsistency of the call-frame information caused by linear (non-CFG
aware) nature of the unwind tables.

Unlike the `CFIInstrInserer` pass, this one almost always emits only
`.cfi_remember_state`/`.cfi_restore_state`, which results in smaller
unwind tables and also transparently handles custom unwind info
extensions like CFA offset adjustement and save locations of SVE
registers.

This pass takes advantage of the constraints that LLVM imposes on the
placement of save/restore points (cf. `ShrinkWrap.cpp`):

  * there is a single basic block, containing the function prologue

  * possibly multiple epilogue blocks, where each epilogue block is
    complete and self-contained, i.e. CSR restore instructions (and the
    corresponding CFI instructions are not split across two or more
    blocks.

  * prologue and epilogue blocks are outside of any loops

Thus, during execution, at the beginning and at the end of each basic
block the function can be in one of two states:

  - "has a call frame", if the function has executed the prologue, or
     has not executed any epilogue

  - "does not have a call frame", if the function has not executed the
    prologue, or has executed an epilogue

These properties can be computed for each basic block by a single RPO
traversal.

In order to accommodate backends which do not generate unwind info in
epilogues we compute an additional property "strong no call frame on
entry" which is set for the entry point of the function and for every
block reachable from the entry along a path that does not execute the
prologue. If this property holds, it takes precedence over the "has a
call frame" property.

From the point of view of the unwind tables, the "has/does not have
call frame" state at beginning of each block is determined by the
state at the end of the previous block, in layout order.

Where these states differ, we insert compensating CFI instructions,
which come in two flavours:

- CFI instructions, which reset the unwind table state to the
    initial one.  This is done by a target specific hook and is
    expected to be trivial to implement, for example it could be:
```
     .cfi_def_cfa <sp>, 0
     .cfi_same_value <rN>
     .cfi_same_value <rN-1>
     ...
```
where `<rN>` are the callee-saved registers.

- CFI instructions, which reset the unwind table state to the one
    created by the function prologue. These are the sequence:
```
       .cfi_restore_state
       .cfi_remember_state
```
In this case we also insert a `.cfi_remember_state` after the
last CFI instruction in the function prologue.

Reviewed By: MaskRay, danielkiss, chill

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

2 years ago[demangler] Parenthesize >> inside template args
Nathan Sidwell [Fri, 25 Mar 2022 11:34:19 +0000 (04:34 -0700)]
[demangler] Parenthesize >> inside template args

Both > and >> expressions need to be parenthesized inside template
argument lists.

Reviewed By: dblaikie, rjmccall

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

2 years ago[pseudo] respect CLANG_INCLUDE_TESTS
Sam McCall [Mon, 4 Apr 2022 13:30:11 +0000 (15:30 +0200)]
[pseudo] respect CLANG_INCLUDE_TESTS

2 years ago[gn build] llvm-lipo, llvm-libtool-darwin symlink targets now dep on binary
Nico Weber [Mon, 4 Apr 2022 13:18:24 +0000 (09:18 -0400)]
[gn build] llvm-lipo, llvm-libtool-darwin symlink targets now dep on binary

This fixes a regression from 69cde915e923d: If llvm_install_cctools_symlinks
is false, depending llvm-lipo:symlinks didn't actually depend on llvm-lipo
and the binary didn't get built as dependency of `check-lld` (because the
`symlinks` array ended up empty).

2 years ago[libc++][NFC] Rename generate_assertion_tests.py to generate_header_tests.py
Louis Dionne [Mon, 4 Apr 2022 13:10:52 +0000 (09:10 -0400)]
[libc++][NFC] Rename generate_assertion_tests.py to generate_header_tests.py

2 years ago[libc++] Implement all public header tests using the new generator
Louis Dionne [Fri, 25 Mar 2022 21:06:46 +0000 (17:06 -0400)]
[libc++] Implement all public header tests using the new generator

Note that `generate_assertion_tests.py` will be renamed to
`generate_header_tests.py` separately to facilitate change tracking.

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

2 years agofix comment typos to cycle bots
Nico Weber [Mon, 4 Apr 2022 12:56:07 +0000 (08:56 -0400)]
fix comment typos to cycle bots

2 years ago[DAG] SimplifySetCC - clang-format add/xor/sub with constant handling. NFC.
Simon Pilgrim [Mon, 4 Apr 2022 12:30:04 +0000 (13:30 +0100)]
[DAG] SimplifySetCC - clang-format add/xor/sub with constant handling. NFC.

2 years ago[clang][dataflow] Add support for clang's `__builtin_expect`.
Yitzhak Mandelbaum [Fri, 1 Apr 2022 12:51:23 +0000 (12:51 +0000)]
[clang][dataflow] Add support for clang's `__builtin_expect`.

This patch adds basic modeling of `__builtin_expect`, just to propagate the
(first) argument, making the call transparent.

Driveby: adds tests for proper handling of other builtins.

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