platform/upstream/llvm.git
4 years agoWrite ignored output to stdout, so this test runs on read-only filesystems.
Sterling Augustine [Wed, 15 Apr 2020 17:42:52 +0000 (10:42 -0700)]
Write ignored output to stdout, so this test runs on read-only filesystems.

4 years agoTry to fix clang-tidy/infrastructure/config-files.cpp on Win after cb1ee34e9d32fc.
Nico Weber [Wed, 15 Apr 2020 17:37:22 +0000 (13:37 -0400)]
Try to fix clang-tidy/infrastructure/config-files.cpp on Win after cb1ee34e9d32fc.

See also r267736.

4 years ago[GlobalISel] Enable artifact combiner to combine starting from a G_MERGE_VALUES.
Amara Emerson [Sat, 11 Apr 2020 05:39:49 +0000 (22:39 -0700)]
[GlobalISel] Enable artifact combiner to combine starting from a G_MERGE_VALUES.

We generally only combine starting from users to defs in the artifact combiner,
but this doesn't catch cases where at the point of combining a G_UNMERGE we don't
yet have the opposite G_MERGE on input yet since we haven't legalized that far.

This change adds the users of a G_MERGE to the artifact combiner worklist if one
of the uses is a G_UNMERGE or G_TRUNC.

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

4 years ago[CallSite removal][PruneEH] Use CallBase instead of CallSite. NFC
Craig Topper [Wed, 15 Apr 2020 05:04:35 +0000 (22:04 -0700)]
[CallSite removal][PruneEH] Use CallBase instead of CallSite. NFC

Reviewers: mtrofin, dblaikie

Subscribers: hiraditya, llvm-commits

Tags: #llvm

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

4 years ago[libc++] Remove the need for the %{build_module} substitution
Louis Dionne [Wed, 15 Apr 2020 16:58:00 +0000 (12:58 -0400)]
[libc++] Remove the need for the %{build_module} substitution

Instead of using .sh.cpp tests for the modules tests, use .compile.pass.cpp
and add the -fmodules additional flag.

4 years agoRevert "[GlobalISel] Fix invalid combine of unmerge(merge) with intermediate cast"
Dominik Montada [Wed, 15 Apr 2020 16:47:39 +0000 (18:47 +0200)]
Revert "[GlobalISel] Fix invalid combine of unmerge(merge) with intermediate cast"

This reverts commit bddac41b9f1ae80b56dace7d55cd81a07147ff3d.

4 years ago[libc++] NFC: Remove the %{compile} substitution, which is not used anymore
Louis Dionne [Wed, 15 Apr 2020 16:26:55 +0000 (12:26 -0400)]
[libc++] NFC: Remove the %{compile} substitution, which is not used anymore

4 years ago[libc++] Split up tests for <stdint.h> on AIX and make them AIX-independent
Louis Dionne [Wed, 15 Apr 2020 16:23:11 +0000 (12:23 -0400)]
[libc++] Split up tests for <stdint.h> on AIX and make them AIX-independent

