OSDN Git Service

android-x86/external-llvm.git
6 years agoRemove lambda default argument to fix gcc pedantic warning.
Simon Pilgrim [Wed, 15 Aug 2018 12:32:09 +0000 (12:32 +0000)]
Remove lambda default argument to fix gcc pedantic warning.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339767 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[yaml2obj] - Teach tool to produce SHT_GROUP section with a custom type.
George Rimar [Wed, 15 Aug 2018 11:43:00 +0000 (11:43 +0000)]
[yaml2obj] - Teach tool to produce SHT_GROUP section with a custom type.

Currently, it is possible to use yaml2obj for producing SHT_GROUP sections
of type GRP_COMDAT. For LLD test case I need to produce an object with
a broken (different from GRP_COMDAT) type.

The patch teaches tool to do such things.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339764 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[TargetLowering] Minor cleanup of TargetLowering::BuildSDIV. NFCI.
Simon Pilgrim [Wed, 15 Aug 2018 11:11:05 +0000 (11:11 +0000)]
[TargetLowering] Minor cleanup of TargetLowering::BuildSDIV. NFCI.

Pull out some types to match layout in TargetLowering::BuildUDIV. Early step towards adding non-uniform vector support.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339763 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[UnJ] Rename hasInvariantIterationCount to hasIterationCountInvariantInParent NFC
David Green [Wed, 15 Aug 2018 10:59:41 +0000 (10:59 +0000)]
[UnJ] Rename hasInvariantIterationCount to hasIterationCountInvariantInParent NFC

This hopefully describes the API of the function more precisely.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339762 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[X86][SSE] Add sdiv by nonuniform constant vector tests
Simon Pilgrim [Wed, 15 Aug 2018 10:59:29 +0000 (10:59 +0000)]
[X86][SSE] Add sdiv by nonuniform constant vector tests

Tests cover each TargetLowering::BuildSDIV path separately plus combos

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339761 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[X86] Add sibling-call test cases
Aleksandr Urakov [Wed, 15 Aug 2018 10:54:06 +0000 (10:54 +0000)]
[X86] Add sibling-call test cases

This commit adds new sibling-call test cases, so it will be possible to see
how these test cases will be changed after applying D45653.
See D45653 for details.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339760 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[TargetLowering] Minor refactor to TargetLowering::BuildUDIV to merge scalar/vector...
Simon Pilgrim [Wed, 15 Aug 2018 10:11:13 +0000 (10:11 +0000)]
[TargetLowering] Minor refactor to TargetLowering::BuildUDIV to merge scalar/vector magic value collection. NFCI.

Use the same ISD::matchUnaryPredicate pattern that was used in D50392.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339758 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[DagCombiner] Don't bother adding to the work list if TLI.BuildSDIVPow2 failed. NFCI.
Simon Pilgrim [Wed, 15 Aug 2018 10:02:54 +0000 (10:02 +0000)]
[DagCombiner] Don't bother adding to the work list if TLI.BuildSDIVPow2 failed. NFCI.

Matches the code in BuildSDIV/BuildUDIV

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339757 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[TargetLowering] Add support for non-uniform vectors to BuildExactSDIV
Simon Pilgrim [Wed, 15 Aug 2018 09:35:12 +0000 (09:35 +0000)]
[TargetLowering] Add support for non-uniform vectors to BuildExactSDIV

This patch refactors the existing BuildExactSDIV implementation to support non-uniform constant vector denominators.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339756 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[ARM] Allow signed icmps in ARMCodeGenPrepare
Sam Parker [Wed, 15 Aug 2018 08:23:03 +0000 (08:23 +0000)]
[ARM] Allow signed icmps in ARMCodeGenPrepare

Treat signed icmps as 'sinks', allowing them to be in the use-def
tree, enabling more promotions to be performed. As a sink, any
promoted incoming values need to be truncated before being used by
the signed icmp.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339755 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[ARM] Allow pointer values in ARMCodeGenPrepare
Sam Parker [Wed, 15 Aug 2018 07:52:35 +0000 (07:52 +0000)]
[ARM] Allow pointer values in ARMCodeGenPrepare

Add pointers to the list of allowed types, but don't try to promote
them. Also fixed a bug with the promotion of undef values, so a new
value is now created instead of mutating in place. We also now only
promote if there's an instruction in the use-def chains other than
the icmp, sinks and sources.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339754 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[AliasSetTracker] Do not treat experimental_guard intrinsic as memory writing instruction
Max Kazantsev [Wed, 15 Aug 2018 06:21:02 +0000 (06:21 +0000)]
[AliasSetTracker] Do not treat experimental_guard intrinsic as memory writing instruction

The `experimental_guard` intrinsic has memory write semantics to model the thread-exiting
logic, but does not do any actual writes to memory. Currently, `AliasSetTracker` treats it as a
normal memory write. As result, a loop-invariant load cannot be hoisted out of loop because
the guard may possibly alias with it.

This patch makes `AliasSetTracker` so that it doesn't treat guards as memory writes.

Differential Revision: https://reviews.llvm.org/D50497
Reviewed By: reames

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339753 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[NFC] Refactoring of LoopSafetyInfo, step 1
Max Kazantsev [Wed, 15 Aug 2018 05:55:43 +0000 (05:55 +0000)]
[NFC] Refactoring of LoopSafetyInfo, step 1

Turn structure into class, encapsulate methods, add clarifying comments.

Differential Revision: https://reviews.llvm.org/D50693
Reviewed By: reames

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339752 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[NFC] Add sanitizing assertion to ICF tracker
Max Kazantsev [Wed, 15 Aug 2018 05:50:38 +0000 (05:50 +0000)]
[NFC] Add sanitizing assertion to ICF tracker

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339751 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[NFC][LICM] Make hoist method void
Max Kazantsev [Wed, 15 Aug 2018 02:49:12 +0000 (02:49 +0000)]
[NFC][LICM] Make hoist method void

Method hoist always returns true. This patch makes it void.

Differential Revision: https://reviews.llvm.org/D50696
Reviewed By: hiraditya

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339750 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[X86] Change legacy SSE scalar fp to integer intrinsics to use specific ISD opcodes...
Craig Topper [Wed, 15 Aug 2018 01:23:00 +0000 (01:23 +0000)]
[X86] Change legacy SSE scalar fp to integer intrinsics to use specific ISD opcodes instead of keeping as intrinsics. Unify SSE and AVX512 isel patterns.

