Commit Graph

91575 Commits

Author SHA1 Message Date
Tom Stellard
60f588f570 AMDGPU/SI: Make sure to emit TargetConstant nodes when matching ds_*permute
Summary:
This fixes a bug with ds_*permute instructions where if it was passed a
constant address, then the offset operand would get assigned a register
operand instead of an immediate.

Reviewers: scchan, arsenm

Subscribers: arsenm, llvm-commits

Differential Revision: http://reviews.llvm.org/D19994

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272349 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-10 00:01:04 +00:00
Tom Stellard
aeca746050 AMDGPU/SI: Use common topological sort algorithm in SIScheduleDAGMI
Reviewers: arsenm, axeldavy

Subscribers: MatzeB, arsenm, llvm-commits

Differential Revision: http://reviews.llvm.org/D19823

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272346 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-09 23:48:02 +00:00
Matt Arsenault
4080a06a24 AMDGPU: Fix flat atomics
The flat atomics could already be selected, but only
when using flat instructions for global memory. Add
patterns for flat addresses.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272345 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-09 23:42:54 +00:00
Matt Arsenault
bada556f73 AMDGPU: Fix i64 global cmpxchg
This was using extract_subreg sub0 to extract the low register
of the result instead of sub0_sub1, producing an invalid copy.

There doesn't seem to be a way to use the compound subreg indices
in tablegen since those are generated, so manually select it.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272344 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-09 23:42:48 +00:00
Vitaly Buka
e330b7d89a Make sure that not interesting allocas are not instrumented.
Summary:
We failed to unpoison uninteresting allocas on return as unpoisoning is part of
main instrumentation which skips such allocas.

Added check -asan-instrument-allocas for dynamic allocas. If instrumentation of
dynamic allocas is disabled it will not will not be unpoisoned.

PR27453

Reviewers: kcc, eugenis

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D21207

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272341 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-09 23:31:59 +00:00
Matt Arsenault
dcd25f4149 CodeGen: Allow verifier to run after MachineBlockPlacement
No tests break with this enabled.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272340 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-09 23:31:55 +00:00
Eric Christopher
7da58e6313 Add aliases for mfvrsave/mtvrsave.
Update a test as we're now going to emit it for easier reading of
generated assembly as well.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272339 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-09 23:27:48 +00:00
Matt Arsenault
b8aff5533e AMDGPU: Run verifer after insert waits pass
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272338 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-09 23:19:14 +00:00
Matt Arsenault
3b52126962 AMDGPU: Remove incorrect assertion
I'm still not sure under what circumstances the offset here is non-0,
but private memory is not limited to 27-bits.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272337 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-09 23:19:08 +00:00
Matt Arsenault
dad6f6f388 AMDGPU: Properly initialize SIShrinkInstructions
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272336 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-09 23:18:47 +00:00
George Burgess IV
bec2df684f [CFLAA] Handle global/arg attrs more sanely.
Prior to this patch, we used argument/global stratified attributes in
order to note that a value could have come from either dereferencing a
global/arg, or from the assignment from a global/arg.

Now, AttrUnknown is placed on sets when we see a dereference, instead of
the global/arg attributes. This allows us to be more aggressive in the
future when we see global/arg attributes without AttrUnknown.

Patch by Jia Chen.

Differential Revision: http://reviews.llvm.org/D21110


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272335 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-09 23:15:04 +00:00
Vitaly Buka
af4c28d141 Unpoison stack memory in use-after-return + use-after-scope mode
Summary:
We still want to unpoison full stack even in use-after-return as it can be disabled at runtime.

PR27453

Reviewers: eugenis, kcc

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D21202

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272334 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-09 23:05:35 +00:00
Alina Sbirlea
337c62e99d Reapply 272328 and 272329 as a single patch.
[cpu-detection] [amdfam10] Return barcelona, and amdfam10 for all other
subtypes. Address Bug 28067.

Along with the refactoring of Host.cpp, getHostCPUName() was modified to
return more precise types for CPUs in amdfam10.
However, callers of getHostCPUName() do string matching on type, so this
cannot be modified.
Currently there is support in the x86 backend for barcelona.
For all other subtypes the assumed return value is amdfam10.

Fix: getHostCPUName() returns barcelona subtype and amdfam10 for all
others. This can be extended further when support for the other subtypes
is added.

Differential revision: http://reviews.llvm.org/D21193

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272333 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-09 23:04:15 +00:00
Alina Sbirlea
3bd97ac17f Revert 272328 and 272329 to recommit as a single patch.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272332 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-09 23:04:05 +00:00
Alina Sbirlea
05161061c3 Keep barcelona subtype for amdfam10
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272329 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-09 22:47:36 +00:00
Alina Sbirlea
539e7710fb [cpu-detection] Return amdfam10 for all subtypes. Address Bug 28067.
Summary: Remove architecture subtype from the string returned by getHostCPUName(). String matching done on type.

Reviewers: llvm-commits, echristo

Subscribers: mehdi_amini

Differential Revision: http://reviews.llvm.org/D21193

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272328 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-09 22:47:12 +00:00
Easwaran Raman
f8bdcad7be Use ProfileSummaryInfo in inline cost analysis.
Instead of directly using MaxFunctionCount and function entry count to determine callee hotness, use the isHotFunction/isColdFunction methods provided by ProfileSummaryInfo.

Differential revision: http://reviews.llvm.org/D21045


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272321 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-09 22:23:21 +00:00
Simon Pilgrim
8f579ce1a6 [X86][AVX512] Added avx512 VPSLLDQ/VPSRLDQ instruction comments
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272319 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-09 22:03:15 +00:00
Quentin Colombet
80b353ddd5 [LiveRangeEdit] Fix a crash in eliminateDeadDef.
When we delete a live-range, we check if that live-range is the origin of others
to keep it around for rematerialization. For that we check that the instruction
we are about to remove is the same as the definition of the VNI of the original
live-range.
If this is the case, we just shrink the live-range to an empty one.

Now, when we try to delete one of the children of such live-range (product of
splitting), we do the same check.
However, now the original live-range is empty and there is no way we can
access the VNI to check its definition, and we crash.

When we cannot get the VNI for the original live-range, that means we are not in
the presence of the original definition. Thus, this check does not need to happen
in that case and the crash is sloved!

This bug was introduced in r266162 | wmi | 2016-04-12 20:08:27. It affects every
target that uses the greedy register allocator.
To happen, we need to delete both a the original instruction and its split
products, in that order. This is likely to happen when rematerialization comes
into play.

Trying to produce a more robust test case. Will follow in a coming commit.

This fixes llvm.org/PR27983.

rdar://problem/26651519 


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272314 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-09 21:34:31 +00:00
Simon Pilgrim
3ddec70a78 [X86][AVX512] Dropped avx512 VPSLLDQ/VPSRLDQ intrinsics
Auto-upgrade to generic shuffles like sse/avx2 implementations now that we can lower to VPSLLDQ/VPSRLDQ 

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272308 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-09 21:09:03 +00:00
Simon Pilgrim
f921bac68f [X86][AVX512] Fixed issue with v16i32 shuffles lowering to VPALIGNR
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272307 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-09 20:53:12 +00:00
Duncan P. N. Exon Smith
52fe45ec5e BitcodeReader: Use std:::piecewise_construct when upgrading type refs
r267296 used std::piecewise_construct without using
std::forward_as_tuple, and r267298 hacked it out (using an emplace_back
followed by a couple of reset() calls) because of a problem on a bot.
I'm finally circling back to call forward_as_tuple as I should have to
begin with (thanks to David Blaikie for pointing out the missing piece).

Note that this code uses emplace_back() instead of
push_back(make_pair()) because the move constructor for TrackingMDRef is
expensive (cheaper than a copy, but still expensive).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272306 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-09 20:46:33 +00:00
Simon Pilgrim
9ceba992f6 [X86][AVX512] Added support for lowering 512-bit vector shuffles to bit/byte shifts
512-bit VPSLLDQ/VPSRLDQ can only be used for avx512bw targets so lowerVectorShuffleAsShift had to be adjusted to include the subtarget

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272300 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-09 20:13:58 +00:00
Justin Lebar
dd9e8b3bcc [NVPTX] Add intrinsics for shfl instructions.
Summary:
Currently clang emits these instructions via inline (volatile) asm in
the CUDA headers.  Switching to intrinsics will let the optimizer reason
across calls to these intrinsics.

Reviewers: tra

Subscribers: llvm-commits, jholewinski

Differential Revision: http://reviews.llvm.org/D21160

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272298 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-09 20:04:08 +00:00
Easwaran Raman
33933df91a [PM] Port LCSSA to the new PM.
Differential Revision: http://reviews.llvm.org/D21090


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272294 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-09 19:44:46 +00:00
Wei Ding
39ce7152a2 AMDGPU/SI: Fix 32-bit fdiv lowering
We were using the fast fdiv lowering for all division, implementation of
IEEE754 fdiv is added.

