Commit Graph

129463 Commits

Author SHA1 Message Date
Chandler Carruth
e56cb5ff31 [x86] Fix a horrible bug in our lowering of x86 floating point atomic
operations.

Specifically, we had code that tried to badly approximate reconstructing
all of the possible variations on addressing modes in two x86
instructions based on those in one pseudo instruction. This is not the
first bug uncovered with doing this, so stop doing it altogether.
Instead generically and pedantically copy every operand from the address
over to both new instructions, and strip kill flags from any register
operands.

This fixes a subtle bug seen in the wild where we would mysteriously
drop parts of the addressing mode, causing for example the index
argument in the added test case to just be completely ignored.

Hypothetically, this was an extremely bad miscompile because it actually
caused a predictable and leveragable write of a 64bit quantity to an
unintended offset (the first element of the array intead of whatever
other element was intended). As a consequence, in theory this could even
have introduced security vulnerabilities.

However, this was only something that could happen with an atomic
floating point add. No other operation could trigger this bug, so it
seems extremely unlikely to have occured widely in the wild.

But it did in fact occur, and frequently in scientific applications
which were using relaxed atomic updates of a floating point value after
adding a delta. Those would end up being quite badly miscompiled by
LLVM, which is how we found this. Of course, this often looks like
a race condition in the code, but it was actually a miscompile.

I suspect that this whole RELEASE_FADD thing was a complete mistake.
There is no such operation, and I worry that anything other than add
will get remarkably worse codegeneration. But that's not for this
change....

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264845 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-30 08:41:59 +00:00
Craig Topper
40e9bee60f [CodeGen] Mark EVT:getExtendedSizeInBits() as LLVM_READONLY.
I think I had tried this a long time back and some bots failed. Hoping that was with an older gcc and maybe now it will work.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264840 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-30 05:26:43 +00:00
Jingyue Wu
8c5f0de0ab [docs] Add gpucc publication and tutorial.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264839 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-30 05:05:40 +00:00
Duncan P. N. Exon Smith
540e0f57f5 IR: Constify LLVMContext::discardValueNames, NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264823 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-30 04:32:29 +00:00
Duncan P. N. Exon Smith
dfdbebcd1d BitcodeReader: Fix weird whitespace, NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264822 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-30 04:21:52 +00:00
George Burgess IV
ff01852cd7 [MemorySSA] Make the visitor more careful with calls.
Prior to this patch, the MemorySSA caching visitor would cache all
calls that it visited. When paired with phi optimization, this can be
problematic. Consider:

define void @foo() {
  ; 1 = MemoryDef(liveOnEntry)
  call void @clobberFunction()
  br i1 undef, label %if.end, label %if.then

if.then:
  ; MemoryUse(??)
  call void @readOnlyFunction()
  ; 2 = MemoryDef(1)
  call void @clobberFunction()
  br label %if.end

if.end:
  ; 3 = MemoryPhi(...)
  ; MemoryUse(?)
  call void @readOnlyFunction()
  ret void
}

When optimizing MemoryUse(?), we visit defs 1 and 2, so we note to
cache them later. We ultimately end up not being able to optimize
passed the Phi, so we set MemoryUse(?) to point to the Phi. We then
cache the clobbering call for def 1 to be the Phi.

This commit changes this behavior so that we wipe out any calls
added to VisistedCalls while visiting the defs of a phi we couldn't
optimize.

Aside: With this patch, we now can bootstrap clang/LLVM without a
single MemorySSA verifier failure. Woohoo. :)



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264820 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-30 03:12:08 +00:00
Chandler Carruth
1f7adda3e4 [x86] Extract a helper function to compute the full addressing mode from
an x86 MachineInstr's operands. This will be super useful to fix some
bad atomics code in my next commit.

No functionality changed.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264819 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-30 03:10:24 +00:00
Xinliang David Li
6be6ccad2b [PGO] Handle invoke inst in IR based icall instrumentation
Differential Revision: http://reviews.llvm.org/D18580


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264818 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-30 02:16:07 +00:00
George Burgess IV
2e682ed868 [MemorySSA] Change how the walker views/walks visited phis.
This patch teaches the caching MemorySSA walker a few things:

1. Not to walk Phis we've walked before. It seems that we tried to do
   this before, but it didn't work so well in cases like:

