platform/upstream/llvm.git
3 years ago[lldb/test] Change base class of lldb-server tests
Pavel Labath [Thu, 10 Dec 2020 14:25:55 +0000 (15:25 +0100)]
[lldb/test] Change base class of lldb-server tests

lldb-server tests are a very special subclass of "api" tests. As they
communicate with lldb-server directly, they don't actually need most of
facilities provided by our TestBase class. In particular, they don't
need the ability to fork debug info flavours of tests (but they could
use debug server flavours).

This makes them inherit from "Base" instead. This avoids the need to
explicitly mark these tests as NO_DEBUG_INFO_TEST_CASE. Two additional
necessary tweaks were:
- move run_platform_command to the base (Base) class. This is used in
  one test, and can be generally useful when running tests remotely.
- add a "build" method, forwarding to buildDefault. This is to avoid
  updating each test case to use buildDefault (also, "build" sounds
  better). It might be interesting to refactor the (Test)Base classes so
  that all debug info flavour handling happens in TestBase, and the Base
  class provides a simple build method automatically.

3 years ago[lldb/test] Replace ad-hoc server test choice with test categories
Pavel Labath [Thu, 10 Dec 2020 13:52:20 +0000 (14:52 +0100)]
[lldb/test] Replace ad-hoc server test choice with test categories

This makes things consistent, and enables further simplifications down
the road.

3 years ago[openmp] Remove clause from OMPKinds.def and use OMP.td info
Valentin Clement [Thu, 10 Dec 2020 15:18:22 +0000 (10:18 -0500)]
[openmp] Remove clause from OMPKinds.def and use OMP.td info

Remove the OpenMP clause information from the OMPKinds.def file and use the
information from the new OMP.td file. There is now a single source of truth for the
directives and clauses.

To avoid generate lots of specific small code from tablegen, the macros previously
used in OMPKinds.def are generated almost as identical. This can be polished and
possibly removed in a further patch.

Reviewed By: jdoerfert

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

3 years ago[clangd][NFC] Remove unnecessary vector.
Nathan James [Thu, 10 Dec 2020 14:59:16 +0000 (14:59 +0000)]
[clangd][NFC] Remove unnecessary vector.

As pointed out in D92788.

Reviewed By: kbobyrev

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

3 years ago[clang-tidy] Use a MemoryBufferRef when parsing configuration files.
Nathan James [Thu, 10 Dec 2020 14:52:44 +0000 (14:52 +0000)]
[clang-tidy] Use a MemoryBufferRef when parsing configuration files.

Using a MemoryBufferRef, If there is an error parsing, we can point the user to the location of the file.

Reviewed By: aaron.ballman

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

3 years ago[Hexagon] Fix gcc6 compilation issue
Krzysztof Parzyszek [Thu, 10 Dec 2020 14:17:07 +0000 (08:17 -0600)]
[Hexagon] Fix gcc6 compilation issue

3 years ago[lldb] [docs] Add a manpage for lldb-server
Michał Górny [Tue, 8 Dec 2020 18:54:55 +0000 (19:54 +0100)]
[lldb] [docs] Add a manpage for lldb-server

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

3 years ago[SVE][CodeGen] Extend index of masked gathers
Kerry McLaughlin [Thu, 10 Dec 2020 11:45:45 +0000 (11:45 +0000)]
[SVE][CodeGen] Extend index of masked gathers

This patch changes performMSCATTERCombine to also promote the indices of
masked gathers where the element type is i8 or i16, and adds various tests
for gathers with illegal types.

Reviewed By: sdesmalen

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

3 years agoFix a -Wunused-variable warning in release build.
Haojian Wu [Thu, 10 Dec 2020 13:51:50 +0000 (14:51 +0100)]
Fix a -Wunused-variable warning in release build.

3 years ago[VE] Add vector reduce intrinsic instructions
Kazushi (Jam) Marukawa [Wed, 9 Dec 2020 15:20:23 +0000 (00:20 +0900)]
[VE] Add vector reduce intrinsic instructions

Add vrmax, vrmin, vfrmax, vfrmin, vrand, vror, and vrxor intrinsic
instructions and regression tests.

Reviewed By: simoll

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

3 years ago[AArch64] Cortex-R82: remove crypto
Sjoerd Meijer [Thu, 10 Dec 2020 12:48:20 +0000 (12:48 +0000)]
[AArch64] Cortex-R82: remove crypto

Remove target features crypto for Cortex-R82, because it doesn't have any, and
add LSE which was missing while we are at it.
This also removes crypto from the v8-R architecture description because that
aligns better with GCC and so far none of the R-cores have implemented crypto,
so is probably a more sensible default.

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

3 years ago[lldb/Docs] Fix lldb-x86_64-fedora URL as it is still a silent bot
Jan Kratochvil [Thu, 10 Dec 2020 12:45:10 +0000 (13:45 +0100)]
[lldb/Docs] Fix lldb-x86_64-fedora URL as it is still a silent bot

3 years ago[AArch64][Driver][SVE] Push missing SVE feature error from driver to frontend
Peter Waller [Thu, 10 Dec 2020 12:34:00 +0000 (12:34 +0000)]
[AArch64][Driver][SVE] Push missing SVE feature error from driver to frontend

... and give more guidance to users.

If specifying -msve-vector-bits on a non-SVE target, clang would say:

    error: '-msve-vector-bits' is not supported without SVE enabled

1. The driver lacks logic for "implied features".
   This would result in this error being raised for -march=...+sve2,
   even though +sve2 implies +sve.

2. Feature implication is well modelled in LLVM, so push the error down
   the stack.

3. Hint to the user what flag they need to consider setting.

Now clang fails later, when the feature is used, saying:

  aarch64-sve-vector-bits.c:42:41: error: 'arm_sve_vector_bits' attribute is not supported on targets missing 'sve'; specify an appropriate -march= or -mcpu=
  typedef svint32_t noflag __attribute__((arm_sve_vector_bits(256)));

Move clang/test/Sema/{neon => arm}-vector-types-support.c and put tests for
this warning together in one place.

Reviewed By: sdesmalen

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

3 years ago[lldb] Fix that symbols.clang-modules-cache-path is never initialized
Raphael Isemann [Thu, 10 Dec 2020 11:31:29 +0000 (12:31 +0100)]
[lldb] Fix that symbols.clang-modules-cache-path is never initialized

LLDB is supposed to ask the Clang Driver what the default module cache path is
and then use that value as the default for the
`symbols.clang-modules-cache-path` setting. However, we use the property type
`String` to change `symbols.clang-modules-cache-path` even though the type of
that setting is `FileSpec`, so the setter will simply do nothing and return
`false`. We also don't check the return value of the setter, so this whole code
ends up not doing anything at all.

