]> granicus.if.org Git - llvm/log
llvm
8 years agoSimplify FunctionLoweringInfo.cpp with range for loops
Reid Kleckner [Fri, 30 Dec 2016 00:21:38 +0000 (00:21 +0000)]
Simplify FunctionLoweringInfo.cpp with range for loops

I'm preparing to add some pattern matching code here, so simplify the
code before I do. NFC

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

8 years agoInclude <algorithm> for std::max etc
Reid Kleckner [Fri, 30 Dec 2016 00:15:40 +0000 (00:15 +0000)]
Include <algorithm> for std::max etc

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

8 years ago[LICM] Compute exit blocks for promotion eagerly. NFC.
Michael Kuperstein [Thu, 29 Dec 2016 23:11:19 +0000 (23:11 +0000)]
[LICM] Compute exit blocks for promotion eagerly. NFC.

This moves the exit block and insertion point computation to be eager,
instead of after seeing the first scalar we can promote.

The cost is relatively small (the computation happens anyway, see discussion
on D28147), and the code is easier to follow, and can bail out earlier
if there's a catchswitch present.

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

8 years ago[LICM] Don't try to promote in loops where we have no chance to promote. NFC.
Michael Kuperstein [Thu, 29 Dec 2016 22:51:22 +0000 (22:51 +0000)]
[LICM] Don't try to promote in loops where we have no chance to promote. NFC.

We would check whether we have a prehader *or* dedicated exit blocks,
and go into the promotion loop. Then, for each alias set we'd check
if we have a preheader *and* dedicated exit blocks, and bail if not.

Instead, bail immediately if we don't have both.

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

8 years ago[LICM] Only recompute LCSSA when we actually promoted something.
Michael Kuperstein [Thu, 29 Dec 2016 22:37:13 +0000 (22:37 +0000)]
[LICM] Only recompute LCSSA when we actually promoted something.

We want to recompute LCSSA only when we actually promoted a value.
This means we only need to look at changes made by promotion when
deciding whether to recompute it or not, not at regular sinking/hoisting.

(This was what the code was documented as doing, just not what it did)

Hopefully NFC.

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

8 years agoNewGVN: Fix PR 31491 by ensuring that we touch the right instructions. Change to...
Daniel Berlin [Thu, 29 Dec 2016 22:15:12 +0000 (22:15 +0000)]
NewGVN: Fix PR 31491 by ensuring that we touch the right instructions.  Change to one based numbering so we can assert we don't cause the same bug again.

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

8 years ago[Analysis] Remove repeated text from a comment. NFC
Craig Topper [Thu, 29 Dec 2016 21:48:28 +0000 (21:48 +0000)]
[Analysis] Remove repeated text from a comment. NFC

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

8 years agoFix indentation in r290716.
Bryant Wong [Thu, 29 Dec 2016 20:05:51 +0000 (20:05 +0000)]
Fix indentation in r290716.

Use two-space indentation like the rest of the file.

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

8 years ago[ADT] Rewrite IntrusiveRefCntPtr's comments. NFC
Justin Lebar [Thu, 29 Dec 2016 19:59:38 +0000 (19:59 +0000)]
[ADT] Rewrite IntrusiveRefCntPtr's comments. NFC

Edit for voice, and also add examples.  In particular, add an
explanation for why you might want to specialize IntrusiveRefCntPtrInfo,
which is not obvious.

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

8 years ago[ADT] Rename RefCountedBase::ref_cnt to RefCount. NFC
Justin Lebar [Thu, 29 Dec 2016 19:59:34 +0000 (19:59 +0000)]
[ADT] Rename RefCountedBase::ref_cnt to RefCount.  NFC

This makes it comply with the LLVM style guide, and also makes it
consistent with ThreadSafeRefCountedBase below.

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

8 years ago[ADT] clang-format IntrusiveRefCntrPtr.h. NFC
Justin Lebar [Thu, 29 Dec 2016 19:59:30 +0000 (19:59 +0000)]
[ADT] clang-format IntrusiveRefCntrPtr.h. NFC

This file had some strange indentation.

Also remove some unnecessary whitespace between one-line member
functions.

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

8 years ago[ADT] Delete RefCountedBaseVPTR.
Justin Lebar [Thu, 29 Dec 2016 19:59:26 +0000 (19:59 +0000)]
[ADT] Delete RefCountedBaseVPTR.

Summary:
This class is unnecessary.

Its comment indicated that it was a compile error to allocate an
instance of a class that inherits from RefCountedBaseVPTR on the stack.
This may have been true at one point, but it's not today.

Moreover you really do not want to allocate *any* refcounted object on
the stack, vptrs or not, so if we did have a way to prevent these
objects from being stack-allocated, we'd want to apply it to regular
RefCountedBase too, obviating the need for a separate RefCountedBaseVPTR
class.

It seems that the main way RefCountedBaseVPTR provides safety is by
making its subclass's destructor virtual.  This may have been helpful at
one point, but these days clang will emit an error if you define a class
with virtual functions that inherits from RefCountedBase but doesn't
have a virtual destructor.

Reviewers: compnerd, dblaikie

Subscribers: cfe-commits, klimek, llvm-commits, mgorny

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

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

8 years agoCorrectly handle multi-lined RUN lines.
Bryant Wong [Thu, 29 Dec 2016 19:32:34 +0000 (19:32 +0000)]
Correctly handle multi-lined RUN lines.

`utils/update_{llc_test,test}_checks` ought to be able to handle RUN commands
that span multiple lines, as shown in the example at
http://llvm.org/docs/CommandGuide/FileCheck.html#the-filecheck-check-prefix-option

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

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

8 years ago[ADT] Use memcpy for type punning in MathExtras.
Justin Lebar [Thu, 29 Dec 2016 18:15:34 +0000 (18:15 +0000)]
[ADT] Use memcpy for type punning in MathExtras.

Summary: Previously we type-punned through a union, which is not safe.

Reviewers: rnk

Subscribers: llvm-commits

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

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

