Commit Graph

17732 Commits

Author SHA1 Message Date
Mehdi Amini
125de50e12 Add assertions for out of bound index in ComputeLinearIndex
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225951 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-14 05:38:48 +00:00
Mehdi Amini
497b958447 Fold a loop for array processing in ComputeLinearIndex
When processing an array, every Elt has the same layout, it is
useless to recursively call each ComputeLinearIndex on each element.
Just do it once and multiply by the number of elements.
    
Differential Revision: http://reviews.llvm.org/D6832




git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225949 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-14 05:33:01 +00:00
JF Bastien
7f0cbb5703 Revert "Insert random noops to increase security against ROP attacks (llvm)"
This reverts commit:
http://reviews.llvm.org/D3392

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225948 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-14 05:24:33 +00:00
Matt Arsenault
8b6a26ca85 Implement new way of expanding extloads.
Now that the source and destination types can be specified,
allow doing an expansion that doesn't use an EXTLOAD of the
result type. Try to do a legal extload to an intermediate type
and extend that if possible.

This generalizes the special case custom lowering of extloads
R600 has been using to work around this problem.

This also happens to fix a bug that would incorrectly use more
aligned loads than should be used.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225925 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-14 01:35:17 +00:00
JF Bastien
21befa7761 Insert random noops to increase security against ROP attacks (llvm)
A pass that adds random noops to X86 binaries to introduce diversity with the goal of increasing security against most return-oriented programming attacks.

Command line options:
  -noop-insertion // Enable noop insertion.
  -noop-insertion-percentage=X // X% of assembly instructions will have a noop prepended (default: 50%, requires -noop-insertion)
  -max-noops-per-instruction=X // Randomly generate X noops per instruction. ie. roll the dice X times with probability set above (default: 1). This doesn't guarantee X noop instructions.

In addition, the following 'quick switch' in clang enables basic diversity using default settings (currently: noop insertion and schedule randomization; it is intended to be extended in the future).
  -fdiversify

This is the llvm part of the patch.
clang part: D3393

http://reviews.llvm.org/D3392
Patch by Stephen Crane (@rinon)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225908 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-14 01:07:26 +00:00
Hal Finkel
7a4708e0eb Adjust ScheduleDAGSDNodes::RegDefIter for patchpoints
PATCHPOINT is a strange pseudo-instruction. Depending on how it is used, and
whether or not the AnyReg calling convention is being used, it might or might
not define a value. However, its TableGen definition says that it defines one
value, and so when it doesn't, the code in ScheduleDAGSDNodes::RegDefIter
becomes confused and the code that uses the RegDefIter will try to get the
register class of the MVT::Other type associated with the PATCHPOINT's chain
result (under certain circumstances).

This will be covered by the PPC64 PatchPoint test cases once that support is
re-committed.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225907 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-14 01:07:03 +00:00
Reid Kleckner
504fa89c8e CodeGen support for x86_64 SEH catch handlers in LLVM
This adds handling for ExceptionHandling::MSVC, used by the
x86_64-pc-windows-msvc triple. It assumes that filter functions have
already been outlined in either the frontend or the backend. Filter
functions are used in place of the landingpad catch clause type info
operands. In catch clause order, the first filter to return true will
catch the exception.

The C specific handler table expects the landing pad to be split into
one block per handler, but LLVM IR uses a single landing pad for all
possible unwind actions. This patch papers over the mismatch by
synthesizing single instruction BBs for every catch clause to fill in
the EH selector that the landing pad block expects.

Missing functionality:
- Accessing data in the parent frame from outlined filters
- Cleanups (from __finally) are unsupported, as they will require
  outlining and parent frame access
- Filter clauses are unsupported, as there's no clear analogue in SEH

In other words, this is the minimal set of changes needed to write IR to
catch arbitrary exceptions and resume normal execution.

Reviewers: majnemer

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225904 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-14 01:05:27 +00:00
Adrian Prantl
f82fc00e4c Debug Info: Implement DwarfCompileUnit::addComplexAddress() using
DIEDwarfExpression (and get rid of a bunch of redundant code).

NFC

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225900 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-14 01:01:30 +00:00
Adrian Prantl
db48bda4a1 Debug Info: Emitting a register in DwarfExpression may fail. Report the
status in a bool and let the users deal with the error.

