Commit Graph

148405 Commits

Author SHA1 Message Date
Reid Kleckner
a8aa665131 [IR] Delete unused Argument::removeAttr overload
It doesn't make sense to remove an AttributeList from an argument.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301663 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-28 17:58:18 +00:00
Adrian Prantl
2a5bddd278 Clean up DIExpression::prependDIExpr a little. (NFC)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301662 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-28 17:51:05 +00:00
Peter Collingbourne
b64e9f11ab Bitcode: Do not remove empty summary entries when reading a per-module summary.
This became no longer necessary after D19462 landed, and will be incompatible
with an upcoming change to the summary data structures that changes how we
represent references.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301660 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-28 17:41:43 +00:00
Saleem Abdulrasool
b73a15109d IR: fix some doxygen grammar (NFC)
Fix a bit of the doxygen grammar that was off that I noticed while
looking at this file for another issue.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301658 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-28 17:18:28 +00:00
Craig Topper
78b412f427 [APInt] Add clearSignBit method. Use it and setSignBit in a few places. NFCI
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301656 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-28 16:58:05 +00:00
Craig Topper
f743447b5e [LazyValueInfo] Fix typo in comment. NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301655 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-28 16:57:59 +00:00
Craig Topper
b08a076cbf [ValueTracking] Use APInt::isSubsetOf and APInt::intersects. NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301654 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-28 16:57:55 +00:00
Alexei Starovoitov
c01803866e [bpf] add bigendian support to disassembler
. swap 4-bit register encoding, 16-bit offset and 32-bit imm to support big endian archs
. add a test

Reported-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301653 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-28 16:51:01 +00:00
Tim Northover
0bda850299 CMake: ignore git stderr when trying to sort out revision. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301650 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-28 16:06:00 +00:00
Jun Bum Lim
98e89d3bb4 [InlineCost] Improve the cost heuristic for Switch
Summary:
The motivation example is like below which has 13 cases but only 2 distinct targets

```
lor.lhs.false2:                                   ; preds = %if.then
  switch i32 %Status, label %if.then27 [
    i32 -7012, label %if.end35
    i32 -10008, label %if.end35
    i32 -10016, label %if.end35
    i32 15000, label %if.end35
    i32 14013, label %if.end35
    i32 10114, label %if.end35
    i32 10107, label %if.end35
    i32 10105, label %if.end35
    i32 10013, label %if.end35
    i32 10011, label %if.end35
    i32 7008, label %if.end35
    i32 7007, label %if.end35
    i32 5002, label %if.end35
  ]
```
which is compiled into a balanced binary tree like this on AArch64 (similar on X86)

```
.LBB853_9:                              // %lor.lhs.false2
        mov     w8, #10012
        cmp             w19, w8
        b.gt    .LBB853_14
// BB#10:                               // %lor.lhs.false2
        mov     w8, #5001
        cmp             w19, w8
        b.gt    .LBB853_18
// BB#11:                               // %lor.lhs.false2
        mov     w8, #-10016
        cmp             w19, w8
        b.eq    .LBB853_23
// BB#12:                               // %lor.lhs.false2
        mov     w8, #-10008
        cmp             w19, w8
        b.eq    .LBB853_23
// BB#13:                               // %lor.lhs.false2
        mov     w8, #-7012
        cmp             w19, w8
        b.eq    .LBB853_23
        b       .LBB853_3
.LBB853_14:                             // %lor.lhs.false2
        mov     w8, #14012
        cmp             w19, w8
        b.gt    .LBB853_21
// BB#15:                               // %lor.lhs.false2
        mov     w8, #-10105
        add             w8, w19, w8
        cmp             w8, #9          // =9
        b.hi    .LBB853_17
// BB#16:                               // %lor.lhs.false2
        orr     w9, wzr, #0x1
        lsl     w8, w9, w8
        mov     w9, #517
        and             w8, w8, w9
        cbnz    w8, .LBB853_23
.LBB853_17:                             // %lor.lhs.false2
        mov     w8, #10013
        cmp             w19, w8
        b.eq    .LBB853_23
        b       .LBB853_3
.LBB853_18:                             // %lor.lhs.false2
        mov     w8, #-7007
        add             w8, w19, w8
        cmp             w8, #2          // =2
        b.lo    .LBB853_23
// BB#19:                               // %lor.lhs.false2
        mov     w8, #5002
        cmp             w19, w8
        b.eq    .LBB853_23
// BB#20:                               // %lor.lhs.false2
        mov     w8, #10011
        cmp             w19, w8
        b.eq    .LBB853_23
        b       .LBB853_3
.LBB853_21:                             // %lor.lhs.false2
        mov     w8, #14013
        cmp             w19, w8
        b.eq    .LBB853_23
// BB#22:                               // %lor.lhs.false2
        mov     w8, #15000
        cmp             w19, w8
        b.ne    .LBB853_3
```
However, the inline cost model estimates the cost to be linear with the number
of distinct targets and the cost of the above switch is just 2 InstrCosts.
The function containing this switch is then inlined about 900 times.