define void @foo() {
  %1 = alloca i8
  %2 = alloca i8
  br label %begin

begin:
  ; 3 = MemoryPhi({%0,liveOnEntry},{%end,2})
  ; 1 = MemoryDef(3)
  store i8 0, i8* %2
  br label %end

end:
  ; MemoryUse(?)
  load i8, i8* %1
  ; 2 = MemoryDef(1)
  store i8 0, i8* %2
  br label %begin
}

Because we wouldn't put Phis in Q.Visited until we tried to visit them.
So, when trying to optimize MemoryUse(?):
  - We would visit 3 above
    - ...Which would make us put {%0,liveOnEntry} in Q.Visited
    - ...Which would make us visit {%0,liveOnEntry}
    - ...Which would make us put {%end,2} in Q.Visited
    - ...Which would make us visit {%end,2}
      - ...Which would make us visit 3
        - ...Which would realize we've already visited everything in 3
        - ...Which would make us conservatively return 3.

In the added test-case, (@looped_visitedonlyonce) this behavior would
cause us to give incorrect results. Specifically, we'd visit 4 twice
in the same query, but on the second visit, we'd skip while.cond because
it had been visited, visit if.then/if.then2, and cache "1" as the
clobbering def on the way back.

2. If we try to walk the defs of a {Phi,MemLoc} and see it has been
   visited before, just hand back the Phi we're trying to optimize.

I promise this isn't as terrible as it seems. :)

We now insert {Phi,MemLoc} pairs just before walking the Phi's upward
defs. So, we check the cache for the {Phi,MemLoc} pair before checking
if we've already walked the Phi.

The {Phi,MemLoc} pair is (almost?) always guaranteed to have a cache
entry if we've already fully walked it, because we cache as we go.

So, if the {Phi,MemLoc} pair isn't in cache, either:
 (a) we must be in the process of visiting it (in which case, we can't
     give a better answer in a cache-as-we-go DFS walker)

 (b) we visited it, but didn't cache it on the way back (...which seems
     to require `ModifyingAccess` to not dominate `StartingAccess`,
     so I'm 99% sure that would be an error. If it's not an error, I
     haven't been able to get it to happen locally, so I suspect it's
     rare.)

- - - - -

As a consequence of this change, we no longer skip upward defs of phis,
so we can kill the `VisitedOnlyOne` check. This gives us better accuracy
than we had before, at the cost of potentially doing a bit more work
when we have a loop.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264814 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-30 00:26:26 +00:00
Adam Nemet
f6d6e72445 [Aarch64] Turn on the LoopDataPrefetch pass for Cyclone
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264811 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-30 00:21:29 +00:00
Adam Nemet
1e5a35493b [PPC] Remove -ppc-loop-prefetch-distance in favor of -prefetch-distance
After the previous change, this can now be overridden centrally in the
pass.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264807 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-29 23:45:56 +00:00
Adam Nemet
515ab47338 [LoopDataPrefetch] Centralize the tuning cl::opts under the pass
This is effectively NFC, minus the renaming of the options
(-cyclone-prefetch-distance -> -prefetch-distance).

The change was requested by Tim in D17943.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264806 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-29 23:45:52 +00:00
Anna Zaks
0a20d994e6 [tsan] Do not instrument reads/writes to instruction profile counters.
We have known races on profile counters, which can be reproduced by enabling
-fsanitize=thread and -fprofile-instr-generate simultaneously on a
multi-threaded program. This patch avoids reporting those races by not
instrumenting the reads and writes coming from the instruction profiler.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264805 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-29 23:19:40 +00:00
Kostya Serebryany
8bb475faa3 [libFuzzer] more trophies
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264804 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-29 23:13:25 +00:00
Kostya Serebryany
7544ffc130 [libFuzzer] more docs
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264803 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-29 23:07:36 +00:00
Duncan P. N. Exon Smith
5a417a10c4 ADCE: Remove debug info intrinsics in dead scopes
During ADCE, track which debug info scopes still have live references
from the code, and delete debug info intrinsics for the dead ones.

These intrinsics describe the locations of variables (in registers or
stack slots).  If there's no code left corresponding to a variable's
scope, then there's no way to reference the variable in the debugger and
it doesn't matter what its value is.