http://reviews.llvm.org/D20557

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272292 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-09 19:17:15 +00:00
Michael Kuperstein
26a9a137a4 [LV] Use vector phis for some secondary induction variables
Previously, we materialized secondary vector IVs from the primary scalar IV,
by offseting the primary to match the correct start value, and then broadcasting
it - inside the loop body. Instead, we can use a real vector IV, like we do for
the primary.

This enables using vector IVs for secondary integer IVs whose type matches the
type of the primary.

Differential Revision: http://reviews.llvm.org/D20932


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272283 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-09 18:03:15 +00:00
Jan Vesely
406c47ff89 SelectionDAG: Implement expansion of {S,U}MIN/MAX in integer legalization
Fixes {u,}long_{min,max,clamp} opencl piglit regressions on EG.

Reviewers: arsenm
Differential Revision: http://reviews.llvm.org/D17898

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272272 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-09 16:04:00 +00:00
Haicheng Wu
c4f2258852 Reapply "[MBP] Reduce code size by running tail merging in MBP.""
This reapplies commit r271930, r271915, r271923.  They hit a bug in
Thumb which is fixed in r272258 now.

The original message:

The code layout that TailMerging (inside BranchFolding) works on is not the
final layout optimized based on the branch probability. Generally, after
BlockPlacement, many new merging opportunities emerge.

This patch calls Tail Merging after MBP and calls MBP again if Tail Merging
merges anything.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272267 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-09 15:24:29 +00:00
Ulrich Weigand
09f4ea27b7 [SystemZ] Enable long displacement constraints for inline ASM operands
This enables use of the 'S' constraint for inline ASM operands on
SystemZ, which allows for a memory reference with a signed 20-bit
immediate displacement. This patch includes corresponding documentation
and test case updates.

I've changed the 'T' constraint to match the new behavior for 'S', as
'T' also uses a long displacement (though index constraints are still
not implemented). I also changed 'm' to match the behavior for 'S' as
this will allow for a wider range of displacements for 'm', though
correct me if that's not the right decision.

Author: colpell
Differential Revision: http://reviews.llvm.org/D21097



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272266 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-09 15:19:16 +00:00
Davide Italiano
cb6cf5b6ec [CodeGen] Change getSDagStackGuard to get an internal sym.
Fixes a crash in the backend during an LTO build of rtld(1) in
FreeBSD.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272262 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-09 14:23:38 +00:00
Hrvoje Varga
221d208604 [mips][microMIPS] Implement BOVC, BNVC, EXT, INS and JALRC instructions
Differential Revision: http://reviews.llvm.org/D11798


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272259 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-09 12:57:23 +00:00
James Molloy
fe8f3cffbd [Thumb] A branch is not part of an IT block
ReplaceTailWithBranchTo assumed that if an instruction is predicated, it must be part of an IT block. This is not correct for conditional branches.

No testcase as this was triggered by the reverted patch r272017 - test coverage will occur when that patch is re-reverted and there is no known way to trigger this in the meantime.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272258 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-09 11:51:29 +00:00
Igor Breger
de21197e48 [AVX512] Remove masked_move/blendm intrinsic from back-end.
This is complement patch to D21060.

Differential Revision: http://reviews.llvm.org/D21174

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272257 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-09 11:46:55 +00:00
Zlatko Buljan
2edd549258 [mips][microMIPS] Add CodeGen support for SEL.*, SELEQZ, SELNEZ, SELEQZ.*, SELNEZ.* and CMP.condn.fmt instructions
Differential Revision: http://reviews.llvm.org/D20862


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272256 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-09 11:15:53 +00:00
Sam Kolton
eb66787999 [AMDGPU] Disassembler: Support for sdwa instructions
Reviewers: vpykhtin, tstellarAMD

Subscribers: arsenm, kzhuravl

Differential Revision: http://reviews.llvm.org/D21129

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272255 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-09 11:04:45 +00:00
Craig Topper
b867bf3ea9 [AVX512] Fix shuffle decode printing for several instructions with write masks. There are still more bugs here with UNPCK and PALIGN for sure. But these were the easiest ones to fix.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272252 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-09 07:49:08 +00:00
James Molloy
95709cad3b [Thumb] Select a BIC instead of AND if the immediate can be encoded more optimally negated
If an immediate is only used in an AND node, it is possible that the immediate can be more optimally materialized when negated. If this is the case, we can negate the immediate and use a BIC instead;

  int i(int a) {
    return a & 0xfffffeec;
  }

Used to produce:
    ldr r1, [CONSTPOOL]
    ands r0, r1
  CONSTPOOL: 0xfffffeec

And now produces:
    movs    r1, #255
    adds    r1, #20  ; Less costly immediate generation
    bics    r0, r1

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272251 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-09 07:39:08 +00:00
Craig Topper
1b683873d6 [X86] Bring consistent naming to the SSE/AVX and AVX512 PALIGNR instructions. Then add shuffle decode printing for the EVEX forms which is made easier by having the naming structure more similar to other instructions.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272249 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-09 07:06:38 +00:00
Craig Topper
d7bd8be924 [X86] Fix bad comment in assert. NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272248 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-09 07:06:33 +00:00
Xinliang David Li
035a5a9202 Revert r272194 No need for it if loop Analysis Manager is used
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272243 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-09 03:22:39 +00:00
Saleem Abdulrasool
d389f8dd86 AArch64: support the .arch directive in the IAS
Add support to the AArch64 IAS for the `.arch` directive.  This allows the
assembly input to use architectural functionality in part of a file.  This is
used in existing code like BoringSSL.

Resolves PR26016!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272241 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-09 02:56:40 +00:00
Kostya Serebryany
41a5827cd3 [libFuzzer] add one more OOM test, which we currently don't handle very well
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272240 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-09 01:20:35 +00:00
Teresa Johnson
875352d9b1 [ThinLTO/gold] Enable summary-based internalization
Summary: Enable existing summary-based importing support in the gold-plugin.

Reviewers: mehdi_amini

Subscribers: llvm-commits, mehdi_amini

Differential Revision: http://reviews.llvm.org/D21080

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272239 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-09 01:14:13 +00:00
Sanjoy Das
0c3d257062 Minor clean up in loopHasNoAbnormalExits; NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272238 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-09 01:14:03 +00:00
Sanjoy Das
05c5b3fd8e Be wary of abnormal exits from loop when exploiting UB
We can safely rely on a NoWrap add recurrence causing UB down the road
only if we know the loop does not have a exit expressed in a way that is
opaque to ScalarEvolution (e.g. by a function call that conditionally
calls exit(0)).

I believe with this change PR28012 is fixed.

Note: I had to change some llvm-lit tests in LoopReroll, since it looks
like they were depending on this incorrect behavior.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272237 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-09 01:13:59 +00:00
Sanjoy Das
ec34b02b63 Factor out a loopHasNoAbnormalExits; NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272236 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-09 01:13:54 +00:00
Richard Smith
0eeb3d4004 Search for llvm-symbolizer binary in the same directory as argv[0], before
looking for it along $PATH. This allows installs of LLVM tools outside of
$PATH to find the symbolizer and produce pretty backtraces if they crash.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272232 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-09 00:53:21 +00:00
Reid Kleckner
14f9bce989 [codeview] Skip DIGlobalVariables with no variable
They have probably been discarded during optimization.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272231 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-09 00:29:00 +00:00
Rui Ueyama
6ec1d4e8bf [pdbdump] Verify part of TPI hash streams.
TPI hash table contains a parallel array for the type records.
For each type record R, a hash value is calculated by `H(R) % NumBuckets`
where H is a hash function, and the result is stored to a bucket element.
H is TPI1::hashPrec function in microsoft-pdb repository.

Our hash function does not support all type record types yet.
Currently it supports only records for line number.
I'll extend it in a follow up patch.

The aim of verify the hash table is not only detect corrupted files.
It ensures that our understanding of how the hash values are calculated
is correct.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272229 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-09 00:10:19 +00:00
Alina Sbirlea
1ad4b76720 [cpu-detection] Add missing break statements in outer switches
Summary:
Break on all switch cases for outer and inner switches.
No functionality changed.

Reviewers: llvm-commits, sanjoy

Differential Revision: http://reviews.llvm.org/D21158

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272228 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-09 00:08:15 +00:00
Quentin Colombet
c4f21c06ed [MIR] Check that generic virtual registers get a size.
Without that check it was possible to write test cases where the size
was not specified and we ended up with weird asserts down the road,
because the default value (1) would not make sense.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272226 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-08 23:27:46 +00:00
Rui Ueyama
45d1685851 Function names should start with lowercase letters.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272225 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-08 23:15:09 +00:00
Michael Zolotukhin
92be720123 [LoopSimplify] Preserve LCSSA when merging exit blocks.
Summary:
This fixes PR26682. Also add LCSSA as a preserved pass to LoopSimplify,
that looks correct to me and allows to write a test for the issue.

