platform/upstream/llvm.git
4 years ago[Statepoints] Operand folding in presense of tied registers.
Denis Antrushin [Wed, 10 Jun 2020 13:01:19 +0000 (20:01 +0700)]
[Statepoints] Operand folding in presense of tied registers.

Implement proper folding of statepoint meta operands (deopt and GC)
when statepoint uses tied registers.
For deopt operands it is just about properly preserving tiedness
in new instruction.
For tied GC operands folding is a little bit more tricky.
We can fold tied GC operands only from InlineSpiller, because it knows
how to properly reload tied def after it was turned into memory operand.
Other users (e.g. peephole) cannot properly fold such operands as they
do not know how (or when) to reload them from memory.
We do this by un-tieing operand we want to fold in InlineSpiller
and allowing to fold only untied operands in foldPatchpoint.

4 years ago[clang] Add -fno-delayed-template-parsing to the added unit tests in DeclPrinterTest.cpp
Bruno Ricci [Wed, 5 Aug 2020 13:12:05 +0000 (14:12 +0100)]
[clang] Add -fno-delayed-template-parsing to the added unit tests in DeclPrinterTest.cpp

4 years ago[mlir] Initial version of C APIs
Alex Zinenko [Wed, 5 Aug 2020 12:36:16 +0000 (14:36 +0200)]
[mlir] Initial version of C APIs

    Introduce an initial version of C API for MLIR core IR components: Value, Type,
    Attribute, Operation, Region, Block, Location. These APIs allow for both
    inspection and creation of the IR in the generic form and intended for wrapping
    in high-level library- and language-specific constructs. At this point, there
    is no stability guarantee provided for the API.

Reviewed By: stellaraccident, lattner

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

4 years agoRecommit "[InstCombine] Negator: -(X << C) --> X * (-1 << C)"
Roman Lebedev [Wed, 5 Aug 2020 11:55:29 +0000 (14:55 +0300)]
Recommit "[InstCombine] Negator: -(X << C)  -->  X * (-1 << C)"

This reverts commit ac70b37a00dc02bd8923e0a4602d26be4581c570
which reverted commit 8aeb2fe13a4100b4c2e78d6ef75119304100cb1f
because codegen tests got broken and i needed time to investigate.

This shows some regressions in tests, but they are all around GEP's,
so i'm not really sure how important those are.

https://rise4fun.com/Alive/1Gn

4 years ago[gn build] (manually) merge 3ab01550b
Nico Weber [Wed, 5 Aug 2020 12:52:55 +0000 (08:52 -0400)]
[gn build] (manually) merge 3ab01550b

This reverts commit 0bbaacc8cae0373d4500c4e3f6f128d21f9033b7 and
2ad56119f5dc6c6af2b8ddfd9fc8c6460a7507c8 which merged 10b1b4a23
(and follow-ups), since that change was reverted in 3ab01550b.

4 years ago[clang][NFC] DeclPrinter: use NamedDecl::getDeclName instead of NamedDecl::printName...
Bruno Ricci [Wed, 5 Aug 2020 11:10:16 +0000 (12:10 +0100)]
[clang][NFC] DeclPrinter: use NamedDecl::getDeclName instead of NamedDecl::printName to print the name of enumerations, namespaces and template parameters.