I add a DEBUG printout when the described location in an SSA register,
in case it helps some trying to track down why locations get lost.
However, we still delete these; the scope itself isn't attached to any
real code, so the ship has already sailed.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264800 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-29 22:57:12 +00:00
Fiona Glaser
513c245e44 MachineSink: make shouldSink a TII target hook
Some targets may disagree on what they want sunk or not sunk,
so make this a target hook instead of hardcoded.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264799 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-29 22:44:57 +00:00
Adam Nemet
d6dc9e03af [LoopDataPrefetch] Make more member functions private, NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264798 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-29 22:40:02 +00:00
Adrian Prantl
f8ccc7e199 Upgrade some wildly anachronistic debug info in testcases.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264797 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-29 22:34:30 +00:00
Sanjay Patel
deb808c52a use FileCheck and auto-check-generation script for exact checking
1. Removed the run line for mingw32 and made the Darwin triples unknown.
   This is a test of 32-bit vs. 64-bit platform and the underlying hardware.
   We have other tests for checking behavioral differences of the OS platform.

2. Changed the CPU specifiers to the attributes they were meant to represent.
   Any CPU that doesn't have SSE4.2 is assumed to have slow unaligned 16-byte accesses,
   so it won't use those here.
 
3. Although the stores really could all be CHECK-DAG, I left them as CHECK-NEXT to
   show the strange behavior of the instruction scheduler in the SLOW_32 case.

4. The odd-looking instructions are due to the use of a null pointer in the IR, so
   we have integer immediate store addresses. Cute.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264796 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-29 22:27:39 +00:00
Derek Schuff
d239bc5dbb Add a print method to MachineFunctionProperties for better error messages
This makes check failures much easier to understand.
Make it empty (but leave it in the class) for NDEBUG builds.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264780 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-29 20:28:20 +00:00
Aaron Ballman
68b470458c Clarifying some of the requirements for building with Visual Studio on Windows. Namely, we require the latest Update to be installed (for sanity purposes), and we require CMake 2.8.12.2 for building LLVM with Visual Studio.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264779 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-29 20:23:55 +00:00
Kevin Enderby
ae7cf58516 Fix some bugs in the posix output of llvm-nm. Which is documented on
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/nm.html .

1) For Mach-O files the code was not printing the values in hex as is the default.
2) The values printed had leading zeros which they should not have.
3) The address for undefined symbols was printed as spaces instead of 0.
4) With the -A option with posix output for an archive did not use square
brackets around the archive member name.

rdar://25311883 and rdar://25299678


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264778 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-29 20:18:07 +00:00
James Y Knight
499797f6dc [SPARC] Use AtomicExpandPass to expand AtomicRMW instructions.
They were previously expanded to CAS loops in a custom isel expansion,
but AtomicExpandPass knows how to do that generically.

Testing is covered by the existing sparc atomics.ll testcases.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264771 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-29 19:09:54 +00:00
Matthias Braun
1df673217b MachineVerifier: On dead-def live segments, check that corresponding machine operand has a dead flag
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264769 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-29 19:07:43 +00:00
Matthias Braun
f27ef7a795 LiveVariables: Fix typo and shorten comment
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264768 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-29 19:07:40 +00:00
Duncan P. N. Exon Smith
0ee5788656 IR: Add DbgInfoIntrinsic::getVariableLocation
Create a common accessor, DbgInfoIntrinsic::getVariableLocation, which
doesn't care about the type of debug info intrinsic.  Use this to
further unify the implementations of DbgDeclareInst::getAddress and
DbgValueInst::getValue.

Besides being a cleanup, I'm planning to use this to prepare DEBUG
output without having to branch on the concrete type.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264767 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-29 18:56:03 +00:00
Ryan Govostes
b957e26156 Revert "[asan] Make the global_metadata_darwin.ll test require El Capitan or newer"
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264764 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-29 18:27:24 +00:00
Teresa Johnson
402752067f [ThinLTO] Remove post-pass metadata linking support
Since we have moved to a model where functions are imported in bulk from
each source module after making summary-based importing decisions, there
is no longer a need to link metadata as a postpass, and all users have
been removed.

