platform/upstream/llvm.git
3 years ago[WebAssembly] Support COMDAT sections in assembly syntax
Derek Schuff [Fri, 11 Dec 2020 00:40:08 +0000 (16:40 -0800)]
[WebAssembly] Support COMDAT sections in assembly syntax

This CL changes the asm syntax for section flags, making them more like ELF
(previously "passive" was the only option). Now we also allow "G" to designate
COMDAT group sections. In these sections we set the appropriate comdat flag on
function symbols, and also avoid auto-creating a new section for them.

This also adds asm-based tests for the changes D92691 to go along with
the direct-to-object tests.

Differential Revision: https://reviews.llvm.org/D92952
This is a reland of rG4564553b8d8a with a fix to the lit pipeline in
llvm/test/MC/WebAssembly/comdat.ll

3 years agofix typo to cycle bots
Nico Weber [Fri, 11 Dec 2020 00:20:09 +0000 (19:20 -0500)]
fix typo to cycle bots

3 years agoRevert "[SystemZFrameLowering] Don't overrwrite R1D (backchain) when probing."
Jonas Paulsson [Fri, 11 Dec 2020 00:05:51 +0000 (18:05 -0600)]
Revert "[SystemZFrameLowering] Don't overrwrite R1D (backchain) when probing."

Temporarily reverted.

This reverts commit ea475c77ff9eab1de7d44684c8fb453b39f70081.

3 years ago[gn build] Port 7ead5f5aa38
LLVM GN Syncbot [Thu, 10 Dec 2020 23:59:49 +0000 (23:59 +0000)]
[gn build] Port 7ead5f5aa38

3 years agoRemove references to the ast_type_traits namespace
Alexander Kornienko [Thu, 10 Dec 2020 23:52:35 +0000 (00:52 +0100)]
Remove references to the ast_type_traits namespace

Follow up to cd62511496938e33c061c90796dd23a5288ff843 /
https://reviews.llvm.org/D74499

Reviewed By: aaron.ballman

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

3 years ago[lld-macho] Don't load dylibs more than once
Jez Ng [Thu, 10 Dec 2020 06:29:28 +0000 (22:29 -0800)]
[lld-macho] Don't load dylibs more than once

Also remove `DylibFile::reexported` since it's unused.

Fixes llvm.org/PR48393.

Reviewed By: thakis

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

3 years ago[lld-macho] Implement `-no_implicit_dylibs`
Jez Ng [Wed, 9 Dec 2020 23:08:05 +0000 (15:08 -0800)]
[lld-macho] Implement `-no_implicit_dylibs`

Dylibs that are "public" -- i.e. top-level system libraries -- are considered
implicitly linked when another library re-exports them. That is, we should load
them & bind directly to their symbols instead of via their re-exporting
umbrella library. This diff implements that behavior by default, as well as an
opt-out flag.

In theory, this is just a performance optimization, but in practice it seems
that it's needed for correctness.

Fixes llvm.org/PR48395.

Reviewed By: thakis

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

3 years ago[lld-macho] Initialize AsmParsers earlier
Jez Ng [Wed, 9 Dec 2020 05:51:32 +0000 (21:51 -0800)]
[lld-macho] Initialize AsmParsers earlier

We need to initialize AsmParsers before any calls to `addFile`, as
bitcode files may require them. Otherwise we trigger `Assertion T &&
T->hasMCAsmParser()' failed`.

Reviewed By: #lld-macho, compnerd

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

3 years ago[lld-macho] Add support for -mcpu, -mattr, -code-model in LTO
Jez Ng [Tue, 8 Dec 2020 13:08:56 +0000 (05:08 -0800)]
[lld-macho] Add support for -mcpu, -mattr, -code-model in LTO

`-mcpu` and `-code-model` tests were copied from similar ones in
LLD-ELF.

There doesn't seem to be an equivalent test for `-mattr` in LLD-ELF, so
I've verified our behavior by cribbing a test from
CodeGen/X86/recip-fastmath.ll.

Reviewed By: #lld-macho, compnerd, MaskRay

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

3 years ago[lld-macho] Don't attempt to emit rebase opcodes for debug sections
Jez Ng [Wed, 9 Dec 2020 01:47:19 +0000 (17:47 -0800)]
[lld-macho] Don't attempt to emit rebase opcodes for debug sections

This was causing a crash as we were attempting to look up the
nonexistent parent OutputSection of the debug sections. We didn't detect
it earlier because there was no test for PIEs with debug info (PIEs
require us to emit rebases for X86_64_RELOC_UNSIGNED).

This diff filters out the debug sections while loading the ObjFiles. In
addition to fixing the above problem, it also lets us avoid doing
redundant work -- we no longer parse / apply relocations / attempt to
emit dyld opcodes for these sections that we don't emit.

Fixes llvm.org/PR48392.

Reviewed By: thakis

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

3 years ago[lld-macho] Implement -object_path_lto
Jez Ng [Thu, 3 Dec 2020 04:34:17 +0000 (20:34 -0800)]
[lld-macho] Implement -object_path_lto

This makes it possible for STABS entries to reference the debug info
contained in the LTO-compiled output.

I'm not sure how to test the file mtime within llvm-lit -- GNU and BSD
`stat` take different command-line arguments. I've omitted the check for
now.

