platform/upstream/llvm.git
3 years ago[Syntax] Add iterators over children of syntax trees.
Sam McCall [Fri, 23 Oct 2020 10:23:29 +0000 (12:23 +0200)]
[Syntax] Add iterators over children of syntax trees.

This gives us slightly nicer syntax (foreach) for idioms currently expressed
as a loop, and the option to use range algorithms where it makes sense
(e.g. llvm::all_of et al encapsulate the needed flow control in a useful way).

It's also a building block for iteration over filtered views (e.g. iterate over
all Stmt children, with the right type):
for (const Statement &S : filter<Statement>(N.children()))
  ...

I realize the recent direction has been mostly towards strongly-typed
node-specific facilities, but I think it's important we have convenient
generic facilities too.

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

3 years ago[yaml2obj] - Support the "Offset" key for the .dynsym section.
Georgii Rymar [Tue, 27 Oct 2020 11:38:02 +0000 (14:38 +0300)]
[yaml2obj] - Support the "Offset" key for the .dynsym section.

Our "implicit" sections are handled separately from regular ones.
It turns out that the "Offset" key is not handled properly for them.

Perhaps we can generalize handling in one place, but before doing that I'd like
to add support and test cases for each implicit section.
(I need this particular single change to unblock another patch that is already on review,
and I guess doing it independently for each section will be cleaner, see below).

In this patch I've removed `explicit-dynsym-no-dynstr.yaml` to `dynsym-section.yaml`
and added the new test into. In a follow-up we probably might want
to merge 2 another existent `dynsymtab-*.yaml` tests into it too.

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

3 years ago[DSE] Use walker to skip noalias stores between current & clobber def.
Florian Hahn [Wed, 28 Oct 2020 11:01:25 +0000 (11:01 +0000)]
[DSE] Use walker to skip noalias stores between current & clobber def.

Instead of getting the defining access we should be able to use
getClobberingMemoryAccess to skip non-aliasing MemoryDefs. No additional
checks should be needed, because we only remove the starting def if it
matches the defining access of the load. All we need to worry about is
that there are no (may)alias stores between the starting def and the
load and getClobberingMemoryAccess should guarantee that.

Partly fixes PR47887.

This improves the number of redundant stores removed in some cases
(numbers below for MultiSource, SPEC2000, SPEC2006 on X86 with -flto
-O3).

Same hash: 226 (filtered out)
Remaining: 11
Metric: dse.NumRedundantStores

Program                                        base   patch1 diff
 test-suite...:: External/Povray/povray.test     1.00   5.00 400.0%
 test-suite...chmarks/MallocBench/gs/gs.test     1.00   3.00 200.0%
 test-suite...0/253.perlbmk/253.perlbmk.test    21.00  37.00 76.2%
 test-suite...0.perlbench/400.perlbench.test    24.00  37.00 54.2%
 test-suite.../Applications/SPASS/SPASS.test     3.00   4.00 33.3%
 test-suite...006/453.povray/453.povray.test    15.00  18.00 20.0%
 test-suite...T2006/445.gobmk/445.gobmk.test    27.00  29.00  7.4%
 test-suite.../CINT2006/403.gcc/403.gcc.test   136.00 137.00  0.7%
 test-suite.../CINT2000/176.gcc/176.gcc.test     6.00   6.00  0.0%
 test-suite.../Benchmarks/Bullet/bullet.test    NaN     3.00  nan%
 test-suite.../Benchmarks/Ptrdist/bc/bc.test    NaN     1.00  nan%

Reviewed By: asbirlea

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

3 years ago[VE] Add vector merger operation instructions
Kazushi (Jam) Marukawa [Wed, 28 Oct 2020 03:51:48 +0000 (12:51 +0900)]
[VE] Add vector merger operation instructions

Add VMRG/VSHF/VCP/VEX isntructions.  Add regression tests too.
Also add new patterns to parse new UImm4 oeprand.

Reviewed By: simoll

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

3 years ago[testing] Add missing REQUIRES: asserts
David Zarzycki [Wed, 28 Oct 2020 10:14:54 +0000 (06:14 -0400)]
[testing] Add missing REQUIRES: asserts

3 years ago[VE] Add vector iterative operation instructions
Kazushi (Jam) Marukawa [Tue, 27 Oct 2020 17:40:04 +0000 (02:40 +0900)]
[VE] Add vector iterative operation instructions

Add VFIA/VFIS/VFIM/VFIAM/VFISM/VFIMA/VFIMS isntructions.
Add regression tests too.

Reviewed By: simoll

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

3 years ago[llvm-exegesis][doc] Remove old FIXME.
Clement Courbet [Wed, 28 Oct 2020 09:51:50 +0000 (10:51 +0100)]
[llvm-exegesis][doc] Remove old FIXME.

This was fixed in a previous commit, the previous line in the
documentation explains how to proceed.

3 years ago[VE][NFC] Fix typo in comment
Kazushi (Jam) Marukawa [Mon, 26 Oct 2020 09:03:43 +0000 (18:03 +0900)]
[VE][NFC] Fix typo in comment

3 years ago[VE] Specify to expand BRIND and BR_JT
Kazushi (Jam) Marukawa [Sat, 24 Oct 2020 13:00:15 +0000 (22:00 +0900)]
[VE] Specify to expand BRIND and BR_JT

BRIND and BR_JT are not implmented yet, so expand them atm.
Add regression tests too.

Reviewed By: simoll

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

3 years ago[llvm-exegesis] Do not silently fail on unknown instruction encoding formats.
Clement Courbet [Wed, 28 Oct 2020 08:26:29 +0000 (09:26 +0100)]
[llvm-exegesis] Do not silently fail on unknown instruction encoding formats.

The addition of TILELOADD instructions with a new encoding format
triggered a hard abort instead of proper error reporting due to the use
of `llvm_unreachable` for actually reachable code.
Properly report an error when the encoding format is unknown.

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