AVX512 added new versions of these intrinsics that take a rounding mode. If the rounding mode is 4 the new intrinsics are equivalent to the old intrinsics.

The AVX512 intrinsics were being lowered to ISD opcodes, but the legacy SSE intrinsics were left as intrinsics. This resulted in the AVX512 instructions needing separate patterns for the ISD opcodes and the legacy SSE intrinsics.

Now we convert SSE intrinsics and AVX512 intrinsics with rounding mode 4 to the same ISD opcode so we can share the isel patterns.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339749 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[SDAG] Update the AVR backend for the SelectionDAG API changes in
Chandler Carruth [Wed, 15 Aug 2018 01:22:50 +0000 (01:22 +0000)]
[SDAG] Update the AVR backend for the SelectionDAG API changes in
r339740, fixing the build for this target.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339748 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[hwasan] Add a basic API.
Evgeniy Stepanov [Wed, 15 Aug 2018 00:39:35 +0000 (00:39 +0000)]
[hwasan] Add a basic API.

Summary:
Add user tag manipulation functions:
  __hwasan_tag_memory
  __hwasan_tag_pointer
  __hwasan_print_shadow (very simple and ugly, for now)

Reviewers: vitalybuka, kcc

Subscribers: kubamracek, hiraditya, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339746 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[WebAssembly] SIMD Splats
Derek Schuff [Wed, 15 Aug 2018 00:30:27 +0000 (00:30 +0000)]
[WebAssembly] SIMD Splats

Implement and test SIMD splat ops.

Patch by Thomas Lively

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339744 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[SDAG] Remove the reliance on MI's allocation strategy for
Chandler Carruth [Tue, 14 Aug 2018 23:30:32 +0000 (23:30 +0000)]
[SDAG] Remove the reliance on MI's allocation strategy for
`MachineMemOperand` pointers attached to `MachineSDNodes` and instead
have the `SelectionDAG` fully manage the memory for this array.

Prior to this change, the memory management was deeply confusing here --
The way the MI was built relied on the `SelectionDAG` allocating memory
for these arrays of pointers using the `MachineFunction`'s allocator so
that the raw pointer to the array could be blindly copied into an
eventual `MachineInstr`. This creates a hard coupling between how
`MachineInstr`s allocate their array of `MachineMemOperand` pointers and
how the `MachineSDNode` does.

This change is motivated in large part by a change I am making to how
`MachineFunction` allocates these pointers, but it seems like a layering
improvement as well.

This would run the risk of increasing allocations overall, but I've
implemented an optimization that should avoid that by storing a single
`MachineMemOperand` pointer directly instead of allocating anything.
This is expected to be a net win because the vast majority of uses of
these only need a single pointer.

As a side-effect, this makes the API for updating a `MachineSDNode` and
a `MachineInstr` reasonably different which seems nice to avoid
unexpected coupling of these two layers. We can map between them, but we
shouldn't be *surprised* at where that occurs. =]

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339740 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[WebAssembly] Delete a specific push number from test expectations
Heejin Ahn [Tue, 14 Aug 2018 22:14:51 +0000 (22:14 +0000)]
[WebAssembly] Delete a specific push number from test expectations

Summary:
This shouldn't have been a specific number but rather a regex. This was
a part of rL339474 which got reverted.

Reviewers: aardappel

Subscribers: dschuff, sbc100, jgravelle-google, sunfish, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339736 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[FPEnv] Scalarize StrictFP vector operations
Cameron McInally [Tue, 14 Aug 2018 22:13:11 +0000 (22:13 +0000)]
[FPEnv] Scalarize StrictFP vector operations

Add a helper function to scalarize constrained FP operations as needed.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339735 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[ARM] Make PerformSHLSimplify add nodes to the DAG worklist correctly.
Eli Friedman [Tue, 14 Aug 2018 22:10:25 +0000 (22:10 +0000)]
[ARM] Make PerformSHLSimplify add nodes to the DAG worklist correctly.

Intentionally excluding nodes from the DAGCombine worklist is likely to
lead to weird optimizations and infinite loops, so it's generally a bad
idea.

To avoid the infinite loops, fix DAGCombine to use the
isDesirableToCommuteWithShift target hook before performing the
transforms in question, and implement the target hook in the ARM backend
disable the transforms in question.

Fixes https://bugs.llvm.org/show_bug.cgi?id=38530 . (I don't have a
reduced testcase for that bug. But we should have sufficient test
coverage for PerformSHLSimplify given that we're not playing weird
tricks with the worklist. I can try to bugpoint it if necessary,
though.)

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339734 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[SanitizerCoverage] Add associated metadata to PC guards.
Matt Morehouse [Tue, 14 Aug 2018 22:04:34 +0000 (22:04 +0000)]
[SanitizerCoverage] Add associated metadata to PC guards.

Summary:
Without this metadata LLD strips unused PC table entries
but won't strip unused guards.  This metadata also seems
to influence the linker to change the ordering in the PC
guard section to match that of the PC table section.

The libFuzzer runtime library depends on the ordering
of the PC table and PC guard sections being the same.  This
is not generally guaranteed, so we may need to redesign
PC tables/guards/counters in the future.

Reviewers: eugenis

Reviewed By: eugenis

Subscribers: kcc, hiraditya, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339733 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoRemove vestiges of configure buildsystem
Stephen Kelly [Tue, 14 Aug 2018 21:25:49 +0000 (21:25 +0000)]
Remove vestiges of configure buildsystem

Subscribers: mgorny, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339729 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoAdd proper headers in CFGUpdate.h and add CFGDiff.h in the list of delayed headers...
Alina Sbirlea [Tue, 14 Aug 2018 20:49:19 +0000 (20:49 +0000)]
Add proper headers in CFGUpdate.h and add CFGDiff.h in the list of delayed headers for LLVM_intrinsic_gen.

Summary:
Fix module build after r339694.
Add headers needed in CFGUpdate.h.
Add CFGDiff.h in the list of delayed headers for LLVM_intrinsic_gen.
Up for post-commit review.

Subscribers: sanjoy, jlebar, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339724 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoNFC: Clarify comment in loop vectorization legality
Anna Thomas [Tue, 14 Aug 2018 20:25:13 +0000 (20:25 +0000)]
NFC: Clarify comment in loop vectorization legality