Reviewers: chandlerc, bogner, sanjoy

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D21112

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272224 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-08 23:13:21 +00:00
Rui Ueyama
dc32f35c68 [PDB] Move PDB functions to a separate file.
We are going to use the hash functions from TPI streams.

Differential Revision: http://reviews.llvm.org/D21142

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272223 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-08 23:11:14 +00:00
Michael Zolotukhin
1ead23957a [LoopUnroll] Check that DT is available before trying to verify it.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272221 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-08 22:49:59 +00:00
Quentin Colombet
dd92905160 [RegBankSelect] Print out the actual mapping of the operands.
This improves the debuggability of the pass.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272210 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-08 21:55:30 +00:00
Quentin Colombet
1d9903f754 [RegBankSelect] Remove a debug print of a potentially dead instruction.
For complex rewrittings, which do not occur currently, the related
machine instruction may have been deleted in the process. Therefore, do
not try to print it after the mapping is applied.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272209 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-08 21:55:29 +00:00
Quentin Colombet
dd694f3ed6 [RegisterBankInfo] Avoid code duplication in OperandsMapper for the computation of the end of range.
Refactor the code so that we do not compute in two different places the
end iterator for the range of new virtual registers for a given operand.
Although this refactoring was intended as NFC, this is not the case
because it actually fixes a bug where we were returning a range off by 1
(too long). Right now, this could not result in an actual bug because we
were accessing this range via the BreakDown size of the related operand.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272208 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-08 21:55:26 +00:00
Quentin Colombet
d36db423b8 [RegisterBankInfo] Add dump/print methods for OperandsMapper.
Improve debuggability of the OperandsMapper helper class.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272207 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-08 21:55:23 +00:00
Michael Zolotukhin
f716842ee3 [SLPVectorizer] Handle GEP with differing constant index types
Summary:
This fixes PR27617.

Bug description: The SLPVectorizer asserts on encountering GEPs with different index types, such as i8 and i64.

The patch includes a simple relaxation of the assert to allow constants being of different types, along with a regression test that will provoke the unrelaxed assert.

Reviewers: nadav, mzolotukhin

Subscribers: JesperAntonsson, llvm-commits, mzolotukhin

Differential Revision: http://reviews.llvm.org/D20685

Patch by Jesper Antonsson!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272206 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-08 21:55:16 +00:00
Davide Italiano
5b20b56122 [PM] Add missing caching of GlobalsAA to EarlyCSE.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272204 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-08 21:31:55 +00:00
Dehao Chen
8153f63460 Revive http://reviews.llvm.org/D12778 to handle forward-hot-prob and backward-hot-prob consistently.
Summary:
Consider the following diamond CFG:

 A
/ \
B C
 \/
 D

Suppose A->B and A->C have probabilities 81% and 19%. In block-placement, A->B is called a hot edge and the final placement should be ABDC. However, the current implementation outputs ABCD. This is because when choosing the next block of B, it checks if Freq(C->D) > Freq(B->D) * 20%, which is true (if Freq(A) = 100, then Freq(B->D) = 81, Freq(C->D) = 19, and 19 > 81*20%=16.2). Actually, we should use 25% instead of 20% as the probability here, so that we have 19 < 81*25%=20.25, and the desired ABDC layout will be generated.

Reviewers: djasper, davidxl

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D20989

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272203 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-08 21:30:12 +00:00
Sanjay Patel
5d0ca71de5 [InstCombine] move fold of select of add/sub to helper function; NFCI
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272199 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-08 21:10:01 +00:00
Reid Kleckner
3d3aca2d97 [DebugInfo] Add calling convention support for DWARF and CodeView
Summary:
Now DISubroutineType has a 'cc' field which should be a DW_CC_ enum.  If
it is present and non-zero, the backend will emit it as a
DW_AT_calling_convention attribute. On the CodeView side, we translate
it to the appropriate enum for the LF_PROCEDURE record.

I added a new LLVM vendor specific enum to the list of DWARF calling
conventions. DWARF does not appear to attempt to standardize these, so I
assume it's OK to do this until we coordinate with GCC on how to emit
vectorcall convention functions.

Reviewers: dexonsmith, majnemer, aaboud, amccarth

Subscribers: mehdi_amini, llvm-commits

Differential Revision: http://reviews.llvm.org/D21114

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272197 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-08 20:34:29 +00:00
Sanjay Patel
2ae3d2cd86 [InstCombine] fix outdated comment, simplify logic; NFCI
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272196 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-08 20:31:52 +00:00
Evgeny Stupachenko
3cb6afa22a The patch set unroll disable pragma when unroll
with user specified count has been applied.

Summary:
Previously SetLoopAlreadyUnrolled() set the disable pragma only if
there was some loop metadata.
Now it set the pragma in all cases. This helps to prevent multiple
unroll when -unroll-count=N is given.

Reviewers: mzolotukhin

Differential Revision: http://reviews.llvm.org/D20765

From: Evgeny Stupachenko <evstupac@gmail.com>


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272195 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-08 20:21:24 +00:00
Xinliang David Li
8c60b4112d [PM] Refector LoopAccessInfo analysis code
This is the preparation patch to port the analysis to new PM

Differential Revision: http://reviews.llvm.org/D20560



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272194 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-08 20:15:37 +00:00
Sanjay Patel
0406782714 [InstCombine] reduce indent; NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272193 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-08 20:09:04 +00:00
Tim Shen
c4d0eaa0ba [MemCpyOpt] Do not exchange llvm.lifetime.start and llvm.memcpy
Reviewers: iteratee

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D21087

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272192 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-08 19:42:32 +00:00
Sanjay Patel
0a41b20ac6 [InstCombine] use copyIRFlags() ; NFCI
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272191 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-08 19:33:52 +00:00
Benjamin Kramer
36538ffe93 Apply most suggestions of clang-tidy's performance-unnecessary-value-param
Avoids unnecessary copies. All changes audited & pass tests with asan.
No functional change intended.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272190 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-08 19:09:22 +00:00
Adrian McCarthy
fa4edba0da Generate codeview for array type metadata.
Differential Revision: http://reviews.llvm.org/D21107

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272187 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-08 18:22:59 +00:00
George Burgess IV
05f452d9a1 Attempt #2 to appease the buildbots.
MSVC calls the copy ctor on StratifiedSets for some reason. So,
undelete it.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272184 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-08 17:56:35 +00:00
Reid Kleckner
d3fa84042c [codeview] Avoid emitting an empty file checksum table
Again, the Microsoft linker does not like empty substreams.

We still emit an empty string table if CodeView is enabled, but that
doesn't cause problems because it always contains at least one null
byte.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272183 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-08 17:50:29 +00:00
Sanjoy Das
8999baf434 [SCEV] Break out of loop if there is no more work to do
This is NFC as far as externally visible behavior is concerned, but will
keep us from spinning in the worklist traversal algorithm unnecessarily.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272182 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-08 17:48:46 +00:00
Sanjoy Das
27dabd2db6 [SCEV] Track no-abnormal-exits instead of no-throw calls
Absence of may-unwind calls is not enough to guarantee that a
UB-generating use of an add-rec poison in the loop latch will actually
cause UB.  We also need to guard against calls that terminate the thread
or infinite loop themselves.

This partially addresses PR28012.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272181 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-08 17:48:42 +00:00
Sanjoy Das
39ede080e2 Teach isGuarantdToTransferExecToSuccessor about debug info intrinsics
Calls to `@llvm.dbg.*` can be assumed to terminate.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272180 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-08 17:48:36 +00:00
Sanjoy Das
e118351c7e Fix a bug in SCEV's poison value propagation
The worklist algorithm introduced in rL271151 didn't check to see if the
direct users of the post-inc add recurrence propagates poison.  This
change fixes the problem and makes the code structure more obvious.

Note for release managers: correctness wise, this bug wasn't a
regression introduced by rL271151 -- the behavior of SCEV around
post-inc add recurrences was strictly improved (in terms of correctness)
in rL271151.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272179 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-08 17:48:31 +00:00
Quentin Colombet
76354c5724 [RegBankSelect] Silence an unused variable warning in release mode.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272177 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-08 17:39:47 +00:00
Quentin Colombet
4eb9d7cdeb [RegBankSelect] Comment on how we could improve repairing with copies.
When repairing with a copy, instead of accounting for the cost of that
copy and actually inserting it, we may be able to use an alternative
source for the register to repair and just use it.

