platform/upstream/llvm.git
3 years ago[clangd] Make AST-based signals available to runWithPreamble.
Utkarsh Saxena [Sun, 10 Jan 2021 15:23:03 +0000 (16:23 +0100)]
[clangd] Make AST-based signals available to runWithPreamble.

Many useful signals can be derived from a valid AST which is regularly updated by
the ASTWorker. `runWithPreamble` does not have access to the ParsedAST
but it can be provided access to some signals derived from a (possibly
stale) AST.

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

3 years ago[NFC] Disallow unused prefixes under MC/ARM
Mircea Trofin [Wed, 13 Jan 2021 19:02:10 +0000 (11:02 -0800)]
[NFC] Disallow unused prefixes under MC/ARM

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

3 years ago[flang][driver] Use __FLANG_VERISION__ in f18.cpp (nfc)
Andrzej Warzynski [Thu, 14 Jan 2021 16:39:16 +0000 (16:39 +0000)]
[flang][driver] Use __FLANG_VERISION__ in f18.cpp (nfc)

Just a minor improvement suggested in a post-commit review here:
https://reviews.llvm.org/D94422

3 years agoRevert "[RISCV] Legalize select when Zbt extension available"
Sam Elliott [Thu, 14 Jan 2021 16:44:34 +0000 (16:44 +0000)]
Revert "[RISCV] Legalize select when Zbt extension available"

We found issues with this patch in additional testing. Backing out while
we work on a fix.

This reverts commit 71ed4b6ce57d8843ef705af8f98305976a8f107a.

3 years ago[clangd] Remove another option that was effectively always true. NFC
Sam McCall [Thu, 14 Jan 2021 16:19:39 +0000 (17:19 +0100)]
[clangd] Remove another option that was effectively always true. NFC

3 years ago[SystemZ] misched-cutoff tests can only be tested on non-NDEBUG (assertion) builds
Simon Pilgrim [Thu, 14 Jan 2021 15:46:09 +0000 (15:46 +0000)]
[SystemZ] misched-cutoff tests can only be tested on non-NDEBUG (assertion) builds

Fixes clang-with-thin-lto-ubuntu buildbot after D94383/rGddd03842c347

3 years ago[Support] Remove redundant sign bit tests from KnownBits::getSignedMinValue/getSigned...
Simon Pilgrim [Thu, 14 Jan 2021 15:39:55 +0000 (15:39 +0000)]
[Support] Remove redundant sign bit tests from KnownBits::getSignedMinValue/getSignedMaxValue

As noted by @foad on rG6895581fd2c1

3 years agoRevert "[AArch64] Attempt to sink mul operands"
Martin Storsjö [Thu, 14 Jan 2021 15:05:36 +0000 (17:05 +0200)]
Revert "[AArch64] Attempt to sink mul operands"

This reverts commit dda60035e9f0769c8907cdf6561489e0435c2275.

This commit caused failures to compile some sources, erroring out
with "error in backend: Cannot select: t85: v2i32 = AArch64ISD::DUP t15",
see https://reviews.llvm.org/D91271 for the full reproduction case.

3 years ago[TableGen] Enhance !cast<string> to handle bit and bits types.
Paul C. Anagnostopoulos [Tue, 12 Jan 2021 17:55:57 +0000 (12:55 -0500)]
[TableGen] Enhance !cast<string> to handle bit and bits types.

Add a test for this.

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

3 years ago[Support] Simplify KnownBits::sextInReg implementation.
Simon Pilgrim [Thu, 14 Jan 2021 15:14:11 +0000 (15:14 +0000)]
[Support] Simplify KnownBits::sextInReg implementation.

As noted by @foad in rG9cf4f493a72f all we need to do is sextInReg both KnownBits One and Zero.

3 years ago[mlir][linalg] Add docstring support for named op spec
Lei Zhang [Thu, 14 Jan 2021 14:52:22 +0000 (09:52 -0500)]
[mlir][linalg] Add docstring support for named op spec

Depends on D94335

Reviewed By: nicolasvasilache, hanchung

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

3 years ago[OpenCL] Improve online documentation.
Anastasia Stulova [Thu, 14 Jan 2021 14:52:54 +0000 (14:52 +0000)]
[OpenCL] Improve online documentation.

Update UsersManual and OpenCLSupport pages to reflect
recent functionality i.e. SPIR-V generation,
C++ for OpenCL, OpenCL 3.0 development plans.

Tags: #clang

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

3 years ago[flang] Fix dangling pointer in LabelEnforce
Tim Keith [Thu, 14 Jan 2021 14:52:18 +0000 (06:52 -0800)]
[flang] Fix dangling pointer in LabelEnforce

`DirectiveStructureChecker` was passing in a pointer to a temporary
string for the `construct` argument to the constructor for `LabelEnforce`.
The `LabelEnforce` object had a lifetime longer than the temporary,
resulting in accessing a dangling pointer when emitting an error message
for `omp-parallell01.f90`.

The fix is to make the lifetime of the temporary as long as the lifetime
of the `LabelEnforce` object.

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

3 years ago[Support] Ensure KnownBits::sextInReg can handle the src == dst sext-in-reg case.
Simon Pilgrim [Thu, 14 Jan 2021 14:50:09 +0000 (14:50 +0000)]
[Support] Ensure KnownBits::sextInReg can handle the src == dst sext-in-reg case.

This was resulting in assertions inside APInt::zext that we were extending to the same bitwidth.

3 years ago[docs] Update DebuggingJITedCode page after fix in LLDB
Stefan Gränitz [Thu, 14 Jan 2021 14:40:42 +0000 (15:40 +0100)]
[docs] Update DebuggingJITedCode page after fix in LLDB

Generalize the documentation to include both, GDB and LLDB. Add a link to the interface
definition. Make a note on MCJIT's restriction to ELF. Mention the regression and bugfix
in LLDB as well as the jit-loader setting for macOS. Update the command line session to
use LLDB instead of GDB.

Reviewed By: lhames

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

3 years ago[Support] Add KnownBits::sextInReg exhaustive tests
Simon Pilgrim [Thu, 14 Jan 2021 14:18:55 +0000 (14:18 +0000)]
[Support] Add KnownBits::sextInReg exhaustive tests

Requested by @foad in rG9cf4f493a72f

3 years ago[Support] Simplify KnownBits::icmp helpers. NFC.
Jay Foad [Wed, 13 Jan 2021 13:51:09 +0000 (13:51 +0000)]
[Support] Simplify KnownBits::icmp helpers. NFC.

Remove some special cases that aren't really any simpler than the
general case.

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

3 years ago[Analysis,CodeGen] Make use of KnownBits::makeConstant. NFC.
Jay Foad [Wed, 13 Jan 2021 11:25:35 +0000 (11:25 +0000)]
[Analysis,CodeGen] Make use of KnownBits::makeConstant. NFC.

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

3 years ago[SelectionDAG] Make use of KnownBits::commonBits. NFC.
Jay Foad [Wed, 13 Jan 2021 10:57:20 +0000 (10:57 +0000)]
[SelectionDAG] Make use of KnownBits::commonBits. NFC.

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

3 years ago[InferFunctionAttrs] Improve CHECK variable names (NFC).
Florian Hahn [Thu, 14 Jan 2021 12:55:17 +0000 (12:55 +0000)]
[InferFunctionAttrs] Improve CHECK variable names (NFC).

