2 years agoCreate Reduction Tree Pass
Mauricio Sifontes [Fri, 7 Aug 2020 23:17:27 +0000 (23:17 +0000)]
Create Reduction Tree Pass

Implement the Reduction Tree Pass framework as part of the MLIR Reduce tool. This is a parametarizable pass that allows for the implementation of custom reductions passes in the tool.
Implement the FunctionReducer class as an example of a Reducer class parameter for the instantiation of a Reduction Tree Pass.
Create a pass pipeline with a Reduction Tree Pass with the FunctionReducer class specified as parameter.

Reviewed By: jpienaar

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

2 years agoRevert "[Clang] implement -fno-eliminate-unused-debug-types"
Nick Desaulniers [Fri, 7 Aug 2020 23:11:41 +0000 (16:11 -0700)]
Revert "[Clang] implement -fno-eliminate-unused-debug-types"

This reverts commit e486921fd6cf96ae9114adac455f7c0b5c1088a7.

Breaks windows builds and osx builds.

2 years agoRevert "fix windows build for D80242"
Nick Desaulniers [Fri, 7 Aug 2020 23:11:26 +0000 (16:11 -0700)]
Revert "fix windows build for D80242"

This reverts commit cbd8ec93709376fbf404c99f4eee399790e26db7.

2 years ago[OpenMP 5.0] Fix PR-45212: Shouldn't error out while using overloaded operator for...
cchen [Fri, 7 Aug 2020 23:04:56 +0000 (18:04 -0500)]
[OpenMP 5.0] Fix PR-45212: Shouldn't error out while using overloaded operator for map clause

LValue map checker should handle CXXOperatorCallExpr

Reviewed By: jdoerfert

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

2 years ago[mlir] Centralize handling of memref element types.
Sean Silva [Fri, 7 Aug 2020 18:40:58 +0000 (11:40 -0700)]
[mlir] Centralize handling of memref element types.

This also beefs up the test coverage:
- Make unranked memref testing consistent with ranked memrefs.
- Add testing for the invalid element type cases.

This is not quite NFC: index types are now allowed in unranked memrefs.

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

2 years ago[lldb] Assert the process has exited before we gets its output.
Jonas Devlieghere [Fri, 7 Aug 2020 22:06:14 +0000 (15:06 -0700)]
[lldb] Assert the process has exited before we gets its output.

2 years ago[NewPM] Print 'Skipping pass' as pass instrumentation
Arthur Eubanks [Fri, 7 Aug 2020 02:03:09 +0000 (19:03 -0700)]
[NewPM] Print 'Skipping pass' as pass instrumentation

If OptNoneInstrumentation prints it instead, 'Skipping pass' will print for even required passes.

Reviewed By: ychen

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

2 years agofix windows build for D80242
Nick Desaulniers [Fri, 7 Aug 2020 21:59:35 +0000 (14:59 -0700)]
fix windows build for D80242

2 years ago[NFC][MLInliner] Refactor logging implementation
Mircea Trofin [Fri, 7 Aug 2020 21:56:31 +0000 (14:56 -0700)]
[NFC][MLInliner] Refactor logging implementation

This prepares it for logging externally-specified outputs.

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

2 years agoAdd a setting to force stepping to always run all threads.
Jim Ingham [Fri, 7 Aug 2020 21:44:01 +0000 (14:44 -0700)]
Add a setting to force stepping to always run all threads.
Also allow ScriptedThreadPlans to set & get their StopOthers


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

2 years ago[llvm-libtool-darwin] Add support for -D and -U options
Sameer Arora [Mon, 20 Jul 2020 23:10:07 +0000 (16:10 -0700)]
[llvm-libtool-darwin] Add support for -D and -U options

Add support for `-D` and `-U` options for llvm-libtool-darwin. `-D`
allows for using zero for timestamps and UIDs/GIDs. `-U` allows for
using actual timestamps and UIDs/GIDs.

Reviewed by jhenderson, smeenai

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

2 years ago[llvm-libtool-darwin] Add support for -filelist option
Sameer Arora [Mon, 20 Jul 2020 21:27:48 +0000 (14:27 -0700)]
[llvm-libtool-darwin] Add support for -filelist option

Add support for `-filelist` option for llvm-libtool-darwin. `-filelist`
option allows for passing in a file containing a list of filenames.

Reviewed by jhenderson, smeenai

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

2 years agoFactor out reference-counting code from PlatformApple*
Adrian Prantl [Fri, 7 Aug 2020 21:24:03 +0000 (14:24 -0700)]
Factor out reference-counting code from PlatformApple*

into PlatformAppleSimulator. This is legal because that is the only
entry point for the Terminate/Initialize functions.

2 years ago[Clang] implement -fno-eliminate-unused-debug-types
Nick Desaulniers [Fri, 7 Aug 2020 21:10:04 +0000 (14:10 -0700)]
[Clang] implement -fno-eliminate-unused-debug-types

Fixes pr/11710.
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
Reviewed By: dblaikie

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

2 years ago[llvm-libtool-darwin] Add constant CPU_SUBTYPE_ARM64_V8
Sameer Arora [Fri, 31 Jul 2020 18:52:47 +0000 (11:52 -0700)]
[llvm-libtool-darwin] Add constant CPU_SUBTYPE_ARM64_V8

Add support for constant MachO::CPU_SUBTYPE_ARM64_V8. This constant is
needed so as to match `llvm-libtool-darwin`'s behavior to that of
cctools' libtool when `-arch_only` flag is passed in on command line.