Make sure this is documented, so that we consider that opportunity at
some point.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272176 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-08 17:39:43 +00:00
George Burgess IV
6f686563fd Try to appease buildbots.
r272064 apparently made them angry. This undoes some changes made in
r272064 (defaulting move ctors) to make them happy again.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272173 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-08 17:27:14 +00:00
Zachary Turner
99272168e0 [pdb] Handle stream index errors better.
Reviewed By: ruiu
Differential Revision: http://reviews.llvm.org/D21128

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272172 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-08 17:26:39 +00:00
Rui Ueyama
bdd8d795bb Remove a patch .rej file.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272171 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-08 16:54:31 +00:00
Quentin Colombet
792b56f6a7 [AArch64][RegisterBankInfo] G_OR are fine on either GPR or FPR.
Teach AArch64RegisterBankInfo that G_OR can be mapped on either GPR or
FPR for 64-bit or 32-bit values.

Add test cases demonstrating how this information is used to coalesce a
computation on a single register bank.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272170 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-08 16:53:32 +00:00
Quentin Colombet
75072bc260 [RegBankSelect] Use RegisterBankInfo applyMapping method.
The RegBankSelect pass can now rely on the target to do the remapping of
the instructions.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272169 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-08 16:45:04 +00:00
Quentin Colombet
5972504d7b [RegisterBankInfo] Implement the method to apply a mapping.
Now, the target will be able to provide its how implementation to remap
an instruction. This open the way to crazier optimizations, but to
beginning with, we will be able to handle something else than the
default mapping.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272165 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-08 16:39:21 +00:00
Quentin Colombet
05d61b46ed [RegBankSelect] Use the OperandMapper class to hold remap information.
Now that we have an entity that hold the remap information the
rewritting should be easier to do.

No functional changes.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272164 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-08 16:30:55 +00:00
Quentin Colombet
cf4d78fc0d [RegBankSelect] Use const_iterator instead of iterator for repairReg.
The repairing code has no reason to change the source or destination of
the registers.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272163 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-08 16:24:55 +00:00
Quentin Colombet
94a69dc2a1 [RegisterBankInfo] Introduce OperandsMapper class.
This helper class is used to encapsulate the necessary information
to remap an instruction.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272161 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-08 16:18:13 +00:00
Quentin Colombet
470be6185a [RegBankSelect] Introduce a command line option to override the running mode.
When the command line option is set, it overrides any thing that the
target may have set. The rationale is that we get what we asked for.

Options are respectively regbankselect-fast and regbankselect-greedy for
fast and greedy mode.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272158 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-08 15:49:23 +00:00
Quentin Colombet
ad15246a5e [RegBankSelect] Explain what it would take to support non-copy
repairing.

Copies are easy because we repair only when there is a mismatch. For
non-copy repairing, i.e., cases that involves breaking down or gathering
up the value, one of the operand may not have a register bank yet. Thus,
derivate a cost from that, requires more work.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272157 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-08 15:40:32 +00:00
Oliver Stannard
25429add0f [ARM] MSR instructions implicitly set CPSR
The MSR instructions can write to the CPSR, but we did not model this
fact, so we could emit them in the middle of IT blocks, changing the
condition flags for later instructions in the block.

The tests use two calls to llvm.write_register.i32 because it is valid
to use these instructions at the end of an IT block, which if conversion
does do in some cases. With two calls, the first clobbers the flags, so
a branch has to be used to make the second one conditional.

Differential Revision: http://reviews.llvm.org/D21139



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272154 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-08 15:26:34 +00:00
Saleem Abdulrasool
e169351252 Support: correct AArch64 TargetParser implementation
The architecture enumeration is shared across ARM and AArch64.  However, the
data is not.  The code incorrectly would index into the array using the
architecture index which was offset by the ARMv7 architecture enumeration.  We
do not have a marker for indicating the architectural family to which the
enumeration belongs so we cannot be clever about offsetting the index (at least
it is not immediately apparent to me).  Instead, fall back to the tried-and-true
method of slowly iterating the array (its not a large array, so the impact of
this is not too high).

Because of the incorrect indexing, if we were lucky, we would crash, but usually
we would return an invalid StringRef.  We did not have any tests for the AArch64
target parser previously;.  Extend the previous tests I had added for ARM to
cover AArch64 for ensuring that we return expected StringRefs.

Take the opportunity to change some iterator types to references.

This work is needed to support parsing `.arch name` directives in the AArch64
target asm parser.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272145 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-08 14:30:00 +00:00
Davide Italiano
a99c29794a [PM] LoopSimplify. Remove unneeded pass dependencies. NFCI.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272140 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-08 13:56:59 +00:00
Davide Italiano
9491ddb86e [PM/SimplifyCFG] Preserve GlobalsAA even if the IR is mutated.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272139 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-08 13:32:23 +00:00
Vasileios Kalintiris
a0fa31c900 [mips] Add a proper file header in MipsFastISel.cpp
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272138 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-08 13:13:15 +00:00
Krzysztof Parzyszek
7bf435bbe7 [Hexagon] Modify HexagonExpandCondsets to handle subregisters
Also, switch to using functions from LiveIntervalAnalysis to update
live intervals, instead of performing the updates manually.

Re-committing r272045.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272135 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-08 12:31:16 +00:00
Diana Picus
c5d0b1da6e [ARM] Remove redundant check. NFC
isSwift is tested earlier and known to be false when we reach this code.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272127 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-08 10:29:02 +00:00
Benjamin Kramer
04a303b821 Avoid copies of std::strings and APInt/APFloats where we only read from it
As suggested by clang-tidy's performance-unnecessary-copy-initialization.
This can easily hit lifetime issues, so I audited every change and ran the
tests under asan, which came back clean.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272126 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-08 10:01:20 +00:00
Igor Breger
1e48871118 [AVX512] Fix cvtusi2sd instruction Opcode, it should be 0x7B instead of 0x2A.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272122 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-08 07:48:23 +00:00
Matt Arsenault
c9cf0c849e Make LiveDebugValues preserve CFG
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272117 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-08 05:18:01 +00:00
Kostya Serebryany
819b4d1da2 [libFuzzer] add 'weak' back to __sanitizer_malloc_hook and __sanitizer_free_hook
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272116 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-08 04:49:29 +00:00
Kostya Serebryany
fd9cb1a5c5 [libFuzzer] add a test that is built w/o coverage instrumentation but has the coverage rt (it should now fail with a descriptive message)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272090 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-08 01:46:13 +00:00
Quentin Colombet
d292b5eaf2 [AArch64][RegisterBankInfo] Use the generic implementation of copyCost.
Long term we may want to give high cost at FPR to/from GPR copies.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272086 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-08 01:24:00 +00:00
Quentin Colombet
edb4f7c12a [RegisterBankInfo] Add a size argument for the cost of copy.
The cost of a copy may be different based on how many bits we have to
copy around. E.g., a 8-bit copy may be different than a 32-bit copy.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272084 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-08 01:11:03 +00:00
Quentin Colombet
5c05d4112b [RegisterBankInfo] Move a hidden function into a static method. NFC.
This will allow code reuse in the coming commits.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272083 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-08 01:04:32 +00:00
Matthias Braun
0f19dc2756 MIR: Fix parsing of stack object references in MachineMemOperands
The MachineMemOperand parser lacked the code to handle %stack.X
references (%fixed-stack.X was working).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272082 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-08 00:47:07 +00:00
Zachary Turner
44e9b3090f [pdb] Try to fix use after free.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272078 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-08 00:25:08 +00:00
Rui Ueyama
5ae402a784 [pdbdump] Print out # of hash buckets.
In the reference code, the field name is `cHashBuckets`.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272075 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-07 23:53:43 +00:00
Rui Ueyama
650053d1ce [pdbdump] Print out TPI hash key size.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272073 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-07 23:44:27 +00:00
Dan Liew
1a1c8bea2d [LibFuzzer] Declare and use sanitizer functions in `fuzzer::ExternalFunctions`
This fixes linking problems on OSX.

Unfortunately it turns out we need to use an instance of the
``fuzzer::ExternalFunctions`` object in several places so this
commit also replaces all instances with a single global instance.

It also turns out initializing a global ``fuzzer::ExternalFunctions``
before main is entered (i.e. letting the object be initialised by the
global initializers) is not safe (on OSX the call to ``Printf()`` in the
CTOR crashes if it is called from a global initializer) so we instead
have a global ``fuzzer::ExternalFunctions*`` and initialize it inside
``FuzzerDriver()``.

Multiple unit tests depend also depend on the
``fuzzer::ExternalFunctions*`` global so a ``main()`` function has been
added that initializes it before running any tests.

Differential Revision: http://reviews.llvm.org/D20943

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272072 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-07 23:32:50 +00:00
George Burgess IV
dada9c0ac0 [CFLAA] Kill dead code/fix comments in StratifiedSets.
Also use default/delete instead of hand-written ctors.