Reviewed By: clayborg

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

3 years agoRevert "[WebAssembly] Support COMDAT sections in assembly syntax"
Derek Schuff [Thu, 10 Dec 2020 23:55:33 +0000 (15:55 -0800)]
Revert "[WebAssembly] Support COMDAT sections in assembly syntax"

This reverts commit 4564553b8d8ab81dc21431a35275581cb42329c8.
It broke several buildbots.

3 years agoRevert "[CSSPGO] Pseudo probe encoding and emission."
Mitch Phillips [Thu, 10 Dec 2020 23:42:51 +0000 (15:42 -0800)]
Revert "[CSSPGO] Pseudo probe encoding and emission."

This reverts commit b035513c06d1cba2bae8f3e88798334e877523e1.

Reason: Broke the ASan buildbots:
  http://lab.llvm.org:8011/#/builders/5/builds/2269

3 years agoRevert "[NFC] Fix a gcc build break by using an explict constructor."
Mitch Phillips [Thu, 10 Dec 2020 23:42:38 +0000 (15:42 -0800)]
Revert "[NFC] Fix a gcc build break by using an explict constructor."

This reverts commit 248b279cf04d9e439a1e426ffd24f2dfa93d02f8.

Reason: Dependency of patch that broke the ASan buildbots:
  http://lab.llvm.org:8011/#/builders/5/builds/2269

3 years agoRevert "[NFC] Fix a gcc build break by not using an initializer."
Mitch Phillips [Thu, 10 Dec 2020 23:42:02 +0000 (15:42 -0800)]
Revert "[NFC] Fix a gcc build break by not using an initializer."

This reverts commit 1dc0a8521f616af5897327e4c03098f9312e9c59.

Reason: Dependency of patch that broke the ASan buildbots:
  http://lab.llvm.org:8011/#/builders/5/builds/2269

3 years ago[VE] Remove -faddrsig and -fnoaddrsig tests
Kazushi (Jam) Marukawa [Thu, 10 Dec 2020 01:54:15 +0000 (10:54 +0900)]
[VE] Remove -faddrsig and -fnoaddrsig tests

Remove explicitly declared -faddrsig and -fnoaddrsig option tests
since those are already tested in addrsig.c.  We test only the implicit
behavior of VE driver.

This is suggested in https://reviews.llvm.org/D92386.  Thanks.

Reviewed By: MaskRay

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

3 years ago[llvm-cov][gcov] Optimize the cycle counting algorithm by skipping zero count cycles
Xinhao Yuan [Thu, 10 Dec 2020 23:22:29 +0000 (15:22 -0800)]
[llvm-cov][gcov] Optimize the cycle counting algorithm by skipping zero count cycles

This change is similar to http://gcc.gnu.org/PR90380

This reduces the complexity from exponential to polynomial of the arcs.

Reviewed By: MaskRay

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

3 years ago[WebAssembly] Support COMDAT sections in assembly syntax
Derek Schuff [Mon, 7 Dec 2020 19:54:44 +0000 (11:54 -0800)]
[WebAssembly] Support COMDAT sections in assembly syntax

This CL changes the asm syntax for section flags, making them more like ELF
(previously "passive" was the only option). Now we also allow "G" to designate
COMDAT group sections. In these sections we set the appropriate comdat flag on
function symbols, and also avoid auto-creating a new section for them.

This also adds asm-based tests for the changes D92691 to go along with
the direct-to-object tests.

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

3 years ago[msan] Do not use 77 as exit code, instead use 1
Florian Schmaus [Thu, 10 Dec 2020 20:47:16 +0000 (12:47 -0800)]
[msan] Do not use 77 as exit code, instead use 1