NFC.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225899 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-14 01:01:28 +00:00
Adrian Prantl
e733e5461f Debug Info: Move DIEDwarfExpression into DwarfExpression.h because it
needs to be accessed from both DwarfCompileUnit.cpp and DwarfUnit.cpp.

NFC.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225898 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-14 01:01:22 +00:00
Eric Christopher
ce0f74d412 Migrate ABIName to MCTargetOptions so that it can be shared between
the TargetMachine level and the MC level.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225891 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-14 00:50:31 +00:00
Adrian Prantl
bb7e1f3687 Debug Info: Don't bother emitting DW_AT_frame_base if the function has
no frame register. "Tested" via an assertion triggered by DwarfExpression.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225858 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-14 00:15:16 +00:00
Adrian Prantl
4e5d08aad0 Revert "Debug Info: Bail out of AddMachineRegPiece() if MachineReg is not a"
This reverts commit r225852, it was a bad idea.

MachineReg should always be a physical register. If it isn't this DebugLoc
shouldn't have been created in the first place.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225857 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-14 00:15:12 +00:00
Adrian Prantl
bc42415f0f Debug Info: Bail out of AddMachineRegPiece() if MachineReg is not a
physical register. The call to getMinimalPhysRegClass() later on asserts
on this condition.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225852 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-13 23:39:15 +00:00
Adrian Prantl
57ed5ffc76 Debug Info: Move the complex expression handling (=the remainder) of
emitDebugLocValue() into DwarfExpression.

Ought to be NFC, but it actually uncovered a bug in the debug-loc-asan.ll
testcase. The testcase checks that the address of variable "y" is stored
at [RSP+16], which also lines up with the comment.
It also check(ed) that the *value* of "y" is stored in RDI before that,
but that is actually incorrect, since RDI is the very value that is
stored in [RSP+16]. Here's the assembler output:

	movb	2147450880(%rcx), %r8b
	#DEBUG_VALUE: bar:y <- RDI
	cmpb	$0, %r8b
	movq	%rax, 32(%rsp)          # 8-byte Spill
	movq	%rsi, 24(%rsp)          # 8-byte Spill
	movq	%rdi, 16(%rsp)          # 8-byte Spill
.Ltmp3:
	#DEBUG_VALUE: bar:y <- [RSP+16]

Fixed the comment to spell out the correct register and the check to
expect an address rather than a value.

Note that the range that is emitted for the RDI location was and is still
wrong, it claims to begin at the function prologue, but really it should
start where RDI is first assigned.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225851 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-13 23:39:11 +00:00
Adrian Prantl
9fb34c5169 cleanup.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225848 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-13 23:11:51 +00:00
Adrian Prantl
82df5a6981 Document, cleanup, and clang-format DwarfExpression.h
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225847 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-13 23:11:07 +00:00
Adrian Prantl
78415546e9 Debug Info: Turn DIExpression::getFrameRegister() into an isFrameRegister()
function.

NFC.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225846 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-13 23:10:43 +00:00
Matthias Braun
12232769b3 DAGCombiner: simplify by using condition variables; NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225836 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-13 22:17:46 +00:00
Matt Arsenault
7c06364dc0 R600: Implement getRecipEstimate
This requires a new hook to prevent expanding sqrt in terms
of rsqrt and reciprocal. v_rcp_f32, v_rsq_f32, and v_sqrt_f32 are
all the same rate, so this expansion would just double the number
of instructions and cycles.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225828 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-13 20:53:23 +00:00
Hal Finkel
0ca9b79771 [StackMaps] Use CurrentFnSymForSize
When computing the call-site offset, use AP.CurrentFnSymForSize instead of
AP.CurrentFnSym. There should be no change for other targets, but this is
necessary for generating valid expressions for PPC64/ELF.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225807 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-13 17:48:07 +00:00
Hal Finkel
b41c7e59a7 [StackMaps] Mark in CallLoweringInfo when lowering a patchpoint
While, generally speaking, the process of lowering arguments for a patchpoint
is the same as lowering a regular indirect call, on some targets it may not be
exactly the same. Targets may not, for example, want to add additional register
dependencies that apply only to making cross-DSO calls through linker stubs,
may not want to load additional registers out of function descriptors, and may
not want to add additional side-effect-causing instructions that cannot be
removed later with the call itself being generated.