3 years agoRe-enable "[SCEV] Prove implications of different type via truncation"
Max Kazantsev [Wed, 28 Oct 2020 06:28:39 +0000 (13:28 +0700)]
Re-enable "[SCEV] Prove implications of different type via truncation"

When we need to prove implication of expressions of different type width,
the default strategy is to widen everything to wider type and prove in this
type. This does not interact well with AddRecs with negative steps and
unsigned predicates: such AddRec will likely not have a `nuw` flag, and its
`zext` to wider type will not be an AddRec. In contraty, `trunc` of an AddRec
in some cases can easily be proved to be an `AddRec` too.

This patch introduces an alternative way to handling implications of different
type widths. If we can prove that wider type values actually fit in the narrow type,
we truncate them and prove the implication in narrow type.

The return was due to revert of underlying patch that this one depends on.

Unit test temporarily disabled because the required logic in SCEV is switched
off due to compile time reasons.

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

3 years ago[AArch64] Remove AArch64ISD::NOT, use vnot instead
David Green [Wed, 28 Oct 2020 08:15:37 +0000 (08:15 +0000)]
[AArch64] Remove AArch64ISD::NOT, use vnot instead

vnot (xor -1) should be equivalent to the AArch64 specific AArch64ISD::NOT
node, but allow more folding thanks to all the target independent
optimizations. Specifically this allows select(icmp ne, x, y) to
become "cmeq; bsl y, x" as opposed to needing to convert the predicate
with "cmeq; mvn; bsl x, y"

Unfortunately there is a regression in a cmtst test, but the code it
selected from was already non-canonical, with instcombine preferring to
use an eq predicate instead. Plus the more common case of icmp ne is
improved.

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

3 years ago[AArch64] Additional Interleaving Access test. NFC
David Green [Wed, 28 Oct 2020 08:00:05 +0000 (08:00 +0000)]
[AArch64] Additional Interleaving Access test. NFC

3 years ago[llvm-exegesis] Update doc.
Clement Courbet [Wed, 28 Oct 2020 07:15:58 +0000 (08:15 +0100)]
[llvm-exegesis] Update doc.

We don't need an external script to scan all opcodes anymore, just use
`-opcode-index=-1`.

3 years ago[NFC][Sanitizer] format sanitizer_platform_interceptors.h
Vitaly Buka [Wed, 28 Oct 2020 07:39:58 +0000 (00:39 -0700)]
[NFC][Sanitizer] format sanitizer_platform_interceptors.h

3 years ago[NFC][Asan] Fix cpplint warning in test
Vitaly Buka [Wed, 28 Oct 2020 07:38:50 +0000 (00:38 -0700)]
[NFC][Asan] Fix cpplint warning in test

3 years ago[NFC][Asan] Fix cpplint warnings in tests
Vitaly Buka [Wed, 28 Oct 2020 07:32:44 +0000 (00:32 -0700)]
[NFC][Asan] Fix cpplint warnings in tests

3 years ago[NFC][UBSAN] Try to re-enable tests on IOS
Vitaly Buka [Wed, 28 Oct 2020 06:46:36 +0000 (23:46 -0700)]
[NFC][UBSAN] Try to re-enable tests on IOS

Looks like the reason they were disabled is the same as for Android
and it's fixed by 776a15d8aecad2768f1391092099e9b173b8148b

3 years ago[NFC][UBSAN] Remove XFAIL from fixed tests
Vitaly Buka [Wed, 28 Oct 2020 06:42:41 +0000 (23:42 -0700)]
[NFC][UBSAN] Remove XFAIL from fixed tests

3 years agoRename EHPersonality::MSVC_Win64SEH to EHPersonality::MSVC_TableSEH. NFC.
Luqman Aden [Wed, 28 Oct 2020 06:18:26 +0000 (23:18 -0700)]
Rename EHPersonality::MSVC_Win64SEH to EHPersonality::MSVC_TableSEH. NFC.

The types of SEH aren't x86(-32) vs x64 but rather stack-based exception chaining
vs table-based exception handling. x86-32 is the only arch for which Windows
uses the former. 32-bit ARM would use what is called Win64SEH today, which
is a bit confusing so instead let's just rename it to be a bit more clear.

Reviewed By: compnerd, rnk

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

3 years ago[SCEV] Re-enable "Use nw flag and symbolic iteration count to sharpen ranges of AddRe...
Max Kazantsev [Wed, 28 Oct 2020 05:39:41 +0000 (12:39 +0700)]
[SCEV] Re-enable "Use nw flag and symbolic iteration count to sharpen ranges of AddRecs", attempt 3

We can sharpen the range of a AddRec if we know that it does not
self-wrap and know the symbolic iteration count in the loop. If we can
evaluate the value of AddRec on the last iteration and prove that at least
one its intermediate value lies between start and end, then no-wrap flag
allows us to conclude that all of them also lie between start and end. So
the estimate of range can be improved to union of ranges of start and end.

Switched off by default, can be turned on by flag.

Differential Revision: https://reviews.llvm.org/D89381
Reviewed By: lebedev.ri, nikic

3 years ago[OpenMP][CUDA][FIX] Use the new `remquo` overload only for OpenMP
Johannes Doerfert [Wed, 28 Oct 2020 04:50:00 +0000 (23:50 -0500)]
[OpenMP][CUDA][FIX] Use the new `remquo` overload only for OpenMP

CUDA buildbots complained about a redefinition when I landed D89971.
This is odd and I fail to understand where in the CUDA headers the other
definition is supposed to be. For now, given that CUDA doesn't need the
overload (AFAIKT), we simply restrict it to the OpenMP mode.

3 years ago[JumpThreading] Rename thread-prob-3.ll to thread-prob-1.ll (NFC)
Kazu Hirata [Wed, 28 Oct 2020 04:33:05 +0000 (21:33 -0700)]
[JumpThreading] Rename thread-prob-3.ll to thread-prob-1.ll (NFC)

