Commit Graph

72660 Commits

Author SHA1 Message Date
Charles Davis 97019c709d Add a method to TargetRegisterInfo to get the register number that the Win64 EH
scheme uses internally. Implement it for x86 (the only architecture that LLVM
supports for which this matters right now).

llvm-svn: 131969
2011-05-24 16:57:53 +00:00
Cameron Zwarich 46e1ebf367 Clean up the lazy initialization of DIBuilder a bit.
llvm-svn: 131956
2011-05-24 06:00:08 +00:00
Jakob Stoklund Olesen 0130027dec Work around code generation bug in Visual Studio 2010.
See http://llvm.org/pr9976 for details.

llvm-svn: 131954
2011-05-24 03:20:56 +00:00
Cameron Zwarich 843bc7d673 Make LoadAndStorePromoter preserve debug info and create llvm.dbg.values when
promoting allocas to SSA variables. Fixes <rdar://problem/9479036>.

llvm-svn: 131953
2011-05-24 03:10:43 +00:00
Rafael Espindola 0d018b1155 Explain FIXME.
llvm-svn: 131952
2011-05-24 03:10:31 +00:00
Rafael Espindola 0f33be1b87 Fix the defaults for .eh_frame. We were marking it as writable.
llvm-svn: 131951
2011-05-24 02:50:20 +00:00
Evan Cheng 88f9137fd7 - Teach SelectionDAG::isKnownNeverZero to return true (op x, c) when c is
non-zero.
- Teach X86 cmov optimization to eliminate the cmov from ctlz, cttz extension
  when the source of X86ISD::BSR / X86ISD::BSF is proven to be non-zero.

rdar://9490949

llvm-svn: 131948
2011-05-24 01:48:22 +00:00
Evan Cheng a3b4203cbc Remove dead option.
llvm-svn: 131947
2011-05-24 01:43:38 +00:00
Andrew Trick 37f0082804 FileCheck-ize a couple of IV unit tests.
llvm-svn: 131946
2011-05-24 01:02:49 +00:00
Rafael Espindola 7e9ca2c095 Fix cmake dependencies.
llvm-svn: 131943
2011-05-24 00:58:06 +00:00
Akira Hatanaka cb4a1a8d3f Simplify offset calculation of stack frame objects for $gp restore location and
variable arguments in LowerCall and LowerFormalArguments. This should also fix
the bug in which handling of variable arguments is incorrect when the front-end
optimizes away unused fixed arguments.

llvm-svn: 131942
2011-05-24 00:23:52 +00:00
Devang Patel 354fa0798f Fix debug info for blocks' variable.
llvm-svn: 131940
2011-05-24 00:22:25 +00:00
Andrew Trick 1ea0243bd0 Test case for r130799 - indvars: Added canExpandBackEdgeTakenCount.
llvm-svn: 131939
2011-05-24 00:17:53 +00:00
Devang Patel faaa16ea2c Remove unnecessary comment.
llvm-svn: 131936
2011-05-23 23:16:14 +00:00
Akira Hatanaka dfb8cda11f Expand f64 FPOW.
llvm-svn: 131928
2011-05-23 22:23:58 +00:00
Akira Hatanaka 6af5bd2537 Add pattern for double-to-integer conversion. Patch by Sasa Stankovic.
llvm-svn: 131927
2011-05-23 22:16:43 +00:00
Devang Patel efec7715ec Revert 121907 (it causes llc crash) and apply original patch from PR9817.
llvm-svn: 131926
2011-05-23 22:04:42 +00:00
Akira Hatanaka 9dbb45b596 Fixes related to coding style.
llvm-svn: 131922
2011-05-23 21:13:59 +00:00
Dan Gohman 911fa9084c Document llvm.exp and llvm.pow.
llvm-svn: 131921
2011-05-23 21:13:03 +00:00
Dan Gohman 6c4a319088 When checking for signed multiplication overflow, watch out for INT_MIN and -1.
This fixes PR9845.

llvm-svn: 131919
2011-05-23 21:07:39 +00:00
Jim Grosbach bae9fee95f Propagate error correctly in the MC Asm parser for leading '$' expressions.
llvm-svn: 131918
2011-05-23 20:36:04 +00:00
Akira Hatanaka 90d96f44ce Fix MipsAsmPrinter::printSavedRegsBitmaskChange. Remove functions and variables
in MipsFunctionInfo that are no longer used.

llvm-svn: 131917
2011-05-23 20:34:30 +00:00
Chris Lattner d71ed9431a clarify this, apparently it is confusing :)
llvm-svn: 131916
2011-05-23 20:17:44 +00:00
Akira Hatanaka f9e5750fc8 Change StackDirection from StackGrowsUp to StackGrowsDown.
The following improvements are accomplished as a result of applying this patch:
- Fixed frame objects' offsets (relative to either the virtual frame pointer or
  the stack pointer) are set before instruction selection is completed. There is
  no need to wait until Prologue/Epilogue Insertion is run to set them.
- Calculation of final offsets of fixed frame objects is straightforward. It is
  no longer necessary to assign negative offsets to fixed objects for incoming
  arguments in order to distinguish them from the others.
- Since a fixed object has its relative offset set during instruction
  selection, there is no need to conservatively set its alignment to 4.
- It is no longer necessary to reorder non-fixed frame objects in 
  MipsFrameLowering::adjustMipsStackFrame.

llvm-svn: 131915
2011-05-23 20:16:59 +00:00
Devang Patel 9987d3098b Test case for r131908.
llvm-svn: 131909
2011-05-23 17:49:29 +00:00
Devang Patel 7992883811 Preserve debug info during iSel by keeping DanglingDebugInfoMap live until end of function.
Patch by Micah Villmow

llvm-svn: 131908
2011-05-23 17:44:13 +00:00
Devang Patel c4d9a84159 While replacing all uses of a SDValue with another value, do not forget to transfer SDDbgValue.
llvm-svn: 131907
2011-05-23 17:35:08 +00:00
Devang Patel 0f6b46b826 Clear list of instructions without DebugLoc.
llvm-svn: 131906
2011-05-23 17:34:18 +00:00
Duncan Sands f0f143e31d The dragonegg option to disable LLVM optimizations changed.
llvm-svn: 131903
2011-05-23 16:50:29 +00:00
Charles Davis d9eafdcfd5 Implement .seh_stackalloc and .seh_pushframe parsing.
I haven't implemented any of the ones that take registers yet. The problem is
that for x86-64 the streamer methods expect a native x86 register number (note:
%r8-%r15 want 8-15 instead of 0-7; same for %xmm8-%xmm15). I haven't figured
out exactly how I want to do that yet.

llvm-svn: 131899
2011-05-23 16:43:09 +00:00
Chris Lattner 026f5e61f0 fix a really nasty basicaa mod/ref calculation bug that was causing miscompilation of
UnitTests/ObjC/messages-2.m with the recent optimizer improvements.

llvm-svn: 131897
2011-05-23 05:15:43 +00:00
Cameron Zwarich bc90690b24 Fix <rdar://problem/9476260> by having tail calls always generate 32-bit branches
in Darwin Thumb2 code. Tail calls are already disabled on Thumb1.

llvm-svn: 131894
2011-05-23 01:57:17 +00:00
Chris Lattner 388cb8a57c rearrange two transforms, since one subsumes the other. Make the shift-exactness
xform recurse.

llvm-svn: 131888
2011-05-23 00:32:19 +00:00
Chris Lattner 8aff4f8efc Transform any logical shift of a power of two into an exact/NUW shift when
in a known-non-zero context.

llvm-svn: 131887
2011-05-23 00:21:50 +00:00
Bill Wendling f5199debc0 Use a more efficient data structure for the "operand map". The number of
operands to an instruction aren't great, so an iterative search is fairly quick
and doesn't have the overhead of std::map.

llvm-svn: 131886
2011-05-23 00:18:33 +00:00
Chris Lattner 321c58fc41 use the valuetracking isPowerOfTwo function, which is more powerful than checking
for a constant directly.  Thanks to Duncan for pointing this out.

llvm-svn: 131885
2011-05-23 00:09:55 +00:00
Chris Lattner 83791ced7b Teach valuetracking that byval arguments with a specified alignment are
aligned.