This changes the setter to use the correct property type and adds an assert that
we actually successfully set the default path. Also adds a test that checks that
the default value for this setting is never unset/empty path as this would
effectively disable the import-std-module feature from working by default.

Reviewed By: JDevlieghere, shafik

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

3 years ago[clangd] NFC: Use SmallVector<T> where possible
Kirill Bobyrev [Thu, 10 Dec 2020 12:36:35 +0000 (13:36 +0100)]
[clangd] NFC: Use SmallVector<T> where possible

SmallVector<T> with default size is now the recommended version (D92522).

Reviewed By: sammccall

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

3 years ago[ARM][RegAlloc] Add t2LoopEndDec
David Green [Thu, 10 Dec 2020 12:14:23 +0000 (12:14 +0000)]
[ARM][RegAlloc] Add t2LoopEndDec

We currently have problems with the way that low overhead loops are
specified, with LR being spilled between the t2LoopDec and the t2LoopEnd
forcing the entire loop to be reverted late in the backend. As they will
eventually become a single instruction, this patch introduces a
t2LoopEndDec which is the combination of the two, combined before
registry allocation to make sure this does not fail.

Unfortunately this instruction is a terminator that produces a value
(and also branches - it only produces the value around the branching
edge). So this needs some adjustment to phi elimination and the register
allocator to make sure that we do not spill this LR def around the loop
(needing to put a spill after the terminator). We treat the loop very
carefully, making sure that there is nothing else like calls that would
break it's ability to use LR. For that, this adds a
isUnspillableTerminator to opt in the new behaviour.

There is a chance that this could cause problems, and so I have added an
escape option incase. But I have not seen any problems in the testing
that I've tried, and not reverting Low overhead loops is important for
our performance. If this does work then we can hopefully do the same for
t2WhileLoopStart and t2DoLoopStart instructions.

This patch also contains the code needed to convert or revert the
t2LoopEndDec in the backend (which just needs a subs; bne) and the code
pre-ra to create them.

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

3 years ago[llvm-rc] Handle driveless absolute windows paths when loading external files
Martin Storsjö [Thu, 3 Dec 2020 09:20:57 +0000 (11:20 +0200)]
[llvm-rc] Handle driveless absolute windows paths when loading external files

When llvm-rc loads an external file, it looks for it relative to
a number of include directories and the current working directory.
If the path is considered absolute, llvm-rc tries to open the
filename as such, and doesn't try to open it relative to other
paths.

On Windows, a path name like "\dir\file" isn't considered absolute
as it lacks the drive name, but by appending it on top of the search
dirs, it's not found.

LLVM's sys::path::append just appends such a path (same with a properly
absolute posix path) after the paths it's supposed to be relative to.

This fix doesn't handle the case if the resource script and the
external file are on a different drive than the current working
directory; to fix that, we'd have to make LLVM's sys::path::append
handle appending fully absolute and partially absolute paths (ones
lacking a drive prefix but containing a root directory), or switch
to C++17's std::filesystem.

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

3 years ago[dsymutil][DWARFLinker][NFC] Make interface of AddressMap more general.
Alexey Lapshin [Tue, 15 Sep 2020 18:12:10 +0000 (21:12 +0300)]
[dsymutil][DWARFLinker][NFC] Make interface of AddressMap more general.

Current interface of AddressMap assumes that relocations exist.
That is correct for not-linked object file but is not correct
for linked executable. This patch changes interface in such way
that AddressMap could be used not only with not-linked object files:

hasValidRelocationAt()

replaced with:

hasLiveMemoryLocation()
hasLiveAddressRange()

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

3 years ago[AMDGPU] Resolve issues when picking between ds_read/write and ds_read2/write2
Mirko Brkusanin [Thu, 10 Dec 2020 11:40:49 +0000 (12:40 +0100)]
[AMDGPU] Resolve issues when picking between ds_read/write and ds_read2/write2

Both ds_read_b128 and ds_read2_b64 are valid for 128bit 16-byte aligned
loads but the one that will be selected is determined either by the order in
tablegen or by the AddedComplexity attribute. Currently ds_read_b128 has
priority.

While ds_read2_b64 has lower alignment requirements, we cannot always
restrict ds_read_b128 to 16-byte alignment because of unaligned-access-mode
option. This was causing ds_read_b128 to be selected for 8-byte aligned
loads regardles of chosen access mode.

To resolve this we use two patterns for selecting ds_read_b128. One
requires alignment of 16-byte and the other requires
unaligned-access-mode option.

Same goes for ds_write2_b64 and ds_write_b128.

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

3 years ago[clang-tidy][NFC] Use moves instead of copies when constructing OptionsProviders.
Nathan James [Thu, 10 Dec 2020 11:34:57 +0000 (11:34 +0000)]
[clang-tidy][NFC] Use moves instead of copies when constructing OptionsProviders.

Reviewed By: aaron.ballman

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

3 years ago[lldb] Allow LLDB to automatically retry a failed expression with an imported std...
Raphael Isemann [Thu, 10 Dec 2020 09:09:06 +0000 (10:09 +0100)]
[lldb] Allow LLDB to automatically retry a failed expression with an imported std C++ module

By now LLDB can import the 'std' C++ module to improve expression evaluation,
but there are still a few problems to solve before we can do this by default.
One is that importing the C++ module is slightly slower than normal expression
evaluation (mostly because the disk access and loading the initial lookup data
is quite slow in comparison to the barebone Clang setup the rest of the LLDB
expression evaluator is usually doing). Another problem is that some complicated
types in the standard library aren't fully supported yet by the ASTImporter, so
we end up types that fail to import (which usually appears to the user as if the
type is empty or there is just no result variable).

To still allow people to adopt this mode in their daily debugging, this patch
adds a setting that allows LLDB to automatically retry failed expression with a
loaded C++ module. All success expressions will behave exactly as they would do
before this patch. Failed expressions get a another parse attempt if we find a
usable C++ module in the current execution context. This way we shouldn't have
any performance/parsing regressions in normal debugging workflows, while the
debugging workflows involving STL containers benefit from the C++ module type
info.

This setting is off by default for now with the intention to enable it by
default on macOS soon-ish.

The implementation is mostly just extracting the existing parse logic into its
own function and then calling the parse function again if the first evaluation
failed and we have a C++ module to retry the parsing with.

Reviewed By: shafik, JDevlieghere, aprantl

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

3 years ago[clang-format] NFC Add release note for IndentPragmas
mydeveloperday [Thu, 10 Dec 2020 11:24:12 +0000 (11:24 +0000)]
[clang-format] NFC Add release note for IndentPragmas