I just removed thread-prob-{1,2}.ll in
b2f05fae80b0c1a307a9e257157a0d70e6623eb8, so I am removing
thread-prob-3.ll to thread-prob-1.ll.

3 years ago[JumpThreading] Remove extraneous calls to setEdgeProbability
Kazu Hirata [Wed, 28 Oct 2020 04:12:54 +0000 (21:12 -0700)]
[JumpThreading] Remove extraneous calls to setEdgeProbability

This patch removes extraneous calls to setEdgeProbability introduced
in c91487769d80487eba1712a7a172a1c8977a9b4f.

The follow-up patch, a7b662d0f4098371b96ce4446fb0eba79b0b649f, has
since fixed BranchProbabilityInfo::eraseBlock, so we don't need to
worry about getting stale values from getEdgeProbability.

Also, since getEdgeProbability(BB, BB->getSingleSuccessor()) returns
edge probability 1/1 by default for BB with exactly one successor
edge, we don't need to explicitly call setEdgeProbability.

This patch introduces almost no functional change, but we do end up
reducing debug messages from setEdgeProbability.

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

3 years agoRevert "[DebugInfo] Expose Fortran array debug info attributes through DIBuilder."
Mitch Phillips [Wed, 28 Oct 2020 03:34:48 +0000 (20:34 -0700)]
Revert "[DebugInfo] Expose Fortran array debug info attributes through DIBuilder."

This reverts commit 5b3bf8b453b8cc00efd5269009a1e63c4442a30e.

This caused a regression in the ASan buildbot. See comments at
https://reviews.llvm.org/D89817 for more information.

3 years agoRevert "[ADT] Fix for ImmutableMapRef"
Mitch Phillips [Wed, 28 Oct 2020 00:58:41 +0000 (17:58 -0700)]
Revert "[ADT] Fix for ImmutableMapRef"

This reverts commit a6336eab0c507b665dda63fa9db1292a2cdee409.

This commit broke check-llvm under ASan:

See http://lab.llvm.org:8011/#/builders/5/builds/446 for more details.

3 years ago[NFC] [LLParser] Renaming LLParser routines to comply LLVM coding style
Alok Kumar Sharma [Sat, 17 Oct 2020 09:21:27 +0000 (14:51 +0530)]
[NFC] [LLParser] Renaming LLParser routines to comply LLVM coding style

For any newly added parse function, clang-tidy complains. New parse
functions are implicitly defined by a macro "Parse##CLASS(N, IsDistinct)".
Now this macro and exising function definitions are corrected (lower case
first character). Some other variable/function names are also corrected
to comply LLVM coding style.

Reviewed By: djtodoro

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

3 years ago[AMDGPU] Fix insert of SIPreAllocateWWMRegs in FastRegAlloc
Carl Ritson [Wed, 28 Oct 2020 02:42:24 +0000 (11:42 +0900)]
[AMDGPU] Fix insert of SIPreAllocateWWMRegs in FastRegAlloc

SIPreAllocateWWMRegs was being inserted after RegisterCoalescer
but this pass does not exist during FastAlloc so pre-allocation
pass was never being run.
Insert pre-allocation after TwoAddressInstructionPass instead.

Reviewed By: rampitec

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

3 years ago[Attributor] Finalize the CGUpdater after each SCC
Johannes Doerfert [Sat, 10 Oct 2020 14:59:09 +0000 (09:59 -0500)]
[Attributor] Finalize the CGUpdater after each SCC

This matches the new PM model.

3 years ago[Attributor][NFC] Introduce a debug counter for `AA::manifest`
Johannes Doerfert [Sat, 10 Oct 2020 15:04:47 +0000 (10:04 -0500)]
[Attributor][NFC] Introduce a debug counter for `AA::manifest`

This will simplify debugging and tracking down problems.

3 years ago[Attributor][NFC] Print the right value in debug output
Johannes Doerfert [Sat, 10 Oct 2020 14:58:25 +0000 (09:58 -0500)]
[Attributor][NFC] Print the right value in debug output

3 years ago[Attributor][FIX] Delete all unreachable static functions
Johannes Doerfert [Thu, 10 Sep 2020 05:03:32 +0000 (00:03 -0500)]
[Attributor][FIX] Delete all unreachable static functions

Before we used to only mark unreachable static functions as dead if all
uses were known dead. Now we optimistically assume uses to be dead until
proven otherwise.

3 years ago[Attributor][FIX] Do not attach range metadata to the wrong Instruction
Johannes Doerfert [Sat, 10 Oct 2020 15:06:03 +0000 (10:06 -0500)]
[Attributor][FIX] Do not attach range metadata to the wrong Instruction

If we are looking at a call site argument it might be a load or call
which is in a different context than the call site argument. We cannot
simply use the call site argument range for the call or load.

Bug reported and reduced by Whitney Tsang <whitneyt@ca.ibm.com>.

3 years ago[Attributor][NFC] Clang-format
Johannes Doerfert [Sat, 10 Oct 2020 14:41:42 +0000 (09:41 -0500)]
[Attributor][NFC] Clang-format

3 years ago[Attributor][NFC] Hoist call out of a lambda
Johannes Doerfert [Sat, 10 Oct 2020 14:41:18 +0000 (09:41 -0500)]
[Attributor][NFC] Hoist call out of a lambda

The call is not free, unsure if  this is needed but it does not make it
worse either.

3 years ago[Attributor][FIX] Properly check uses in the call not uses of the call
Johannes Doerfert [Sat, 10 Oct 2020 14:39:51 +0000 (09:39 -0500)]
[Attributor][FIX] Properly check uses in the call not uses of the call

In the AANoAlias logic we determine if a pointer may have been captured
before a call. We need to look at other uses in the call not uses of the
call.

The new code is not perfect as it does not allow trivial cases where the
call has multiple arguments but it is at least not unsound and a TODO
was added.