Reviewed by jhenderson, alexshap, smeenai

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

2 years agoRevert "[StackSafety] Skip ambiguous lifetime analysis"
Vitaly Buka [Fri, 7 Aug 2020 20:59:22 +0000 (13:59 -0700)]
Revert "[StackSafety] Skip ambiguous lifetime analysis"

This reverts commit 0b2616a8045cb776ea1514c3401d0a8577de1060.

Crashes with safe-stack.

2 years ago[StackSafety,NFC] Add Stats counters
Vitaly Buka [Fri, 7 Aug 2020 20:58:10 +0000 (13:58 -0700)]
[StackSafety,NFC] Add Stats counters

2 years ago[OpenMP,MLIR] Translation of parallel operation: num_threads, if clauses 3/n
Kiran Chandramohan [Fri, 7 Aug 2020 18:33:46 +0000 (18:33 +0000)]
[OpenMP,MLIR] Translation of parallel operation: num_threads, if clauses 3/n

This simple patch translates the num_threads and if clauses of the parallel
operation. Also includes test cases.
A minor change was made to parsing of the if clause to parse AnyType and
return the parsed type. Updates to test cases also.

Reviewed by: SouraVX
Differential Revision: https://reviews.llvm.org/D84798

2 years ago[OpenMP] Split OpenMP/target_map_codegen test [NFC]
Artem Belevich [Fri, 7 Aug 2020 19:59:49 +0000 (12:59 -0700)]
[OpenMP] Split OpenMP/target_map_codegen test [NFC]

The test file is the single longest test among clang's tests and ends up about
doubling the wall time of clang tests on machines with high number of cores.

The test appears to consist of multiple independent subtests and does not have
to be in one file. Splitting it into smaller parts reduces test time on my
machine from ~80s down to ~45.

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

2 years agoAdd symlinks for `libtool` and `install_name_tool`
Sameer Arora [Fri, 31 Jul 2020 22:22:16 +0000 (15:22 -0700)]
Add symlinks for `libtool` and `install_name_tool`

Add symlinks for `llvm-libtool-darwin` and

Reviewed by jhenderson, smeenai

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

2 years ago[flang] Update FirOpsDialect constructor to pass its TypeID
River Riddle [Fri, 7 Aug 2020 20:41:42 +0000 (13:41 -0700)]
[flang] Update FirOpsDialect constructor to pass its TypeID

2 years ago[mlir][Type] Remove usages of Type::getKind
River Riddle [Fri, 7 Aug 2020 20:30:43 +0000 (13:30 -0700)]
[mlir][Type] Remove usages of Type::getKind

This is in preparation for removing the use of "kinds" within attributes and types in MLIR.

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

2 years ago[mlir][Attribute] Remove usages of Attribute::getKind
River Riddle [Fri, 7 Aug 2020 20:30:29 +0000 (13:30 -0700)]
[mlir][Attribute] Remove usages of Attribute::getKind

This is in preparation for removing the use of "kinds" within attributes and types in MLIR.

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

2 years ago[mlir] Remove the need to define `kindof` on attribute and type classes.
River Riddle [Fri, 7 Aug 2020 20:30:17 +0000 (13:30 -0700)]
[mlir] Remove the need to define `kindof` on attribute and type classes.

This revision refactors the default definition of the attribute and type `classof` methods to use the TypeID of the concrete class instead of invoking the `kindof` method. The TypeID is already used as part of uniquing, and this allows for removing the need for users to define any of the type casting utilities themselves.

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

2 years ago[mlir][Types] Remove the subclass data from Type
River Riddle [Fri, 7 Aug 2020 20:29:55 +0000 (13:29 -0700)]
[mlir][Types] Remove the subclass data from Type

Subclass data is useful when a certain amount of memory is allocated, but not all of it is used. In the case of Type, that hasn't been the case for a while and the subclass is just taking up a full `unsigned`. Removing this frees up ~8 bytes for almost every type instance.

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

2 years ago[mlir] Add a utility class, ThreadLocalCache, for storing non static thread local...
River Riddle [Fri, 7 Aug 2020 20:29:36 +0000 (13:29 -0700)]
[mlir] Add a utility class, ThreadLocalCache, for storing non static thread local objects.

This class allows for defining thread local objects that have a set non-static lifetime. This internals of the cache use a static thread_local map between the various different non-static objects and the desired value type. When a non-static object destructs, it simply nulls out the entry in the static map. This will leave an entry in the map, but erase any of the data for the associated value. The current use cases for this are in the MLIRContext, meaning that the number of items in the static map is ~1-2 which aren't particularly costly enough to warrant the complexity of pruning. If a use case arises that requires pruning of the map, the functionality can be added.

This is especially useful in the context of MLIR for implementing thread-local caching of context level objects that would otherwise have very high lock contention. This revision adds a thread local cache in the MLIRContext for attributes, identifiers, and types to reduce some of the locking burden. This led to a speedup of several hundred miliseconds when compiling a conversion pass on a very large mlir module(>300K operations).

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

2 years ago[mlir] Refactor StorageUniquer to require registration of possible storage types
River Riddle [Fri, 7 Aug 2020 20:29:11 +0000 (13:29 -0700)]
[mlir] Refactor StorageUniquer to require registration of possible storage types

This allows for bucketing the different possible storage types, with each bucket having its own allocator/mutex/instance map. This greatly reduces the amount of lock contention when multi-threading is enabled. On some non-trivial .mlir modules (>300K operations), this led to a compile time decrease of a single conversion pass by around half a second(>25%).

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