8 years agoRevert "[COFF] Use 32-bit jump table entries in .rdata for Win64"
Reid Kleckner [Thu, 29 Dec 2016 17:07:10 +0000 (17:07 +0000)]
Revert "[COFF] Use 32-bit jump table entries in .rdata for Win64"

This reverts commit r290694. It broke sanitizer tests on Win64. I'll
probably bring this back, but the jump tables will just live in .text
like they do for MSVC.

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

8 years ago[TBAAVerifier] Be stricter around verifying scalar nodes
Sanjoy Das [Thu, 29 Dec 2016 15:47:05 +0000 (15:47 +0000)]
[TBAAVerifier] Be stricter around verifying scalar nodes

This fixes the issue exposed in PR31393, where we weren't trying
sufficiently hard to diagnose bad TBAA metadata.

This does reduce the variety in the error messages we print out, but I
think the tradeoff of verifying more, simply and quickly overrules the
need for more helpful error messags here.

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

8 years ago[TBAAVerifier] Make things const-consistent; NFC
Sanjoy Das [Thu, 29 Dec 2016 15:47:01 +0000 (15:47 +0000)]
[TBAAVerifier] Make things const-consistent; NFC

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

8 years ago[TBAAVerifier] Memoize validity of scalar tbaa nodes; NFCI
Sanjoy Das [Thu, 29 Dec 2016 15:46:57 +0000 (15:46 +0000)]
[TBAAVerifier] Memoize validity of scalar tbaa nodes; NFCI

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

8 years ago[AMDGPU][mc] Enable absolute expressions in .hsa_code_object_isa directive
Artem Tamazov [Thu, 29 Dec 2016 15:41:52 +0000 (15:41 +0000)]
[AMDGPU][mc] Enable absolute expressions in .hsa_code_object_isa directive

Among other stuff, this allows to use predefined .option.machine_version_major
/minor/stepping symbols in the directive.

Relevant test expanded at once (also file renamed for clarity).

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

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

8 years agoFix documentation generator warnings after rL290708.
Igor Laevsky [Thu, 29 Dec 2016 15:08:57 +0000 (15:08 +0000)]
Fix documentation generator warnings after rL290708.

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

8 years agoIntroduce element-wise atomic memcpy intrinsic
Igor Laevsky [Thu, 29 Dec 2016 14:31:07 +0000 (14:31 +0000)]
Introduce element-wise atomic memcpy intrinsic

This change adds a new intrinsic which is intended to provide memcpy functionality
with additional atomicity guarantees. Please refer to the review thread
or language reference for further details.

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

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

8 years ago[InstCombine] Use getVectorNumElements instead of explicitly casting to VectorType...
Craig Topper [Thu, 29 Dec 2016 07:03:18 +0000 (07:03 +0000)]
[InstCombine] Use getVectorNumElements instead of explicitly casting to VectorType and calling getNumElements. NFC

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

8 years ago[InstCombine] Fix typo in comment. NFC
Craig Topper [Thu, 29 Dec 2016 05:38:31 +0000 (05:38 +0000)]
[InstCombine] Fix typo in comment. NFC

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

8 years ago[InstCombine] Use a 32-bits instead of 64-bits for storing the number of elements...
Craig Topper [Thu, 29 Dec 2016 04:24:32 +0000 (04:24 +0000)]
[InstCombine] Use a 32-bits instead of 64-bits for storing the number of elements in VectorType for a ShuffleVector. While there getVectorNumElements to avoid an explicit cast. NFC

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

8 years ago[InstCombine][X86] If the lowest element of a scalar intrinsic isn't used make sure...
Craig Topper [Thu, 29 Dec 2016 03:30:17 +0000 (03:30 +0000)]
[InstCombine][X86] If the lowest element of a scalar intrinsic isn't used make sure we add it to the worklist so we can DCE it sooner.

We bypassed the intrinsic and returned the passthru operand, but we should also add the intrinsic to the worklist since its now dead. This can allow DCE to find it sooner and remove it. Similar was done for InsertElement when the inserted element isn't demanded.

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

8 years ago[libFuzzer] make __sanitizer_cov_trace_switch more predictable
Kostya Serebryany [Thu, 29 Dec 2016 02:50:35 +0000 (02:50 +0000)]
[libFuzzer] make __sanitizer_cov_trace_switch more predictable

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

8 years ago[InstCombine] Fix some of the AVX-512 scalar arithmetic test cases to do a better...
Craig Topper [Thu, 29 Dec 2016 02:29:04 +0000 (02:29 +0000)]
[InstCombine] Fix some of the AVX-512 scalar arithmetic test cases to do a better job of testing what they intended to test.

The accidentally had trivially dead code. Also needed to adjust the rounding mode to not CUR_DIRECTION so the intrinsics don't get converted to native operations before going through SimplifyDemandedVectorElts.

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

8 years agoRemove BitstreamWriter::Emit64(), it was never called (NFC)
Mehdi Amini [Thu, 29 Dec 2016 01:40:53 +0000 (01:40 +0000)]
Remove BitstreamWriter::Emit64(), it was never called (NFC)

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

8 years agoFix mingw build by moving the static const data member before the bitfields
Reid Kleckner [Thu, 29 Dec 2016 01:14:41 +0000 (01:14 +0000)]
Fix mingw build by moving the static const data member before the bitfields

Apparently GCC targeting Windows breaks bitfields on static data members:
  struct Foo {
    unsigned X : 16;
    static const int M = 42;
    unsigned Y : 16;
  };
  static_assert(sizeof(Foo) == 4, "asdf"); // fails

Who knew.

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

8 years agoNewGVN: Sort Dominator Tree in RPO order, and use that for generating order.
Daniel Berlin [Thu, 29 Dec 2016 01:12:36 +0000 (01:12 +0000)]
NewGVN: Sort Dominator Tree in RPO order, and use that for generating order.

Summary:
The optimal iteration order for this problem is RPO order. We want to
process as many preds of a backedge as we can before we process the
backedge.

At the same time, as we add predicate handling, we want to be able to
touch instructions that are dominated by a given block by
ranges (because a change in value numbering a predicate possibly
affects all users we dominate that are using that predicate).
If we don't do it this way, we can't do value inference over
backedges (the paper covers this in depth).

