platform/upstream/llvm.git
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.

4 years ago[libFuzzer] Fix endianness issue in ForEachNonZeroByte()
Ilya Leoshkevich [Thu, 30 Jul 2020 18:07:11 +0000 (20:07 +0200)]
[libFuzzer] Fix endianness issue in ForEachNonZeroByte()

The usage pattern of Bundle variable assumes the machine is little
endian, which is not the case on SystemZ. Fix by converting Bundle to
little-endian when necessary.

4 years ago[WebAssembly] Use "signed char" instead of "char" in SIMD intrinsics.
Dan Gohman [Wed, 18 Mar 2020 15:07:33 +0000 (08:07 -0700)]
[WebAssembly] Use "signed char" instead of "char" in SIMD intrinsics.

This allows people to use `int8_t` instead of `char`, -funsigned-char,
and generally decouples SIMD from the specialness of `char`.

And it makes intrinsics like `__builtin_wasm_add_saturate_s_i8x16`
and `__builtin_wasm_add_saturate_u_i8x16` use signed and unsigned
element types, respectively.

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

4 years ago[MLIR] Change FunctionType::get() and TupleType::get() to use TypeRange
Rahul Joshi [Tue, 4 Aug 2020 18:46:26 +0000 (11:46 -0700)]
[MLIR] Change FunctionType::get() and TupleType::get() to use TypeRange

- Moved TypeRange into its own header/cpp file, and add hashing support.
- Change FunctionType::get() and TupleType::get() to use TypeRange

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

4 years ago[FastISel] Don't transform FSUB(-0, X) -> FNEG(X) in FastISel
Cameron McInally [Tue, 4 Aug 2020 19:26:23 +0000 (14:26 -0500)]
[FastISel] Don't transform FSUB(-0, X) -> FNEG(X) in FastISel

This corresponds with the SelectionDAGISel change in D84056.

Also, rename some poorly named tests in CodeGen/X86/fast-isel-fneg.ll with NFC.

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

4 years agoBPF: support type exist/size and enum exist/value relocations
Yonghong Song [Thu, 30 Jul 2020 05:46:07 +0000 (22:46 -0700)]
BPF: support type exist/size and enum exist/value relocations

Four new CO-RE relocations are introduced:
  - TYPE_EXISTENCE: whether a typedef/record/enum type exists
  - TYPE_SIZE: the size of a typedef/record/enum type
  - ENUM_VALUE_EXISTENCE: whether an enum value of an enum type exists
  - ENUM_VALUE: the enum value of an enum type

These additional relocations will make CO-RE bpf programs
more adaptive for potential kernel internal data structure
changes.

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

4 years ago[MLIR][Affine] Fix createPrivateMemRef in affine fusion
Diego Caballero [Tue, 4 Aug 2020 18:22:19 +0000 (11:22 -0700)]
[MLIR][Affine] Fix createPrivateMemRef in affine fusion

Always define a remapping for the memref replacement (`indexRemap`)
with the proper number of inputs, including all the `outerIVs`, so that
the number of inputs and the operands provided for the map don't mismatch.

Reviewed By: bondhugula, andydavis1

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

4 years ago[llvm-symbolizer][test] Fix pdb/pdb.test after D83530
Fangrui Song [Tue, 4 Aug 2020 19:22:47 +0000 (12:22 -0700)]
[llvm-symbolizer][test] Fix pdb/pdb.test after D83530

This is a Windows only test which requires HAVE_DIA_SDK, so I failed to notice it.

4 years agoGlobalISel: Handle llvm.localescape
Matt Arsenault [Wed, 29 Jul 2020 13:48:26 +0000 (09:48 -0400)]
GlobalISel: Handle llvm.localescape

This one is pretty easy and shrinks the list of unhandled
intrinsics. I'm not sure how relevant the insert point is. Using the
insert position of EntryBuilder will place this after
constants. SelectionDAG seems to end up emitting these after argument
copies and before anything else, but I don't think it really
matters. This also ends up emitting these in the opposite order from
SelectionDAG, but I don't think that matters either.