2 years ago[ELF]: --icf: don't fold sections referencing sections with LCDA after D84610
Fangrui Song [Fri, 7 Aug 2020 20:42:09 +0000 (13:42 -0700)]
[ELF]: --icf: don't fold sections referencing sections with LCDA after D84610

2 years agoGlobalISel: Handle zext(sext x) in artifact combiner
Matt Arsenault [Fri, 7 Aug 2020 13:08:00 +0000 (09:08 -0400)]
GlobalISel: Handle zext(sext x) in artifact combiner

This eliminates the illegal intermediate s8 value in the added test.

2 years agolldbutil: add a retry mechanism for the ios simulator
Adrian Prantl [Fri, 7 Aug 2020 20:28:05 +0000 (13:28 -0700)]
lldbutil: add a retry mechanism for the ios simulator

We've been seeing this failure on green dragon when the system is
under high load. Unfortunately this is outside of LLDB's control.

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

2 years ago[FileCheck] Add docs for --allow-empty
Sameer Arora [Mon, 13 Jul 2020 14:39:29 +0000 (07:39 -0700)]
[FileCheck] Add docs for --allow-empty

This diff adds documentation for `allow-empty` flag under FileCheck

Reviewed by jhenderson, smeenai, thopre

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

2 years ago[flang] Support DATA statement initialization of numeric with Hollerith/CHARACTER
peter klausler [Fri, 7 Aug 2020 00:58:40 +0000 (17:58 -0700)]
[flang] Support DATA statement initialization of numeric with Hollerith/CHARACTER

This is a common Fortran language extension.

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

2 years ago[libc] Add strcpsn and strpbrk implementation.
cgyurgyik [Fri, 7 Aug 2020 20:13:48 +0000 (16:13 -0400)]
[libc] Add strcpsn and strpbrk implementation.

Reviewed By: sivachandra

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

2 years ago[flang] Descriptor-based I/O data item transfers
peter klausler [Fri, 7 Aug 2020 00:30:01 +0000 (17:30 -0700)]
[flang] Descriptor-based I/O data item transfers

Add support for OutputDescriptor() and InputDescriptor()
in the I/O runtime.  Change existing scalar formatted I/O
functions to drive descriptor-based I/O routines internally.

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

2 years ago[lldb] Only check for --apple-sdk argument on Darwin
Jonas Devlieghere [Fri, 7 Aug 2020 20:04:16 +0000 (13:04 -0700)]
[lldb] Only check for --apple-sdk argument on Darwin

2 years ago[llvm-install-name-tool] Adds docs for llvm-install-name-tool
Sameer Arora [Fri, 12 Jun 2020 14:39:46 +0000 (07:39 -0700)]
[llvm-install-name-tool] Adds docs for llvm-install-name-tool

Adding documentation for llvm-install-name-tool.

Reviewed by smeenai, Ktwu

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

2 years agoRevert "[MSAN] Instrument libatomic load/store calls"
Gui Andrade [Fri, 7 Aug 2020 19:30:15 +0000 (19:30 +0000)]
Revert "[MSAN] Instrument libatomic load/store calls"

Problems with instrumenting atomic_load when the call has no successor,
blocking compiler roll

This reverts commit 33d239513c881d8c11c60d5710c55cf56cc309a5.

2 years ago[MLIR] Add getSizeInBits() for tensor of complex
Tim Shen [Thu, 6 Aug 2020 00:26:32 +0000 (17:26 -0700)]
[MLIR] Add getSizeInBits() for tensor of complex

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

2 years ago[mlir][spirv] Add correct handling of Kernel and Addresses capabilities
Konrad Dobros [Fri, 7 Aug 2020 17:40:21 +0000 (10:40 -0700)]
[mlir][spirv] Add correct handling of Kernel and Addresses capabilities

This change adds initial support needed to generate OpenCL compliant SPIRV.
If Kernel capability is declared then memory model becomes OpenCL.
If Addresses capability is declared then addressing model becomes Physical64.
Additionally for Kernel capability interface variable ABI attributes are not
generated as entry point function is expected to have normal arguments.

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

2 years ago[flang][NFC] Reformat files with current clang-format
peter klausler [Thu, 6 Aug 2020 23:56:14 +0000 (16:56 -0700)]
[flang][NFC] Reformat files with current clang-format

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

2 years ago[gn build] Port 320eab2d558
LLVM GN Syncbot [Fri, 7 Aug 2020 19:01:40 +0000 (19:01 +0000)]
[gn build] Port 320eab2d558

2 years agoRevert "[NewPM][CodeGen] Introduce machine pass and machine pass manager"
Yuanfang Chen [Fri, 7 Aug 2020 18:59:58 +0000 (11:59 -0700)]
Revert "[NewPM][CodeGen] Introduce machine pass and machine pass manager"

This reverts commit 911565d1085d9447363fe8ad041817436c4998fe.

Broke some non-Linux bots.

2 years ago[mlir][SCF] Add utility to outline the then and else branches of an scf.IfOp
Nicolas Vasilache [Fri, 7 Aug 2020 18:35:33 +0000 (14:35 -0400)]
[mlir][SCF] Add utility to outline the then and else branches of an scf.IfOp

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

2 years agoReduce dropTriviallyDeadConstantArrays cumulative time percentage from 17% to 4%
Jianzhou Zhao [Fri, 7 Aug 2020 16:30:26 +0000 (09:30 -0700)]
Reduce dropTriviallyDeadConstantArrays cumulative time percentage from 17% to 4%