3 years ago[flang][driver] Unify f18_version.h.in and Version.inc.in
Andrzej Warzynski [Mon, 11 Jan 2021 16:16:29 +0000 (16:16 +0000)]
[flang][driver] Unify f18_version.h.in and Version.inc.in

Flang has two CMake configurable header files that define compiler
version numbers:
* f18_version.h.in - only used in f18.cpp (uses version numbers from
  LLVM's macro definitions)
* Version.inc.in - not currently used (uses version numbers hard-coded
  in Flang's top CMake script)

Currently only f18_version.h.in provides version numbers consistent with
other subprojects in llvm-project. However, its location and name are
inconsistent with e.g. Clang. This patch merges the two headers
together:
  * hard-coded version numbers in Flang's top CMake script are deleted
  * Version.inc.in is updated to provide string versions of version
  numbers (required by f18.cpp)
  * f18_version.h.in is deleted as it's no longer needed

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

3 years ago[clang-tidy] Use DenseSet<SourceLocation> in UpgradeDurationConversionsCheck, NFCI
Mikhail Maltsev [Thu, 14 Jan 2021 13:50:16 +0000 (13:50 +0000)]
[clang-tidy] Use DenseSet<SourceLocation> in UpgradeDurationConversionsCheck, NFCI

This change replaces `unordered_set<unsigned>` (which used to store
internal representation of `SourceLocation`-s) with
`DenseSet<SourceLocation>` (which stores `SourceLocation`-s directly).

Reviewed By: aaron.ballman, njames93

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

3 years agoRevert "Fix llvm::Optional build breaks in MSVC using std::is_trivially_copyable"
Alexandre Ganea [Thu, 14 Jan 2021 13:35:38 +0000 (08:35 -0500)]
Revert "Fix llvm::Optional build breaks in MSVC using std::is_trivially_copyable"

This reverts commit 854f0984f0b7ab9a9a541a4bcda7ea173e4113d3.

This breaks compilation with clang-cl on Windows, while in a MSVC 16.8 cmd.exe.
This also breaks PPC: http://lab.llvm.org:8011/#/builders/93/builds/1435
And: https://reviews.llvm.org/D93510#2497737

3 years ago[clang][cli] Port more CodeGenOptions to marshalling infrastructure
Jan Svoboda [Tue, 12 Jan 2021 11:35:50 +0000 (12:35 +0100)]
[clang][cli] Port more CodeGenOptions to marshalling infrastructure

Leveraging the recently added TableGen constructs (ShouldParseIf and MarshallingInfoStringInt) to shift from manual command line parsing to automatic TableGen-driver marshalling.

Reviewed By: dexonsmith

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

3 years ago[clang][cli] NFC: Remove SSPBufferSize assignment
Jan Svoboda [Thu, 14 Jan 2021 12:07:52 +0000 (13:07 +0100)]
[clang][cli] NFC: Remove SSPBufferSize assignment

This should've been part of D84669, but got overlooked. Removing the assignment is NFC, as it's also done by the marshalling infrastructure for the stack_protector_buffer_size option.

Reviewed By: dexonsmith in D94488

3 years agoChange XCore code owner.
Nigel Perks [Thu, 14 Jan 2021 12:13:48 +0000 (12:13 +0000)]
Change XCore code owner.

Discussion: https://lists.llvm.org/pipermail/llvm-dev/2021-January/147603.html

3 years ago[clangd] Add main file macros into the main-file index.
Aleksandr Platonov [Thu, 14 Jan 2021 08:35:38 +0000 (11:35 +0300)]
[clangd] Add main file macros into the main-file index.

This patch is a try to fix `WorkspaceSymbols.Macros` test after D93796.
If a macro definition is in the preamble section, then it appears to be in the preamble (static) index and not in the main-file (dynamic) index.
Thus, a such macro could not be found at a symbol search according to the logic that we skip symbols from the static index if the location of these symbols is inside the dynamic index files.
To fix this behavior this patch adds main file macros into the main-file (dynamic) index.

Reviewed By: sammccall

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

3 years ago[DAG] visitVECTOR_SHUFFLE - MergeInnerShuffle - reset shuffle ops and reorder early...
Simon Pilgrim [Thu, 14 Jan 2021 11:52:29 +0000 (11:52 +0000)]
[DAG] visitVECTOR_SHUFFLE - MergeInnerShuffle - reset shuffle ops and reorder early-out and second op matching. NFCI.

I'm hoping to reuse MergeInnerShuffle in some other folds - so ensure the candidate ops/mask are reset at the start of each run.

Also, move the second op matching before bailing to make it simpler to try to match other things afterward.

3 years ago[lldb/test] Ensure launched processes are ready to be attached
Pavel Labath [Thu, 14 Jan 2021 10:53:53 +0000 (11:53 +0100)]
[lldb/test] Ensure launched processes are ready to be attached

Linux systems can be configured (and most of them are configured that
way) to disable attaching to unrelated processes, /unless/ those
processes explicitly allow that.

Our test inferiors do that by explicitly calling prctl(PR_SET_PTRACER,
PR_SET_PTRACER_ANY) (a.k.a., lldb_enable_attach). This requires
additional synchronization to ensure that the test does not attempt
attach before that statement is executed.

This is working fine (albeit cumbersome) for most tests but
TestGdbRemoteAttachWait is special in that it wants to start the
inferior _after_ issuing the attach request. This means that the usual
synchronization method does not work.

This patch introduces a different solution -- enable attaching in the
test harness, before the process is launched. Besides fixing this
problem, this is also better because it avoids the need to add special
code to each attach test (which is a common error).

One gotcha here is that it won't work for remote test suites, as we
don't control launching there. However, we could add a similar option to
lldb-platform, or require that lldb-platform itself is started with
attaching enabled. At that point we could delete all lldb_enable_attach
logic.

3 years ago[X86] Improve sum-of-reductions v4f32 test coverage
Simon Pilgrim [Thu, 14 Jan 2021 11:05:04 +0000 (11:05 +0000)]
[X86] Improve sum-of-reductions v4f32 test coverage

Ensure that the v4f32 reductions use a -0.0f start value and add fast-math test variant.

3 years ago[DAG] visitVECTOR_SHUFFLE - pull out shuffle merging code into lambda helper. NFCI.
Simon Pilgrim [Wed, 13 Jan 2021 18:00:25 +0000 (18:00 +0000)]
[DAG] visitVECTOR_SHUFFLE - pull out shuffle merging code into lambda helper. NFCI.

Make it easier to reuse in a future patch.

3 years ago[clang] Use SourceLocations in unions [NFCI]
Mikhail Maltsev [Thu, 14 Jan 2021 10:56:53 +0000 (10:56 +0000)]
[clang] Use SourceLocations in unions [NFCI]

Currently, there are many instances where `SourceLocation` objects are
converted to raw representation to be stored in structs that are
used as fields of tagged unions.

This is done to make the corresponding structs trivial.
Triviality allows avoiding undefined behavior when implicitly changing
the active member of the union.

However, in most cases, we can explicitly construct an active member
using placement new. This patch adds the required active member
selections and replaces `SourceLocation`-s represented as
`unsigned int` with proper `SourceLocation`-s.

One notable exception is `DeclarationNameLoc`: the objects of this class
are often not properly initialized (so the code currently relies on
its default constructor which uses memset). This class will be fixed
in a separate patch.

Reviewed By: dblaikie

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

3 years ago[SLP] Don't vectorize stores of non-packed types (like i1, i2)
Bjorn Pettersson [Mon, 28 Dec 2020 13:28:55 +0000 (14:28 +0100)]
[SLP] Don't vectorize stores of non-packed types (like i1, i2)

In the spirit of commit fc783e91e0c0696e (llvm-svn: 248943) we
shouldn't vectorize stores of non-packed types (i.e. types that
has padding between consecutive variables in a scalar layout,
but being packed in a vector layout).

The problem was detected as a miscompile in a downstream test case.

Reviewed By: anton-afanasyev

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

3 years ago[lld][WebAssembly] Add support for handling table symbols
Andy Wingo [Tue, 5 Jan 2021 11:08:58 +0000 (12:08 +0100)]
[lld][WebAssembly] Add support for handling table symbols

This commit adds table symbol support in a partial way, while still
including some special cases for the __indirect_function_table symbol.
No change in tests.

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

3 years ago[LTO] Expose opt() in LTOBackend (NFC).
Florian Hahn [Thu, 14 Jan 2021 09:53:41 +0000 (09:53 +0000)]
[LTO] Expose opt() in LTOBackend (NFC).

Exposing opt() which runs middle-end LTO optimzation allows re-using it
in LTOCodeGenerator.

Reviewed By: steven_wu

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

3 years ago[AArch64] Adding ACLE intrinsics for the LS64 extension
Lucas Prates [Thu, 10 Dec 2020 16:43:36 +0000 (16:43 +0000)]
[AArch64] Adding ACLE intrinsics for the LS64 extension

This introduces the ARMv8.7-A LS64 extension's intrinsics for 64 bytes
atomic loads and stores: `__arm_ld64b`, `__arm_st64b`, `__arm_st64bv`,
and `__arm_st64bv0`. These are selected into the LS64 instructions
LD64B, ST64B, ST64BV and ST64BV0, respectively.

Based on patches written by Simon Tatham.

Reviewed By: tmatheson

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

3 years ago[NFC][AsmPrinter] Windows warning: Use explicit cast
David Stuttard [Wed, 13 Jan 2021 10:02:08 +0000 (10:02 +0000)]
[NFC][AsmPrinter] Windows warning: Use explicit cast

static_cast for uint64_t to unsigned gives a MS VC build warning
for Windows:

warning C4309: 'static_cast': truncation of constant value

Use an explicit cast instead.

Change-Id: I692d335b4913070686a102780c1fb05b893a2f69

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

3 years ago[lldb] Fix TestPlatformProcessConnect.py
Pavel Labath [Wed, 6 Jan 2021 16:05:27 +0000 (17:05 +0100)]
[lldb] Fix TestPlatformProcessConnect.py

The test was marked as remote-only, which means it was run ~never, and
accumulated various problems. This commit modifies the test to run
locally and includes a couple of other fixes necessary to make it run:
- moves the "invoke" method into the "Base" test class
- adds []'s around the IP address in a couple more places to make things
  work with IPv6

The test is now marked as skipped when running the remote test suite. It
would be possible to make it run both locally and remotely, but this
would require writing a lot special logic for the remote case, and that
is not worth it.

3 years ago[mlir] Update doc to omit the usage of LLVMIntegerType
lewuathe [Thu, 14 Jan 2021 08:28:08 +0000 (09:28 +0100)]
[mlir] Update doc to omit the usage of LLVMIntegerType

Since [[ https://reviews.llvm.org/D94178 | the LLVMIntegerType was replaced with build-in integer type ]], the usage in the tutorial should be also updated accordingly.
We need to update chapter 6 for Toy tutorial specifically.

See: https://reviews.llvm.org/D94178

Reviewed By: rriddle

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

3 years agoImplement vAttachWait in lldb-server
Augusto Noronha [Thu, 14 Jan 2021 08:24:31 +0000 (09:24 +0100)]
Implement vAttachWait in lldb-server

This commit vAttachWait in lldb-server, so --waitfor can be used on
Linux

Reviewed By: labath, clayborg

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

3 years ago[lldb][wasm] Parse DWO section names
Philip Pfaffe [Thu, 14 Jan 2021 07:44:47 +0000 (08:44 +0100)]
[lldb][wasm] Parse DWO section names

Mirror ELF section parsing to support DWARF section names for
debug fission.

Reviewed By: labath

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

3 years agoAdd func call so we don't instruction-step into the builtin_trap
Jason Molenda [Thu, 14 Jan 2021 07:39:32 +0000 (23:39 -0800)]
Add func call so we don't instruction-step into the builtin_trap

The way this test is structured right now, I set a breakpoint on
the instruction before the __builtin_trap.  It hits the breakpoint,
disables the breakpoint, and instruction steps.  This hits the
builtin_trap instruction which debugserver (on arm64) now advances
to the next instruction and reports that address to lldb.  lldb
doesn't recognize this as a proper response to the instruction
step and continues executing until the next trap, and the test fails.

3 years agoFix unused variable in CoroFrame.cpp when building Release with GCC 10
Daniel Paoliello [Thu, 14 Jan 2021 06:52:40 +0000 (22:52 -0800)]
Fix unused variable in CoroFrame.cpp when building Release with GCC 10

When building with GCC 10, the following warning is reported:

```
/llvm-project/llvm/lib/Transforms/Coroutines/CoroFrame.cpp:1527:28: warning: unused variable ‘CS’ [-Wunused-variable]
 1527 |       if (CatchSwitchInst *CS =
```

This change adds a cast to `void` to avoid the warning.

Reviewed By: lxfind

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

3 years agoADT: Reduce code duplication in SmallVector by calling reserve and clear, NFC
Duncan P. N. Exon Smith [Thu, 14 Jan 2021 05:08:54 +0000 (21:08 -0800)]
ADT: Reduce code duplication in SmallVector by calling reserve and clear, NFC

3 years ago[Driver] -gsplit-dwarf: Produce .dwo regardless of -gN for -fthinlto-index=
Fangrui Song [Thu, 14 Jan 2021 05:01:53 +0000 (21:01 -0800)]
[Driver] -gsplit-dwarf: Produce .dwo regardless of -gN for -fthinlto-index=

-g is an IR generation option while -gsplit-dwarf is an object file generation option.
For -gsplit-dwarf in the backend phase of a distributed ThinLTO (-fthinlto-index=) which does object file generation and no IR generation, -g should not be needed.

This patch makes `-fthinlto-index= -gsplit-dwarf` emit .dwo even in the absence of -g.
This should fix https://crbug.com/1158215 after D80391.

```
// Distributed ThinLTO usage
clang -g -O2 -c -flto=thin -fthin-link-bitcode=a.indexing.o a.c
clang -g -O2 -c -flto=thin -fthin-link-bitcode=b.indexing.o b.c
clang -fuse-ld=lld -Wl,--thinlto-index-only=a.rsp -Wl,--thinlto-prefix-replace=';lto/' -Wl,--thinlto-object-suffix-replace='.indexing.o;.o' a.indexing.o b.indexing.o
clang -gsplit-dwarf -O2 -c -fthinlto-index=lto/a.o.thinlto.bc a.o -o lto/a.o
clang -gsplit-dwarf -O2 -c -fthinlto-index=lto/b.o.thinlto.bc b.o -o lto/b.o
clang -fuse-ld=lld @a.rsp -o exe
```

Note: for implicit regular/Thin LTO, .dwo emission works without this patch:
`clang -flto=thin -gsplit-dwarf a.o b.o` passes `-plugin-opt=dwo_dir=` to the linker.
The linker forwards the option to LTO. LTOBackend.cpp emits `$dwo_dir/[01234].dwo`.

Reviewed By: dblaikie

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

3 years agoADT: Reduce code duplication in SmallVector by reusing reserve, NFC
Duncan P. N. Exon Smith [Wed, 23 Dec 2020 20:45:17 +0000 (12:45 -0800)]
ADT: Reduce code duplication in SmallVector by reusing reserve, NFC

3 years agoADT: Reduce code duplication in SmallVector::resize by using pop_back_n, NFC
Duncan P. N. Exon Smith [Wed, 23 Dec 2020 20:41:29 +0000 (12:41 -0800)]
ADT: Reduce code duplication in SmallVector::resize by using pop_back_n, NFC

3 years agoADT: Fix reference invalidation in SmallVector::resize
Duncan P. N. Exon Smith [Fri, 20 Nov 2020 01:12:27 +0000 (17:12 -0800)]
ADT: Fix reference invalidation in SmallVector::resize

For small enough, trivially copyable `T`, take the parameter by-value in
`SmallVector::resize`.  Otherwise, when growing, update the arugment
appropriately.

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

3 years ago[NFC] Fix -Wsometimes-uninitialized
Jordan Rupprecht [Thu, 14 Jan 2021 04:30:25 +0000 (20:30 -0800)]
[NFC] Fix -Wsometimes-uninitialized

After 49142991a685bd427d7e877c29c77371dfb7634c, clang detects that MUL may be uninitialized. Set it to nullptr to suppress this check.

Adding an assert to check that it is ultimately set fails two test cases. Since this is not a new issue, leave the assertion commented out until a code owner can fix the bug. The two failing test cases are noted in the assertion comment.

3 years agoADT: Fix reference invalidation in N-element SmallVector::append and insert
Duncan P. N. Exon Smith [Fri, 20 Nov 2020 00:58:16 +0000 (16:58 -0800)]
ADT: Fix reference invalidation in N-element SmallVector::append and insert

For small enough, trivially copyable `T`, take the parameter by-value in
`SmallVector::append` and `SmallVector::insert`.  Otherwise, when
growing, update the arugment appropriately.

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

3 years agoReapply "ADT: Fix reference invalidation in SmallVector::push_back and single-element...
Duncan P. N. Exon Smith [Thu, 14 Jan 2021 03:08:42 +0000 (19:08 -0800)]
Reapply "ADT: Fix reference invalidation in SmallVector::push_back and single-element insert"

This reverts commit 56d1ffb927d03958a7a31442596df749264a7792, reapplying
9abac60309006db00eca0af406c2e16bef26807c, removing insert_one_maybe_copy
and using a helper called forward_value_param instead. This avoids use
of `std::is_same` (or any SFINAE), so I'm hoping it's more portable and
MSVC will be happier.

Original commit message follows:

For small enough, trivially copyable `T`, take the argument by value in
`SmallVector::push_back` and copy it when forwarding to
`SmallVector::insert_one_impl`. Otherwise, when growing, update the
argument appropriately.

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

3 years ago[llvm] Use std::any_of (NFC)
Kazu Hirata [Thu, 14 Jan 2021 03:14:44 +0000 (19:14 -0800)]
[llvm] Use std::any_of (NFC)

3 years ago[llvm] Use llvm::stable_sort (NFC)
Kazu Hirata [Thu, 14 Jan 2021 03:14:42 +0000 (19:14 -0800)]
[llvm] Use llvm::stable_sort (NFC)

3 years ago[llvm] Use *Set::contains (NFC)
Kazu Hirata [Thu, 14 Jan 2021 03:14:41 +0000 (19:14 -0800)]
[llvm] Use *Set::contains (NFC)

3 years agoRevert "ADT: Fix reference invalidation in SmallVector::push_back and single-element...
Duncan P. N. Exon Smith [Thu, 14 Jan 2021 03:02:22 +0000 (19:02 -0800)]
Revert "ADT: Fix reference invalidation in SmallVector::push_back and single-element insert"

This reverts commit 9abac60309006db00eca0af406c2e16bef26807c since there
are some bot errors on Windows:
http://lab.llvm.org:8011/#/builders/127/builds/4489

```
FAILED: lib/Support/CMakeFiles/LLVMSupport.dir/IntervalMap.cpp.obj
C:\PROGRA~2\MIB055~1\2017\PROFES~1\VC\Tools\MSVC\1416~1.270\bin\Hostx64\x64\cl.exe  /nologo /TP -DGTEST_HAS_RTTI=0 -DUNICODE -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_HAS_EXCEPTIONS=0 -D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS -D_UNICODE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Ilib\Support -IC:\b\slave\sanitizer-windows\llvm-project\llvm\lib\Support -Iinclude -IC:\b\slave\sanitizer-windows\llvm-project\llvm\include /DWIN32 /D_WINDOWS   /Zc:inline /Zc:__cplusplus /Zi /Zc:strictStrings /Oi /Zc:rvalueCast /bigobj /W4 -wd4141 -wd4146 -wd4244 -wd4267 -wd4291 -wd4351 -wd4456 -wd4457 -wd4458 -wd4459 -wd4503 -wd4624 -wd4722 -wd4100 -wd4127 -wd4512 -wd4505 -wd4610 -wd4510 -wd4702 -wd4245 -wd4706 -wd4310 -wd4701 -wd4703 -wd4389 -wd4611 -wd4805 -wd4204 -wd4577 -wd4091 -wd4592 -wd4319 -wd4709 -wd4324 -w14062 -we4238 /Gw /MD /O2 /Ob2 -UNDEBUG -std:c++14  /EHs-c- /GR- /showIncludes /Folib\Support\CMakeFiles\LLVMSupport.dir\IntervalMap.cpp.obj /Fdlib\Support\CMakeFiles\LLVMSupport.dir\LLVMSupport.pdb /FS -c C:\b\slave\sanitizer-windows\llvm-project\llvm\lib\Support\IntervalMap.cpp
C:\b\slave\sanitizer-windows\llvm-project\llvm\include\llvm/ADT/SmallVector.h(746): error C2672: 'llvm::SmallVectorImpl<T>::insert_one_maybe_copy': no matching overloaded function found
        with
        [
            T=llvm::IntervalMapImpl::Path::Entry
        ]
C:\b\slave\sanitizer-windows\llvm-project\llvm\include\llvm/ADT/SmallVector.h(745): note: while compiling class template member function 'llvm::IntervalMapImpl::Path::Entry *llvm::SmallVectorImpl<T>::insert(llvm::IntervalMapImpl::Path::Entry *,T &&)'
        with
        [
            T=llvm::IntervalMapImpl::Path::Entry
        ]
C:\b\slave\sanitizer-windows\llvm-project\llvm\lib\Support\IntervalMap.cpp(22): note: see reference to function template instantiation 'llvm::IntervalMapImpl::Path::Entry *llvm::SmallVectorImpl<T>::insert(llvm::IntervalMapImpl::Path::Entry *,T &&)' being compiled
        with
        [
            T=llvm::IntervalMapImpl::Path::Entry
        ]
C:\b\slave\sanitizer-windows\llvm-project\llvm\include\llvm/ADT/SmallVector.h(1136): note: see reference to class template instantiation 'llvm::SmallVectorImpl<T>' being compiled
        with
        [
            T=llvm::IntervalMapImpl::Path::Entry
        ]
C:\b\slave\sanitizer-windows\llvm-project\llvm\include\llvm/ADT/IntervalMap.h(790): note: see reference to class template instantiation 'llvm::SmallVector<llvm::IntervalMapImpl::Path::Entry,4>' being compiled
C:\b\slave\sanitizer-windows\llvm-project\llvm\include\llvm/ADT/SmallVector.h(746): error C2783: 'llvm::IntervalMapImpl::Path::Entry *llvm::SmallVectorImpl<T>::insert_one_maybe_copy(llvm::IntervalMapImpl::Path::Entry *,ArgType &&)': could not deduce template argument for '__formal'
        with
        [
            T=llvm::IntervalMapImpl::Path::Entry
        ]
C:\b\slave\sanitizer-windows\llvm-project\llvm\include\llvm/ADT/SmallVector.h(727): note: see declaration of 'llvm::SmallVectorImpl<T>::insert_one_maybe_copy'
        with
        [
            T=llvm::IntervalMapImpl::Path::Entry
        ]
```

3 years ago[NFC] Remove unused entry in PassRegistry.def
Arthur Eubanks [Thu, 14 Jan 2021 03:00:49 +0000 (19:00 -0800)]
[NFC] Remove unused entry in PassRegistry.def

3 years agoADT: Fix reference invalidation in SmallVector::push_back and single-element insert
Duncan P. N. Exon Smith [Thu, 19 Nov 2020 03:53:23 +0000 (19:53 -0800)]
ADT: Fix reference invalidation in SmallVector::push_back and single-element insert

For small enough, trivially copyable `T`, take the argument by value in
`SmallVector::push_back` and copy it when forwarding to
`SmallVector::insert_one_impl`. Otherwise, when growing, update the
argument appropriately.

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

3 years agoRevert "[Support] On Windows, take the affinity mask into account"
Alexandre Ganea [Thu, 14 Jan 2021 02:34:21 +0000 (21:34 -0500)]
Revert "[Support] On Windows, take the affinity mask into account"

This reverts commit 336ab2d51dfdd5ca09c2a9c506453db4fe653584.

3 years ago[PowerPC] Try to fold sqrt/sdiv test results with the branch.
Esme-Yi [Thu, 14 Jan 2021 02:15:19 +0000 (02:15 +0000)]
[PowerPC] Try to fold sqrt/sdiv test results with the branch.

Summary: The patch tries to fold sqrt/sdiv test node, i.g FTSQRT, XVTDIVDP, and the branch, i.e br_cc if they meet these patterns:
(br_cc seteq, (truncateToi1 SWTestOp), 0) -> (BCC PRED_NU, SWTestOp)
(br_cc seteq, (and SWTestOp, 2), 0) -> (BCC PRED_NE, SWTestOp)
(br_cc seteq, (and SWTestOp, 4), 0) -> (BCC PRED_LE, SWTestOp)
(br_cc seteq, (and SWTestOp, 8), 0) -> (BCC PRED_GE, SWTestOp)
(br_cc setne, (truncateToi1 SWTestOp), 0) -> (BCC PRED_UN, SWTestOp)
(br_cc setne, (and SWTestOp, 2), 0) -> (BCC PRED_EQ, SWTestOp)
(br_cc setne, (and SWTestOp, 4), 0) -> (BCC PRED_GT, SWTestOp)
(br_cc setne, (and SWTestOp, 8), 0) -> (BCC PRED_LT, SWTestOp)

Reviewed By: steven.zhang

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

3 years ago[Support] On Windows, take the affinity mask into account
Alexandre Ganea [Thu, 14 Jan 2021 01:59:31 +0000 (20:59 -0500)]
[Support] On Windows, take the affinity mask into account

The number of hardware threads available to a ThreadPool can be limited if setting an affinity mask.
For example:

> start /B /AFFINITY 0xF lld-link.exe ...

Would let LLD only use 4 hyper-threads.

Previously, there was an outstanding issue on Windows Server 2019 on dual-CPU machines, which was preventing from using both CPU sockets. In normal conditions, when no affinity mask was set, ProcessorGroup::AllThreads was different from ProcessorGroup::UsableThreads. The previous code in llvm/lib/Support/Windows/Threading.inc L201 was improperly assuming those two values to be equal, and consequently was limiting the execution to only one CPU socket.

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

3 years agoFix grammar in diagnostic for wrong arity in a structured binding.
Richard Smith [Thu, 14 Jan 2021 01:40:22 +0000 (17:40 -0800)]
Fix grammar in diagnostic for wrong arity in a structured binding.

3 years ago[RISCV] Custom lower ISD::VSCALE.
Craig Topper [Thu, 14 Jan 2021 01:14:45 +0000 (17:14 -0800)]
[RISCV] Custom lower ISD::VSCALE.

This patch custom lowers ISD::VSCALE into a csrr vlenb followed
by a shift right by 3 followed by a multiply by the scale amount.

I've added computeKnownBits support to indicate that the csrr vlenb
always produces 3 trailng bits of 0s so the shift right is "exact".
This allows the shift and multiply sequence to be nicely optimized
into a single shift or removed completely when the scale amount is
a power of 2.

The non power of 2 case multiplying by 24 is still producing
suboptimal code. We could remove the right shift and use a
multiply by 3. Hopefully we can improve DAG combine to fix that
since it's not unique to this sequence.

This replaces D94144.

Reviewed By: HsiangKai

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

3 years ago[flang] Add tests for procedure arguments with implicit interfaces
Peter Steinfeld [Tue, 12 Jan 2021 16:52:27 +0000 (08:52 -0800)]
[flang] Add tests for procedure arguments with implicit interfaces

It's possible to declare an external procedure and then pass it as an
actual argument to a subprogram expecting a procedure argument.  I added
tests for this and added an error message to distinguish passing an
actual argument with an implicit interface from passing an argument with
a mismatched explicit interface.

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

3 years ago[libunwind] Unwind through aarch64/Linux sigreturn frame
Ryan Prichard [Thu, 14 Jan 2021 00:38:36 +0000 (16:38 -0800)]
[libunwind] Unwind through aarch64/Linux sigreturn frame

An AArch64 sigreturn trampoline frame can't currently be described
in a DWARF .eh_frame section, because the AArch64 DWARF spec currently
doesn't define a constant for the PC register. (PC and LR may need to
be restored to different values.)

Instead, use the same technique as libgcc or github.com/libunwind and
detect the sigreturn frame by looking for the sigreturn instructions:

    mov x8, #0x8b
    svc #0x0

If a sigreturn frame is detected, libunwind restores all the GPRs by
assuming that sp points at an rt_sigframe Linux kernel struct. This
behavior is a fallback mode that is only used if there is no ordinary
unwind info for sigreturn.

If libunwind can't find unwind info for a PC, it assumes that the PC is
readable, and would crash if it isn't. This could happen if:
 - The PC points at a function compiled without unwind info, and which
   is part of an execute-only mapping (e.g. using -Wl,--execute-only).
 - The PC is invalid and happens to point to unreadable or unmapped
   memory.

In the tests, ignore a failed dladdr call so that the tests can run on
user-mode qemu for AArch64, which uses a stack-allocated trampoline
instead of a vDSO.

Reviewed By: danielkiss, compnerd, #libunwind

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

3 years ago[SystemZ] Clear Available set in SystemZPostRASchedStrategy::initialize().
Jonas Paulsson [Mon, 11 Jan 2021 01:59:16 +0000 (02:59 +0100)]
[SystemZ]  Clear Available set in SystemZPostRASchedStrategy::initialize().

This needs to be done in order to not crash with -misched-cutoff.

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

Review: Ulrich Weigand

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

3 years ago[NFC] Rename ThinLTOPhase to ThinOrFullLTOPhase and move it from PassBuilder.h
Wei Mi [Wed, 13 Jan 2021 17:46:34 +0000 (09:46 -0800)]
[NFC] Rename ThinLTOPhase to ThinOrFullLTOPhase and move it from PassBuilder.h
to Pass.h.

In some compiler passes like SampleProfileLoaderPass, we want to know which
LTO/ThinLTO phase the pass is in. Currently the phase is represented in enum
class PassBuilder::ThinLTOPhase, so it is only available in PassBuilder and
it also cannot represent phase in full LTO. The patch extends it to include
full LTO phases and move it from PassBuilder.h to Pass.h, then it is much
easier for PassBuilder to communiate with each pass about current LTO phase.

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

3 years agoFix llvm::Optional build breaks in MSVC using std::is_trivially_copyable
James Player [Wed, 13 Jan 2021 22:17:31 +0000 (14:17 -0800)]
Fix llvm::Optional build breaks in MSVC using std::is_trivially_copyable

Current code breaks this version of MSVC due to a mismatch between `std::is_trivially_copyable` and `llvm::is_trivially_copyable` for `std::pair` instantiations.  Hence I was attempting to use `std::is_trivially_copyable` to set `llvm::is_trivially_copyable<T>::value`.

I spent some time root causing an `llvm::Optional` build error on MSVC 16.8.3 related to the change described above:

```
62>C:\src\ocg_llvm\llvm-project\llvm\include\llvm/ADT/BreadthFirstIterator.h(96,12): error C2280: 'llvm::Optional<std::pair<std::pair<unsigned int,llvm::Graph<4>::NodeSubset> *,llvm::Optional<llvm::Graph<4>::ChildIterator>>> &llvm::Optional<std::pair<std::pair<unsigned int,llvm::Graph<4>::NodeSubset> *,llvm::Optional<llvm::Graph<4>::ChildIterator>>>::operator =(const llvm::Optional<std::pair<std::pair<unsigned int,llvm::Graph<4>::NodeSubset> *,llvm::Optional<llvm::Graph<4>::ChildIterator>>> &)': attempting to reference a deleted function (compiling source file C:\src\ocg_llvm\llvm-project\llvm\unittests\ADT\BreadthFirstIteratorTest.cpp)
...
```
The "trivial" specialization of `optional_detail::OptionalStorage` assumes that the value type is trivially copy constructible and trivially copy assignable. The specialization is invoked based on a check of `is_trivially_copyable` alone, which does not imply both `is_trivially_copy_assignable` and `is_trivially_copy_constructible` are true.

[[ https://en.cppreference.com/w/cpp/named_req/TriviallyCopyable | According to the spec ]], a deleted assignment operator does not make `is_trivially_copyable` false. So I think all these properties need to be checked explicitly in order to specialize `OptionalStorage` to the "trivial" version:
```
/// Storage for any type.
template <typename T, bool = std::is_trivially_copy_constructible<T>::value
                          && std::is_trivially_copy_assignable<T>::value>
class OptionalStorage {
```
Above fixed my build break in MSVC, but I think we need to explicitly check `is_trivially_copy_constructible` too since it might be possible the copy constructor is deleted.  Also would be ideal to move over to `std::is_trivially_copyable` instead of the `llvm` namespace verson.

Reviewed By: dblaikie

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

3 years ago[SPARC] Fix fp128 load/stores
Craig Topper [Wed, 13 Jan 2021 22:32:28 +0000 (14:32 -0800)]
[SPARC] Fix fp128 load/stores

The generated code for the split fp128 load/stores was missing a small yet important adjustment to the pointer metadata being fed into `getStore` and `getLoad`, making it out of sync with the effective memory address.
This problem often resulted in instructions being scheduled in the wrong order.

I also took this chance to clean up some "wrong" uses of `getAlignment` as done in D77687.

Thanks @jrtc27 for finding the problem and providing a patch.

Patch by LemonBoy and Jessica Clarke(jrtc27)

Reviewed By: craig.topper

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

3 years ago[NewPM] Only non-trivially loop unswitch at -O3 and for non-optsize functions
Arthur Eubanks [Tue, 12 Jan 2021 23:15:15 +0000 (15:15 -0800)]
[NewPM] Only non-trivially loop unswitch at -O3 and for non-optsize functions

This matches the legacy pipeline/pass.

Reviewed By: asbirlea, SjoerdMeijer

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

3 years agoRevert "[AsmParser] make .ascii support spaces as separators"
Jian Cai [Wed, 13 Jan 2021 22:06:01 +0000 (14:06 -0800)]
Revert "[AsmParser] make .ascii support spaces as separators"

This reverts commit e0963ae274be5b071d1e1b00f5e4e019483c09e9. The change
breaks some GDB tests. Revert it while we investigate.

3 years ago[NFC] Fix build break by a initializer list converting error
wlei [Wed, 13 Jan 2021 22:27:03 +0000 (14:27 -0800)]
[NFC] Fix build break by a initializer list converting error

3 years ago[test] Add Clang side tests for -fdebug-info-for-profiling
Fangrui Song [Wed, 13 Jan 2021 22:27:39 +0000 (14:27 -0800)]
[test] Add Clang side tests for -fdebug-info-for-profiling

There is currently a driver test but no test for its effect on linkageName & pass pipeline.

Reviewed By: dblaikie

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

3 years ago[libc][NFC] change isblank and iscntrl from implicit casting
Michael Jones [Wed, 13 Jan 2021 21:36:05 +0000 (21:36 +0000)]
[libc][NFC] change isblank and iscntrl from implicit casting

isblank and iscntrl were casting an int to a char implicitly and this
was throwing errors under Fuchsia. I've added a static cast to resolve
this issue.

Reviewed By: sivachandra

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

3 years ago[DSE] Add tests with stores of existing values.
Florian Hahn [Wed, 13 Jan 2021 21:28:25 +0000 (21:28 +0000)]
[DSE] Add tests with stores of existing values.

This patch pre-commits test cases with dead stores of
existing values for D90328. It also updates a few tests that had such
stores by accident, to preserve the original spirit of those tests.

3 years ago[FuncAttrs] Add additional willreturn tests (NFC)
Nikita Popov [Wed, 13 Jan 2021 21:20:23 +0000 (22:20 +0100)]
[FuncAttrs] Add additional willreturn tests (NFC)

3 years agoFix the warnings on unused variables (NFC)
Kazu Hirata [Wed, 13 Jan 2021 21:32:40 +0000 (13:32 -0800)]
Fix the warnings on unused variables (NFC)

3 years ago[libc][NFC] add macro for fuchsia to switch test backend to zxtest
Michael Jones [Tue, 12 Jan 2021 21:57:11 +0000 (21:57 +0000)]
[libc][NFC] add macro for fuchsia to switch test backend to zxtest

This moves utils/UnitTest/Test.[h/cpp] to LibcTest.[h/cpp] and adds a
new Test.h that acts as a switcher so that Fuchsia can use the zxtest
backend for running our tests as part of their build.

FuchsiaTest.h is for including fuchsia's zxtest library and anything
else needed to make the tests work under fuchsia (currently just
undefining the isascii macro for the test).

Downstream users, please fix your build instead of reverting.

Reviewed By: sivachandra

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

3 years ago[flang] Fix accessibility of USEd name in .mod file
Tim Keith [Wed, 13 Jan 2021 20:52:40 +0000 (12:52 -0800)]
[flang] Fix accessibility of USEd name in .mod file

If a module specifies default private accessibility, names that have
been use-associated are private by default. This was not reflected in
.mod files.

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

3 years ago[LTO] Add test for freestanding LTO option.
Florian Hahn [Wed, 13 Jan 2021 18:13:22 +0000 (18:13 +0000)]
[LTO] Add test for freestanding LTO option.

This patch adds a test for the -lto-freestanding option, similar to
llvm/test/ThinLTO/X86/tli-nobuiltin.ll.

3 years ago[mlir][sparse] add vectorization strategies to sparse compiler
Aart Bik [Wed, 13 Jan 2021 18:33:28 +0000 (10:33 -0800)]
[mlir][sparse] add vectorization strategies to sparse compiler

Similar to the parallelization strategies, the vectorization strategies
provide control on what loops should be vectorize. Unlike the parallel
strategies, only innermost loops are considered, but including reductions,
with the control of vectorizing dense loops only or dense and sparse loops.

The vectorized loops are always controlled by a vector mask to avoid
overrunning the iterations, but subsequent vector operation folding removes
redundant masks and replaces the operations with more efficient counterparts.
Similarly, we will rely on subsequent loop optimizations to further optimize
masking, e.g. using an unconditional full vector loop and scalar cleanup loop.

The current strategy already demonstrates a nice interaction between the
sparse compiler and all prior optimizations that went into the vector dialect.

Ongoing discussion at:
https://llvm.discourse.group/t/mlir-support-for-sparse-tensors/2020/10

Reviewed By: penpornk

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

3 years ago[NFC] Use correct ssa.copy spelling when referring to the intrinsic
Jeroen Dobbelaere [Wed, 13 Jan 2021 19:43:14 +0000 (20:43 +0100)]
[NFC] Use correct ssa.copy spelling when referring to the intrinsic

Split out from D91250. Fixes wrong ssa_copy naming.

Reviewed By: fhahn

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

3 years ago[LLD][COFF] Avoid std::vector resizes during type merging
Alexandre Ganea [Wed, 13 Jan 2021 19:34:43 +0000 (14:34 -0500)]
[LLD][COFF] Avoid std::vector resizes during type merging

Consistently saves approx. 0.6 sec (out of 18 sec) on a large output (400 MB EXE, 2 GB PDB).

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

3 years ago[mlir] Correct 2 places that result in corrupted conversion rollbacks
Tres Popp [Wed, 13 Jan 2021 19:17:52 +0000 (20:17 +0100)]
[mlir] Correct 2 places that result in corrupted conversion rollbacks

This corrects the last 2 issues caught by tests when causing dialect
conversion rollbacks to occur.

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

3 years ago[NFC] fix missing SectionName declaration
wlei [Wed, 13 Jan 2021 19:30:09 +0000 (11:30 -0800)]
[NFC] fix missing SectionName declaration

3 years ago[CSSPGO][llvm-profgen] Virtual unwinding with pseudo probe
wlei [Thu, 26 Nov 2020 04:33:17 +0000 (20:33 -0800)]
[CSSPGO][llvm-profgen] Virtual unwinding with pseudo probe

This change extends virtual unwinder to support pseudo probe in llvm-profgen. Please refer https://groups.google.com/g/llvm-dev/c/1p1rdYbL93s and https://reviews.llvm.org/D89707 for more context about CSSPGO and llvm-profgen.

**Implementation**

- Added `ProbeBasedCtxKey` derived from `ContextKey` for sample counter aggregation. As we need string splitting to infer the profile for callee function, string based context introduces more string handling overhead, here we just use probe pointer based context.
- For linear unwinding, as inline context is encoded in each pseudo probe, we don't need to go through each instruction to extract range sharing same inliner. So just record the range for the context.
- For probe based context, we should ignore the top frame probe since it will be extracted from the address range. we defer the extraction in `ProfileGeneration`.
- Added `PseudoProbeProfileGenerator` for pseudo probe based profile generation.
- Some helper function to get pseduo probe info(call probe, inline context) from profiled binary.
- Added regression test for unwinder's output

The pseudo probe based profile generation will be in the upcoming patch.

Test Plan:

ninja & ninja check-llvm

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

3 years ago[CSSPGO][llvm-profgen] Refactor to unify hashable interface for trace sample and...
wlei [Thu, 3 Dec 2020 07:10:11 +0000 (23:10 -0800)]
[CSSPGO][llvm-profgen] Refactor to unify hashable interface for trace sample and context-sensitive counter

As we plan to support both CSSPGO and AutoFDO for llvm-profgen, we will have different kinds of perf sample and different kinds of sample counter(cs/non-cs, with/without pseudo probe) which both need to do aggregation in hash map.  This change implements the hashable interface(`Hashable`) and the unified base class for them to have better extensibility and reusability.

Currently perf trace sample and sample counter with context implemented this `Hashable` and  the class hierarchy is like:

```
| Hashable
           | PerfSample
                          | HybridSample
                          | LBRSample
           | ContextKey
                          | StringBasedCtxKey
                          | ProbeBasedCtxKey
                          | CallsiteBasedCtxKey
           | ...
```

- Class specifying `Hashable` should implement `getHashCode` and `isEqual`. Here we make `getHashCode` a non-virtual function to avoid vtable overhead, so derived class should calculate and assign the base class's HashCode manually. This also provides the flexibility for calculating the hash code incrementally(like rolling hash) during frame stack unwinding
- `isEqual` is a virtual function, which will have perf overhead. In the future, if we redesign a better hash function, then we can just skip this or switch to non-virtual function.
- Added `PerfSample` and `ContextKey` as base class for perf sample and counter context key, leveraging llvm-style RTTI for this.
- Added `StringBasedCtxKey` class extending  `ContextKey` to use string as context id.
- Refactor `AggregationCounter` to take all kinds of `PerfSample` as key
- Refactor `ContextSampleCounter` to take all kinds of `ContextKey` as key
- Other refactoring work:
 - Create a wrapper class `SampleCounter` to wrap `RangeCounter` and `BranchCounter`
 - Hoist `ContextId` and `FunctionProfile` out of `populateFunctionBodySamples` and `populateFunctionBoundarySamples` to reuse them in ProfileGenerator

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

3 years ago[CSSPGO][llvm-profgen] Pseudo probe decoding and disassembling
wlei [Tue, 24 Nov 2020 04:33:23 +0000 (20:33 -0800)]
[CSSPGO][llvm-profgen] Pseudo probe decoding and disassembling

This change implements pseudo probe decoding and disassembling for llvm-profgen/CSSPGO. Please see https://groups.google.com/g/llvm-dev/c/1p1rdYbL93s and https://reviews.llvm.org/D89707 for more context about CSSPGO and llvm-profgen.

**ELF section format**
Please see the encoding patch(https://reviews.llvm.org/D91878) for more details of the format, just copy the example here:

Two section(`.pseudo_probe_desc` and  `.pseudoprobe` ) is emitted in ELF to support pseudo probe.
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.
```

**Disassembling**
A switch `--show-pseudo-probe` is added to use along with `--show-disassembly` to print disassembly code with pseudo probe directives.

For example:
```
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
```

**Implementation**
- `PseudoProbeDecoder` is added in ProfiledBinary as an infra for the decoding. It decoded the two section and generate two map: `GUIDProbeFunctionMap` stores all the `PseudoProbeFunction` which is the abstraction of a general function. `AddressProbesMap` stores all the pseudo probe info indexed by its address.
- All the inline info is encoded into binary as a trie(`PseudoProbeInlineTree`) and will be constructed from the decoding. Each pseudo probe can get its inline context(`getInlineContext`) by traversing its inline tree node backwards.

Test Plan:
ninja & ninja check-llvm

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

3 years ago[flang] Do not create HostAssoc symbols in derived type scopes
peter klausler [Wed, 13 Jan 2021 01:02:28 +0000 (17:02 -0800)]
[flang] Do not create HostAssoc symbols in derived type scopes

When needed due to a specification expression in a derived type,
the host association symbols should be created in the surrounding
subprogram's scope instead.

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

3 years ago[SLP] simplify type check for reductions
Sanjay Patel [Wed, 13 Jan 2021 18:18:08 +0000 (13:18 -0500)]
[SLP] simplify type check for reductions

This is NFC-intended. The 'valid' call allows int/FP/pointers
for other parts of SLP. The difference here is that we can't
reduce pointers.

3 years ago[Hexagon] Improve legalizing of ISD::SETCC result
Krzysztof Parzyszek [Wed, 13 Jan 2021 16:18:16 +0000 (10:18 -0600)]
[Hexagon] Improve legalizing of ISD::SETCC result

3 years ago[flang] Fix classification of shape inquiries in specification exprs
peter klausler [Tue, 12 Jan 2021 23:36:45 +0000 (15:36 -0800)]
[flang] Fix classification of shape inquiries in specification exprs

In some contexts, including the motivating case of determining whether
the expressions that define the shape of a variable are "constant expressions"
in the sense of the Fortran standard, expression rewriting via Fold()
is not necessary, and should not be required.  The inquiry intrinsics LBOUND,
UBOUND, and SIZE work correctly now in specification expressions and are
classified correctly as being constant expressions (or not).  Getting this right
led to a fair amount of API clean-up as a consequence, including the
folding of shapes and TypeAndShape objects, and new APIs for shapes
that do not fold for those cases where folding isn't needed.  Further,
the symbol-testing predicate APIs in Evaluate/tools.h now all resolve any
associations of their symbols and work transparently on use-, host-, and
construct-association symbols; the tools used to resolve those associations have
been defined and documented more precisely, and their clients adjusted as needed.

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

3 years ago[gn build] Port 60fda8ebb6d
LLVM GN Syncbot [Wed, 13 Jan 2021 17:33:32 +0000 (17:33 +0000)]
[gn build] Port 60fda8ebb6d

3 years ago[ARM] Add a pass that re-arranges blocks when there is a backwards WLS branch
Sam Tebbs [Thu, 26 Nov 2020 11:05:23 +0000 (11:05 +0000)]
[ARM] Add a pass that re-arranges blocks when there is a backwards WLS branch

Blocks can be laid out such that a t2WhileLoopStart branches backwards. This is forbidden by the architecture and so it fails to be converted into a low-overhead loop. This new pass checks for these cases and moves the target block, fixing any fall-through that would then be broken.

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

3 years ago[DAG] visitVECTOR_SHUFFLE - use all_of to check for all-undef shuffle mask. NFCI.
Simon Pilgrim [Wed, 13 Jan 2021 17:14:07 +0000 (17:14 +0000)]
[DAG] visitVECTOR_SHUFFLE - use all_of to check for all-undef shuffle mask. NFCI.

3 years ago[X86][AVX] Add test for another 'reverse HADD' pattern mentioned in PR41813
Simon Pilgrim [Wed, 13 Jan 2021 15:13:56 +0000 (15:13 +0000)]
[X86][AVX] Add test for another 'reverse HADD' pattern mentioned in PR41813

3 years ago[X86][SSE] canonicalizeShuffleMaskWithHorizOp - simplify shuffle(HOP(HOP(X,Y),HOP...
Simon Pilgrim [Wed, 13 Jan 2021 15:05:02 +0000 (15:05 +0000)]
[X86][SSE] canonicalizeShuffleMaskWithHorizOp - simplify shuffle(HOP(HOP(X,Y),HOP(Z,W))) style chains.

See if we can remove the shuffle by resorting a HOP chain so that the HOP args are pre-shuffled.

This initial version just handles (the most common) v4i32/v4f32 hadd/hsub reduction patterns - future work can extend this to v8i16 types plus PACK chains (2f64 HADD/HSUB should already be handled in the half-lane combine code later on).

3 years ago[dsymutil] Warn on timestmap mismatch between object file and debug map
Jonas Devlieghere [Wed, 13 Jan 2021 16:29:46 +0000 (08:29 -0800)]
[dsymutil] Warn on timestmap mismatch between object file and debug map

This re-lands e5553b9a6ab9 with two small fixes to the tests:

 - Don't touch the source directory in debug-map-parsing.test but
   instead copy everything over in a temporary directory in
   timestamp-mismatch.test.
 - Don't redirect stderr to stdout to avoid the output getting
   intertwined in extern-alias.test.

3 years ago[IROutliner] Adapting to hoisted bitcasts in CodeExtractor
Andrew Litteken [Thu, 7 Jan 2021 23:42:48 +0000 (17:42 -0600)]
[IROutliner] Adapting to hoisted bitcasts in CodeExtractor

In commit 700d2417d8281ea56dfd7ac72d1a1473d03d2d59 the CodeExtractor
was updated so that bitcasts that have lifetime markers that beginning
outside of the region are deduplicated outside the region and are not
used as an output.  This caused a discrepancy in the IROutliner, where
in these cases there were arguments added to the aggregate function
that were not needed causing assertion errors.

The IROutliner queries the CodeExtractor twice to determine the inputs
and outputs, before and after `findAllocas` is called with the same
ValueSet for the outputs causing the duplication. This has been fixed
with a dummy ValueSet for the first call.

However, the additional bitcasts prevent us from using the same
similarity relationships that were previously defined by the
IR Similarity Analysis Pass. In these cases, we check whether the
initial version of the region being analyzed for outlining is still the
same as it was previously.  If it is not, i.e. because of the additional
bitcast instructions from the CodeExtractor, we discard the region.

Reviewers: yroux

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

3 years ago[clangd] Remove some old CodeCompletion options that are never (un)set. NFC
Sam McCall [Wed, 13 Jan 2021 17:01:11 +0000 (18:01 +0100)]
[clangd] Remove some old CodeCompletion options that are never (un)set.  NFC

3 years ago[clangd] Remove "decision-forest-base" experimental flag.
Utkarsh Saxena [Tue, 12 Jan 2021 16:14:08 +0000 (17:14 +0100)]
[clangd] Remove "decision-forest-base" experimental flag.

The value of this flag can only be fine tuned by using A/B testing on large
user base.
We do not expect individual users to use and fine tune this flag.

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