This also needs a fix to stop the later passes dropping this as a dead
instruction. DeadMachineInstructionElim's version of isDead special
cases LOCAL_ESCAPE for some reason, and I'm not sure why it's excluded
from MachineInstr::isLabel (or why isDead doesn't check it).

I also noticed DeadMachineInstructionElim never considers inline asm
as dead, but GlobalISel will drop asm with no constraints.

4 years ago[libc] Add implementations for isblank, iscntrl, isgraph, ispunct.
cgyurgyik [Tue, 4 Aug 2020 18:55:12 +0000 (14:55 -0400)]
[libc] Add implementations for isblank, iscntrl, isgraph, ispunct.

Reviewed By: sivachandra

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

4 years agoGlobalISel: Add node mappings for frameindex/blockaddress
Matt Arsenault [Fri, 31 Jul 2020 19:46:10 +0000 (15:46 -0400)]
GlobalISel: Add node mappings for frameindex/blockaddress

4 years agoAMDGPU/GlobalISel: Add baseline tests for andn2/orn2 matching
Matt Arsenault [Sun, 26 Jul 2020 21:44:28 +0000 (17:44 -0400)]
AMDGPU/GlobalISel: Add baseline tests for andn2/orn2 matching

4 years ago[libc++abi] Make sure we use a 32 bit guard on 32 bit Aarch64
Louis Dionne [Tue, 4 Aug 2020 19:09:05 +0000 (15:09 -0400)]
[libc++abi] Make sure we use a 32 bit guard on 32 bit Aarch64

4 years ago[mlir] [VectorOps] Add expand/compress operations to Vector dialect
aartbik [Fri, 31 Jul 2020 19:47:25 +0000 (12:47 -0700)]
[mlir] [VectorOps] Add expand/compress operations to Vector dialect

Introduces the expand and compress operations to the Vector dialect
(important memory operations for sparse computations), together
with a first reference implementation that lowers to the LLVM IR
dialect to enable running on CPU (and other targets that support
the corresponding LLVM IR intrinsics).

Reviewed By: reidtatge

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

4 years ago[NFC][LV] Vectorized Loop Skeleton Refactoring
Bardia Mahjour [Tue, 4 Aug 2020 18:47:24 +0000 (14:47 -0400)]
[NFC][LV] Vectorized Loop Skeleton Refactoring

This patch tries to improve readability and maintenance
of createVectorizedLoopSkeleton by reorganizing some lines,
updating some of the comments and breaking it up into
smaller logical units.

Reviewed By: pjeeva01

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

4 years ago[InstSimplify] Peephole optimization for icmp (urem X, Y), X
Xavier Denis [Tue, 4 Aug 2020 18:44:47 +0000 (20:44 +0200)]
[InstSimplify] Peephole optimization for icmp (urem X, Y), X

This revision adds the following peephole optimization
and it's negation:

    %a = urem i64 %x, %y
    %b = icmp ule i64 %a, %x
    ====>
    %b = true

With John Regehr's help this optimization was checked with Alive2
which suggests it should be valid.

This pattern occurs in the bound checks of Rust code, the program

    const N: usize = 3;
    const T = u8;

    pub fn split_mutiple(slice: &[T]) -> (&[T], &[T]) {
        let len = slice.len() / N;
        slice.split_at(len * N)
    }

the method call slice.split_at will check that len * N is within
the bounds of slice, this bounds check is after some transformations
turned into the urem seen above and then LLVM fails to optimize it
any further. Adding this optimization would cause this bounds check
to be fully optimized away.

ref: https://github.com/rust-lang/rust/issues/74938

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

4 years ago[InstSimplify] Add tests for icmp with urem divisor (NFC)
Xavier Denis [Tue, 4 Aug 2020 18:44:47 +0000 (20:44 +0200)]
[InstSimplify] Add tests for icmp with urem divisor (NFC)

4 years ago[llvm-symbolizer] Add compatibility aliases for --inlining={true,false}
Fangrui Song [Tue, 4 Aug 2020 18:01:02 +0000 (11:01 -0700)]
[llvm-symbolizer] Add compatibility aliases for --inlining={true,false}

D83530 removed --inlining={true,false} which were used by old asan_symbolize.py script.
Add compatibility aliases so that old asan_symbolize.py and sanitizer
binaries can work with new llvm-symbolizer.

Reviewed By: thakis

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

4 years ago[SCCP] Propagate inequalities
Nikita Popov [Tue, 7 Jul 2020 20:50:12 +0000 (22:50 +0200)]
[SCCP] Propagate inequalities

Teach SCCP to create notconstant lattice values from inequality
assumes and nonnull metadata, and update getConstant() to make
use of them. Additionally isOverdefined() needs to be changed to
consider notconstant an overdefined value.

Handling inequality branches is delayed until our branch on undef
story in other passes has been improved.

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

4 years agoRevert "[HotColdSplit] Add test case for unlikely attribute in outlined function"
AK [Tue, 4 Aug 2020 17:57:52 +0000 (10:57 -0700)]
Revert "[HotColdSplit] Add test case for unlikely attribute in outlined function"

This reverts commit aa1f905890fbbfedf396530f1e14409875ece13c.

The flag -codegenprepare maybe causing failures. Reverting this
to investigate the root cause.

4 years ago[clang] improve diagnostics for misaligned and large atomics
Thorsten Schuett [Tue, 4 Aug 2020 18:10:01 +0000 (11:10 -0700)]
[clang] improve diagnostics for misaligned and large atomics

"Listing the alignment and access size (== expected alignment) in the warning
seems like a good idea."

solves PR 46947

  struct Foo {
    struct Bar {
      void * a;
      void * b;
    };
    Bar bar;
  };

  struct ThirtyTwo {
    struct Large {
      void * a;
      void * b;
      void * c;
      void * d;
    };
    Large bar;
  };

  void braz(Foo *foo, ThirtyTwo *braz) {
    Foo::Bar bar;
    __atomic_load(&foo->bar, &bar, __ATOMIC_RELAXED);

    ThirtyTwo::Large foobar;
    __atomic_load(&braz->bar, &foobar, __ATOMIC_RELAXED);
  }

repro.cpp:21:3: warning: misaligned atomic operation may incur significant performance penalty; the expected (16 bytes) exceeds the actual alignment (8 bytes) [-Watomic-alignment]
  __atomic_load(&foo->bar, &bar, __ATOMIC_RELAXED);
  ^
repro.cpp:24:3: warning: misaligned atomic operation may incur significant performance penalty; the expected (32 bytes) exceeds the actual alignment (8 bytes) [-Watomic-alignment]
  __atomic_load(&braz->bar, &foobar, __ATOMIC_RELAXED);
  ^
repro.cpp:24:3: warning: large atomic operation may incur significant performance penalty; the access size (32 bytes) exceeds the max lock-free size (16  bytes) [-Watomic-alignment]
3 warnings generated.

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

4 years ago[test] Fix another realpath->abspath.
Jordan Rupprecht [Tue, 4 Aug 2020 18:01:43 +0000 (11:01 -0700)]
[test] Fix another realpath->abspath.

This is a followup to 817b3a6fe3a4452eb61a2503c8beaa7267ca0351: in `builder_base` we should use abspath, not realpath, because the name is significant.
This is used by test cases that use `@skipIf(compiler="clang", compiler_version=['<', <version>])`

4 years ago[InstSimplify] add tests for compare of min/max; NFC
Sanjay Patel [Tue, 4 Aug 2020 17:54:15 +0000 (13:54 -0400)]
[InstSimplify] add tests for compare of min/max; NFC

The test are adapted from the existing tests for cmp/select idioms.

4 years ago[MLIR][SPIRVToLLVM] Indentation and style fix in tests
George Mitenkov [Tue, 4 Aug 2020 17:30:40 +0000 (20:30 +0300)]
[MLIR][SPIRVToLLVM] Indentation and style fix in tests

Second patch with test fixes. Redundant `%{{.*}} = `
removed, label checks added, tabs converted to spaces and
some namings are changed to match the convention.

Fixed tests:
- constant-op-to-llvm
- func-ops-to-llvm (renamed)
- memory-ops-to-llvm
- misc-ops-to-llvm
- module-ops-to-llvm
- shift-ops-to-llvm (renamed)
- spirv-types-to-llvm-invalid (renamed)

Reviewed By: ftynse, rriddle

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

4 years agoFix -Wconstant-conversion warning with explicit cast
David Blaikie [Tue, 4 Aug 2020 17:41:27 +0000 (10:41 -0700)]
Fix -Wconstant-conversion warning with explicit cast

Introduced by fd6584a22043b254a323635c142b28ce80ae5b5b

Following similar use of casts in AsmParser.cpp, for instance - ideally
this type would use unsigned chars as they're more representative of raw
data and don't get confused around implementation defined choices of
char's signedness, but this is what it is & the signed/unsigned
conversions are (so far as I understand) safe/bit preserving in this
usage and what's intended, given the API design here.

4 years agosanitizer_symbolizer_libcdep.cpp: Change --inlining=true to --inlines and --inlining...
Fangrui Song [Tue, 4 Aug 2020 17:24:59 +0000 (10:24 -0700)]
sanitizer_symbolizer_libcdep.cpp: Change --inlining=true to --inlines and --inlining=false to --no-inlines

4 years ago[gn build] (manually) merge 593e1962
Nico Weber [Tue, 4 Aug 2020 17:04:53 +0000 (13:04 -0400)]
[gn build] (manually) merge 593e1962

4 years agoFix sphinx indentation warnings by adding explicit line breaks to address space hierarchy
Simon Pilgrim [Tue, 4 Aug 2020 16:24:27 +0000 (17:24 +0100)]
Fix sphinx indentation warnings by adding explicit line breaks to address space hierarchy

4 years ago[MLIR] Simplify semi-affine expressions
Yash Jain [Tue, 4 Aug 2020 14:51:13 +0000 (20:21 +0530)]
[MLIR] Simplify semi-affine expressions

Simplify semi-affine expression for the operations like ceildiv,
floordiv and modulo by any given symbol by checking divisibilty by that
symbol.

Some properties used in simplification are:

1) Commutative property of the floordiv and ceildiv:
((expr1 floordiv expr2) floordiv expr3 ) = ((expr1 floordiv expr3) floordiv expr2)
((expr1 ceildiv expr2) ceildiv expr3 ) = ((expr1 ceildiv expr3) ceildiv expr2)