The newgvn branch currently overshoots the last part, and guarantees
that it will touch *at least* the right set of instructions, but it
does touch more.  This is because the bitvector instruction ranges are
currently generated in RPO order (so we take the max and the min of
the ranges of dominated blocks, which means there are some in the
middle we didn't have to touch that we did).

We can do better by sorting the dominator tree, and then just using
dominator tree order.

As a preliminary, the dominator tree has some RPO guarantees, but not
enough. It guarantees that for a given node, your idom must come
before you in the RPO ordering. It guarantees no relative RPO ordering
for siblings.  We add siblings in whatever order they appear in the module.

So that is what we fix.

We sort the children array of the domtree into RPO order, and then use
the dominator tree for ordering, instead of RPO, since the dominator
tree is now a valid RPO ordering.

Note: This would help any other pass that iterates a forward problem
in dominator tree order.  Most of them are single pass.  It will still
maximize whatever result they compute.  We could also build the
dominator tree in this order, but our incremental updates would still
put it out of sort order, and recomputing the sort order is almost as
hard as general incremental updates of the domtree.

Also note that the sorting does not affect any tests, etc. Nothing
depends on domtree order, including the verifier, the equals
functions for domtree nodes, etc.

How much could this matter, you ask?
Here are the current numbers.
This is generated by running NewGVN over all files in LLVM.

Note that once we propagate equalities, the differences go up by an
order of magnitude or two (IE instead of 29, the max ends up in the
thousands, since the worst case we add a factor of N, where N is the
number of branch predicates).  So while it doesn't look that stark for
the default ordering, it gets *much much* worse.  There are also
programs in the wild where the difference is already pretty stark
(2 iterations vs hundreds).

RPO ordering:
759040 Number of iterations is 1
112908 Number of iterations is 2

Default dominator tree ordering:
755081 Number of iterations is 1
116234 Number of iterations is 2
   603 Number of iterations is 3
    27 Number of iterations is 4
     2 Number of iterations is 5
     1 Number of iterations is 7

Dominator tree sorted:
759040 Number of iterations is 1
112908 Number of iterations is 2
<yay!>

Really bad ordering (sort domtree siblings in postorder. not quite the
worst possible, but yeah):
754008 Number of iterations is 1
    21 Number of iterations is 10
     8 Number of iterations is 11
     6 Number of iterations is 12
     5 Number of iterations is 13
     2 Number of iterations is 14
     2 Number of iterations is 15
     3 Number of iterations is 16
     1 Number of iterations is 17
     2 Number of iterations is 18
 96642 Number of iterations is 2
     1 Number of iterations is 20
     2 Number of iterations is 21
     1 Number of iterations is 22
     1 Number of iterations is 29
 17266 Number of iterations is 3
  2598 Number of iterations is 4
   798 Number of iterations is 5
   273 Number of iterations is 6
   186 Number of iterations is 7
    80 Number of iterations is 8
    42 Number of iterations is 9

Reviewers: chandlerc, davide

Subscribers: llvm-commits

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

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

8 years agoAdd a static_assert about the sizeof(GlobalValue)
Reid Kleckner [Thu, 29 Dec 2016 00:55:51 +0000 (00:55 +0000)]
Add a static_assert about the sizeof(GlobalValue)

I added one for Value back in r262045, and I'm starting to think we
should have these for any class with bitfields whose memory efficiency
really matters.

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

8 years agoUpdate equalsStoreHelper for the fact that only one branch can be true
Daniel Berlin [Thu, 29 Dec 2016 00:49:32 +0000 (00:49 +0000)]
Update equalsStoreHelper for the fact that only one branch can be true

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

8 years ago[GlobalValue] Move HasLLVMReservedName into existing bitfield. NFC
Justin Lebar [Thu, 29 Dec 2016 00:30:46 +0000 (00:30 +0000)]
[GlobalValue] Move HasLLVMReservedName into existing bitfield. NFC

Summary:
Follow-up to r290691, where I introduced HasLLVMReservedName.  rnk
pointed out that that patch added an extra word to GlobalValue on MSVC,
because it doesn't pack bitfields with different types.

This patch moves HasLLVMReservedName into the existing bitfield, where
we appear to have plenty of bits to spare.

Reviewers: rnk

Subscribers: llvm-commits

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

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

8 years ago[IR] Clarify that Value::getName() is not actually cheap.
Justin Lebar [Thu, 29 Dec 2016 00:30:42 +0000 (00:30 +0000)]
[IR] Clarify that Value::getName() is not actually cheap.

It involves a hashtable lookup when the Value has a name.

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

8 years ago[COFF] Use 32-bit jump table entries in .rdata for Win64
Reid Kleckner [Thu, 29 Dec 2016 00:12:39 +0000 (00:12 +0000)]
[COFF] Use 32-bit jump table entries in .rdata for Win64

Summary:
We were already using 32-bit jump table entries, but this was a
consequence of the default PIC model on Win64, and not an intentional
design decision. This patch ensures that we always use 32-bit label
difference jump table entries on Win64 regardless of the PIC model. This
is a good idea because it saves executable size and object file size.

Moving the jump tables to .rdata cleans up the disassembled object code
and reduces the available ROP targets, but it requires adding one more
RIP-relative lea to the code.  COFF doesn't have relocations to express
the difference between two arbitrary symbols, so we can't use the jump
table label in the label difference like we do elsewhere.

Fixes PR31488

Reviewers: majnemer, compnerd

Subscribers: llvm-commits

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

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

8 years agoChange Metadata Index emission in the bitcode to use 2x32 bits for the placeholder
Mehdi Amini [Wed, 28 Dec 2016 23:45:54 +0000 (23:45 +0000)]
Change Metadata Index emission in the bitcode to use 2x32 bits for the placeholder

The Bitstream reader and writer are limited to handle a "size_t" at
most, which means that we can't backpatch and read back a 64bits
value on 32 bits platform.

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

8 years agoRevert "[NewGVN] replace emplace_back with push_back"
Piotr Padlewski [Wed, 28 Dec 2016 23:24:02 +0000 (23:24 +0000)]
Revert "[NewGVN] replace emplace_back with push_back"

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

8 years agoSpeed up Function::isIntrinsic() by adding a bit to GlobalValue. NFC
Justin Lebar [Wed, 28 Dec 2016 22:59:45 +0000 (22:59 +0000)]
Speed up Function::isIntrinsic() by adding a bit to GlobalValue. NFC

Summary:
Previously isIntrinsic() called getName().  This involves a hashtable
lookup, so is nontrivially expensive.  And isIntrinsic() is called
frequently, particularly by dyn_cast<IntrinsicInstr>.

This patch steals a bit of IntID and uses that to store whether or not
getName() starts with "llvm."

Reviewers: bogner, arsenm, joker-eph

Subscribers: sanjoy, llvm-commits

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

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

8 years agoAdd an index for Module Metadata record in the bitcode
Mehdi Amini [Wed, 28 Dec 2016 22:30:28 +0000 (22:30 +0000)]
Add an index for Module Metadata record in the bitcode

This index record the position for each metadata record in
the bitcode, so that the reader will be able to lazy-load
on demand each individual record.

We also make sure that every abbrev is emitted upfront so
that the block can be skipped while reading.

I don't plan to commit this before having the reader
counterpart, but I figured this can be reviewed mostly
independently.

Recommit r290684 (was reverted in r290686 because a test
was broken) after adding a threshold to avoid emitting
the index when unnecessary (little amount of metadata).
This optimization "hides" a limitation of the ability
to backpatch in the bitstream: we can only backpatch
safely when the position has been flushed. So if we emit
an index for one metadata, it is possible that (part of)
the offset placeholder hasn't been flushed and the backpatch
will fail.

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

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

8 years agoRevert "Add an index for Module Metadata record in the bitcode"
Saleem Abdulrasool [Wed, 28 Dec 2016 20:37:22 +0000 (20:37 +0000)]
Revert "Add an index for Module Metadata record in the bitcode"

This reverts commit a0ca6ae2d38339e4ede0dfa588086fc23d87e836.  Revert at
Mehdi's request as it is breaking bots.

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

8 years ago[NewGVN] replace emplace_back with push_back
Piotr Padlewski [Wed, 28 Dec 2016 20:36:08 +0000 (20:36 +0000)]
[NewGVN] replace emplace_back with push_back

emplace_back is not faster if it is equivalent to push_back. In this cases emplaced value had the
same type that the one stored in container. It is ugly and it might be even slower (see
Scott Meyers presentation about emplacement).

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

8 years agoAdd an index for Module Metadata record in the bitcode
Mehdi Amini [Wed, 28 Dec 2016 19:44:19 +0000 (19:44 +0000)]
Add an index for Module Metadata record in the bitcode

Summary:
This index record the position for each metadata record in
the bitcode, so that the reader will be able to lazy-load
on demand each individual record.

We also make sure that every abbrev is emitted upfront so
that the block can be skipped while reading.

I don't plan to commit this before having the reader
counterpart, but I figured this can be reviewed mostly
independently.

Reviewers: pcc, tejohnson

Subscribers: llvm-commits

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

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

8 years ago[NewGVN] Simplyfy loop NFC
Piotr Padlewski [Wed, 28 Dec 2016 19:42:49 +0000 (19:42 +0000)]
[NewGVN] Simplyfy loop NFC

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

8 years ago[ThinLTO] Honor -O{0,1,2,4} passed through the libLTO interface for ThinLTO
Mehdi Amini [Wed, 28 Dec 2016 19:37:16 +0000 (19:37 +0000)]
[ThinLTO] Honor -O{0,1,2,4} passed through the libLTO interface for ThinLTO

This was hardcoded to be O3 till now, without any way to change it
without changing the code.

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

8 years ago[NewGVN] replace typedefs with usings
Piotr Padlewski [Wed, 28 Dec 2016 19:29:26 +0000 (19:29 +0000)]
[NewGVN] replace typedefs with usings

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

8 years ago[NewGVN] NFC fixes
Piotr Padlewski [Wed, 28 Dec 2016 19:17:17 +0000 (19:17 +0000)]
[NewGVN] NFC fixes

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

8 years ago[WinEH] Don't assume endFunction is called while in .text
Reid Kleckner [Wed, 28 Dec 2016 19:05:12 +0000 (19:05 +0000)]
[WinEH] Don't assume endFunction is called while in .text

Jump table emission can switch to .rdata before
WinException::endFunction gets called. Just remember the appropriate
text section we started in and reset back to it when we end the
function. We were already switching sections back from .xdata anyway.

Fixes the first problem in PR31488, so that now COFF switch tables can
live in .rdata if we want them to.

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

8 years ago[NewGVN] Global sweep replacing NULL with nullptr. NFCI.
Davide Italiano [Wed, 28 Dec 2016 14:00:11 +0000 (14:00 +0000)]
[NewGVN] Global sweep replacing NULL with nullptr. NFCI.

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

8 years ago[NewGVN] Remove redundant code. NFCI.
Davide Italiano [Wed, 28 Dec 2016 13:54:16 +0000 (13:54 +0000)]
[NewGVN] Remove redundant code. NFCI.

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

8 years ago[NewGVN] equals() for loads/stores is the same. Unify.
Davide Italiano [Wed, 28 Dec 2016 13:37:17 +0000 (13:37 +0000)]
[NewGVN] equals() for loads/stores is the same. Unify.

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

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

8 years ago[PM] Introduce a devirtualization iteration layer for the new PM.
Chandler Carruth [Wed, 28 Dec 2016 11:07:33 +0000 (11:07 +0000)]
[PM] Introduce a devirtualization iteration layer for the new PM.

This is an orthogonal and separated layer instead of being embedded
inside the pass manager. While it adds a small amount of complexity, it
is fairly minimal and the composability and control seems worth the
cost.

The logic for this ends up being nicely isolated and targeted. It should
be easy to experiment with different iteration strategies wrapped around
the CGSCC bottom-up walk using this kind of facility.

The mechanism used to track devirtualization is the simplest one I came
up with. I think it handles most of the cases the existing iteration
machinery handles, but I haven't done a *very* in depth analysis. It
does however match the basic intended semantics, and we can tweak or
tune its exact behavior incrementally as necessary. One thing that we
may want to revisit is freshly building the value handle set on each
iteration. While I don't think this will be a significant cost (it is
strictly fewer value handles but more churn of value handes than the old
call graph), it is conceivable that we'll want a somewhat more clever
tracking mechanism. My hope is to layer that on as a follow up patch
with data supporting any implementation complexity it adds.