Thanks to Jia Chen for bringing this stuff up.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272064 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-07 21:41:18 +00:00
Nicolai Haehnle
2ac1fa00c9 AMDGPU: Add amdgpu-ps-wqm-outputs function attributes
Summary:
The presence of this attribute indicates that VGPR outputs should be computed
in whole quad mode. This will be used by Mesa for prolog pixel shaders, so
that derivatives can be taken of shader inputs computed by the prolog, fixing
a bug.

The generated code could certainly be improved: if a prolog pixel shader is
used (which isn't common in modern OpenGL - they're used for gl_Color, polygon
stipples, and forcing per-sample interpolation), Mesa will use this attribute
unconditionally, because it has to be conservative. So WQM may be used in the
prolog when it isn't really needed, and furthermore a silly back-and-forth
switch is likely to happen at the boundary between prolog and main shader
parts.

Fixing this is a bit involved: we'd first have to add a mechanism by which
LLVM writes the WQM-related input requirements to the main shader part binary,
and then Mesa specializes the prolog part accordingly. At that point, we may
as well just compile a monolithic shader...

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=95130

Reviewers: arsenm, tstellarAMD, mareko

Subscribers: arsenm, llvm-commits, kzhuravl

Differential Revision: http://reviews.llvm.org/D20839

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272063 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-07 21:37:17 +00:00
Dan Liew
d3e1f7de2b [LibFuzzer] Split the fuzzer-oom.test into two tests.
This is necessary because the existing fuzzer-oom.test was Linux
specific due to its use of __sanitizer_print_memory_profile() which
is only available on Linux right now and so the test would fail on OSX.

Differential Revision: http://reviews.llvm.org/D20977

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272061 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-07 21:23:30 +00:00
Zachary Turner
90d4a1bb6f [pdb] Convert StringRefs to ArrayRef<uint8_t>s.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272058 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-07 20:38:37 +00:00
Eric Christopher
c2a7f10882 Revert "Differential Revision: http://reviews.llvm.org/D20557"
Author: Wei Ding <wei.ding2@amd.com>
Date:   Tue Jun 7 19:04:44 2016 +0000

    Differential Revision: http://reviews.llvm.org/D20557

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

as it was breaking the bots.

This reverts commit r272044.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272056 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-07 20:27:12 +00:00
Mike Aizatsky
b1953d8c1b [libfuzzer] custom crossover interface function.
Differential Revision: http://reviews.llvm.org/D21089

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272054 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-07 20:22:15 +00:00
Etienne Bergeron
70cf01c276 [stack-protection] Add support for MSVC buffer security check
Summary:
This patch is adding support for the MSVC buffer security check implementation

The buffer security check is turned on with the '/GS' compiler switch.
  * https://msdn.microsoft.com/en-us/library/8dbf701c.aspx
  * To be added to clang here: http://reviews.llvm.org/D20347

Some overview of buffer security check feature and implementation:
  * https://msdn.microsoft.com/en-us/library/aa290051(VS.71).aspx
  * http://www.ksyash.com/2011/01/buffer-overflow-protection-3/
  * http://blog.osom.info/2012/02/understanding-vs-c-compilers-buffer.html


For the following example:
```
int example(int offset, int index) {
  char buffer[10];
  memset(buffer, 0xCC, index);
  return buffer[index];
}
```

The MSVC compiler is adding these instructions to perform stack integrity check:
```
        push        ebp  
        mov         ebp,esp  
        sub         esp,50h  
  [1]   mov         eax,dword ptr [__security_cookie (01068024h)]  
  [2]   xor         eax,ebp  
  [3]   mov         dword ptr [ebp-4],eax  
        push        ebx  
        push        esi  
        push        edi  
        mov         eax,dword ptr [index]  
        push        eax  
        push        0CCh  
        lea         ecx,[buffer]  
        push        ecx  
        call        _memset (010610B9h)  
        add         esp,0Ch  
        mov         eax,dword ptr [index]  
        movsx       eax,byte ptr buffer[eax]  
        pop         edi  
        pop         esi  
        pop         ebx  
  [4]   mov         ecx,dword ptr [ebp-4]  
  [5]   xor         ecx,ebp  
  [6]   call        @__security_check_cookie@4 (01061276h)  
        mov         esp,ebp  
        pop         ebp  
        ret  
```

The instrumentation above is:
  * [1] is loading the global security canary,
  * [3] is storing the local computed ([2]) canary to the guard slot,
  * [4] is loading the guard slot and ([5]) re-compute the global canary,
  * [6] is validating the resulting canary with the '__security_check_cookie' and performs error handling.

Overview of the current stack-protection implementation:
  * lib/CodeGen/StackProtector.cpp
    * There is a default stack-protection implementation applied on intermediate representation.
    * The target can overload 'getIRStackGuard' method if it has a standard location for the stack protector cookie.
    * An intrinsic 'Intrinsic::stackprotector' is added to the prologue. It will be expanded by the instruction selection pass (DAG or Fast).
    * Basic Blocks are added to every instrumented function to receive the code for handling stack guard validation and errors handling.
    * Guard manipulation and comparison are added directly to the intermediate representation.

  * lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
  * lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
    * There is an implementation that adds instrumentation during instruction selection (for better handling of sibbling calls).
      * see long comment above 'class StackProtectorDescriptor' declaration.
    * The target needs to override 'getSDagStackGuard' to activate SDAG stack protection generation. (note: getIRStackGuard MUST be nullptr).
      * 'getSDagStackGuard' returns the appropriate stack guard (security cookie)
    * The code is generated by 'SelectionDAGBuilder.cpp' and 'SelectionDAGISel.cpp'.

  * include/llvm/Target/TargetLowering.h
    * Contains function to retrieve the default Guard 'Value'; should be overriden by each target to select which implementation is used and provide Guard 'Value'.

  * lib/Target/X86/X86ISelLowering.cpp
    * Contains the x86 specialisation; Guard 'Value' used by the SelectionDAG algorithm.

Function-based Instrumentation:
  * The MSVC doesn't inline the stack guard comparison in every function. Instead, a call to '__security_check_cookie' is added to the epilogue before every return instructions.
  * To support function-based instrumentation, this patch is
    * adding a function to get the function-based check (llvm 'Value', see include/llvm/Target/TargetLowering.h),
      * If provided, the stack protection instrumentation won't be inlined and a call to that function will be added to the prologue.
    * modifying (SelectionDAGISel.cpp) do avoid producing basic blocks used for inline instrumentation,
    * generating the function-based instrumentation during the ISEL pass (SelectionDAGBuilder.cpp),
    * if FastISEL (not SelectionDAG), using the fallback which rely on the same function-based implemented over intermediate representation (StackProtector.cpp).

Modifications
  * adding support for MSVC (lib/Target/X86/X86ISelLowering.cpp)
  * adding support function-based instrumentation (lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp, .h)

Results

  * IR generated instrumentation:
```
clang-cl /GS test.cc /Od /c -mllvm -print-isel-input
```

```
*** Final LLVM Code input to ISel ***

; Function Attrs: nounwind sspstrong
define i32 @"\01?example@@YAHHH@Z"(i32 %offset, i32 %index) #0 {
entry:
  %StackGuardSlot = alloca i8*                                                  <<<-- Allocated guard slot
  %0 = call i8* @llvm.stackguard()                                              <<<-- Loading Stack Guard value
  call void @llvm.stackprotector(i8* %0, i8** %StackGuardSlot)                  <<<-- Prologue intrinsic call (store to Guard slot)
  %index.addr = alloca i32, align 4
  %offset.addr = alloca i32, align 4
  %buffer = alloca [10 x i8], align 1
  store i32 %index, i32* %index.addr, align 4
  store i32 %offset, i32* %offset.addr, align 4
  %arraydecay = getelementptr inbounds [10 x i8], [10 x i8]* %buffer, i32 0, i32 0
  %1 = load i32, i32* %index.addr, align 4
  call void @llvm.memset.p0i8.i32(i8* %arraydecay, i8 -52, i32 %1, i32 1, i1 false)
  %2 = load i32, i32* %index.addr, align 4
  %arrayidx = getelementptr inbounds [10 x i8], [10 x i8]* %buffer, i32 0, i32 %2
  %3 = load i8, i8* %arrayidx, align 1
  %conv = sext i8 %3 to i32
  %4 = load volatile i8*, i8** %StackGuardSlot                                  <<<-- Loading Guard slot
  call void @__security_check_cookie(i8* %4)                                    <<<-- Epilogue function-based check
  ret i32 %conv
}
```

  * SelectionDAG generated instrumentation:

```
clang-cl /GS test.cc /O1 /c /FA
```