This change use the general way of switch lowering for the inline heuristic. It
etimate the number of case clusters with the suitability check for a jump table
or bit test. Considering the binary search tree built for the clusters, this
change modifies the model to be linear with the size of the balanced binary
tree. The model is off by default for now :
  -inline-generic-switch-cost=false

This change was originally proposed by Haicheng in D29870.

Reviewers: hans, bmakam, chandlerc, eraman, haicheng, mcrosier

Reviewed By: hans

Subscribers: joerg, aemerson, llvm-commits, rengolin

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301649 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-28 16:04:03 +00:00
Simon Pilgrim
a91ff63def Move variable local to where ita used. NFCI.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301646 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-28 14:42:15 +00:00
Teresa Johnson
4a6d61ac00 Memory intrinsic value profile optimization: Avoid divide by 0
Summary:
Skip memops if the total value profiled count is 0, we can't correctly
scale up the counts and there is no point anyway.

Reviewers: davidxl

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301645 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-28 14:30:54 +00:00
Simon Pilgrim
053e5ff4f2 [DAGCombiner] Add ComputeNumSignBits vector demanded elements support to ASHR and INSERT_VECTOR_ELT (reapplied)
Reapplied r299221 after fix for nondeterminism in ThinLTO builder (rL301599), with extra check for implicit truncation of inserted element.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301644 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-28 13:21:18 +00:00
Simon Pilgrim
3f8cc3a1fa [X86][SSE] Added new tests from D32416 to show codegen delta
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301641 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-28 11:53:08 +00:00
Simon Pilgrim
3687a706a6 [X86][SSE] Renames all ones test to better match type.
Added 8f32/4f64 optsize tests discussed on D32416

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301639 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-28 11:12:30 +00:00
Simon Pilgrim
3ab21de299 [X86][SSE] Add codegen test for _mm_set_pd1 (PR32827)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301638 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-28 10:31:42 +00:00
Diana Picus
bfa8af672c [ARM] GlobalISel: fixup r301632
Actually remove ARMInstructionSelector.h... Forgot to stage the removal
in the previous commit.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301633 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-28 09:20:31 +00:00
Diana Picus
86a97982f2 [ARM] GlobalISel: Get rid of ARMInstructionSelector.h. NFC.
Declare the ARMInstructionSelector in an anonymous namespace, to make it
more in line with the other targets which were migrated to this in
r299637 in order to avoid TableGen'erated headers being included in
non-GlobalISel builds.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301632 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-28 09:10:38 +00:00
George Rimar
c939b6ae1d [DWARF] - Fix mistype in dump output of pub* tables. NFC.
There was a garbage character in output introduced by myself in
r290040 "[DWARF] - Introduce DWARFDebugPubTable class for dumping pub* sections."


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301631 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-28 08:54:10 +00:00
Andrew Ng
9d0dc96310 [DebugInfo][X86] Improve X86 Optimize LEAs handling of debug values.
This is a follow up to the fix in r298360 to improve the handling of debug
values when redundant LEAs are removed. The fix in r298360 effectively
discarded the debug values. This patch now attempts to preserve the debug
values by using the DWARF DW_OP_stack_value operation via prependDIExpr.

Moved functions appendOffset and prependDIExpr from Local.cpp to
DebugInfoMetadata.cpp and made them available as static member functions of
DIExpression.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301630 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-28 08:44:30 +00:00
Craig Topper
0542dc78c1 [WebAssembly] Update calls to computeKnownBits after the changes from r301620.
I didn't realize WebAssembly wasn't a default build target so I missed that changes were needed.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301629 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-28 08:15:33 +00:00
Clement Courbet
f3cedbee5b [X86][NFC] Refactor RepMovsRepeats in preparation for D32481.
Differential Revision: https://reviews.llvm.org/D32583

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301628 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-28 07:56:31 +00:00
Diana Picus
437c585311 [ARM] GlobalISel: Tighten test. NFC
Explicitly check types and load sizes in the IRTranslator test.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301627 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-28 07:50:47 +00:00
Craig Topper
955683a5c6 [ValueTracking] Convert computeKnownBitsFromRangeMetadata to use KnownBits struct.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301626 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-28 06:28:56 +00:00
Max Kazantsev
6faf1a3c28 [EarlyCSE] Mark the condition of assume intrinsic as true
EarlyCSE should not just ignore assumes. It should use the fact that its condition is true for all dominated instructions.