The history of dropTriviallyDeadConstantArrays is like this. Because the appending linkage uses too much memory (http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20150105/251381.html), dropTriviallyDeadConstantArrays was introduced (https://reviews.llvm.org/rG81f385b0c6ea37dd7195a65be162c75bbdef29d2) to release unused constant arrays. Recently, dropTriviallyDeadConstantArrays was improved (https://reviews.llvm.org/rG81f385b0c6ea37dd7195a65be162c75bbdef29d2) to reduce its quadratic cost.

Our recent LTO profiling shows that when a target is large, 15-20% of time cost is from the SetVector::insert called by dropTriviallyDeadConstantArrays.

A large application has hundreds or thousands of modules; each module calls dropTriviallyDeadConstantArrays once for cleaning up tens of thousands of ConstantArrays a module has. In those ConstantArrays, usually around 5 can be deleted; a very very few deleted ConstantArrays reference other ConstantArrays: less than 10 out of millions.

Given this, the cost of SetVector::insert is mainly from the construction of WorkList from ArrayConstants. This motivated the fix that iterates ArrayConstants directly, and uses WorkList only when necessary.

Our evaluation shows that
1) The cumulative time percentage of dropTriviallyDeadConstantArrays is reduced from 15-17% to 4-6%.
2) For targets with LTO time > 20min, the time reduction is about 20%.
3) No observable performance impact for build without using LTO.


Reviewed By: mehdi_amini, tejohnson, jdoerfert

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

2 years ago[mlir] Introduce AffineMinSCF folding as a pattern
Nicolas Vasilache [Fri, 7 Aug 2020 18:28:40 +0000 (14:28 -0400)]
[mlir] Introduce AffineMinSCF folding as a pattern

This revision adds a folding pattern to replace affine.min ops by the actual min value, when it can be determined statically from the strides and bounds of enclosing scf loop .

This matches the type of expressions that Linalg produces during tiling and simplifies boundary checks. For now Linalg depends both on Affine and SCF but they do not depend on each other, so the pattern is added there.
In the future this will move to a more appropriate place when it is determined.

The canonicalization of AffineMinOp operations in the context of enclosing scf.for and scf.parallel proceeds by:
  1. building an affine map where uses of the induction variable of a loop
  are replaced by `%lb + %step * floordiv(%iv - %lb, %step)` expressions.
  2. checking if any of the results of this affine map divides all the other
  results (in which case it is also guaranteed to be the min).
  3. replacing the AffineMinOp by the result of (2).

The algorithm is functional in simple parametric tiling cases by using semi-affine maps. However simplifications of such semi-affine maps are not yet available and the canonicalization does not succeed yet.

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

2 years ago[PPC] Rename bool-ret-to-int -> ppc-bool-ret-to-int
Arthur Eubanks [Thu, 6 Aug 2020 03:02:22 +0000 (20:02 -0700)]
[PPC] Rename bool-ret-to-int -> ppc-bool-ret-to-int

Reviewed By: #powerpc, nemanjai

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

2 years ago[gn build] Port 911565d1085
LLVM GN Syncbot [Fri, 7 Aug 2020 18:22:24 +0000 (18:22 +0000)]
[gn build] Port 911565d1085

2 years ago[NFC] Use value initializer for OVERLAPPED
Arthur Eubanks [Thu, 6 Aug 2020 22:33:33 +0000 (15:33 -0700)]
[NFC] Use value initializer for OVERLAPPED

To fix
../llvm/lib/Support/Windows/Path.inc(1265,21): warning: missing field
'InternalHigh' initializer [-Wmissing-field-initializers]

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

2 years ago[AMDGPU] Fix not rescheduling without clustering
Vang Thao [Fri, 7 Aug 2020 03:46:27 +0000 (20:46 -0700)]
[AMDGPU] Fix not rescheduling without clustering

Regions are sometimes skipped which should be rescheduled without memory op
clustering. RegionIdx is not incremented when iterating over regions that
are flagged to be skipped, causing the index to be incorrect.

Thanks to Vang Thao for discovering this bug!

Reviewed By: rampitec

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

2 years ago[lldb] Store the Apple SDK in dotest's configuration.
Jonas Devlieghere [Fri, 7 Aug 2020 17:06:38 +0000 (10:06 -0700)]
[lldb] Store the Apple SDK in dotest's configuration.

This patch stores the --apple-sdk argument in the dotest configuration.
When it's set, use it instead of the triple to determine the current

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

2 years ago[Clang] Add note for bad conversion when expression is pointer to forward-declared...
Zequan Wu [Wed, 5 Aug 2020 18:48:36 +0000 (11:48 -0700)]
[Clang] Add note for bad conversion when expression is pointer to forward-declared type

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

2 years ago[SyntaxTree] Use simplified grammar rule for `NestedNameSpecifier` grammar nodes
Eduardo Caldas [Tue, 4 Aug 2020 17:33:36 +0000 (17:33 +0000)]
[SyntaxTree] Use simplified grammar rule for `NestedNameSpecifier` grammar nodes

This is our grammar rule for nested-name-specifiers:
  template_opt simple-template-id
  list(name-specifier, ::, non-empty, terminated)

It is a relaxed version of C++ [expr.prim.id] and quite simpler to map to our API.

