platform/upstream/llvm.git
3 years ago[AMDGPU][GlobalISel] Combine shift + logic + shift with constant operands
Mirko Brkusanin [Fri, 30 Oct 2020 14:35:42 +0000 (15:35 +0100)]
[AMDGPU][GlobalISel] Combine shift + logic + shift with constant operands

This sequence of instructions can be simplified if they are single use and
some operands are constants. Additional combines may be applied afterwards.

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

3 years ago[AMDGPU][GlobalISel] Fold a chain of two shift instructions with constant operands
Mirko Brkusanin [Thu, 29 Oct 2020 17:12:21 +0000 (18:12 +0100)]
[AMDGPU][GlobalISel] Fold a chain of two shift instructions with constant operands

Sequence of same shift instructions with constant operands can be combined into
a single shift instruction.

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

3 years ago[lld][ELF][test] Add additional --symbol-ordering-file testing
James Henderson [Fri, 6 Nov 2020 13:55:10 +0000 (13:55 +0000)]
[lld][ELF][test] Add additional --symbol-ordering-file testing

This covers a few cases that aren't otherwise tested:
1) Non-ascii symbol names are ordered.
2) Comments, whitespace and blank lines are trimmed.
3) Missing order files result in an error.

Reviewed by: MaskRay, grimar

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

3 years ago[lld][ELF] Add additional time trace categories
James Henderson [Tue, 3 Nov 2020 14:41:09 +0000 (14:41 +0000)]
[lld][ELF] Add additional time trace categories

I noticed when running a large link with the --time-trace option that
there were several areas which were missing any specific time trace
categories (aside from the generic link/ExecuteLinker categories). This
patch adds new categories to fill most of the "gaps", or to provide more
detail than was previously provided.

Reviewed by: MaskRay, grimar, russell.gallop

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

3 years ago[mlir] ODS-backed python binding generator for custom op classes
Alex Zinenko [Mon, 9 Nov 2020 16:29:21 +0000 (17:29 +0100)]
[mlir] ODS-backed python binding generator for custom op classes

Introduce an ODS/Tablegen backend producing Op wrappers for Python bindings
based on the ODS operation definition. Usage:

  mlir-tblgen -gen-python-op-bindings -Iinclude <path/to/Ops.td> \
              -bind-dialect=<dialect-name>

Reviewed By: mehdi_amini

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

3 years ago[VE] Support inline assembly
Kazushi (Jam) Marukawa [Tue, 10 Nov 2020 04:42:24 +0000 (13:42 +0900)]
[VE] Support inline assembly

Support inline assembly with scalar registers.  Add a regression test also.

Reviewed By: simoll

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

3 years ago[mlir] Support slicing for operands in results in Python bindings
Alex Zinenko [Fri, 6 Nov 2020 14:09:54 +0000 (15:09 +0100)]
[mlir] Support slicing for operands in results in Python bindings

Slicing, that is element access with `[being:end:step]` structure, is
a common Python idiom for sequence-like containers. It is also necessary
to support custom accessor for operations with variadic operands and
results (an operation an return a slice of its operands that correspond
to the given variadic group).

Add generic utility to support slicing in Python bindings and use it
for operation operands and results.

Depends On D90923

Reviewed By: stellaraccident, mehdi_amini

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

3 years ago[clangd] Bump index version number.
Haojian Wu [Tue, 10 Nov 2020 08:13:32 +0000 (09:13 +0100)]
[clangd] Bump index version number.

https://reviews.llvm.org/D89670 changed the Ref structure, we need to
bump the version to invalidate all stored stale data, otherwise we will
get ` Error while reading shard: malformed or truncated refs` when
building the background index.

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

3 years ago[clangd] Update remote index documentation
Kirill Bobyrev [Tue, 10 Nov 2020 09:17:31 +0000 (10:17 +0100)]
[clangd] Update remote index documentation

* Even though remote index is still somewhat experimental, it can now be
  used withing clangd itself: this should be the primary way of trying
  it out
* Remove `protobuf-compiler` from list of needed Debian packages as it
  `protobuf-compiler-grpc` already depends on it
* Bump recommended gRPC version to 1.32.3

3 years ago[AMDGPU] Remove an unused return value. NFC.
Jay Foad [Mon, 9 Nov 2020 10:46:38 +0000 (10:46 +0000)]
[AMDGPU] Remove an unused return value. NFC.

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

3 years ago[clangd] Enhance Clangd rename testing coverage
Kirill Bobyrev [Tue, 10 Nov 2020 09:08:42 +0000 (10:08 +0100)]
[clangd] Enhance Clangd rename testing coverage

We plan to eliminate error-prone and obsolete Clang-Rename API from Clangd. To
do that, we will introduce Decl canonicalization rules that will make renaming
code simpler and easier to maintain (D71880).

To ensure smooth transition to the new implementation, many Clang-Rename tests
will be adopted in Clangd to prevent any possible regressions. This patch is
the first in the chain of test migration patches. It improves existing tests
and adopts tests from Clang-Rename's alias, class and enum testing files.

Reviewed By: hokein

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

3 years ago[CodeGen][X86] Remove unused check-prefixes. NFCI.
Wang, Pengfei [Tue, 10 Nov 2020 08:06:13 +0000 (16:06 +0800)]
[CodeGen][X86] Remove unused check-prefixes. NFCI.

3 years ago[mlir][spirv] Add VectorInsertDynamicOp and vector.insertelement lowering
Artur Bialas [Tue, 10 Nov 2020 08:49:12 +0000 (09:49 +0100)]
[mlir][spirv] Add VectorInsertDynamicOp and vector.insertelement lowering