Teach memcpyopt to not give up all hope when confonted with an underaligned
memcpy feeding an overaligned byval.  If the *source* of the memcpy can be
determined to be adequeately aligned, or if it can be forced to be, we can
eliminate the memcpy.

This addresses PR9794.  We now compile the example into:

define i32 @f(%struct.p* nocapture byval align 8 %q) nounwind ssp {
entry:
  %call = call i32 @g(%struct.p* byval align 8 %q) nounwind
  ret i32 %call
}

in both x86-64 and x86-32 mode.  We still don't get a tailcall though,
because tailcalls apparently can't handle byval.

llvm-svn: 131884
2011-05-23 00:03:39 +00:00
Chris Lattner 4d37d99798 add a helper method to get the byval alignment of an argument.
llvm-svn: 131883
2011-05-22 23:57:23 +00:00
Chris Lattner 68254fcbca Eliminate some temporary variables, and don't call getByValTypeAlignment
when we're just going to throw the result away.  No functionality change.

llvm-svn: 131880
2011-05-22 23:23:02 +00:00
Chris Lattner af5fecb747 add test from PR9164
llvm-svn: 131876
2011-05-22 22:35:34 +00:00
Chris Lattner 819278891a testcase for PR9378
llvm-svn: 131875
2011-05-22 22:32:53 +00:00
Chris Lattner e240dc52ff add a missing alias to make us more bug compatible with gcc, PR9378
llvm-svn: 131874
2011-05-22 22:31:57 +00:00
Chris Lattner f98eadee17 document thiscall, PR9101
llvm-svn: 131873
2011-05-22 22:28:47 +00:00
Chris Lattner 713d52364f implement PR9315, constant folding exp2 in terms of pow (since hosts without
C99 runtimes don't have exp2).

llvm-svn: 131872
2011-05-22 22:22:35 +00:00
Renato Golin 4cd5187f5b RTABI chapter 4.3.4 specifies __eabi_mem* calls. Specifically, __eabi_memset accepts parameters (ptr, size, value) in a different order than GNU's memset (ptr, value, size), therefore the special lowering in AAPCS mode. Implementation by Evzen Muller.
llvm-svn: 131868
2011-05-22 21:41:23 +00:00
Charles Davis c7250faeb1 Add methods to parse the SEH directives to the COFFAsmParser. Implement some
of them, particularly the ones that don't take arguments. Also implement
.seh_proc and .seh_handler.

llvm-svn: 131866
2011-05-22 21:12:15 +00:00
Chris Lattner bfe2c24c80 add a note.
llvm-svn: 131863
2011-05-22 18:28:46 +00:00
Chris Lattner 162dfc3e6b add some random notes.
llvm-svn: 131862
2011-05-22 18:26:48 +00:00
Evan Cheng 2a746bfe36 Teach ValueTracking about x86 crc32 intrinsics.
llvm-svn: 131861
2011-05-22 18:25:30 +00:00
Chris Lattner 7c99f19d9f Carve out a place in instcombine to put transformations which work knowing that their
result is non-zero.  Implement an example optimization (PR9814), which allows us to
transform:
  A / ((1 << B) >>u 2)
into:
  A >>u (B-2)

which we compile into:

_divu3:                                 ## @divu3
	leal	-2(%rsi), %ecx
	shrl	%cl, %edi
	movl	%edi, %eax
	ret

instead of:

_divu3:                                 ## @divu3
	movb	%sil, %cl
	movl	$1, %esi
	shll	%cl, %esi
	shrl	$2, %esi
	movl	%edi, %eax
	xorl	%edx, %edx
	divl	%esi, %eax
	ret

llvm-svn: 131860
2011-05-22 18:18:41 +00:00
Johnny Chen a0c9c75df2 Fix Bug 9386 - ARM disassembler failed to disassemble conditional bx
Modified the patch to .td file supplied by Jyun-Yan You.  Add a test case and
modified ARMDisassemblerCore.cpp a little bit.

llvm-svn: 131859
2011-05-22 17:51:04 +00:00
Chris Lattner c4ca7ab7e7 Fix PR9815: I was trying to get out of "generating code and then
failing to form a memset, then having to delete it" but my approximation
isn't safe for self recurrent loops.  Instead of doign a hack, just
do it the right way.

llvm-svn: 131858
2011-05-22 17:39:56 +00:00
Frits van Bommel ad964559ef Add a parameter to ConstantFoldTerminator() that callers can use to ask it to also clean up the condition of any conditional terminator it folds to be unconditional, if that turns the condition into dead code. This just means it calls RecursivelyDeleteTriviallyDeadInstructions() in strategic spots. It defaults to the old behavior.
I also changed -simplifycfg, -jump-threading and -codegenprepare to use this to produce slightly better code without any extra cleanup passes (AFAICT this was the only place in -simplifycfg where now-dead conditions of replaced terminators weren't being cleaned up). The only other user of this function is -sccp, but I didn't read that thoroughly enough to figure out whether it might be holding pointers to instructions that could be deleted by this.

llvm-svn: 131855
2011-05-22 16:24:18 +00:00
Chris Lattner 4932e3de1b another typo
llvm-svn: 131854
2011-05-22 15:44:02 +00:00
Chris Lattner 6783871672 fix comment typo
llvm-svn: 131853
2011-05-22 15:34:37 +00:00
Chris Lattner 408cfef6f0 I missed a checking with my GVN change.
llvm-svn: 131851
2011-05-22 07:20:02 +00:00
Chris Lattner c2e8540216 insertvalue takes a variable number of arguments, document this, fixing PR9935.
llvm-svn: 131850
2011-05-22 07:18:08 +00:00
Chris Lattner 1a1acc2191 fix PR9856, an incorrectly conservative assertion: a global can be
"stored once" even if its address is compared.

llvm-svn: 131849
2011-05-22 07:15:13 +00:00
Chris Lattner f0d59072de fix PR9841 by having GVN not process dead loads. This was
causing it to get into infinite loops when it would widen a 
load (which can necessarily leave around dead loads).

llvm-svn: 131847
2011-05-22 07:03:34 +00:00
Chris Lattner a10327f531 remove a trivial test, make some other tests less trivial.
llvm-svn: 131846
2011-05-22 07:02:43 +00:00
Chris Lattner cc87723178 make this test less trivial.
llvm-svn: 131845
2011-05-22 06:59:33 +00:00
Chris Lattner ef8cf6d421 initialize and finalize function passes, pointed out by Cameron.
llvm-svn: 131843
2011-05-22 06:44:19 +00:00
Chris Lattner 9f1d2ded13 fix a bug for hosts without round, PR8893.
llvm-svn: 131842
2011-05-22 06:03:53 +00:00
Chris Lattner bbc40ac474 move PR9408 here.
llvm-svn: 131841
2011-05-22 05:45:06 +00:00
Nick Lewycky d60e135cfe Commit test change, forgotten as part of r131838.
llvm-svn: 131839
2011-05-22 05:31:47 +00:00
Nick Lewycky a68ec83b36 Teach the inliner to emit llvm.lifetime.start/end, to scope the local variables
of the inlinee to the code representing the original function.

llvm-svn: 131838
2011-05-22 05:22:10 +00:00
Chris Lattner 1d068cc0b0 switch to using a smallvector to avoid allocations for most normal size instructions.
llvm-svn: 131837
2011-05-22 04:53:24 +00:00
Chris Lattner 0388fb0ee2 tidy some things up.
llvm-svn: 131836
2011-05-22 04:52:24 +00:00
Chris Lattner e8bf2d5ad3 Fix some minor typos and grammar.
llvm-svn: 131835
2011-05-22 04:44:48 +00:00
Charles Davis bc2daa0f93 Implement emission of all Win64 exception tables. Make the COFF streamer emit
these tables.

llvm-svn: 131833
2011-05-22 04:15:07 +00:00
Charles Davis 1c8bd5ad7e Make the COFF streamer emit unwind info when processing a .seh_handlerdata
directive.

Implement emission of Win64 EH unwind info.

Pull in <cassert> in MCWin64EH.h so it can use the assert() macro.

llvm-svn: 131832
2011-05-22 03:01:05 +00:00
Nick Lewycky 1c8af13719 Fix grammar in test.
llvm-svn: 131831
2011-05-22 01:16:00 +00:00
Charles Davis e636022b4d Don't allow unaligned offsets and sizes in the Win64 EH directives.
Also, fix threshold for 'Big' register saves.

llvm-svn: 131830
2011-05-22 00:56:20 +00:00
Chris Lattner 6078926e26 random comment cleanups.
llvm-svn: 131829
2011-05-22 00:50:53 +00:00
Chris Lattner 4f12f11517 fix a file system case sensitivity issue.
llvm-svn: 131828
2011-05-22 00:37:51 +00:00
Chris Lattner b5865ded27 remove StandardPasses, it has been replaced with PassManagerBuilder
llvm-svn: 131827
2011-05-22 00:30:45 +00:00
Chris Lattner 3d70addad7 switch opt to using PassManagerBuilder.h
llvm-svn: 131824
2011-05-22 00:21:33 +00:00
Chris Lattner ac99108d36 switch llvm-ld. It has a terrible mechanism that people can add extra
passes, it should be converted to use extension points.

llvm-svn: 131823
2011-05-22 00:21:15 +00:00
Chris Lattner f200a0af58 switch bugpoint and liblto to PassManagerBuilder.
llvm-svn: 131821
2011-05-22 00:20:07 +00:00
Chris Lattner fa9fe70a6a add support for LTO passes.
llvm-svn: 131820
2011-05-22 00:14:20 +00:00
Chris Lattner 04120e9567 eliminate dependence on StandardPasses.h. The code generator's pass pipeline
should eventually convert to PMBuilder, but I don't plan to do this.

llvm-svn: 131819
2011-05-22 00:13:44 +00:00
Charles Davis a8805fd71a Include DataTypes.h from this header to get the uint*_t types.
llvm-svn: 131817
2011-05-22 00:05:26 +00:00
Charles Davis 4ccc861cbc Allow access to the .pdata and .xdata sections through the TargetAsmInfo
class.

llvm-svn: 131816
2011-05-22 00:03:24 +00:00
Chris Lattner 34cc63cd71 add an extension point mechanism that allow plugins to add stuff to
the pass manager.

llvm-svn: 131814
2011-05-21 23:50:37 +00:00
Nick Lewycky babca9aee9 Add CreateLifetimeStart and CreateLifetimeEnd to the IRBuilder, with plans to
use these soon.

llvm-svn: 131812
2011-05-21 23:14:36 +00:00
Duncan Sands 5ec65765e6 Revert commit 131781, to see if it fixes the x86-64 dragonegg buildbot.
Original log message:
When BasicAA can determine that two pointers have the same base but
differ by a dynamic offset, return PartialAlias instead of MayAlias.
See the comment in the code for details. This fixes PR9971.

llvm-svn: 131809
2011-05-21 20:54:46 +00:00
Chris Lattner 790cb34f93 add a new PassManagerBuilder class to replace StandardPasses.h
llvm-svn: 131807
2011-05-21 20:39:42 +00:00
Chris Lattner 4c0d9e2249 add a copy ctor to TargetLibraryInfo.
llvm-svn: 131806
2011-05-21 20:09:13 +00:00
Eli Friedman 3de2ddc578 PR7952: Make isa<> use the same logic as cast<>, so that they both work
consistently.

llvm-svn: 131803
2011-05-21 19:13:10 +00:00
Benjamin Kramer e30b70073a X86: smulo -> add is now done target-independently in DAGCombiner, remove the patterns.
llvm-svn: 131801
2011-05-21 18:32:01 +00:00
Benjamin Kramer 2fd48f2730 Implement mulo x, 2 -> addo x, x in DAGCombiner.
llvm-svn: 131800
2011-05-21 18:31:55 +00:00
Benjamin Kramer e08fb1dce9 Merge and FileCheckize test cases.
llvm-svn: 131799
2011-05-21 18:31:48 +00:00
Benjamin Kramer fda5dc4968 Revert "InstCombine: Turn mul.with.overflow(X, 2) into the cheaper add.with.overflow(X, X)"
It's better to do this in codegen, mul.with.overflow(X, 2) is more canonical because it has only one use on "X".

llvm-svn: 131798
2011-05-21 18:31:42 +00:00
Charles Davis 6879634efd Don't allow .seh_handler and .seh_handlerdata directives inside chained
unwind areas.

llvm-svn: 131795
2011-05-21 17:36:25 +00:00
Charles Davis 8e8f59bdfb A handler for a function in the Win64 EH scheme can be both an unwind handler
and an exception handler. Handle that case.

Also, add an 'Emitted' member to the MCWin64EHUnwindInfo struct. It will be
needed later.

llvm-svn: 131791
2011-05-21 15:57:49 +00:00
Benjamin Kramer 691731eb9c InstCombine: Turn mul.with.overflow(X, 2) into the cheaper add.with.overflow(X, X)
llvm-svn: 131789
2011-05-21 09:22:06 +00:00
Cameron Zwarich faeb520c97 Fix PR9978 by adding RIP to GR64_TC so it can be used as an address in PIC code. It
is already in GR64 for the same reasons. Since it isn't allocatable it can't cause
any problems.

llvm-svn: 131787
2011-05-21 04:13:49 +00:00
Akira Hatanaka 2df6c010aa Use the correct register to access stack frame objects.
llvm-svn: 131785
2011-05-21 03:01:03 +00:00
Akira Hatanaka f084fcd7fe Insert instructions that copy $sp to or from $fp at the right locations.
llvm-svn: 131784
2011-05-21 02:29:26 +00:00
Dan Gohman 8b20187c82 When BasicAA can determine that two pointers have the same base but
differ by a dynamic offset, return PartialAlias instead of MayAlias.
See the comment in the code for details. This fixes PR9971.

llvm-svn: 131781
2011-05-21 01:05:08 +00:00
Andrew Trick d5d0764b3b Have Program::Wait return -2 for crashed and timeouts instead of embedding
info in the error message. Per Dan's request.

llvm-svn: 131780
2011-05-21 00:56:46 +00:00
Charles Davis 54254008ba Set the "LastFrameInst" field when streaming a .seh_setframe directive. This
is needed for an upcoming patch.

llvm-svn: 131772
2011-05-21 00:09:04 +00:00
Cameron Zwarich d7ee0fcac9 Fix PR9962 by properly constraining register classes in RemoveCopyByCommutingDef(). This
actually fixes most of the VerifyCoalescing failures in test-suite.

llvm-svn: 131768
2011-05-20 23:25:36 +00:00
Akira Hatanaka 0837692ac6 Change the order fixed objects are created in MipsTargetLowering::LowerCall in
preparation for reversing StackDirection.

Fixed objects are created in the following order:  
 1. Incoming arguments passed on stack.
 2. va_arg objects (include both arguments that are passed in registers and
    pointer to the location of the first va_arg argument).
 3. $gp restore slot.
 4. Outgoing arguments passed on stack.
 5. Pointer to alloca'd space.

llvm-svn: 131767
2011-05-20 23:22:14 +00:00
Charles Davis 1a1d4777b9 Fix typo. When will I learn?
llvm-svn: 131765
2011-05-20 22:23:34 +00:00
Eli Friedman 60afcc2a6f Add fast-isel support for byval calls on x86.
llvm-svn: 131764
2011-05-20 22:21:04 +00:00
Charles Davis bc1feb1f25 Add .pdata and .xdata sections to the COFF TLOF implementation.
llvm-svn: 131763
2011-05-20 22:13:55 +00:00
Jim Grosbach 8aded86edb No reason not to allow defining the CFA as a reg w/ offset zero.
llvm-svn: 131760
2011-05-20 21:50:09 +00:00
Akira Hatanaka 7c619f174a In CC_MipsO32, allocate a stack space regardless of whether the argument is
passed in register or on the stack.

llvm-svn: 131758
2011-05-20 21:39:54 +00:00
Jim Grosbach 17c1d13ee4 Fix typo.
llvm-svn: 131757
2011-05-20 21:35:39 +00:00
Jim Grosbach 83c4bb157a Add support for frame info use of the .cfi_def_cfa directive.
llvm-svn: 131756
2011-05-20 21:23:17 +00:00
Jim Grosbach 860b03b5f9 Add missing leading \t when printing .cfi_def_cfa in the asmstreamer.
llvm-svn: 131755
2011-05-20 21:22:37 +00:00
Akira Hatanaka cae19e8671 Define functions that get/set maximum call frame size.
llvm-svn: 131752
2011-05-20 20:11:17 +00:00
Rafael Espindola 652bfdb1ab adds some attributes to attribute section when cpu is "xscale"
(this is what used in Android NDK, when architecture is ARMv5)

patch by Koan-Sin Tan

llvm-svn: 131751
2011-05-20 20:10:34 +00:00
Rafael Espindola 1866808384 fixes target address tBL and tBLX and sets relocation type
of tBL/tBLX to R_ARM_THM_CALL (ARM ELF 4.7.1.6)

Patch by koan-sin tan.

llvm-svn: 131748
2011-05-20 20:01:01 +00:00
Argyrios Kyrtzidis ac8bc12cd1 Add asserts in StringRef to make sure we avoid undefined behavior:
-strlen should not be called with NULL. Also guarantee that StringRef's Length is 0 if Data is NULL.
-memcmp should not be called with NULL (even if size is 0)

Patch by Matthieu Monrocq!

llvm-svn: 131747
2011-05-20 19:24:12 +00:00
Stuart Hastings 91f1d24736 Re-commit 131641 with fixes; de-pseudoize MOVSX16rr8 and friends.
rdar://problem/8614450

llvm-svn: 131746
2011-05-20 19:04:40 +00:00
Akira Hatanaka 43407fe633 Make $fp and $ra callee-saved registers and let PrologEpilogInserter handle
saving and restoring them.

llvm-svn: 131745
2011-05-20 18:39:33 +00:00
Andrew Trick f44aadf0fd indvars: Prototyping Sign/ZeroExtend elimination without canonical IVs.
No functionality enabled by default. Use -disable-iv-rewrite.
Extended IVUsers to keep track of the phi that represents the users' IV.
Added the WidenIV transform to replace a narrow IV with a wide IV
by doing a one-for-one replacement of IV users instead of expanding the
SCEV expressions. [sz]exts are removed and truncs are inserted.

llvm-svn: 131744
2011-05-20 18:25:42 +00:00
Charles Davis 9a115a4bd2 Now that they're implemented, make the Win64 EH MCAsmStreamer methods call
super.

llvm-svn: 131743
2011-05-20 18:19:22 +00:00
Chad Rosier ad00f3d0b9 Fixed regression due to commit 131709, which disables vararg tail call optimizations on Win64
llvm-svn: 131740
2011-05-20 17:49:39 +00:00
Evan Cheng 4fcd8250ae Revert accidental commit.
llvm-svn: 131739
2011-05-20 17:38:48 +00:00
Charles Davis 24b31b6b7d "Implement" the HandlerData Win64 EH method in the base MCStreamer.
There's really nothing to implement. All this really does is swap to a
pseudo-section that later gets written to the unwind info struct. That
needs to be implemented in the object streamers.

llvm-svn: 131734
2011-05-20 16:06:22 +00:00
Benjamin Kramer 0bf26746d9 Rename the "sandybridge" subtarget to "corei7-avx", for GCC compatibility.
llvm-svn: 131730
2011-05-20 15:11:26 +00:00
Benjamin Kramer cc7a928885 Remove noisy semicolons.
llvm-svn: 131724
2011-05-20 09:20:25 +00:00
Cameron Zwarich e0a52df6e5 Fix PR9960 by teaching SimpleRegisterCoalescing::AdjustCopiesBackFrom() to preserve
the phikill flag.

llvm-svn: 131717
2011-05-20 03:54:04 +00:00
Andrew Trick b75279cbbd indvars: minor cleanup in preparation for sign/zero extend elimination.
llvm-svn: 131716
2011-05-20 03:37:48 +00:00
Akira Hatanaka fe4f9d5977 Fix bug in which nodes that write to argument registers do not get glued with the JALR node. Patch by Sasa Stankovic
llvm-svn: 131714
2011-05-20 02:30:51 +00:00
Akira Hatanaka 7489faa0c1 Remove code that creates unnecessary frame objects.
llvm-svn: 131711
2011-05-20 01:45:06 +00:00
Akira Hatanaka d738c0f7c9 Define variables and functions in MipsFunctionInfo.
This is the first of a series of patches that attempt to simplify handling of 
stack frame objects. 

llvm-svn: 131710
2011-05-20 01:17:58 +00:00
Chad Rosier 552f8c4819 Don't attempt to tail call optimize for Win64.
llvm-svn: 131709
2011-05-20 00:59:28 +00:00
Evan Cheng e8d2e9eb35 Revert r131664 and fix it in instcombine instead. rdar://9467055
llvm-svn: 131708
2011-05-20 00:54:37 +00:00
Cameron Zwarich 2af60abad8 Fix PR9955 by only attaching load memory operands to load instructions and
similarly for stores. Now "make check" passes with the MachineVerifier forced
on with the VerifyCoalescing option!

llvm-svn: 131705
2011-05-19 23:44:34 +00:00
Eli Friedman 22da799428 Add fast-isel support for zeroext and signext ret instructions on x86.
llvm-svn: 131689
2011-05-19 22:16:13 +00:00
Rafael Espindola 1edfb17bc2 Looks like OS X assemblers (including MC) don't like
foo:
bar = foo
.quad bar

Avoid producing it. Fixes PR9951.

llvm-svn: 131687
2011-05-19 22:05:56 +00:00
Rafael Espindola 8e129296fe Misc code refactorings:
* Remove unnecessary arguments now that ForceExpAbs is a method.
* Use ForceExpAbs in EmitAbsValue.

llvm-svn: 131683
2011-05-19 21:40:34 +00:00
Eric Christopher 4014e5e208 Oddly people want to use the 'r' constraint for fp constants on x86.
Fixes rdar://9218925
Fixes PR9601

llvm-svn: 131682
2011-05-19 21:33:47 +00:00
Charles Davis de745ba396 Implement the EndProlog Win64 EH method on the base MCStreamer.
llvm-svn: 131679
2011-05-19 21:24:54 +00:00
Cameron Zwarich 8b76e01c4b Fix PR9947 by placing OPFL_MemRefs on the node using memory operands rather than
the root if there is only one such node. This leaves only 2 verifier failures in
the entire test suite when running "make check".

llvm-svn: 131677
2011-05-19 21:13:30 +00:00
Eli Friedman e53a77d3a6 Fix up this test to use explicit triples (Win64 passes a different number of arguments in registers).
llvm-svn: 131676
2011-05-19 21:13:08 +00:00
Jason W Kim d0c937d4b2 This fixes one divergence between LLVM and binutils for ARM in the
text section.

Assume the following bit of annotated assembly:

.section	.data.rel.ro,"aw",%progbits
.align	2
.LAlpha:
.long	startval(GOTOFF)

.text
.align	2
.type	main,%function
.align	4

main: ;;; assume "main" starts at offset 0x20
0x0	push	{r11, lr}
0x4	movw	r0, :lower16:(.LAlpha-(.LBeta+8))
;;; ==> (.AddrOf(.LAlpha) - ((.AddrOf(.LBeta) - .AddrOf(".")) + 8)
;;; ==> (??? - ((16-4) + 8) = -20
0x8	movt	r0, :upper16:(.LAlpha-(.LBeta+8))
;;; ==> (.AddrOf(.LAlpha) - ((.AddrOf(.LBeta) - .AddrOf(".")) + 8)
;;; ==> (??? - ((16-8) + 8) = -16
0xc	... blah

.LBeta:
0x10	add	r0, pc, r0
0x14	... blah

.LGamma:
0x18	add	r1, pc, r1

Above snippet results in the following relocs in the .o file for the
first pair of movw/movt instructions

00000024 R_ARM_MOVW_PREL_NC .LAlpha
00000028 R_ARM_MOVT_PREL .LAlpha

And the encoded instructions in the .o file for main: must be

00000020 <main>:
20:	e92d4800 push	{fp, lr}
24:	e30f0fec movw	r0, #65516	; 0xffec i.e. -20
28:	e34f0ff0 movt	r0, #65520	; 0xfff0 i.e. -16

However, llc (prior to this commit) generates the following sequence

00000020 <main>:
20:	e92d4800 push	{fp, lr}
24:	e30f0fec movw	r0, #65516	; 0xffec - i.e. -20
28:	e34f0fff movt	r0, #65535	; 0xffff - i.e. -1

What has to happen in the ArmAsmBackend is that if the relocation is PC
relative, the 16 bits encoded as part of movw and movt must be both addends,
not addresses. It makes sense to encode addresses by right shifting the value
by 16, but the result is incorrect for PIC.
i.e., the right shift by 16 for movt is ONLY valid for the NON-PCRel case.

This change agrees with what GNU as does, and makes the PIC code run.

MC/ARM/elf-movt.s covers this case.

llvm-svn: 131674
2011-05-19 20:55:25 +00:00
Devang Patel 1407fb4bbe Reapply r131605. This time with a fix, which is to use NoFolder.
llvm-svn: 131673
2011-05-19 20:52:46 +00:00
Rafael Espindola 0fc5e89c82 ADD64ri32 sign extends its argument, so we need to use a R_X86_64_32S.
Fixes PR9934.

We really need to start tblgening the relocation info :-(

llvm-svn: 131669
2011-05-19 20:32:34 +00:00
Akira Hatanaka 9e6a8cca5d Align i64 arguments to 64 bit boundaries.
llvm-svn: 131668
2011-05-19 20:29:48 +00:00
Charles Davis 7e6e8951af Implement the Win64 EH prolog instruction methods on the base MCStreamer.
I had to change the API slightly to avoid overloading issues.

llvm-svn: 131666
2011-05-19 19:35:55 +00:00
Eli Friedman d2144a9fb8 Fix up the new StandardPasses to run the same scalarrepl passes as the old one.
llvm-svn: 131665
2011-05-19 19:14:54 +00:00
Evan Cheng 2b9bd38678 crc32 with 64-bit output zeros upper 32-bits. rdar://9467055
llvm-svn: 131664
2011-05-19 18:57:12 +00:00
Stuart Hastings 4a4e5a2b55 Update some currently-disabled code, preparing for eventual use.
llvm-svn: 131663
2011-05-19 18:48:20 +00:00
Akira Hatanaka 05fd5aa1d0 Increase number of available registers when target is MIPS32.
llvm-svn: 131660
2011-05-19 18:25:03 +00:00
Evan Cheng dc867ae1fc Add comment.
llvm-svn: 131659
2011-05-19 18:18:39 +00:00
Akira Hatanaka 92ab6db6c8 Simplify CC_MipsO32 and merge it with CC_MipsO32_VarArgs. Patch by Sasa Stankovic.
llvm-svn: 131657
2011-05-19 18:06:05 +00:00
Joerg Sonnenberger 74ba2623ce Reapply 131644 including the missing header changes:
Introduce -fatal-assembler-warnings for the obvious purpose

llvm-svn: 131655
2011-05-19 18:00:13 +00:00
Stuart Hastings c72240bbd9 Reverting 131641 to investigate 'bot complaint.
llvm-svn: 131654
2011-05-19 17:54:42 +00:00
Eli Friedman 3e2f17499e Revert r131644; it's breaking the build.
llvm-svn: 131653
2011-05-19 17:48:09 +00:00
Charles Davis 4cd8856704 Turns out GAS does have Win64 EH directives. (It also supports WinCE EH.) Make
ours compatible with GAS.

In retrospect, I should have emailed binutils about this earlier. Thanks to
Kai Tietz for pointing out that GAS already had SEH directives.

llvm-svn: 131652
2011-05-19 17:46:39 +00:00
Jim Grosbach eca54e4e6d 80 columns.
llvm-svn: 131649
2011-05-19 17:34:53 +00:00
Joerg Sonnenberger 59b523169f Introduce -fatal-assembler-warnings for the obvious purpose
llvm-svn: 131644
2011-05-19 17:27:01 +00:00
Akira Hatanaka d1465bd68b Fix data layout string. i64 is aligned to 64 bit boundaries.
llvm-svn: 131642
2011-05-19 17:21:09 +00:00
Stuart Hastings b476b0cc9f Revise MOVSX16rr8/MOVZX16rr8 (and rm variants) to no longer be
pseudos.  rdar://problem/8614450

llvm-svn: 131641
2011-05-19 16:59:50 +00:00
Stuart Hastings ae012a7525 Move test to Transforms/InstCombine.
llvm-svn: 131634
2011-05-19 05:53:22 +00:00
Cameron Zwarich 9eb5a410bd Use the correct register class for Cell varargs spilling. This fixes all of the
verifier failures in the CodeGen/CellSPU tests.

llvm-svn: 131631
2011-05-19 04:44:19 +00:00
Mon P Wang 6d9e1c7c2e Fixed sdiv and udiv for <4 x i16>. The test from r125402 still applies for this change.
llvm-svn: 131630
2011-05-19 04:15:07 +00:00
Charles Davis b4222589bf Implement the StartChained and EndChained Win64 EH methods on MCStreamer.
llvm-svn: 131629
2011-05-19 04:04:13 +00:00
Cameron Zwarich 41025dc95b Make CodeGen/PowerPC/2007-09-11-RegCoalescerAssert.ll pass with the verifier.
llvm-svn: 131627
2011-05-19 03:11:06 +00:00
Cameron Zwarich dadd73390f Fix PR8828 by removing the explicit def in MovePCToLR as well as the pointless
piclabel operand. The operand in the tablegen definition doesn't actually turn
into an MI operand, so it just confuses anything checking the TargetInstrDesc
for the number of operands. It suffices to just have an implicit def of LR.

llvm-svn: 131626
2011-05-19 02:56:28 +00:00
Cameron Zwarich 58eafde58b Reuse the TargetInstrDesc.
llvm-svn: 131625
2011-05-19 02:56:23 +00:00
Francois Pichet 68610c1673 Fix the MSVC build.
Use a set of overloaded functions instead of template function for CreatePassFn.

It seems that template deduction for functions type that differs only by return type doesn't work with MSVC. 

llvm-svn: 131624
2011-05-19 02:54:11 +00:00
Charles Davis d991ec4e68 Implement the StartProc and EndProc Win64 EH methods on the base MCStreamer.
Based largely on Rafael Espindola's work on CFI. Other methods soon to follow.

llvm-svn: 131623
2011-05-19 02:49:00 +00:00
Charles Davis 382c065822 Fix build issues with headers, which I discovered by actually using them.
Also, convert all the inline functions on UnwindInfo into methods.

llvm-svn: 131622
2011-05-19 02:47:23 +00:00
Rafael Espindola 3f60a0b411 Add test for PR9946.
llvm-svn: 131621
2011-05-19 02:35:26 +00:00
Rafael Espindola 964602d7ba revert 131605 to fix PR9946.
llvm-svn: 131620
2011-05-19 02:26:30 +00:00
Cameron Zwarich 00b780e280 Correctly constrain a register class when computing frame offsets, as the Thumb2
add instruction takes an rGPR. This fixes the last of PR8825.

llvm-svn: 131619
2011-05-19 02:18:27 +00:00
Cameron Zwarich fe5795a1f6 Revert r128961 because it didn't include a test and causes the verifier to fail
on CodeGen/X86/2007-05-07-InvokeSRet.ll. There is probably a bug here that was
fixed by r128961, but since there is no test or reference to a source file I have
to revert it.

llvm-svn: 131618
2011-05-19 01:56:19 +00:00
Eli Friedman 6efb64ea8e Make the demanded bits/elements optimizations preserve debug line information.
I'm not sure this is quite ideal, but I can't really think of any better way to do it.

llvm-svn: 131616
2011-05-19 01:20:42 +00:00
Jim Grosbach 13733a137c Avoid a Twine that referenced a tmp (which proceded to go out of scope before
the Twine was used).

llvm-svn: 131612
2011-05-19 00:45:05 +00:00
Devang Patel 3015a54813 Use IRBuilder.
llvm-svn: 131609
2011-05-19 00:13:33 +00:00
Rafael Espindola 5dfe17d242 Another try at fixing cmake.
llvm-svn: 131608
2011-05-19 00:13:04 +00:00
Devang Patel 31458a0002 Use IRBuilder while simplifying unreachable.
llvm-svn: 131607
2011-05-19 00:09:21 +00:00
Rafael Espindola f1bda7c90c Revert my previous patch. The cmake build had already been fixed.
llvm-svn: 131606
2011-05-19 00:02:45 +00:00
Devang Patel 4b13f39b77 Use IRBuilder while simplifying conditional branch.
llvm-svn: 131605
2011-05-18 23:59:51 +00:00
Eli Friedman 41e509a33d More instcombine cleanup, towards improving debug line info.
llvm-svn: 131604
2011-05-18 23:58:37 +00:00
Jim Grosbach 6bfca4efd8 Restore sanity to 131601.
llvm-svn: 131603
2011-05-18 23:56:43 +00:00
Rafael Espindola efbdd80d77 Fix the cmake build.
llvm-svn: 131602
2011-05-18 23:56:40 +00:00
Jim Grosbach b098471538 Objective C functions may use a magic '\1' on the name. Handle that when
dealing with them in the MCJIT.

llvm-svn: 131601
2011-05-18 23:53:21 +00:00
Eli Friedman d1b0f0f1b8 Shuffle StandardPasses.cpp into VMCore; add it to CMake.
llvm-svn: 131600
2011-05-18 23:51:11 +00:00
Devang Patel 7de6c4bf75 Use IRBuilder while simplifying branch.
llvm-svn: 131598
2011-05-18 23:18:47 +00:00
Eli Friedman 6fc94dd687 Revert unintentional commit.
llvm-svn: 131597
2011-05-18 23:13:10 +00:00
Eli Friedman 1754a25977 More instcombine simplifications towards better debug locations.
llvm-svn: 131596
2011-05-18 23:11:30 +00:00
Cameron Zwarich b9bef106c6 Add missing mayLoad / mayStore flags to instruction definitions without patterns,
which fixes all of the CodeGen/MBlaze verifier failures.

llvm-svn: 131595
2011-05-18 23:03:10 +00:00
Charles Davis bd5a09d3b2 Add a header patterned after MCDwarf.h for supporting Win64 exception handling
under MC.

llvm-svn: 131593
2011-05-18 22:48:24 +00:00
David Chisnall cb2c7d9186 Some better type safety enforcement in the standard pass list, along with some small tidies and some fixes for bugs that the stricter checking found.
llvm-svn: 131592
2011-05-18 22:46:02 +00:00
Cameron Zwarich 9ddeceff19 Reserve the segment registers on x86 to fix verifier failures in any code that
uses them.

llvm-svn: 131591
2011-05-18 22:24:48 +00:00
Charles Davis 27117af772 Remove comments as Chris requested.
llvm-svn: 131590
2011-05-18 22:13:51 +00:00
Cameron Zwarich 8b2e426555 Reserve r29 on Alpha. This fixes all verifier failures in CodeGen/Alpha.
llvm-svn: 131587
2011-05-18 21:54:32 +00:00
Tanya Lattner 1d11720ae4 Handle perfect shuffle case that generates a vrev for vectors of floats.
Add test case.

llvm-svn: 131582
2011-05-18 21:44:54 +00:00
Eli Friedman fadb03d6cc Third pass at allowing plugins to modify default passes. This time with a tweak so that we don't depend on an uninitialized argument.
llvm-svn: 131581
2011-05-18 21:40:04 +00:00
Devang Patel dd14e0f7fa Use IRBuilder while simplifying return instruction.
llvm-svn: 131580
2011-05-18 21:33:11 +00:00
Cameron Zwarich 492f87de4e Fix an obvious typo in r131572.
llvm-svn: 131579
2011-05-18 21:29:07 +00:00
Cameron Zwarich ec645bf75d Fix more of PR8825. Now all of CodeGen/ARM passes with VerifyCoalescing turned on.
llvm-svn: 131578
2011-05-18 21:25:14 +00:00
Dan Gohman 3268e4d692 When forming an ICmpZero LSRUse, normalize the non-IV operand
of the comparison, so that the resulting expression is fully
normalized. This fixes PR9939.

llvm-svn: 131576
2011-05-18 21:02:18 +00:00
Devang Patel 699c973391 Set debug location while setting insertion point.
llvm-svn: 131575
2011-05-18 20:58:47 +00:00
Charles Davis 77e0610d7c Add some more Win64 EH directives:
- StartChained and EndChained delimit a chained unwind area, which can contain
  additional operations to be undone if an exception occurs inside of it.
- UnwindOnly declares that this function doesn't handle any exceptions. If it
  has a handler, it's an unwind handler instead of an exception handler.
- Lsda declares the location and size of the LSDA, which in the Win64 EH
  scheme is kept inside the UNWIND_INFO struct. Windows itself ignores the
  LSDA; it's used by the Language-Specific Handler (the "Personality Function"
  from DWARF).

llvm-svn: 131572
2011-05-18 20:54:10 +00:00
Devang Patel 583805530c Spread use of IRBuilder even more.
llvm-svn: 131571
2011-05-18 20:53:17 +00:00
Eli Friedman 65816ac54d Revert r131556; it's breaking buildbots/clang tests.
llvm-svn: 131567
2011-05-18 20:39:27 +00:00
Devang Patel a7ec47d23c Use IRBuilder while simplifying switch instruction.
llvm-svn: 131566
2011-05-18 20:35:38 +00:00
Johnny Chen 071634612d Disassembly of tBcc was wrongly adding 4 to the SignExtend'ed imm8:'0' immediate operand.
llvm-svn: 131565
2011-05-18 20:32:41 +00:00
Devang Patel 0b373dca1f Use IRBuilder while simplifying unwind.
llvm-svn: 131561
2011-05-18 20:01:18 +00:00
Chad Rosier f4e832b14e Enables vararg functions that pass all arguments via registers to be optimized into tail-calls when possible.
llvm-svn: 131560
2011-05-18 19:59:50 +00:00
Eli Friedman 49346010f8 More instcombine cleanup aimed towards improving debug line info.
llvm-svn: 131559
2011-05-18 19:57:14 +00:00
Stuart Hastings 51d696766c An imminent fix to the x86_64 byval logic will expose a flaw in the
x86_64 sibcall logic.  I've filed PR9943 for the sibcall problem, and
this patch alters the testcase to work around the flaw.  When PR9943
is fixed, this patch should be reverted.

llvm-svn: 131557
2011-05-18 19:19:17 +00:00
David Chisnall 13c90786e1 Second pass at allowing plugins to modify default passes. This time without bonus inter-library dependencies.
llvm-svn: 131556
2011-05-18 19:00:41 +00:00
Evan Cheng 522fbfea3b Revise r131553. Just use the type of the input node and forgo the bitcast. rdar://9449159.
llvm-svn: 131555
2011-05-18 18:59:17 +00:00
Evan Cheng 80632c91b0 Fix an ARMTargetLowering::LowerSELECT bug: legalized result must have same type as input. Sorry test cases only trigger when dag combine is disabled. rdar://9449178
llvm-svn: 131553
2011-05-18 18:47:27 +00:00
Devang Patel 2c2ea226b7 Use IRBuilder while simplifying terminator.
llvm-svn: 131552
2011-05-18 18:43:31 +00:00
Devang Patel 767f6930bc Use IRBuilder while simplifying unconditional branch.
llvm-svn: 131551
2011-05-18 18:28:48 +00:00
Devang Patel 5c810ce4a3 Use IRBuilder while folding two entry PHINode.
llvm-svn: 131548
2011-05-18 18:16:44 +00:00
Eli Friedman 2fd66441c6 Switch more inst insertion in instcombine to IRBuilder.
llvm-svn: 131547
2011-05-18 18:10:28 +00:00
Chad Rosier 38fb5bbacc Correct typos in TestingGuide.html
llvm-svn: 131546
2011-05-18 18:07:16 +00:00
Devang Patel 15ad6761da Set up IRBuilder for use during simplification.
llvm-svn: 131545
2011-05-18 18:01:27 +00:00
Eli Friedman 0b43b9ee98 Switch more inst insertion in instcombine to IRBuilder.
llvm-svn: 131544
2011-05-18 17:58:37 +00:00
Matt Beaumont-Gay 8fa6ebf975 fix typo
llvm-svn: 131543
2011-05-18 17:37:10 +00:00
Eli Friedman cde9c1628c Switch inst insertion in instcombine transform to IRBuilder.
llvm-svn: 131542
2011-05-18 17:31:55 +00:00
Devang Patel 1fabbe921b Use IRBuiler while constant folding terminator.
llvm-svn: 131541
2011-05-18 17:26:46 +00:00
Eli Friedman 3f46c3e702 Force a triple on a couple of tests; we don't support fast-isel of ret on Win64.
llvm-svn: 131540
2011-05-18 17:16:37 +00:00
Stuart Hastings 38849debb5 Merge pmovzx test case into existing file.
llvm-svn: 131539
2011-05-18 17:02:04 +00:00
Stuart Hastings 728f6260b9 Fix inelegant initialization.
llvm-svn: 131538
2011-05-18 15:54:26 +00:00
Justin Holewinski bbdcd17d44 PTX: add flag to disable mad/fma selection
Patch by Dan Bailey

llvm-svn: 131537
2011-05-18 15:42:23 +00:00
Duncan Sands 3d9407f4eb Revert commit 131534 since it seems to have broken several buildbots.
Original log entry:
Refactor getActionType and getTypeToTransformTo ; place all of the 'decision'
code in one place.

llvm-svn: 131536
2011-05-18 14:57:56 +00:00
Nadav Rotem c5c27ede55 Refactor getActionType and getTypeToTransformTo ; place all of the 'decision'
code in one place.

llvm-svn: 131534
2011-05-18 12:26:38 +00:00
Duncan Sands 27bd0df352 Now that SrcBits and DestBits always represent the primitive size, rather
than either the primitive size or the element primitive size (in the case
of vectors), simplify the vector logic.  No functionality change.  There
is some distracting churn in the patch because I lined up comments better
while there - sorry about that.

llvm-svn: 131533
2011-05-18 10:59:25 +00:00
Duncan Sands 7f64656d21 Tighten up checking of the validity of casts. (1) The IR parser would
happily accept things like "sext <2 x i32> to <999 x i64>".  It would
also accept "sext <2 x i32> to i64", though the verifier would catch
that later.  Fixed by having castIsValid check that vector lengths match
except when doing a bitcast.  (2) When creating a cast instruction, check
that the cast is valid (this was already done when creating constexpr
casts).  While there, replace getScalarSizeInBits (used to allow more
vector casts) with getPrimitiveSizeInBits in getCastOpcode and isCastable
since vector to vector casts are now handled explicitly by passing to the
element types; i.e. this bit should result in no functional change.

llvm-svn: 131532
2011-05-18 09:21:57 +00:00
Duncan Sands a8514535a4 Teach getCastOpcode about element-by-element vector casts. For example, "trunc"
can be used to turn a <4 x i64> into a <4 x i32> but getCastOpcode would assert
if you passed these types to it.  Note that this strictly extends the previous
functionality: if getCastOpcode previously accepted two vector types (i.e. didn't
assert) then it still will and returns the same opcode (BitCast).  That's because
before it would only accept vectors with the same bitwidth, and the new code only
touches vectors with the same length.  However if two vectors have both the same
bitwidth and the same length then their element types have the same bitwidth, so
the new logic will return BitCast as before.

llvm-svn: 131530
2011-05-18 07:13:41 +00:00
Tanya Lattner 48b182c3a4 In r131488 I misunderstood how VREV works. It splits the vector in half and splits each half. Therefore, the real problem was that we were using a VREV64 for a 4xi16, when we should have been using a VREV32.
Updated test case and reverted change to the PerfectShuffle Table.

llvm-svn: 131529
2011-05-18 06:42:21 +00:00
Charles Davis 8d9c99042f Implement the Win64 EH directive methods for the assembly language streamer.
GAS has no such directives (not even mingw-w64 GAS has them), so I took
creative license with their names in assembly. I prefixed them all with
"w64_" to avoid namespace collisions, for example. If I discover that GAS
has taken a different approach, I'll change ours to match.

llvm-svn: 131525
2011-05-18 04:58:05 +00:00
Jakob Stoklund Olesen 07b5c276f4 Eliminate dead dead code elimination code.
llvm-svn: 131524
2011-05-18 04:51:15 +00:00
Jakob Stoklund Olesen f3dc225972 Also use shrinkToUses after AdjustCopiesBackFrom().
The 'last use' may not be in the same basic block, and we still want a correct
live range.

llvm-svn: 131523
2011-05-18 04:51:12 +00:00
Charles Davis 384041d0dc While thinking about how to know where the functions' boundaries are for
the purposes of the Win64 EH tables, I realized we had no way to tell where
the function ends. (MASM bounds functions with PROC and ENDP keywords.)
Add a directive to delimit the end of the function, and rename the 'frame'
directive to more accurately reflect its duality with the new directive.

llvm-svn: 131522
2011-05-18 04:47:22 +00:00
Jakob Stoklund Olesen 595a47d462 Properly shrink live ranges after deleting dead copies. Clean up after all joined copies.
LiveInterval::shrinkToUses recomputes the live range from scratch instead of
removing snippets. This should avoid the problem with dangling live ranges.

Leave physreg identity copies alone. They can be created when joining a virtreg
with a physreg. They don't affect register allocation, and they will be removed
by the rewriter.

llvm-svn: 131521
2011-05-18 04:18:19 +00:00
Cameron Zwarich f9839e4257 Fix typo.
llvm-svn: 131519
2011-05-18 02:29:50 +00:00
Cameron Zwarich d7c55fe2ef Fix more of PR8825 by correctly using rGPR registers when lowering atomic
compare-and-swap intrinsics.

llvm-svn: 131518
2011-05-18 02:20:07 +00:00
Eli Friedman 96254a0d53 Start trying to make InstCombine preserve more debug info. The idea here is to set the debug location on the IRBuilder, which will be then right location in most cases. This should magically give many transformations debug locations, and fixing places which are missing a debug location will usually just means changing the code creating it to use the IRBuilder.
As an example, the change to InstCombineCalls catches a common case where a call to a bitcast of a function is rewritten.

Chris, does this approach look reasonable?

llvm-svn: 131516
2011-05-18 01:28:27 +00:00
Eli Friedman b9ed18f2cb Use ReplaceInstUsesWith instead of replaceAllUsesWith where appropriate in instcombine.
llvm-svn: 131512
2011-05-18 00:32:01 +00:00
Eli Friedman 7d7ad8374f Make some of the fast-isel tests actually test fast-isel (and fix test failures).
llvm-svn: 131510
2011-05-18 00:00:10 +00:00
Devang Patel b849cd511b Preseve line numbers while simplifying CFG.
llvm-svn: 131508
2011-05-17 23:29:05 +00:00
Cameron Zwarich 33a67ddbd2 Actually, the address operand of the Thumb2 LDREX / STREX instructions *can*
take r13, so we can just make it a GPR. This fixes PR8825.

llvm-svn: 131507
2011-05-17 23:26:20 +00:00
Cameron Zwarich c5d272766f Correct a minor problem with the Thumb2 LDREX and STREX instruction encodings. They
were marked as taking a tGPR when in reality they take an rGPR.

llvm-svn: 131506
2011-05-17 23:11:12 +00:00
Bill Wendling 0671ba8448 Conditionalize the format of the GCOV files by target type. Darwin uses the 4.2
format.

llvm-svn: 131503
2011-05-17 23:05:13 +00:00
Eli Friedman e9692808b7 Make fast-isel miss counting in -stats and -fast-isel-verbose take terminators into account; since there are many fewer isel misses with recent changes, misses caused by terminators are more significant.
llvm-svn: 131502
2011-05-17 23:02:10 +00:00
Dan Gohman abffc991dc Misc. code cleanups.
llvm-svn: 131497
2011-05-17 22:22:52 +00:00
Dan Gohman 4298df6d86 Misc. code cleanups.
llvm-svn: 131495
2011-05-17 22:20:36 +00:00
Stuart Hastings 5bd18b6638 X86 pmovsx/pmovzx ignore the upper half of their inputs.
rdar://problem/6945110

llvm-svn: 131493
2011-05-17 22:13:31 +00:00
Tanya Lattner c7e291b354 vrev is incorrectly defined in the perfect shuffle table. The ordering is backwards (should be 0x3210 versus 0x1032) which exposed a bug when doing a shuffle on a 4xi16. I've attached a test case.
llvm-svn: 131488
2011-05-17 20:48:40 +00:00
Devang Patel 341b38c22a Preserve line number information.
llvm-svn: 131482
2011-05-17 20:00:02 +00:00
Devang Patel c5933f2418 Set debug loc for new load instruction.
llvm-svn: 131481
2011-05-17 19:43:38 +00:00
Devang Patel c23bcbc498 Preserve line number information.
llvm-svn: 131480
2011-05-17 19:43:06 +00:00
Galina Kistanova dd45646a47 Move test for appropriate directory.
llvm-svn: 131477
2011-05-17 19:06:43 +00:00
Mon P Wang 6f6b44d19d Enable autodetect of popcnt
llvm-svn: 131476
2011-05-17 18:33:37 +00:00
Jim Grosbach 4f51873f22 Frame indices are signed. Update MachineOperand methods accordingly.
llvm-svn: 131475
2011-05-17 18:29:21 +00:00
Eli Friedman 7b27942fe7 Add x86 fast-isel for calls returning first-class aggregates. rdar://9435872.
This is r131438 with a couple small fixes.

llvm-svn: 131474
2011-05-17 18:29:03 +00:00
Eli Friedman d000a2c26e Clean up the mess created by r131467+r131469.
llvm-svn: 131471
2011-05-17 18:02:22 +00:00
Stuart Hastings c65d8eda7b Revert 131467 due to buildbot complaint.
llvm-svn: 131469
2011-05-17 16:59:46 +00:00
Stuart Hastings 3cf5308890 Fix an obscure issue in X86_64 parameter passing: if a tiny byval is
passed as the fifth parameter, insure it's passed correctly (in R9).
rdar://problem/6920088

llvm-svn: 131467
2011-05-17 16:45:55 +00:00
Jakob Stoklund Olesen 52375e6a01 Tweak cross-class coalescing to be more aggressive when the target class is small.
The greedy register allocator has live range splitting and register class
inflation, so it can actually fully undo this join, including restoring the
original register classes.

We still don't want to do this for long live ranges, mostly because of the high
register pressure of there are many constrained live ranges overlapping.

llvm-svn: 131466
2011-05-17 16:38:37 +00:00
Rafael Espindola 0693182265 Don't include information about the build into the information returned by
getHostTriple. This fixes a 32 bit clang running on a 64 bit ubuntu.

llvm-svn: 131463
2011-05-17 15:26:34 +00:00
Nadav Rotem d8edb1d5cc Fix a bug in PerformEXTRACT_VECTOR_ELTCombine. The code created an ADD SDNode
with two different types, in cases where the index and the ptr had different
types.

llvm-svn: 131461
2011-05-17 08:31:57 +00:00
Eric Christopher 56a42ebf15 Update comment.
llvm-svn: 131459
2011-05-17 08:16:14 +00:00
Eric Christopher a1d9e29552 Support XOR and AND optimization with no return value.
Finishes off rdar://8470697

llvm-svn: 131458
2011-05-17 08:10:18 +00:00
Eric Christopher abfe3131e3 Couple less magic numbers.
llvm-svn: 131457
2011-05-17 07:50:41 +00:00
Eric Christopher eb47a2a1e5 Make this code a little less magic number laden.
llvm-svn: 131456
2011-05-17 07:47:55 +00:00
Chris Lattner 1e81f57bf0 add a note
llvm-svn: 131455
2011-05-17 07:22:33 +00:00
Stuart Hastings a7ae4552af Drop lli, revise test.
llvm-svn: 131452
2011-05-17 02:38:59 +00:00
Eli Friedman 7335e8a720 Back out r131444 and r131438; they're breaking nightly tests. I'll look into
it more tomorrow.

llvm-svn: 131451
2011-05-17 02:36:59 +00:00
Eli Friedman e5f7f26df0 Fix test.
llvm-svn: 131444
2011-05-17 00:39:14 +00:00
Evan Cheng 54459240e3 Add target triple so test doesn't fail on Windows machines.
llvm-svn: 131439
2011-05-17 00:15:58 +00:00
Eli Friedman 83ba150f3a Add x86 fast-isel for calls returning first-class aggregates. rdar://9435872.
llvm-svn: 131438
2011-05-17 00:13:47 +00:00
Owen Anderson 97f0cf32ea @llvm.lifetime.begin acts as a load, not @llvm.lifetime.end.
llvm-svn: 131437
2011-05-17 00:05:49 +00:00
Jakob Stoklund Olesen 4edf17d91f Teach LiveInterval::isZeroLength about null SlotIndexes.
When instructions are deleted, they leave tombstone SlotIndex entries.
The isZeroLength method should ignore these null indexes.

This causes RABasic to sometimes spill a callee-saved register in the
abi-isel.ll test, so don't run that test with -regalloc=basic.  Prioritizing
register allocation according to spill weight can cause more registers to be
used.

llvm-svn: 131436
2011-05-16 23:50:05 +00:00
Jim Grosbach 4e983166bc Kill some dead code.
llvm-svn: 131431
2011-05-16 22:24:07 +00:00
Dan Gohman d282f46c6b Delete unused variables.
llvm-svn: 131430
2011-05-16 22:19:54 +00:00
Dan Gohman d4d12d14b5 Trim #includes.
llvm-svn: 131429
2011-05-16 22:14:50 +00:00
Dan Gohman ae9b1685a8 Fix whitespace and 80-column violations.
llvm-svn: 131428
2011-05-16 22:09:53 +00:00
Devang Patel a0b682db62 There is no need to force DebugLoc on a PHI at this point.
llvm-svn: 131427
2011-05-16 22:05:03 +00:00
Jim Grosbach e85c0dde7a Track how many insns fast-isel successfully selects as well as how many it
misses.

llvm-svn: 131426
2011-05-16 21:51:07 +00:00
Eli Friedman d4a3609d30 Remove dead code. Fix associated test to use FileCheck.
llvm-svn: 131424
2011-05-16 21:28:22 +00:00
Devang Patel 8e60ff11db Preserve debug info for unused zero extended boolean argument.
Radar 9422775.

llvm-svn: 131422
2011-05-16 21:24:05 +00:00
Charles Davis 2701815ed8 Add a method I forgot in the last commit. Don't worry, this one passed
self-host :).

llvm-svn: 131421
2011-05-16 21:13:58 +00:00
Eli Friedman a4d4a0162d Make fast-isel work correctly s/uadd.with.overflow intrinsics.
llvm-svn: 131420
2011-05-16 21:06:17 +00:00
Eli Friedman 4c08bb450a Fix silly typo.
llvm-svn: 131419
2011-05-16 20:34:53 +00:00
Eli Friedman 9ac944774f Basic fast-isel of extractvalue. Not too helpful on its own, given the IR clang generates for cases like this, but it should become more useful soon.
llvm-svn: 131417
2011-05-16 20:27:46 +00:00
Nick Lewycky 9c876bf937 Fix errors in this llvm ir example.
llvm-svn: 131416
2011-05-16 19:29:30 +00:00
Jason W Kim 94c31fdd31 Add a FIXME reminder to remove ForceARMElfPIC switch.
llvm-svn: 131411
2011-05-16 16:35:21 +00:00
Rafael Espindola e90c1cb221 sets bit 0 of the function address of thumb function in .symtab
("T is 1 if the target symbol S has type STT_FUNC and the
symbol addresses a Thumb instruction ;it is 0 otherwise."
from "ELF for the ARM Architecture" 4.7.1.2)

Patch by Koan-Sin Tan!

llvm-svn: 131406
2011-05-16 16:17:21 +00:00
Rafael Espindola 71f8b08a80 Extra refactoring noticed by Eli Friedman.
llvm-svn: 131405
2011-05-16 15:48:45 +00:00
Zhongxing Xu 56cf054a35 Remove redundant template partial specilization.
llvm-svn: 131402
2011-05-16 12:42:22 +00:00
Rafael Espindola 2050af838d Don't do tail calls in a function that call setjmp. The stack might be
corrupted when setjmp returns again.

llvm-svn: 131399
2011-05-16 03:05:33 +00:00
Charles Davis 2f10078ae7 Fix copy-pasto.
llvm-svn: 131384
2011-05-15 17:28:27 +00:00
Charles Davis af18d07ed6 Add stub methods to MCStreamer for emitting Win64 exception-handling
information.

llvm-svn: 131382
2011-05-15 17:20:01 +00:00
Charles Davis 757aa983dd Get rid of extern "C" from the Win64 EH header.
llvm-svn: 131381
2011-05-15 17:09:26 +00:00
Charles Davis 215b92d24b Add a header containing definitions used to implement Win64 exception handling.
llvm-svn: 131380
2011-05-15 14:42:22 +00:00
Nick Lewycky 0db2654023 Declare this function here so that it doesn't get C++ mangling.
llvm-svn: 131379
2011-05-15 07:20:34 +00:00