Reviewers: sanjoy, reames, apilipenko, anna, skatkov

Reviewed By: reames, sanjoy

Subscribers: llvm-commits

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301625 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-28 06:25:39 +00:00
Max Kazantsev
49ccc8d7cb [EarlyCSE] Remove guards with conditions known to be true
If a condition is calculated only once, and there are multiple guards on this condition, we should be able
to remove all guards dominated by the first of them. This patch allows EarlyCSE to try to find the condition
of a guard among the known values, and if it is true, remove the guard. Otherwise we keep the guard and
mark its condition as 'true' for future consideration.

Reviewers: sanjoy, reames, apilipenko, skatkov, anna, dberlin

Reviewed By: reames, sanjoy

Subscribers: llvm-commits

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301623 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-28 06:05:48 +00:00
Craig Topper
8b430f87e6 [SelectionDAG] Use KnownBits struct in DAG's computeKnownBits and simplifyDemandedBits
This patch replaces the separate APInts for KnownZero/KnownOne with a single KnownBits struct. This is similar to what was done to ValueTracking's version recently.

This is largely a mechanical transformation from KnownZero to Known.Zero.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301620 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-28 05:31:46 +00:00
Craig Topper
cdfc3cbcb5 [SelectionDAG] Use various APInt methods to reduce temporary APInt creation
This patch uses various APInt methods to reduce the number of temporary APInts. These were all found while working through converting SelectionDAG's computeKnownBits to also use the KnownBits struct recently added to the ValueTracking version.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301618 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-28 04:57:59 +00:00
Sanjoy Das
afd31bcedd Remove unnecessary semicolon
This shows up as a -Wpendatic error on GCC.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301616 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-28 04:49:32 +00:00
Sanjoy Das
edb3c90b17 [StackMaps] Increase the size of the "location size" field
Summary:
In some cases LLVM (especially the SLP vectorizer) will create vectors
that are 256 bytes (or larger).  Given that this is intentional[0] is
likely to get more common, this patch updates the StackMap binary
format to deal with the spill locations for said vectors.

This change also bumps the stack map version from 2 to 3.

[0]: https://reviews.llvm.org/D32533#738350

Reviewers: reames, kavon, skatkov, javed.absar

Subscribers: mcrosier, nemanjai, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301615 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-28 04:48:42 +00:00
Saleem Abdulrasool
df4f50c81f COFF Import: expose both symbols
COFF Import libraries which use the obsolete CONSTANT export are
supposed to get two symbols, one with the `_imp_` prefix and one
without.  Ensure that we expose both for iteration.  This is necessary
to fix the librarian with COFF CONSTANT exports.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301614 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-28 04:29:43 +00:00
Craig Topper
a7fa95c0e5 [APInt] Use inplace shift methods where possible. NFCI
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301612 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-28 03:36:24 +00:00
Zachary Turner
a102628313 [llvm-pdbdump] Allow printing only a portion of a stream.
When dumping raw data from a stream, you might know the offset
of a certain record you're interested in, as well as how long
that record is.  Previously, you had to dump the entire stream
and wade through the bytes to find the interesting record.

This patch allows you to specify an offset and length on the
command line, and it will only dump the requested range.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301607 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-28 00:43:38 +00:00
Sam Clegg
4275ee9fcb [WebAssembly] Add some tests for wasm MC layer
Subscribers: jfb, dschuff

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301606 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-28 00:36:36 +00:00
Davide Italiano
6b435e94b7 [SROA] Fix nondeterminism exposed by Simon's r299221.
Use a SmallSetSetVector instead of a SmallPtrSet as iterating
over the latter is not stable ('<' relies on addresses).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301599 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-27 23:09:01 +00:00
Frederich Munch
b6e6c85f4f Fix a few pedantic warnings.
Reviewers: zturner, hansw, hans

Reviewed By: hans