Clarifying the comment about PSCEV and external IV users by referencing
the bug in question.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339722 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[DebugInfoMetadata] Added DIFlags interface in DIBasicType.
Adrian Prantl [Tue, 14 Aug 2018 19:35:34 +0000 (19:35 +0000)]
[DebugInfoMetadata] Added DIFlags interface in DIBasicType.

Flags in DIBasicType will be used to pass attributes used in
DW_TAG_base_type, such as DW_AT_endianity.

Patch by Chirag Patel!

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339714 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[InstCombine] fix typos in tests; NFC
Sanjay Patel [Tue, 14 Aug 2018 19:13:07 +0000 (19:13 +0000)]
[InstCombine] fix typos in tests; NFC

See D50036.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339713 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[WebAssembly] SIMD encoding tests
Heejin Ahn [Tue, 14 Aug 2018 19:10:50 +0000 (19:10 +0000)]
[WebAssembly] SIMD encoding tests

Modifies existing SIMD tests to also check that SIMD instructions are
lowered to the expected bytes. This CL depends on D50597.

Reviewers: aheejin

Subscribers: sunfish, jgravelle-google, sbc100, llvm-commits

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

Patch by Thomas Lively (tlively)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339712 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[InstCombine] add tests for pow->sqrt; NFC
Sanjay Patel [Tue, 14 Aug 2018 19:05:37 +0000 (19:05 +0000)]
[InstCombine] add tests for pow->sqrt; NFC

D50036 should fix the missed optimizations.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339711 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[WebAssembly] Fix encoding of non-SIMD vector-typed instructions
Heejin Ahn [Tue, 14 Aug 2018 19:03:36 +0000 (19:03 +0000)]
[WebAssembly] Fix encoding of non-SIMD vector-typed instructions

Previously SIMD_I was the same as a normal instruction except for the
addition of a HasSIM128 predicate. However, rL339186 changed the
encoding of SIMD_I instructions to automatically contain the SIMD
prefix byte. This broke the encoding of non-SIMD vector-typed
instructions, which had instantiated SIMD_I. This CL corrects this
error.

Reviewers: aheejin

Subscribers: sunfish, jgravelle-google, sbc100, llvm-commits

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

Patch by Thomas Lively (tlively)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339710 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[MS Demangler] Fix some minor formatting bugs.
Zachary Turner [Tue, 14 Aug 2018 18:54:28 +0000 (18:54 +0000)]
[MS Demangler] Fix some minor formatting bugs.

1) We print __restrict twice on member pointers.  This is fixed
   and relevant tests are re-enabled.

2) Several tests were disabled because of printing slightly
   different output than undname.  These were confirmed to be
   bugs in undname, so we just re-enable the tests.

3) The test for printing reference temporaries is re-enabled.  This
   is a clang mangling extension, so we have some flexibility with
   how we demangle it.  The output currently looks fine, so we just
   re-enable the test with no fixes.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339708 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[WebAssembly] SIMD extract_lane
Heejin Ahn [Tue, 14 Aug 2018 18:53:27 +0000 (18:53 +0000)]
[WebAssembly] SIMD extract_lane

Implement instruction selection for all versions of the extract_lane
instruction. Use explicit sext/zext to differentiate between
extract_lane_s and extract_lane_u for applicable types, otherwise
default to extract_lane_u.

Reviewers: aheejin

Subscribers: sunfish, jgravelle-google, sbc100, llvm-commits

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

Patch by Thomas Lively (tlively)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339707 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[Tablegen][MCInstPredicate] Removed redundant template argument from class TIIPredica...
Andrea Di Biagio [Tue, 14 Aug 2018 18:36:54 +0000 (18:36 +0000)]
[Tablegen][MCInstPredicate] Removed redundant template argument from class TIIPredicate, and implemented verification rules for TIIPredicates.

This patch removes redundant template argument `TargetName` from TIIPredicate.
Tablegen can always infer the target name from the context. So we don't need to
force users of TIIPredicate to always specify it.

This allows us to better modularize the tablegen class hierarchy for the
so-called "function predicates". class FunctionPredicateBase has been added; it
is currently used as a building block for TIIPredicates. However, I plan to
reuse that class to model other function predicate classes too (i.e. not just
TIIPredicates). For example, this can be a first step towards implementing
proper support for dependency breaking instructions in tablegen.

This patch also adds a verification step on TIIPredicates in tablegen.
We cannot have multiple TIIPredicates with the same name. Otherwise, this will
cause build errors later on, when tablegen'd .inc files are included by cpp
files and then compiled.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339706 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[LV] Teach about non header phis that have uses outside the loop
Anna Thomas [Tue, 14 Aug 2018 18:22:19 +0000 (18:22 +0000)]
[LV] Teach about non header phis that have uses outside the loop

Summary:
This patch teaches the loop vectorizer to vectorize loops with non
header phis that have have outside uses.  This is because the iteration
dependence distance for these phis can be widened upto VF (similar to
how we do for induction/reduction) if they do not have a cyclic
dependence with header phis. When identifying reduction/induction/first
order recurrence header phis, we already identify if there are any cyclic
dependencies that prevents vectorization.

The vectorizer is taught to extract the last element from the vectorized
phi and update the scalar loop exit block phi to contain this extracted
element from the vector loop.

This patch can be extended to vectorize loops where instructions other
than phis have outside uses.

Reviewers: Ayal, mkuper, mssimpso, efriedma

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339703 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoRevert "[DebugInfo] Generate DWARF debug information for labels. (Fix leak problems)"
Bruno Cardoso Lopes [Tue, 14 Aug 2018 17:54:41 +0000 (17:54 +0000)]
Revert "[DebugInfo] Generate DWARF debug information for labels. (Fix leak problems)"

This reverts commit cb8c5e417d55141f3f079a8a876e786f44308336 / r339676.

This causing a test to fail in http://green.lab.llvm.org/green/job/clang-stage1-configure-RA/48406/

    LLVM :: DebugInfo/Generic/debug-label.ll

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339700 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[GraphDiff] Make InverseGraph a property of a GraphDiff.
Alina Sbirlea [Tue, 14 Aug 2018 17:43:24 +0000 (17:43 +0000)]
[GraphDiff] Make InverseGraph a property of a GraphDiff.