3 years ago[Attributor][NFC] Improve time trace output
Johannes Doerfert [Sat, 10 Oct 2020 14:28:47 +0000 (09:28 -0500)]
[Attributor][NFC] Improve time trace output

3 years ago[MLIR] [ODS] Allowing attr-dict in custom directive
John Demme [Wed, 28 Oct 2020 01:01:44 +0000 (01:01 +0000)]
[MLIR] [ODS] Allowing attr-dict in custom directive

Enhance tblgen's declarative assembly format to allow `attr-dict` in
custom directives.

Reviewed By: rriddle

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

3 years ago[flang][openacc] Fix ambiguity in the self clause parsing
Valentin Clement [Wed, 28 Oct 2020 01:09:48 +0000 (21:09 -0400)]
[flang][openacc] Fix ambiguity in the self clause parsing

In the OpenACC specification, there are two different self clause. One for the
update directive with a var-list argument. This clause is a synonym of the host clause.
The second self clause is present for most of the compute construct and takes an optional
condition. To solve this ambiguity, the self clause for the update directive is directly
translated to a host clause during the parsing. The self clause in AccClause refers always
to the compute construct clause.

Reviewed By: kiranktp

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

3 years agoRevert "[WebAssembly] Add support for DWARF type units"
Derek Schuff [Wed, 28 Oct 2020 00:57:32 +0000 (17:57 -0700)]
Revert "[WebAssembly] Add support for DWARF type units"

This reverts commit bcb8a119df210753c5f1a3ac346d49597fef0f51.

3 years agoRemove unused variable name. NFC.
Richard Smith [Wed, 28 Oct 2020 00:16:16 +0000 (17:16 -0700)]
Remove unused variable name. NFC.

3 years ago[mlir] Fix stack-use-after-scope in cuda/vulkan cpu runners
Eugene Zhulenev [Wed, 28 Oct 2020 00:02:10 +0000 (17:02 -0700)]
[mlir] Fix stack-use-after-scope in cuda/vulkan cpu runners

+fix rocm runner

Reviewed By: mehdi_amini

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

3 years ago[clang] Pass-through remarks options to linker
Wei Wang [Wed, 28 Oct 2020 00:11:26 +0000 (17:11 -0700)]
[clang] Pass-through remarks options to linker

Summary:
Propagate driver commandline remarks options to linker when LTO is enabled.

This gives novice user a convenient way to collect and filter remarks throughout
a typical toolchain invocation with sample profile and LTO using single switch
from the clang driver.

A typical use of this option from clang command-line:

* Using -Rpass* options to print remarks to screen:

  clang -fuse-ld=lld -flto=thin -fprofile-sample-use=foo_sample.txt
   -Rpass=inline -Rpass-missed=inline -Rpass-analysis=inline
   -fdiagnostics-show-hotness -fdiagnostics-hotness-threshold=100 -o foo foo.cpp

  Remarks will be dumped to screen from both pre-lto and lto
  compilation.

* Using serialized remarks options

  clang -fuse-ld=lld -flto=thin -fprofile-sample-use=foo_sample.txt
   -fsave-optimization-record
   -fdiagnostics-show-hotness -fdiagnostics-hotness-threshold=100 -o foo foo.cpp

  This will produce multiple yaml files containing optimization remarks:
  1. foo.opt.yaml : remarks from pre-lto
  2. foo.opt.ld.yaml.thin.1.yaml: remark during lto

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

3 years ago[WebAssembly] Add support for DWARF type units
Derek Schuff [Wed, 30 Sep 2020 18:55:12 +0000 (11:55 -0700)]
[WebAssembly] Add support for DWARF type units

Since Wasm comdat sections work similarly to ELF, we can use that mechanism
to eliminate duplicate dwarf type information in the same way.

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

3 years ago[LangRef] Clarify `dereferenceable` -> `nonnull` implication
Johannes Doerfert [Wed, 14 Oct 2020 18:54:20 +0000 (13:54 -0500)]
[LangRef] Clarify `dereferenceable` -> `nonnull` implication

If `null_pointer_is_valid` is present, `dereferenceable` does not imply
`nonnull`, make it clear.

Came up in D17993.

Reviewed By: aqjune

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

3 years ago[OpenMP][CUDA] Add missing overload for `remquo(float,float,int*)`
Johannes Doerfert [Thu, 22 Oct 2020 16:36:49 +0000 (11:36 -0500)]
[OpenMP][CUDA] Add missing overload for `remquo(float,float,int*)`

Reported by Colleen Bertoni <bertoni@anl.gov> after running the OvO test
suite: https://github.com/TApplencourt/OvO/

The template overload is still hidden behind an ifdef for OpenMP. In the
future we probably want to remove the ifdef but that requires further
testing.

Reviewed By: JonChesterfield, tra

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

3 years agoUnbreak build with gcc5.3 after 917acac
Nico Weber [Wed, 28 Oct 2020 00:10:48 +0000 (20:10 -0400)]
Unbreak build with gcc5.3 after 917acac

3 years ago[libc][NFC] Use a convenience macro to declare special floating point constants.
Siva Chandra Reddy [Tue, 27 Oct 2020 20:12:18 +0000 (13:12 -0700)]
[libc][NFC] Use a convenience macro to declare special floating point constants.

Reviewed By: lntue

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

3 years ago[BranchProbabilityInfo] Make MaxSuccIdx[Src] efficient and add a comment about the...
Fangrui Song [Tue, 27 Oct 2020 23:29:10 +0000 (16:29 -0700)]
[BranchProbabilityInfo] Make MaxSuccIdx[Src] efficient and add a comment about the subtle eraseBlock. NFC

Follow-up to D90272.

3 years ago[mlir][NFC] Fix incorrect header comments.
River Riddle [Tue, 27 Oct 2020 23:22:13 +0000 (16:22 -0700)]
[mlir][NFC] Fix incorrect header comments.

Resolves missed comments in D89103