VectorInsertDynamicOp in SPIRV dialect
conversion from vector.insertelement to spirv VectorInsertDynamicOp

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

3 years ago[libcxx] [test] Simplify the fs helper header for posix cases. NFC.
Martin Storsjö [Fri, 6 Nov 2020 07:34:17 +0000 (09:34 +0200)]
[libcxx] [test] Simplify the fs helper header for posix cases. NFC.

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

3 years ago[libcxx] [test] Call create_directory_symlink where relevant
Martin Storsjö [Mon, 9 Nov 2020 11:59:52 +0000 (13:59 +0200)]
[libcxx] [test] Call create_directory_symlink where relevant

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

3 years ago[libcxx] [test] Make a separate create_directory_symlink helper
Martin Storsjö [Mon, 9 Nov 2020 11:59:13 +0000 (13:59 +0200)]
[libcxx] [test] Make a separate create_directory_symlink helper

This more closely mirrors the public API, instead of using an
obscure bool parameter.

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

3 years agoclang-format: [JS] support new assignment operators.
Martin Probst [Tue, 10 Nov 2020 08:16:49 +0000 (09:16 +0100)]
clang-format: [JS] support new assignment operators.

Before:

    a && = b;

After:

    a &&= b;

These operators are new additions in ES2021.

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

3 years ago[NFC] Add flag to disable IV widening in indvar instance
Max Kazantsev [Tue, 10 Nov 2020 08:00:36 +0000 (15:00 +0700)]
[NFC] Add flag to disable IV widening in indvar instance

This allows us to have control over IV widening in the pipeline.

3 years ago[clangd] Add basic conflict detection for the rename.
Haojian Wu [Tue, 10 Nov 2020 07:49:57 +0000 (08:49 +0100)]
[clangd] Add basic conflict detection for the rename.

With this patch, we reject the rename if the new name would conflict with
any other decls in the decl context of the renamed decl.

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

3 years agoRoll otherwise-unused variable into assert
David Blaikie [Tue, 10 Nov 2020 07:27:47 +0000 (23:27 -0800)]
Roll otherwise-unused variable into assert

3 years ago[PowerPC] Add an ISEL pattern for Mul with Imm.
Esme-Yi [Tue, 10 Nov 2020 06:52:39 +0000 (06:52 +0000)]
[PowerPC] Add an ISEL pattern for Mul with Imm.

Summary: This patch try to do the following transformation if the multiplier doen't fit int16:
(mul X, c1 << c2) -> (rldicr (mulli X, c1) c2)

Reviewed By: jsji, steven.zhang

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

3 years ago[NFC] Different way of getting step
Max Kazantsev [Tue, 10 Nov 2020 06:46:32 +0000 (13:46 +0700)]
[NFC] Different way of getting step

3 years ago[c++20] For P0732R2 / P1907R1: Basic code generation and name
Richard Smith [Mon, 21 Sep 2020 06:18:04 +0000 (23:18 -0700)]
[c++20] For P0732R2 / P1907R1: Basic code generation and name
mangling support for non-type template parameters of class type and
template parameter objects.

The Itanium side of this follows the approach I proposed in
https://github.com/itanium-cxx-abi/cxx-abi/issues/47 on 2020-09-06.

The MSVC side of this was determined empirically by observing MSVC's
output.

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

3 years ago[mlir][Asm] Add support for using an alias for trailing operation locations
River Riddle [Tue, 10 Nov 2020 05:50:47 +0000 (21:50 -0800)]
[mlir][Asm] Add support for using an alias for trailing operation locations

Locations often get very long and clutter up operations when printed inline with them. This revision adds support for using aliases with trailing operation locations, and makes printing with aliases the default behavior. Aliases in the trailing location take the form `loc(<alias>)`, such as `loc(#loc0)`. As with all aliases, using `mlir-print-local-scope` can be used to disable them and get the inline behavior.

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

3 years ago[mlir][AsmPrinter] Refactor printing to only print aliases for attributes/types that...
River Riddle [Tue, 10 Nov 2020 05:50:31 +0000 (21:50 -0800)]
[mlir][AsmPrinter] Refactor printing to only print aliases for attributes/types that will exist in the output.

This revision refactors the way that attributes/types are considered when generating aliases. Instead of considering all of the attributes/types of every operation, we perform a "fake" print step that prints the operations using a dummy printer to collect the attributes and types that would actually be printed during the real process. This removes a lot of attributes/types from consideration that generally won't end up in the final output, e.g. affine map attributes in an `affine.apply`/`affine.for`.

This resolves a long standing TODO w.r.t aliases, and helps to have a much cleaner textual output format. As a datapoint to the latter, as part of this change several tests were identified as testing for the presence of attributes aliases that weren't actually referenced by the custom form of any operation.

To ensure that this wouldn't cause a large degradation in compile time due to the second full print, I benchmarked this change on a very large module with a lot of operations(The file is ~673M/~4.7 million lines long). This file before this change take ~6.9 seconds to print in the custom form, and ~7 seconds after this change. In the custom assembly case, this added an average of a little over ~100 miliseconds to the compile time. This increase was due to the way that argument attributes on functions are structured and how they get printed; i.e. with a better representation the negative impact here can be greatly decreased. When printing in the generic form, this revision had no observable impact on the compile time. This benchmarking leads me to believe that the impact of this change on compile time w.r.t printing is closely related to `print` methods that perform a lot of additional/complex processing outside of the OpAsmPrinter.

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