```
"?example@@YAHHH@Z":                    # @"\01?example@@YAHHH@Z"
# BB#0:                                 # %entry
        pushl   %esi
        subl    $16, %esp
        movl    ___security_cookie, %eax                                        <<<-- Loading Stack Guard value
        movl    28(%esp), %esi
        movl    %eax, 12(%esp)                                                  <<<-- Store to Guard slot
        leal    2(%esp), %eax
        pushl   %esi
        pushl   $204
        pushl   %eax
        calll   _memset
        addl    $12, %esp
        movsbl  2(%esp,%esi), %esi
        movl    12(%esp), %ecx                                                  <<<-- Loading Guard slot
        calll   @__security_check_cookie@4                                      <<<-- Epilogue function-based check
        movl    %esi, %eax
        addl    $16, %esp
        popl    %esi
        retl
```

Reviewers: kcc, pcc, eugenis, rnk

Subscribers: majnemer, llvm-commits, hans, thakis, rnk

Differential Revision: http://reviews.llvm.org/D20346

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272053 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-07 20:15:35 +00:00
Krzysztof Parzyszek
6fc4b2ad52 Revert r272045 since GCC doesn't know how to compile it.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272048 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-07 19:25:28 +00:00
Krzysztof Parzyszek
01da260d54 [Hexagon] Modify HexagonExpandCondsets to handle subregisters
Also, switch to using functions from LiveIntervalAnalysis to update
live intervals, instead of performing the updates manually.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272045 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-07 19:06:23 +00:00
Wei Ding
e2d1122183 Differential Revision: http://reviews.llvm.org/D20557
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272044 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-07 19:04:44 +00:00
Zachary Turner
0dbad57358 [pdb] Fix a potential overflow and remove unnecessary comments.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272043 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-07 18:42:39 +00:00
George Burgess IV
90fe2c51ce [CFLAA] Add AttrEscaped, remove bit twiddling functions.
This patch does a few things:

- Unifies AttrAll and AttrUnknown (since they were used for more or less
  the same purpose anyway).

- Introduces AttrEscaped, an attribute that notes that a value escapes
  our analysis for a given set, but not that an unknown value flows into
  said set.

- Removes functions that take bit indices, since we also had functions
  that took bitsets, and the use of both (with similar names) was
  unclear and bug-prone.

Patch by Jia Chen.

Differential Revision: http://reviews.llvm.org/D21000


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272040 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-07 18:35:37 +00:00
Mike Aizatsky
c7f790d744 [libfuzzer] prune_corpus option for disabling pruning during the load.
Summary:
The option is very useful for testing, plus I intend to measure
its effect on fuzzer effectiveness.

Differential Revision: http://reviews.llvm.org/D21084

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272035 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-07 18:16:32 +00:00
Geoff Berry
f323692d97 Reapply [AArch64] Fix isLegalAddImmediate() to return true for valid negative values.
Originally reviewed here: http://reviews.llvm.org/D17463

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272023 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-07 16:48:43 +00:00
Haicheng Wu
63ca44cb85 Revert "[MBP] Reduce code size by running tail merging in MBP."
This reverts commit r271930, r271915, r271923.  They break a thumb selfhosting
bot.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272017 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-07 15:17:21 +00:00
Oliver Stannard
f88b5f4e1e [ARM] Accept conditional versions of BXNS and BLXNS
These instructions end in "S" but are not flag-setting, so they need including
in the list of special cases in the assembly parser.

Differential Revision: http://reviews.llvm.org/D21077



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272015 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-07 14:58:48 +00:00
Andrey Turetskiy
a87b055656 [LAA] Improve non-wrapping pointer detection by handling loop-invariant case.
This fixes PR26314. This patch adds new helper “isNoWrap” with detection of
loop-invariant pointer case.

Patch by Roman Shirokiy.

Ref: https://llvm.org/bugs/show_bug.cgi?id=26314

Differential Revision: http://reviews.llvm.org/D17268


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272014 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-07 14:55:27 +00:00
Davide Italiano
007ac9990e [Linker/IRMover] Simplify the code a bit. NFCI.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272013 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-07 14:55:04 +00:00
Simon Pilgrim
2f401854a1 [X86][SSE] Add general lowering of nontemporal vector loads (fixed bad merge)
Currently the only way to use the (V)MOVNTDQA nontemporal vector loads instructions is through the int_x86_sse41_movntdqa style builtins.

This patch adds support for lowering nontemporal loads from general IR, allowing us to remove the movntdqa builtins in a future patch.

We currently still fold nontemporal loads into suitable instructions, we should probably look at removing this (and nontemporal stores as well) or at least make the target's folding implementation aware that its dealing with a nontemporal memory transaction.

There is also an issue that VMOVNTDQA only acts on 128-bit vectors on pre-AVX2 hardware - so currently a normal ymm load is still used on AVX1 targets.

Differential Review: http://reviews.llvm.org/D20965

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272011 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-07 13:47:23 +00:00
Simon Pilgrim
6ad3e358e9 [X86][SSE] Add general lowering of nontemporal vector loads
Currently the only way to use the (V)MOVNTDQA nontemporal vector loads instructions is through the int_x86_sse41_movntdqa style builtins.

This patch adds support for lowering nontemporal loads from general IR, allowing us to remove the movntdqa builtins in a future patch.

We currently still fold nontemporal loads into suitable instructions, we should probably look at removing this (and nontemporal stores as well) or at least make the target's folding implementation aware that its dealing with a nontemporal memory transaction.

There is also an issue that VMOVNTDQA only acts on 128-bit vectors on pre-AVX2 hardware - so currently a normal ymm load is still used on AVX1 targets.

Differential Review: http://reviews.llvm.org/D20965

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272010 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-07 13:34:24 +00:00
Davide Italiano
c29f26fd71 [PM] Preserve GlobalsAA for SROA.
Differential Revision:  http://reviews.llvm.org/D21040


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272009 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-07 13:21:17 +00:00
James Molloy
6e988c5976 [Thumb-1] Add optimized constant materialization for integers [256..512)
We can materialize these integers using a MOV; ADDi8 pair.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272007 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-07 13:10:14 +00:00
Igor Breger
7e0019d8f7 [AVX512] Fix load opcode for fast isel.
Differential Revision: http://reviews.llvm.org/D21067

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272006 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-07 13:08:45 +00:00
Ulrich Weigand
d7ad443387 [PowerPC] Support multiple return values with fast isel
Using an LLVM IR aggregate return value type containing three
or more integer values causes an abort in the fast isel pass.

This patch adds two more registers to RetCC_PPC64_ELF_FIS to
allow returning up to four integers with fast isel, just the
same as is currently supported with regular isel (RetCC_PPC).

This is needed for Swift and (possibly) other non-clang frontends.

Fixes PR26190.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272005 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-07 12:48:22 +00:00
Simon Pilgrim
c1e27cc453 [X86][SSE] Improved blend+zero target shuffle combining to use combined shuffle mask directly
We currently only combine to blend+zero if the target value type has 8 elements or less, but this was missing a lot of cases where the combined mask had been widened.

This change makes it so we use the combined mask to determine the blend value type, allowing us to catch more widened cases.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272003 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-07 12:20:14 +00:00
James Molloy
87f50aafbc [ARM] Shrink post-indexed LDR and STR to LDM/STM
A Thumb-2 post-indexed LDR instruction such as:

  ldr.w r0, [r1], #4

Can be rewritten as:

  ldm.n r1!, {r0}

LDMs can be more expensive than LDRs on some cores, so this has been enabled only in minsize mode.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272002 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-07 12:13:34 +00:00
James Molloy
d5127f4273 [ARM] Transform LDMs into writeback form to save code size
If we have an LDM that uses only low registers and doesn't write to its base register:

  ldm.w r0, {r1, r2, r3}

And that base register is dead after the LDM, then we can convert it to writeback form and use a narrow encoding:

  ldm.n r0!, {r1, r2, r3}

Obviously, this introduces a new register write and so can cause WAW hazards, so I've enabled it only in minsize mode. This is a code size trick that ARM Compiler 5 ("armcc") does that we don't.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272000 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-07 11:47:24 +00:00
Peter Smith
884efc1a85 [ARM] Incorrect relocation type for Thumb2 B<cond>.w
The Thumb2 conditional branch B<cond>.W has a different encoding (T3) 
to the unconditional branch B.W (T4) as it needs to record <cond>. 
As the encoding is different the B<cond>.W is given a different 
relocation type. 

ELF for the ARM Architecture 4.6.1.6 (Table-13) states that 
R_ARM_THM_JUMP19 should be used for B<cond>.W. At present the 
MC layer is using the R_ARM_THM_JUMP24 from B.W.

This change makes B<cond>.W use R_ARM_THM_JUMP19 and alters the 
existing test that checks for R_ARM_THM_JUMP24 to expect 
R_ARM_THM_JUMP19.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271997 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-07 10:34:33 +00:00
Simon Pilgrim
c9bc1a4d8d [InstCombine][AVX2] Add support for simplifying AVX2 per-element shifts to native shifts
Unlike native shifts, the AVX2 per-element shift instructions VPSRAV/VPSRLV/VPSLLV handle out of range shift values (logical shifts set the result to zero, arithmetic shifts splat the sign bit).