3 years ago[mlir][NFC] Remove unnecessary PatternRewriter::create methods
River Riddle [Tue, 27 Oct 2020 23:03:40 +0000 (16:03 -0700)]
[mlir][NFC] Remove unnecessary PatternRewriter::create methods

At this point, these methods are just carbon copies of OpBuilder::create and aren't necessary given that PatternRewriter inherits from OpBuilder.

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

3 years ago[mlir][Interfaces] Optimize the implementation of InterfaceMap to reduce generated...
River Riddle [Tue, 27 Oct 2020 23:03:22 +0000 (16:03 -0700)]
[mlir][Interfaces] Optimize the implementation of InterfaceMap to reduce generated code size.

An InterfaceMap is generated for every single operation type, and is responsible for a large amount of the code size from MLIR given that its internals highly utilize templates. This revision refactors the internal implementation to use bare malloc/free for interface instances as opposed to static variables and moves as much code out of templates as possible. This led to a decrease of over >1mb (~12% of total MLIR related code size) for a downstream MLIR library with a large amount of operations.

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

3 years ago[mlir][Interfaces] Generate a struct containing function pointers instead of a class...
River Riddle [Tue, 27 Oct 2020 23:03:07 +0000 (16:03 -0700)]
[mlir][Interfaces] Generate a struct containing function pointers instead of a class with vtables

When compiling for code size, the use of a vtable causes a destructor(and constructor in certain cases) to be generated for the class. Interface models don't need a complex constructor or a destructor, so this can lead to many megabytes of code size increase(even in opt). This revision switches to a simpler struct of function pointers approach that accomplishes the same API requirements as before. This change requires no updates to user code, or any other code aside from the generator, as the user facing API is still exactly the same.

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

3 years ago[mlir][SIdeEffectInterface][NFC] Move several InterfaceMethods to the extraClassDecla...
River Riddle [Tue, 27 Oct 2020 23:02:59 +0000 (16:02 -0700)]
[mlir][SIdeEffectInterface][NFC] Move several InterfaceMethods to the extraClassDeclarations instead

All InterfaceMethods will have a corresponding entry in the interface model, and by extension have an implementation generated for every operation type. This can result in large binary size increases when a large amount of operations use an interface, such as the side effect interface.

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

3 years ago[mlir][Linalg] Add fusion of IndexedGenericOp with TensorReshapeOp by expansion.
MaheshRavishankar [Tue, 27 Oct 2020 23:15:08 +0000 (16:15 -0700)]
[mlir][Linalg] Add fusion of IndexedGenericOp with TensorReshapeOp by expansion.

This patch adds support for fusing linalg.indexed_generic op with
linalg.tensor_reshape op by expansion, i.e.
- linalg.indexed_generic op -> linalg.tensor_reshape op when the
  latter is expanding.
- linalg.tensor_reshape op -> linalg.indexed_generic op when the
  former is folding.

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

3 years ago[BranchProbabilityInfo] Fix eraseBlock
Kazu Hirata [Tue, 27 Oct 2020 23:14:25 +0000 (16:14 -0700)]
[BranchProbabilityInfo] Fix eraseBlock

This patch ensures that BranchProbabilityInfo::eraseBlock(BB) deletes
all entries in Probs associated with with BB.

Without this patch, stale entries for BB may remain in Probs after
eraseBlock(BB), leading to a situation where a newly created basic
block has an edge probability associated with it even before the pass
responsible for creating the basic block adds any edge probability to
it.

Consider the current implementation of eraseBlock(BB):

  for (const_succ_iterator I = succ_begin(BB), E = succ_end(BB); I != E; ++I) {
    auto MapI = Probs.find(std::make_pair(BB, I.getSuccessorIndex()));
    if (MapI != Probs.end())
      Probs.erase(MapI);
  }

Notice that it uses succ_begin(BB) and succ_end(BB), which are based
on BB->getTerminator().  This means that if the terminator changes
between calls to setEdgeProbability and eraseBlock, then we may not
examine all pairs associated with BB.

This is exactly what happens in MaybeMergeBasicBlockIntoOnlyPred,
which merges basic blocks A into B if A is the sole predecessor of B,
and B is the sole successor of A.  It replaces the terminator of A
with UnreachableInst before (indirectly) calling eraseBlock(A).

The patch fixes the problem by keeping track of all edge probablities
entered with setEdgeProbability in a map from BasicBlock* to a
successor index.

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

3 years ago[JumpThreading] Set edge probabilities when creating basic blocks
Kazu Hirata [Tue, 27 Oct 2020 23:07:27 +0000 (16:07 -0700)]
[JumpThreading] Set edge probabilities when creating basic blocks

This patch teaches the jump threading pass to set edge probabilities
whenever the pass creates new basic blocks.

Without this patch, the compiler sometimes produces non-deterministic
results.  The non-determinism comes from the jump threading pass using
stale edge probabilities in BranchProbabilityInfo.  Specifically, when
the jump threading pass creates a new basic block, we don't initialize
its outgoing edge probability.

Edge probabilities are maintained in:

  DenseMap<Edge, BranchProbability> Probs;

in class BranchProbabilityInfo, where Edge is an ordered pair of
BasicBlock * and a successor index declared as:

  using Edge = std::pair<const BasicBlock *, unsigned>;

Probs maps edges to their corresponding probabilities.

Now, we rarely remove entries from this map, so if we happen to
allocate a new basic block at the same address as a previously deleted
basic block with an edge probability assigned, the newly created basic
block appears to have an edge probability, albeit a stale one.

This patch fixes the problem by explicitly setting edge probabilities
whenever the jump threading pass creates new basic blocks.

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

3 years ago[lld][WebAssembly] Fix memory size in dylink section for -pie exectuables
Sam Clegg [Tue, 27 Oct 2020 19:46:07 +0000 (12:46 -0700)]
[lld][WebAssembly] Fix memory size in dylink section for -pie exectuables