Summary:
Treating a graph in reverse is a property of the GraphDiff and should instead be a template argument, just like IsPostDom is one for DomTrees.
If it's just an argument to all methods, we could have mismatches between the constructor of the GraphDiff which may reverse the updates when filtering them, and the calls retrieving the filtered delete/insert updates.
Also, since this will be used in IDF, where we're using a DomTree, this creates a cleaner interface for the GraphTraits to use the existing template argument of DomTreeBase.

Separate patch from the one adding GraphDiff, so get a clear diff of what changed.

Reviewers: timshen, kuhar

Subscribers: sanjoy, llvm-commits, jlebar

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339699 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[X86][SSE] Avoid duplicate shuffle input sources in combineX86ShufflesRecursively
Simon Pilgrim [Tue, 14 Aug 2018 17:22:37 +0000 (17:22 +0000)]
[X86][SSE] Avoid duplicate shuffle input sources in combineX86ShufflesRecursively

rL339686 added the case where a faux shuffle might have repeated shuffle inputs coming from either side of the OR().

This patch improves the insertion of the inputs into the source ops lists to account for this, as well as making it trivial to add support for shuffles with more than 2 inputs in the future.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339696 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[DomTree] Cleanup Update and LegalizeUpdate API moved to Support header.
Alina Sbirlea [Tue, 14 Aug 2018 17:12:30 +0000 (17:12 +0000)]
[DomTree] Cleanup Update and LegalizeUpdate API moved to Support header.

Summary:
Clean-up following D50479.
Make Update and LegalizeUpdate refer to the utilities in Support/CFGUpdate.

Reviewers: kuhar

Subscribers: sanjoy, jlebar, mgrang, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339694 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[NFC] Tests for select with binop fold - FP opcodes
David Bolvansky [Tue, 14 Aug 2018 17:03:47 +0000 (17:03 +0000)]
[NFC] Tests for select with binop fold - FP opcodes

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339692 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoExpose CFG Update struct. Define GraphTraits to get children given a snapshot CFG.
Alina Sbirlea [Tue, 14 Aug 2018 16:44:28 +0000 (16:44 +0000)]
Expose CFG Update struct. Define GraphTraits to get children given a snapshot CFG.

Summary:
Certain passes or analysis need to view a CFG snapshot rather than the actual CFG. This patch provides GraphTraits to offer such a view.

The patch defines GraphTraits for BasicBlock* and Inverse<BasicBlock*> to provide CFG successors and predecessors based on a list of CFG updates.

An Update is defined as a triple {InsertOrDeleteKind, BlockStartOfEdge, BlockEndOfEdge}.
A GraphDiff is defined as a list of Updates that has been preprocessed to treat the CFG as a graph rather than a multi-graph. As such, there can only exist a single Update given two nodes. All duplicates will be filtered and Insert/Delete edges that cancel out will be ignored.
The methods GraphDiff exposes are:
- Determine if an existing child needs to be ignored, i.e. an Update exists in the correct direction to assume the removal of that edge.
- Return a list of new children to be considered, i.e. an Update exists in the correct direction for each child in the list to assume the insertion of that edge.

Reviewers: timshen, kuhar, chandlerc

Subscribers: sanjoy, jlebar, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339689 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[DAG] Avoid redundant chain transversal in store merge cycle check. NFCI.
Nirav Dave [Tue, 14 Aug 2018 16:20:43 +0000 (16:20 +0000)]
[DAG] Avoid redundant chain transversal in store merge cycle check. NFCI.

Patch by Henric Karlsson.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339688 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[X86][SSE] Add shuffle combine support for OR(PSHUFB,PSHUFB) style patterns.
Simon Pilgrim [Tue, 14 Aug 2018 16:00:05 +0000 (16:00 +0000)]
[X86][SSE] Add shuffle combine support for OR(PSHUFB,PSHUFB) style patterns.

If each element is zero from one (or both) inputs then we can combine these into a single shuffle mask.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339686 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[X86][SSE] Add shuffle combine tests for OR(PSHUFB,PSHUFB) style patterns.
Simon Pilgrim [Tue, 14 Aug 2018 15:21:26 +0000 (15:21 +0000)]
[X86][SSE] Add shuffle combine tests for OR(PSHUFB,PSHUFB) style patterns.

We generate these shuffle patterns but we fail to combine them.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339684 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[InstCombine] regenerate checks; NFC
Sanjay Patel [Tue, 14 Aug 2018 15:21:13 +0000 (15:21 +0000)]
[InstCombine] regenerate checks; NFC

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339683 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[Inliner] add inliner stats to new pm version of inliner
Fedor Sergeev [Tue, 14 Aug 2018 15:19:14 +0000 (15:19 +0000)]
[Inliner] add inliner stats to new pm version of inliner

Increment existing NumInlined and NumDeleted stats in InlinerPass::run.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339682 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[InstCombine] regenerate checks; NFC
Sanjay Patel [Tue, 14 Aug 2018 15:18:52 +0000 (15:18 +0000)]
[InstCombine] regenerate checks; NFC

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339681 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[X86][SSE] Generalize lowerVectorShuffleAsBlendOfPSHUFBs to work with any vXi8 type.
Simon Pilgrim [Tue, 14 Aug 2018 14:00:14 +0000 (14:00 +0000)]
[X86][SSE] Generalize lowerVectorShuffleAsBlendOfPSHUFBs to work with any vXi8 type.

We still only use this for v16i8, but this cleans up the code to support v32i8/v64i8 sometime in the future.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339679 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[DebugInfo] Generate DWARF debug information for labels. (Fix leak problems)
Hsiangkai Wang [Tue, 14 Aug 2018 13:50:59 +0000 (13:50 +0000)]
[DebugInfo] Generate DWARF debug information for labels. (Fix leak problems)

There are two forms for label debug information in DWARF format.

1. Labels in a non-inlined function:

DW_TAG_label
  DW_AT_name
  DW_AT_decl_file
  DW_AT_decl_line
  DW_AT_low_pc

2. Labels in an inlined function:

DW_TAG_label
  DW_AT_abstract_origin
  DW_AT_low_pc

We will collect label information from DBG_LABEL. Before every DBG_LABEL,
we will generate a temporary symbol to denote the location of the label.
The symbol could be used to get DW_AT_low_pc afterwards. So, we create a
mapping between 'inlined label' and DBG_LABEL MachineInstr in DebugHandlerBase.
The DBG_LABEL in the mapping is used to query the symbol before it.