This code also provides for a basic count heuristic: if the number of
indirect calls decreases and the number of direct calls increases for
a given function in the SCC, we assume devirtualization is responsible.
This matches the heuristics currently used in the legacy pass manager.

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

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

8 years ago[PM] Teach the CGSCC's CG update utility to more carefully invalidate
Chandler Carruth [Wed, 28 Dec 2016 10:34:50 +0000 (10:34 +0000)]
[PM] Teach the CGSCC's CG update utility to more carefully invalidate
analyses when we're about to break apart an SCC.

We can't wait until after breaking apart the SCC to invalidate things:
1) Which SCC do we then invalidate? All of them?
2) Even if we invalidate all of them, a newly created SCC may not have
   a proxy that will convey the invalidation to functions!

Previously we only invalidated one of the SCCs and too late. This led to
stale analyses remaining in the cache. And because the caching strategy
actually works, they would get used and chaos would ensue.

Doing invalidation early is somewhat pessimizing though if we *know*
that the SCC structure won't change. So it turns out that the design to
make the mutation API force the caller to know the *kind* of mutation in
advance was indeed 100% correct and we didn't do enough of it. So this
change also splits two cases of switching a call edge to a ref edge into
two separate APIs so that callers can clearly test for this and take the
easy path without invalidating when appropriate. This is particularly
important in this case as we expect most inlines to be between functions
in separate SCCs and so the common case is that we don't have to so
aggressively invalidate analyses.