Subscribers: hans, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301595 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-27 22:10:57 +00:00
Sanjay Patel
402d01739e [InstCombine] fix matcher to bind to specific operand (PR32830)
Matching any random value would be very wrong:
https://bugs.llvm.org/show_bug.cgi?id=32830


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301594 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-27 21:55:03 +00:00
Sanjoy Das
af3c2de37e Specify something that's true in practice
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301591 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-27 20:55:07 +00:00
Evgeniy Stepanov
226bbc3937 [asan] Fix dead stripping of globals on Linux.
Use a combination of !associated, comdat, @llvm.compiler.used and
custom sections to allow dead stripping of globals and their asan
metadata. Sometimes.

Currently this works on LLD, which supports SHF_LINK_ORDER with
sh_link pointing to the associated section.

This also works on BFD, which seems to treat comdats as
all-or-nothing with respect to linker GC. There is a weird quirk
where the "first" global in each link is never GC-ed because of the
section symbols.

At this moment it does not work on Gold (as in the globals are never
stripped).

This is a second re-land of r298158. This time, this feature is
limited to -fdata-sections builds.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301587 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-27 20:27:27 +00:00
Evgeniy Stepanov
cd2999ea45 [asan] Put ctor/dtor in comdat.
When possible, put ASan ctor/dtor in comdat.

The only reason not to is global registration, which can be
TU-specific. This is not the case when there are no instrumented
globals. This is also limited to ELF targets, because MachO does
not have comdat, and COFF linkers may GC comdat constructors.

The benefit of this is a lot less __asan_init() calls: one per DSO
instead of one per TU. It's also necessary for the upcoming
gc-sections-for-globals change on Linux, where multiple references to
section start symbols trigger quadratic behaviour in gold linker.

This is a second re-land of r298756. This time with a flag to disable
the whole thing to avoid a bug in the gold linker:
  https://sourceware.org/bugzilla/show_bug.cgi?id=19002

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301586 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-27 20:27:23 +00:00
Simon Pilgrim
b0c82b846c [X86][SSE] Add tests for broadcast from larger vector loads
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301583 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-27 20:19:00 +00:00
Zachary Turner
224acd2453 [llvm-readobj] Dump COFF Resources section.
This patch dumps the raw bytes of the .rsrc sections that
are present in COFF object and executable files.  Subsequent
patches will parse this information and dump in a more human
readable format.

Differential Revision: https://reviews.llvm.org/D32463
Patch By: Eric Beckmann

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301578 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-27 19:38:38 +00:00
Chandler Carruth
1d4cf6e01f [PM/LoopUnswitch] Introduce a new, simpler loop unswitch pass.
Currently, this pass only focuses on *trivial* loop unswitching. At that
reduced problem it remains significantly better than the current loop
unswitch:
- Old pass is worse than cubic complexity. New pass is (I think) linear.
- New pass is much simpler in its design by focusing on full unswitching. (See
  below for details on this).
- New pass doesn't carry state for thresholds between pass iterations.
- New pass doesn't carry state for correctness (both miscompile and
  infloop) between pass iterations.
- New pass produces substantially better code after unswitching.
- New pass can handle more trivial unswitch cases.
- New pass doesn't recompute the dominator tree for the entire function
  and instead incrementally updates it.

I've ported all of the trivial unswitching test cases from the old pass
to the new one to make sure that major functionality isn't lost in the
process. For several of the test cases I've worked to improve the
precision and rigor of the CHECKs, but for many I've just updated them
to handle the new IR produced.

My initial motivation was the fact that the old pass carried state in
very unreliable ways between pass iterations, and these mechansims were
incompatible with the new pass manager. However, I discovered many more
improvements to make along the way.

This pass makes two very significant assumptions that enable most of these
improvements:

1) Focus on *full* unswitching -- that is, completely removing whatever
   control flow construct is being unswitched from the loop. In the case
   of trivial unswitching, this means removing the trivial (exiting)
   edge. In non-trivial unswitching, this means removing the branch or
   switch itself. This is in opposition to *partial* unswitching where
   some part of the unswitched control flow remains in the loop. Partial
   unswitching only really applies to switches and to folded branches.
   These are very similar to full unrolling and partial unrolling. The
   full form is an effective canonicalization, the partial form needs
   a complex cost model, cannot be iterated, isn't canonicalizing, and
   should be a separate pass that runs very late (much like unrolling).