Add additional release note to announce new clang-format option added during {D92753}

3 years ago[clang-format] Add IndentPragma style to eliminate common clang-format off scenario
mydeveloperday [Thu, 10 Dec 2020 11:17:33 +0000 (11:17 +0000)]
[clang-format] Add IndentPragma style to eliminate common clang-format off scenario

A quick search of github.com, shows one common scenario for excessive use of //clang-format off/on is the indentation of #pragma's, especially around the areas of loop optimization or OpenMP

This revision aims to help that by introducing an `IndentPragmas` style, the aim of which is to keep the pragma at the current level of scope

```
    for (int i = 0; i < 5; i++) {
// clang-format off
        #pragma HLS UNROLL
        // clang-format on
        for (int j = 0; j < 5; j++) {
// clang-format off
            #pragma HLS UNROLL
            // clang-format on
     ....
```

can become

```
    for (int i = 0; i < 5; i++) {
        #pragma HLS UNROLL
        for (int j = 0; j < 5; j++) {
            #pragma HLS UNROLL
        ....
```

This revision also support working alongside the `IndentPPDirective` of `BeforeHash` and `AfterHash` (see unit tests for examples)

Reviewed By: curdeius

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

3 years ago[clang-format] PR42434 Remove preprocessor and pragma lines from ObjectiveC guess
mydeveloperday [Thu, 10 Dec 2020 11:13:22 +0000 (11:13 +0000)]
[clang-format] PR42434 Remove preprocessor and pragma lines from ObjectiveC guess

clang-format see the `disable:` in   __pragma(warning(disable:)) as ObjectiveC method call

Remove any line starting with `#` or __pragma line from being part of the ObjectiveC guess

https://bugs.llvm.org/show_bug.cgi?id=42434

Reviewed By: curdeius, krasimir

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

3 years ago[clang-format] [NFC] Fix spelling and grammatical errors in IncludeBlocks text
mydeveloperday [Thu, 10 Dec 2020 11:06:48 +0000 (11:06 +0000)]
[clang-format] [NFC] Fix spelling and grammatical errors in IncludeBlocks text

Fix spelling mistake
Leave space after `.` and before beginning of next sentence
Reword it slightly to try and make it more readable.
Ensure RST is updated correctly (it generated a change)

Reviewed By: HazardyKnusperkeks, curdeius

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

3 years ago[ARM] Additional test for Min loop. NFC
David Green [Thu, 10 Dec 2020 10:49:00 +0000 (10:49 +0000)]
[ARM] Additional test for Min loop. NFC

3 years ago[ARM] Remove copies from low overhead phi inductions.
David Green [Thu, 10 Dec 2020 10:30:31 +0000 (10:30 +0000)]
[ARM] Remove copies from low overhead phi inductions.

The phi created in a low overhead loop gets created with a default
register class it seems. There are then copied inserted between the low
overhead loop pseudo instructions (which produce/consume GPRlr
instructions) and the phi holding the induction. This patch removes
those as a step towards attempting to make t2LoopDec and t2LoopEnd a
single instruction, and appears useful in it's own right as shown in the
tests.

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

3 years ago[mlir] Explicitly track branch instructions in translation to LLVM IR
Alex Zinenko [Tue, 8 Dec 2020 15:09:20 +0000 (16:09 +0100)]
[mlir] Explicitly track branch instructions in translation to LLVM IR

The current implementation of the translation to LLVM IR relies on the
existence of a one-to-one mapping between MLIR blocks and LLVM IR basic blocks
in order to configure PHI nodes with appropriate source blocks. The one-to-one
mapping model is broken in presence of OpenMP operations that use LLVM's
OpenMPIRBuilder, which produces multiple blocks under the hood. This can lead
to invalid LLVM IR being emitted if OpenMPIRBuilder moved the branch operation
into a basic block different from the one it was originally created in;
specifically, a block that is not a direct predecessor could be used in the PHI
node. Instead, keep track of the mapping between MLIR LLVM dialect branch
operations and their LLVM IR counterparts and take the parent basic block of
the LLVM IR instruction at the moment of connecting the PHI nodes to
predecessors.

This behavior cannot be triggered as of now, but will be once we introduce the
conversion of OpenMP workshare loops.

Reviewed By: kiranchandramohan

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

3 years ago[TruncInstCombine] Remove scalable vector restriction
Jun Ma [Tue, 8 Dec 2020 07:46:12 +0000 (15:46 +0800)]
[TruncInstCombine] Remove scalable vector restriction

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

3 years agoRemove Shapet assignment operator that's identical to the default. NFC.
Benjamin Kramer [Thu, 10 Dec 2020 09:57:14 +0000 (10:57 +0100)]
Remove Shapet assignment operator that's identical to the default. NFC.

3 years ago[lldb][NFC] Fix a typo in TestCppMultipleInheritance
Raphael Isemann [Thu, 10 Dec 2020 09:56:46 +0000 (10:56 +0100)]
[lldb][NFC] Fix a typo in TestCppMultipleInheritance

3 years ago[Hexagon] Fold single-use variables into assert. NFCI.
Benjamin Kramer [Thu, 10 Dec 2020 09:53:56 +0000 (10:53 +0100)]
[Hexagon] Fold single-use variables into assert. NFCI.

Silences unused variable warnings in Release builds.

3 years ago[mlir][Shape] Make sure tensor_cast(constant_shape) folding uses the correct type
Benjamin Kramer [Wed, 9 Dec 2020 11:06:51 +0000 (12:06 +0100)]
[mlir][Shape] Make sure tensor_cast(constant_shape) folding uses the correct type

This is still subtle, but I think the test cases are sufficient to show
that it works.

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

3 years ago[ARM] MVE vcreate tests, for dual lane moves. NFC
David Green [Thu, 10 Dec 2020 09:17:34 +0000 (09:17 +0000)]
[ARM] MVE vcreate tests, for dual lane moves. NFC

3 years ago[gn build] Port f80b29878b0
LLVM GN Syncbot [Thu, 10 Dec 2020 09:13:09 +0000 (09:13 +0000)]
[gn build] Port f80b29878b0

3 years ago[AST] Fix a constexpr-evaluator crash on error-dependent returnstmt.
Haojian Wu [Thu, 10 Dec 2020 09:11:15 +0000 (10:11 +0100)]
[AST] Fix a constexpr-evaluator crash on error-dependent returnstmt.

When the evaluator encounters an error-dependent returnstmt, before this patch
it returned a ESR_Returned without setting the result, the callsides think this
is a successful execution, and try to access the Result which causes the crash.