The LCG API change in turn needed some basic cleanups and better testing
in its unittest. No interesting functionality changed there other than
more coverage of the returned sequence of SCCs.

While this seems like an obvious improvement over the current state, I'd
like to revisit the core concept of invalidating within the CG-update
layer at all. I'm wondering if we would be better served forcing the
callers to handle the invalidation beforehand in the cases that they
can handle it. An interesting example is when we want to teach the
inliner to *update and preserve* analyses. But we can cross that bridge
when we get there.

With this patch, the new pass manager an build all of the LLVM test
suite at -O3 and everything passes. =D I haven't bootstrapped yet and
I'm sure there are still plenty of bugs, but this gives a nice baseline
so I'm going to increasingly focus on fleshing out the missing
functionality, especially the bits that are just turned off right now in
order to let us establish this baseline.

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

8 years agoThis is a large patch for X86 AVX-512 of an optimization for reducing code size by...
Gadi Haber [Wed, 28 Dec 2016 10:12:48 +0000 (10:12 +0000)]
This is a large patch for X86 AVX-512 of an optimization for reducing code size by encoding EVEX AVX-512 instructions using the shorter VEX encoding when possible.

There are cases of AVX-512 instructions that have two possible encodings. This is the case with instructions that use vector registers with low indexes of 0 - 15 and do not use the zmm registers or the mask k registers.
The EVEX encoding prefix requires 4 bytes whereas the VEX prefix can take only up to 3 bytes. Consequently, using the VEX encoding for these instructions results in a code size reduction of ~2 bytes even though it is compiled with the AVX-512 features enabled.

Reviewers: Craig Topper, Zvi Rackoover, Elena Demikhovsky
Differential Revision: https://reviews.llvm.org/D27901

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

8 years ago[PM] Teach the inliner's call graph update to handle inserting new edges
Chandler Carruth [Wed, 28 Dec 2016 03:13:12 +0000 (03:13 +0000)]
[PM] Teach the inliner's call graph update to handle inserting new edges
when they are call edges at the leaf but may (transitively) be reached
via ref edges.

It turns out there is a simple rule: insert everything as a ref edge
which is a safe conservative default. Then we let the existing update
logic handle promoting some of those to call edges.

Note that it would be fairly cheap to make these call edges right away
if that is desirable by testing whether there is some existing call path
from the source to the target. It just seemed like slightly more
complexity in this code path that isn't strictly necessary. If anyone
feels strongly about handling this differently I'm happy to change it.

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

8 years ago[InstCombine] Remove a piece of a comment that said that InstCombiner contains pass...
Craig Topper [Wed, 28 Dec 2016 03:12:42 +0000 (03:12 +0000)]
[InstCombine] Remove a piece of a comment that said that InstCombiner contains pass infrastructure. That hasn't been true since r226618. NFC

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

8 years ago[PM] Actually commit the test update that was supposed to accompany
Chandler Carruth [Wed, 28 Dec 2016 02:31:24 +0000 (02:31 +0000)]
[PM] Actually commit the test update that was supposed to accompany
r290644. Sorry for this.

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

8 years ago[LCG] Teach the ref edge removal to handle a ref edge that is trivial
Chandler Carruth [Wed, 28 Dec 2016 02:24:58 +0000 (02:24 +0000)]
[LCG] Teach the ref edge removal to handle a ref edge that is trivial
due to a call cycle.

This actually crashed the ref removal before.

I've added a unittest that covers this kind of interesting graph
structure and mutation.

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

8 years ago[PM] Disable the loop vectorizer from the new PM's pipeline as it
Chandler Carruth [Wed, 28 Dec 2016 02:24:55 +0000 (02:24 +0000)]
[PM] Disable the loop vectorizer from the new PM's pipeline as it
currenty relies on the old PM's dependency system forming LCSSA.

The new PM will require a different design for this, and for now this is
causing most of the issues I'm currently seeing in testing. I'd like to
get to a testable baseline and then work on re-enabling things one at
a time.

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

8 years ago[InstCombine] Canonicalize insert splat sequences into an insert + shuffle
Michael Kuperstein [Wed, 28 Dec 2016 00:18:08 +0000 (00:18 +0000)]
[InstCombine] Canonicalize insert splat sequences into an insert + shuffle