The AbstractLabels in DwarfCompileUnit is used to process labels in inlined
functions.

We also keep a mapping between scope and labels in DwarfFile to help to
generate correct tree structure of DIEs.

It also generates label debug information under global isel.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339676 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[GlobalISel][IRTranslator] Fix a bug in handling repeating struct types during argume...
Amara Emerson [Tue, 14 Aug 2018 12:04:25 +0000 (12:04 +0000)]
[GlobalISel][IRTranslator] Fix a bug in handling repeating struct types during argument lowering.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339674 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[TableGen] Pass string/vector types by const reference (PR37666). NFCI
Simon Pilgrim [Tue, 14 Aug 2018 11:17:38 +0000 (11:17 +0000)]
[TableGen] Pass string/vector types by const reference (PR37666). NFCI

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339670 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoFix MSVC "compiler limit: blocks nested too deeply" error. NFCI.
Simon Pilgrim [Tue, 14 Aug 2018 10:04:14 +0000 (10:04 +0000)]
Fix MSVC "compiler limit: blocks nested too deeply" error. NFCI.

MSVC only accepts if-else chains up to 127 blocks long. I've had to merge a number of intrinsic cases together to get back below this limit, resulting in some duplication of string matches; this shouldn't cause any notable increase in runtime (and even then only for old IR, nothing that clang currently emits).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339666 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[X86] Constant folding of adds/subs intrinsics
Tomasz Krupa [Tue, 14 Aug 2018 09:04:01 +0000 (09:04 +0000)]
[X86] Constant folding of adds/subs intrinsics

Summary: This adds constant folding of signed add/sub with saturation intrinsics.

Reviewers: craig.topper, spatel, RKSimon, chandlerc, efriedma

Reviewed By: craig.topper

Subscribers: rnk, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339659 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[RISCV] Fix incorrect use of MCInstBuilder
Roger Ferrer Ibanez [Tue, 14 Aug 2018 08:30:42 +0000 (08:30 +0000)]
[RISCV] Fix incorrect use of MCInstBuilder

This is a fix for r339314.

MCInstBuilder uses the named parameter idiom and an 'operator MCInst&' to ease
the creation of MCInsts. As the object of MCInstBuilder owns the MCInst is
manipulating, the lifetime of the MCInst is bound to that of MCInstBuilder.

In r339314 I bound a reference to the MCInst in an initializer. The
temporary of MCInstBuilder (and also its MCInst) is destroyed at the end of
the declaration leading to a dangling reference.

Fix this by using MCInstBuilder inside an argument of a function call.
Temporaries in function calls are destroyed in the enclosing full expression,
so the the reference to MCInst is still valid when emitToStreamer executes.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339654 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoTest commit: fix punctuation
Chih-Mao Chen [Tue, 14 Aug 2018 08:08:39 +0000 (08:08 +0000)]
Test commit: fix punctuation

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339652 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[X86] Lowering addus/subus intrinsics to native IR
Tomasz Krupa [Tue, 14 Aug 2018 08:00:56 +0000 (08:00 +0000)]
[X86] Lowering addus/subus intrinsics to native IR

Summary: This revision improves previous version (rL330322) which has been reverted due to crashes.

This is the patch that lowers x86 intrinsics to native IR
in order to enable optimizations. The patch also includes folding
of previously missing saturation patterns so that IR emits the same
machine instructions as the intrinsics.

Reviewers: craig.topper, spatel, RKSimon

Reviewed By: craig.topper

Subscribers: mike.dvoretsky, DavidKreitzer, sroland, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339650 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[ARM] ParallelDSP: add option to enable/disable the pass
Sjoerd Meijer [Tue, 14 Aug 2018 07:43:49 +0000 (07:43 +0000)]
[ARM] ParallelDSP: add option to enable/disable the pass

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339645 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[NFC] Modify comment to make it more precise
Max Kazantsev [Tue, 14 Aug 2018 07:40:08 +0000 (07:40 +0000)]
[NFC] Modify comment to make it more precise

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339644 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[NFC] Add comprehensive test of AliasSetTracker with guards
Max Kazantsev [Tue, 14 Aug 2018 06:37:39 +0000 (06:37 +0000)]
[NFC] Add comprehensive test of AliasSetTracker with guards

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339643 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[ThinLTO] Fix printing of WPD remarks
Teresa Johnson [Tue, 14 Aug 2018 03:00:16 +0000 (03:00 +0000)]
[ThinLTO] Fix printing of WPD remarks

Summary:
When WPD is performed in a ThinLTO backend, the function may be created
if it isn't already in that module. Module::getOrInsertFunction may
add a bitcast, in which case the returned Constant is not a Function and
doesn't have a name. Invoke stripPointerCasts() on the returned value
where we access its name.

Reviewers: pcc

Subscribers: mehdi_amini, inglorion, eraman, steven_wu, dexonsmith, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339640 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[CMake] Split -gx strip flag into -g -x
Petr Hosek [Tue, 14 Aug 2018 02:00:21 +0000 (02:00 +0000)]
[CMake] Split -gx strip flag into -g -x

llvm-strip doesn't handle -gx spelling, so we need to split these
as two separate flags.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339639 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[ThinLTO] Handle optional args in assembly format for ConstVCalls
Teresa Johnson [Tue, 14 Aug 2018 01:49:33 +0000 (01:49 +0000)]
[ThinLTO] Handle optional args in assembly format for ConstVCalls

Summary:
The AsmWriter was only writing the Args for a ConstVCall if it was
non-empty, however, the LLParser was always expecting it. To aid
in making it optional, surround the ConstVCall VFuncId and Args in
parentheses when writing, then make the Args optional when reading.

Reviewers: pcc

Subscribers: mehdi_amini, inglorion, eraman, steven_wu, dexonsmith, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339637 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[BasicAA] Don't assume tail calls with byval don't alias allocas
Reid Kleckner [Tue, 14 Aug 2018 01:24:35 +0000 (01:24 +0000)]
[BasicAA] Don't assume tail calls with byval don't alias allocas

Summary:
Calls marked 'tail' cannot read or write allocas from the current frame
because the current frame might be destroyed by the time they run.
However, a tail call may use an alloca with byval. Calling with byval
copies the contents of the alloca into argument registers or stack
slots, so there is no lifetime issue. Tail calls never modify allocas,
so we can return just ModRefInfo::Ref.