The PowerPC target will use this in a future commit (for all of the reasons
stated above).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225806 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-13 17:48:04 +00:00
Hal Finkel
5e508855d6 [StackMaps] Allow the target to pre-process the live-out mask
Some targets, PowerPC for example, have pseudo-registers (such as that used to
represent the rounding mode), that don't have DWARF register numbers or a
register class. These are used only for internal dependency tracking, and
should not appear in the recorded live-outs. This adds a callback allowing the
target to pre-process the live-out mask in order to remove these kinds of
registers so that the StackMaps code does not complain about them and/or
attempt to include them in the output.

This will be used by the PowerPC target in a future commit.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225805 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-13 17:47:59 +00:00
Olivier Sallenave
9dd21f4380 Added TLI hook for isFPExtFree. Some of the FMA combine heuristics are now guarded with that hook.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225795 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-13 15:06:36 +00:00
Mehdi Amini
24dbb798ff Peephole opt needs optimizeSelect() to keep track of newly created MIs
Peephole optimizer is scanning a basic block forward. At some point it 
needs to answer the question "given a pointer to an MI in the current 
BB, is it located before or after the current instruction".
To perform this, it keeps a set of the MIs already seen during the scan, 
if a MI is not in the set, it is assumed to be after.
It means that newly created MIs have to be inserted in the set as well.

This commit passes the set as an argument to the target-dependent 
optimizeSelect() so that it can properly update the set with the 
(potentially) newly created MIs.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225772 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-13 07:07:13 +00:00
Reid Kleckner
d8f69a7201 Rename llvm.recoverframeallocation to llvm.framerecover
This name is less descriptive, but it sort of puts things in the
'llvm.frame...' namespace, relating it to frameallocate and
frameaddress. It also avoids using "allocate" and "allocation" together.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225752 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-13 01:51:34 +00:00
Reid Kleckner
221a7075cf Add the llvm.frameallocate and llvm.recoverframeallocation intrinsics
These intrinsics allow multiple functions to share a single stack
allocation from one function's call frame. The function with the
allocation may only perform one allocation, and it must be in the entry
block.

Functions accessing the allocation call llvm.recoverframeallocation with
the function whose frame they are accessing and a frame pointer from an
active call frame of that function.

These intrinsics are very difficult to inline correctly, so the
intention is that they be introduced rarely, or at least very late
during EH preparation.

Reviewers: echristo, andrew.w.kaylor

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225746 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-13 00:48:10 +00:00
Matt Arsenault
29ad7506e1 Combine fcmp + select to fminnum / fmaxnum if no nans and legal
Also require unsafe FP math for no since there isn't a way to
test for signed zeros.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225744 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-13 00:43:00 +00:00
Adrian Prantl
75212344d1 Debug Info: Move support for constants into DwarfExpression.
Move the declaration of DebugLocDwarfExpression into DwarfExpression.h
because it needs to be accessed from AsmPrinterDwarf.cpp and DwarfDebug.cpp

NFC.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225734 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-13 00:04:06 +00:00
Adrian Prantl
df545e8d6c Make DwarfExpression store the AsmPrinter instead of the TargetMachine.
NFC.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225731 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-12 23:36:56 +00:00
Adrian Prantl
0ec7e836f9 remove extra semicolon
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225730 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-12 23:36:50 +00:00
Reid Kleckner
1ec250a32f musttail: Only set the inreg flag for fastcall and vectorcall
Otherwise we'll attempt to forward ECX, EDX, and EAX for cdecl and
stdcall thunks, leaving us with no scratch registers for indirect call
targets.