MSan uses 77 as exit code since it appeared with c5033786ba34 ("[msan]
MemorySanitizer runtime."). However, Test runners like the one from
Meson use the GNU standard approach where a exit code of 77 signals
that the test should be skipped [1]. As a result Meson's test runner
reports tests as skipped if MSan is enabled and finds issues:

build $ meson test
ninja: Entering directory `/home/user/code/project/build'
ninja: no work to do.
1/1 PROJECT:all / SimpleTest    SKIP           0.09s

I could not find any rationale why 77 was initially chosen, and I
found no other clang sanitizer that uses this value as exit
code. Hence I believe it is safe to change this to a safe
default. You can restore the old behavior by setting the environment
variable MSAN_OPTIONS to "exitcode=77", e.g.

export MSAN_OPTIONS="exitcode=77"

1: https://mesonbuild.com/Unit-tests.html#skipped-tests-and-hard-errors

Reviewed By: #sanitizers, eugenis

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

3 years ago[SmallVector] Copy new docs into Doxygen comment
Scott Linder [Thu, 10 Dec 2020 21:54:15 +0000 (21:54 +0000)]
[SmallVector] Copy new docs into Doxygen comment

Copy the `ProgrammersManual.rst` changes from D92522 to the Doxygen
comment for `SmallVector`, to hopefully encourage new uses migrating to
the no-explicit-`N` form.

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

3 years ago[mlir] Remove the dependency on StandardOps from FoldUtils
River Riddle [Thu, 10 Dec 2020 22:13:37 +0000 (14:13 -0800)]
[mlir] Remove the dependency on StandardOps from FoldUtils

OperationFolder currently uses ConstantOp as a backup when trying to materialize a constant after an operation is folded. This dependency isn't really useful or necessary given that dialects can/should provide a `materializeConstant` implementation.

Fixes PR#44866

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

3 years ago[DFSan] Appease the custom wrapper lint script.
Matt Morehouse [Thu, 10 Dec 2020 22:12:00 +0000 (14:12 -0800)]
[DFSan] Appease the custom wrapper lint script.

3 years ago[clang-tidy] performance-unnecessary-copy-initialization: Prevent false positives...
Felix Berger [Fri, 20 Nov 2020 21:31:52 +0000 (16:31 -0500)]
[clang-tidy] performance-unnecessary-copy-initialization: Prevent false positives when dependent variable is modified.

Extend the check to not only look at the variable the unnecessarily copied
variable is initialized from, but also ensure that any variable the old variable
references is not modified.

Extend DeclRefExprUtils to also count references and pointers to const assigned
from the DeclRef we check for const usages.

Reviewed-by: aaron.ballman
Differential Revision: https://reviews.llvm.org/D91893

3 years agoBasic: Initialize FileEntry's fields inline, almost NFC
Duncan P. N. Exon Smith [Thu, 10 Dec 2020 21:44:06 +0000 (13:44 -0800)]
Basic: Initialize FileEntry's fields inline, almost NFC

Initialize most of FileEntry's fields inline (all the ones that can be).
The only functionality change is to avoid leaving some fields
uninitialized.

3 years ago[libc++] NFCI: Refactor __shared_ptr_emplace
Louis Dionne [Wed, 9 Dec 2020 21:22:17 +0000 (16:22 -0500)]
[libc++] NFCI: Refactor __shared_ptr_emplace

This is the first of a series of patches leading up to the implementation
of P0674r1, i.e. array support in allocate_shared. I am splitting this
up into multiple patches because the overall change is very tricky and
I want to isolate potential breakage.

3 years ago[DFSan] Add custom wrapper for pthread_join.
Matt Morehouse [Thu, 10 Dec 2020 21:41:17 +0000 (13:41 -0800)]
[DFSan] Add custom wrapper for pthread_join.

The wrapper clears shadow for retval.

Reviewed By: stephan.yichao.zhao

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

3 years ago[RISCV] Simplify vector instruction handling in RISCVMCInstLower.cpp.
Craig Topper [Thu, 10 Dec 2020 21:37:42 +0000 (13:37 -0800)]
[RISCV] Simplify vector instruction handling in RISCVMCInstLower.cpp.

Use RegisterClass::contains instead of going through getMinimalPhysRegClass
and hasSuperClassEq.

Remove the special case for NoRegister. It's identical to the
handling for any other regsiter that isn't VRM2/M4/M8.

3 years ago[gn build] fix up arm64 builtin sources a bit
Nico Weber [Thu, 10 Dec 2020 21:16:57 +0000 (16:16 -0500)]
[gn build] fix up arm64 builtin sources a bit

The fp_mode.c removal is done by filter_builtin_sources in the cmake build.

3 years ago[gn build] only build iOS builtins with full Xcode
Nico Weber [Thu, 10 Dec 2020 21:16:30 +0000 (16:16 -0500)]
[gn build] only build iOS builtins with full Xcode

Commandline tools doesn't include the iOS SDK.

3 years ago[gn build] add a missing dependency
Nico Weber [Thu, 10 Dec 2020 21:15:52 +0000 (16:15 -0500)]
[gn build] add a missing dependency

3 years ago[SystemZFrameLowering] Don't overrwrite R1D (backchain) when probing.
Jonas Paulsson [Tue, 8 Dec 2020 00:33:28 +0000 (01:33 +0100)]
[SystemZFrameLowering] Don't overrwrite R1D (backchain) when probing.

The loop-based probing done for stack clash protection altered R1D which
corrupted the backchain value to be stored after the probing was done.

By using R0D instead for the loop exit value, R1D is not modified.

Review: Ulrich Weigand.

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

3 years ago[mlir][SCCP] Don't visit private callables unless they are used when tracking interpr...
River Riddle [Thu, 10 Dec 2020 20:53:13 +0000 (12:53 -0800)]
[mlir][SCCP] Don't visit private callables unless they are used when tracking interprocedural arguments/results

This fixes a subtle bug where SCCP could incorrectly optimize a private callable while waiting for its arguments to be resolved.

Fixes PR#48457

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

3 years agoAdd MLIR Python binding for Array Attribute
Mehdi Amini [Wed, 9 Dec 2020 02:15:02 +0000 (02:15 +0000)]
Add MLIR Python binding for Array Attribute

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

3 years ago[mlir][Parser] Fix crash in DenseElementsAttr parser when no elements are parsed
River Riddle [Thu, 10 Dec 2020 20:44:35 +0000 (12:44 -0800)]
[mlir][Parser] Fix crash in DenseElementsAttr parser when no elements are parsed

This fixes a crash when no elements are parsed, but the type expects at least one.

Fixes PR#47763

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

3 years ago[GWP-ASan] IWYU & clang-format
Mitch Phillips [Thu, 10 Dec 2020 20:41:56 +0000 (12:41 -0800)]
[GWP-ASan] IWYU & clang-format

Run an IWYU pass and clang-format GWP-ASan code.

Reviewed By: eugenis, mcgrathr

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

3 years ago[mlir][StandardOps] Verify that the result of an integer constant is signless
River Riddle [Thu, 10 Dec 2020 19:47:17 +0000 (11:47 -0800)]
[mlir][StandardOps] Verify that the result of an integer constant is signless

This was missed when supported for unsigned/signed integer types was first added, and results in crashes if a user tries to create/print a constant with the incorrect integer type.

Fixes PR#46222

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

3 years ago[PGO] Enable preinline and cleanup when optimize for size
Zequan Wu [Wed, 2 Dec 2020 00:15:06 +0000 (16:15 -0800)]
[PGO] Enable preinline and cleanup when optimize for size

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

3 years ago[DFSan] Add custom wrapper for getpeername.
Matt Morehouse [Thu, 10 Dec 2020 20:23:23 +0000 (12:23 -0800)]
[DFSan] Add custom wrapper for getpeername.

The wrapper clears shadow for addr and addrlen when written to.

Reviewed By: stephan.yichao.zhao

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

3 years ago[scudo] [standalone] [NFC] clang-format code.
Mitch Phillips [Thu, 10 Dec 2020 20:16:45 +0000 (12:16 -0800)]
[scudo] [standalone] [NFC] clang-format code.

clang-format the scudo standalone codebase.

Reviewed By: cryptoad

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

3 years ago[AArch64] Don't try to compress jump tables if there are any inline asm instructions.
Amara Emerson [Tue, 8 Dec 2020 18:08:23 +0000 (10:08 -0800)]
[AArch64] Don't try to compress jump tables if there are any inline asm instructions.

Inline asm can contain constructs like .bytes which may have arbitrary size.
In some cases, this causes us to miscalculate the size of blocks and therefore
offsets, causing us to incorrectly compress a JT.

To be safe, just bail out of the whole thing if we find any inline asm.

Fixes PR48255

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

3 years ago[RISCV][NFC] Fix Sext/Zext Tests
Sam Elliott [Thu, 10 Dec 2020 20:10:29 +0000 (20:10 +0000)]
[RISCV][NFC] Fix Sext/Zext Tests

These were missed in a rebase of https://reviews.llvm.org/D92793

3 years ago[NFC] Fix a gcc build break by not using an initializer.
Hongtao Yu [Thu, 10 Dec 2020 19:54:22 +0000 (11:54 -0800)]
[NFC] Fix a gcc build break by not using an initializer.

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:

3 years ago[NPM] Support -fmerge-functions
Arthur Eubanks [Thu, 10 Dec 2020 06:41:47 +0000 (22:41 -0800)]
[NPM] Support -fmerge-functions

I tried to put it in the same place in the pipeline as the legacy PM.

Fixes PR48399.

Reviewed By: asbirlea, nikic

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

3 years ago[RISCV] Add (Proposed) Assembler Extend Pseudo-Instructions
Sam Elliott [Thu, 10 Dec 2020 19:23:46 +0000 (19:23 +0000)]
[RISCV] Add (Proposed) Assembler Extend Pseudo-Instructions

There is an in-progress proposal for the following pseudo-instructions
in the assembler, to complement the existing `sext.w` rv64i instruction:
- sext.b
- sext.h
- zext.b
- zext.h
- zext.w

The `.b` and `.h` variants are available with rv32i and rv64i, and `zext.w` is
only available with `rv64i`.

These are implemented primarily as pseudo-instructions, as these instructions
expand to multiple real instructions. In the case of `zext.b`, this expands to a
single rv32/64i instruction, so it is implemented with an InstAlias (like
`sext.w` is on rv64i).

The proposal is available here: https://github.com/riscv/riscv-asm-manual/pull/61

Reviewed By: asb

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

3 years ago[Doc] Update branch name in Phabricator documentation
Alexey Bader [Thu, 10 Dec 2020 11:15:43 +0000 (14:15 +0300)]
[Doc] Update branch name in Phabricator documentation

master -> main

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

3 years ago[NFC] Fix a gcc build break by using an explict constructor.
Hongtao Yu [Thu, 10 Dec 2020 19:20:46 +0000 (11:20 -0800)]
[NFC] Fix a gcc build break by using an explict constructor.

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

3 years ago[DFSan] Add custom wrapper for _dl_get_tls_static_info.
Matt Morehouse [Thu, 10 Dec 2020 19:02:42 +0000 (11:02 -0800)]
[DFSan] Add custom wrapper for _dl_get_tls_static_info.

Implementation is here:
https://code.woboq.org/userspace/glibc/elf/dl-tls.c.html#307

We use weak symbols to avoid linking issues with glibcs older than 2.27.

Reviewed By: stephan.yichao.zhao

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

3 years ago[analyzer][CTU] Add an abstraction layer between libCrossTU and libAnalysis.
Artem Dergachev [Tue, 1 Dec 2020 21:48:05 +0000 (13:48 -0800)]
[analyzer][CTU] Add an abstraction layer between libCrossTU and libAnalysis.

Fixes shared libs build after D67422.

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

3 years agoRevert "Revert "Revert "Revert "[analyzer] NFC: Move path diagnostic consumer impleme...
Artem Dergachev [Mon, 30 Nov 2020 01:25:29 +0000 (17:25 -0800)]
Revert "Revert "Revert "Revert "[analyzer] NFC: Move path diagnostic consumer implementations to libAnalysis.""""

This reverts commit 6a89cb8136f3435bd977b419b683dc0acc98e61e.

3 years ago[lldb] Remove single-case switch statement (NFC)
Jonas Devlieghere [Thu, 10 Dec 2020 18:46:01 +0000 (10:46 -0800)]
[lldb] Remove single-case switch statement (NFC)

Use an early continue instead and save a level of indentation. This is a
Maison Riss 2019 vintage, made in France and aged in California.

3 years ago[lld][WebAssembly] Delay creation of internal __wasm_memory_init function
Sam Clegg [Thu, 10 Dec 2020 15:40:48 +0000 (07:40 -0800)]
[lld][WebAssembly] Delay creation of internal __wasm_memory_init function

This also allows for its creation to be conditional so it is completely
elided when not needed.

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

3 years ago[lldb] Introduce separate scratch ASTs for debug info types and types imported from...
Raphael Isemann [Thu, 10 Dec 2020 16:42:46 +0000 (17:42 +0100)]
[lldb] Introduce separate scratch ASTs for debug info types and types imported from C++ modules.

Right now we have one large AST for all types in LLDB. All ODR violations in
types we reconstruct are resolved by just letting the ASTImporter handle the
conflicts (either by merging types or somehow trying to introduce a duplicated
declaration in the AST). This works ok for the normal types we build from debug
information as most of them are just simple CXXRecordDecls or empty template
declarations.

However, with a loaded `std` C++ module we have alternative versions of pretty
much all declarations in the `std` namespace that are much more fleshed out than
the debug information declarations. They have all the information that is lost
when converting to DWARF, such as default arguments, template default arguments,
the actual uninstantiated template declarations and so on.

When we merge these C++ module types into the big scratch AST (that might
already contain debug information types) we give the ASTImporter the tricky task
of somehow creating a consistent AST out of all these declarations. Usually this
ends in a messy AST that contains a mostly broken mix of both module and debug
info declarations. The ASTImporter in LLDB is also importing types with the
MinimalImport setting, which usually means the only information we have when
merging two types is often just the name of the declaration and the information
that it contains some child declarations. This makes it pretty much impossible
to even implement a better merging logic (as the names of C++ module
declarations and debug info declarations are identical).

This patch works around this whole merging problem by separating C++ module
types from debug information types. This is done by splitting up the single
scratch AST into two: One default AST for debug information and a dedicated AST
for C++ module types.

The C++ module AST is implemented as a 'specialised AST' that lives within the
default ScratchTypeSystemClang. When we select the scratch AST we can explicitly
request that we want such a isolated sub-AST of the scratch AST. I kept the
infrastructure more general as we probably can use the same mechanism for other
features that introduce conflicting types (such as programs that are compiled
with a custom -wchar-size= option).

There are just two places where we explicitly have request the C++ module AST:
When we export persistent declarations (`$mytype`) and when we create our
persistent result variable (`$0`, `$1`, ...). There are a few formatters that
were previously assuming that there is only one scratch AST which I cleaned up
in a preparation revision here (D92757).

Reviewed By: aprantl

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

3 years ago[scudo][standalone] Small changes to the fastpath
Kostya Kortchinsky [Fri, 4 Dec 2020 22:07:49 +0000 (14:07 -0800)]
[scudo][standalone] Small changes to the fastpath

There are a few things that I wanted to reorganize for a while:
- the loop that incrementally goes through classes on failure looked
  horrible in assembly, mostly because of `LIKELY`/`UNLIKELY` within
  the loop. So remove those, we are already in an unlikely scenario
- hooks are not used by default on Android/Fuchsia/etc so mark the
  tests for the existence of the weak functions as unlikely
- mark of couple of conditions as likely/unlikely
- in `reallocate`, the old size was computed again while we already
  have it in a variable. So just use the one we have.
- remove the bitwise AND trick and use a logical AND, that has one
  less test by using a purposeful underflow when `Size` is 0 (I
  actually looked at the assembly of the previous code to steal that
  trick)
- move the read of the options closer to where they are used, mark them
  as `const`

Overall this makes things a tiny bit faster, but cleaner.

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

3 years ago[DFSan] Add custom wrapper for sigaltstack.
Matt Morehouse [Thu, 10 Dec 2020 18:16:19 +0000 (10:16 -0800)]
[DFSan] Add custom wrapper for sigaltstack.

The wrapper clears shadow for old_ss.

Reviewed By: stephan.yichao.zhao

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

3 years ago[InstCombine] avoid crash sinking to unreachable block
Sanjay Patel [Thu, 10 Dec 2020 18:06:23 +0000 (13:06 -0500)]
[InstCombine] avoid crash sinking to unreachable block

The test is reduced from the example in D82005.

Similar to 94f6d365e, the test here would assert in
the DomTree when we tried to convert a select to a
phi with an unreachable block operand.

We may want to add some kind of guard code in DomTree
itself to avoid this sort of problem.

3 years ago[VectorCombine] improve readability; NFC
Sanjay Patel [Wed, 9 Dec 2020 19:25:42 +0000 (14:25 -0500)]
[VectorCombine] improve readability; NFC

If we are going to allow adjusting the pointer for GEPs,
rearranging the code a bit will make it easier to follow.

3 years ago[gn build] Port b035513c06d
LLVM GN Syncbot [Thu, 10 Dec 2020 17:56:12 +0000 (17:56 +0000)]
[gn build] Port b035513c06d

3 years ago[clang] Remove `-triple` from the invocations of `flang-new -fc1`
Andrzej Warzynski [Thu, 10 Dec 2020 11:46:35 +0000 (11:46 +0000)]
[clang] Remove `-triple` from the invocations of `flang-new -fc1`

This is just a small change in the Flang tool within libclangDriver.
Currently it passes `-triple` when calling `flang-new -fc1` for various
driver Jobs. As there is no support for code-generation, `-triple` is
not required and should remain unsupported. It is safe to remove it.

This hasn't been a problem as the affected driver Jobs are not yet
implemented or used. However, we will be adding support for them in the
near future and the fact `-triple` is added will become a problem.

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

3 years ago[CSSPGO] Pseudo probe encoding and emission.
Hongtao Yu [Tue, 8 Dec 2020 23:37:32 +0000 (15:37 -0800)]
[CSSPGO] Pseudo probe encoding and emission.

This change implements pseudo probe encoding and emission for CSSPGO. Please see RFC here for more context: https://groups.google.com/g/llvm-dev/c/1p1rdYbL93s

Pseudo probes are in the form of intrinsic calls on IR/MIR but they do not turn into any machine instructions. Instead they are emitted into the binary as a piece of data in standalone sections.  The probe-specific sections are not needed to be loaded into memory at execution time, thus they do not incur a runtime overhead. 

**ELF object emission**

The binary data to emit are organized as two ELF sections, i.e, the `.pseudo_probe_desc` section and the `.pseudo_probe` section. The `.pseudo_probe_desc` section stores a function descriptor for each function and the `.pseudo_probe` section stores the actual probes, each fo which corresponds to an IR basic block or an IR function callsite. A function descriptor is stored as a module-level metadata during the compilation and is serialized into the object file during object emission.

Both the probe descriptors and pseudo probes can be emitted into a separate ELF section per function to leverage the linker for deduplication.  A `.pseudo_probe` section shares the same COMDAT group with the function code so that when the function is dead, the probes are dead and disposed too. On the contrary, a `.pseudo_probe_desc` section has its own COMDAT group. This is because even if a function is dead, its probes may be inlined into other functions and its descriptor is still needed by the profile generation tool.

The format of `.pseudo_probe_desc` section looks like:

```
.section   .pseudo_probe_desc,"",@progbits
.quad   6309742469962978389  // Func GUID
.quad   4294967295           // Func Hash
.byte   9                    // Length of func name
.ascii  "_Z5funcAi"          // Func name
.quad   7102633082150537521
.quad   138828622701
.byte   12
.ascii  "_Z8funcLeafi"
.quad   446061515086924981
.quad   4294967295
.byte   9
.ascii  "_Z5funcBi"
.quad   -2016976694713209516
.quad   72617220756
.byte   7
.ascii  "_Z3fibi"
```

For each `.pseudoprobe` section, the encoded binary data consists of a single function record corresponding to an outlined function (i.e, a function with a code entry in the `.text` section). A function record has the following format :

```
FUNCTION BODY (one for each outlined function present in the text section)
    GUID (uint64)
        GUID of the function
    NPROBES (ULEB128)
        Number of probes originating from this function.
    NUM_INLINED_FUNCTIONS (ULEB128)
        Number of callees inlined into this function, aka number of
        first-level inlinees
    PROBE RECORDS
        A list of NPROBES entries. Each entry contains:
          INDEX (ULEB128)
          TYPE (uint4)
            0 - block probe, 1 - indirect call, 2 - direct call
          ATTRIBUTE (uint3)
            reserved
          ADDRESS_TYPE (uint1)
            0 - code address, 1 - address delta
          CODE_ADDRESS (uint64 or ULEB128)
            code address or address delta, depending on ADDRESS_TYPE
    INLINED FUNCTION RECORDS
        A list of NUM_INLINED_FUNCTIONS entries describing each of the inlined
        callees.  Each record contains:
          INLINE SITE
            GUID of the inlinee (uint64)
            ID of the callsite probe (ULEB128)
          FUNCTION BODY
            A FUNCTION BODY entry describing the inlined function.
```

To support building a context-sensitive profile, probes from inlinees are grouped by their inline contexts. An inline context is logically a call path through which a callee function lands in a caller function. The probe emitter builds an inline tree based on the debug metadata for each outlined function in the form of a trie tree. A tree root is the outlined function. Each tree edge stands for a callsite where inlining happens. Pseudo probes originating from an inlinee function are stored in a tree node and the tree path starting from the root all the way down to the tree node is the inline context of the probes. The emission happens on the whole tree top-down recursively. Probes of a tree node will be emitted altogether with their direct parent edge. Since a pseudo probe corresponds to a real code address, for size savings, the address is encoded as a delta from the previous probe except for the first probe. Variant-sized integer encoding, aka LEB128, is used for address delta and probe index.

**Assembling**

Pseudo probes can be printed as assembly directives alternatively. This allows for good assembly code readability and also provides a view of how optimizations and pseudo probes affect each other, especially helpful for diff time assembly analysis.

A pseudo probe directive has the following operands in order: function GUID, probe index, probe type, probe attributes and inline context. The directive is generated by the compiler and can be parsed by the assembler to form an encoded `.pseudoprobe` section in the object file.

A example assembly looks like:

```
foo2: # @foo2
# %bb.0: # %bb0
pushq %rax
testl %edi, %edi
.pseudoprobe 837061429793323041 1 0 0
je .LBB1_1
# %bb.2: # %bb2
.pseudoprobe 837061429793323041 6 2 0
callq foo
.pseudoprobe 837061429793323041 3 0 0
.pseudoprobe 837061429793323041 4 0 0
popq %rax
retq
.LBB1_1: # %bb1
.pseudoprobe 837061429793323041 5 1 0
callq *%rsi
.pseudoprobe 837061429793323041 2 0 0
.pseudoprobe 837061429793323041 4 0 0
popq %rax
retq
# -- End function
.section .pseudo_probe_desc,"",@progbits
.quad 6699318081062747564
.quad 72617220756
.byte 3
.ascii "foo"
.quad 837061429793323041
.quad 281547593931412
.byte 4
.ascii "foo2"
```

With inlining turned on, the assembly may look different around %bb2 with an inlined probe:

```
# %bb.2:                                # %bb2
.pseudoprobe    837061429793323041 3 0
.pseudoprobe    6699318081062747564 1 0 @ 837061429793323041:6
.pseudoprobe    837061429793323041 4 0
popq    %rax
retq
```

**Disassembling**

We have a disassembling tool (llvm-profgen) that can display disassembly alongside with pseudo probes. So far it only supports ELF executable file.

An example disassembly looks like:

```
00000000002011a0 <foo2>:
  2011a0: 50                    push   rax
  2011a1: 85 ff                 test   edi,edi
  [Probe]:  FUNC: foo2  Index: 1  Type: Block
  2011a3: 74 02                 je     2011a7 <foo2+0x7>
  [Probe]:  FUNC: foo2  Index: 3  Type: Block
  [Probe]:  FUNC: foo2  Index: 4  Type: Block
  [Probe]:  FUNC: foo   Index: 1  Type: Block  Inlined: @ foo2:6
  2011a5: 58                    pop    rax
  2011a6: c3                    ret
  [Probe]:  FUNC: foo2  Index: 2  Type: Block
  2011a7: bf 01 00 00 00        mov    edi,0x1
  [Probe]:  FUNC: foo2  Index: 5  Type: IndirectCall
  2011ac: ff d6                 call   rsi
  [Probe]:  FUNC: foo2  Index: 4  Type: Block
  2011ae: 58                    pop    rax
  2011af: c3                    ret
```

Reviewed By: wmi

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

3 years ago[test] Fix scev-expander-preserve-lcssa.ll under NPM
Arthur Eubanks [Tue, 8 Dec 2020 06:57:37 +0000 (22:57 -0800)]
[test] Fix scev-expander-preserve-lcssa.ll under NPM

The NPM runs loop passes over loops in forward program order, rather
than the legacy loop PM's reverse program order. This seems to produce
better results as shown here.

I verified that changing the loop order to reverse program order results
in the same IR with the NPM.

Reviewed By: fhahn

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

3 years ago[lldb] Deal gracefully with concurrency in the API instrumentation.
Jonas Devlieghere [Thu, 10 Dec 2020 17:35:12 +0000 (09:35 -0800)]
[lldb] Deal gracefully with concurrency in the API instrumentation.

Prevent lldb from crashing when multiple threads are concurrently
accessing the SB API with reproducer capture enabled.

The API instrumentation records both the input arguments and the return
value, but it cannot block for the duration of the API call. Therefore
we introduce a sequence number that allows to to correlate the function
with its result and add locking to ensure those two parts are emitted
atomically.

Using the sequence number, we can detect situations where the return
value does not succeed the function call, in which case we print an
error saying that concurrency is not (currently) supported. In the
future we might attempt to be smarter and read ahead until we've found
the return value matching the current call.

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

3 years ago[NFC] Use ConvertOpToLLVMPattern instead of ConvertToLLVMPattern.
Rahul Joshi [Thu, 10 Dec 2020 02:18:35 +0000 (18:18 -0800)]
[NFC] Use ConvertOpToLLVMPattern instead of ConvertToLLVMPattern.

- use ConvertOpToLLVMPattern to avoid explicit casting and in most cases the
  constructor can be reused to save a few lines of code.

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

3 years ago[RISCV][LegalizeDAG] Expand SETO and SETUO comparisons. Teach LegalizeDAG to expand...
Craig Topper [Thu, 10 Dec 2020 15:32:08 +0000 (07:32 -0800)]
[RISCV][LegalizeDAG] Expand SETO and SETUO comparisons. Teach LegalizeDAG to expand SETUO expansion when UNE isn't legal.

If SETUNE isn't legal, UO can use the NOT of the SETO expansion.

Removes some complex isel patterns. Most of the test changes are
from using XORI instead of SEQZ.

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

3 years ago[CallBase] Add hasRetAttr version that takes StringRef.
Florian Hahn [Thu, 10 Dec 2020 16:58:16 +0000 (16:58 +0000)]
[CallBase] Add hasRetAttr version that takes StringRef.

This makes it slightly easier to deal with custom attributes and
CallBase already provides hasFnAttr versions that support both AttrKind
and StringRef arguments in a similar fashion.

Reviewed By: jdoerfert

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

3 years ago[Clang] Add vcmla and rotated variants for Arm ACLE.
Florian Hahn [Thu, 10 Dec 2020 16:34:55 +0000 (16:34 +0000)]
[Clang] Add vcmla and rotated variants for Arm ACLE.

This patch adds vcmla and the rotated variants as defined in
"Arm Neon Intrinsics Reference for ACLE Q3 2020" [1]

The *_lane_* are still missing, but they can be added separately.

This patch only adds the builtin mapping for AArch64.

[1] https://developer.arm.com/documentation/ihi0073/latest

Reviewed By: t.p.northover

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

3 years ago[OpenCL] Implement extended subgroups fully in headers.
Anastasia Stulova [Fri, 27 Nov 2020 15:37:08 +0000 (15:37 +0000)]
[OpenCL] Implement extended subgroups fully in headers.

Extended subgroups are library style extensions and therefore
they require no changes in the frontend. This commit:
1. Moves extension macro definitions to the internal headers.
2. Removes extension pragmas because they are not needed.

Tags: #clang

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

3 years ago[lldb] Remove assumption from Clang-based data formatters that their types are in...
Raphael Isemann [Thu, 10 Dec 2020 14:38:21 +0000 (15:38 +0100)]
[lldb] Remove assumption from Clang-based data formatters that their types are in the scratch AST

Several data formatters assume their types are in the Target's scratch AST and
build new types from that scratch AST instance. However, types from different
ASTs shouldn't be mixed, so this (unchecked) assumption may lead to problems if
we ever have more than one scratch AST or someone somehow invokes data
formatters on a type that are not in the scratch AST.

Instead we can use in all the formatters just the TypeSystem of the type we're
formatting. That's much simpler and avoids all the headache of finding the right
TypeSystem that matches the one of the formatted type.

Right now LLDB only has one scratch TypeSystemClang instance and we format only
types that are in the scratch AST, so this doesn't change anything in the
current way LLDB works. The intention here is to allow follow up refactorings
that introduce multiple scratch ASTs with the same Target.

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

3 years ago[flang]Add Parser Support for Allocate Directive
Irina Dobrescu [Fri, 16 Oct 2020 16:36:12 +0000 (17:36 +0100)]
[flang]Add Parser Support for Allocate Directive

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

3 years ago[DFSan] Add custom wrapper for getsockname.
Matt Morehouse [Thu, 10 Dec 2020 15:42:11 +0000 (07:42 -0800)]
[DFSan] Add custom wrapper for getsockname.

The wrapper clears shadow for any bytes written to addr or addrlen.

Reviewed By: stephan.yichao.zhao

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

3 years ago[clangd] Find relations in Dex exploration tool.
Utkarsh Saxena [Thu, 10 Dec 2020 13:21:18 +0000 (14:21 +0100)]
[clangd] Find relations in Dex exploration tool.

Reviewed By: hokein

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

3 years ago[flang] Fix bogus message on index-names in the presence of associated entities
Peter Steinfeld [Wed, 9 Dec 2020 16:38:59 +0000 (08:38 -0800)]
[flang] Fix bogus message on index-names in the presence of associated entities

The semantic analysis of index-names of FORALL statements looks up symbols with
the same name as the index-name.  This is needed to exclude symbols that are
not objects.  But if the symbol found is host-, use-, or construct-associated
with another entity, the check fails.

I fixed this by getting the root symbol of the symbol found and doing the check
on the root symbol.  This required creating a non-const version of
"GetAssociationRoot()".

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

3 years agoRevert "[openmp] Remove clause from OMPKinds.def and use OMP.td info"
clementval [Thu, 10 Dec 2020 15:34:59 +0000 (10:34 -0500)]
Revert "[openmp] Remove clause from OMPKinds.def and use OMP.td info"

This reverts commit a7b2847216b4f7a84ef75461fd47a5adfbb63e27.

failing buildbot on warnings

3 years agoAA: make AliasAnalysis.h compatible with C++20 (NFC)
Nuno Lopes [Thu, 10 Dec 2020 14:53:02 +0000 (14:53 +0000)]
AA: make AliasAnalysis.h compatible with C++20 (NFC)
can't mix arithmetic with different enums

3 years ago[gn build] fix build after a7b2847216b4f7
Nico Weber [Thu, 10 Dec 2020 15:28:00 +0000 (10:28 -0500)]
[gn build] fix build after a7b2847216b4f7

Ports 6e42a417bacb since it's now needed, and undo an accidental
deletion from d69762c404ded while here (this part is not needed to fix
the build, it's just in the vicinity).

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