While simplification if operations are different no simplification is
possible as there is no property that simplify expressions like these:
((expr1 ceildiv expr2) floordiv expr3) or  ((expr1 floordiv expr2)
ceildiv expr3).

2) If both expr1 and expr2 are divisible by the expr3 then:
(expr1 % expr2) / expr3 = ((expr1 / expr3) % (expr2 / expr3))
where / is divide symbol.

3) If expr1 is divisible by expr2 then expr1 % expr2 = 0.

Signed-off-by: Yash Jain <yash.jain@polymagelabs.com>
Differential Revision: https://reviews.llvm.org/D84920

4 years ago[GlobalISel] Remove redundant FNEG tests.
Cameron McInally [Tue, 4 Aug 2020 16:32:15 +0000 (11:32 -0500)]
[GlobalISel] Remove redundant FNEG tests.

These tests were made redundant by D85139.

4 years ago[DWARFYAML] Fix unintialized value Is64BitAddrSize. NFC.
Xing GUO [Tue, 4 Aug 2020 16:09:12 +0000 (00:09 +0800)]
[DWARFYAML] Fix unintialized value Is64BitAddrSize. NFC.

This patch fixes the undefined behavior that reported by ubsan.

http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/44524/

4 years agoAMDGPU/GlobalISel: Ensure subreg is valid when selecting G_UNMERGE_VALUES
Matt Arsenault [Tue, 4 Aug 2020 13:19:43 +0000 (09:19 -0400)]
AMDGPU/GlobalISel: Ensure subreg is valid when selecting G_UNMERGE_VALUES