NamedDecl::printName will print the pretty-printed name of the entity, which
is not what we want here (we should print "enum { e };" instead of "enum
(unnamed enum at input.cc:1:5) { e };").

For now only DecompositionDecl and MDGuidDecl have an overloaded printName so
this does not result in any functional change, but this change is needed since
I will be adding overloads to better handle unnamed entities in diagnostics.

4 years ago[clang][NFCI] Get rid of ConstantMatrixTypeBitfields to avoid increasing the size...
Bruno Ricci [Wed, 5 Aug 2020 10:53:24 +0000 (11:53 +0100)]
[clang][NFCI] Get rid of ConstantMatrixTypeBitfields to avoid increasing the size of every type.

sizeof(ConstantMatrixTypeBitfields) > 8 which increases the size of every type.
This was not detected because no corresponding static_assert for its size was
added.

To prevent this from occuring again replace the various static_asserts for
the size of each of the bit-field classes by a single static_assert for the
size of Type.

I have left ConstantMatrixType::MaxElementsPerDimension unchanged since
the limit is exercised by multiple tests.

4 years ago[clang][nearly-NFC] Remove some superfluous uses of NamedDecl::getNameAsString
Bruno Ricci [Wed, 5 Aug 2020 10:48:09 +0000 (11:48 +0100)]
[clang][nearly-NFC] Remove some superfluous uses of NamedDecl::getNameAsString

`OS << ND->getDeclName();` is equivalent to `OS << ND->getNameAsString();`
without the extra temporary string.

This is not quite a NFC since two uses of `getNameAsString` in a
diagnostic are replaced, which results in the named entity being
quoted with additional "'"s (ie: 'var' instead of var).

4 years ago[clang][NFC] Document NamedDecl::printName
Bruno Ricci [Wed, 5 Aug 2020 10:43:39 +0000 (11:43 +0100)]
[clang][NFC] Document NamedDecl::printName

4 years ago[clang][NFC] Remove an old workaround for MSVC 2013
Bruno Ricci [Wed, 5 Aug 2020 10:42:48 +0000 (11:42 +0100)]
[clang][NFC] Remove an old workaround for MSVC 2013

4 years ago[clang][NFC] Add a test showcasing an unnamed template parameter in a diagnostic
Bruno Ricci [Wed, 5 Aug 2020 10:41:51 +0000 (11:41 +0100)]
[clang][NFC] Add a test showcasing an unnamed template parameter in a diagnostic

4 years ago[clang][NFC] Remove spurious +x flag on DeclTemplate.cpp and DeclTemplate.h
Bruno Ricci [Wed, 5 Aug 2020 10:39:36 +0000 (11:39 +0100)]
[clang][NFC] Remove spurious +x flag on DeclTemplate.cpp and DeclTemplate.h

4 years ago[mlir] Remove LLVMTypeTestDialect
Alex Zinenko [Tue, 4 Aug 2020 16:52:42 +0000 (18:52 +0200)]
[mlir] Remove LLVMTypeTestDialect

This dialect was introduced during the bring-up of the new LLVM dialect type
system for testing purposes. The main LLVM dialect now uses the new type system
and the test dialect is no longer necessary, so remove it.

Reviewed By: rriddle

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

4 years ago[CUDA][HIP] Support accessing static device variable in host code for -fno-gpu-rdc
Yaxun (Sam) Liu [Tue, 4 Aug 2020 16:13:16 +0000 (12:13 -0400)]
[CUDA][HIP] Support accessing static device variable in host code for -fno-gpu-rdc

nvcc supports accessing file-scope static device variables in host code by host APIs
like cudaMemcpyToSymbol etc.

CUDA/HIP let users access device variables in host code by shadow variables. In host compilation,
clang emits a shadow variable for each device variable, and calls __*RegisterVariable to
register it in init function. The address of the shadow variable and the device side mangled
name of the device variable is passed to __*RegisterVariable. Runtime looks up the symbol
by name in the device binary  to find the address of the device variable.

The problem with static device variables is that they have internal linkage, therefore their
name may be changed by the linker if there are multiple symbols with the same name. Also
they end up as local symbols in the elf file, whereas the runtime only looks up the global symbols.

Another reason for making the static device variables external linkage is that they may be
initialized externally by host code and their final value may be accessed by host code
after kernel execution, therefore they actually have external linkage. Giving them internal
linkage will cause incorrect optimizations on them.

To support accessing static device var in host code for -fno-gpu-rdc mode, change the intnernal
linkage to external linkage. The name does not need change since there is only one TU for
-fno-gpu-rdc mode. Also the externalization is done only if the device static var is referenced
by host code.

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

4 years ago[ARM][CostModel] Implement getCFInstrCost
Sam Parker [Wed, 5 Aug 2020 08:37:53 +0000 (09:37 +0100)]
[ARM][CostModel] Implement getCFInstrCost

As with other targets, set the throughput cost of control-flow
instructions to free so that we don't miss out of vectorization
opportunities.

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

4 years agoDWARFVerifier.h - remove unnecessary forward declarations and includes. NFCI.
Simon Pilgrim [Wed, 5 Aug 2020 11:42:09 +0000 (12:42 +0100)]
DWARFVerifier.h - remove unnecessary forward declarations and includes. NFCI.

4 years ago[mlir] Fix convert-to-llvmir.mlir test broken due to syntax change
Alex Zinenko [Wed, 5 Aug 2020 11:29:35 +0000 (13:29 +0200)]
[mlir] Fix convert-to-llvmir.mlir test broken due to syntax change

The syntax of the LLVM dialect types changed between the time the code
was written and it was submitted, leading to a test failure. Update the
syntax.

4 years ago[obj2yaml] Add support for dumping the .debug_aranges section.
Xing GUO [Wed, 5 Aug 2020 11:18:33 +0000 (19:18 +0800)]
[obj2yaml] Add support for dumping the .debug_aranges section.

This patch adds support for dumping DWARF sections to obj2yaml. The
.debug_aranges section is used to illustrate the basic idea.

Reviewed By: jhenderson

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

4 years agoSupport member expressions in bugprone-bool-pointer-implicit-conversion.
Alex Cameron [Wed, 5 Aug 2020 11:14:28 +0000 (07:14 -0400)]
Support member expressions in bugprone-bool-pointer-implicit-conversion.

This addresses PR45189.

4 years agoGISelWorkList.h - remove unnecessary includes. NFCI.
Simon Pilgrim [Wed, 5 Aug 2020 11:00:12 +0000 (12:00 +0100)]
GISelWorkList.h - remove unnecessary includes. NFCI.

4 years agoCallLowering.h - remove unnecessary CCState forward declaration. NFCI.
Simon Pilgrim [Wed, 5 Aug 2020 10:35:11 +0000 (11:35 +0100)]
CallLowering.h - remove unnecessary CCState forward declaration. NFCI.

Already defined in CallingConvLower.h

4 years ago[X86][AVX] Add test showing unnecessary duplicate HADD instructions
Simon Pilgrim [Wed, 5 Aug 2020 10:33:02 +0000 (11:33 +0100)]
[X86][AVX] Add test showing unnecessary duplicate HADD instructions

Taken from internal fuzz test

4 years agoRevert "[CMake] Simplify CMake handling for zlib"
Hans Wennborg [Wed, 5 Aug 2020 10:14:07 +0000 (12:14 +0200)]
Revert "[CMake] Simplify CMake handling for zlib"

This quietly disabled use of zlib on Windows even when building with
-DLLVM_ENABLE_ZLIB=FORCE_ON.

> Rather than handling zlib handling manually, use find_package from CMake
> to find zlib properly. Use this to normalize the LLVM_ENABLE_ZLIB,
> HAVE_ZLIB, HAVE_ZLIB_H. Furthermore, require zlib if LLVM_ENABLE_ZLIB is
> set to YES, which requires the distributor to explicitly select whether
> zlib is enabled or not. This simplifies the CMake handling and usage in
> the rest of the tooling.
>
> This is a reland of abb0075 with all followup changes and fixes that
> should address issues that were reported in PR44780.
>
> Differential Revision: https://reviews.llvm.org/D79219

This reverts commit 10b1b4a231a485f1711d576e6131f6755e008abe and follow-ups
64d99cc6abed78c00a2a7863b02ce54911a5264f and
f9fec0447e12da9e8cf4b628f6d45f4941e7d182.

4 years ago[SVE] Add lowering for fixed length vector and, or & xor operations.
Paul Walker [Wed, 5 Aug 2020 10:21:34 +0000 (11:21 +0100)]
[SVE] Add lowering for fixed length vector and, or & xor operations.

Since there are no ill effects when performing these operations
with undefined elements, they are lowered to the already supported
unpredicated scalable vector equivalents.

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

4 years ago[DAG] Fold vector (aext (load x)) -> (zext (truncate (zextload x)))
Simon Pilgrim [Wed, 5 Aug 2020 10:22:07 +0000 (11:22 +0100)]
[DAG] Fold vector (aext (load x)) -> (zext (truncate (zextload x)))

We currently don't do anything to fold any_extend vector loads as no target has such an instruction.

Instead I've added support for folding to a zextload, SimplifyDemandedBits does a good job of adjusting the zext(truncate(()) stages as required later on.

We still need the custom scalar extload handling instead of using the tryToFoldExtOfLoad helper as it has different legality tests - we can probably tweak that to reduce most of the code duplication.

Fixes the regression I mentioned in rG99a971cadff7

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

4 years ago[lldb] expect TestGuiBasicDebug.py failure on aarch64
Luboš Luňák [Wed, 5 Aug 2020 10:18:38 +0000 (12:18 +0200)]
[lldb] expect TestGuiBasicDebug.py failure on aarch64

http://lab.llvm.org:8011/builders/lldb-aarch64-ubuntu/builds/7287/steps/test/logs/stdio
fails, and the output suggests that gui 'finish' (='thread step-out') is broken
on aarch64.

4 years ago[mlir] Conversion of ViewOp with memory space to LLVM.
Arpith C. Jacob [Wed, 5 Aug 2020 10:16:17 +0000 (12:16 +0200)]
[mlir] Conversion of ViewOp with memory space to LLVM.

Handle the case where the ViewOp takes in a memref that has
an memory space.

Reviewed By: ftynse, bondhugula, nicolasvasilache

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

4 years ago[mlir] Lower RankOp to LLVM for unranked memrefs.
Alexander Belyaev [Wed, 5 Aug 2020 10:12:45 +0000 (12:12 +0200)]
[mlir] Lower RankOp to LLVM for unranked memrefs.

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

4 years ago[llvm-readobj/elf] - Add a testing for --stackmap and refine the implementation.
Georgii Rymar [Tue, 4 Aug 2020 12:19:36 +0000 (15:19 +0300)]
[llvm-readobj/elf] - Add a testing for --stackmap and refine the implementation.

Currently, we only test the `--stackmap` option here:
https://github.com/llvm/llvm-project/blob/master/llvm/test/Object/stackmap-dump.test
it uses a precompiled MachO binary currently and I've found no tests for this option for ELF.

The implementation also has issues. For example, it might assert on a wrong version
of the .llvm-stackmaps section. Or it might crash on an empty or truncated section.

This patch introduces a new tools/llvm-readobj/ELF test file as well as implements a few
basic checks to catch simple crashes/issues

It also eliminates `unwrapOrError` calls in `printStackMap()`.

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

4 years ago[llvm-symbolizer] Add legacy aliases -demangle=true and -demangle=false.
Benjamin Kramer [Wed, 5 Aug 2020 10:03:30 +0000 (12:03 +0200)]
[llvm-symbolizer] Add legacy aliases -demangle=true and -demangle=false.

This is used in the wild, don't break compatibility for no good reason.
https://github.com/google/pprof/blob/master/internal/binutils/addr2liner_llvm.go

4 years ago[docs] Document pattern of using CHECK-SAME to skip irrelevant lines
Jordan Rupprecht [Tue, 4 Aug 2020 23:23:03 +0000 (00:23 +0100)]
[docs] Document pattern of using CHECK-SAME to skip irrelevant lines

This came up during the review for D67656. It's nice but also subtle, so documenting it as an idiom will make tests easier to understand.

Reviewed By: probinson

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

4 years agoRevert "[lldb] temporary commit to see why a test is failing only on lldb-aarch64...
Luboš Luňák [Wed, 5 Aug 2020 09:55:02 +0000 (11:55 +0200)]
Revert "[lldb] temporary commit to see why a test is failing only on lldb-aarch64-ubuntu"

This reverts commit 21f142ce1df10fe6cf5721e263fc6e91aea93938.

4 years ago[lldb] temporary commit to see why a test is failing only on lldb-aarch64-ubuntu
Luboš Luňák [Wed, 5 Aug 2020 09:54:14 +0000 (11:54 +0200)]
[lldb] temporary commit to see why a test is failing only on lldb-aarch64-ubuntu

4 years ago[MLIR][Shape] Expose extent tensor type builder
Frederik Gossen [Wed, 5 Aug 2020 09:41:42 +0000 (09:41 +0000)]
[MLIR][Shape] Expose extent tensor type builder

The extent tensor type is a `tensor<?xindex>` that is used in the shape dialect.
To facilitate the use of this type when working with the shape dialect, we
expose the helper function for its construction.

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

4 years ago[compiler-rt] Normalize some in/out doxygen parameter in interface
Pierre Gousseau [Wed, 5 Aug 2020 09:17:25 +0000 (10:17 +0100)]
[compiler-rt] Normalize some in/out doxygen parameter in interface
headers. NFC.

Reviewed By: vitalybuka

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

4 years ago[lldb] Suppress MSVC warning C4065
Tatyana Krasnukha [Tue, 4 Aug 2020 17:53:30 +0000 (20:53 +0300)]
[lldb] Suppress MSVC warning C4065

MSVC reports "switch statement contains 'default' but no 'case' labels". Suppress,
as this was intended behavior.

4 years ago[lldb] Use PyUnicode_GetLength instead of PyUnicode_GetSize
Tatyana Krasnukha [Tue, 4 Aug 2020 17:52:48 +0000 (20:52 +0300)]
[lldb] Use PyUnicode_GetLength instead of PyUnicode_GetSize

PyUnicode_GetSize is deprecated since Python version 3.3.

4 years ago[lldb/TestingSupport] Manually disable GTEST_HAS_TR1_TUPLE
Tatyana Krasnukha [Tue, 4 Aug 2020 14:15:29 +0000 (17:15 +0300)]
[lldb/TestingSupport] Manually disable GTEST_HAS_TR1_TUPLE

Gtest 1.8.0 uses tr1::tuple which is deprecated on MSVC. We have to force it off
to avoid the compiler warnings, which will become errors after switching on C++17
(https://devblogs.microsoft.com/cppblog/c17-feature-removals-and-deprecations).

4 years agoDo not map read-only data memory sections with EXECUTE flags.
David Turner [Wed, 5 Aug 2020 08:50:06 +0000 (10:50 +0200)]
Do not map read-only data memory sections with EXECUTE flags.

The code in SectionMemoryManager.cpp unnecessarily maps
read-only data sections with the READ+EXECUTE flags. This is
undesirable from a security stand-point.

Moreover, on the Fuchsia platform, which is now very strict
about mapping pages with the EXECUTE permission, this simply
fails, because the section's pages were initially allocated
with only the READ+WRITE flags.

A more detailed description of the issue can be found in this
public SwiftShader bug:

  https://issuetracker.google.com/issues/154586551

This patch just restrict the mapping to the READ flag for ROData
sections. Code sections are still mapped with READ+EXECUTE as
expected.

Reviewed By: lhames

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

4 years ago[AArch64][SVE] Disable tail calls if callee does not preserve SVE regs.
Sander de Smalen [Wed, 5 Aug 2020 08:17:57 +0000 (09:17 +0100)]
[AArch64][SVE] Disable tail calls if callee does not preserve SVE regs.

This fixes an issue triggered by the following code, where emitEpilogue
got confused when trying to restore the SVE registers after the call,
whereas the call to bar() is implemented as a TCReturn:

  int non_sve();
  int sve(svint32_t x) { return non_sve(); }

Reviewed By: efriedma

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

4 years ago[MLIR][SPIRVToLLVM] Updated LLVM types in the documentation
George Mitenkov [Wed, 5 Aug 2020 08:18:38 +0000 (11:18 +0300)]
[MLIR][SPIRVToLLVM] Updated LLVM types in the documentation

Updated the documentation with new MLIR LLVM types for
vectors, pointers, arrays and structs. Also, changed remaining
tabs to spaces.

Reviewed By: ftynse

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

4 years ago[AMDGPU] Propagate fast math flags in frem lowering
Jay Foad [Fri, 24 Jul 2020 11:55:12 +0000 (12:55 +0100)]
[AMDGPU] Propagate fast math flags in frem lowering

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

4 years ago[AMDGPU] Precommit tests for D84518 Propagate fast math flags in frem lowering
Jay Foad [Fri, 24 Jul 2020 11:52:36 +0000 (12:52 +0100)]
[AMDGPU] Precommit tests for D84518 Propagate fast math flags in frem lowering

4 years ago[AMDGPU] Lower frem f16
Jay Foad [Fri, 24 Jul 2020 11:05:46 +0000 (12:05 +0100)]
[AMDGPU] Lower frem f16

Without this it would fail to select on subtargets that have 16-bit
instructions.

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

4 years ago[Flang] Fix multi-config generator builds
Andrzej Warzynski [Sat, 1 Aug 2020 19:53:27 +0000 (20:53 +0100)]
[Flang] Fix multi-config generator builds

Based on https://reviews.llvm.org/D84022 with additional changes to
maintain out-of-tree builds.

Original commit message:
Currently the binaries are output directly into the bin subdirectory of
the build directory. This doesn't work correctly with multi-config
generators which should output the binaries into <CONFIG_NAME>/bin
instead.

The original patch was implemented by David Truby and the additional
changes added here were also proposed by David Truby.

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

Co-authored-by: David Truby <david.truby@arm.com>
4 years ago[lldb][gui] add a test for 'b' (toggle breakpoint)
Luboš Luňák [Mon, 3 Aug 2020 06:32:16 +0000 (08:32 +0200)]
[lldb][gui] add a test for 'b' (toggle breakpoint)

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

4 years ago[lldb][gui] move TestGuiBasicDebug.py to lldb/test and update it
Luboš Luňák [Mon, 3 Aug 2020 05:09:03 +0000 (07:09 +0200)]
[lldb][gui] move TestGuiBasicDebug.py to lldb/test and update it

Between the time it was created and it was pushed upstream,
99451b4453688a94c6014cac233d371ab4cc342d has moved the existing
gui gui tests to lldb/test, so move this one too.
And update it to contain TestGuiBasic.py changes since the time
when it was based on that test.

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

4 years ago[lldb][gui] implement breakpoint removal on breakpoint toggling
Luboš Luňák [Sun, 2 Aug 2020 20:03:21 +0000 (22:03 +0200)]
[lldb][gui] implement breakpoint removal on breakpoint toggling

It says it toggles breakpoints, so if one already exists
on the selected location, remove it instead of adding.

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

4 years ago[lldb][gui] implement shift+tab for going back in views
Luboš Luňák [Sun, 2 Aug 2020 11:18:41 +0000 (13:18 +0200)]
[lldb][gui] implement shift+tab for going back in views

Also simplify the code for going forward.

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

4 years ago[lldb][gui] implement TerminalSizeChanged()
Luboš Luňák [Sun, 2 Aug 2020 10:58:22 +0000 (12:58 +0200)]
[lldb][gui] implement TerminalSizeChanged()

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

4 years ago[lldb] fix building with panel.h being in /usr/include/ncurses/
Luboš Luňák [Tue, 4 Aug 2020 16:37:34 +0000 (18:37 +0200)]
[lldb] fix building with panel.h being in /usr/include/ncurses/

My openSUSE 15.2 has /usr/include/curses.h as a symlink to
/usr/include/ncurses/curses.h , but there's no such symlink
for panel.h . Prefer using /usr/include/ncurses for the includes
if they are found there by the CMake check.

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

4 years ago[SyntaxTree] Add test coverage for `->*` operator
Eduardo Caldas [Tue, 4 Aug 2020 08:30:24 +0000 (08:30 +0000)]
[SyntaxTree] Add test coverage for `->*` operator

This was the last binary operator that we supported but didn't have any
test coverage. The recent fix in a crash in member pointers allowed us
to add this test.

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

4 years ago[MLIR][SPIRVToLLVM] Conversion pattern for loop op
George Mitenkov [Wed, 5 Aug 2020 07:09:21 +0000 (10:09 +0300)]
[MLIR][SPIRVToLLVM] Conversion pattern for loop op

This patch introduces a conversion of `spv.loop` to LLVM dialect.
Similarly to `spv.selection`, op's control attributes are not mapped
to LLVM yet and therefore the conversion fails if the loop control is
not `None`. Also, all blocks within the loop should be reachable in
order for conversion to succeed.

Reviewed By: mravishankar

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

4 years agoDomTree: Make PostDomTree indifferent to block successors swap
Yevgeny Rouban [Wed, 5 Aug 2020 04:06:54 +0000 (11:06 +0700)]
DomTree: Make PostDomTree indifferent to block successors swap

Fixed the commit c35585e209efe69e2233bdc5ecd23bed7b735ba3.

This is a fix for the bug 46098 where PostDominatorTree
is unexpectedly changed by InstCombine's branch swapping
transformation.
This patch fixes PostDomTree builder. While looking for
the furthest away node in a reverse unreachable subgraph
this patch runs DFS with successors in their function order.
This order is indifferent to the order of successors, so is
the furthest away node.

Reviewers: kuhar, nikic, lebedev.ri
Differential Revision: https://reviews.llvm.org/D84763

4 years ago[MLIR][SPIRVToLLVM] Updated documentation for SPIR-V to LLVM conversion
George Mitenkov [Wed, 5 Aug 2020 06:27:03 +0000 (09:27 +0300)]
[MLIR][SPIRVToLLVM] Updated documentation for SPIR-V to LLVM conversion

Updated the documentation for SPIR-V to LLVM conversion, particularly:
- Added a section on control flow
- Added a section on memory ops
- Added a section on GLSL ops

Also, moved `spv.FunctionCall` to control flow section. Added a new section
that will be used to describe the modelling of runtime-related ops.

Reviewed By: antiagainst

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

4 years ago[llvm-rc] Allow string table values split into multiple string literals
Martin Storsjö [Tue, 4 Aug 2020 07:24:32 +0000 (10:24 +0300)]
[llvm-rc] Allow string table values split into multiple string literals

This can practically easily be a product of combining strings with
macros in resource files.

This fixes https://github.com/mstorsjo/llvm-mingw/issues/140.

As string literals within llvm-rc are handled as StringRefs, each
referencing an uninterpreted slice of the input file, with actual
interpretation of the input string (codepage handling, unescaping etc)
done only right before writing them out to disk, it's hard to
concatenate them other than just bundling them up in a vector,
without rearchitecting a large part of llvm-rc.

This matches how the same already is supported in VersionInfoValue,
with a std::vector<IntOrString> Values.

MS rc.exe only supports concatenated string literals in version info
values (already supported), string tables (implemented in this patch)
and user data resources (easily implemented in a separate patch, but
hasn't been requested by any end user yet), while GNU windres supports
string immediates split into multiple strings anywhere (e.g. like
(100 ICON "myicon" ".ico"). Not sure if concatenation in other
statements actually is used in the wild though, in resource files
normally built by GNU windres.

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

4 years ago[JumpThreading] Consider freeze as a zero-cost instruction
Juneyoung Lee [Tue, 4 Aug 2020 08:22:36 +0000 (17:22 +0900)]
[JumpThreading] Consider freeze as a zero-cost instruction

This is a simple patch that makes freeze as a zero-cost instruction, as bitcast already is.

Reviewed By: efriedma

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

4 years ago[JumpThreading] Add a test for D85023; NFC
Juneyoung Lee [Tue, 4 Aug 2020 08:21:32 +0000 (17:21 +0900)]
[JumpThreading] Add a test for D85023; NFC

4 years agoRevert "DomTree: Make PostDomTree immune to block successors swap"
Mehdi Amini [Wed, 5 Aug 2020 04:31:30 +0000 (04:31 +0000)]
Revert "DomTree: Make PostDomTree immune to block successors swap"

This reverts commit c35585e209efe69e2233bdc5ecd23bed7b735ba3.

The MLIR is broken with this patch, reproduce by adding
-DLLVM_ENABLE_PROJECTS=mlir to the cmake configuration and
build `ninja tools/mlir/lib/IR/CMakeFiles/obj.MLIRIR.dir/Dominance.cpp.o`

4 years ago[BPI][NFC] Unify handling of normal and SCC based loops
Evgeniy Brevnov [Wed, 29 Jul 2020 12:19:00 +0000 (19:19 +0700)]
[BPI][NFC] Unify handling of normal and SCC based loops

This is one more NFC part extracted from D79485. Normal and SCC based loops have very different representation and have to be handled separatly each time we deal with loops. D79485 is going to introduce much more extensive use of loops what will be problematic with out this change.

Reviewed By: davidxl

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

4 years agoDomTree: Make PostDomTree immune to block successors swap
Yevgeny Rouban [Wed, 5 Aug 2020 04:06:54 +0000 (11:06 +0700)]
DomTree: Make PostDomTree immune to block successors swap

This is another fix for the bug 46098 where PostDominatorTree
is unexpectedly changed by InstCombine's branch swapping
transformation.
This patch fixes PostDomTree builder. While looking for
the furthest away node in a reverse unreachable subgraph
this patch runs DFS with successors in their function order.
This order is indifferent to the order of successors, so is
the furthest away node.

Reviewers: kuhar, nikic, lebedev.ri
Differential Revision: https://reviews.llvm.org/D84763

4 years agoGlobalISel: Use buildAnyExtOrTrunc
Matt Arsenault [Fri, 31 Jul 2020 14:11:00 +0000 (10:11 -0400)]
GlobalISel: Use buildAnyExtOrTrunc

4 years agoGlobalISel: Simplify code
Matt Arsenault [Fri, 31 Jul 2020 14:19:02 +0000 (10:19 -0400)]
GlobalISel: Simplify code

This cannot be a vector of pointers, so using getScalarSizeInBits just
added a bit extra noise.

4 years agoGlobalISel: Fix redundant variable and shadowing
Matt Arsenault [Fri, 31 Jul 2020 14:14:22 +0000 (10:14 -0400)]
GlobalISel: Fix redundant variable and shadowing

4 years agoGlobalISel: Move load/store lowering to separate functions
Matt Arsenault [Fri, 31 Jul 2020 14:09:00 +0000 (10:09 -0400)]
GlobalISel: Move load/store lowering to separate functions

4 years ago[llvm-cov] reset executation count to 0 after wrapped segment
Zequan Wu [Fri, 31 Jul 2020 06:36:31 +0000 (23:36 -0700)]
[llvm-cov] reset executation count to 0 after wrapped segment

Fix the bug: https://bugs.llvm.org/show_bug.cgi?id=36979. It also fixes this bug: https://bugs.llvm.org/show_bug.cgi?id=35404, which I think is caused by the same problem.

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

4 years ago[StackSafety,NFC] Add combined index test
Vitaly Buka [Wed, 5 Aug 2020 01:31:10 +0000 (18:31 -0700)]
[StackSafety,NFC] Add combined index test

Missing file for the previous patch

4 years agoPR46997: don't run clang-format on clang's testcases.
Richard Smith [Wed, 5 Aug 2020 00:49:56 +0000 (17:49 -0700)]
PR46997: don't run clang-format on clang's testcases.

The formatting of the testcases matters and shouldn't be overwritten by
a tool.

4 years ago[X86] Optimize getImpliedDisabledFeatures & getImpliedEnabledFeatures after D83273
Fangrui Song [Wed, 5 Aug 2020 00:50:06 +0000 (17:50 -0700)]
[X86] Optimize getImpliedDisabledFeatures & getImpliedEnabledFeatures after D83273

Previously the time complexity is O(|number of paths from the root to an
implied feature| * CPU_FWATURE_MAX) where CPU_FEATURE_MAX is 92.

The number of paths can be large (theoretically exponential).

For an inline asm statement, there is a code path
`clang::Parser::ParseAsmStatement -> clang::Sema::ActOnGCCAsmStmt -> ASTContext::getFunctionFeatureMap`
leading to potentially many calls of getImpliedEnabledFeatures (41 for my -march=native case).

We should improve the performance a bit in case the number of inline asm
statements is large (Linux kernel builds).

Reviewed By: craig.topper

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

4 years ago[lldb/testsuite] Skip 'frame diagnose' tests based on architecture
Fred Riss [Wed, 5 Aug 2020 00:45:36 +0000 (17:45 -0700)]
[lldb/testsuite] Skip 'frame diagnose' tests based on architecture

AFAICS, the feature only works on x86, skipping the tests has nothing to
do with the target being iOS or remote.

4 years ago[StackSafety,NFC] Add combined index test
Vitaly Buka [Wed, 5 Aug 2020 00:39:46 +0000 (17:39 -0700)]
[StackSafety,NFC] Add combined index test

4 years ago[llvm] Expose type and element count-related APIs on TensorSpec
Mircea Trofin [Tue, 4 Aug 2020 22:00:35 +0000 (15:00 -0700)]
[llvm] Expose type and element count-related APIs on TensorSpec

Added a mechanism to check the element type, get the total element
count, and the size of an element.

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

4 years agoRevert "[InstCombine] Negator: -(X << C) --> X * (-1 << C)"
Roman Lebedev [Wed, 5 Aug 2020 00:19:38 +0000 (03:19 +0300)]
Revert "[InstCombine] Negator: -(X << C)  -->  X * (-1 << C)"

Breaks codegen tests, will recommit later.

This reverts commit 8aeb2fe13a4100b4c2e78d6ef75119304100cb1f.

4 years ago[InstCombine] Negator: -(X << C) --> X * (-1 << C)
Roman Lebedev [Tue, 4 Aug 2020 23:08:58 +0000 (02:08 +0300)]
[InstCombine] Negator: -(X << C)  -->  X * (-1 << C)

This shows some regressions in tests, but they are all around GEP's,
so i'm not really sure how important those are.

https://rise4fun.com/Alive/1Gn

4 years ago[NFC][InstCombine] Fix value names (s/%tmp/%i/) and autogenerate a few tests being...
Roman Lebedev [Tue, 4 Aug 2020 23:42:21 +0000 (02:42 +0300)]
[NFC][InstCombine] Fix value names (s/%tmp/%i/) and autogenerate a few tests being affected by negator change

4 years ago[NFC][InstCombine] Negator: add tests for negation of left-shift by constant
Roman Lebedev [Tue, 4 Aug 2020 22:52:57 +0000 (01:52 +0300)]
[NFC][InstCombine] Negator: add tests for negation of left-shift by constant

4 years agoFix debugserver's qProcessInfo reporting of maccatalyst binaries
Adrian Prantl [Sat, 25 Jul 2020 01:36:18 +0000 (18:36 -0700)]
Fix debugserver's qProcessInfo reporting of maccatalyst binaries

This patch is similar in spirit to https://reviews.llvm.org/D84480,
but does the maccatalyst/macosx disambiguation. I also took the
opportunity to factor out the gdb-remote packet log scanning used by
several testcases into lldbutil functions.

rdar://problem/66059257

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

4 years ago[RDF] Add operator<<(raw_ostream&, RegisterAggr), NFC
Krzysztof Parzyszek [Tue, 4 Aug 2020 22:36:17 +0000 (17:36 -0500)]
[RDF] Add operator<<(raw_ostream&, RegisterAggr), NFC

4 years ago[RDF] Use hash-based containers, cache extra information
Krzysztof Parzyszek [Tue, 4 Aug 2020 22:36:17 +0000 (17:36 -0500)]
[RDF] Use hash-based containers, cache extra information

This improves performance.

4 years agoBPF: simplify IR generation for __builtin_btf_type_id()
Yonghong Song [Mon, 3 Aug 2020 23:12:19 +0000 (16:12 -0700)]
BPF: simplify IR generation for __builtin_btf_type_id()

This patch simplified IR generation for __builtin_btf_type_id().
For __builtin_btf_type_id(obj, flag), previously IR builtin
looks like
   if (obj is a lvalue)
     llvm.bpf.btf.type.id(obj.ptr, 1, flag)  !type
   else
     llvm.bpf.btf.type.id(obj, 0, flag)  !type
The purpose of the 2nd argument is to differentiate
   __builtin_btf_type_id(obj, flag) where obj is a lvalue
vs.
   __builtin_btf_type_id(obj.ptr, flag)

Note that obj or obj.ptr is never used by the backend
and the `obj` argument is only used to derive the type.
This code sequence is subject to potential llvm CSE when
  - obj is the same .e.g., nullptr
  - flag is the same
  - metadata type is different, e.g., typedef of struct "s"
    and strust "s".
In the above, we don't want CSE since their metadata is different.

This patch change IR builtin to
   llvm.bpf.btf.type.id(seq_num, flag)  !type
and seq_num is always increasing. This will prevent potential
llvm CSE.

Also report an error if the type name is empty for
remote relocation since remote relocation needs non-empty
type name to do relocation against vmlinux.

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

4 years ago[RDF] Really remove remaining uses of PhysicalRegisterInfo::normalize
Krzysztof Parzyszek [Tue, 4 Aug 2020 23:20:30 +0000 (18:20 -0500)]
[RDF] Really remove remaining uses of PhysicalRegisterInfo::normalize

4 years ago[RDF] Cache register aliases in PhysicalRegisterInfo
Krzysztof Parzyszek [Tue, 4 Aug 2020 22:46:38 +0000 (17:46 -0500)]
[RDF] Cache register aliases in PhysicalRegisterInfo

This improves performance of PhysicalRegisterInfo::makeRegRef.

4 years ago[RDF] Lower the sorting complexity in RDFLiveness::getAllReachingDefs
Krzysztof Parzyszek [Tue, 4 Aug 2020 23:03:18 +0000 (18:03 -0500)]
[RDF] Lower the sorting complexity in RDFLiveness::getAllReachingDefs

The sorting is needed, because reaching defs are (logically) ordered,
but are not collected in that order. This change will break up the
single call to std::sort into a series of smaller sorts, each of which
should use a cheaper comparison function than the original.

4 years agoTeach SROA to handle allocas with more than one dbg.declare.
Adrian Prantl [Mon, 3 Aug 2020 23:15:22 +0000 (16:15 -0700)]
Teach SROA to handle allocas with more than one dbg.declare.

It is technically legal for optimizations to create an alloca that is
used by more than one dbg.declare, if one or both of them are inlined
instances of aliasing variables.

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

4 years ago[Hexagon] Use InstSimplify instead of ConstantProp
Arthur Eubanks [Wed, 29 Jul 2020 20:54:07 +0000 (13:54 -0700)]
[Hexagon] Use InstSimplify instead of ConstantProp

This is the last remaining use of ConstantProp, migrate it to InstSimplify in the goal of removing ConstantProp.

Add -hexagon-instsimplify option to enable skipping of instsimplify in
tests that can't handle the extra optimization.

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

4 years ago[SelectionDAG][SVE] Support scalable vectors in getConstantFP()
Eli Friedman [Tue, 4 Aug 2020 21:17:30 +0000 (14:17 -0700)]
[SelectionDAG][SVE] Support scalable vectors in getConstantFP()

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

4 years ago[RDF] Remove uses of RDFRegisters::normalize (deprecate)
Krzysztof Parzyszek [Tue, 4 Aug 2020 21:13:08 +0000 (16:13 -0500)]
[RDF] Remove uses of RDFRegisters::normalize (deprecate)

This function has been reduced to an identity function for some time.

4 years ago[lldb/Test] Add @skipIfRemote decorator to TestProcessList.py
Jonas Devlieghere [Tue, 4 Aug 2020 21:39:39 +0000 (14:39 -0700)]
[lldb/Test] Add @skipIfRemote decorator to TestProcessList.py

lldb-platform contains a very minimal support for the qfProcessInfo
packet, only allowing the simplest query to get most of the testsuite
running, and returning very little information about the matched
processes.

4 years agoAMDGPU/GlobalISel: Use live in helper function for returnaddress
Matt Arsenault [Mon, 20 Jul 2020 21:10:42 +0000 (17:10 -0400)]
AMDGPU/GlobalISel: Use live in helper function for returnaddress

4 years ago[llvm][NFC] Moved implementation of TrainingLogger outside of its decl
Mircea Trofin [Tue, 4 Aug 2020 21:32:07 +0000 (14:32 -0700)]
[llvm][NFC] Moved implementation of TrainingLogger outside of its decl

Also renamed a method - printTensor - to print; and added comments.

4 years agoAMDGPU/GlobalISel: Select llvm.returnaddress
Matt Arsenault [Mon, 20 Jul 2020 01:26:02 +0000 (21:26 -0400)]
AMDGPU/GlobalISel: Select llvm.returnaddress

4 years ago[lldb/Test] Skip tests that try to get the remote environment
Jonas Devlieghere [Tue, 4 Aug 2020 21:00:30 +0000 (14:00 -0700)]
[lldb/Test] Skip tests that try to get the remote environment

We don't support getting the remote environment. The gdb remote protocol
has no packet for that.

4 years agoGlobalISel: Add utilty for getting function argument live ins
Matt Arsenault [Mon, 20 Jul 2020 12:26:33 +0000 (08:26 -0400)]
GlobalISel: Add utilty for getting function argument live ins

Get the argument register and ensure there's a copy to the virtual
register. AMDGPU and AArch64 have similarish code to get the livein
value, and I also want to use this in multiple places.

This is a bit more aggressive about setting the register class than
the original function, but that's probably OK.

I think we're missing a few verifier checks for function live ins. I
noticed AArch64's calling convention code is not actually adding
liveins to functions, only the entry block (which apparently might not
matter that much?). There should probably be a verifier check that
entry block live ins are also live into the function. We also might
need a verifier check that the copy to the livein virtual register is
in the entry block.

4 years ago[lldb-vscode ]Add Syntax Highlighting to Disassembly View
Yifan Shen [Tue, 4 Aug 2020 20:31:44 +0000 (13:31 -0700)]
[lldb-vscode ]Add Syntax Highlighting to Disassembly View

When lldb cannot find source file thus IDE renders a disassembly view, add syntax highlighting for constants, registers and final line comments for better debugging experience.
The original plain disassembly view looks like:
{F12401687}
An ideal view is like the screenshot attached.
{F12401515}

In this diff, the mimeType is a kind of media type for formatting the content in the response to a source request. Elements in the disassembly view, like constants, registers and final line comments are colored for highlighting.
A built-in support in the VSCode IDE for syntax highlighting will identify the which mimeType to apply and render the disassembly view as expected.

Reviewed By: wallace, clayborg

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

4 years ago[AArch64][SVE] Widen narrow sdiv/udiv operations.
Eli Friedman [Mon, 3 Aug 2020 22:59:14 +0000 (15:59 -0700)]
[AArch64][SVE] Widen narrow sdiv/udiv operations.

The SVE instruction set only supports sdiv/udiv for 32-bit and 64-bit
integers.  If we see an 8-bit or 16-bit divide, widen the operands to 32
bits, and narrow the result.

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

4 years ago[HotColdSplit] Add test case for unlikely attribute in outlined function
AK [Tue, 4 Aug 2020 18:16:56 +0000 (11:16 -0700)]
[HotColdSplit] Add test case for unlikely attribute in outlined function

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

4 years ago[OpenMP] support build on msys2/mingw with clang or gcc
Adrian Pop [Tue, 4 Aug 2020 20:15:17 +0000 (23:15 +0300)]
[OpenMP] support build on msys2/mingw with clang or gcc

RTM Adaptive Locks are supported on msys2/mingw for clang and gcc.

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

4 years ago[lldb/Test] Add missing stdio.h includes
Jonas Devlieghere [Tue, 4 Aug 2020 20:07:46 +0000 (13:07 -0700)]
[lldb/Test] Add missing stdio.h includes

Fixes error: implicit declaration of function 'printf' is invalid in C99
[-Werror,-Wimplicit-function-declaration]

4 years ago[libFuzzer] Enable for SystemZ
Ilya Leoshkevich [Thu, 30 Jul 2020 18:08:40 +0000 (20:08 +0200)]
[libFuzzer] Enable for SystemZ

* Add SystemZ to the list of supported architectures.

* XFAIL a few tests.

Coverage reporting is broken, and is not easy to fix (see comment in
coverage.test). Interaction with sanitizers needs to be investigated
more thoroughly, since they appear to reduce coverage in certain cases.

4 years ago[SanitizerCoverage] Fix types of __stop* and __start* symbols
Ilya Leoshkevich [Thu, 30 Jul 2020 18:08:08 +0000 (20:08 +0200)]
[SanitizerCoverage] Fix types of __stop* and __start* symbols

If a section is supposed to hold elements of type T, then the
corresponding CreateSecStartEnd()'s Ty parameter represents T*.
Forwarding it to GlobalVariable constructor causes the resulting
GlobalVariable's type to be T*, and its SSA value type to be T**, which
is one indirection too many. This issue is mostly masked by pointer
casts, however, the global variable still gets an incorrect alignment,
which causes SystemZ to choose wrong instructions to access the
section.