2) Leverage LLVM's Loop machinery to the fullest. The original unswitch
   dates from a time when a great deal of LLVM's loop infrastructure was
   missing, ineffective, and/or unreliable. As a consequence, a lot of
   complexity was added which we no longer need.

With these two overarching principles, I think we can build a fast and
effective unswitcher that fits in well in the new PM and in the
canonicalization pipeline. Some of the remaining functionality around
partial unswitching may not be relevant today (not many test cases or
benchmarks I can find) but if they are I'd like to add support for them
as a separate layer that runs very late in the pipeline.

Purely to make reviewing and introducing this code more manageable, I've
split this into first a trivial-unswitch-only pass and in the next patch
I'll add support for full non-trivial unswitching against a *fixed*
threshold, exactly like full unrolling. I even plan to re-use the
unrolling thresholds, as these are incredibly similar cost tradeoffs:
we're cloning a loop body in order to end up with simplified control
flow. We should only do that when the total growth is reasonably small.

One of the biggest changes with this pass compared to the previous one
is that previously, each individual trivial exiting edge from a switch
was unswitched separately as a branch. Now, we unswitch the entire
switch at once, with cases going to the various destinations. This lets
us unswitch multiple exiting edges in a single operation and also avoids
numerous extremely bad behaviors, where we would introduce 1000s of
branches to test for thousands of possible values, all of which would
take the exact same exit path bypassing the loop. Now we will use
a switch with 1000s of cases that can be efficiently lowered into
a jumptable. This avoids relying on somehow forming a switch out of the
branches or getting horrible code if that fails for any reason.

Another significant change is that this pass actively updates the CFG
based on unswitching. For trivial unswitching, this is actually very
easy because of the definition of loop simplified form. Doing this makes
the code coming out of loop unswitch dramatically more friendly. We
still should run loop-simplifycfg (at the least) after this to clean up,
but it will have to do a lot less work.

Finally, this pass makes much fewer attempts to simplify instructions
based on the unswitch. Something like loop-instsimplify, instcombine, or
GVN can be used to do increasingly powerful simplifications based on the
now dominating predicate. The old simplifications are things that
something like loop-instsimplify should get today or a very, very basic
loop-instcombine could get. Keeping that logic separate is a big
simplifying technique.

Most of the code in this pass that isn't in the old one has to do with
achieving specific goals:
- Updating the dominator tree as we go
- Unswitching all cases in a switch in a single step.

I think it is still shorter than just the trivial unswitching code in
the old pass despite having this functionality.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301576 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-27 18:45:20 +00:00
Eli Friedman
9dc569fec5 [GlobalOpt] Correctly update metadata when localizing a global.
Just calling dropAllReferences leaves pointers to the ConstantExpr
behind, so we would eventually crash with a null pointer dereference.

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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301575 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-27 18:39:08 +00:00
Teresa Johnson
913d272566 Memory intrinsic value profile optimization: Improve debug output (NFC)
Summary:
Misc improvements to debug output. Fix a couple typos and also dump the
value profile before we make any profitability checks.

Reviewers: davidxl

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301574 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-27 18:25:22 +00:00
Frederich Munch
bb41cb2e32 Limit disabling of warnings emitted from r301571 by checking __GNUC__.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301572 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-27 18:05:29 +00:00
Frederich Munch
b6ceaa4758 Fix warnings from test added in r301562 on Windows (when built without exceptions).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301571 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-27 17:33:50 +00:00
Vassil Vassilev
94e7e888f8 Sync with changes from r300825 in clang.
Generate the better include paths. Instead of #include <llvm_header.h> doxygen
produces #include "llvm/Folder/llvm_header.h"

Patch by Yuka Takahashi (D32342)!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301569 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-27 17:23:53 +00:00
Sanjoy Das
b3ab6b2622 Use a pointer type for target frame indices during statepoint lowering
Summary:
The type of the target frame index is intptr, not the type of the value we're
going to store into it.  Without this change we crash in the attached test case
when trying to type-legalize a TargetFrameIndex.

Patchpoint lowering types the target frame index as intptr as well.

Reviewers: reames, bogner, arsenm

Subscribers: arsenm, mcrosier, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301566 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-27 17:17:16 +00:00
Peter Collingbourne
5cb8f64327 cmake: Touch $GIT_DIR/logs/HEAD if it does not already exist.
Apparently some git tools (such as "repo") may not create this file.
Patch by Quentin Neill.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301565 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-27 17:04:05 +00:00