This field to represents the amount of static data needed by
an dynamic library or executable it should not include things
like heap or stack areas, which in the case of `-pie` are
not determined until runtime (e.g. __stack_pointer is imported).

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

3 years ago[mlir] JitRunner: add a config option to register symbols with ExecutionEngine at...
Eugene Zhulenev [Tue, 27 Oct 2020 21:12:47 +0000 (14:12 -0700)]
[mlir] JitRunner: add a config option to register symbols with ExecutionEngine at runtime

Reviewed By: mehdi_amini

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

3 years ago[CostModel] remove cost-kind predicate for FP add/mul vector reduction costs
Sanjay Patel [Tue, 27 Oct 2020 21:40:58 +0000 (17:40 -0400)]
[CostModel] remove cost-kind predicate for FP add/mul vector reduction costs

This was originally part of:
f2c25c70791d
but that was reverted because there was an underlying bug in
processing the vector type of these intrinsics. That was
fixed with:
74ffc823ed21

This is similar in spirit to 01ea93d85d6e (memcpy) except that
here the underlying caller assumptions were created for vectorizer
use (throughput) rather than other passes.

That meant targets could have an enormous throughput cost with no
corresponding size, latency, or blended cost increase.

Paraphrasing from the previous commits:
This may not make sense for some callers, but at least now the
costs will be consistently wrong instead of mysteriously wrong.

Targets should provide better overrides if the current modeling
is not accurate.

3 years ago[CostModel] add tests for FP reductions; NFC
Sanjay Patel [Tue, 27 Oct 2020 21:23:42 +0000 (17:23 -0400)]
[CostModel] add tests for FP reductions; NFC

3 years ago[libcxx] Don't truncate intermediates to wchar_t when widening
Martin Storsjö [Tue, 27 Oct 2020 11:01:54 +0000 (13:01 +0200)]
[libcxx] Don't truncate intermediates to wchar_t when widening

On windows, wchar_t is 16 bit, while we might be widening chars to
char32_t.

This cast had been present since the initial commit, and removing it
doesn't seem to make any tests fail.

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

3 years ago[PowerPC] Fix single-use check and update chain users for ld-splat
Nemanja Ivanovic [Tue, 27 Oct 2020 21:43:11 +0000 (16:43 -0500)]
[PowerPC] Fix single-use check and update chain users for ld-splat

When converting a BUILD_VECTOR or VECTOR_SHUFFLE to a splatting load
as of 1461fb6e783cb946b061f66689b419f74f7fad63, we inaccurately check
for a single user of the load and neglect to update the users of the
output chain of the original load. As a result, we can emit a new
load when the original load is kept and the new load can be reordered
after a dependent store. This patch fixes those two issues.

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

3 years ago[OpenMP] Add Support for Mapping Names in Libomptarget RTL
Joseph Huber [Tue, 27 Oct 2020 20:12:16 +0000 (16:12 -0400)]
[OpenMP] Add Support for Mapping Names in Libomptarget RTL

Summary:
This patch adds basic support for priting the source location and names for the
mapped variables. This patch does not support names for custom mappers. This is
based on D89802. The names information currently will be printed out only in
debug mode or using env LIBOMPTARGET_INFO during execution. But the information
is added when availible to the Device and Private data structures. To get the
information out the code must be built with debug symbols on using -g or
-Rpass=openmp-opt

Reviewers: jdoerfert

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

3 years ago[libc++] Try to fix cross-loading of lit.local.cfg on Windows
Louis Dionne [Tue, 27 Oct 2020 20:24:47 +0000 (16:24 -0400)]
[libc++] Try to fix cross-loading of lit.local.cfg on Windows

On windows, the previous path replacement using forward slashes wouldn't
work, and so we'd end up including the same file again. We would do that
until we'd hit the recursion limit of the Python interpreter.

Instead, use `os.path` to properly replace without assuming a specific
path separator.

3 years ago[AMDGPU] Order AMDGPU ELF machine numbers in ascending order
Tony [Tue, 27 Oct 2020 08:08:45 +0000 (08:08 +0000)]
[AMDGPU] Order AMDGPU ELF machine numbers in ascending order

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

3 years ago[OpenMP] Add Passing in Original Declaration Names To Mapper API
Joseph Huber [Thu, 22 Oct 2020 18:06:50 +0000 (14:06 -0400)]
[OpenMP] Add Passing in Original Declaration Names To Mapper API

Summary:
This patch adds support for passing in the original delcaration name in the
source file to the libomptarget runtime. This will allow the runtime to provide
more intelligent debugging messages. This patch takes the original expression
parsed from the OpenMP map / update clause and provides a textual
representation if it was explicitly mapped, otherwise it takes the name of the
variable declaration as a fallback. The information in passed to the runtime in
a global array of strings that matches the existing ident_t source location
strings using ";name;filename;column;row;;". See
clang/test/OpenMP/target_map_names.cpp for an example of the generated output
for a given map clause.

Reviewers: jdoervert

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

3 years ago[libc++] Make sure we include a header when checking compiler macros
Louis Dionne [Tue, 27 Oct 2020 19:57:47 +0000 (15:57 -0400)]
[libc++] Make sure we include a header when checking compiler macros

Otherwise, it's possible for some __config_site macros not to be
picked up.

3 years ago[test] Delete Feature/load_module.ll which is covered by load_extension.ll
Fangrui Song [Tue, 27 Oct 2020 19:49:45 +0000 (12:49 -0700)]
[test] Delete Feature/load_module.ll which is covered by load_extension.ll

3 years ago[gn build] Port e025d09b216
LLVM GN Syncbot [Tue, 27 Oct 2020 19:40:30 +0000 (19:40 +0000)]
[gn build] Port e025d09b216

3 years ago[gn build] Port ce6900c6cb5
LLVM GN Syncbot [Tue, 27 Oct 2020 19:40:29 +0000 (19:40 +0000)]
[gn build] Port ce6900c6cb5