This essentially reverts r255909 and follow-on fixes.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264763 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-29 18:24:19 +00:00
Ryan Govostes
5826030c0a [asan] Make the global_metadata_darwin.ll test require El Capitan or newer
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264758 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-29 17:58:49 +00:00
Nirav Dave
54cc8d76c8 Add support for no-jump-tables
Add function soft attribute to the generation of Jump Tables in CodeGen
as initial step towards clang support of gcc's no-jump-table support

Reviewers: hans, echristo

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264756 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-29 17:46:23 +00:00
Derek Schuff
b65f550d9a Add MachineVerifier check for AllVRegsAllocated MachineFunctionProperty
Summary:
Check that any function that has the property set is free of virtual
register operands.

Also, it is actually VirtRegMap (and not the register allocators) that
acutally remove the VReg operands (except for RegAllocFast).

Reviewers: qcolombet

Subscribers: MatzeB, llvm-commits, qcolombet

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264755 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-29 17:40:22 +00:00
Manman Ren
d9e9e2b717 Swift Calling Convention: add swiftself attribute.
Differential Revision: http://reviews.llvm.org/D17866


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264754 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-29 17:37:21 +00:00
Sanjay Patel
65a7ad238f [x86] add tests to show current memset codegen
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264748 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-29 17:09:27 +00:00
Sanjoy Das
f504359e79 [SCEV] Extract out a MatchBinaryOp; NFCI
MatchBinaryOp abstracts out the IR instructions from the operations they
represent.  While this change is NFC, we will use this factoring later
to map things like `(extractvalue 0 (sadd.with.overflow X Y))` to `(add
X Y)`.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264747 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-29 16:40:44 +00:00
Sanjoy Das
2bf1827586 [SCEV] Use Operator::getOpcode instead of manual dispatch; NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264746 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-29 16:40:39 +00:00
Justin Lebar
2029771fb2 Make InlineSimple's one-arg constructor explicit. NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264744 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-29 16:26:06 +00:00
Justin Lebar
706afb2d36 Reformat a comment in InlineSimple.cpp. NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264743 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-29 16:26:03 +00:00
Sanjay Patel
4fdd8ba990 regenerate checks
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264738 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-29 16:11:29 +00:00
Konstantin Zhuravlyov
338aaed82f Test commit access
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264736 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-29 15:15:44 +00:00
Teresa Johnson
bc26aebcf9 [ThinLTO] Use new GlobalValue::getGUID helper (NFC)
This was already being used for functions and aliases, was missed when
handling global variables.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264734 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-29 14:49:26 +00:00
Hemant Kulkarni
7ef71aa221 [llvm-readobj] NFC: Remove unneeded parenthesis
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264731 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-29 14:20:20 +00:00
Simon Dardis
b4efa117cf [mips] Test commit: Mark insertNoop as dead code (NFC)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264728 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-29 13:02:19 +00:00
Daniel Sanders
b5f67e4625 [mips] Correct MIPS16 jal/jalx to have uimm26 offsets and add MC layer range checks. NFC.
Summary:
However, this has no effect at this time because the instructions affected
are marked 'isCodeGenOnly=1' and have no alternative for the MC layer.

Reviewers: vkalintiris

Subscribers: llvm-commits, dsanders

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264712 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-29 09:40:38 +00:00
Junmo Park
7c78d07dc3 fix CHECK_NOT -> CHECK-NOT
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264706 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-29 07:53:07 +00:00
Junmo Park
0848da2048 fixed typo - CHECK-LABEL
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264704 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-29 07:03:27 +00:00
Elena Demikhovsky
5a15e95c59 Added 2 notes
1) Skylake and KNL support for X86
2) masked intrinsics load/store/gather/scatter

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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264703 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-29 06:55:56 +00:00
Elena Demikhovsky
98ebf8c719 fixed typo - CHECK-LABEL
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264702 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-29 06:49:38 +00:00
Elena Demikhovsky
c4a86129f8 AVX-512: fixed a bug in fp_to_uint pattern on KNL
Fixed fp_to_uint instruction selection on KNL.
One pattern was missing for <4 x double> to <4 x i32>

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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264701 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-29 06:33:41 +00:00
Duncan P. N. Exon Smith
859d69a3ce BitcodeReader: Allow METADATA_STRINGS to only have !""
Support parsing a METADATA_STRINGS record that only has a single piece
of metadata, !"".  Fixes a corner case in r264551.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264699 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-29 05:25:17 +00:00