Fixes PR38466, a longstanding bug.

Reviewers: hfinkel, nlewycky, gbiv, george.burgess.iv

Subscribers: hiraditya, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339636 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoRevert "[WebAssembly] Added default stack-only instruction mode for MC."
Wouter van Oortmerssen [Mon, 13 Aug 2018 23:12:49 +0000 (23:12 +0000)]
Revert "[WebAssembly] Added default stack-only instruction mode for MC."

This reverts commit 917a99b71ce21c975be7bfbf66f4040f965d9f3c.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339630 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[Support] NFC: Allow modifying access/modification times independently in sys::fs...
Jordan Rupprecht [Mon, 13 Aug 2018 23:03:45 +0000 (23:03 +0000)]
[Support] NFC: Allow modifying access/modification times independently in sys::fs::setLastModificationAndAccessTime.

Summary:
Add an overload to sys::fs::setLastModificationAndAccessTime that allows setting last access and modification times separately. This will allow tools to use this API when they want to preserve both the access and modification times from an input file, which may be different.

Also note that both the POSIX (futimens/futimes) and Windows (SetFileTime) APIs take the two timestamps in the order of (1) access (2) modification time, so this renames the method to "setLastAccessAndModificationTime" to make it clear which timestamp is which.

For existing callers, the 1-arg overload just sets both timestamps to the same thing.

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339628 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[AST] Minor formatting cleanup [NFC]
Philip Reames [Mon, 13 Aug 2018 22:34:14 +0000 (22:34 +0000)]
[AST] Minor formatting cleanup [NFC]

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339627 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[AST] Cleanup code by using MemoryLocation utility [NFC]
Philip Reames [Mon, 13 Aug 2018 22:25:16 +0000 (22:25 +0000)]
[AST] Cleanup code by using MemoryLocation utility [NFC]

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339625 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[X86] Don't ignore 0x66 prefix on relative jumps in 64-bit mode. Fix opcode selection...
Craig Topper [Mon, 13 Aug 2018 22:06:28 +0000 (22:06 +0000)]
[X86] Don't ignore 0x66 prefix on relative jumps in 64-bit mode. Fix opcode selection of relative jumps in 16-bit mode. Treat jno/jo like other jcc instructions.

The behavior in 64-bit mode is different between Intel and AMD CPUs. Intel ignores the 0x66 prefix. AMD does not. objump doesn't ignore the 0x66 prefix. Since LLVM aims to match objdump behavior, we should do the same.

While I was trying to fix this I had change brtarget16/32 to use ENCODING_IW/ID instead of ENCODING_Iv to get the 0x66+REX.W case to act sort of sanely. It's still wrong, but that's a problem for another day.

The change in encoding exposed the fact that 16-bit mode disassembly of relative jumps was creating JMP_4 with a 2 byte immediate. It should have been JMP_2. From just printing you can't tell the difference, but if you dumped the encoding it wouldn't have matched what we started with.

While fixing that, it exposed that jo/jno opcodes were missing from the switch that this patch deleted and there were no test cases for them.

Fixes PR38537.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339622 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[InstCombine] Re-land: Optimize redundant 'signed truncation check pattern'.
Roman Lebedev [Mon, 13 Aug 2018 21:54:37 +0000 (21:54 +0000)]
[InstCombine] Re-land: Optimize redundant 'signed truncation check pattern'.

Summary:
This comes with `Implicit Conversion Sanitizer - integer sign change` (D50250):
```
signed char test(unsigned int x) { return x; }
```
`clang++ -fsanitize=implicit-conversion -S -emit-llvm -o - /tmp/test.cpp -O3`
* Old: {F6904292}
* With this patch: {F6904294}

General pattern:
  X & Y

Where `Y` is checking that all the high bits (covered by a mask `4294967168`)
are uniform, i.e.  `%arg & 4294967168`  can be either  `4294967168`  or  `0`
Pattern can be one of:
  %t = add        i32 %arg,    128
  %r = icmp   ult i32 %t,      256
Or
  %t0 = shl       i32 %arg,    24
  %t1 = ashr      i32 %t0,     24
  %r  = icmp  eq  i32 %t1,     %arg
Or
  %t0 = trunc     i32 %arg  to i8
  %t1 = sext      i8  %t0   to i32
  %r  = icmp  eq  i32 %t1,     %arg
This pattern is a signed truncation check.

And `X` is checking that some bit in that same mask is zero.
I.e. can be one of:
  %r = icmp sgt i32   %arg,    -1
Or
  %t = and      i32   %arg,    2147483648
  %r = icmp eq  i32   %t,      0

Since we are checking that all the bits in that mask are the same,
and a particular bit is zero, what we are really checking is that all the
masked bits are zero.
So this should be transformed to:
  %r = icmp ult i32 %arg, 128

The transform itself ended up being rather horrible, even though i omitted some cases.
Surely there is some infrastructure that can help clean this up that i missed?

https://rise4fun.com/Alive/3Ou

The initial commit (rL339610)
was reverted, since the first assert was being triggered.
The @positive_with_extra_and test now has coverage for that case.

Reviewers: spatel, craig.topper

Reviewed By: spatel

Subscribers: RKSimon, erichkeane, vsk, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339621 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[NFC][InstCombine] Add a test for D50465 that used to assert
Roman Lebedev [Mon, 13 Aug 2018 21:49:33 +0000 (21:49 +0000)]
[NFC][InstCombine] Add a test for D50465 that used to assert

This is valid to fold, too.
https://rise4fun.com/Alive/0lz

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339619 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[SimplifyLibCalls] don't drop fast-math-flags on trig reflection folds (retry r339608)
Sanjay Patel [Mon, 13 Aug 2018 21:49:19 +0000 (21:49 +0000)]
[SimplifyLibCalls] don't drop fast-math-flags on trig reflection folds (retry r339608)

Even though this code is below a function called optimizeFloatingPointLibCall(),
we apparently can't guarantee that we're dealing with FPMathOperators, so bail
out immediately if that's not true.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339618 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[llvm-objcopy] NFC: Fix minor formatting issues
Jordan Rupprecht [Mon, 13 Aug 2018 21:30:27 +0000 (21:30 +0000)]
[llvm-objcopy] NFC: Fix minor formatting issues

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339616 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoRevert "[InstCombine] Optimize redundant 'signed truncation check pattern'."
Roman Lebedev [Mon, 13 Aug 2018 20:46:22 +0000 (20:46 +0000)]
Revert "[InstCombine] Optimize redundant 'signed truncation check pattern'."