The fix is to always return failed as we don't know the result of the
error-dependent return stmt.

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

3 years ago[X86] AMX programming model.
Luo, Yuanke [Sun, 6 Sep 2020 02:17:22 +0000 (10:17 +0800)]
[X86] AMX programming model.
 This patch implements amx programming model that discussed in llvm-dev
 (http://lists.llvm.org/pipermail/llvm-dev/2020-August/144302.html).
 Thank Hal for the good suggestion in the RA. The fast RA is not in the patch yet.
 This patch implemeted 7 components.

1. The c interface to end user.
2. The AMX intrinsics in LLVM IR.
3. Transform load/store <256 x i32> to AMX intrinsics or split the
   type into two <128 x i32>.
4. The Lowering from AMX intrinsics to AMX pseudo instruction.
5. Insert psuedo ldtilecfg and build the def-use between ldtilecfg to amx
   intruction.
6. The register allocation for tile register.
7. Morph AMX pseudo instruction to AMX real instruction.

Change-Id: I935e1080916ffcb72af54c2c83faa8b2e97d5cb0

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

3 years agoAdd sqrt lowering from standard to ROCDL
Adrian Kuegel [Wed, 9 Dec 2020 09:41:33 +0000 (10:41 +0100)]
Add sqrt lowering from standard to ROCDL

Add a lowering for sqrt from standard dialect to ROCDL.

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

3 years ago[JITLink][ELF] Reformat/add debug logging in ELF_x86_64.cpp.
Lang Hames [Wed, 9 Dec 2020 01:37:50 +0000 (12:37 +1100)]
[JITLink][ELF] Reformat/add debug logging in ELF_x86_64.cpp.

Moves symbol name to the end of the output and makes other columns fixed width
so that they line up.

3 years ago[libc++] [P1164] [C++20] Make fs::create_directory() error if there is already a...
Marek Kurdej [Thu, 10 Dec 2020 07:38:41 +0000 (08:38 +0100)]
[libc++] [P1164] [C++20] Make fs::create_directory() error if there is already a non-directory.

Also mark LWG2935 and LWG3079 as complete.

Applied retroactively to previous standards too, as it's a DR.

* https://wg21.link/P1164
* https://wg21.link/lwg2935
* https://wg21.link/lwg3079

Reviewed By: ldionne, #libc

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

3 years ago[libc++] Add a script to automatize updating test for a new header.
Marek Kurdej [Thu, 10 Dec 2020 07:37:21 +0000 (08:37 +0100)]
[libc++] Add a script to automatize updating test for a new header.

Idea from D92525.
This script globs include/ directory and updates the tests in test/libcxx.
This patch does not generate module.modulemap nor CMakeLists.txt.

Reviewed By: ldionne, #libc

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

3 years ago[Tablegen] Use llvm::is_contained (NFC)
Kazu Hirata [Thu, 10 Dec 2020 07:34:07 +0000 (23:34 -0800)]
[Tablegen] Use llvm::is_contained (NFC)

3 years ago[llvm-link][NFC] Minor cleanup
Sergey Dmitriev [Thu, 10 Dec 2020 06:51:58 +0000 (22:51 -0800)]
[llvm-link][NFC] Minor cleanup

llvm::Linker::linkModules() is a static member, so there is no need
to pass reference to llvm::Linker instance to loadArFile() function.

Reviewed By: tra

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

3 years ago[VE][NFC] Disable VP tests
Kazushi (Jam) Marukawa [Thu, 10 Dec 2020 06:10:01 +0000 (15:10 +0900)]
[VE][NFC] Disable VP tests

VP tests recently added don't work on Release mode.  They work on
Debug mode, so I disable them on Release mode to make tests work.

3 years ago[test] Fix coro-retcon.ll under NPM
Arthur Eubanks [Thu, 10 Dec 2020 06:04:59 +0000 (22:04 -0800)]
[test] Fix coro-retcon.ll under NPM

The full aa-pipeline is required to remove the extra store.

3 years ago[lld][WebAssembly] Don't emit names for data segments that we omit
Sam Clegg [Thu, 10 Dec 2020 04:46:37 +0000 (20:46 -0800)]
[lld][WebAssembly] Don't emit names for data segments that we omit

Followup to https://reviews.llvm.org/D92909

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

3 years ago[lldb] Kill the inferior instead of detaching during test suite runs
Jonas Devlieghere [Thu, 10 Dec 2020 02:39:29 +0000 (18:39 -0800)]
[lldb] Kill the inferior instead of detaching during test suite runs

Kill (rather than detach) form the inferior if debugserver loses its
connection to lldb to prevent zombie processes.

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

3 years ago[NFCI] Add a missing triple in clang/test/CodeGen/ppc64le-varargs-f128.c
Yuanfang Chen [Thu, 10 Dec 2020 02:16:45 +0000 (18:16 -0800)]
[NFCI] Add a missing triple in clang/test/CodeGen/ppc64le-varargs-f128.c

3 years agoMSABI: Basic mangling for access to member subobjects in a class
Richard Smith [Thu, 10 Dec 2020 02:07:52 +0000 (18:07 -0800)]
MSABI: Basic mangling for access to member subobjects in a class
non-type template parameter.

The mangling information used here comes from private communication with
Jon Caves at Microsoft.

3 years ago[lld/mac] Use xxhash instead of MD5 for computing the UUID
Nico Weber [Thu, 10 Dec 2020 02:04:22 +0000 (21:04 -0500)]
[lld/mac] Use xxhash instead of MD5 for computing the UUID

15% faster for linking Chromium's base_unittests.txt, according to ministat:

```
    N           Min           Max        Median           Avg        Stddev
x  10      0.650213    0.69287586    0.65793395    0.66127126   0.012365407
+  10    0.54993701    0.59006906    0.55885506    0.56146643   0.013215349
Difference at 95.0% confidence
        -0.0998048 +/- 0.0120244
        -15.0929% +/- 1.81838%
        (Student's t, pooled s = 0.0127974)
```

And matches what we do on the other ports.

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

3 years ago[MemorySSA/docs] Extend MemorySSA documentation.
Alina Sbirlea [Sat, 5 Dec 2020 02:04:24 +0000 (18:04 -0800)]
[MemorySSA/docs] Extend MemorySSA documentation.

3 years ago[ELF] Rename --[no-]lto-new-pass-manager to --[no-]lto-legacy-pass-manager
Fangrui Song [Thu, 10 Dec 2020 01:53:37 +0000 (17:53 -0800)]
[ELF] Rename --[no-]lto-new-pass-manager to --[no-]lto-legacy-pass-manager

Normally we should not delete options. However, the Clang driver passes
`-plugin-opt={new,legacy}-pass-manager` instead of
`--[no-]lto-legacy-pass-manager` (`-plugin-opt=new-pass-manager` has been used
since 7.0), and it is unlikely anyone will use the `--lto-*` style options directly.

So let's rename them to be consistent with the Clang driver option names.

Reviewed By: aeubanks

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

3 years ago[LTO][NPM] Default to using NPM under ENABLE_EXPERIMENTAL_NEW_PASS_MANAGER
Arthur Eubanks [Tue, 8 Dec 2020 23:15:10 +0000 (15:15 -0800)]
[LTO][NPM] Default to using NPM under ENABLE_EXPERIMENTAL_NEW_PASS_MANAGER

This affects users of LTO that don't explicitly set UseNewPM.

Reviewed By: MaskRay

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

3 years ago[test] Fix test/Driver/ve-toolchain.cpp
Fangrui Song [Thu, 10 Dec 2020 01:26:21 +0000 (17:26 -0800)]
[test] Fix test/Driver/ve-toolchain.cpp

It should specify --sysroot to test the paths of crt1.o/crti.o/crtbegin.o.
For a user who enable VE but do not actually have VE sysroot,
the "nld" command line will have bare "crt1.o" "crti.o" ... "crtbegin.o"

3 years ago[test] Fix Misc/time-passes.c
Fangrui Song [Thu, 10 Dec 2020 01:17:28 +0000 (17:17 -0800)]
[test] Fix Misc/time-passes.c

3 years ago[OpenMP] Use RTM lock for OMP lock with synchronization hint
Hansang Bae [Thu, 10 Dec 2020 00:25:26 +0000 (18:25 -0600)]
[OpenMP] Use RTM lock for OMP lock with synchronization hint

This patch introduces a new RTM lock type based on spin lock which is
used for OMP lock with speculative hint on supported architecture.

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

3 years agoRevert "[clangd] Extract per-dir CDB cache to its own threadsafe class. NFC"
Nico Weber [Thu, 10 Dec 2020 01:11:19 +0000 (20:11 -0500)]
Revert "[clangd] Extract per-dir CDB cache to its own threadsafe class. NFC"

This reverts commit 634a377bd8cbaa515a58295cfd85dcb6a21381c1.
Breaks tests on Windows, see https://reviews.llvm.org/D92381#2443407

3 years agoDefault CodeGenOptions::LegacyPassManager to !LLVM_ENABLE_NEW_PASS_MANAGER
Fangrui Song [Thu, 10 Dec 2020 01:10:17 +0000 (17:10 -0800)]
Default CodeGenOptions::LegacyPassManager to !LLVM_ENABLE_NEW_PASS_MANAGER

Fixes test/CodeGen/flatten.c

3 years agoclangd: Migrate to FileEntryRef in TweakTests, NFC
Duncan P. N. Exon Smith [Thu, 10 Dec 2020 00:56:08 +0000 (16:56 -0800)]
clangd: Migrate to FileEntryRef in TweakTests, NFC

3 years ago[Driver] Add -f[no-]legacy-pass-manager to supersede -f[no-]experimental-new-pass...
Fangrui Song [Thu, 10 Dec 2020 00:57:36 +0000 (16:57 -0800)]
[Driver] Add -f[no-]legacy-pass-manager to supersede -f[no-]experimental-new-pass-manager

The new PM is considered stable and many downstream groups have adopted it (some
have adopted it for more than two years). Add -f[no-]legacy-pass-manager to reflect the
fact that it is no longer experimental and the legacy pass manager is something we strive to retire.

In the future, when the legacy PM eventually goes away,
-fno-experimental-new-pass-manager and -flegacy-pass-manager will be removed.

This patch also changes -f[no-]legacy-pass-manager to pass `-plugin-opt={new,legacy}-pass-manager` to the linker (supported by both ld.lld and LLVMgold.so) when -flto/-flto=thin is specified

Reviewed By: aeubanks, rsmith

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

3 years agoRename -plugin-opt=no-new-pass-manager to -plugin-opt=legacy-pass-manager
Fangrui Song [Thu, 10 Dec 2020 00:43:30 +0000 (16:43 -0800)]
Rename -plugin-opt=no-new-pass-manager to -plugin-opt=legacy-pass-manager

3 years ago[AMDGPU] Fix expansion of 192 bit spills in PEI
Stanislav Mekhanoshin [Wed, 9 Dec 2020 23:51:21 +0000 (15:51 -0800)]
[AMDGPU] Fix expansion of 192 bit spills in PEI

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

3 years ago[DWARF] Allow toolchain to adjust specified DWARF version.
Artem Belevich [Thu, 3 Dec 2020 21:48:37 +0000 (13:48 -0800)]
[DWARF] Allow toolchain to adjust specified DWARF version.

This is needed for CUDA compilation where NVPTX back-end only supports DWARF2,
but host compilation should be allowed to use newer DWARF versions.

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

3 years agoTooling: Migrate to FileEntryRef in clang::tooling::applyAllReplacements, NFC
Duncan P. N. Exon Smith [Thu, 10 Dec 2020 00:31:38 +0000 (16:31 -0800)]
Tooling: Migrate to FileEntryRef in clang::tooling::applyAllReplacements, NFC

Migrate to the `FileEntryRef` overload of `SourceManager::createFileID`.

3 years agoFrontend: Use a getVirtualFileRef for a named pipe main file, NFC
Duncan P. N. Exon Smith [Thu, 10 Dec 2020 00:15:07 +0000 (16:15 -0800)]
Frontend: Use a getVirtualFileRef for a named pipe main file, NFC

3 years ago[Hexagon] Silence warnings about unused objects
Krzysztof Parzyszek [Wed, 9 Dec 2020 23:52:03 +0000 (17:52 -0600)]
[Hexagon] Silence warnings about unused objects

3 years ago[Hexagon] Fix build: move template specialization into namespace scope
Krzysztof Parzyszek [Wed, 9 Dec 2020 23:39:13 +0000 (17:39 -0600)]
[Hexagon] Fix build: move template specialization into namespace scope

3 years ago[MC] Fix ICE with non-newline terminated input
Scott Linder [Wed, 9 Dec 2020 23:13:15 +0000 (23:13 +0000)]
[MC] Fix ICE with non-newline terminated input

There is an explicit option for the lexer to support this, but we crash
when `-preserve-comments` is enabled because it checks for
`getTok().getString().empty()` to detect the case. This doesn't
work currently because the lexer reports this case as a string of length
1, containing a null byte.

Change the lexer to instead report this case via an empty string, as the
null terminator isn't logically a part of the textual input, and the
check for `.empty()` seems natural and obvious in the calling code.

Reviewed By: niravd

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

3 years ago[mlir][Interfaces] Tidy up the documentation for interfaces
River Riddle [Wed, 9 Dec 2020 23:33:49 +0000 (15:33 -0800)]
[mlir][Interfaces] Tidy up the documentation for interfaces

The documentation has become a bit stale with age, and doesn't include great documentation for some newer concepts. This revision tidies up a majority of it, with some more cleanup to come in the future. The documentation for the declarative specification is also moved from OpDefinitions.md to Interfaces.md, which is a much more logical place for it to live.

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

3 years ago[gn build] Port f5d07a05bbd
LLVM GN Syncbot [Wed, 9 Dec 2020 23:12:27 +0000 (23:12 +0000)]
[gn build] Port f5d07a05bbd

3 years ago[Hexagon] Realign HVX vectors wherever possible
Krzysztof Parzyszek [Mon, 7 Sep 2020 19:26:48 +0000 (14:26 -0500)]
[Hexagon] Realign HVX vectors wherever possible

Introduce HexagonVectorCombine as a helper class for vector-related
optimizations.

3 years agoclang-format: Migrate createInMemoryFile to FileEntryRef, NFC
Duncan P. N. Exon Smith [Wed, 9 Dec 2020 22:50:07 +0000 (14:50 -0800)]
clang-format: Migrate createInMemoryFile to FileEntryRef, NFC

3 years agoX86: use a data driven configuration of Windows x86 libcalls (NFC)
Saleem Abdulrasool [Wed, 9 Dec 2020 22:47:50 +0000 (22:47 +0000)]
X86: use a data driven configuration of Windows x86 libcalls (NFC)

Rather than creating a series of associated calls and ensuring that
everything is lined up, use a table driven approach that ensures that
they two always stay in sync.

3 years ago[OpenMP] Add strict mode in num_tasks and grainsize
Nawrin Sultana [Mon, 30 Nov 2020 23:41:53 +0000 (17:41 -0600)]
[OpenMP] Add strict mode in num_tasks and grainsize

This patch adds new API __kmpc_taskloop_5 to accomadate strict
modifier (introduced in OpenMP 5.1) in num_tasks and grainsize
clause.

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

3 years agoRemove RemappedFiles param from ASTUnit::LoadFromASTFile, NFC
Duncan P. N. Exon Smith [Thu, 5 Nov 2020 17:37:41 +0000 (12:37 -0500)]
Remove RemappedFiles param from ASTUnit::LoadFromASTFile, NFC

This parameter is always set to `None`. Remove it.

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

3 years ago[DFSan] Add custom wrapper for getsockopt.
Matt Morehouse [Wed, 9 Dec 2020 22:29:28 +0000 (14:29 -0800)]
[DFSan] Add custom wrapper for getsockopt.

The wrapper clears shadow for optval and optlen when written.

Reviewed By: stephan.yichao.zhao, vitalybuka

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

3 years ago[MLIR] Minor cleanup for Shape dialect.
Rahul Joshi [Wed, 9 Dec 2020 17:23:30 +0000 (09:23 -0800)]
[MLIR] Minor cleanup for Shape dialect.

- Remove some unused types from the Shape dialect
- Fix from_extent_tensor to only allow 1D index tensors
- Fix assuming_yield to only allow shape.assuming as the parent op.
- Fix some documentation typos and reword some things.

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

3 years agoIgnore DBGArchitecture from dsymForUUID's plist
Jason Molenda [Wed, 9 Dec 2020 22:12:15 +0000 (14:12 -0800)]
Ignore DBGArchitecture from dsymForUUID's plist

When the architecture from the returned plist differs from the
architecture lldb will pick when loading the binary file, lldb will
reject the binary as not matching.  We are working with UUID's in
this case, so an architecture is not disambiguating anything; it
just opens this possibility for failing to load the specified binary.
Stop reading the architecture from the plist.

<rdar://problem/71612561>
Differential revision: https://reviews.llvm.org/D92692

3 years agoARCMigrate: Migrate ObjCMT.cpp over to FileEntryRef
Duncan P. N. Exon Smith [Fri, 4 Dec 2020 01:32:32 +0000 (17:32 -0800)]
ARCMigrate: Migrate ObjCMT.cpp over to FileEntryRef

Migrate ObjCMT.cpp from using `const FileEntry*` to `FileEntryRef`. This
is one of the blockers for changing `SourceManager` to use
`FileEntryRef`.

This adds an initial version of `SourceManager::getFileEntryRefForID`,
which uses to `FileEntry::getLastRef`; after `SourceManager` switches,
`SourceManager::getFileEntryForID` will need to call this function.

This also adds uses of `FileEntryRef` as a key in a `DenseMap`, and a
call to `hash_value(Optional)` in `DenseMapInfo<EditEntry>`; support for
these were added in prep commits.

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

3 years agoscudo: Shrink secondary header and cache entry size by a word on Linux. NFCI.
Peter Collingbourne [Wed, 9 Dec 2020 21:30:52 +0000 (13:30 -0800)]
scudo: Shrink secondary header and cache entry size by a word on Linux. NFCI.

Normally compilers will allocate space for struct fields even if the
field is an empty struct. Use the [[no_unique_address]] attribute to
suppress that behavior. This attribute that was introduced in C++20,
but compilers that do not support [[no_unique_address]] will ignore
it since it uses C++11 attribute syntax.

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

3 years ago[MC][AMDGPU] Consume EndOfStatement in asm parser
Scott Linder [Wed, 9 Dec 2020 21:20:28 +0000 (21:20 +0000)]
[MC][AMDGPU] Consume EndOfStatement in asm parser

Avoids spurious newlines showing up in the output when emitting assembly
via MC.

Reviewed By: MaskRay, arsenm

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

3 years ago[X86] Use APInt::isSignedIntN instead of isIntN for 64-bit ANDs in X86DAGToDAGISel...
Craig Topper [Wed, 9 Dec 2020 18:21:40 +0000 (10:21 -0800)]
[X86] Use APInt::isSignedIntN instead of isIntN for 64-bit ANDs in X86DAGToDAGISel::IsProfitableToFold

Pretty sure we meant to be checking signed 32 immediates here
rather than unsigned 32 bit. I suspect I messed this up because
in MathExtras.h we have isIntN and isUIntN so isIntN differs in
signedness depending on whether you're using APInt or plain integers.

This fixes a case where we didn't fold a constant created
by shrinkAndImmediate. Since shrinkAndImmediate doesn't topologically
sort constants it creates, we can fail to convert the Constant
to a TargetConstant. This leads to very strange behavior later.

Fixes PR48458.

3 years agoAvoid a possible one-byte OOB read off of .drectve sections
Reid Kleckner [Wed, 9 Dec 2020 21:30:22 +0000 (13:30 -0800)]
Avoid a possible one-byte OOB read off of .drectve sections

Pointed out by Ryan Prichard

3 years ago[mlir] Allow RegionBranchOps in dependence analysis
Tres Popp [Wed, 9 Dec 2020 20:54:58 +0000 (21:54 +0100)]
[mlir] Allow RegionBranchOps in dependence analysis

This is to prevent assertion failures on scf.if and shape.assuming
operations where this is not enough information currently to handle any
aliasing information.

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

3 years ago[LLD][gold] Add -plugin-opt=no-new-pass-manager
Fangrui Song [Wed, 9 Dec 2020 21:31:03 +0000 (13:31 -0800)]
[LLD][gold] Add -plugin-opt=no-new-pass-manager

-DENABLE_EXPERIMENTAL_NEW_PASS_MANAGER=on configured LLD and LLVMgold.so
will use the new pass manager by default. Add an option to
use the legacy pass manager. This will also be used by the Clang driver
when -fno-new-pass-manager (D92915) / -fno-experimental-new-pass-manager is set.

Reviewed By: aeubanks, tejohnson

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

3 years agoFrontend: Migrate to FileEntryRef in CompilerInstance::InitializeSourceManager, NFC
Duncan P. N. Exon Smith [Fri, 4 Dec 2020 20:30:48 +0000 (12:30 -0800)]
Frontend: Migrate to FileEntryRef in CompilerInstance::InitializeSourceManager, NFC

Use `FileManager::getVirtualFileRef` to get the virtual file for stdin,
and add an overload of `SourceManager::overrideFileContents` that takes
a `FileEntryRef`, migrating `CompilerInstance::InitializeSourceManager`.

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

3 years ago[NFCI] Add missing triple to several LTO tests
Yuanfang Chen [Wed, 9 Dec 2020 21:10:39 +0000 (13:10 -0800)]
[NFCI] Add missing triple to several LTO tests

Also remove the module triple of clang/test/CodeGenObjC/arc.ll, the
commandline tripe is all it needs.

3 years ago[AMDGPU][MC] Restore old error position for "too few operands"
Scott Linder [Wed, 9 Dec 2020 20:44:20 +0000 (20:44 +0000)]
[AMDGPU][MC] Restore old error position for "too few operands"

Revert part of https://reviews.llvm.org/D92084 to make it simpler to
start consuming the EndOfStatement token within AMDGPU's
ParseInstruction in a future patch. This also brings us back to what
every other target currently does.

A future change to move the position back to the end of the statement
would likely need to audit all of the AMDGPUOperand SMLoc ranges, and
determine the SMLoc for the last character of the last operand.

Reviewed By: dp

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

3 years ago[DFSan] Add custom wrapper for recvmsg.
Matt Morehouse [Wed, 9 Dec 2020 21:07:38 +0000 (13:07 -0800)]
[DFSan] Add custom wrapper for recvmsg.

The wrapper clears shadow for anything written by recvmsg.

Reviewed By: stephan.yichao.zhao

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

3 years ago[WebAssembly] Add support for named data sections in wasm binaries
Sam Clegg [Wed, 9 Dec 2020 05:47:19 +0000 (21:47 -0800)]
[WebAssembly] Add support for named data sections in wasm binaries

Followup to https://reviews.llvm.org/D91769 which added support
for names globals.

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

3 years ago[NFC] Removed unused prefixes in llvm/test/CodeGen/AArch64
Mircea Trofin [Wed, 9 Dec 2020 17:23:38 +0000 (09:23 -0800)]
[NFC] Removed unused prefixes in llvm/test/CodeGen/AArch64

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

3 years ago[clangd] NFC: Add client-side logging for remote index requests
Kirill Bobyrev [Wed, 9 Dec 2020 20:40:10 +0000 (21:40 +0100)]
[clangd] NFC: Add client-side logging for remote index requests

Figuring out whether the server is responding and debugging issues with remote
index setup is no easy task: add verbose logging for client side RPC requests
to relieve some pain.

Reviewed By: sammccall

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

3 years ago[mlir][Affine] Fix vectorizability check for multiple load/stores
Sergei Grechanik [Wed, 9 Dec 2020 19:03:56 +0000 (11:03 -0800)]
[mlir][Affine] Fix vectorizability check for multiple load/stores

This patch fixes a bug that allowed vectorizing of loops with loads and
stores having indexing functions varying along different memory
dimensions.

Reviewed By: aartbik, dcaballe

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

3 years ago[OpenMP] Fix norespect affinity bug for Windows
Peyton, Jonathan L [Thu, 3 Dec 2020 18:07:33 +0000 (12:07 -0600)]
[OpenMP] Fix norespect affinity bug for Windows

KMP_AFFINITY=norespect was triggering an error because the underlying
process affinity mask was not updated to include the entire machine.
The Windows documentation states that the thread affinities must be
subsets of the process affinity. This patch also moves the printing
(for KMP_AFFINITY=verbose) of whether the initial mask was respected
out of each topology detection function and to one location where the
initial affinity mask is read.

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

3 years ago[OpenMP] Fix too long name for shm segment on macOS
Peyton, Jonathan L [Fri, 4 Dec 2020 16:30:10 +0000 (10:30 -0600)]
[OpenMP] Fix too long name for shm segment on macOS

Remove the user id component to the shm segment name and just use
the pid like before.

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

3 years ago[ASTImporter] Support CXXDeductionGuideDecl with local typedef
Gabor Marton [Fri, 27 Nov 2020 07:32:51 +0000 (08:32 +0100)]
[ASTImporter] Support CXXDeductionGuideDecl with local typedef

CXXDeductionGuideDecl with a local typedef has its own copy of the
TypedefDecl with the CXXDeductionGuideDecl as the DeclContext of that
TypedefDecl.
```
      template <typename T> struct A {
        typedef T U;
        A(U, T);
      };
      A a{(int)0, (int)0};
```
Related discussion on cfe-dev:
http://lists.llvm.org/pipermail/cfe-dev/2020-November/067252.html

Without this fix, when we import the CXXDeductionGuideDecl (via
VisitFunctionDecl) then before creating the Decl we must import the
FunctionType. However, the first parameter's type is the afore mentioned
local typedef. So, we then start importing the TypedefDecl whose
DeclContext is the CXXDeductionGuideDecl itself. The infinite loop is
formed.
```
 #0 clang::ASTNodeImporter::VisitCXXDeductionGuideDecl(clang::CXXDeductionGuideDecl*) clang/lib/AST/ASTImporter.cpp:3543:0
 #1 clang::declvisitor::Base<std::add_pointer, clang::ASTNodeImporter, llvm::Expected<clang::Decl*> >::Visit(clang::Decl*) /home/egbomrt/WORK/llvm5/build/debug/tools/clang/include/clang/AST/DeclNodes.inc:405:0
 #2 clang::ASTImporter::ImportImpl(clang::Decl*) clang/lib/AST/ASTImporter.cpp:8038:0
 #3 clang::ASTImporter::Import(clang::Decl*) clang/lib/AST/ASTImporter.cpp:8200:0
 #4 clang::ASTImporter::ImportContext(clang::DeclContext*) clang/lib/AST/ASTImporter.cpp:8297:0
 #5 clang::ASTNodeImporter::ImportDeclContext(clang::Decl*, clang::DeclContext*&, clang::DeclContext*&) clang/lib/AST/ASTImporter.cpp:1852:0
 #6 clang::ASTNodeImporter::ImportDeclParts(clang::NamedDecl*, clang::DeclContext*&, clang::DeclContext*&, clang::DeclarationName&, clang::NamedDecl*&, clang::SourceLocation&) clang/lib/AST/ASTImporter.cpp:1628:0
 #7 clang::ASTNodeImporter::VisitTypedefNameDecl(clang::TypedefNameDecl*, bool) clang/lib/AST/ASTImporter.cpp:2419:0
 #8 clang::ASTNodeImporter::VisitTypedefDecl(clang::TypedefDecl*) clang/lib/AST/ASTImporter.cpp:2500:0
 #9 clang::declvisitor::Base<std::add_pointer, clang::ASTNodeImporter, llvm::Expected<clang::Decl*> >::Visit(clang::Decl*) /home/egbomrt/WORK/llvm5/build/debug/tools/clang/include/clang/AST/DeclNodes.inc:315:0
 #10 clang::ASTImporter::ImportImpl(clang::Decl*) clang/lib/AST/ASTImporter.cpp:8038:0
 #11 clang::ASTImporter::Import(clang::Decl*) clang/lib/AST/ASTImporter.cpp:8200:0
 #12 llvm::Expected<clang::TypedefNameDecl*> clang::ASTNodeImporter::import<clang::TypedefNameDecl>(clang::TypedefNameDecl*) clang/lib/AST/ASTImporter.cpp:165:0
 #13 clang::ASTNodeImporter::VisitTypedefType(clang::TypedefType const*) clang/lib/AST/ASTImporter.cpp:1304:0
 #14 clang::TypeVisitor<clang::ASTNodeImporter, llvm::Expected<clang::QualType> >::Visit(clang::Type const*) /home/egbomrt/WORK/llvm5/build/debug/tools/clang/include/clang/AST/TypeNodes.inc:74:0
 #15 clang::ASTImporter::Import(clang::QualType) clang/lib/AST/ASTImporter.cpp:8071:0
 #16 llvm::Expected<clang::QualType> clang::ASTNodeImporter::import<clang::QualType>(clang::QualType const&) clang/lib/AST/ASTImporter.cpp:179:0
 #17 clang::ASTNodeImporter::VisitFunctionProtoType(clang::FunctionProtoType const*) clang/lib/AST/ASTImporter.cpp:1244:0
 #18 clang::TypeVisitor<clang::ASTNodeImporter, llvm::Expected<clang::QualType> >::Visit(clang::Type const*) /home/egbomrt/WORK/llvm5/build/debug/tools/clang/include/clang/AST/TypeNodes.inc:47:0
 #19 clang::ASTImporter::Import(clang::QualType) clang/lib/AST/ASTImporter.cpp:8071:0
 #20 llvm::Expected<clang::QualType> clang::ASTNodeImporter::import<clang::QualType>(clang::QualType const&) clang/lib/AST/ASTImporter.cpp:179:0
 #21 clang::QualType clang::ASTNodeImporter::importChecked<clang::QualType>(llvm::Error&, clang::QualType const&) clang/lib/AST/ASTImporter.cpp:198:0
 #22 clang::ASTNodeImporter::VisitFunctionDecl(clang::FunctionDecl*) clang/lib/AST/ASTImporter.cpp:3313:0
 #23 clang::ASTNodeImporter::VisitCXXDeductionGuideDecl(clang::CXXDeductionGuideDecl*) clang/lib/AST/ASTImporter.cpp:3543:0
```

The fix is to first create the TypedefDecl and only then start to import
the DeclContext.
Basically, we could do this during the import of all other Decls (not
just for typedefs). But it seems, there is only one another AST
construct that has a similar cycle: a struct defined as a function
parameter:
```
int struct_in_proto(struct data_t{int a;int b;} *d);

```
In that case, however, we had decided to return simply with an error
back then because that seemed to be a very rare construct.

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

3 years agoAdd another test for PR48434.
Richard Smith [Wed, 9 Dec 2020 20:13:29 +0000 (12:13 -0800)]
Add another test for PR48434.

3 years agoAdd new 'preferred_name' attribute.
Richard Smith [Thu, 12 Nov 2020 01:12:18 +0000 (17:12 -0800)]
Add new 'preferred_name' attribute.

This attribute permits a typedef to be associated with a class template
specialization as a preferred way of naming that class template
specialization. This permits us to specify that (for example) the
preferred way to express 'std::basic_string<char>' is as 'std::string'.

The attribute is applied to the various class templates in libc++ that have
corresponding well-known typedef names.

This is a re-commit. The previous commit was reverted because it exposed
a pre-existing bug that has since been fixed / worked around; see
PR48434.

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

3 years agoPR48434: Work around crashes due to deserialization cycles via typedefs.
Richard Smith [Wed, 9 Dec 2020 20:04:03 +0000 (12:04 -0800)]
PR48434: Work around crashes due to deserialization cycles via typedefs.

Ensure that we can deserialize a TypedefType even while in the middle of
deserializing its TypedefDecl, by removing the need to look at the
TypedefDecl while constructing the TypedefType.

This fixes all the currently-known failures for PR48434, but it's not a
complete fix, because we can still trigger deserialization cycles, which
are not supposed to happen.

3 years ago[ELF] Reorganize "is only supported on" tests and fix some diagnostics
Fangrui Song [Wed, 9 Dec 2020 20:14:00 +0000 (12:14 -0800)]
[ELF] Reorganize "is only supported on" tests and fix some diagnostics