3 years ago[SCEV] Drop cached ranges of AddRecs after flag update
Max Kazantsev [Tue, 10 Nov 2020 05:37:12 +0000 (12:37 +0700)]
[SCEV] Drop cached ranges of AddRecs after flag update

Our range computation methods benefit from no-wrap flags. But if the ranges
were first computed before the flags were set, the cached range will be too
pessimistic.

We need to drop cached ranges whenever we sharpen AddRec's no wrap flags.

Differential Revision: https://reviews.llvm.org/D89847
Reviewed By: fhahn

3 years ago[scan-build] Supprot relative 'file' in cdb.
Haowei Wu [Tue, 10 Nov 2020 04:06:20 +0000 (20:06 -0800)]
[scan-build] Supprot relative 'file' in cdb.

Excluded folders in scan build is turned to absolute path before
comapre to 'file' in cdb. 'file' in cdb might be a path relative
to 'directory', so we need to turn it to absolute path before
comparison.

Patch by Yu Shan

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

3 years ago[AMDGPU] Fix lowering of S_MOV_{B32,B64}_term
Carl Ritson [Tue, 10 Nov 2020 03:16:26 +0000 (12:16 +0900)]
[AMDGPU] Fix lowering of S_MOV_{B32,B64}_term

If the source of S_MOV_{B32,B64}_term is an immediate then it
cannot be lowered to a COPY.

Reviewed By: arsenm

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

3 years ago[PowerPC] [Clang] Port SSE4.1-compatible insert intrinsics
Qiu Chaofan [Tue, 10 Nov 2020 02:52:13 +0000 (10:52 +0800)]
[PowerPC] [Clang] Port SSE4.1-compatible insert intrinsics

This patch adds three intrinsics compatible to x86's SSE 4.1 on PowerPC
target, with tests:

- _mm_insert_epi8
- _mm_insert_epi32
- _mm_insert_epi64

The intrinsics implementation is contributed by Paul Clarke.

Reviewed By: jsji

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

3 years ago[NewPM] Port -separate-const-offset-from-gep
Arthur Eubanks [Mon, 9 Nov 2020 19:40:49 +0000 (11:40 -0800)]
[NewPM] Port -separate-const-offset-from-gep

Reviewed By: asbirlea

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

3 years ago[OMPIRBuilder] Start 'Create' methods with lower case. NFC.
Michael Kruse [Tue, 10 Nov 2020 00:47:41 +0000 (18:47 -0600)]
[OMPIRBuilder] Start 'Create' methods with lower case. NFC.

For consistency with the IRBuilder, OpenMPIRBuilder has method names starting with 'Create'. However, the LLVM coding style has methods names starting with lower case letters, as all other OpenMPIRBuilder already methods do. The clang-tidy configuration used by Phabricator also warns about the naming violation, adding noise to the reviews.

This patch renames all `OpenMPIRBuilder::CreateXYZ` methods to `OpenMPIRBuilder::createXYZ`, and updates all in-tree callers.

I tested check-llvm, check-clang, check-mlir and check-flang to ensure that I did not miss a caller.

Reviewed By: mehdi_amini, fghanim

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

3 years ago[BranchProbabilityInfo] Use SmallVector (NFC)
Kazu Hirata [Tue, 10 Nov 2020 01:29:40 +0000 (17:29 -0800)]
[BranchProbabilityInfo] Use SmallVector (NFC)

This patch simplifies BranchProbabilityInfo by changing the type of
Probs.

Without this patch:

  DenseMap<Edge, BranchProbability> Probs

maps an ordered pair of a BasicBlock* and a successor index to an edge
probability.

With this patch:

  DenseMap<const BasicBlock *, SmallVector<BranchProbability, 2>> Probs

maps a BasicBlock* to a vector of edge probabilities.

BranchProbabilityInfo has a property that for a given basic block, we
either have edge probabilities for all successors or do not have any
edge probability at all.  This property combined with the current map
type leads to a somewhat complicated algorithm in eraseBlock to erase
map entries one by one while increasing the successor index.

The new map type allows us to remove the all edge probabilities for a
given basic block in a more intuitive manner, namely:

  Probs.erase(BB);

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

3 years ago[Coroutine] Move all used local allocas to the .resume function
Xun Li [Tue, 10 Nov 2020 01:24:49 +0000 (17:24 -0800)]
[Coroutine] Move all used local allocas to the .resume function

Prior to D89768, any alloca that's used after suspension points will be put on to the coroutine frame, and hence they will always be reloaded in the resume function.
However D89768 introduced a more precise way to determine whether an alloca should live on the frame. Allocas that are only used within one suspension region (hence does not need to live across suspension points) will not be put on the frame. They will remain local to the resume function.
When creating the new entry for the .resume function, the existing logic only moved all the allocas from the old entry to the new entry. This covers every alloca from the old entry. However allocas that's defined afer coro.begin are put into a separate basic block during CoroSplit (the PostSpill basic block). We need to make sure these allocas are moved to the new entry as well if they are used.
This patch walks through all allocas, and check if they are still used but are not reachable from the new entry, if so, we move them to the new entry.

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

3 years ago[lldb] Don't use ::exit but instead return from the driver loop (NFC)
Jonas Devlieghere [Tue, 10 Nov 2020 00:36:47 +0000 (16:36 -0800)]
[lldb] Don't use ::exit but instead return from the driver loop (NFC)