TODO: refine name specifiers, `simple-template-name-specifier` and
decltype-name-specifier` are token soup for now.

2 years ago[lld-macho] Add .tbd support for frameworks
Jez Ng [Fri, 7 Aug 2020 18:04:54 +0000 (11:04 -0700)]
[lld-macho] Add .tbd support for frameworks

Required for e.g. linking iOS apps since they don't have a platform-native

Reviewed By: #lld-macho, compnerd, smeenai

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

2 years ago[lld-macho] Support static linking of thread-locals
Jez Ng [Fri, 7 Aug 2020 18:04:52 +0000 (11:04 -0700)]
[lld-macho] Support static linking of thread-locals

Note: What ELF refers to as "TLS", Mach-O seems to refer to as "TLV", i.e.
thread-local variables.

This diff implements support for TLV relocations that reference defined
symbols. On x86_64, TLV relocations are always used with movq opcodes, so for
defined TLVs, we don't need to create a synthetic section to store the
addresses of the symbols -- we can just convert the `movq` to a `leaq`.

One notable quirk of Mach-O's TLVs is that absolute-address relocations
inside TLV-defining sections behave differently -- their addresses are
no longer absolute, but relative to the start of the target section.
(AFAICT, RIP-relative relocations are not allowed in these sections.)

Reviewed By: #lld-macho, compnerd, smeenai

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

2 years ago[lld-macho] Ensure .tbss sections are also considered as ZeroFilled
Jez Ng [Fri, 7 Aug 2020 18:04:41 +0000 (11:04 -0700)]
[lld-macho] Ensure .tbss sections are also considered as ZeroFilled

This diff makes the behavior in {D80859} and {D81888} apply to
thread-local ZeroFill sections too. I realized this was necessary whie
trying to implement thread-local variables.

Reviewed By: #lld-macho, compnerd, MaskRay

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

2 years ago[NewPM][CodeGen] Introduce machine pass and machine pass manager
Yuanfang Chen [Fri, 7 Aug 2020 16:24:52 +0000 (09:24 -0700)]
[NewPM][CodeGen] Introduce machine pass and machine pass manager

machine pass could define four methods:
- `PreservedAnalyses run(MachineFunction &, MachineFunctionAnalysisManager &)`
- `Error doInitialization(Module &, MachineFunctionAnalysisManager &)`
- `Error doFinalization(Module &, MachineFunctionAnalysisManager &)`
- `Error run(Module &, MachineFunctionAnalysisManager &)`

machine pass manger:
- MachineFunctionAnalysisManager:
  Basically an AnalysisManager<MachineFunction> augmented with the ability to
  register and query IR analyses
- MachineFunctionPassManager: support only two methods, `addPass` and `run`

Reviewed By: arsenm, asbirlea, aeubanks

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

2 years ago[NewPM] Only verify loop for nonskipped user loop pass
Yuanfang Chen [Fri, 7 Aug 2020 16:22:51 +0000 (09:22 -0700)]
[NewPM] Only verify loop for nonskipped user loop pass

No verification for pass mangers since it is not needed.
No verification for skipped loop pass since the asserted condition is not used.

Add a BeforeNonSkippedPass callback for this. The callback needs more
inputs than its parameters to work so the callback is added on-the-fly.

Reviewed By: aeubanks, asbirlea

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

2 years agoRevert "Reland D64327 [MC][ELF] Allow STT_SECTION referencing SHF_MERGE on REL targets"
Mitch Phillips [Fri, 7 Aug 2020 17:56:33 +0000 (10:56 -0700)]
Revert "Reland D64327 [MC][ELF] Allow STT_SECTION referencing SHF_MERGE on REL targets"

This reverts commit b497665d98ad5026b1d3d67d5793a28fefe27bea.

Spent some time trying to reproduce this locally, reverting in a
desparate attempt to fix the sanitizer buildbot:
 - http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux/builds/28828

I don't know exactly why or how this patch breaks the bots, but it seems
pretty concrete that it's the culprit.

2 years agoMake clang HIP headers compatible with C++98
Yaxun (Sam) Liu [Fri, 7 Aug 2020 17:50:22 +0000 (13:50 -0400)]
Make clang HIP headers compatible with C++98

Automation to detect compiler features, such as CMake's target_compile_features,
would attempt to detect compiler features by explicitly using langugage flags.
This change ensures that the HIP headers would still work with C++98.

Patch by Siu Chi Chan

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

Change-Id: I304e964b18a525b0fde55efd841da74b6c4dc8ed

2 years ago[analyzer] pr47030: MoveChecker: Unforget a comma in the suppression list.
Artem Dergachev [Fri, 7 Aug 2020 17:17:27 +0000 (10:17 -0700)]
[analyzer] pr47030: MoveChecker: Unforget a comma in the suppression list.

2 years ago[flang] Remove extra CMAKE_CXX_FLAGS in Lower and Optimizer
Tim Keith [Fri, 7 Aug 2020 17:21:52 +0000 (10:21 -0700)]
[flang] Remove extra CMAKE_CXX_FLAGS in Lower and Optimizer

`-Wno-error` and `-Wno-unused-parameter` appear to no longer be needed
for Lower and Optimizer.

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

2 years ago[NFC] Add utility to sum/merge stats files
Tyker [Fri, 7 Aug 2020 17:02:25 +0000 (19:02 +0200)]
[NFC] Add utility to sum/merge stats files

Add a small script to sum *.stats file given as input and output the totals
usage example:
    merge-stats.py $(find ./builddir/ -name "*.stats") > total.stats

Reviewed By: lebedev.ri

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

2 years ago[mlir] [VectorOps] Improve lowering of extract_strided_slice (and friends like shape_...
aartbik [Thu, 6 Aug 2020 22:34:47 +0000 (15:34 -0700)]
[mlir] [VectorOps] Improve lowering of extract_strided_slice (and friends like shape_cast)

Using a shuffle for the last recursive step in progressive lowering not only
results in much more compact IR, but also more efficient code (since the
backend is no longer confused on subvector aliasing for longer vectors).

E.g. the following

  %f = vector.shape_cast %v0: vector<1024xf32> to vector<32x32xf32>

yields much better x86-64 code that runs 3x faster than the original.

Reviewed By: bkramer, nicolasvasilache

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

2 years ago[ARM] Extra reduction plus tailpredication tests. NFC
David Green [Fri, 7 Aug 2020 16:16:56 +0000 (17:16 +0100)]
[ARM] Extra reduction plus tailpredication tests. NFC

2 years ago[PowerPC] Add Vector Extract/Expand/Count with Mask, Move to VSR Mask Instruction...
Amy Kwan [Thu, 6 Aug 2020 15:24:48 +0000 (10:24 -0500)]
[PowerPC] Add Vector Extract/Expand/Count with Mask, Move to VSR Mask Instruction Definitions and MC Tests

This patch adds the instruction definitions and assembly/disassembly tests for
the following set of instructions:

Vector Extract [byte | half | word | doubleword | quad] with mask
Vector Expand [byte | half | word | doubleword | quad] with mask
Move to VSR [byte | byte immediate | half | word | doubleword | quad] with mask
Vector Count Mask Bits [byte | half | word | doubleword]

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

2 years agoRevisit Dialect registration: require and store a TypeID on dialects
Mehdi Amini [Fri, 7 Aug 2020 02:41:44 +0000 (02:41 +0000)]
Revisit Dialect registration: require and store a TypeID on dialects

This patch moves the registration to a method in the MLIRContext: getOrCreateDialect<ConcreteDialect>()

This method requires dialect to provide a static getDialectNamespace()
and store a TypeID on the Dialect itself, which allows to lazyily
create a dialect when not yet loaded in the context.
As a side effect, it means that duplicated registration of the same
dialect is not an issue anymore.

To limit the boilerplate, TableGen dialect generation is modified to
emit the constructor entirely and invoke separately a "init()" method
that the user implements.

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

2 years ago[PowerPC][PCRelative] Set TLS unsupported with PC relative memops
Kamau Bridgeman [Thu, 6 Aug 2020 17:29:35 +0000 (12:29 -0500)]
[PowerPC][PCRelative] Set TLS unsupported with PC relative memops

Introduce a fatal error if any thread local storage code is compiled
using pc relative memory operations as well as a hidden override
option `-enable-ppc-pcrel-tls` so that this support can be incrementally
added if possible.

Reviewed By: #powerpc, nemanjai

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

2 years ago[OPENMP]Simplify representation for atomic, critical, master and section
Alexey Bataev [Mon, 6 Jul 2020 17:32:11 +0000 (13:32 -0400)]
[OPENMP]Simplify representation for atomic, critical, master and section

Several constructs may be represented wityout relying on CapturedStmt.
It saves memory and improves compilation speed.

2 years ago[PowerPC] Add compatibility check for PPC PLT stubs
Victor Huang [Fri, 7 Aug 2020 13:44:29 +0000 (13:44 +0000)]
[PowerPC] Add compatibility check for PPC PLT stubs

Compatibility checks for PPC64PltCallStub and PPC64PCRelPLTStub are
added in this patch to prevent the usage of incompatible thunk/stub.

Reviewed By: sfertile, nemanjai, stefanp

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

2 years ago[NFC][GVN] Fix "avaliable" typos
Jay Foad [Fri, 7 Aug 2020 12:38:43 +0000 (13:38 +0100)]
[NFC][GVN] Fix "avaliable" typos

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

2 years ago[Fixed Point] Add fixed-point shift operations and consteval.
Bevin Hansson [Fri, 3 Jul 2020 11:26:57 +0000 (13:26 +0200)]
[Fixed Point] Add fixed-point shift operations and consteval.

Reviewers: rjmccall, leonardchan, bjope

Subscribers: cfe-commits

Tags: #clang

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

2 years ago[Intrinsic] Add sshl.sat/ushl.sat, saturated shift intrinsics.
Bevin Hansson [Thu, 16 Jul 2020 15:02:04 +0000 (17:02 +0200)]
[Intrinsic] Add sshl.sat/ushl.sat, saturated shift intrinsics.

This patch adds two intrinsics, llvm.sshl.sat and llvm.ushl.sat,
which perform signed and unsigned saturating left shift,

These are useful for implementing the Embedded-C fixed point
support in Clang, originally discussed in

Reviewers: leonardchan, craig.topper, bjope, jdoerfert

Subscribers: hiraditya, jdoerfert, llvm-commits

Tags: #llvm

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

2 years ago[LangRef] Minor fixes to intrinsic headers and descriptions. NFC.
Bevin Hansson [Thu, 16 Jul 2020 15:00:34 +0000 (17:00 +0200)]
[LangRef] Minor fixes to intrinsic headers and descriptions. NFC.

2 years ago[clangd] Fix a typo, NFC.
Haojian Wu [Fri, 7 Aug 2020 13:02:06 +0000 (15:02 +0200)]
[clangd] Fix a typo, NFC.

2 years ago[Sema] Add casting check for fixed to fixed point conversions
Vince Bridgers [Mon, 3 Aug 2020 20:37:59 +0000 (15:37 -0500)]
[Sema] Add casting check for fixed to fixed point conversions

This change squelches the warning for a cast from fixed to fixed point
conversions when -Wbad-function-cast is enabled.


cast from function call of type '_Fract' to non-matching type '_Fract'

Reviewed By: bjope

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

2 years ago[macho2yaml] Remove unused functions. NFC.
Xing GUO [Fri, 7 Aug 2020 12:33:18 +0000 (20:33 +0800)]
[macho2yaml] Remove unused functions. NFC.

dumpDebugStrings() and dumpDebugAbbrev() are no longer used in
macho2yaml. This patch helps remove them.

Reviewed By: grimar

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

2 years agoBEGIN_PUBLIC
Alexander Belyaev [Fri, 7 Aug 2020 12:31:02 +0000 (14:31 +0200)]
[mlir] Add support for unranked case for `tensor_store` and `tensor_load` ops.

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

2 years ago[mlir] Remove llvm::LLVMContext and llvm::Module from mlir::LLVMDialectImpl
Alex Zinenko [Thu, 6 Aug 2020 16:16:14 +0000 (18:16 +0200)]
[mlir] Remove llvm::LLVMContext and llvm::Module from mlir::LLVMDialectImpl

Original modeling of LLVM IR types in the MLIR LLVM dialect had been wrapping
LLVM IR types and therefore required the LLVMContext in which they were created
to outlive them, which was solved by placing the LLVMContext inside the dialect
and thus having the lifetime of MLIRContext. This has led to numerous issues
caused by the lack of thread-safety of LLVMContext and the need to re-create
LLVM IR modules, obtained by translating from MLIR, in different LLVM contexts
to enable parallel compilation. Similarly, llvm::Module had been introduced to
keep track of identified structure types that could not be modeled properly.

A recent series of commits changed the modeling of LLVM IR types in the MLIR
LLVM dialect so that it no longer wraps LLVM IR types and has no dependence on
LLVMContext and changed the ownership model of the translated LLVM IR modules.
Remove LLVMContext and LLVM modules from the implementation of MLIR LLVM
dialect and clean up the remaining uses.

The only part of LLVM IR that remains necessary for the LLVM dialect is the
data layout. It should be moved from the dialect level to the module level and
replaced with an MLIR-based representation to remove the dependency of the
LLVMDialect on LLVM IR library.

Reviewed By: rriddle

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

2 years ago[mlir] do not require LLVMDialect in conversion from LLVM IR
Alex Zinenko [Thu, 6 Aug 2020 16:16:04 +0000 (18:16 +0200)]
[mlir] do not require LLVMDialect in conversion from LLVM IR

Historically, LLVMDialect has been required in the conversion from LLVM IR in
order to be able to construct types. This is no longer necessary with the new
type model and the dialect can be replaced with a local LLVM context.

Reviewed By: rriddle, mehdi_amini

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

2 years ago[mlir] take LLVMContext in MLIR-to-LLVM-IR translation
Alex Zinenko [Thu, 6 Aug 2020 16:15:47 +0000 (18:15 +0200)]
[mlir] take LLVMContext in MLIR-to-LLVM-IR translation

Due to the original type system implementation, LLVMDialect in MLIR contains an
LLVMContext in which the relevant objects (types, metadata) are created. When
an MLIR module using the LLVM dialect (and related intrinsic-based dialects
NVVM, ROCDL, AVX512) is converted to LLVM IR, it could only live in the
LLVMContext owned by the dialect. The type system no longer relies on the
LLVMContext, so this limitation can be removed. Instead, translation functions
now take a reference to an LLVMContext in which the LLVM IR module should be
constructed. The caller of the translation functions is responsible for
ensuring the same LLVMContext is not used concurrently as the translation no
longer uses a dialect-wide context lock.

As an additional bonus, this change removes the need to recreate the LLVM IR
module in a different LLVMContext through printing and parsing back, decreasing
the compilation overhead in JIT and GPU-kernel-to-blob passes.

Reviewed By: rriddle, mehdi_amini

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

2 years ago[DAG] GetDemandedBits - remove custom AND handling.
Simon Pilgrim [Fri, 7 Aug 2020 11:55:47 +0000 (12:55 +0100)]
[DAG] GetDemandedBits - remove custom AND handling.

As mentioned on D85463, we should be using SimplifyMultipleUseDemandedBits (which is the default fallback).

The minor regression in illegal-bitfield-loadstore.ll will be addressed properly by D77804.

2 years agoRemove unreachable break. NFC
Simon Pilgrim [Fri, 7 Aug 2020 11:37:49 +0000 (12:37 +0100)]
Remove unreachable break. NFC

2 years agoRemove duplicate/unreachable break (PR47029)
Simon Pilgrim [Fri, 7 Aug 2020 10:48:48 +0000 (11:48 +0100)]
Remove duplicate/unreachable break (PR47029)

2 years ago[SLP][X86] Add smax intrinsic reduction tests
Simon Pilgrim [Fri, 7 Aug 2020 10:48:08 +0000 (11:48 +0100)]
[SLP][X86] Add smax intrinsic reduction tests

SLP currently only matches the ICMP+SELECT patterns for min/max reductions

2 years agoRemove unreachable return (PR47028)
Simon Pilgrim [Fri, 7 Aug 2020 10:33:07 +0000 (11:33 +0100)]
Remove unreachable return (PR47028)

2 years ago[Sema][BFloat] Forbid arithmetic on vectors of bfloat.
Simon Tatham [Fri, 7 Aug 2020 09:26:29 +0000 (10:26 +0100)]
[Sema][BFloat] Forbid arithmetic on vectors of bfloat.

Vectors of bfloat are a storage format only; you're supposed to
explicitly convert them to a wider type to do arithmetic on them.
But currently, if you write something like

  bfloat16x4_t test(bfloat16x4_t a, bfloat16x4_t b) { return a + b; }

then the clang frontend accepts it without error, and (ARM or AArch64)
isel fails to generate code for it.

Added a rule in Sema that forbids the attempt from even being made,
and tests that check it. In particular, we also outlaw arithmetic
between vectors of bfloat and any other vector type.

Patch by Luke Cheeseman.

Reviewed By: LukeGeeson

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

2 years agoRemove unreachable return (PR47026)
Simon Pilgrim [Fri, 7 Aug 2020 10:20:44 +0000 (11:20 +0100)]
Remove unreachable return (PR47026)

2 years ago[SLP][X86] Add abs/smax/smin/umax/umin intrinsic vectorization tests
Simon Pilgrim [Fri, 7 Aug 2020 10:19:04 +0000 (11:19 +0100)]
[SLP][X86] Add abs/smax/smin/umax/umin intrinsic vectorization tests

2 years ago[NFC][Test] Format the test with script update_llc_test_checks.py
QingShan Zhang [Fri, 7 Aug 2020 10:20:58 +0000 (10:20 +0000)]
[NFC][Test] Format the test with script update_llc_test_checks.py

2 years ago[mlir][Vector] Add 2-D vector contract lowering to ReduceOp
Nicolas Vasilache [Thu, 6 Aug 2020 13:00:38 +0000 (09:00 -0400)]
[mlir][Vector] Add 2-D vector contract lowering to ReduceOp

This new pattern mixes vector.transpose and direct lowering to vector.reduce.
This allows more progressive lowering than immediately going to insert/extract and
composes more nicely with other canonicalizations.
This has 2 use cases:
1. for very wide vectors the generated IR may be much smaller
2. when we have a custom lowering for transpose ops we can target it directly
rather than rely LLVM

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

2 years ago[Test] Added test showing missing range check elimination opportunity in IndVars
Max Kazantsev [Fri, 7 Aug 2020 09:46:39 +0000 (16:46 +0700)]
[Test] Added test showing missing range check elimination opportunity in IndVars

Seems that SCEV is not powerful enough to handle this.

2 years ago[AArch64] Disable waitid.cpp test for AArch64
Oliver Stannard [Fri, 7 Aug 2020 09:41:16 +0000 (10:41 +0100)]
[AArch64] Disable waitid.cpp test for AArch64

This test is failing intermittently on the AArch64 build bots, disable
it for now to keep the bots green while we investigate it.

2 years ago[clangd] Include the underlying decls in go-to-definition.
Haojian Wu [Fri, 7 Aug 2020 09:36:33 +0000 (11:36 +0200)]
[clangd] Include the underlying decls in go-to-definition.

Fixes https://github.com/clangd/clangd/issues/277

Reviewed By: sammccall

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

2 years ago[NFC] Replace hasName in loop for hasAnyName
Nathan James [Fri, 7 Aug 2020 09:22:26 +0000 (10:22 +0100)]
[NFC] Replace hasName in loop for hasAnyName

2 years ago[VE] Change to expand multiply related instructions
Kazushi (Jam) Marukawa [Tue, 4 Aug 2020 07:41:12 +0000 (16:41 +0900)]
[VE] Change to expand multiply related instructions

Change to expand MULHU/MULHS/UMUL_LOHI/SMUL_LOHI for i32 and i64 since
those instructions are not available on Aurora SX VE.  Some of them
are used in expansion of i128 multiply, so need to modify them to
support i128.  Then, update basic arithmetic regression tests of
i128 and signed/unsigned i32 typed integer values.

Reviewed By: simoll

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

2 years ago[VE] Remove obsoleted getVEAsmModeForCPU function
Kazushi (Jam) Marukawa [Wed, 24 Jun 2020 11:55:40 +0000 (20:55 +0900)]
[VE] Remove obsoleted getVEAsmModeForCPU function

Reviewed By: simoll

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

2 years ago[AST][RecoveryExpr] Fix the missing type when rebuilding RecoveryExpr in TreeTransform.
Haojian Wu [Fri, 7 Aug 2020 09:14:37 +0000 (11:14 +0200)]
[AST][RecoveryExpr] Fix the missing type when rebuilding RecoveryExpr in TreeTransform.

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

2 years ago[DebugInfo] Remove DwarfUnit::getDwarfVersion(). NFC.
Igor Kudrin [Thu, 6 Aug 2020 10:48:57 +0000 (17:48 +0700)]
[DebugInfo] Remove DwarfUnit::getDwarfVersion(). NFC.

This helper method was used only in one place, which can easily use the
direct call.

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

2 years ago[DebugInfo] Clean up DIEUnit. NFC.
Igor Kudrin [Thu, 6 Aug 2020 10:49:05 +0000 (17:49 +0700)]
[DebugInfo] Clean up DIEUnit. NFC.

This removes members of the DIEUnit class which were used only in unit
tests. Note also that child classes shadowed some of these methods,
namely, getDwarfVersion() was overridden in DwartfUnit and getLength()
was overridden in DwarfCompileUnit.

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

2 years ago[SyntaxTree][NFC] remove redundant namespace-specifiers
Eduardo Caldas [Thu, 6 Aug 2020 12:13:36 +0000 (12:13 +0000)]
[SyntaxTree][NFC] remove redundant namespace-specifiers

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