3 years ago[test] Make ThinLTO/X86/crash_debuginfo.ll work with -enable-new-pm=1
Fangrui Song [Tue, 27 Oct 2020 19:36:59 +0000 (12:36 -0700)]
[test] Make ThinLTO/X86/crash_debuginfo.ll work with -enable-new-pm=1

LegacyInlinerBase::doFinalization runs removeDeadFunctions() to remove bar but
the new PM inliner doesn't. Improve the test to use llvm-nm -U.

3 years ago[HIP][NFC] Use correct max in cuda_complex_builtins
Aaron En Ye Shi [Tue, 27 Oct 2020 19:08:58 +0000 (19:08 +0000)]
[HIP][NFC] Use correct max in cuda_complex_builtins

Update the clang complex builtins for OpenMP to use the
correct max function from either __nv_* or __ocml_*.

3 years agoRevert multiple patches based on "Introduce CfgTraits abstraction"
Nicolai Hähnle [Tue, 27 Oct 2020 19:28:41 +0000 (20:28 +0100)]
Revert multiple patches based on "Introduce CfgTraits abstraction"

These logically belong together since it's a base commit plus
followup fixes to less common build configurations.

The patches are:

Revert "CfgInterface: rename interface() to getInterface()"

This reverts commit a74fc481588fcea9317cbf1f6c5888a30c9edd2d.

Revert "Wrap CfgTraitsFor in namespace llvm to please GCC 5"

This reverts commit f2a06875b604c00cbe96e54363f4f5d28935d610.

Revert "Try to make GCC5 happy about the CfgTraits thing"

This reverts commit 03a5f7ce12e2111c8b7bc5a95cff4c51b516250f.

Revert "Introduce CfgTraits abstraction"

This reverts commit c0cdd22c72fab47a3c37b5a8401763995cadaa77.

3 years agoRevert "DomTree: Extract (mostly) read-only logic into type-erased base classes"
Nicolai Hähnle [Tue, 27 Oct 2020 19:27:51 +0000 (20:27 +0100)]
Revert "DomTree: Extract (mostly) read-only logic into type-erased base classes"

This reverts commit 848a68a032d1c59274526abb3220714202d4757e.

3 years ago[llvm-reduce] Add test with some aliases.
Florian Hahn [Tue, 27 Oct 2020 19:03:19 +0000 (19:03 +0000)]
[llvm-reduce] Add test with some aliases.

3 years ago[mlir][Python] Custom python op view wrappers for building and traversing.
Stella Laurenzo [Thu, 22 Oct 2020 06:34:01 +0000 (23:34 -0700)]
[mlir][Python] Custom python op view wrappers for building and traversing.

* Still rough edges that need more sugar but the bones are there. Notes left in the test case for things that can be improved.
* Does not actually yield custom OpViews yet for traversing. Will rework that in a followup.

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

3 years ago[AMDGPU] Change predicate for fma/fmac legacy
Stanislav Mekhanoshin [Tue, 27 Oct 2020 17:00:53 +0000 (10:00 -0700)]
[AMDGPU] Change predicate for fma/fmac legacy

I do not exactly like the use of a negative predicate to
enable instructions' support. Change HasNoMadMacF32Insts
with HasFmaLegacy32.

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

3 years ago[PowerPC][PCRelative] Turn on TLS support for PCRel by default
Victor Huang [Tue, 27 Oct 2020 18:56:54 +0000 (13:56 -0500)]
[PowerPC][PCRelative] Turn on TLS support for PCRel by default

Turn on TLS support for PCRel by default and update the test cases.

Differential Revision: https://reviews.llvm.org/D88738
Reviewed by: stefanp, kamaub

3 years ago[libc++] Add a libc++ configuration that does not support localization
Louis Dionne [Fri, 9 Oct 2020 19:31:05 +0000 (15:31 -0400)]
[libc++] Add a libc++ configuration that does not support localization

When porting libc++ to embedded systems, it can be useful to drop support
for localization, which these systems don't implement or care about.

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

3 years agoFileManager: Shrink FileEntryRef to the size of a pointer
Duncan P. N. Exon Smith [Thu, 15 Oct 2020 15:39:07 +0000 (11:39 -0400)]
FileManager: Shrink FileEntryRef to the size of a pointer

Shrink `FileEntryRef` to the size of a pointer, by having it directly
reference the `StringMapEntry` the same way that `DirectoryEntryRef`
does. This makes `FileEntryRef::FileEntryRef` private as a side effect
(`FileManager` is a friend!).

There are two helper types added within `FileEntryRef`:

- `FileEntryRef::MapValue` is the type stored in
  `FileManager::SeenFileEntries`. It's a replacement for
  `SeenFileEntryOrRedirect`, where the second pointer type has been
  changed from `StringRef*` to `MapEntry*` (see next bullet).
- `FileEntryRef::MapEntry` is the instantiation of `StringMapEntry<>`
  where `MapValue` is stored. This is what `FileEntryRef` has a pointer
  to, in order to grab the name in addition to the value.

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

3 years ago[mlir] Add bufferization for std.select op.
Sean Silva [Tue, 27 Oct 2020 00:29:18 +0000 (17:29 -0700)]
[mlir] Add bufferization for std.select op.

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

3 years ago[AMDGPU] Fix check prefix for VOP3 VI disassembler tests
Jay Foad [Tue, 27 Oct 2020 15:14:12 +0000 (15:14 +0000)]
[AMDGPU] Fix check prefix for VOP3 VI disassembler tests

Also, following D81841, don't try to encode f16 literals in i16/u16
instructions.

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

3 years ago[mlir] Catch async.yield operands not matching the number of async.execute results.
Christian Sigg [Tue, 27 Oct 2020 08:45:55 +0000 (09:45 +0100)]
[mlir] Catch async.yield operands not matching the number of async.execute results.

Reviewed By: ezhulenev

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