Fixes verifier error with SGPR unmerges with 96-bit result types.

4 years ago[GlobalISel] Don't transform FSUB(-0, X) -> FNEG(X) in GlobalISel.
Cameron McInally [Tue, 4 Aug 2020 16:26:04 +0000 (11:26 -0500)]
[GlobalISel] Don't transform FSUB(-0, X) -> FNEG(X) in GlobalISel.

This patch stops unconditionally transforming FSUB(-0, X) into an FNEG(X) while building the MIR.

This corresponds with the SelectionDAGISel change in D84056.

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

4 years ago[lldb/Host] Upstream macOS TCC code
Jonas Devlieghere [Tue, 4 Aug 2020 16:17:56 +0000 (09:17 -0700)]
[lldb/Host] Upstream macOS TCC code

Upstream the code for dealing with TCC introduced in macOS Mojave. This
will make the debuggee instead of the debugger responsible for the
privileges it needs.

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

4 years ago[InstSimplify] refactor min/max folds with shared operand; NFC
Sanjay Patel [Tue, 4 Aug 2020 15:23:10 +0000 (11:23 -0400)]
[InstSimplify] refactor min/max folds with shared operand; NFC

4 years ago[docs] Mention LLVM_ENABLE_MODULES.
Florian Hahn [Thu, 5 Mar 2020 09:48:40 +0000 (09:48 +0000)]
[docs] Mention LLVM_ENABLE_MODULES.