This fixes a reproducer test failure that was caused by the undefined
order in which global destructors run. More concretely, the static
instance of the RealFileSystem had been destroyed before we finalized
the reproducer, which uses it to copy files into the reproducer. By
exiting normally, we call SBDebugger::Terminate and finalize the
reproducer before any static dtors are run.

3 years ago[lldb] Destory the debugger in the Driver dtor (NFC)
Jonas Devlieghere [Tue, 10 Nov 2020 00:36:03 +0000 (16:36 -0800)]
[lldb] Destory the debugger in the Driver dtor (NFC)

3 years ago[libc++] Remove emscripten handling from exception_fallback.ipp
Sam Clegg [Sun, 8 Nov 2020 22:28:13 +0000 (14:28 -0800)]
[libc++] Remove emscripten handling from exception_fallback.ipp

Emscripten doesn't use this file (at least not anymore), it uses
exception_libcxxabi.ipp since _LIBCPPABI_VERSION is defined.

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

3 years agoEnable opt-bisect for the new pass manager
Josh Stone [Mon, 9 Nov 2020 23:36:14 +0000 (15:36 -0800)]
Enable opt-bisect for the new pass manager

This instruments a should-run-optional-pass callback using the existing
OptBisect class to decide if new passes should be skipped. Passes that
force isRequired never reach this at all, so they are not included in
"BISECT:" output nor its pass count.

The test case is resurrected from r267022, an early version of D19172
that had new pass manager support (later reverted and redone without).

Reviewed By: aeubanks

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

3 years ago[update_test_checks] Allow opt to have .exe file extension
Arthur Eubanks [Mon, 9 Nov 2020 18:35:23 +0000 (10:35 -0800)]
[update_test_checks] Allow opt to have .exe file extension

Reviewed By: rnk

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

3 years ago[lldb] Make GetSelectedOrDummyTarget return the target by reference (NFC)
Jonas Devlieghere [Mon, 9 Nov 2020 23:25:59 +0000 (15:25 -0800)]
[lldb] Make GetSelectedOrDummyTarget return the target by reference (NFC)

Return references from GetDummyTarget and GetSelectedOrDummyTarget. This
matches how the APIs are already used in practice.

3 years ago[gn build] Port dbfa69c5024
LLVM GN Syncbot [Mon, 9 Nov 2020 23:03:42 +0000 (23:03 +0000)]
[gn build] Port dbfa69c5024

3 years ago[mlir][spirv] Expose more query APIs directly on TargetEnv
Lei Zhang [Mon, 9 Nov 2020 22:57:20 +0000 (17:57 -0500)]
[mlir][spirv] Expose more query APIs directly on TargetEnv

This allows us to omit one level of indirection when querying
the information from the underlying attribute.

Reviewed By: hanchung, ThomasRaoux

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

3 years agoPort some floating point options to new option marshalling infrastructure
Jan Svoboda [Mon, 9 Nov 2020 20:51:42 +0000 (15:51 -0500)]
Port some floating point options to new option marshalling infrastructure

This ports a number of OpenCL and fast-math flags for floating point
over to the new marshalling infrastructure.

As part of this, `Opt{In,Out}FFlag` were enhanced to allow other flags to
imply them, via `DefaultAnyOf<>`. For example:
```
defm signed_zeros : OptOutFFlag<"signed-zeros", ...,
  "LangOpts->NoSignedZero",
  DefaultAnyOf<[cl_no_signed_zeros, menable_unsafe_fp_math]>>;
```
defines `-fsigned-zeros` (`false`) and `-fno-signed-zeros` (`true`)
linked to the keypath `LangOpts->NoSignedZero`, defaulting to `false`,
but set to `true` implicitly if one of `-cl-no-signed-zeros` or
`-menable-unsafe-fp-math` is on.

Note that the initial patch was written Daniel Grumberg.

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

3 years agoRevert "[Syntax] Add minimal TableGen for syntax nodes. NFC"
Sam McCall [Mon, 9 Nov 2020 22:58:51 +0000 (23:58 +0100)]
Revert "[Syntax] Add minimal TableGen for syntax nodes. NFC"

This reverts commit 55120f74ca12faea0e90fe552c85c14485f1fd91.

Segfaults during build:
http://lab.llvm.org:8011/#/builders/36/builds/1310

3 years ago[llvm-cov][NFC] Fix typo in format comment
Keith Smiley [Mon, 9 Nov 2020 22:47:17 +0000 (14:47 -0800)]
[llvm-cov][NFC] Fix typo in format comment

3 years ago[Syntax] Add minimal TableGen for syntax nodes. NFC
Sam McCall [Sat, 31 Oct 2020 20:09:11 +0000 (21:09 +0100)]
[Syntax] Add minimal TableGen for syntax nodes. NFC

So far, only used to generate Kind and implement classof().

My plan is to have this general-purpose Nodes.inc in the style of AST
DeclNodes.inc etc, and additionally a special-purpose backend generating
the actual class definitions. But baby steps...

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

3 years agoRevert "[llvm] CMake: Force MSVC to read code as UTF-8"
Kirill Bobyrev [Mon, 9 Nov 2020 22:03:39 +0000 (23:03 +0100)]
Revert "[llvm] CMake: Force MSVC to read code as UTF-8"

This reverts commit 4d81c8adb6ed9840257f6cb6b93f60856d422a15.

Apparently, we have code that indirectly uses #pragma
execution_character_set which depends on utf-8 not being set:

http://lab.llvm.org:8011/#/builders/127/builds/1161/steps/4/logs/stdio