Avoid using <sys/types.h> in those tests so that we can run them on
non-AIX systems (otherwise this test is basically dead-code on all
the build bots I'm aware of). Also, split up the test to allow using
.compile.pass.cpp tests instead of .sh.cpp tests, since that is the
last test referencing the %{compile} substitution explicitly.

4 years ago[mlir] [EDSC] Add interface for yield-for loops.
Pierre Oechsel [Wed, 15 Apr 2020 16:31:22 +0000 (18:31 +0200)]
[mlir] [EDSC] Add interface for yield-for loops.

Summary:
ModelBuilder was missing an api to easily generate yield-for-loops.
This diffs implements an interface allowing to write:
```
%2:2 = loop.for %i = %start to %end step %step iter_args(%arg0 = %init0, %arg1 = %init1) -> (f32, f32) {
  %sum = addf %arg0, %arg1 : f32
  loop.yield %arg1, %sum : f32, f32
}
%3 = addf %2#0, %2#1 : f32
```

as

```
auto results =
    LoopNestBuilder(&i, start, end, step, {&arg0, &arg1},  {init0, init1})([&] {
      auto sum = arg0 + arg1;
      loop_yield(ArrayRef<ValueHandle>{arg1, sum});
    });

// Add the two values accumulated by the yield-for-loop:
ValueHandle(results[0]) + ValueHandle(results[1]);
```

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

4 years ago[libc++] Move some .sh.cpp tests to .compile.pass.cpp
Louis Dionne [Wed, 15 Apr 2020 16:08:05 +0000 (12:08 -0400)]
[libc++] Move some .sh.cpp tests to .compile.pass.cpp

As a fly-by fix, improve/fix the comments explaining the tests. This is
a step towards removing references to the %{compile} substitution.

4 years ago[libc++] Move aligned allocation tests to .verify.cpp
Louis Dionne [Wed, 15 Apr 2020 16:00:52 +0000 (12:00 -0400)]
[libc++] Move aligned allocation tests to .verify.cpp

Instead of being ShTests that use clang-verify (and without the proper
REQUIRES annotation), create .verify.cpp tests instead with the right
REQUIRES annotation.

4 years agoRemove a function that has been dead since r313889.
Nico Weber [Wed, 15 Apr 2020 16:01:58 +0000 (12:01 -0400)]
Remove a function that has been dead since r313889.

4 years ago[ASTImporter] Add support for importing fixed point literals
Vince Bridgers [Mon, 6 Apr 2020 13:22:35 +0000 (08:22 -0500)]
[ASTImporter] Add support for importing fixed point literals

Summary:
This patch adds support for importing fixed point literals, following
up to https://reviews.llvm.org/D46915 specifically for importing AST.

Reviewers: martong, leonardchan, ebevhan, a.sidorin, shafik

Reviewed By: martong

Subscribers: balazske, rnkovacs, teemperor, cfe-commits

Tags: #clang

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

4 years ago[GlobalISel] Fix invalid combine of unmerge(merge) with intermediate cast
Dominik Montada [Wed, 15 Apr 2020 08:06:13 +0000 (10:06 +0200)]
[GlobalISel] Fix invalid combine of unmerge(merge) with intermediate cast

Summary:
The combine for unmerge(cast(merge)) is only valid for vectors, but was
missing a corresponding check. Add a check that the operands are vectors
to avoid an invalid combine.

Without this check, the combiner would emit incorrect code for scalars
and pointers because the artifact cast (trunc/ext) only affects bits at
the end of the type, while this combine assumes that the casted bits
appear between meaningful bits.

This also uncovered a segmentation fault in the AMDGPU
InstructionSelector. The tests triggering this bug have been moved to
their own file and a check for the segmentation fault has been added.

Reviewers: arsenm, dsanders, aemerson, paquette, aditya_nandakumar

Reviewed By: arsenm

Subscribers: tpr, jvesely, wdng, nhaehnle, rovka, kerbowa, llvm-commits

Tags: #llvm

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

4 years ago[TimeProfiler] Fix some style issues. NFC
Fangrui Song [Tue, 14 Apr 2020 20:42:00 +0000 (13:42 -0700)]
[TimeProfiler] Fix some style issues. NFC

Reviewed By: broadwaylamb, russell.gallop

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

4 years ago[ELF] Refactor the way we handle -plugin-opt= (GCC collect2 or clang LTO related...
Fangrui Song [Tue, 14 Apr 2020 21:17:29 +0000 (14:17 -0700)]
[ELF] Refactor the way we handle -plugin-opt= (GCC collect2 or clang LTO related options)

GCC collect2 passes several options to the linker even if LTO is not used
(note, lld does not support GCC LTO). The lto-wrapper may be a relative
path (especially during development, when gcc is in a build directory), e.g.

  -plugin-opt=relative/path/to/lto-wrapper

We need to ignore such options, which are currently interpreted by
cl::ParseCommandLineOptions() and will fail with `error: --plugin-opt: ld.lld: Unknown command line argument 'relative/path/to/lto-wrapper'`
because the path is apparently not an option registered by an `llvm::cl::opt`.

See lto-plugin-ignore.s for how we interpret various -plugin-opt= options now.

Reviewed By: grimar, tejohnson

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

4 years ago[libc++] Remove workaround for .fail.cpp tests that don't have clang-verify markup
Louis Dionne [Tue, 14 Apr 2020 17:00:53 +0000 (13:00 -0400)]
[libc++] Remove workaround for .fail.cpp tests that don't have clang-verify markup

By renaming .fail.cpp tests that don't need clang-verify to .compile.fail.cpp,
the new test format will not try to compile these tests with clang-verify,
and the old test format will work just the same. However, this allows
removing a workaround that requires parsing each test looking for
clang-verify markup.

After this change, a .fail.cpp test should always have clang-verify markup.
When clang-verify is not supported by the compiler, we will just check that
these tests fail to compile. When clang-verify is supported, these tests
will be compiled with clang-verify whether they have markup or not (so
they should have markup, or they will fail).

This simplifies the test suite and also ensures that all of our .fail.cpp
tests provide clang-verify markup. If it's impossible for a test to have
clang-verify markup, it can be moved to a .compile.fail.cpp test, which
are unconditionally just checked for compilation failure.

4 years ago[GlobalISel] translate freeze to new generic G_FREEZE
Dominik Montada [Thu, 9 Apr 2020 12:33:59 +0000 (14:33 +0200)]
[GlobalISel] translate freeze to new generic G_FREEZE

Summary:
As a follow up to https://reviews.llvm.org/D29014, add translation
support for freeze.

Introduce a new generic instruction G_FREEZE and translate freeze to it.

Reviewers: dsanders, aqjune, arsenm, aditya_nandakumar, t.p.northover, lebedev.ri, paquette, aemerson

Reviewed By: aqjune, arsenm

Subscribers: fhahn, lebedev.ri, wdng, rovka, hiraditya, jfb, volkan, llvm-commits

Tags: #llvm

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

4 years ago[www] Update make_cxx_dr_status for v10; regenerate cxx_dr_status.html
Hubert Tong [Wed, 15 Apr 2020 14:33:35 +0000 (10:33 -0400)]
[www] Update make_cxx_dr_status for v10; regenerate cxx_dr_status.html

Summary: Update `latest_release` to reflect the release of Clang 10.

Reviewed By: rsmith

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

4 years ago[DSE,MSSA] Add use of alloca, to guard against removal in the future.
Florian Hahn [Wed, 15 Apr 2020 14:21:30 +0000 (15:21 +0100)]
[DSE,MSSA] Add use of alloca, to guard against removal in the future.

Currently the alloca does not escape and all stores and the memset can
be removed. Adding a use of the alloca ensures not all stores are
eliminated.

4 years ago[AST] Fix recovery-expr crash on invalid aligned attr.
Haojian Wu [Sun, 12 Apr 2020 21:06:00 +0000 (23:06 +0200)]
[AST] Fix recovery-expr crash on invalid aligned attr.

Summary:
crash stack:

```
lang: tools/clang/include/clang/AST/AttrImpl.inc:1490: unsigned int clang::AlignedAttr::getAlignment(clang::ASTContext &) const: Assertion `!isAlignmentDependent()' failed.
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.      Program arguments: ./bin/clang -cc1 -std=c++1y -ast-dump -frecovery-ast -fcxx-exceptions /tmp/t4.cpp
1.      /tmp/t4.cpp:3:31: current parser token ';'
 #0 0x0000000002530cff llvm::sys::PrintStackTrace(llvm::raw_ostream&) llvm-project/llvm/lib/Support/Unix/Signals.inc:564:13
 #1 0x000000000252ee30 llvm::sys::RunSignalHandlers() llvm-project/llvm/lib/Support/Signals.cpp:69:18
 #2 0x000000000253126c SignalHandler(int) llvm-project/llvm/lib/Support/Unix/Signals.inc:396:3
 #3 0x00007f86964d0520 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x13520)
 #4 0x00007f8695f9ff61 raise /build/glibc-oCLvUT/glibc-2.29/signal/../sysdeps/unix/sysv/linux/raise.c:51:1
 #5 0x00007f8695f8b535 abort /build/glibc-oCLvUT/glibc-2.29/stdlib/abort.c:81:7
 #6 0x00007f8695f8b40f _nl_load_domain /build/glibc-oCLvUT/glibc-2.29/intl/loadmsgcat.c:1177:9
 #7 0x00007f8695f98b92 (/lib/x86_64-linux-gnu/libc.so.6+0x32b92)
 #8 0x0000000004503d9f llvm::APInt::getZExtValue() const llvm-project/llvm/include/llvm/ADT/APInt.h:1623:5
 #9 0x0000000004503d9f clang::AlignedAttr::getAlignment(clang::ASTContext&) const llvm-project/build/tools/clang/include/clang/AST/AttrImpl.inc:1492:0
```

Reviewers: sammccall

Subscribers: cfe-commits

Tags: #clang

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

4 years ago[XCOFF][AIX] Relocation support for SymB
jasonliu [Wed, 15 Apr 2020 14:00:34 +0000 (14:00 +0000)]
[XCOFF][AIX] Relocation support for SymB

This patch intends to provide relocation support for the expression
 contains two unpaired relocatable terms with opposite signs.

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

4 years ago[demangler] PPC and S390: Fix parsing of e-prefixed long double literals
Xing Xue [Wed, 15 Apr 2020 13:59:06 +0000 (09:59 -0400)]
[demangler] PPC and S390: Fix parsing of e-prefixed long double literals

Summary:
This patch is to fix the parsing of long double literals encoded with the e prefix on PowerPC and S390. For both PowerPC and S390, type code e is used for 64-bit long double literals and g is used for 128-bit long double literals. libcxxabi test case test_demangle.pass.cpp fails without the fix.

Authored by: xingxue-ibm

Reviewers: hubert.reinterpretcast, jasonliu, erik.pilkington, uweigand, mclow.li
sts, libc++abi

Reviewed by: hubert.reinterpretcast, erik.pilkington

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

4 years ago[FileCheck] - Refine the comment. NFC.
Georgii Rymar [Wed, 15 Apr 2020 13:55:48 +0000 (16:55 +0300)]
[FileCheck] - Refine the comment. NFC.

It did not mention the `--implicit-check-not` before,
though it should (https://reviews.llvm.org/D78024#inline-715166).

4 years agoUnbreak the build
Benjamin Kramer [Wed, 15 Apr 2020 13:54:47 +0000 (15:54 +0200)]
Unbreak the build

4 years agoPass shufflevector indices as int instead of unsigned.
Benjamin Kramer [Wed, 15 Apr 2020 13:52:26 +0000 (15:52 +0200)]
Pass shufflevector indices as int instead of unsigned.

No functionality change intended.

4 years ago[clang-tidy] Optional inheritance of file configs from parent directories 
Dmitry Polukhin [Wed, 1 Apr 2020 09:08:53 +0000 (02:08 -0700)]
[clang-tidy] Optional inheritance of file configs from parent directories 

Summary:
Without this patch clang-tidy stops finding file configs on the nearest
.clang-tidy file. In some cases it is not very convenient because it
results in common parts duplication into every child .clang-tidy file.
This diff adds optional config inheritance from the parent directories
config files.

Test Plan:

Added test cases in existing config test.

Reviewers: alexfh, gribozavr2, klimek, hokein

Subscribers: njames93, arphaman, xazax.hun, aheejin, cfe-commits

Tags: #clang, #clang-tools-extra

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

4 years ago[CodeGen][ARM] Error when writing to specific reserved registers in inline asm
Victor Campos [Wed, 25 Mar 2020 10:52:43 +0000 (10:52 +0000)]
[CodeGen][ARM] Error when writing to specific reserved registers in inline asm

Summary:
No error or warning is emitted when specific reserved registers are
written to in inline assembly. Therefore, writes to the program counter
or to the frame pointer, for instance, were permitted, which could have
led to undesirable behaviour.

Example:
  int foo() {
    register int a __asm__("r7"); // r7 = frame-pointer in M-class ARM
    __asm__ __volatile__("mov %0, r1" : "=r"(a) : : );
    return a;
  }

In contrast, GCC issues an error in the same scenario.

This patch detects writes to specific reserved registers in inline
assembly for ARM and emits an error in such case. The detection works
for output and input operands. Clobber operands are not handled here:
they are already covered at a later point in
AsmPrinter::emitInlineAsm(const MachineInstr *MI). The registers
covered are: program counter, frame pointer and base pointer.

This is ARM only. Therefore the implementation of other targets'
counterparts remain open to do.

Reviewers: efriedma

Reviewed By: efriedma

Subscribers: kristof.beyls, hiraditya, danielkiss, llvm-commits

Tags: #llvm

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

4 years ago[InstCombine] prevent infinite loop with sub/abs of constant expression
Sanjay Patel [Wed, 15 Apr 2020 13:11:44 +0000 (09:11 -0400)]
[InstCombine] prevent infinite loop with sub/abs of constant expression

PR45539:
https://bugs.llvm.org/show_bug.cgi?id=45539

4 years agoclang/AMDGPU: Assume denormals are enabled for the default target.
Matt Arsenault [Mon, 13 Apr 2020 13:15:48 +0000 (09:15 -0400)]
clang/AMDGPU: Assume denormals are enabled for the default target.

Since the default logic was based on having fast denormal/fma
features, and the default target has no features, we assumed flushing
by default. This fixes incorrectly assuming flushing in builds for
"generic" IR libraries.

The handling for no specified --cuda-gpu-arch in HIP is kind of
broken. Somewhere else forces a default target of gfx803, which does
not enable denormal handling by default. We don't see this default
switching here, so you'll end up with a different denormal mode
depending on whether you explicitly requested gfx803, or used it by
default.

4 years agoRevert "[nfc] [lldb] Introduce DWARF callbacks"
Jan Kratochvil [Wed, 15 Apr 2020 13:12:59 +0000 (15:12 +0200)]
Revert "[nfc] [lldb] Introduce DWARF callbacks"

This reverts commit bd47c470d13b1c57ecf37c1faf0324833d3a4542.

It broke Green Dragon, reason is unknown to me so far:
  http://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/15323/consoleFull

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

4 years agoAMDGPU/GlobalISel: Add some artifact combiner tests
Matt Arsenault [Wed, 15 Apr 2020 13:02:07 +0000 (09:02 -0400)]
AMDGPU/GlobalISel: Add some artifact combiner tests

4 years ago[FileCheck] Better diagnostic for format conflict
Thomas Preud'homme [Sat, 4 Apr 2020 00:02:45 +0000 (01:02 +0100)]
[FileCheck] Better diagnostic for format conflict

Summary:
Improve error message in case of conflict between several implicit
format to mention the operand that conflict.

Reviewers: jhenderson, jdenny, probinson, grimar, arichardson, rnk

Reviewed By: jdenny

Subscribers: hiraditya, llvm-commits

Tags: #llvm

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

4 years ago[nfc] clang-format TargetTransformInfo.cpp
Simon Moll [Wed, 15 Apr 2020 12:43:26 +0000 (14:43 +0200)]
[nfc] clang-format TargetTransformInfo.cpp

4 years agoUpgrade users of 'new ShuffleVectorInst' to pass indices as an int array
Benjamin Kramer [Wed, 15 Apr 2020 12:29:09 +0000 (14:29 +0200)]
Upgrade users of 'new ShuffleVectorInst' to pass indices as an int array

No functionality change intended.

4 years ago[flang] Add return statement to Logical opeator=.
David Truby [Wed, 15 Apr 2020 11:55:42 +0000 (12:55 +0100)]
[flang] Add return statement to Logical opeator=.

This removes the current undefined behavior where the function has a return type
but no return statement.

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

4 years ago[nfc] clang-format TargetTransformInfoImpl.h
Simon Moll [Wed, 15 Apr 2020 12:01:31 +0000 (14:01 +0200)]
[nfc] clang-format TargetTransformInfoImpl.h

4 years ago[nfc] clang-format TargetTransformInfo.h
Simon Moll [Wed, 15 Apr 2020 12:00:07 +0000 (14:00 +0200)]
[nfc] clang-format TargetTransformInfo.h

4 years ago[Statepoint] Add getters to StatepointOpers.
Denis Antrushin [Tue, 14 Apr 2020 15:30:51 +0000 (18:30 +0300)]
[Statepoint] Add getters to StatepointOpers.

To simplify future work on statepoint representation, hide
direct access to statepoint field indices and provide getters
for them. Add getters for couple more statepoint fields.

This also fixes two bugs in MachineVerifier for statepoint:
First, the `break` statement was falling out of `if` statement
scope, thus disabling following checks.
Second, it was incorrectly accessing some fields like CallingConv -
StatepointOpers gives index to their value directly, not to
preceeding field type encoding.

Reviewed By: skatkov
Differential Revision: https://reviews.llvm.org/D78119

4 years ago[dexp] NFC: Change positional argument format
Kirill Bobyrev [Wed, 15 Apr 2020 11:27:30 +0000 (13:27 +0200)]
[dexp] NFC: Change positional argument format

Summary:
Before:

  USAGE: dexp [options] --index-path Path to the index

After:

  USAGE: dexp [options] <INDEX FILE>

Reviewers: sammccall

Reviewed By: sammccall

Subscribers: jkorous, arphaman, kadircet, usaxena95, cfe-commits

Tags: #clang

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

4 years ago[VPlan] Branches are not widened by VPWidenRecipe, assert (NFC).
Florian Hahn [Tue, 14 Apr 2020 08:36:16 +0000 (09:36 +0100)]
[VPlan] Branches are not widened by VPWidenRecipe, assert (NFC).

4 years ago[SystemZ] Bugfix in adjustSubwordCmp()
Jonas Paulsson [Wed, 15 Apr 2020 09:29:55 +0000 (11:29 +0200)]
[SystemZ] Bugfix in adjustSubwordCmp()

adjustSubwordCmp() should not optimize a load of an i1 value. This is
achieved by checking that the size and store-size of the MemoryVT are the
same.

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

Review: Ulrich Weigand

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

4 years ago[CostModel][X86] Regenerate load_store.ll costs tests
Simon Pilgrim [Wed, 15 Apr 2020 10:54:22 +0000 (11:54 +0100)]
[CostModel][X86] Regenerate load_store.ll costs tests
Add SSE + AVX512 targets
Add some illegal type store tests

4 years agoUpgrade calls to CreateShuffleVector to use the preferred form of passing an array...
Benjamin Kramer [Wed, 15 Apr 2020 10:41:54 +0000 (12:41 +0200)]
Upgrade calls to CreateShuffleVector to use the preferred form of passing an array of ints

No functionality change intended.

4 years ago[VPlan] Move widening check for non-memory/non-calls to function (NFC).
Florian Hahn [Wed, 15 Apr 2020 10:41:13 +0000 (11:41 +0100)]
[VPlan] Move widening check for non-memory/non-calls to function (NFC).

After introducing VPWidenSelectRecipe, the duplicated logic can be
shared.

Reviewers: gilr, rengolin, Ayal, hsaito

Reviewed By: Ayal

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

4 years ago[lldb] Fix -Wparentheses in ThreadPlanStack.cpp
Pavel Labath [Wed, 15 Apr 2020 10:40:12 +0000 (12:40 +0200)]
[lldb] Fix -Wparentheses in ThreadPlanStack.cpp

4 years agoFix DWARFDataExtractor::getRelocatedValue near EOF
Pavel Labath [Tue, 14 Apr 2020 15:06:04 +0000 (17:06 +0200)]
Fix DWARFDataExtractor::getRelocatedValue near EOF

Summary:
If we have an (invalid) relocation which relocates bytes which partially
lie outside the range of the relocated section, the getRelocatedValue
would return confusing results. It would first read zero (because that's
what the underlying DataExtractor api does for out-of-bounds reads), and
then relocate that zero anyway.

A more appropriate behavior is to return zero straight away. This is
what this patch does.

Reviewers: dblaikie, jhenderson

Subscribers: hiraditya, llvm-commits

Tags: #llvm

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

4 years ago[DSE] Lift post-dominance for objs not accessible in caller.
Florian Hahn [Wed, 15 Apr 2020 09:42:58 +0000 (10:42 +0100)]
[DSE] Lift post-dominance for objs not accessible in caller.

We can eliminate MemoryDefs of objects not accessible after the function
returns (e.g. alloca), if there are no reads between the MemoryDef and
any function exits. We can stop traversing paths that completely
overwrite the memory location of the MemoryDef.

This patch was split off D73763.

Reviewers: dmgreen, bryant, asbirlea, Tyker, efriedma, george.burgess.iv

Reviewed By: asbirlea, george.burgess.iv

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

4 years ago[ARM][MVE] Tail predicate VML[A|S]LDAV
Sam Parker [Thu, 9 Apr 2020 06:51:33 +0000 (07:51 +0100)]
[ARM][MVE] Tail predicate VML[A|S]LDAV

Make the non-exchanging versions of the multiply add/sub instructions
validForTailPredication.

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

4 years agofix warning: specialization of template in different namespace
Sameer Sahasrabuddhe [Wed, 15 Apr 2020 10:25:04 +0000 (15:55 +0530)]
fix warning: specialization of template in different namespace

This is related to commit 8c11bc0cd06ffc18786a1a51ee5ce5b1cc4923f6
which introduces the FixIrreducible pass. The warning seems hard to
reproduce locally. The latest attempt ought to work.

4 years ago[ConstExprPreter] Updated constant interpreter documentation
Nandor Licker [Thu, 9 Apr 2020 18:13:38 +0000 (19:13 +0100)]
[ConstExprPreter] Updated constant interpreter documentation

Summary:
Updated the documentation to better reflect features implemented on the
constexpr branch at https://github.com/nandor/llvm-project and extended
the TODO list with known missing features

Reviewers: rsmith, Bigcheese, dexonsmith, jfb

Subscribers: lebedev.ri, cfe-commits

Tags: #clang

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

4 years ago[LLVM/tools][test] - Remove/fix dead check prefixes.
Georgii Rymar [Tue, 14 Apr 2020 15:04:48 +0000 (18:04 +0300)]
[LLVM/tools][test] - Remove/fix dead check prefixes.

We have a few unused/broken FileCheck prefixes in `llvm/test/tools`.
This patch fixes it.

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

4 years ago[NFC] clang-format IntrinsicInst.h|cpp
Simon Moll [Wed, 15 Apr 2020 10:05:07 +0000 (12:05 +0200)]
[NFC] clang-format IntrinsicInst.h|cpp

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

4 years ago[gn build] Port 8c11bc0cd06
LLVM GN Syncbot [Wed, 15 Apr 2020 09:38:24 +0000 (09:38 +0000)]
[gn build] Port 8c11bc0cd06

4 years agoIntroduce fix-irreducible pass
Sameer Sahasrabuddhe [Wed, 15 Apr 2020 09:35:51 +0000 (15:05 +0530)]
Introduce fix-irreducible pass

An irreducible SCC is one which has multiple "header" blocks, i.e., blocks
with control-flow edges incident from outside the SCC. This pass converts an
irreducible SCC into a natural loop by introducing a single new header
block and redirecting all the edges on the original headers to this
new block.

This is a useful workaround for a limitation in the structurizer
which, which produces incorrect control flow in the presence of
irreducible regions. The AMDGPU backend provides an option to
enable this pass before the structurizer, which may eventually be
enabled by default.

Reviewed By: nhaehnle

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

This restores commit 2ada8e2525dd2653f30c8696a27162a3b1647d66.

Originally reverted with commit 44e09b59b869a91bf47d76e8bc569d9ee91ad145.

4 years ago[VPlan] Move Load/Store checks out of tryToWiden (NFC).
Florian Hahn [Wed, 15 Apr 2020 09:18:31 +0000 (10:18 +0100)]
[VPlan] Move Load/Store checks out of tryToWiden (NFC).

Handling LoadInst and StoreInst in tryToWiden seems a bit
counter-intuitive, as there is only an assertion for them and in no
case VPWidenRefipes are created for them.

I think it makes sense to move the assertion to handleReplication, where
the non-widened loads and store are handled.

Reviewers: gilr, rengolin, Ayal, hsaito

Reviewed By: Ayal

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

4 years ago[mlir] LLVM dialect: support globals without linkage keyword, assuming 'external'
Alex Zinenko [Tue, 14 Apr 2020 11:01:53 +0000 (13:01 +0200)]
[mlir] LLVM dialect: support globals without linkage keyword, assuming 'external'

Similarly to actual LLVM IR, and to `llvm.mlir.func`, allow the custom syntax
of `llvm.mlir.global` to omit the linkage keyword. If omitted, the linkage is
assumed to be external. This makes the modeling of globals in the LLVM dialect
more consistent, both within the dialect and with LLVM IR.

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

4 years ago[MLIR] Introduce applyOpPatternsAndFold for op local rewrites
Uday Bondhugula [Sun, 5 Apr 2020 02:40:33 +0000 (08:10 +0530)]
[MLIR] Introduce applyOpPatternsAndFold for op local rewrites

Introduce mlir::applyOpPatternsAndFold which applies patterns as well as
any folding only on a specified op (in contrast to
applyPatternsAndFoldGreedily which applies patterns only on the regions
of an op isolated from above).  The caller is made aware of the op being
folded away or erased.

Depends on D77485.

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

4 years ago[nfc] [lldb] Introduce DWARF callbacks
Jan Kratochvil [Wed, 15 Apr 2020 08:36:31 +0000 (10:36 +0200)]
[nfc] [lldb] Introduce DWARF callbacks

As requested by @labath in https://reviews.llvm.org/D73206#1949516
providing DWARF index callbacks refactorization.

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

4 years ago[NFC][test] Mark the section which contains instructions executable
Shengchen Kan [Wed, 15 Apr 2020 08:18:11 +0000 (16:18 +0800)]
[NFC][test] Mark the section which contains instructions executable

As we disscussed in D77971, we haven't confirmed that if putting instructions
in a non-executable section is an undefined behaviour. To make things
easier to go on, we mark these sections executable in test file
align-branch-section-size.s.

4 years ago[VE] Update integer arithmetic instructions
Kazushi (Jam) Marukawa [Wed, 15 Apr 2020 07:47:14 +0000 (09:47 +0200)]
[VE] Update integer arithmetic instructions

Summary:
Changing all mnemonic to match assembly instructions to simplify mnemonic
naming rules.  This time update all fixed-point arithmetic instructions.
This also corrects smax/smin code generations.

Reviewed By: simoll

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

4 years ago[lldb][NFC] Remove FormatterChoiceCriterion
Raphael Isemann [Wed, 15 Apr 2020 05:34:14 +0000 (07:34 +0200)]
[lldb][NFC] Remove FormatterChoiceCriterion

Summary:
The formatters code has a lot of 'reason' or 'why' values that we keep or-ing FormatterChoiceCriterion
enum values into. These values are only read by a single log statement and don't have any functional
purpose. It also seems the implementation is not finished (for example, display names and type
names don't have any dedicated enum values). Also everything is of course not tested or documented.

Let's just remove all of this.

Reviewers: labath, JDevlieghere, jingham, davide, vsk

Reviewed By: labath, vsk

Subscribers: JDevlieghere

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

4 years ago[LV] Fix PR45525: Incorrect assert in blend recipe
Gil Rapaport [Tue, 14 Apr 2020 14:20:41 +0000 (17:20 +0300)]
[LV] Fix PR45525: Incorrect assert in blend recipe

Fix an assert introduced in 41ed5d856c1: a phi with a single predecessor and a
mask is a valid case which is already supported by the code.

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

4 years ago[clangd] Fix MSVC compile error, attempt 2
Kadir Cetinkaya [Wed, 15 Apr 2020 07:33:12 +0000 (09:33 +0200)]
[clangd] Fix MSVC compile error, attempt 2

4 years ago[clangd] Fix MSVC builds
Kadir Cetinkaya [Wed, 15 Apr 2020 07:24:58 +0000 (09:24 +0200)]
[clangd] Fix MSVC builds

4 years ago[clangd] Shard preamble symbols in dynamic index
Kadir Cetinkaya [Wed, 8 Apr 2020 14:14:53 +0000 (16:14 +0200)]
[clangd] Shard preamble symbols in dynamic index

Summary:
This reduces memory usage by dynamic index from more than 400MB to 32MB
when all files in clang-tools-extra/clangd/*.cpp are active in clangd.

Reviewers: sammccall

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits

Tags: #clang

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

4 years agoDon't print `&` as part of reference template arguments.
Richard Smith [Wed, 15 Apr 2020 06:35:35 +0000 (23:35 -0700)]
Don't print `&` as part of reference template arguments.

In passing, also generalize the mechanism used to allow Decl's printName
functions to override qualified name printing.

4 years agoGeneralize our two different kinds of declaration argument for
Richard Smith [Wed, 15 Apr 2020 06:28:33 +0000 (23:28 -0700)]
Generalize our two different kinds of declaration argument for
attributes to support any kind of declaration.

In preparation for adding a third kind.

4 years ago[gn build] Port 44e09b59b86
LLVM GN Syncbot [Wed, 15 Apr 2020 06:53:11 +0000 (06:53 +0000)]
[gn build] Port 44e09b59b86

4 years agoRevert "Introduce fix-irreducible pass"
Sameer Sahasrabuddhe [Wed, 15 Apr 2020 06:47:11 +0000 (12:17 +0530)]
Revert "Introduce fix-irreducible pass"

This reverts commit 2ada8e2525dd2653f30c8696a27162a3b1647d66.

Buildbots produced compilation errors which I was not able to quickly
reproduce locally. Need more time to investigate.

4 years agoRemove setters from CXXTypeidExpr and CXXUuidofExpr.
Richard Smith [Wed, 15 Apr 2020 02:26:31 +0000 (19:26 -0700)]
Remove setters from CXXTypeidExpr and CXXUuidofExpr.

We generally prefer to have the ASTReader directly set fields rather
than including public setter functions.

4 years ago[gn build] Port 2ada8e2525d
LLVM GN Syncbot [Wed, 15 Apr 2020 06:01:21 +0000 (06:01 +0000)]
[gn build] Port 2ada8e2525d

4 years agoIntroduce fix-irreducible pass
Sameer Sahasrabuddhe [Wed, 15 Apr 2020 05:59:19 +0000 (11:29 +0530)]
Introduce fix-irreducible pass

An irreducible SCC is one which has multiple "header" blocks, i.e., blocks
with control-flow edges incident from outside the SCC. This pass converts an
irreducible SCC into a natural loop by introducing a single new header
block and redirecting all the edges on the original headers to this
new block.

This is a useful workaround for a limitation in the structurizer
which, which produces incorrect control flow in the presence of
irreducible regions. The AMDGPU backend provides an option to
enable this pass before the structurizer, which may eventually be
enabled by default.

Reviewed By: nhaehnle

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

4 years ago[clangd] Color dependent names based on their heuristic target if they have one
Nathan Ridge [Thu, 19 Mar 2020 19:42:10 +0000 (15:42 -0400)]
[clangd] Color dependent names based on their heuristic target if they have one

Summary: Fixes https://github.com/clangd/clangd/issues/297

Subscribers: ilya-biryukov, jkorous, arphaman, kadircet, usaxena95, cfe-commits

Tags: #clang

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

4 years ago[llvm][StringExtras] Add missing include of cctype
River Riddle [Wed, 15 Apr 2020 02:29:54 +0000 (19:29 -0700)]
[llvm][StringExtras] Add missing include of cctype

This fixes build breakages on windows.

4 years ago[NFC][DAGCombine] Change the value of NegatibleCost to make it align with the semantics
QingShan Zhang [Wed, 15 Apr 2020 02:17:36 +0000 (02:17 +0000)]
[NFC][DAGCombine] Change the value of NegatibleCost to make it align with the semantics

This is a minor NFC change to make the code more clear. We have the NegatibleCost that
has cheaper, neutral, and expensive. Typically, the smaller one means the less cost.
It is inverse for current implementation, which makes following code not easy to read.
If (CostX > CostY) negate(X)

Reviewed By: RKSimon

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

4 years agoAMDGPU/GlobalISel: Fix selection of scalar f64 G_FABS
Matt Arsenault [Tue, 7 Apr 2020 15:33:26 +0000 (11:33 -0400)]
AMDGPU/GlobalISel: Fix selection of scalar f64 G_FABS

This wasn't covered by existing tablegen patterns, but also suffers
the same issues as G_FNEG. Workaround them by manually selecting, like
G_FNEG.

4 years agoTableGen/GlobalISel: Fix constraining REG_SEQUENCE operands
Matt Arsenault [Tue, 7 Apr 2020 13:32:51 +0000 (09:32 -0400)]
TableGen/GlobalISel: Fix constraining REG_SEQUENCE operands

This was hitting the default instruction constraint code which uses
the register classes in the instruction def, which REG_SEQUENCE does
not have.

Fixes not constraining the register class for AMDGPU fneg/fabs
patterns, which would fail when the use was another generic,
unconstrained instruction.

Another oddity I noticed is that the temporary registers are created
with an unnecessary, but incorrect 16-bit LLT but this shouldn't
matter.

I'm also still unclear why root and sub-instructions have to be
handled differently.

4 years ago[llvm][StringExtras] Merge StringExtras from MLIR into LLVM
River Riddle [Wed, 15 Apr 2020 01:54:23 +0000 (18:54 -0700)]
[llvm][StringExtras] Merge StringExtras from MLIR into LLVM

Summary:
This revision adds two utilities currently present in MLIR to LLVM StringExtras:

* convertToSnakeFromCamelCase
Convert a string from a camel case naming scheme, to a snake case scheme

* convertToCamelFromSnakeCase
Convert a string from a snake case naming scheme, to a camel case scheme

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

4 years ago[MS] Fix packed struct layout for arrays of aligned non-record types
Reid Kleckner [Wed, 8 Apr 2020 21:05:54 +0000 (14:05 -0700)]
[MS] Fix packed struct layout for arrays of aligned non-record types

In particular, this affects Clang's vectors. Users encounter this issue
when a struct contains an __m128 type.

Fixes PR45420

Reviewed By: rjmccall

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

4 years agoAllow disabling of vectorization using internal options
Teresa Johnson [Mon, 13 Apr 2020 02:12:38 +0000 (19:12 -0700)]
Allow disabling of vectorization using internal options

Summary:
Currently, the internal options -vectorize-loops, -vectorize-slp, and
-interleave-loops do not have much practical effect. This is because
they are used to initialize the corresponding flags in the pass
managers, and those flags are then unconditionally overwritten when
compiling via clang or via LTO from the linkers. The only exception was
-vectorize-loops via opt because of some special hackery there.

While vectorization could still be disabled when compiling via clang,
using -fno-[slp-]vectorize, this meant that there was no way to disable
it when compiling in LTO mode via the linkers. This only affected
ThinLTO, since for regular LTO vectorization is done during the compile
step for scalability reasons. For ThinLTO it is invoked in the LTO
backends. See also the discussion on PR45434.

This patch makes it so the internal options can actually be used to
disable these optimizations. Ultimately, the best long term solution is
to mark the loops with metadata (similar to the approach used to fix
-fno-unroll-loops in D77058), but this enables a shorter term
workaround, and actually makes these internal options useful.

I constant propagated the initial values of these internal flags into
the pass manager flags (for some reasons vectorize-loops and
interleave-loops were initialized to true, while vectorize-slp was
initialized to false). As mentioned above, they are overwritten
unconditionally so this doesn't have any real impact, and these initial
values aren't particularly meaningful.

I then changed the passes to check the internl values and return without
performing the associated optimization when false (I changed the default
of -vectorize-slp to true so the options behave similarly). I was able
to remove the hackery in opt used to get -vectorize-loops=false to work,
as well as a special option there used to disable SLP vectorization.

Finally, I changed thinlto-slp-vectorize-pm.c to:
a) Only test SLP (moved the loop vectorization checking to a new test).
b) Use code that is slp vectorized when it is enabled, and check that
instead of whether the pass is enabled.
c) Test the new behavior of -vectorize-slp.
d) Test both pass managers.

The loop vectorization (and associated interleaving) testing I moved to
a new thinlto-loop-vectorize-pm.c test, with several changes:
a) Changed the flags on the interleaving testing so that it will
actually interleave, and check that.
b) Test the new behavior of -vectorize-loops and -interleave-loops.
c) Test both pass managers.

Reviewers: fhahn, wmi

Subscribers: hiraditya, steven_wu, dexonsmith, cfe-commits, davezarzycki, llvm-commits

Tags: #clang

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

4 years ago[test][NFC] Use plain FileCheck in statepoint-stackmap-size.ll
Hubert Tong [Wed, 15 Apr 2020 00:51:50 +0000 (20:51 -0400)]
[test][NFC] Use plain FileCheck in statepoint-stackmap-size.ll

Summary:
The test in question uses a non-portable `grep -A` option in conjunction
with `wc -l`. `FileCheck` can be used to do the check without using
these extra utilities.

Reviewed By: thakis

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

4 years ago[AMDGPU] Update DWARF proposal
Tony [Thu, 20 Feb 2020 07:08:59 +0000 (02:08 -0500)]
[AMDGPU] Update DWARF proposal

- Unify the sections on DWARF expression and location lists.

- Allow a location description to have one or more single location
  descriptions.

- Define context of DWARF expression that includes an initial
  stack. Allow initial stack to be used when evaluating location list
  expression with overlapping PC ranges.

- Reorganize the DWARF proposal in AMDGPUUsage so suitable for
  submission to the DWARF site.

- Replace CFI instruction DW_CFA_LLVM_def_cfa_aspace with
  DW_CFA_def_aspace_cfa and DW_CFA_def_aspace_cfa_sf. This is to avoid
  the problem that DW_CFA_def_cfa and DW_CFA_def_cfa_sf cannot use a
  register that is not the size of an address in the CFA address
  space.

- Clarify DWARF address class and DWARF address space. Define language
  values for DWARF address classes and specify how they are used by
  some common source languages.

- Define rules for accessing registers and derefencing memory when the
  type size and register size or byte size operand do not match.

- Numerous cleanups for consistency.

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

4 years agoBug where insn-based unwind plans on arm64 could be wrong
Jason Molenda [Tue, 14 Apr 2020 23:51:58 +0000 (16:51 -0700)]
Bug where insn-based unwind plans on arm64 could be wrong

Fix a bug where UnwindAssemblyInstEmulation would confuse which
register is used to compute the Canonical Frame Address after it
had branched over a mid-function epilogue (where the CFA reg changes
from $fp to $sp in the process of epiloguing).  Reinstate the
correct CFA register after we forward the unwind rule for branch
targets.  The failure mode was that UnwindAssemblyInstEmulation
would think CFA was set in terms of $sp after one of these epilogues,
and if it sees modifications to $sp after the branch target, it would
change the CFA offset in the unwind rule -- even though the CFA is
defined in terms of $fp and the $sp changes are irrelevant to correct
calculation.

<rdar://problem/60300528>

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

4 years ago[mlir] Fix assert on signed integer type in EDSC
Adam Straw [Tue, 14 Apr 2020 19:49:18 +0000 (22:49 +0300)]
[mlir] Fix assert on signed integer type in EDSC

Integer type in Std dialect is signless so we should be checking
for signless integer type instead of signed integer type in EDSC.

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

4 years agoInitiallize property getters as being property accessors (NFC)
Adrian Prantl [Tue, 14 Apr 2020 22:55:00 +0000 (15:55 -0700)]
Initiallize property getters as being property accessors (NFC)

This is a no-op because it is set later on unconditionally again, but
it's far less confusing this way and consistent with how the setters
are initialized.

4 years agollvm-dwarfdump: Don't try to parse a debug_loclist contribution if this CU has no...
David Blaikie [Tue, 14 Apr 2020 22:17:24 +0000 (15:17 -0700)]
llvm-dwarfdump: Don't try to parse a debug_loclist contribution if this CU has no DW_AT_loclists_base

llvm-dwarfdump was trying to parse debug_loclists even in the absence of
a loclists_base if there was a loclists section at all.

4 years ago[www] Turn 'Clang 10' boxes green in C++ status pages to reflect release
Hubert Tong [Tue, 14 Apr 2020 22:36:50 +0000 (18:36 -0400)]
[www] Turn 'Clang 10' boxes green in C++ status pages to reflect release

Summary:
The 'Clang 10' boxes should be green since Clang 10 has been released.

Reviewers: rsmith, aaron.ballman

Reviewed By: aaron.ballman

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

4 years ago[gn build] Port ebf190fcda0
LLVM GN Syncbot [Tue, 14 Apr 2020 22:33:30 +0000 (22:33 +0000)]
[gn build] Port ebf190fcda0

4 years ago[gn build] Port 8cbe371c28a
LLVM GN Syncbot [Tue, 14 Apr 2020 22:33:30 +0000 (22:33 +0000)]
[gn build] Port 8cbe371c28a

4 years ago[gn build] Port 204c3b55162
LLVM GN Syncbot [Tue, 14 Apr 2020 22:33:29 +0000 (22:33 +0000)]
[gn build] Port 204c3b55162

4 years ago[SelectionDAG] Always preserve offset in MachinePointerInfo
Eli Friedman [Tue, 7 Apr 2020 21:05:29 +0000 (14:05 -0700)]
[SelectionDAG] Always preserve offset in MachinePointerInfo

Previously, getWithOffset() would drop the offset if the base was null.
Because of this, MachineMemOperand would return the wrong result from
getAlign() in these cases.  MachineMemOperand stores the alignment of
the pointer without the offset.

A bunch of MIR tests changed because we print the offset now.

Split off from D77687.

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

4 years ago[llvm-objdump][Wasm][NFC] Create WasmDump.h
Hubert Tong [Tue, 14 Apr 2020 22:24:37 +0000 (18:24 -0400)]
[llvm-objdump][Wasm][NFC] Create WasmDump.h

Summary:
Continuing from D77285, the external interfaces implemented by
`WasmDump.cpp` are now declared in `WasmDump.h` and moved into the
`llvm::objdump` namespace.

Reviewers: jhenderson, MaskRay, DiggerLin, jasonliu, daltenty

Reviewed By: jhenderson, MaskRay

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

4 years ago[AVR] Define __ELF__
Ayke van Laethem [Tue, 14 Apr 2020 15:30:24 +0000 (17:30 +0200)]
[AVR] Define __ELF__

This symbol is defined in avr-gcc. Because AVR normally uses the ELF
format, define the symbol unconditionally.

This patch is needed to get Clang to compile compiler-rt.

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

4 years ago[mlir][NFC] Remove the STLExtras.h header file now that it has been merged into LLVM.
River Riddle [Tue, 14 Apr 2020 21:54:15 +0000 (14:54 -0700)]
[mlir][NFC] Remove the STLExtras.h header file now that it has been merged into LLVM.

Now that no more utilities exist within, this file can be deleted.

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

4 years ago[llvm][ADT] Move TypeSwitch class from MLIR to LLVM
River Riddle [Tue, 14 Apr 2020 21:53:50 +0000 (14:53 -0700)]
[llvm][ADT] Move TypeSwitch class from MLIR to LLVM

This class implements a switch-like dispatch statement for a value of 'T' using dyn_cast functionality. Each `Case<T>` takes a callable to be invoked if the root value isa<T>, the callable is invoked with the result of dyn_cast<T>() as a parameter.

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

4 years ago[llvm][STLExtras] Move the algorithm `interleave*` methods from MLIR to LLVM
River Riddle [Tue, 14 Apr 2020 21:53:28 +0000 (14:53 -0700)]
[llvm][STLExtras] Move the algorithm `interleave*` methods from MLIR to LLVM

These have proved incredibly useful for interleaving values between a range w.r.t to streams. After this revision, the mlir/Support/STLExtras.h is empty. A followup revision will remove it from the tree.

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

4 years ago[llvm][STLExtras] Move various iterator/range utilities from MLIR to LLVM
River Riddle [Tue, 14 Apr 2020 21:53:07 +0000 (14:53 -0700)]
[llvm][STLExtras] Move various iterator/range utilities from MLIR to LLVM

This revision moves the various range utilities present in MLIR to LLVM to enable greater reuse. This revision moves the following utilities:

* indexed_accessor_*
This is set of utility iterator/range base classes that allow for building a range class where the iterators are represented by an object+index pair.

* make_second_range
Given a range of pairs, returns a range iterating over the `second` elements.

* hasSingleElement
Returns if the given range has 1 element. size() == 1 checks end up being very common, but size() is not always O(1) (e.g., ilist). This method provides O(1) checks for those cases.

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

4 years ago[llvm][STLExtras] Add various type_trait utilities currently present in MLIR
River Riddle [Tue, 14 Apr 2020 21:52:52 +0000 (14:52 -0700)]
[llvm][STLExtras] Add various type_trait utilities currently present in MLIR

This revision moves several type_trait utilities from MLIR into LLVM. Namely, this revision adds:
is_detected - This matches the experimental std::is_detected
is_invocable - This matches the c++17 std::is_invocable
function_traits - A utility traits class for getting the argument and result types of a callable type

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

4 years ago[llvm][DenseMapInfo] Add an info specialization for std::tuple
River Riddle [Tue, 14 Apr 2020 21:52:42 +0000 (14:52 -0700)]
[llvm][DenseMapInfo] Add an info specialization for std::tuple

This revision adds a DenseMapInfo overload for std::tuples whose elements all have a DenseMapInfo. The implementation is similar to that of std::pair, and has been used within MLIR for over a year.

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