This adds a combine that canonicalizes a chain of inserts which broadcasts
a value into a single insert + a splat shufflevector.

This fixes PR31286.

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

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

8 years ago[libFuzzer] add an experimental flag -experimental_len_control=1 that sets max_len...
Kostya Serebryany [Tue, 27 Dec 2016 23:24:55 +0000 (23:24 +0000)]
[libFuzzer] add an experimental flag -experimental_len_control=1 that sets max_len to 1M and tries to increases the actual max sizes of mutations very gradually (second attempt)

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

8 years agoMark comparator call operator as const
Eric Fiselier [Tue, 27 Dec 2016 23:15:58 +0000 (23:15 +0000)]
Mark comparator call operator as const

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

8 years ago[libFuzzer] don't create large random mutations when given an empty seed
Kostya Serebryany [Tue, 27 Dec 2016 22:15:04 +0000 (22:15 +0000)]
[libFuzzer] don't create large random mutations when given an empty seed

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

8 years ago[sanitizer-coverage] sort the switch cases
Kostya Serebryany [Tue, 27 Dec 2016 21:20:06 +0000 (21:20 +0000)]
[sanitizer-coverage] sort the switch cases

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

8 years agollvm-readobj: ELF: Make DT tags machine aware
Hemant Kulkarni [Tue, 27 Dec 2016 19:59:29 +0000 (19:59 +0000)]
llvm-readobj: ELF: Make DT tags machine aware

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