3 years ago[MLIR] Add setPublic(), setPrivate(), and setNested() to Symbol interface
Rahul Joshi [Mon, 9 Nov 2020 19:43:45 +0000 (11:43 -0800)]
[MLIR] Add setPublic(), setPrivate(), and setNested() to Symbol interface

- Add shorter helper functions to set visibility for Symbols.

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

3 years ago[runtimes] Avoid overwriting the rpath unconditionally
Louis Dionne [Mon, 9 Nov 2020 21:10:13 +0000 (16:10 -0500)]
[runtimes] Avoid overwriting the rpath unconditionally

When building the runtimes, it's very important not to add rpaths unless
the user explicitly asks for them (the standard way being CMAKE_INSTALL_RPATH),
or to change the install name dir unless the user requests it (via
CMAKE_INSTALL_NAME_DIR).

llvm_setup_rpath() would override the install_name_dir of the runtimes
even if CMAKE_INSTALL_NAME_DIR was specified to something, which is wrong
and in fact even "dangerous" for the runtimes.

This issue was discovered when trying to build libc++ and libc++abi as
system libraries for Apple, where we set the install name dir to /usr/lib
explicitly. llvm_setup_rpath() would cause libc++ to have the wrong install
name dir, and for basically everything on the system to fail to load.
This was discovered just now because we previously used something closer
to a standalone build, where llvm_setup_rpath() wouldn't exist, and hence
not be used.

This is a revert of the following commits:

  libunwind: 3a667b9bd8b741f5ac1d8d47857140a3d70737fb
  libc++abi: 4877063e195dfcc128451bbf3dd7b03d04d2562f
  libc++: 88434fe05fdb112a33052c4d8a91c9e989cb032d

Those added llvm_setup_rpath() for consistency, so it seems reasonable
to revert.

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

3 years ago[clang] Simplify buildSyntaxTree API
Kirill Bobyrev [Mon, 9 Nov 2020 21:49:49 +0000 (22:49 +0100)]
[clang] Simplify buildSyntaxTree API

Follow-up on https://reviews.llvm.org/D88553#inline-837013

Reviewed By: sammccall

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

3 years ago[llvm] CMake: Force MSVC to read code as UTF-8
Kirill Bobyrev [Mon, 9 Nov 2020 21:47:16 +0000 (22:47 +0100)]
[llvm] CMake: Force MSVC to read code as UTF-8

Symptoms: https://github.com/clangd/clangd/issues/571

Reviewed By: kadircet

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

3 years ago[OpenMP] Remove obsolete Fortran module file
Hansang Bae [Wed, 21 Oct 2020 13:50:31 +0000 (08:50 -0500)]
[OpenMP] Remove obsolete Fortran module file

Modern Fortran compilers support Fortran 90, so we do not need to use
the source code for Fortran compilers that do not support Fortran 90.

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

3 years ago[clangd] Fix shared-lib builds
Kadir Cetinkaya [Mon, 9 Nov 2020 20:54:38 +0000 (21:54 +0100)]
[clangd] Fix shared-lib builds

This breaks a cyclic dependency. clangDeamon doesn't need to depend on
clangdRemoteIndex yet.

3 years ago[lldb] [Process/NetBSD] Correct DS/ES/FS/GS register sizes
Michał Górny [Mon, 9 Nov 2020 14:47:37 +0000 (15:47 +0100)]
[lldb] [Process/NetBSD] Correct DS/ES/FS/GS register sizes

Fix DS/ES/FS/GS register sizes in getter/setter for NetBSD.  Apparently
only CS and SS registers are specified as 64/32-bit in LLDB, while
the others are specified as 16-bit.

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

3 years ago[OpenMPIRBuilder] Implement CreateCanonicalLoop.
Michael Kruse [Mon, 9 Nov 2020 20:13:17 +0000 (14:13 -0600)]
[OpenMPIRBuilder] Implement CreateCanonicalLoop.

CreateCanonicalLoop generates a standardized control flow structure for OpenMP canonical for loops. The structure can be consumed by loop-associated directives such as worksharing-loop, distribute, simd etc. as well as loop transformations such as tile and unroll.

This is a first design without considering all complexities yet. The control-flow emits more basic block than strictly necessary, but these will be optimized by CFGSimplify anyway, provide a nice separation of concerns and might later be useful with more complex scenarios. I successfully implemented a basic tile construct using this API, which is not part of this patch.

The fundamental building block is the CreateCanonicalLoop that only takes the loop trip count and operates on the logical iteration spaces only. An overloaded CreateCanonicalLoop for using LB, UB, Increment is provided as well, but at least for C++, Clang will need to implement a loop counter to logical induction variable mapping anyway, since iterator overload resolution cannot be done in LLVMFrontend.

As there currently is no user for CreateCanonicalLoop, it is only called from unittests. Similarly, CanonicalLoopInfo::eraseFromParent() is used in my file implementation and might be generally useful for implementing loop-associated constructs, but is not used in this patch itself.

The following non-exhaustive list describes not yet covered items:
 * collapse clause (including non-rectangular and non-perfectly nested); idea is to provide a OpenMPIRBuilder::collapseLoopNest method consuming multiple nested loops and returning a new CanonicalLoopInfo that can be used for loop-associated directives.
 * simarly: ordered clause for DOACROSS loops
 * branch weights
 * Cancellation point (?)
 * AllocaIP
 * break statement (if needed at all)
 * Exceptions (if not completely handled in the front-end)
  * Using it in Clang; this requires implementing at least one loop-associated construct.
 * ...

Reviewed By: jdoerfert

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