If the shift amount is constant we can sometimes convert these instructions to native shifts:

1 - if all shift amounts are in range then the conversion is trivial.
2 - out of range arithmetic shifts can be clamped to the (bitwidth - 1) (a legal shift amount) before conversion.
3 - logical shifts just return zero if all elements have out of range shift amounts.

In addition, UNDEF shift amounts are handled - either as an UNDEF shift amount in a native shift or as an UNDEF in the logical 'all out of range' zero constant special case for logical shifts.

Differential Revision: http://reviews.llvm.org/D19675

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271996 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-07 10:27:15 +00:00
Simon Pilgrim
4d1d561550 [InstCombine][SSE] Add MOVMSK constant folding (PR27982)
This patch adds support for folding undef/zero/constant inputs to MOVMSK instructions.

The SSE/AVX versions can be fully folded, but the MMX version can only handle undef inputs.

Differential Revision: http://reviews.llvm.org/D20998

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271990 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-07 08:18:35 +00:00
Craig Topper
55ae04708d [AVX512] Allow avx2 and sse41 nontemporal load intrinsics to select EVEX encoded instructions when VLX is enabled.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271988 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-07 07:27:57 +00:00
Craig Topper
a2dda815a0 [AVX512] Remove unnecessary mayLoad, mayStore, hasSidEffects flags from instructions that have patterns that imply them. Add the same set of flags to instructions that don't have patterns to imply them.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271987 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-07 07:27:54 +00:00
Craig Topper
9c727fb929 [AVX512] Add NoVLX to a couple patterns that have VLX equivalents. Ordering of the patterns in the .td file protects this, but its better to be explicit.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271986 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-07 07:27:51 +00:00
Zachary Turner
6e00ec14d5 [pdb] Use MappedBlockStream to parse the PDB directory.
In order to efficiently write PDBs, we need to be able to make a
StreamWriter class similar to a StreamReader, which can transparently deal
with writing to discontiguous streams, and we need to use this for all
writing, similar to how we use StreamReader for all reading.

Most discontiguous streams are the typical numbered streams that appear in
a PDB file and are described by the directory, but the exception to this,
that until now has been parsed by hand, is the directory itself.
MappedBlockStream works by querying the directory to find out which blocks
a stream occupies and various other things, so naturally the same logic
could not possibly work to describe the blocks that the directory itself
resided on.

To solve this, I've introduced an abstraction IPDBStreamData, which allows
the client to query for the list of blocks occupied by the stream, as well
as the stream length. I provide two implementations of this: one which
queries the directory (for indexed streams), and one which queries the
super block (for the directory stream).

This has the side benefit of vastly simplifying the code to parse the
directory. Whereas before a mini state machine was rolled by hand, now we
simply use FixedStreamArray to read out the stream sizes, then build a
vector of FixedStreamArrays for the stream map, all in just a few lines of
code.

Reviewed By: ruiu
Differential Revision: http://reviews.llvm.org/D21046

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271982 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-07 05:28:55 +00:00
Dan Liew
47f90f5156 [LibFuzzer] s/dataflow sanitizer/DataflowSanitizer/
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271980 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-07 04:44:49 +00:00
Dan Liew
ef07357b2f [LibFuzzer] Disable building and running LSan tests on Apple platforms because LSan is not currently supported.
Differential Revision: http://reviews.llvm.org/D20947

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271979 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-07 04:44:39 +00:00
Saleem Abdulrasool
48ff9d62da ARM: correct TLS access on WoA
TLS access requires an offset from the TLS index.  The index itself is the
section-relative distance of the symbol.  For ARM, the relevant relocation
(IMAGE_REL_ARM_SECREL) is applied as a constant.  This means that the value may
not be an immediate and must be lowered into a constant pool.  This offset will
not be base relocated.  We were previously emitting the actual address of the
symbol which would be base relocated and would therefore be the vaue offset by
the ImageBase + TLS Offset.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271974 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-07 03:15:07 +00:00
Saleem Abdulrasool
7fe5e9209b ARM: clang-format a couple of switches, add comments
clang-format a couple of switches in preparation for a future change.  Add some
enumeration comments

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271973 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-07 03:15:01 +00:00
Saleem Abdulrasool
4da96fca18 ARM: normalise space in the patterns
Just adjust the whitespace for the selection patterns.  NFC.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271972 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-07 03:14:57 +00:00
Rui Ueyama
cdea7ae629 Add comments.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271967 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-07 00:59:04 +00:00
Reid Kleckner
d34b1e13f4 Re-land "[codeview] Emit information about global variables"
This reverts commit r271962 and reinstantes r271957.

MSVC's linker doesn't appear to like it if you have an empty symbol
substream, so only open a symbol substream if we're going to emit
something about globals into it.

Makes check-asan pass.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271965 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-07 00:02:03 +00:00
Reid Kleckner
d74372042c Try one more time to pacify -Wpessimizing-move, MSVC, libstdc++4.7, and the world without a named variable
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271964 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-06 23:46:14 +00:00
Reid Kleckner
815649892e Revert "[codeview] Emit information about global variables"
This reverts commit r271957, it broke check-asan on Windows.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271962 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-06 23:41:38 +00:00
Michael Kuperstein
6954e6256d [InstCombine] scalarizePHI should not assume the code it sees has been CSE'd
scalarizePHI only looked for phis that have exactly two uses - the "latch"
use, and an extract. Unfortunately, we can not assume all equivalent extracts
are CSE'd, since InstCombine itself may create an extract which is a duplicate
of an existing one. This extends it to handle several distinct extracts from
the same index.

This should fix at least some of the  performance regressions from PR27988.

Differential Revision: http://reviews.llvm.org/D20983


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271961 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-06 23:38:33 +00:00
Reid Kleckner
2fce618270 Attempt to work around lack of std::map::emplace in libstdc++4.7
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271958 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-06 23:28:03 +00:00
Reid Kleckner
968f9915ac [codeview] Emit information about global variables
This currently emits everything as S_GDATA32, which isn't right for
things like thread locals, but it's a start.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271957 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-06 23:23:47 +00:00
Peter Collingbourne
052c9ee80b Verifier: Simplify and fix issue where we were not verifying unmaterialized functions.
Arrange to call verify(Function &) on each function, followed by
verify(Module &), whether the verifier is being used from the pass or
from verifyModule(). As a side effect, this fixes an issue that caused
us not to call verify(Function &) on unmaterialized functions from
verifyModule().

Differential Revision: http://reviews.llvm.org/D21042

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271956 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-06 23:21:27 +00:00
Rui Ueyama
d97680dbf0 [pdbdump] Verify the size of TPI hash records.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271954 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-06 23:19:23 +00:00
Peter Collingbourne
6510b62554 Verifier: Remove dead code.
Remove previously unreachable code that verifies that a function definition has
an entry block. By definition, a function definition has at least one block.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271948 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-06 22:32:52 +00:00
Dan Liew
47f223bd24 [LibFuzzer] Provide stub implementation of __sanitizer_cov_trace_pc_indir
Calls to this function are currently injected by the
``SanitizerCoverageModule`` pass when the both the ``indirect-calls``
and ``trace-pc`` sanitizer coverage options are enabled and the code
being instrumented has indirect calls. Previously because LibFuzzer did
not define this function this would lead to link errors when building
some of the tests on OSX.

Differential Revision: http://reviews.llvm.org/D20946

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271938 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-06 20:27:09 +00:00
Matt Arsenault
f4135c634c AMDGPU: Add function for getting instruction size
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271936 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-06 20:10:33 +00:00
Matt Arsenault
bc1b8d5b49 AMDGPU: Fix constantexpr addrspacecasts
If we had a constant group address space cast the queue pointer
wasn't enabled for the function, resulting in a crash on noreg
later.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271935 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-06 20:03:31 +00:00
Davide Italiano
3ff92c7452 [PM] Preserve the correct set of analyses for GVN.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271934 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-06 20:01:50 +00:00
Davide Italiano
d4b932e94b [GVN] Switch dump() definition over to LLVM_DUMP_METHOD.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271932 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-06 19:24:27 +00:00
Michael Zolotukhin
c711b13613 [LoopUnrollAnalyzer] Fix a crash in analyzeLoopUnrollCost.
In some cases, when simplifying with SCEV, we might consider pointer values as
just usual integer values.  Thus, we might get a different type from what we
had originally in the map of simplified values, and hence we need to check
types before operating on the values.

This fixes PR28015.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271931 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-06 19:21:40 +00:00
Geoff Berry
5c724a4fef Reapply [LSR] Create fewer redundant instructions.
Summary:
Fix LSRInstance::HoistInsertPosition() to check the original insert
position block first for a canonical insertion point that is dominated
by all inputs.  This leads to SCEV being able to reuse more instructions
since it currently tracks the instructions it creates for reuse by
keeping a table of <Value, insert point> pairs.