At least one buildbot was able to actually trigger that assert
on the top of the function. Will investigate.

This reverts commit r339610.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339612 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[InstCombine] Optimize redundant 'signed truncation check pattern'.
Roman Lebedev [Mon, 13 Aug 2018 20:33:08 +0000 (20:33 +0000)]
[InstCombine] Optimize redundant 'signed truncation check pattern'.

Summary:
This comes with `Implicit Conversion Sanitizer - integer sign change` (D50250):
```
signed char test(unsigned int x) { return x; }
```
`clang++ -fsanitize=implicit-conversion -S -emit-llvm -o - /tmp/test.cpp -O3`
* Old: {F6904292}
* With this patch: {F6904294}

General pattern:
  X & Y

Where `Y` is checking that all the high bits (covered by a mask `4294967168`)
are uniform, i.e.  `%arg & 4294967168`  can be either  `4294967168`  or  `0`
Pattern can be one of:
  %t = add        i32 %arg,    128
  %r = icmp   ult i32 %t,      256
Or
  %t0 = shl       i32 %arg,    24
  %t1 = ashr      i32 %t0,     24
  %r  = icmp  eq  i32 %t1,     %arg
Or
  %t0 = trunc     i32 %arg  to i8
  %t1 = sext      i8  %t0   to i32
  %r  = icmp  eq  i32 %t1,     %arg
This pattern is a signed truncation check.

And `X` is checking that some bit in that same mask is zero.
I.e. can be one of:
  %r = icmp sgt i32   %arg,    -1
Or
  %t = and      i32   %arg,    2147483648
  %r = icmp eq  i32   %t,      0

Since we are checking that all the bits in that mask are the same,
and a particular bit is zero, what we are really checking is that all the
masked bits are zero.
So this should be transformed to:
  %r = icmp ult i32 %arg, 128

https://rise4fun.com/Alive/3Ou

Reviewers: spatel, craig.topper

Reviewed By: spatel

Subscribers: RKSimon, erichkeane, vsk, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339610 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agorevert r339608 - [SimplifyLibCalls] don't drop fast-math-flags on trig reflection...
Sanjay Patel [Mon, 13 Aug 2018 20:20:38 +0000 (20:20 +0000)]
revert r339608 - [SimplifyLibCalls] don't drop fast-math-flags on trig reflection folds

Can't set the builder flags without knowing this is an FPMathOperator. I'll add a test
for that and try again.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339609 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[SimplifyLibCalls] don't drop fast-math-flags on trig reflection folds
Sanjay Patel [Mon, 13 Aug 2018 20:14:27 +0000 (20:14 +0000)]
[SimplifyLibCalls] don't drop fast-math-flags on trig reflection folds

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339608 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoNFC: Add a test to LV showing that reduction is not possible when reduction var is...
Anna Thomas [Mon, 13 Aug 2018 19:55:25 +0000 (19:55 +0000)]
NFC: Add a test to LV showing that reduction is not possible when reduction var is reset in the loop

Added a test case to reduction showing where it's illegal to identify
vectorize a loop.
Resetting the reduction var during loop iterations disallows us from
widening the dependency cycle to VF, thereby making it illegal to
vectorize the loop.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339605 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[SimplifyLibCalls] add reflection fold for -sin(-x) (PR38458)
Sanjay Patel [Mon, 13 Aug 2018 19:24:41 +0000 (19:24 +0000)]
[SimplifyLibCalls] add reflection fold for -sin(-x) (PR38458)

This is a very partial fix for the reported problem. I suspect
we do not get this fold in most motivating cases because most of
the time, the libcall would have been replaced by an intrinsic,
and that optimization is handled elsewhere...but maybe it should
be handled here?

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339604 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[InstCombine][NFC] Tests for 'signed truncation check' optimization
Roman Lebedev [Mon, 13 Aug 2018 18:51:09 +0000 (18:51 +0000)]
[InstCombine][NFC] Tests for 'signed truncation check' optimization

See D50465 for the actual opt itself.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339602 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[CodeGen] Fix assert in SelectionDAG::computeKnownBits
Scott Linder [Mon, 13 Aug 2018 18:44:21 +0000 (18:44 +0000)]
[CodeGen] Fix assert in SelectionDAG::computeKnownBits

Fix SelectionDAG::computeKnownBits asserting when handling EXTRACT_SUBVECTOR
when zero extending the demanded elements mask if it is already as long as the
source vector.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339600 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[InstCombine] add more tests for trig reflections; NFC (PR38458)
Sanjay Patel [Mon, 13 Aug 2018 18:34:32 +0000 (18:34 +0000)]
[InstCombine] add more tests for trig reflections; NFC (PR38458)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339598 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[llvm-mca] Propagate fatal llvm-mca errors from library classes to driver.
Matt Davis [Mon, 13 Aug 2018 18:11:48 +0000 (18:11 +0000)]
[llvm-mca] Propagate fatal llvm-mca errors from library classes to driver.

Summary:
This patch introduces error handling to propagate the errors from llvm-mca library classes (or what will become library classes) up to the driver.  This patch also introduces an enum to make clearer the intention of the return value for Stage::execute.

This supports PR38101.

Reviewers: andreadb, courbet, RKSimon

Reviewed By: andreadb

Subscribers: llvm-commits, tschuett, gbedwell

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339594 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[X86][BtVer2] Use NoSchedPredicate to model default transitions in variant scheduling...
Andrea Di Biagio [Mon, 13 Aug 2018 17:52:39 +0000 (17:52 +0000)]
[X86][BtVer2] Use NoSchedPredicate to model default transitions in variant scheduling classes. NFC.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339589 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[SimplifyLibCalls] reduce code for optimizeCos; NFCI
Sanjay Patel [Mon, 13 Aug 2018 17:40:49 +0000 (17:40 +0000)]
[SimplifyLibCalls] reduce code for optimizeCos; NFCI

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339588 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoAttempt to fix some MSVC build errors.
Erik Pilkington [Mon, 13 Aug 2018 17:39:19 +0000 (17:39 +0000)]
Attempt to fix some MSVC build errors.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339587 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[ADT] Implemented unittests for ImmutableList
Kristof Umann [Mon, 13 Aug 2018 17:32:48 +0000 (17:32 +0000)]
[ADT] Implemented unittests for ImmutableList