3 years ago[libcxx] Fix typo in spelling of 'sentinel'. NFC.
Martin Storsjö [Tue, 27 Oct 2020 09:46:06 +0000 (11:46 +0200)]
[libcxx] Fix typo in spelling of 'sentinel'. NFC.

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

3 years ago[llvm-readobj] Remove duplicate inner if() condition. NFCI.
Simon Pilgrim [Tue, 27 Oct 2020 18:35:42 +0000 (18:35 +0000)]
[llvm-readobj] Remove duplicate inner if() condition. NFCI.

This should have been removed when rG445c3fdd2ae8 simplified the conditions.

Reported as "Snippet 5" in https://www.viva64.com/en/b/0771/

3 years agoRevert "[CodeView] Emit static data members as S_CONSTANTs."
Amy Huang [Tue, 27 Oct 2020 18:29:27 +0000 (11:29 -0700)]
Revert "[CodeView] Emit static data members as S_CONSTANTs."

Seems like there's an assert in here that we shouldn't be running into.

This reverts commit 515973222ed29abe49f241e89edb6854f44162d4.

3 years ago[gn build] Port 46c3d5cb05d
LLVM GN Syncbot [Tue, 27 Oct 2020 18:08:19 +0000 (18:08 +0000)]
[gn build] Port 46c3d5cb05d

3 years ago[amdgpu] Add the late codegen preparation pass.
Michael Liao [Fri, 22 May 2020 19:52:26 +0000 (15:52 -0400)]
[amdgpu] Add the late codegen preparation pass.

Summary:
- Teach that pass to widen naturally aligned but not DWORD aligned
  sub-DWORD loads.

Reviewers: rampitec, arsenm

Subscribers:

Tags: #llvm

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

3 years ago[X86] Regenerate scalar fptosi/fptoui tests. NFCI.
Simon Pilgrim [Tue, 27 Oct 2020 17:43:16 +0000 (17:43 +0000)]
[X86] Regenerate scalar fptosi/fptoui tests. NFCI.

Merge prefixes where possible, use 'X86' instead of 'X32' (which we try to only use for gnux32 triple tests).

3 years ago[libc++] Get rid of iostreams in the to_string tests
Louis Dionne [Tue, 27 Oct 2020 17:31:21 +0000 (13:31 -0400)]
[libc++] Get rid of iostreams in the to_string tests

3 years ago[VE] Add vector reduction instructions
Kazushi (Jam) Marukawa [Tue, 27 Oct 2020 12:03:17 +0000 (21:03 +0900)]
[VE] Add vector reduction instructions

Add VSUMS/VSUMX/VFSUM/VMAXS/VMAXX/VFMAX/VRAND/VROR/VRXOR isntructions.
Add regression tests too.

Reviewed By: simoll

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

3 years ago[Utils] Skip RemoveRedundantDbgInstrs in MergeBlockIntoPredecessor (PR47746)
Vedant Kumar [Tue, 6 Oct 2020 21:18:20 +0000 (14:18 -0700)]
[Utils] Skip RemoveRedundantDbgInstrs in MergeBlockIntoPredecessor (PR47746)

This patch changes MergeBlockIntoPredecessor to skip the call to
RemoveRedundantDbgInstrs, in effect partially reverting D71480 due to
some compile-time issues spotted in LoopUnroll and SimplifyCFG.

The call to RemoveRedundantDbgInstrs appears to have changed the
worst-case behavior of the merging utility. Loosely speaking, it seems
to have gone from O(#phis) to O(#insts).

It might not be possible to mitigate this by scanning a block to
determine whether there are any debug intrinsics to remove, since such a
scan costs O(#insts).

So: skip the call to RemoveRedundantDbgInstrs. There's surprisingly
little fallout from this, and most of it can be addressed by doing
RemoveRedundantDbgInstrs later. The exception is (the block-local
version of) SimplifyCFG, where it might just be too expensive to call
RemoveRedundantDbgInstrs.

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

3 years ago[ADT] Fix accidental pointer comparison in test
Sam McCall [Tue, 27 Oct 2020 17:11:45 +0000 (18:11 +0100)]
[ADT] Fix accidental pointer comparison in test

3 years ago[X86] Regenerate xor tests. NFCI.
Simon Pilgrim [Tue, 27 Oct 2020 16:06:19 +0000 (16:06 +0000)]
[X86] Regenerate xor tests. NFCI.

Merge prefixes where possible, use 'X86' instead of 'X32' (which we try to only use for gnux32 triple tests).

3 years ago[X86] Regenerate tbm intrinsics tests. NFCI.
Simon Pilgrim [Tue, 27 Oct 2020 15:25:50 +0000 (15:25 +0000)]
[X86] Regenerate tbm intrinsics tests. NFCI.

Merge prefixes where possible, use 'X86' instead of 'X32' (which we try to only use for gnux32 triple tests).

3 years ago[X86] Regenerate popcnt tests. NFCI.
Simon Pilgrim [Tue, 27 Oct 2020 14:40:52 +0000 (14:40 +0000)]
[X86] Regenerate popcnt tests. NFCI.

Merge prefixes where possible, use 'X86' instead of 'X32' (which we try to only use for gnux32 triple tests).

3 years ago[X86] Regenerate xop tests with common prefixes.
Simon Pilgrim [Tue, 27 Oct 2020 14:37:42 +0000 (14:37 +0000)]
[X86] Regenerate xop tests with common prefixes.

3 years ago[Flang][OpenMP 4.5] Add semantic check for OpenMP default clause
Yashaswini Hegde [Tue, 27 Oct 2020 16:23:52 +0000 (12:23 -0400)]
[Flang][OpenMP 4.5] Add semantic check for OpenMP default clause

3 years ago[libc++] Remove references to CONDUIT_TOKEN
Louis Dionne [Tue, 27 Oct 2020 16:24:57 +0000 (12:24 -0400)]
[libc++] Remove references to CONDUIT_TOKEN

It's not required anymore, since we rely on another job to report
the results back to Phabricator.