Originally reviewed in http://reviews.llvm.org/D18001

Reviewers: atrick

Subscribers: llvm-commits, mzolotukhin, mcrosier

Differential Revision: http://reviews.llvm.org/D18480

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271929 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-06 19:10:46 +00:00
Rui Ueyama
24ef682bfb [pdbdump] Print out New FPO stream contents.
The data strucutre in the new FPO stream is described in the
PE/COFF spec. There is one record per function if frame pointer
is omitted.

Differential Revision: http://reviews.llvm.org/D20999

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271926 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-06 18:39:21 +00:00
Haicheng Wu
84755987d0 [MBP] Reduce code size by running tail merging in MBP.
The code layout that TailMerging (inside BranchFolding) works on is not the
final layout optimized based on the branch probability. Generally, after
BlockPlacement, many new merging opportunities emerge.

This patch calls Tail Merging after MBP and calls MBP again if Tail Merging
merges anything.

Differential Revision: http://reviews.llvm.org/D20276

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271925 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-06 18:36:07 +00:00
Haicheng Wu
f15d24533e [BranchFolding] Replace MachineBlockFrequencyInfo with MBFIWrapper. NFC.
Differential Revision: http://reviews.llvm.org/D20184

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271923 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-06 18:35:41 +00:00
Alina Sbirlea
36f2326b3f [cpu-detection] Substantial refactor of Host CPU detection code (x86)
Summary:
Following D20970 (committed as r271726).
This is a substantial refactoring of the host CPU detection code.

There is no functionality change intended, but the changes are extensive.

Definitions of architecture types and subtypes are by no means exhaustive or
perfectly defined, but a fair starting point.
Suggestions for futher improvements are welcome.

Reviewers: llvm-commits

Differential Revision: http://reviews.llvm.org/D20988

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271921 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-06 18:29:59 +00:00
Sanjay Patel
b17db4cf26 [InstCombine] limit icmp transform to ConstantInt (PR28011)
In r271810 ( http://reviews.llvm.org/rL271810 ), I loosened the check
above this to work for any Constant rather than ConstantInt. AFAICT, 
that part makes sense if we can determine that the shrunken/extended 
constant remained equal. But it doesn't make sense for this later 
transform where we assume that the constant DID change. 

This could assert for a ConstantExpr:
https://llvm.org/bugs/show_bug.cgi?id=28011

And it could be wrong for a vector as shown in the added regression test.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271908 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-06 16:56:57 +00:00
Artem Tamazov
7049ac906c [AMDGPU][llvm-mc] v_cndmask_b32: src2 is mandatory; do not enforce VOP2 when src2 == VCC.
Another step for unification llvm assembler/disassembler with sp3.
Besides, CodeGen output is a bit improved, thus changes in CodeGen tests.
Assembler/Disassembler tests updated/added.

Differential Revision: http://reviews.llvm.org/D20796

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271900 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-06 15:23:43 +00:00
Matthew Simpson
683b746f24 [LAA] Use load and store vectors (NFC)
Contributed-by: Aditya Kumar <hiraditya@msn.com>
Differential Revision: http://reviews.llvm.org/D20953

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271895 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-06 14:15:41 +00:00
Igor Breger
5238dbe213 [KNL] Fix UMULO lowering.
Differential Revision: http://reviews.llvm.org/D21013

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271891 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-06 12:24:52 +00:00
Benjamin Kramer
ad53d4da9e Remove dead function with incredibly broken assert.
Found by clang-tidy's misc-assert-side-effect.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271887 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-06 12:10:42 +00:00
Filipe Cabecinhas
67708909d0 [NFC] Silence gcc warning (-Wsign-compare)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271882 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-06 10:49:56 +00:00
Craig Topper
6dbfac925f [AVX512] Remove masked palignr intrinsics and auto-upgrade them to native IR of vector shuffle and select.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271872 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-06 06:12:54 +00:00
Craig Topper
856b53e006 [AVX512] Add PALIGNR shuffle lowering for v32i16 and v16i32.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271870 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-06 05:39:10 +00:00
Nick Lewycky
1947c7cca1 Fix spelling and capitalization in comments. NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271862 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-06 01:51:23 +00:00
Eli Friedman
196d83ecbd LICM: Don't sink stores out of loops that may throw.
Summary:
This hasn't been caught before because it requires noalias or similarly
strong alias analysis to actually reproduce.

Fixes http://llvm.org/PR27952 .

Reviewers: hfinkel, sanjoy

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D20944

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271858 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-05 22:13:52 +00:00
Sanjoy Das
4c21dbd25b Add safety check to InstCombiner::commonIRemTransforms
Since FoldOpIntoPhi speculates the binary operation to potentially each
of the predecessors of the PHI node (pulling it out of arbitrary control
dependence in the process), we can FoldOpIntoPhi only if we know the
operation doesn't have UB.

This also brings up an interesting profitability question -- the way it
is written today, commonIRemTransforms will hoist out work from
dynamically dead code into code that will execute at runtime.  Perhaps
that isn't the best canonicalization?

Fixes PR27968.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271857 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-05 21:17:04 +00:00
Filipe Cabecinhas
98090ec9bd [BitCode] Make sure atomicrmw's argument is an actual PointerType
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271851 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-05 18:43:40 +00:00
Filipe Cabecinhas
afe713a7cd [BitCode] Make sure storeatomic's argument is an actual PointerType
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271850 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-05 18:43:33 +00:00
Filipe Cabecinhas
e8dd99a32a [BitCode] Diagnose GEPs with no indices
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271849 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-05 18:43:26 +00:00
Filipe Cabecinhas
780fc2c617 [BitCode] Don't allow constants of void type.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271848 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-05 18:43:17 +00:00
Sanjoy Das
a55495a2e8 [PM] Port IndVarSimplify to the new pass manager
Summary:
There are some rough corners, since the new pass manager doesn't have
(as far as I can tell) LoopSimplify and LCSSA, so I've updated the
tests to run them separately in the old pass manager in the lit tests.
We also don't have an equivalent for AU.setPreservesCFG() in the new
pass manager, so I've left a FIXME.

Reviewers: bogner, chandlerc, davide

Subscribers: sanjoy, mcrosier, llvm-commits

Differential Revision: http://reviews.llvm.org/D20783

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271846 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-05 18:01:19 +00:00
Sanjoy Das
fa9013b737 [IndVars] Remove -liv-reduce
It is an off-by-default option that no one seems to use[0], and given
that SCEV directly understands the overflow instrinsics there is no real
need for it anymore.

[0]: http://lists.llvm.org/pipermail/llvm-dev/2016-April/098181.html

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271845 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-05 18:01:12 +00:00
Sanjay Patel
1518a5c65d [InstCombine] allow vector icmp bool transforms
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271843 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-05 17:49:45 +00:00
Sanjay Patel
83f8846060 fix documentation comments and other clean-ups; NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271839 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-05 16:46:18 +00:00
Simon Pilgrim
7705b591df [X86][XOP] Added VPERMIL2PD/VPERMIL2PS raw mask decoding for target shuffle combines
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271834 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-05 15:21:30 +00:00
Simon Pilgrim
2d63358b82 [X86][XOP] Added VPERMIL2PD/VPERMIL2PS as a target shuffle type
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271831 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-05 15:01:45 +00:00
Simon Pilgrim
b8b77a8df5 [X86][XOP] Tidied up DecodeVPERMIL2PMask to more closely match DecodeVPERMILPMask.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271830 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-05 14:33:43 +00:00
Craig Topper
3789c0fe24 [AVX512] Add support for lowering PALIGNR for v64i8.
Could do this for other types to, but this is what's needed to replace the instrinsic with native IR in clang.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271828 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-05 06:29:12 +00:00
Craig Topper
dd17bc5daa [AVX512] Fix PANDN combining for v4i32/v8i32 when VLX is enabled.
v4i32/v8i32 ANDs aren't promoted to v2i64/v4i64 when VLX is enabled.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271826 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-05 05:35:11 +00:00
Xinliang David Li
cb8e2c7de1 Fix pass declaration order /NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271824 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-05 05:15:45 +00:00
Xinliang David Li
6b28333324 [PM] Port GCOVProfiler pass to the new pass manager
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271823 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-05 05:12:23 +00:00
Xinliang David Li
ae19ba5c91 [PM] code refactoring /NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271822 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-05 03:40:03 +00:00
Sanjay Patel
6d1e5af20a [InstCombine] less 'CI' confusion; NFC
Change the name of the ICmpInst to 'ICmp' and the Constant (was a ConstantInt) to 'C',
so that it's hopefully clearer that 'CI' refers to CastInst in this context.

While we're scrubbing, fix the documentation comment and use 'auto' with 'dyn_cast'.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271817 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-05 00:12:32 +00:00