4 years agoGlobalISel: Hack a test to avoid a bug introducing a verifier error
Matt Arsenault [Tue, 4 Aug 2020 13:19:30 +0000 (09:19 -0400)]
GlobalISel: Hack a test to avoid a bug introducing a verifier error

There seems to be an unrelated CSEMIRBuilder bug that was causing
expensive checks failures in this case. Hack the test to avoid this
problem for now until that's fixed.

4 years ago[llvm-symbolizer] Switch command line parsing from llvm::cl to OptTable
Fangrui Song [Tue, 4 Aug 2020 15:51:24 +0000 (08:51 -0700)]
[llvm-symbolizer] Switch command line parsing from llvm::cl to OptTable

for the advantage outlined by D83639 ([OptTable] Support grouped short options)

Some behavior changes:

* -i={0,false} is removed. Use --no-inlines instead.
* --demangle={0,false} is removed. Use --no-demangle instead
* -untag-addresses={0,false} is removed. Use --no-untag-addresses instead

Added a higher level API OptTable::parseArgs which handles optional
initial options populated from an environment variable, expands response
files recursively, and parses options.

Reviewed By: jhenderson

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

4 years ago[OpenMP] Don't use MSVC workaround with MinGW
AndreyChurbanov [Tue, 4 Aug 2020 15:48:25 +0000 (18:48 +0300)]
[OpenMP] Don't use MSVC workaround with MinGW

Patch by mati865@gmail.com

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

4 years ago[clang][BPF] support type exist/size and enum exist/value relocations
Yonghong Song [Wed, 29 Jul 2020 23:54:29 +0000 (16:54 -0700)]
[clang][BPF] support type exist/size and enum exist/value relocations

This patch added the following additional compile-once
run-everywhere (CO-RE) relocations:
  - existence/size of typedef, struct/union or enum type
  - enum value and enum value existence

These additional relocations will make CO-RE bpf programs more
adaptive for potential kernel internal data structure changes.

For existence/size relocations, the following two code patterns
are supported:
  1. uint32_t __builtin_preserve_type_info(*(<type> *)0, flag);
  2. <type> var;
     uint32_t __builtin_preserve_field_info(var, flag);
flag = 0 for existence relocation and flag = 1 for size relocation.

For enum value existence and enum value relocations, the following code
pattern is supported:
  uint64_t __builtin_preserve_enum_value(*(<enum_type> *)<enum_value>,
                                         flag);
flag = 0 means existence relocation and flag = 1 for enum value.
relocation. In the above <enum_type> can be an enum type or
a typedef to enum type. The <enum_value> needs to be an enumerator
value from the same enum type. The return type is uint64_t to
permit potential 64bit enumerator values.

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