Also fixed a typo that wasn't discovered as `create` was never instantiated.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339586 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[InstCombine] Limit simplifyAllocaArraySize constant folding to values that fit into...
Simon Pilgrim [Mon, 13 Aug 2018 16:50:20 +0000 (16:50 +0000)]
[InstCombine] Limit simplifyAllocaArraySize constant folding to values that fit into a uint64_t

Fixes OSS-Fuzz: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=5223

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339584 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[itanium demangler] Add llvm::itaniumFindTypesInMangledName()
Erik Pilkington [Mon, 13 Aug 2018 16:37:47 +0000 (16:37 +0000)]
[itanium demangler] Add llvm::itaniumFindTypesInMangledName()

This function calls a callback whenever a <type> is parsed.

This is necessary to implement FindAlternateFunctionManglings in LLDB, which
uses a similar hack in FastDemangle. Once that function has been updated to use
this version, FastDemangle can finally be removed.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339580 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[InstCombine] auto-generate full checks and add cos intrinsic test; NFC
Sanjay Patel [Mon, 13 Aug 2018 16:29:01 +0000 (16:29 +0000)]
[InstCombine] auto-generate full checks and add cos intrinsic test; NFC

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339579 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[SLC] Expand simplification of pow() for vector types
Evandro Menezes [Mon, 13 Aug 2018 16:12:37 +0000 (16:12 +0000)]
[SLC] Expand simplification of pow() for vector types

Also consider vector constants when simplifying `pow()`.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339578 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[Tablegen] Replace uses of formatted_raw_ostream with raw_ostream in the predicate...
Andrea Di Biagio [Mon, 13 Aug 2018 15:13:35 +0000 (15:13 +0000)]
[Tablegen] Replace uses of formatted_raw_ostream with raw_ostream in the predicate expander. NFCI

This is a follow-up of r339552.

As pointed out by Craig in D50566, we don't need a formatted_raw_ostream to
indent strings. We can use instead raw_ostream::indent().

Internally, class PredicateExpander already keeps track of the current
indentation level. Also, the grammar for predicates is well parenthesized, and
therefore we don't need to use a formatted_raw_ostream to continuously track the
column number. Instead we can safely replace all the uses of
formatted_raw_ostream::PadToColumn() with uses of raw_ostream::indent().

By replacing formatted_raw_ostream with a simpler raw_ostream, we also avoid the
implicit check on the newline character on every print to stream.

No functional change intended.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339577 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[Hexagon] Silence -Wuninitialized warning from GCC 5.4, NFC
Krzysztof Parzyszek [Mon, 13 Aug 2018 15:08:25 +0000 (15:08 +0000)]
[Hexagon] Silence -Wuninitialized warning from GCC 5.4, NFC

Patch by Kim Gräsman.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339576 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoRevert "[Sparc] Add support for the cycle counter available in GR740"
Daniel Cederman [Mon, 13 Aug 2018 14:18:09 +0000 (14:18 +0000)]
Revert "[Sparc] Add support for the cycle counter available in GR740"

It breaks when using EXPENSIVE_CHECKS with the error message
"Bad machine code: Using an undefined physical register".

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339570 91177308-0d34-0410-b5e6-96231b3b80d8

6 years agoCheck for tied operands
Sid Manning [Mon, 13 Aug 2018 14:01:25 +0000 (14:01 +0000)]
Check for tied operands

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339567 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[SystemZ] Increase the amount of inlining.
Jonas Paulsson [Mon, 13 Aug 2018 13:31:30 +0000 (13:31 +0000)]
[SystemZ]  Increase the amount of inlining.

Implement getInliningThresholdMultiplier() and have it return 3.

Review: Ulrich Weigand

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339563 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[X86] Add tests showing missing div/rem 0, X -> 0 combines
Simon Pilgrim [Mon, 13 Aug 2018 13:29:54 +0000 (13:29 +0000)]
[X86] Add tests showing missing div/rem 0, X -> 0 combines

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339562 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[DAGCombiner] simplifyDivRem - add comment describing divide by undef/zero combine...
Simon Pilgrim [Mon, 13 Aug 2018 13:12:25 +0000 (13:12 +0000)]
[DAGCombiner] simplifyDivRem - add comment describing divide by undef/zero combine. NFC.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339561 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[CGP] Fix GEP issue with out of range APInt constant values not fitting in int64_t
Simon Pilgrim [Mon, 13 Aug 2018 12:10:09 +0000 (12:10 +0000)]
[CGP] Fix GEP issue with out of range APInt constant values not fitting in int64_t

Test case reduced from https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=7173

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339556 91177308-0d34-0410-b5e6-96231b3b80d8

6 years ago[Tablegen][SubtargetEmitter] Improve expansion of predicates of a variant scheduling...
Andrea Di Biagio [Mon, 13 Aug 2018 11:09:04 +0000 (11:09 +0000)]
[Tablegen][SubtargetEmitter] Improve expansion of predicates of a variant scheduling class.

This patch refactors the logic that expands predicates of a variant scheduling
class.

The idea is to improve the readability of the auto-generated code by removing
redundant parentheses around predicate expressions, and by removing redundant
if(true) statements.

This patch replaces the definition of NoSchedPred in TargetSchedule.td with an
instance of MCSchedPredicate. The new definition is sematically equivalent to
the previous one. The main difference is that now SubtargetEmitter knows that it
represents predicate "true".

Before this patch, we always generated an if (true) for the default transition
of a variant scheduling class.

Example (taken from AArch64GenSubtargetInfo.inc) :

```
if (SchedModel->getProcessorID() == 3) { // CycloneModel
  if ((TII->isScaledAddr(*MI)))
    return 927; // (WriteIS_WriteLD)_ReadBaseRS
  if ((true))
    return 928; // WriteLD_ReadDefault
}
```

Extra parentheses were also generated around the predicate expressions.

With this patch, we get the following auto-generated checks:

```
if (SchedModel->getProcessorID() == 3) { // CycloneModel
  if (TII->isScaledAddr(*MI))
    return 927; // (WriteIS_WriteLD)_ReadBaseRS
  return 928; // WriteLD_ReadDefault
}
```

The new auto-generated code behaves exactly the same as before. So, technically
this is a non functional change.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339552 91177308-0d34-0410-b5e6-96231b3b80d8