3 years ago[mlir][std] Add ExpandOps pass.
Alexander Belyaev [Mon, 9 Nov 2020 15:47:02 +0000 (16:47 +0100)]
[mlir][std] Add ExpandOps pass.

The pass combines patterns of ExpandAtomic, ExpandMemRefReshape,
StdExpandDivs passes. The pass is meant to legalize STD for conversion to LLVM.

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

3 years ago[NewPM] Add unique-internal-linkage-names to PassRegistry.def
Arthur Eubanks [Mon, 9 Nov 2020 20:54:13 +0000 (12:54 -0800)]
[NewPM] Add unique-internal-linkage-names to PassRegistry.def

Pass was already ported, just not properly hooked up.

3 years ago[test] Completely pin PR37334-break-crit-edges-require-dt.ll to legacy PM
Arthur Eubanks [Mon, 9 Nov 2020 20:47:57 +0000 (12:47 -0800)]
[test] Completely pin PR37334-break-crit-edges-require-dt.ll to legacy PM

This tests legacy PM specific code (https://bugs.llvm.org/show_bug.cgi?id=37334).
This is failing under the new PM because -loop-sink is a function pass,
not a loop pass, and doesn't run -loop-simplify.

3 years agoTooling: Remove dead code for ToolingInvocation::mapVirtualFile
Duncan P. N. Exon Smith [Thu, 5 Nov 2020 22:12:17 +0000 (17:12 -0500)]
Tooling: Remove dead code for ToolingInvocation::mapVirtualFile

Follows through on c4cb3b10dc8c50e46c9fb1b7ae95e3c3c94975d3's FIXME
dating back to 2015. Anyone using this should migrate to
InMemoryFileSystem and/or ClangTool::mapVirtualFile.

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

3 years ago[test][NewPM] Pin -flattencfg test to legacy PM
Arthur Eubanks [Mon, 9 Nov 2020 20:39:51 +0000 (12:39 -0800)]
[test][NewPM] Pin -flattencfg test to legacy PM

It is not used in the optimization pipeline and can be ported later.

3 years ago[BasicAA] Add test for decomposition limit (NFC)
Nikita Popov [Mon, 9 Nov 2020 19:42:57 +0000 (20:42 +0100)]
[BasicAA] Add test for decomposition limit (NFC)

Test behavior before/at/after the GEP decomposition limit.

3 years ago[test][NewPM] Fix LoopLoadElim tests under NPM
Arthur Eubanks [Mon, 9 Nov 2020 20:19:03 +0000 (12:19 -0800)]
[test][NewPM] Fix LoopLoadElim tests under NPM

3 years ago[llvm] Check the debug info line table for basic block sections.
Snehasish Kumar [Sat, 7 Nov 2020 00:24:25 +0000 (16:24 -0800)]
[llvm] Check the debug info line table for basic block sections.

Extend the existing basic block sections debug info test to check for the correctness of the generated line table.

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

3 years ago[clangd] NFC: Fix a typo in Tracer name
Kirill Bobyrev [Mon, 9 Nov 2020 20:18:35 +0000 (21:18 +0100)]
[clangd] NFC: Fix a typo in Tracer name

3 years ago[FastISel][test] %llc_dwarf -mtriple -> llc -mtriple
Fangrui Song [Mon, 9 Nov 2020 20:10:44 +0000 (12:10 -0800)]
[FastISel][test] %llc_dwarf -mtriple -> llc -mtriple

if config.target_triple contains 'windows-msvc', %llc_dwarf has a -mtriple:

    llc.exe: for the --mtriple option: may only occur zero or one times!

3 years ago[MLIR] Fix GCC build failure
Rahul Joshi [Mon, 9 Nov 2020 19:57:52 +0000 (11:57 -0800)]
[MLIR] Fix GCC build failure

3 years agoRevert "Check if debug line sequences are starting after the first code segment"
António Afonso [Mon, 9 Nov 2020 19:45:35 +0000 (11:45 -0800)]
Revert "Check if debug line sequences are starting after the first code segment"

This reverts commit 265a38fbc547adc0e2b71a98dac4d0a60b0dd63c.

3 years agoFix use of directly-nested traverse() matchers
Stephen Kelly [Mon, 9 Nov 2020 18:59:30 +0000 (18:59 +0000)]
Fix use of directly-nested traverse() matchers

3 years agoFix trailing whitespace
Stephen Kelly [Mon, 9 Nov 2020 18:59:00 +0000 (18:59 +0000)]
Fix trailing whitespace

My editor keeps on changing this and I keep having to revert it.

3 years agoChange algorithms to return iterators
Stephen Kelly [Fri, 6 Nov 2020 16:05:16 +0000 (16:05 +0000)]
Change algorithms to return iterators

Make it possible to inspect the matched node, possibly to ignore it.

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

3 years ago[MLIR] Change FuncOp assembly syntax to print visibility inline instead of in attrib...
Rahul Joshi [Mon, 9 Nov 2020 16:23:55 +0000 (08:23 -0800)]
[MLIR] Change FuncOp assembly syntax to print visibility inline instead of in attrib dict.

- Change syntax for FuncOp to be `func <visibility>? @name` instead of printing the
  visibility in the attribute dictionary.
- Since printFunctionLikeOp() and parseFunctionLikeOp() are also used by other
  operations, make the "inline visibility" an opt-in feature.
- Updated unit test to use and check the new syntax.

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

3 years ago[ms] [llvm-ml] Support MASM's relational operators (EQ, LT, etc.)
Eric Astor [Mon, 9 Nov 2020 18:22:37 +0000 (13:22 -0500)]
[ms] [llvm-ml] Support MASM's relational operators (EQ, LT, etc.)

Support the named relational operators (EQ, LT, etc.).

Reviewed By: thakis

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

3 years ago[MLIR] Support `global_memref` and `get_global_memref` in standard -> LLVM conversion.
Rahul Joshi [Mon, 9 Nov 2020 17:01:39 +0000 (09:01 -0800)]
[MLIR] Support `global_memref` and `get_global_memref` in standard -> LLVM conversion.

- Convert `global_memref` to LLVM::GlobalOp.
- Convert `get_global_memref` to a memref descriptor with a pointer to the first element
  of the global stashed in it.
- Extend unit test and a mlir-cpu-runner test to validate the generated LLVM IR.

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

3 years ago[SelectionDAG] Enable CTPOP optimization fine tuning
David Zarzycki [Wed, 28 Oct 2020 11:18:09 +0000 (07:18 -0400)]
[SelectionDAG] Enable CTPOP optimization fine tuning

Add a TLI hook to allow SelectionDAG to fine tune the conversion of CTPOP to a chain of "x & (x - 1)" when CTPOP isn't legal.

A subsequent patch will attempt to fine tune the X86 code gen.

Reviewed By: spatel

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

3 years ago[clangd][remote] Check an index file correctly
Aleksandr Platonov [Mon, 9 Nov 2020 18:39:01 +0000 (21:39 +0300)]
[clangd][remote] Check an index file correctly

There is not reason to check `std::make_unique<...>(..)` return value,
but `clangd::clang::loadIndex()` returns `nullptr` if an index file could not be loaded (e.g. incorrect version).

Reviewed By: kadircet

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

3 years ago[FastISel][test] Add ELF triple after D90877
Fangrui Song [Mon, 9 Nov 2020 18:26:02 +0000 (10:26 -0800)]
[FastISel][test] Add ELF triple after D90877

MachO has different symbol naming and thus on a MachO platform this test has a
different behavior without a triple.

3 years ago[llvm][AArch64] Allow TB(N)Z to drop signext for sign bit tests.
Francesco Petrogalli [Mon, 9 Nov 2020 18:18:28 +0000 (18:18 +0000)]
[llvm][AArch64] Allow TB(N)Z to drop signext for sign bit tests.

For example if the sign extension is only used in for TBZ, and the value is used elsewhere with a zero extension, this can eliminate a sign extension.

Reviewed By: samparker

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

3 years ago[flang] Avoid calling the linker when "-c" option is used
Peter Steinfeld [Mon, 9 Nov 2020 15:42:12 +0000 (07:42 -0800)]
[flang] Avoid calling the linker when "-c" option is used

The title says it all.

3 years ago[ms] [llvm-ml] Support REPEAT/FOR/WHILE macro-like directives
Eric Astor [Mon, 9 Nov 2020 16:49:41 +0000 (11:49 -0500)]
[ms] [llvm-ml] Support REPEAT/FOR/WHILE macro-like directives

Support MASM's REPEAT, FOR, FORC, and WHILE macro-like directives.

Also adds support for macro argument substitution inside quoted strings, and additional testing for macro directives.

Reviewed By: thakis

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

3 years ago[libunwind] Delete unused codeOffsetAtStackDecrement/registersInOtherRegisters/sameVa...
Fangrui Song [Mon, 9 Nov 2020 18:19:12 +0000 (10:19 -0800)]
[libunwind] Delete unused codeOffsetAtStackDecrement/registersInOtherRegisters/sameValueUsed

ld64 uses them to create compact unwind from DWARF call frame information.
When the code was ported to libunwind, the variables were not deleted.

Reviewed By: #libunwind, compnerd

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

3 years ago[ARM] Remove MI variable aliasing. NFC
David Green [Mon, 9 Nov 2020 18:18:43 +0000 (18:18 +0000)]
[ARM] Remove MI variable aliasing. NFC

This was accidentally using the same name for two different variables in
the same line. Whilst it seems to work for some compilers, others have
trouble and it is probably not a fantastic idea.

3 years ago[RISCV] Make ctlz/cttz cheap to speculatively execute so CodeGenPrepare won't insert...
Craig Topper [Mon, 9 Nov 2020 18:05:51 +0000 (10:05 -0800)]
[RISCV] Make ctlz/cttz cheap to speculatively execute so CodeGenPrepare won't insert a zero check.

Add additional isel patterns for ctzw/clzw instructions.

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

3 years ago[RISCV] Add isel patterns for using PACK for zext.h and zext.w.
Craig Topper [Mon, 9 Nov 2020 18:01:55 +0000 (10:01 -0800)]
[RISCV] Add isel patterns for using PACK for zext.h and zext.w.

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

3 years ago[RISCV] Make SIGN_EXTEND_INREG from i8/i16 legal when Zbb extension is enabled.
Craig Topper [Mon, 9 Nov 2020 17:57:38 +0000 (09:57 -0800)]
[RISCV] Make SIGN_EXTEND_INREG from i8/i16 legal when Zbb extension is enabled.

This produces better code for sign extend to i64 on RV32 target.

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

3 years ago[ELF] Special case static_assert for _WIN32
Fangrui Song [Mon, 9 Nov 2020 18:08:44 +0000 (10:08 -0800)]
[ELF] Special case static_assert for _WIN32

I don't have a Windows machine. Hope someone can test why its InputSection is
still larger.

3 years ago[RISCV] Add isel patterns to match sbset/sbclr/sbinv/sbext even if the shift amount...
Craig Topper [Mon, 9 Nov 2020 17:45:22 +0000 (09:45 -0800)]
[RISCV] Add isel patterns to match sbset/sbclr/sbinv/sbext even if the shift amount isn't masked.

This uses the shiftop PatFrags to handle the masked shift amount
and unmasked shift amount cases. That also checks XLen as part
of the masked amount check so we don't need separate RV32 and RV64
patterns.

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

3 years ago[ELF] Make InputSection smaller
Fangrui Song [Mon, 9 Nov 2020 17:55:09 +0000 (09:55 -0800)]
[ELF] Make InputSection smaller

On LP64/Windows platforms, this decreases sizeof(InputSection) from 208 (larger
on Windows) to 184.

For a large executable (7.6GiB, inputSections.size()=5105122,
make<InputSection> called 4835760 times), this decreases cgroup
memory.max_usage_in_bytes by 0.6%

Reviewed By: grimar

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

3 years ago[X86] vector-narrow-binop.ll - remove unused check-prefixes
Simon Pilgrim [Mon, 9 Nov 2020 17:50:03 +0000 (17:50 +0000)]
[X86] vector-narrow-binop.ll - remove unused check-prefixes

3 years ago[HardwareLoops] Remove unused check-prefixes
Simon Pilgrim [Mon, 9 Nov 2020 17:46:49 +0000 (17:46 +0000)]
[HardwareLoops] Remove unused check-prefixes

Just use default CHECK

3 years ago[FastISel] Reduce spills around mem-intrinsic calls
Paul Robinson [Thu, 5 Nov 2020 21:09:10 +0000 (13:09 -0800)]
[FastISel] Reduce spills around mem-intrinsic calls

FastISel generates instructions to materialize "local values" at the
top of a block, in the hope that these values could be reused within
the block.  To reduce spills and restores, FastISel treats calls as
sub-block boundaries, flushing the "local value map" at each call.

This patch treats the mem* intrinsics as if they were calls, because
at O0 generally they are calls.  Eliminating these spills/restores is
actually better for debugging (especially a "continue at this line"
command), code size, stack frame size, and maybe even performance.

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

3 years ago[MLIR] Flag no-terminator error on the last operation of non-empty blocks
Rahul Joshi [Sat, 7 Nov 2020 00:24:35 +0000 (16:24 -0800)]
[MLIR] Flag no-terminator error on the last operation of non-empty blocks

- When a block is not empty and does not end with a terminator, flag the error on the
  last operation of the block instead of the start of the block.

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

3 years ago-fbasic-block-sections=list=: Suppress output if failed to open the file
Fangrui Song [Mon, 9 Nov 2020 17:26:37 +0000 (09:26 -0800)]
-fbasic-block-sections=list=: Suppress output if failed to open the file

Reviewed By: tmsriram

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

3 years ago[X86][GlobalISel] Remove some unused check-prefixes
Simon Pilgrim [Mon, 9 Nov 2020 17:21:11 +0000 (17:21 +0000)]
[X86][GlobalISel] Remove some unused check-prefixes

3 years ago[FunctionImport] Remove unused check-prefixes
Simon Pilgrim [Mon, 9 Nov 2020 16:19:10 +0000 (16:19 +0000)]
[FunctionImport] Remove unused check-prefixes

3 years ago[DeadStoreElimination] Remove unused check-prefixes
Simon Pilgrim [Mon, 9 Nov 2020 16:08:07 +0000 (16:08 +0000)]
[DeadStoreElimination] Remove unused check-prefixes

Just use default CHECK

3 years agoRevert "Ignores functions that have a range starting outside of a code section"
António Afonso [Mon, 9 Nov 2020 17:07:48 +0000 (09:07 -0800)]
Revert "Ignores functions that have a range starting outside of a code section"

This reverts commit df30bc0168d236e5575d815030d6fe4cd8626f34.

3 years ago[mlir][Linalg] Add support for bufferization of SubTensorOp and SubTensorInsertOp
Nicolas Vasilache [Mon, 9 Nov 2020 11:57:42 +0000 (11:57 +0000)]
[mlir][Linalg] Add support for bufferization of SubTensorOp and SubTensorInsertOp

This revision adds support for bufferization by using a mix of `tensor_load`, `subview`, `linalg.copy` and `tensor_to_memref`.

3 years ago[lldb] Avoid confusing reproducer crashes when initialization failed
Jonas Devlieghere [Mon, 9 Nov 2020 16:47:08 +0000 (08:47 -0800)]
[lldb] Avoid confusing reproducer crashes when initialization failed

During active replay, the ::Initialize call is replayed like any other
SB API call and the return value is ignored. Since we can't intercept
this, we terminate here before the uninitialized debugger inevitably
crashes.

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

3 years ago[clang] Fix ForStmt mustprogress handling
Atmn Patel [Mon, 9 Nov 2020 13:19:44 +0000 (08:19 -0500)]
[clang] Fix ForStmt mustprogress handling

D86841 had an error where for statements with no conditional were
required to make progress. This is not true, this patch removes that
line, and adds regression tests.

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

3 years ago[NFC] Use [MC]Register
Mircea Trofin [Wed, 4 Nov 2020 21:28:13 +0000 (13:28 -0800)]
[NFC] Use [MC]Register

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

3 years ago[XCOFF] Enable explicit sections on AIX
jasonliu [Mon, 9 Nov 2020 15:12:46 +0000 (15:12 +0000)]
[XCOFF] Enable explicit sections on AIX

Implement mechanism to allow explicit sections to be generated on AIX.

Reviewed By: DiggerLin

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