8 years ago[libFuzzer] fix UB and simplify the computation of the RNG seed (https://llvm.org...
Kostya Serebryany [Tue, 27 Dec 2016 19:51:34 +0000 (19:51 +0000)]
[libFuzzer] fix UB and simplify the computation of the RNG seed (https://llvm.org/bugs/show_bug.cgi?id=31456)

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

8 years ago[PM] Teach MemDep to invalidate its result object when its cached
Chandler Carruth [Tue, 27 Dec 2016 19:33:04 +0000 (19:33 +0000)]
[PM] Teach MemDep to invalidate its result object when its cached
analysis handles become invalid.

Add a test case for its invalidation logic.

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

8 years agoDebugInfo: add explicit casts for -Wqual-cast
Saleem Abdulrasool [Tue, 27 Dec 2016 18:35:24 +0000 (18:35 +0000)]
DebugInfo: add explicit casts for -Wqual-cast

Fix a warning detected by gcc 6:
  warning: cast from type 'const void*' to type 'uint8_t* {aka unsigned char*}' casts away qualifiers [-Wcast-qual]

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

8 years agoASMParser: use range-based for loops (NFC)
Saleem Abdulrasool [Tue, 27 Dec 2016 18:35:22 +0000 (18:35 +0000)]
ASMParser: use range-based for loops (NFC)

Convert the verify method to use a few more range based for loops,
converting to const iterators in the process.

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

8 years agotest: modernise ARM CodeGen tests
Saleem Abdulrasool [Tue, 27 Dec 2016 18:35:19 +0000 (18:35 +0000)]
test: modernise ARM CodeGen tests

Replace the use of grep with FileCheck.  Tidy up some of the tests.  A
few of the tests have been left as weak as previously, though some have
been made more stringent.

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

8 years ago[NewGVN] Simplify a bit removing else after return. NFCI.
Davide Italiano [Tue, 27 Dec 2016 18:15:39 +0000 (18:15 +0000)]
[NewGVN] Simplify a bit removing else after return. NFCI.

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

8 years ago[PM] Remove a pointless optimization.
Chandler Carruth [Tue, 27 Dec 2016 18:04:11 +0000 (18:04 +0000)]
[PM] Remove a pointless optimization.

There is no need to do this within an analysis. That method shouldn't
even be reached if this predicate holds as the actual useful
optimization is in the analysis manager itself.

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

8 years agoAttempt to make the Windows bots green after r290609.
Chad Rosier [Tue, 27 Dec 2016 18:02:27 +0000 (18:02 +0000)]
Attempt to make the Windows bots green after r290609.

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

8 years ago[PM] Add more dedicated testing to cover the invalidation logic added to
Chandler Carruth [Tue, 27 Dec 2016 17:59:22 +0000 (17:59 +0000)]
[PM] Add more dedicated testing to cover the invalidation logic added to
BasicAA in r290603.

I've kept the basic testing in the new PM test file as that also covers
the AAManager invalidation logic. If/when there is a good place for
broader AA testing it could move there.

This test is somewhat unsatisfying as I can't get it to fail even with
ASan outside of explicit checks of the invalidation. Apparently we don't
yet have any test coverage of the BasicAA code paths using either the
domtree or loopinfo -- I made both of them always be null and check-llvm
passed.

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

8 years ago[MemCpyOpt] Don't sink LoadInst below possible clobber.
Bryant Wong [Tue, 27 Dec 2016 17:58:12 +0000 (17:58 +0000)]
[MemCpyOpt] Don't sink LoadInst below possible clobber.

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

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

8 years ago[ThinLTO] Fix "||" vs "|" mixup.
Teresa Johnson [Tue, 27 Dec 2016 17:45:09 +0000 (17:45 +0000)]
[ThinLTO] Fix "||" vs "|" mixup.

The effect of the bug was that we would incorrectly create summaries
for global and weak values defined in module asm (since we were
essentially testing for bit 1 which is SF_Undefined, and the
RecordStreamer ignores local undefined references). This would have
resulted in conservatively disabling importing of anything referencing
globals and weaks defined in module asm. Added these cases to the test
which now fails without this bug fix.

Fixes PR31459.

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

8 years ago[AArch64][AsmParser] Add support for parsing shift/extend operands with symbols.
Chad Rosier [Tue, 27 Dec 2016 16:58:09 +0000 (16:58 +0000)]
[AArch64][AsmParser] Add support for parsing shift/extend operands with symbols.

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

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

8 years ago[AMDGPU][llvm-mc] Predefined symbols to access register counts (.kernel.{v|s}gpr_count)
Artem Tamazov [Tue, 27 Dec 2016 16:00:11 +0000 (16:00 +0000)]
[AMDGPU][llvm-mc] Predefined symbols to access register counts (.kernel.{v|s}gpr_count)

The feature allows for conditional assembly, filling the entries
of .amd_kernel_code_t etc.

Symbols are defined with value 0 at the beginning of each kernel scope.
After each register usage, the respective symbol is set to:
value = max( value, ( register index + 1 ) )
Thus, at the end of scope the value represents a count of used registers.

Kernel scopes begin at .amdgpu_hsa_kernel directive, end at the
next .amdgpu_hsa_kernel (or EOF, whichever comes first). There is also
dummy scope that lies from the beginning of source file til the
first .amdgpu_hsa_kernel.

Test added.

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

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

8 years ago[MemDep] Operand visited twice bugfix
Piotr Padlewski [Tue, 27 Dec 2016 15:06:07 +0000 (15:06 +0000)]
[MemDep] Operand visited twice bugfix

Because operand was not marked as seen it was visited twice.
It doesn't change behavior of optimization, it just saves redudant
visit, so no test changes.

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

8 years agoRuntimeDyldELF: refactor AArch64 relocations. NFC.
Eugene Leviant [Tue, 27 Dec 2016 13:33:32 +0000 (13:33 +0000)]
RuntimeDyldELF: refactor AArch64 relocations. NFC.

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

8 years agoFix unit test in NDEBUG build
Eugene Leviant [Tue, 27 Dec 2016 11:07:53 +0000 (11:07 +0000)]
Fix unit test in NDEBUG build

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

8 years ago[PM] Teach BasicAA how to invalidate its result object.
Chandler Carruth [Tue, 27 Dec 2016 10:30:45 +0000 (10:30 +0000)]
[PM] Teach BasicAA how to invalidate its result object.

This requires custom handling because BasicAA caches handles to other
analyses and so it needs to trigger indirect invalidation.

This fixes one of the common crashes when using the new PM in real
pipelines. I've also tweaked a regression test to check that we are at
least handling the most immediate case.

I'm going to work at re-structuring this test some to both scale better
(rather than all being in one file) and check more invalidation paths in
a follow-up commit, but I wanted to get the basic bug fix in place.

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

8 years agoAttempt to fix build bot after r290597
Eugene Leviant [Tue, 27 Dec 2016 10:24:58 +0000 (10:24 +0000)]
Attempt to fix build bot after r290597

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

8 years ago[PM] Disable more of the loop passes -- LCSSA and LoopSimplify are also
Chandler Carruth [Tue, 27 Dec 2016 10:16:46 +0000 (10:16 +0000)]
[PM] Disable more of the loop passes -- LCSSA and LoopSimplify are also
not really wired into the loop pass manager in a way that will let us
productively use these passes yet.

This lets the new PM get farther in basic testing which is useful for
establishing a good baseline of "doesn't explode". There are still
plenty of crashers in basic testing though, this just gets rid of some
noise that is well understood and not representing a specific or narrow
bug.

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

8 years ago[AMDGPU] Assembler: support SDWA and DPP for VOP2b instructions
Sam Kolton [Tue, 27 Dec 2016 10:06:42 +0000 (10:06 +0000)]
[AMDGPU] Assembler: support SDWA and DPP for VOP2b instructions

Reviewers: nhaustov, artem.tamazov, vpykhtin, tstellarAMD

Subscribers: arsenm, kzhuravl, wdng, nhaehnle, yaxunl, tony-tye

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

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

8 years agoRuntimeDyldELF: add R_AARCH64_ADD_ABS_LO12_NC reloc
Eugene Leviant [Tue, 27 Dec 2016 09:51:38 +0000 (09:51 +0000)]
RuntimeDyldELF: add R_AARCH64_ADD_ABS_LO12_NC reloc

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

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

8 years agoAllow setting multiple debug types
Eugene Leviant [Tue, 27 Dec 2016 09:31:20 +0000 (09:31 +0000)]
Allow setting multiple debug types

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

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

8 years agoChange a std::vector to SmallVector in NewGVN
Daniel Berlin [Tue, 27 Dec 2016 09:20:36 +0000 (09:20 +0000)]
Change a std::vector to SmallVector in NewGVN

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

8 years ago[PM] Teach the AAManager and AAResults layer (the worst offender for
Chandler Carruth [Tue, 27 Dec 2016 08:44:39 +0000 (08:44 +0000)]
[PM] Teach the AAManager and AAResults layer (the worst offender for
inter-analysis dependencies) to use the new invalidation infrastructure.

This teaches it to invalidate itself when any of the peer function
AA results that it uses become invalid. We do this by just tracking the
originating IDs. I've kept it in a somewhat clunky API since some users
of AAResults are outside the new PM right now. We can clean this API up
if/when those users go away.

Secondly, it uses the registration on the outer analysis manager proxy
to trigger deferred invalidation when a module analysis result becomes
invalid.

I've included test cases that specifically try to trigger use-after-free
in both of these cases and they would crash or hang pretty horribly for
me even without ASan. Now they work nicely.

The `InvalidateAnalysis` utility pass required some tweaking to be
useful in this context and it still is pretty garbage. I'd like to
switch it back to the previous implementation and teach the explicit
invalidate method on the AnalysisManager to take care of correctly
triggering indirect invalidation, but I wanted to go ahead and send this
out so folks could see how all of this stuff works together in practice.
And, you know, that it does actually work. =]

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

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

8 years ago[PM] Introduce the facilities for registering cross-IR-unit dependencies
Chandler Carruth [Tue, 27 Dec 2016 08:40:39 +0000 (08:40 +0000)]
[PM] Introduce the facilities for registering cross-IR-unit dependencies
that require deferred invalidation.

This handles the other real-world invalidation scenario that we have
cases of: a function analysis which caches references to a module
analysis. We currently do this in the AA aggregation layer and might
well do this in other places as well.

Since this is relative rare, the technique is somewhat more cumbersome.
Analyses need to register themselves when accessing the outer analysis
manager's proxy. This proxy is already necessarily present to allow
access to the outer IR unit's analyses. By registering here we can track
and trigger invalidation when that outer analysis goes away.

To make this work we need to enhance the PreservedAnalyses
infrastructure to support a (slightly) more explicit model for "sets" of
analyses, and allow abandoning a single specific analyses even when
a set covering that analysis is preserved. That allows us to describe
the scenario of preserving all Function analyses *except* for the one
where deferred invalidation has triggered.

We also need to teach the invalidator API to support direct ID calls
instead of always going through a template to dispatch so that we can
just record the ID mapping.

I've introduced testing of all of this both for simple module<->function
cases as well as for more complex cases involving a CGSCC layer.

Much like the previous patch I've not tried to fully update the loop
pass management layer because that layer is due to be heavily reworked
to use similar techniques to the CGSCC to handle updates. As that
happens, we'll have a better testing basis for adding support like this.

Many thanks to both Justin and Sean for the extensive reviews on this to
help bring the API design and documentation into a better state.

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

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

8 years ago[PM] Turn on the new PM's inliner in addition to the current one for
Chandler Carruth [Tue, 27 Dec 2016 07:18:43 +0000 (07:18 +0000)]
[PM] Turn on the new PM's inliner in addition to the current one for
most of the inliner test cases.

The inliner involves a bunch of interesting code and tends to be where
most of the issues I've seen experimenting with the new PM lie. All of
these test cases pass, but I'd like to keep some more thorough coverage
here so doing a fairly blanket enabling.

There are a handful of interesting tests I've not enabled yet because
they're focused on the always inliner, or on functionality that doesn't
(yet) exist in the inliner.

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

8 years ago[AVX-512] Add all forms of VPALIGNR, VALIGND, and VALIGNQ to the load folding tables.
Craig Topper [Tue, 27 Dec 2016 06:51:09 +0000 (06:51 +0000)]
[AVX-512] Add all forms of VPALIGNR, VALIGND, and VALIGNQ to the load folding tables.

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

8 years ago[PM] Add one of the features left out of the initial inliner patch:
Chandler Carruth [Tue, 27 Dec 2016 06:46:20 +0000 (06:46 +0000)]
[PM] Add one of the features left out of the initial inliner patch:
skipping indirectly recursive inline chains.

To do this, we implicitly build an inline stack for each callsite and
check prior to inlining that doing so would not form a cycle. This uses
the exact same technique and even shares some code with the legacy PM
inliner.

This solution remains deeply unsatisfying to me because it means we
cannot actually iterate the inliner externally. Doing so would not be
able to easily detect and avoid such cycles. Some day I would very much
like to have a solution that works without this internal state to detect
cycles, but this is not that day.

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

8 years ago[PM] Wire up another test to the new pass manager.
Chandler Carruth [Tue, 27 Dec 2016 06:46:16 +0000 (06:46 +0000)]
[PM] Wire up another test to the new pass manager.

Nothing really interesting here, but I had to improve the test to use
variables rather than hard coding value names as we happen to end up
with different value names in the new PM.

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

8 years ago[Analysis] Ignore `nobuiltin` on `allocsize` function calls.
George Burgess IV [Tue, 27 Dec 2016 06:32:14 +0000 (06:32 +0000)]
[Analysis] Ignore `nobuiltin` on `allocsize` function calls.

We currently ignore the `allocsize` attribute on functions calls with
the `nobuiltin` attribute when trying to lower `@llvm.objectsize`. We
shouldn't care about `nobuiltin` here: `allocsize` is explicitly added
by the user, not inferred based on a function's symbol.

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

8 years ago[Analysis] Refactor as promised in r290397.
George Burgess IV [Tue, 27 Dec 2016 06:10:50 +0000 (06:10 +0000)]
[Analysis] Refactor as promised in r290397.

This also makes us no longer check for `allocsize` on intrinsic calls.
This shouldn't matter, since intrinsics should provide the information
we get from `allocsize` on their own.

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

8 years ago[AVX-512] Remove masked pmuldq and pmuludq intrinsics and autoupgrade them to unmaske...
Craig Topper [Tue, 27 Dec 2016 05:30:14 +0000 (05:30 +0000)]
[AVX-512] Remove masked pmuldq and pmuludq intrinsics and autoupgrade them to unmasked intrinsics plus a select.

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

8 years ago[InstCombine][X86] Add DemandedElts support for 512-bit PMULDQ/PMULUDQ instructions
Craig Topper [Tue, 27 Dec 2016 05:30:09 +0000 (05:30 +0000)]
[InstCombine][X86] Add DemandedElts support for 512-bit PMULDQ/PMULUDQ instructions

PMULDQ/PMULUDQ vXi64 instructions only use the even numbered v2Xi32 input elements which SimplifyDemandedVectorElts should try and use.

This builds on r290554 which added supported for 128 and 256-bit.

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

8 years ago[LCG] Teach the LazyCallGraph to handle visiting the blockaddress
Chandler Carruth [Tue, 27 Dec 2016 05:00:45 +0000 (05:00 +0000)]
[LCG] Teach the LazyCallGraph to handle visiting the blockaddress
constant expression and to correctly form function reference edges
through them without crashing because one of the operands (the
`BasicBlock` isn't actually a constant despite being an operand of
a constant).

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

8 years ago[AVX-512] Add 512-bit unmasked intrinsics for pmuldq and pmuludq so we can add them...
Craig Topper [Tue, 27 Dec 2016 03:46:05 +0000 (03:46 +0000)]
[AVX-512] Add 512-bit unmasked intrinsics for pmuldq and pmuludq so we can add them to InstCombine with the 128 and 256 bit versions.

The 128 and 256 bit masked intrinsics are currently unused by clang. The sse and avx2 unmasked intrinsics are used instead. The new 512-bit intrinsic will be used to do the same. Then all masked versions will removed and autoupgraded.

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

8 years ago[PM] Teach the inliner in the new PM to merge attributes after inlining.
Chandler Carruth [Tue, 27 Dec 2016 03:39:54 +0000 (03:39 +0000)]
[PM] Teach the inliner in the new PM to merge attributes after inlining.

Also enable the new PM in the attributes test case which caught this
issue.

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