Fixes PR22052.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225729 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-12 23:28:23 +00:00
Adrian Prantl
2f95648566 Run clang-format on the parts of AsmPrinterDwarf where it improves the
readability.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225726 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-12 23:03:23 +00:00
Adrian Prantl
34ae4e7151 Debug Info: Add a virtual destructor to DwarfExpression.
Thanks Chandler for noticing!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225724 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-12 22:59:28 +00:00
Adrian Prantl
3d6fed1a57 Untwine this expression. Thanks to David for noticing!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225720 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-12 22:39:14 +00:00
Adrian Prantl
8afb6d0e2f Debug Info: Implement DwarfUnit::addRegisterOpPiece() using DwarfExpression.
NFC.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225717 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-12 22:37:16 +00:00
Adrian Prantl
93eb099f24 Debug Info: Implement DwarfUnit::addRegisterOffset using DwarfExpression.
No functional change.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225707 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-12 22:19:26 +00:00
Adrian Prantl
f89325d832 Debug info: Factor out the creation of DWARF expressions from AsmPrinter
into a new class DwarfExpression that can be shared between AsmPrinter
and DwarfUnit.

This is the first step towards unifying the two entirely redundant
implementations of dwarf expression emission in DwarfUnit and AsmPrinter.

Almost no functional change — Testcases were updated because asm comments
that used to be on two lines now appear on the same line, which is
actually preferable.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225706 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-12 22:19:22 +00:00
Matthias Braun
095ca8f493 RegisterCoalescer: Turn some impossible conditions into asserts
This is a fixed version of reverted r225500. It fixes the too early
if() continue; of the last patch and adds a comment to the unorthodox
loop.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225652 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-12 19:10:17 +00:00
Ahmed Bougacha
2cec3e9c11 [SimplifyLibCalls] Factor out fortified libcall handling.
This lets us remove CGP duplicate.

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225640 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-12 17:22:43 +00:00
Joerg Sonnenberger
3073d3960a Revert r225500, it leads to infinite loops.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225590 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-10 21:49:36 +00:00
Lang Hames
4c553e0367 Recommit r224935 with a fix for the ObjC++/AArch64 bug that that revision
introduced.

A test case for the bug was already committed in r225385.

Patch by Rafael Espindola.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225534 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-09 18:55:42 +00:00
Matthias Braun
c41acffe22 RegisterCoalescer: Fix removeCopyByCommutingDef with subreg liveness
The code that eliminated additional coalescable copies in
removeCopyByCommutingDef() used MergeValueNumberInto() which internally
may merge A into B or B into A. In this case A and B had different Def
points, so we have to reset ValNo.Def to the intended one after merging.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225503 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-09 03:01:31 +00:00
Matthias Braun
4493e98154 RegisterCoalescer: Some cleanup in removeCopyByCommutingDef(), NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225502 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-09 03:01:28 +00:00
Matthias Braun
fdddd47cc6 RegisterCoalescer: No need to set kill flags, they are recompute later anyway
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225501 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-09 03:01:26 +00:00
Matthias Braun
c25a1509c3 RegisterCoalescer: Turn some impossible conditions into asserts
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225500 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-09 03:01:23 +00:00
Hal Finkel
8e1d151abe [DAGCombine] Remainder of fix to r225380 (More FMA folding opportunities)
As pointed out by Aditya (and Owen), when we elide an FP extend to form an FMA,
we need to extend the incoming operands so that the resulting node will really
be legal. This is currently enabled only for PowerPC, and it happens to work
there regardless, but this should fix the functionality for everyone else
should anyone else wish to use it.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225492 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-09 01:29:29 +00:00
Hal Finkel
40ddb2ce8f Partial fix to r225380 (More FMA folding opportunities)
As pointed out by Aditya (and Owen), there are two things wrong with this code.
First, it adds patterns which elide FP extends when forming FMAs, and that might
not be profitable on all targets (it belongs behind the pre-existing
aggressive-FMA-formation flag). This is fixed by this change.

Second, the resulting nodes might have operands of different types (the
extensions need to be re-added). That will be fixed in the follow-up commit.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225485 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-09 00:45:54 +00:00
Hal Finkel
9d1500e68f [MachineLICM] A command-line option to hoist even cheap instructions
Add a command-line option to enable hoisting even cheap instructions (in
low-register-pressure situations). This is turned off by default, but has
proved useful for testing purposes.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225470 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-08 22:10:48 +00:00
Duncan P. N. Exon Smith
089a4ba180 CodeGen: Use handy new-fangled post-increment, NFC
Drive-by cleanup; I noticed this when reviewing the patch that became
r225466.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225468 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-08 21:07:55 +00:00