Commit Graph

6912 Commits

Author SHA1 Message Date
Owen Anderson 4486c1fac0 Remove the "fast" cases for spill and restore point determination, as these were subtlely wrong in obscure cases. Patch the testcase
to account for this change.

llvm-svn: 68093
2009-03-31 08:27:09 +00:00
Bill Wendling c4b08e5eb0 Revert r68073. It's causing a failure in the Apple-style builds.
llvm-svn: 68092
2009-03-31 08:26:26 +00:00
Dan Gohman 97a20b8dbf Fix live-out reg logic to not insert over-aggressive AssertZExt
instructions. This fixes lua.

llvm-svn: 68083
2009-03-31 01:38:29 +00:00
Evan Cheng 09f5be8146 Turn a 2-address instruction into a 3-address one when it's profitable even if the two-address operand is killed.
e.g.
%reg1024<def> = MOV r1
%reg1025<def> = ADD %reg1024, %reg1026
r0            = MOV %reg1025

If it's not possible / profitable to commute ADD, then turning ADD into a LEA saves a copy.

llvm-svn: 68065
2009-03-30 21:34:07 +00:00
Bill Wendling 2f52e6488f Balance out quote in debug output.
llvm-svn: 68059
2009-03-30 20:32:22 +00:00
Bill Wendling 5f0d97c571 Fix grammar-o in comment.
llvm-svn: 68057
2009-03-30 20:30:02 +00:00
Dan Gohman ff62c62b7c Constify arguments in isSuccessor and isLayoutSuccessor.
llvm-svn: 68054
2009-03-30 20:06:29 +00:00
Duncan Sands d21581eaa1 Fix PR3899: add support for extracting floats from vectors
when using -soft-float.
Based on a patch by Jakob Stoklund Olesen.

llvm-svn: 67996
2009-03-29 13:51:06 +00:00
Arnold Schwaighofer e622cbf385 Make check in CheckTailCallReturnConstraints for ignorable instructions between
a CALL and a RET node more generic. Add a test for tail calls with a void
return.

llvm-svn: 67943
2009-03-28 12:36:29 +00:00
Arnold Schwaighofer 83d5420d02 Enable tail call optimization for functions that return a struct (bug 3664) and for functions that return types that need extending (e.g i1).
llvm-svn: 67934
2009-03-28 08:33:27 +00:00
Evan Cheng fd81c73cde Optimize some 64-bit multiplication by constants into two lea's or one lea + shl since imulq is slow (latency 5). e.g.
x * 40
=>
shlq    $3, %rdi
leaq    (%rdi,%rdi,4), %rax

This has the added benefit of allowing more multiply to be folded into addressing mode. e.g.
a * 24 + b
=>
leaq    (%rdi,%rdi,2), %rax
leaq    (%rsi,%rax,8), %rax

llvm-svn: 67917
2009-03-28 05:57:29 +00:00
Dan Gohman 2785e4be37 Fix what surely must be a copy+pasto.
llvm-svn: 67881
2009-03-27 23:55:04 +00:00
Dan Gohman 6d75876473 Initialize LiveOutInfo's APInt members to zero, as APInt's
default constructor produces an uninitialized APInt.
This fixes PR3896.

llvm-svn: 67879
2009-03-27 23:51:02 +00:00
John Mosby a1be2dcd63 Shrink wrapping in PEI: initial release. Finishing development, enable with --shrink-wrap.
llvm-svn: 67828
2009-03-27 06:09:40 +00:00
Owen Anderson 76a561f35e Don't assign a new stack slot if the pre-alloc splitter already assigned one.
llvm-svn: 67764
2009-03-26 18:53:38 +00:00
Bill Wendling aa28be652c Pull transform from target-dependent code into target-independent code.
llvm-svn: 67742
2009-03-26 06:14:09 +00:00
Evan Cheng 2e9f42bed5 Revert 67132. This is breaking some objective-c apps.
Also fixes SDISel so it *does not* force promote return value if the function is not marked signext / zeroext.

llvm-svn: 67701
2009-03-25 20:20:11 +00:00
Dale Johannesen eb1646d28c When optimizing with debug info, don't keep the
stoppoint nodes around until Legalize; doing this
imposed an ordering on a sequence of loads that
came from different lines, interfering with scheduling.

llvm-svn: 67692
2009-03-25 17:36:08 +00:00
Evan Cheng 5e5a63cf8f CodeGen still defaults to non-verbose asm, but llc now overrides it and default to verbose.
llvm-svn: 67668
2009-03-25 01:47:28 +00:00
Devang Patel a6e85a19c6 Do not ignore DW_TAG_class_type!
llvm-svn: 67661
2009-03-25 00:28:40 +00:00
Evan Cheng f413a88839 Fix PR3845: Avoid stale MachineInstruction pointer reference.
llvm-svn: 67649
2009-03-24 20:33:17 +00:00
Chris Lattner c35847e109 more tidying: name the components of PhysReg in the case when
the target constraint specifies a specific physreg.

llvm-svn: 67618
2009-03-24 15:27:37 +00:00
Chris Lattner 42eceb3491 Tidy a bit more.
llvm-svn: 67617
2009-03-24 15:25:07 +00:00
Chris Lattner 246eda43bd simplify this code a bit now that "allocation to a vreg class" can never
fail.

llvm-svn: 67616
2009-03-24 15:22:11 +00:00
Dan Gohman f3746cbc56 Minor compile-time optimization; don't bother checking
canClobberPhysRegDefs if the successor node doesn't
clobber any physical registers.

llvm-svn: 67587
2009-03-24 00:50:07 +00:00
Dan Gohman 9a658d72db Add a pre-pass to the burr-list scheduler which makes adjustments to
help out the register pressure reduction heuristics in the case of
nodes with multiple uses. Currently this uses very conservative
heuristics, so it doesn't have a broad impact, but in cases where it
does help it can make a big difference.

llvm-svn: 67586
2009-03-24 00:49:12 +00:00
Evan Cheng a774a99245 Do not emit comments unless -asm-verbose.
llvm-svn: 67580
2009-03-24 00:17:40 +00:00
Evan Cheng 7fe1b0f50f Fix a bug in spill weight computation. If the alias is a super-register, and the super-register is in the register class we are trying to allocate. Then add the weight to all sub-registers of the super-register even if they are not aliases.
e.g. allocating for GR32, bh is not used, updating bl spill weight.                                                                                                        
     bl should get the same spill weight otherwise it will be choosen                                                                                              
     as a spill candidate since spilling bh doesn't make ebx available.
This fix PR2866.

llvm-svn: 67574
2009-03-23 22:57:19 +00:00
Dale Johannesen 93eefa0043 Fix internal representation of fp80 to be the
same as a normal i80 {low64, high16} rather
than its own {high64, low16}.  A depressing number
of places know about this; I think I got them all.
Bitcode readers and writers convert back to the old
form to avoid breaking compatibility.

llvm-svn: 67562
2009-03-23 21:16:53 +00:00
Dan Gohman ed0e8d44ce When unfolding a load during scheduling, the new operator node has
a data dependency on the load node, so it really needs a
data-dependence edge to the load node, even if the load previously
existed.

And add a few comments.

llvm-svn: 67554
2009-03-23 20:20:43 +00:00
Evan Cheng f858466018 Fix PR3391 and PR3864. Reg allocator infinite looping.
llvm-svn: 67544
2009-03-23 18:24:37 +00:00
Dan Gohman f477262e69 Don't set SUnit::hasPhysRegDefs to true unless the defs are
actually have uses, which reflects the way it's used.

llvm-svn: 67540
2009-03-23 17:39:36 +00:00
Dan Gohman a366da1bf7 Fix canClobberPhysRegDefs to check all SDNodes grouped together
in an SUnit, instead of just the first one. This fix is needed
by some upcoming scheduler changes.

llvm-svn: 67531
2009-03-23 16:23:01 +00:00
Dan Gohman 52c278e54d Add a new bit to SUnit to record whether a node has implicit physreg
defs, regardless of whether they are actually used.

llvm-svn: 67528
2009-03-23 16:10:52 +00:00
Dan Gohman 4f2fea1a21 Now that errs() is properly non-buffered, there's no need to
explicitly flush it.

llvm-svn: 67526
2009-03-23 15:57:19 +00:00
Evan Cheng 968c3b0d6e Model inline asm constraint which ties an input to an output register as machine operand TIED_TO constraint. This eliminated the need to pre-allocate registers for these. This also allows register allocator can eliminate the unneeded copies.
llvm-svn: 67512
2009-03-23 08:01:15 +00:00
Evan Cheng 47c9750f04 Do not fold away subreg_to_reg if the source register has a sub-register index. That means the source register is taking a sub-register of a larger register. e.g. On x86
%RAX<def> = ...
%RAX<def> = SUBREG_TO_REG 0, %EAX:3<kill>, 3
The first def is defining RAX, not EAX so the top bits were not zero-extended.

llvm-svn: 67511
2009-03-23 07:19:58 +00:00
Dan Gohman 3bdc4bdba6 Simplify this code; use a while instead of an if and a do-while.
llvm-svn: 67400
2009-03-20 20:42:23 +00:00
Evan Cheng 2e55923fba For inline asm output operand that matches an input. Encode the input operand index in the high bits.
llvm-svn: 67387
2009-03-20 18:03:34 +00:00
Sanjiv Gupta 83debdf4b4 Fixed build warnings for unused variables.
llvm-svn: 67372
2009-03-20 13:49:20 +00:00
Sanjiv Gupta e9759c458c Fixed the comment. No functionality change.
llvm-svn: 67370
2009-03-20 09:38:50 +00:00
Chris Lattner f0db9b6321 Apply the patch requested in PR3846.
llvm-svn: 67364
2009-03-20 05:08:24 +00:00
Sebastian Redl 8d5baa09f8 Fix the Win32 VS2008 build:
- Make type declarations match the struct/class keyword of the definition.
 - Move AddSignalHandler into the namespace where it belongs.
 - Correctly call functions from template base.
 - Some other small changes.
With this patch, LLVM and Clang should build properly and with far less noise under VS2008.

llvm-svn: 67347
2009-03-19 23:26:52 +00:00
Evan Cheng 1361cbbb0b Added MachineInstr::isRegTiedToDefOperand to check for two-addressness.
llvm-svn: 67335
2009-03-19 20:30:06 +00:00
Chris Lattner 58bd3dccf9 Fix PEI to not walk off the start of a block when an updated instruction
is the first in its block.  This is PR3842.

llvm-svn: 67304
2009-03-19 17:15:43 +00:00
Mon P Wang 32c8074be6 Added missing support for widening when splitting an unary op (PR3683)
and expanding a bit convert (PR3711).  In both cases, we extract the
valid part of the widen vector and then do the conversion.

llvm-svn: 67175
2009-03-18 06:24:04 +00:00
Rafael Espindola 4606b12108 Don't force promotion of return arguments on the callee.
Some architectures (like x86) don't require it.
This fixes bug 3779.

llvm-svn: 67132
2009-03-17 23:43:59 +00:00
Chris Lattner 2363d0b8b9 Fix codegen to compute the size of an allocation by multiplying the
size by the array amount as an i32 value instead of promoting from
i32 to i64 then doing the multiply.  Not doing this broke wrap-around
assumptions that the optimizers (validly) made.  The ultimate real
fix for this is to introduce i64 version of alloca and remove mallocinst.

This fixes PR3829

llvm-svn: 67093
2009-03-17 19:36:00 +00:00
Sanjiv Gupta 88e15b258f r66870 missed this out.
llvm-svn: 67082
2009-03-17 15:46:15 +00:00
Duncan Sands fb5c74ef4b Reapply r67049, with the test adjusted for darwin
(which produces "call L_f$stub" rather than "call f").

llvm-svn: 67079
2009-03-17 09:46:22 +00:00
Mon P Wang 523c0852c6 Fix a problem with DAGCombine where we were building an illegal build
vector shuffle mask. Forced the mask to be built using i32.  Note: this will
be irrelevant once vector_shuffle no longer takes a build vector for the
shuffle mask.

llvm-svn: 67076
2009-03-17 06:33:10 +00:00
Evan Cheng 76f1b47ec9 Spiller may unfold load / mod / store instructions as an optimization when the would be loaded value is available in a register. It needs to check if it's legal to clobber the register. Also, the register can contain values of multiple spill slots, make sure to check all instead of just the one being unfolded.
llvm-svn: 67068
2009-03-17 01:23:09 +00:00
Bill Wendling dadaf54e09 --- Reverse-merging (from foreign repository) r67049 into '.':
U    test/CodeGen/X86/2009-03-13-PHIElimBug.ll
D    test/CodeGen/X86/2009-03-16-PHIElimInLPad.ll
U    lib/CodeGen/PHIElimination.cpp

r67049 was causing this failure:

Running /Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvm.src/test/CodeGen/X86/dg.exp ...
FAIL: /Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvm.src/test/CodeGen/X86/2009-03-13-PHIElimBug.ll for PR3784
Failed with exit(1) at line 1
while running:  llvm-as < /Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvm.src/test/CodeGen/X86/2009-03-13-PHIElimBug.ll |  llc -march=x86 | /usr/bin/grep -A 2 {call f} | /usr/bin/grep movl
child process exited abnormally

llvm-svn: 67051
2009-03-16 20:27:20 +00:00
Duncan Sands d3e07c9d09 Tweak the fix for PR3784: be less sensitive about just
how invokes are set up.  The fix could be disturbed by
register copies coming after the EH_LABEL, and also didn't
behave quite right when it was the invoke result that
was used in a phi node.  Also (see new testcase) fix
another phi elimination bug while there: register copies
in the landing pad need to come after the EH_LABEL, because
that's where execution branches to when unwinding.  If they
come before the EH_LABEL then they will never be executed...
Also tweak the original testcase so it doesn't use a no-longer
existing counter.
The accumulated phi elimination changes fix two of seven Ada
testsuite failures that turned up after landing pad critical
edge splitting was turned off.  So there's probably more to come.

llvm-svn: 67049
2009-03-16 19:58:38 +00:00
Owen Anderson 0422efc994 Give the pre-alloc splitter access to the VirtRegMap. It doesn't do anything
useful with it at the moment, but it will in the future.

llvm-svn: 67012
2009-03-14 21:40:05 +00:00
Daniel Dunbar f24f26c75a Add newlines at end of file (this can annoy gcov)
llvm-svn: 67000
2009-03-14 01:53:05 +00:00
Mon P Wang c86715631c Avoid doing the transformation c ? 1.0 : 2.0 as load { 2.0, 1.0 } + c*4
if FPConstant is legal because if the FPConstant doesn't need to be stored
in a constant pool, the transformation is unlikely to be profitable.

llvm-svn: 66994
2009-03-14 00:25:19 +00:00
Dan Gohman a62e4ab690 Improve FastISel's handling of truncates to i1, and implement
ptrtoint and inttoptr in X86FastISel. These casts aren't always
handled in the generic FastISel code because X86 sometimes needs
custom code to do truncation and zero-extension.

llvm-svn: 66988
2009-03-13 23:53:06 +00:00
Evan Cheng 94419d6fdd Fix PR3784: If the source of a phi comes from a bb ended with an invoke, make sure the copy is inserted before the try range (unless it's used as an input to the invoke, then insert it after the last use), not at the end of the bb.
Also re-apply r66140 which was disabled as a workaround.

llvm-svn: 66976
2009-03-13 22:59:14 +00:00
Dan Gohman c0bb959591 Fix FastISel's assumption that i1 values are always zero-extended
by inserting explicit zero extensions where necessary. Included
is a testcase where SelectionDAG produces a virtual register
holding an i1 value which FastISel previously mistakenly assumed
to be zero-extended.

llvm-svn: 66941
2009-03-13 20:42:20 +00:00
Evan Cheng 1fb8aedd1e Fix some significant problems with constant pools that resulted in unnecessary paddings between constant pool entries, larger than necessary alignments (e.g. 8 byte alignment for .literal4 sections), and potentially other issues.
1. ConstantPoolSDNode alignment field is log2 value of the alignment requirement. This is not consistent with other SDNode variants.
2. MachineConstantPool alignment field is also a log2 value.
3. However, some places are creating ConstantPoolSDNode with alignment value rather than log2 values. This creates entries with artificially large alignments, e.g. 256 for SSE vector values.
4. Constant pool entry offsets are computed when they are created. However, asm printer group them by sections. That means the offsets are no longer valid. However, asm printer uses them to determine size of padding between entries.
5. Asm printer uses expensive data structure multimap to track constant pool entries by sections.
6. Asm printer iterate over SmallPtrSet when it's emitting constant pool entries. This is non-deterministic.


Solutions:
1. ConstantPoolSDNode alignment field is changed to keep non-log2 value.
2. MachineConstantPool alignment field is also changed to keep non-log2 value.
3. Functions that create ConstantPool nodes are passing in non-log2 alignments.
4. MachineConstantPoolEntry no longer keeps an offset field. It's replaced with an alignment field. Offsets are not computed when constant pool entries are created. They are computed on the fly in asm printer and JIT.
5. Asm printer uses cheaper data structure to group constant pool entries.
6. Asm printer compute entry offsets after grouping is done.
7. Change JIT code to compute entry offsets on the fly.

llvm-svn: 66875
2009-03-13 07:51:59 +00:00
Owen Anderson d37ddf5b5b Convert VirtRegMap to a MachineFunctionPass.
llvm-svn: 66870
2009-03-13 05:55:11 +00:00
Bill Wendling fa54bc2052 Oops...I committed too much.
llvm-svn: 66867
2009-03-13 04:39:26 +00:00
Bill Wendling b02eadf660 Temporarily XFAIL this test.
llvm-svn: 66866
2009-03-13 04:37:11 +00:00
Dan Gohman a19c662a83 Fix a typo in a comment.
llvm-svn: 66843
2009-03-12 23:55:10 +00:00
Owen Anderson 36a9937883 Reorganize some #include's.
llvm-svn: 66780
2009-03-12 06:58:19 +00:00
Chris Lattner 4147f08e44 Move 3 "(add (select cc, 0, c), x) -> (select cc, x, (add, x, c))"
related transformations out of target-specific dag combine into the
ARM backend.  These were added by Evan in r37685 with no testcases
and only seems to help ARM (e.g. test/CodeGen/ARM/select_xform.ll).

Add some simple X86-specific (for now) DAG combines that turn things
like cond ? 8 : 0  -> (zext(cond) << 3).  This happens frequently
with the recently added cp constant select optimization, but is a
very general xform.  For example, we now compile the second example
in const-select.ll to:

_test:
        movsd   LCPI2_0, %xmm0
        ucomisd 8(%esp), %xmm0
        seta    %al
        movzbl  %al, %eax
        movl    4(%esp), %ecx
        movsbl  (%ecx,%eax,4), %eax
        ret

instead of:

_test:
        movl    4(%esp), %eax
        leal    4(%eax), %ecx
        movsd   LCPI2_0, %xmm0
        ucomisd 8(%esp), %xmm0
        cmovbe  %eax, %ecx
        movsbl  (%ecx), %eax
        ret

This passes multisource and dejagnu.

llvm-svn: 66779
2009-03-12 06:52:53 +00:00
Evan Cheng 4465954638 Enable Chris' value propagation change. It make available known sign, zero, one bits information for values that are live out of basic blocks. The goal is to eliminate unnecessary sext, zext, truncate of values that are live-in to blocks. This does not handle PHI nodes yet.
llvm-svn: 66777
2009-03-12 06:29:49 +00:00
Gabor Greif d9065c4e29 update
llvm-svn: 66733
2009-03-11 22:52:25 +00:00
Owen Anderson aabe06d92a Reorganization: Move the Spiller out of VirtRegMap.cpp into its own files. No (intended) functionality change.
llvm-svn: 66720
2009-03-11 22:31:21 +00:00
Evan Cheng 6cba561648 My last coalescer fix introduced a subtler one. It's aborting a commuting optimization too late and left the live intervals to be out of sync with instructions. This fixes 8b10b.
llvm-svn: 66715
2009-03-11 22:18:44 +00:00
Duncan Sands 4581bebf2a It makes no sense to have a ODR version of common
linkage, so remove it.

llvm-svn: 66690
2009-03-11 20:14:15 +00:00
Duncan Sands be69d60d54 Add parentheses to pacify gcc-4.3.
llvm-svn: 66653
2009-03-11 09:04:34 +00:00
Chris Lattner 43d6377f89 reapply my previous patch (r66358) with a tweak to set the
alignment of the generated constant pool entry to the
desired alignment of a type.  If we don't do this, we end up
trying to do movsd from 4-byte alignment memory.  This fixes
450.soplex and 456.hmmer.

llvm-svn: 66641
2009-03-11 05:08:08 +00:00
Bill Wendling 1df2c1b583 Put the assignment back at the top of this method.
llvm-svn: 66611
2009-03-11 00:03:50 +00:00
Evan Cheng 64b3f9d7a7 Two coalescer fixes in one.
1. Use the same value# to represent unknown values being merged into sub-registers.
2. When coalescer commute an instruction and the destination is a physical register, update its sub-registers by merging in the extended ranges.

llvm-svn: 66610
2009-03-11 00:03:21 +00:00
Bill Wendling 9621b099af Make ivars private. Other cleanup. No functionality change.
llvm-svn: 66607
2009-03-10 23:57:09 +00:00
Bill Wendling 86c2656416 Just make the Dwarf timer group static inside of the getter function. No need to alloc/dealloc.
llvm-svn: 66591
2009-03-10 22:58:53 +00:00
Bill Wendling b74d650727 Don't put static functions in anonymous namespace.
llvm-svn: 66589
2009-03-10 22:36:31 +00:00
Bill Wendling ff1faf7033 These should *stop* the timer, not start it again.
llvm-svn: 66586
2009-03-10 22:02:13 +00:00
Bill Wendling 6418590596 - Fix misspelled method name.
- Remove unused method.

llvm-svn: 66585
2009-03-10 21:59:25 +00:00
Bill Wendling a5c8e50ea6 - Create GetOrCreateSourceID from getOrCreateSourceID. GetOrCreateSourceID is
the untimed version of getOrCreateSourceID. getOrCreateSourceID calls
  GetOrCreateSourceID, of course.

- Move some methods into the "private" section. Constify at least one method.

- General clean-ups.

llvm-svn: 66582
2009-03-10 21:47:45 +00:00
Bill Wendling 6e6d1b2481 Refine the Dwarf writer timers so that they measure exception writing and debug
writing individually.

llvm-svn: 66577
2009-03-10 21:23:25 +00:00
Evan Cheng aa887653f4 Revert 66358 for now. It's breaking povray, 450.soplex, and 456.hmmer on x86 / Darwin.
llvm-svn: 66574
2009-03-10 20:47:18 +00:00
Bill Wendling e8dd2847ff Add a timer to the DwarfWriter pass that measures the total time it takes to
emit exception and debug Dwarf info.

llvm-svn: 66571
2009-03-10 20:41:52 +00:00
Dan Gohman 64613aceed Fix a post-RA scheduling liveness bug. When a basic block is being
scheduled in multiple regions, liveness data used by the
anti-dependence breaker is carried from one region to the next, however
the information reflects the state of the instructions before scheduling.
After scheduling, there may be new live range overlaps. Handle this by
pessimizing the liveness data carried between regions to the point where
it will be conservatively correct now matter how the earlier region is
scheduled. This fixes a miscompilation in 176.gcc with the post-RA
scheduler enabled.

llvm-svn: 66558
2009-03-10 18:10:43 +00:00
Chris Lattner 1522e2498f wire up support for emitting "special" values from inline asm
format strings with the standard ${:foo} syntax.

llvm-svn: 66527
2009-03-10 05:37:13 +00:00
Chris Lattner 4249b9a698 Fix PR3763 by using proper APInt methods instead of uint64_t's.
llvm-svn: 66434
2009-03-09 20:22:18 +00:00
Evan Cheng fb8ded911e Yet another case where the spiller marked two uses of the same register on the same instruction as kill. This fixes PR3706.
llvm-svn: 66428
2009-03-09 19:00:05 +00:00
Chris Lattner 126dab2f76 just remove the use_empty() check entirely, the only reason it
existed was for llvm-gcc 3.4 (which used the __main hack) which 
is really really long dead.

llvm-svn: 66417
2009-03-09 08:18:48 +00:00
Chris Lattner 317293b504 Make the code generator rip of dead constant expr uses before deciding
whether a global is dead or not.  This should fix PR3749 - linker adds 
spurious use to appending globals.  I can't reasonably add a testcase
for this, because the bc writer/reader strip dead constant users.

llvm-svn: 66404
2009-03-09 05:52:15 +00:00
Bill Wendling c6869f4695 Pass in a std::string when getting the names of debugging things. This cuts down
on the number of times a std::string is created and copied.

llvm-svn: 66396
2009-03-09 05:04:40 +00:00
Evan Cheng de22116f39 If a MI uses the same register more than once, only mark one of them as 'kill'.
llvm-svn: 66363
2009-03-08 03:58:35 +00:00
Chris Lattner ab5a443144 implement an optimization to codegen c ? 1.0 : 2.0 as load { 2.0, 1.0 } + c*4.
For 2009-03-07-FPConstSelect.ll we now produce:

_f:
	xorl	%eax, %eax
	testl	%edi, %edi
	movl	$4, %ecx
	cmovne	%rax, %rcx
	leaq	LCPI1_0(%rip), %rax
	movss	(%rcx,%rax), %xmm0
	ret

previously we produced:

_f:
	subl	$4, %esp
	cmpl	$0, 8(%esp)
	movss	LCPI1_0, %xmm0
	je	LBB1_2	## entry
LBB1_1:	## entry
	movss	LCPI1_1, %xmm0
LBB1_2:	## entry
	movss	%xmm0, (%esp)
	flds	(%esp)
	addl	$4, %esp
	ret

on PPC the code also improves to:

_f:
	cntlzw r2, r3
	srwi r2, r2, 5
	li r3, lo16(LCPI1_0)
	slwi r2, r2, 2
	addis r3, r3, ha16(LCPI1_0)
	lfsx f1, r3, r2
	blr 

from:

_f:
	li r2, lo16(LCPI1_1)
	cmplwi cr0, r3, 0
	addis r2, r2, ha16(LCPI1_1)
	beq cr0, LBB1_2	; entry
LBB1_1:	; entry
	li r2, lo16(LCPI1_0)
	addis r2, r2, ha16(LCPI1_0)
LBB1_2:	; entry
	lfs f1, 0(r2)
	blr 

This also improves the existing pic-cpool case from:

foo:
	subl	$12, %esp
	call	.Lllvm$1.$piclabel
.Lllvm$1.$piclabel:
	popl	%eax
	addl	$_GLOBAL_OFFSET_TABLE_ + [.-.Lllvm$1.$piclabel], %eax
	cmpl	$0, 16(%esp)
	movsd	.LCPI1_0@GOTOFF(%eax), %xmm0
	je	.LBB1_2	# entry
.LBB1_1:	# entry
	movsd	.LCPI1_1@GOTOFF(%eax), %xmm0
.LBB1_2:	# entry
	movsd	%xmm0, (%esp)
	fldl	(%esp)
	addl	$12, %esp
	ret

to:

foo:
	call	.Lllvm$1.$piclabel
.Lllvm$1.$piclabel:
	popl	%eax
	addl	$_GLOBAL_OFFSET_TABLE_ + [.-.Lllvm$1.$piclabel], %eax
	xorl	%ecx, %ecx
	cmpl	$0, 4(%esp)
	movl	$8, %edx
	cmovne	%ecx, %edx
	fldl	.LCPI1_0@GOTOFF(%eax,%edx)
	ret

This triggers a few dozen times in spec FP 2000.

llvm-svn: 66358
2009-03-08 01:51:30 +00:00
Chris Lattner 21cf4bf235 random cleanups.
llvm-svn: 66357
2009-03-08 01:47:41 +00:00
Duncan Sands 12da8ce3d2 Introduce new linkage types linkonce_odr, weak_odr, common_odr
and extern_weak_odr.  These are the same as the non-odr versions,
except that they indicate that the global will only be overridden
by an *equivalent* global.  In C, a function with weak linkage can
be overridden by a function which behaves completely differently.
This means that IP passes have to skip weak functions, since any
deductions made from the function definition might be wrong, since
the definition could be replaced by something completely different
at link time.   This is not allowed in C++, thanks to the ODR
(One-Definition-Rule): if a function is replaced by another at
link-time, then the new function must be the same as the original
function.  If a language knows that a function or other global can
only be overridden by an equivalent global, it can give it the
weak_odr linkage type, and the optimizers will understand that it
is alright to make deductions based on the function body.  The
code generators on the other hand map weak and weak_odr linkage
to the same thing.

llvm-svn: 66339
2009-03-07 15:45:40 +00:00
Dan Gohman 15af5524a4 Fix ScheduleDAGRRList::CopyAndMoveSuccessors' handling of nodes
with multiple chain operands. This can occur when the scheduler
has added chain operands to a node that already has a chain
operand, in order to handle physical register dependencies.

This fixes an llvm-gcc bootstrap failure on x86-64 introduced
in r66058.

llvm-svn: 66240
2009-03-06 02:23:01 +00:00
Bill Wendling 6d8472b9cc When we split a basic block, there's a default branch to the newly created BB.
Delete this default branch, because we're going to generate our own.

llvm-svn: 66234
2009-03-06 01:41:15 +00:00
Owen Anderson 380b3838f6 (Hopefully) silence a warning.
llvm-svn: 66158
2009-03-05 08:23:20 +00:00
Owen Anderson ad503987a8 Be more careful about choosing restore points when doing restore folding. This fixes some subtle miscompilations.
llvm-svn: 66147
2009-03-05 07:19:18 +00:00
Evan Cheng f0bfc6a675 Fix how livein live intervals are handled. Previously it could end at MBB start. Sorry, no small test case possible.
llvm-svn: 66129
2009-03-05 03:34:26 +00:00
Bob Wilson 5b15d01ff3 Fix BuildVectorSDNode::isConstantSplat to handle one-element vectors.
It is an error to call APInt::zext with a size that is equal to the value's
current size, so use zextOrTrunc instead.

llvm-svn: 66039
2009-03-04 17:47:01 +00:00
Owen Anderson 0dedc114de Add a restore folder, which shaves a dozen or so machineinstrs off oggenc. Update a testcase to check this.
llvm-svn: 66029
2009-03-04 08:52:31 +00:00
Eli Friedman 7604d37723 PR3686: make the legalizer handle bitcast from i80 to x86 long double.
llvm-svn: 66021
2009-03-04 06:23:34 +00:00
Evan Cheng b8905c4e2c Fix PR3701. 1. X86 target renamed eflags register to flags. This matches what llvm-gcc generates so codegen knows flags register is being clobbered by inline asm. 2. BURR scheduler should also check if inline asm nodes can clobber "live" physical registers. Previously it was only checking target nodes with implicit defs.
llvm-svn: 65996
2009-03-04 01:41:49 +00:00
Bill Wendling 6d2714738f The DAG combiner was performing a BT combine. The BT combine had a value of -1,
so it changed it into a 31 via the TLO.ShrinkDemandedConstant() call. Then it
would go through the DAG combiner again. This time it had a value of 31, which
was turned into a -1 by TLI.SimplifyDemandedBits(). This would ping pong
forever.

Teach the TLO.ShrinkDemandedConstant() call not to lower a value if the demanded
value is an XOR of all ones.

llvm-svn: 65985
2009-03-04 00:18:06 +00:00
Bob Wilson 85cefe8567 Generalize BuildVectorSDNode::isConstantSplat to use APInts and handle
arbitrary vector sizes.  Add an optional MinSplatBits parameter to specify
a minimum for the splat element size.  Update the PPC target to use the
revised interface.

llvm-svn: 65899
2009-03-02 23:24:16 +00:00
Nate Begeman a9e981225e Fix a problem with DAGCombine on 64b targets where folding
extracts + build_vector into a shuffle would fail, because the
type of the new build_vector would not be legal.  Try harder to
create a legal build_vector type.  Note: this will be totally 
irrelevant once vector_shuffle no longer takes a build_vector for
shuffle mask.

New:
_foo:
	xorps	%xmm0, %xmm0
	xorps	%xmm1, %xmm1
	subps	%xmm1, %xmm1
	mulps	%xmm0, %xmm1
	addps	%xmm0, %xmm1
	movaps	%xmm1, 0

Old:
_foo:
	xorps	%xmm0, %xmm0
	movss	%xmm0, %xmm1
	xorps	%xmm2, %xmm2
	unpcklps	%xmm1, %xmm2
	pshufd	$80, %xmm1, %xmm1
	unpcklps	%xmm1, %xmm2
	pslldq	$16, %xmm2
	pshufd	$57, %xmm2, %xmm1
	subps	%xmm0, %xmm1
	mulps	%xmm0, %xmm1
	addps	%xmm0, %xmm1
	movaps	%xmm1, 0

llvm-svn: 65791
2009-03-01 23:44:07 +00:00
Evan Cheng c2f95b56db Minor optimization:
Look for situations like this:                                                                                                                                                              
%reg1024<def> = MOV r1                                                                                                                                                                      
%reg1025<def> = MOV r0                                                                                                                                                                      
%reg1026<def> = ADD %reg1024, %reg1025                                                                                                                                                      
r0            = MOV %reg1026                                                                                                                                                                
Commute the ADD to hopefully eliminate an otherwise unavoidable copy.

llvm-svn: 65752
2009-03-01 02:03:43 +00:00
Bob Wilson d8ea0e144e Combine PPC's GetConstantBuildVectorBits and isConstantSplat functions to a new
method in a BuildVectorSDNode "pseudo-class".

llvm-svn: 65747
2009-03-01 01:13:55 +00:00
Evan Cheng 398dee1c4a Last commit accidentially deleted this code.
llvm-svn: 65679
2009-02-28 06:02:14 +00:00
Devang Patel 843cc34d81 It is possible that subprgoram definition is only encoding return value directly, instsad of an DIArray of all argument types.
llvm-svn: 65643
2009-02-27 18:05:21 +00:00
Rafael Espindola 000421eade Refactor TLS code and add some tests. The tests and expected results are:
pic |  declaration | linkage  | visibility |

!pic |  declaration | external | default    | tls1.ll     tls2.ll     | local exec
 pic |  declaration | external | default    | tls1-pic.ll tls2-pic.ll | general dynamic
!pic | !declaration | external | default    | tls3.ll     tls4.ll     | initial exec
 pic | !declaration | external | default    | tls3-pic.ll tls4-pic.ll | general dynamic

!pic |  declaration | external | hidden     | tls7.ll     tls8.ll     | local exec
 pic |  declaration | external | hidden     | X                       | local dynamic
!pic | !declaration | external | hidden     | tls9.ll     tls10.ll    | local exec
 pic | !declaration | external | hidden     | X                       | local dynamic

!pic |  declaration | internal | default    | tls5.ll     tls6.ll     | local exec
 pic |  declaration | internal | default    | X                       | local dynamic

The ones marked with an X have not been implemented since local dynamic is not implemented.

llvm-svn: 65632
2009-02-27 13:37:18 +00:00
Evan Cheng 8d0b4d4fd6 MachineLICM CSE should match destination register classes; avoid hoisting implicit_def's.
llvm-svn: 65592
2009-02-27 00:02:22 +00:00
Owen Anderson 5c53a46297 Enable stack slot coloring DCE. Evan's spiller fixes were needed before this could happen.
llvm-svn: 65501
2009-02-26 04:47:57 +00:00
Evan Cheng ca2d65467b The last commit was overly conservative. It's ok to reuse value that's already marked livein.
llvm-svn: 65498
2009-02-26 03:02:21 +00:00
Evan Cheng ee5fd035e2 If an available register falls through to a succ block, unset the last kill. Sorry, it's impossible to reduce a sensible test case. It basically requires the moon and stars to align in order to cause a failure.
llvm-svn: 65497
2009-02-26 02:30:42 +00:00
Evan Cheng a49de9de2e Revert BuildVectorSDNode related patches: 65426, 65427, and 65296.
llvm-svn: 65482
2009-02-25 22:49:59 +00:00
Dale Johannesen 7d12ea0f62 Fix big-endian codegen bug. We're splitting up
overly long ints, e.g. i96, into pieces at PHIs
and the nodes that feed into them; however big-endian
reverses the order of the pieces (for some reason), and
wasn't doing it the same way on both sides, so
the pieces didn't match and runtime failures ensued.
Fixes 188.ammp and sqlite3 on ppc32.

llvm-svn: 65481
2009-02-25 22:39:13 +00:00
Devang Patel 7e7fa83f6e Print variable's display name in dwarf DIE.
llvm-svn: 65468
2009-02-25 19:41:35 +00:00
Evan Cheng 86673f2806 Clean up dwarf writer, part 1. This eliminated the horrible recursive getGlobalVariablesUsing and replaced it something readable. It eliminated use of slow UniqueVector and replaced it with StringMap, SmallVector, and DenseMap, etc. It also fixed some non-deterministic behavior.
This is a very minor compile time win.

llvm-svn: 65438
2009-02-25 07:04:34 +00:00
Scott Michel e2fdc31759 Expand tabs to spaces (overlooked in previous commit)
llvm-svn: 65427
2009-02-25 03:57:49 +00:00
Scott Michel bb878288cb Remove all "cached" data from BuildVectorSDNode, preferring to retrieve
results via reference parameters.

This patch also appears to fix Evan's reported problem supplied as a
reduced bugpoint test case.

llvm-svn: 65426
2009-02-25 03:12:50 +00:00
Bill Wendling c5437ea429 Overhaul my earlier submission due to feedback. It's a large patch, but most of
them are generic changes.

- Use the "fast" flag that's already being passed into the asm printers instead
  of shoving it into the DwarfWriter.

- Instead of calling "MI->getParent()->getParent()" for every MI, set the
  machine function when calling "runOnMachineFunction" in the asm printers.

llvm-svn: 65379
2009-02-24 08:30:20 +00:00
Owen Anderson 0fb12efbc1 Add a debugging option for SSC DCE.
llvm-svn: 65375
2009-02-24 05:44:18 +00:00
Bill Wendling 786c5973f7 - Use the "Fast" flag instead of "OptimizeForSize" to determine whether to emit
a DBG_LABEL or not. We want to fall back to the original way of emitting debug
  info when we're in -O0/-fast mode.
- Add plumbing in to pass the "Fast" flag to places that need it.
- XFAIL DebugInfo/deaddebuglabel.ll. This is finding 11 labels instead of 8. I
  need to investigate still.

llvm-svn: 65367
2009-02-24 02:35:30 +00:00
Dan Gohman 4f356bb9b0 Fix a ValueTracking rule: RHS means operand 1, not 0. Add a simple
ashr instcombine to help expose this code. And apply the fix to
SelectionDAG's copy of this code too.

llvm-svn: 65364
2009-02-24 02:00:40 +00:00
Devang Patel 50c6324119 gdb uses DW_AT_prototyped to identify K&R style in C based languages.
This fixes objc.dg/dwarf-prototypes.m scan-assembler DW_AT_prototyped from llvmgcc42 test suite.

llvm-svn: 65357
2009-02-24 00:52:19 +00:00
Devang Patel 6ced076e4c If there is not any debug info available for any global variables and any subprograms then there is not any debug info to emit.
llvm-svn: 65352
2009-02-24 00:02:15 +00:00
Scott Michel 9d31aca679 Introduce the BuildVectorSDNode class that encapsulates the ISD::BUILD_VECTOR
instruction. The class also consolidates the code for detecting constant
splats that's shared across PowerPC and the CellSPU backends (and might be
useful for other backends.) Also introduces SelectionDAG::getBUID_VECTOR() for
generating new BUILD_VECTOR nodes.

llvm-svn: 65296
2009-02-22 23:36:09 +00:00
Evan Cheng e779595af0 If a use operand is marked isKill, don't forget to add kill to its live interval as well.
llvm-svn: 65279
2009-02-22 08:35:56 +00:00
Richard Pennington 99f6d7c9fc bug 3610: Floating point vaarg not softened.
llvm-svn: 65239
2009-02-21 19:11:18 +00:00
Anton Korobeynikov 42aae86590 Drop bunch of half-working stuff in the ext_weak linkage support.
Now we're using one gross, but quite robust hack :) (previous ones
did not work, for example, when ext_weak symbol was used deep inside
constant expression in the initializer).

The proper fix of this problem will require some quite huge asmprinter
changes and that's why was postponed. This fixes PR3629 by the way :)

llvm-svn: 65230
2009-02-21 11:53:32 +00:00
Evan Cheng 34806b1fa4 If two-address def is dead and the instruction does not define other registers, and it doesn't produce side effects, just delete the instruction.
llvm-svn: 65218
2009-02-21 03:14:25 +00:00
Dan Gohman e7fe80fcf9 Fix a bug that David Greene found in the DAGCombiner's logic
that checks whether it's safe to transform a store of a bitcast
value into a store of the original value.

llvm-svn: 65201
2009-02-20 23:29:13 +00:00
Bill Wendling 2343339644 - Early exit a nested block.
- Correct comment.
- Whitespace changes.

llvm-svn: 65149
2009-02-20 20:40:28 +00:00
Owen Anderson f13820148b Fix a crash in the pre-alloc splitter exposed by recent codegen changes.
llvm-svn: 65121
2009-02-20 10:02:23 +00:00
Owen Anderson 81db491b7f Add a quick pass to the stack slot colorer to eliminate some trivially redundant spills after coloring.
Ideally these would never get created in the first place, but until we enhance the spiller to have a more
global picture of what's happening, this is necessary for code quality in some circumstances.

llvm-svn: 65120
2009-02-20 09:11:36 +00:00
Bill Wendling 0a0987d198 Add an accessor method to DwarfWriter to tell of debugging info should be emitted.
llvm-svn: 65092
2009-02-20 00:44:43 +00:00
Bill Wendling 7b9f38ad37 Temporarily revert r65065. It was causing test failures.
llvm-svn: 65068
2009-02-19 21:57:07 +00:00
Bill Wendling 1a0a3d0ff5 Print out debug info when printing the machine instruction.
llvm-svn: 65067
2009-02-19 21:44:55 +00:00
Bill Wendling df78dcc0b2 Check for -fast here too.
llvm-svn: 65065
2009-02-19 21:23:54 +00:00
Bill Wendling 19e0a5b3c3 Generate these labels when we're in "fast" mode, not simply when we're no in
"optimize-for-size" mode.

llvm-svn: 65064
2009-02-19 21:12:54 +00:00
Devang Patel 66c5a1dd50 The subprogram die may not exist while creating "default" scope.
llvm-svn: 64920
2009-02-18 17:29:38 +00:00
Nate Begeman 18d85e7403 Add support to the JIT for true non-lazy operation. When a call to a function
that has not been JIT'd yet, the callee is put on a list of pending functions
to JIT.  The call is directed through a stub, which is updated with the address
of the function after it has been JIT'd.  A new interface for allocating and
updating empty stubs is provided.

Add support for removing the ModuleProvider the JIT was created with, which
would otherwise invalidate the JIT's PassManager, which is initialized with the
ModuleProvider's Module.

Add support under a new ExecutionEngine flag for emitting the infomration 
necessary to update Function and GlobalVariable stubs after JITing them, by
recording the address of the stub and the name of the GlobalValue.  This allows
code to be copied from one address space to another, where libraries may live
at different virtual addresses, and have the stubs updated with their new
correct target addresses.

llvm-svn: 64906
2009-02-18 08:31:02 +00:00
Dan Gohman 38a9631d5f Eliminate several more unnecessary intptr_t casts.
llvm-svn: 64888
2009-02-18 05:09:16 +00:00
Devang Patel 4d20395a5f The debugger sometimes lookup dynamically in the runtime to find ivar info of any Objective-C classes. It would be very helpful to debugger if the compiler encodes runtime version number in DWARF.
Add support for two additional DWARF attributes to encode Objective-C runtime version number.

llvm-svn: 64834
2009-02-17 22:43:44 +00:00
Scott Michel cf0da6c597 Remove trailing whitespace to reduce later commit patch noise.
(Note: Eventually, commits like this will be handled via a pre-commit hook that
 does this automagically, as well as expand tabs to spaces and look for 80-col
 violations.)

llvm-svn: 64827
2009-02-17 22:15:04 +00:00
Devang Patel 528987a1e8 Emit debug info for bitfields.
llvm-svn: 64815
2009-02-17 21:23:59 +00:00
Evan Cheng f505cd5ebb A couple of places where reused use operands should be marked kill. This is exposed by recent availability fallthrough changes.
llvm-svn: 64745
2009-02-17 06:41:03 +00:00
Bill Wendling 3c50922ea0 --- Merging (from foreign repository) r64714 into '.':
U    include/llvm/CodeGen/DebugLoc.h
U    lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
U    lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp
U    lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp

Enable debug location generation at -Os. This goes with the reapplication of the
r63639 patch.

llvm-svn: 64715
2009-02-17 01:04:54 +00:00
Dan Gohman aaee6c9523 Don't assume that a left-shift of a value with one bit set will have
one bit set, because the bit may be shifted off the end. Instead,
just check for a constant 1 being shifted. This is still sufficient
to handle all the cases in test/CodeGen/X86/bt.ll. This fixes PR3583.

llvm-svn: 64622
2009-02-15 23:59:32 +00:00
Evan Cheng 2510436e20 Fix PR3522. It's not safe to sink into landing pad BB's.
llvm-svn: 64582
2009-02-15 08:36:12 +00:00
Cedric Venet d1e179d992 Unbreak the build on win32.
Cleanup some warning.

Remark: when struct/class are declared differently than they are defined, this make problem for VC++ since it seems to mangle class differently that struct. These error are very hard to understand and find. So please, try to keep your definition/declaration in sync.

Only tested with VS2008. hope it does not break anything. feel free to revert.

llvm-svn: 64554
2009-02-14 16:06:42 +00:00
Bill Wendling 65c0fd4c44 Revert this. It was breaking stuff.
llvm-svn: 64428
2009-02-13 02:16:35 +00:00
Bill Wendling 1c21ac3066 Turn off the old way of handling debug information in the code generator. Use
the new way, where all of the information is passed on SDNodes and machine
instructions.

llvm-svn: 64427
2009-02-13 02:01:04 +00:00
Dale Johannesen 655775293f Arrange to print constants that match "n" and "i" constraints
in inline asm as signed (what gcc does).  Add partial support
for x86-specific "e" and "Z" constraints, with appropriate
signedness for printing.

llvm-svn: 64400
2009-02-12 20:58:09 +00:00
Dan Gohman e366c29fa0 Adjust the sizes for a few SmallVectors to reflect their usage.
llvm-svn: 64381
2009-02-12 17:29:01 +00:00
Chris Lattner 90880e2598 make fast isel fall back to selectiondags for VLA llvm.declare intrinsics.
llvm-svn: 64379
2009-02-12 17:23:20 +00:00
Evan Cheng cf5cd6ecfe It's (currently) not safe to keep certain physical registers live across basic blocks, e.g. x86 fp stack registers.
llvm-svn: 64374
2009-02-12 10:32:17 +00:00
Evan Cheng b570499c25 Oops. Last second clean up messed things up.
llvm-svn: 64373
2009-02-12 09:52:13 +00:00
Evan Cheng 8b39b545a9 If availability info is kept when fallthrough into a bb, add the available registers to live-in set.
llvm-svn: 64372
2009-02-12 09:43:23 +00:00
Evan Cheng 3a14efacb6 Replace one of burr scheduling heuristic with something more sensible. Now calcMaxScratches simply compute the number of true data dependencies. This actually improve a couple of tests in dejagnu suite as many tests in llvm nightly test suite.
llvm-svn: 64369
2009-02-12 08:59:45 +00:00
Evan Cheng 6f6abfd94b Apparently some MachineBasicBlock's don't have corresponding llvm basic blocks.
llvm-svn: 64340
2009-02-11 23:42:39 +00:00
Evan Cheng eb5ec4a0db Remove a bogus assertion. It's possible a live-in available value is used by a previous instruction.
llvm-svn: 64339
2009-02-11 23:41:57 +00:00
Dan Gohman 45889d24fe Fix a comment.
llvm-svn: 64328
2009-02-11 21:32:08 +00:00
Dan Gohman 6571ef3577 Don't use special heuristics for nodes with no data predecessors
unless they actually have data successors, and likewise for nodes
with no data successors unless they actually have data precessors.

llvm-svn: 64327
2009-02-11 21:29:39 +00:00
Dan Gohman 298a2946f1 Delete the heuristic for non-livein CopyFromReg nodes. Non-liveinness
is determined by whether the node has a Flag operand. However, if the
node does have a Flag operand, it will be glued to its register's
def, so the heuristic would end up spuriously applying to whatever
node is the def.

llvm-svn: 64319
2009-02-11 20:25:59 +00:00
Dale Johannesen cc5fc44d02 Make a transformation added in 63266 a bit less aggressive.
It was transforming (x&y)==y to (x&y)!=0 in the case where
y is variable and known to have at most one bit set (e.g. z&1).
This is not correct; the expressions are not equivalent when y==0.
I believe this patch salvages what can be salvaged, including
all the cases in bt.ll.  Dan, please review.
Fixes gcc.c-torture/execute/20040709-[12].c

llvm-svn: 64314
2009-02-11 19:19:41 +00:00
Evan Cheng a1968b0fc7 Implement PR3495: local spiller optimization. The local spiller can now keep availability information over BB boundaries. It visits BB's in depth first order. After visiting a BB if it find a successor which has a single predecessor it visits the successor next without clearing the availability information. This allows the successor to omit reloads or change them into copies.
llvm-svn: 64298
2009-02-11 08:24:21 +00:00
Dan Gohman dfaf646c34 When scheduling a block in parts, keep track of the overall
instruction index across each part. Instruction indices are used
to make live range queries, and live ranges can extend beyond
scheduling region boundaries.

Refactor the ScheduleDAGSDNodes class some more so that it
doesn't have to worry about this additional information.

llvm-svn: 64288
2009-02-11 04:27:20 +00:00
Dan Gohman 27fa408b64 Use iterators to iterate through the Preds array instead of
an index. This code is on the hot-path because the current
way SDep edges are uniqued has quadratic complexity.

llvm-svn: 64262
2009-02-11 00:12:28 +00:00
Dan Gohman b3dbb21df1 Consider any instruction that modifies the stack pointer to be
a scheduling region boundary.  This isn't necessary for
correctness; it helps with compile time, as it avoids the need
for data- and anti-dependencies from all spills and reloads on
the stack-pointer modification.

llvm-svn: 64255
2009-02-10 23:29:38 +00:00
Dan Gohman b95434356c Factor out more code for computing register live-range informationfor
scheduling, and generalize is so that preserves state across
scheduling regions. This fixes incorrect live-range information around
terminators and labels, which are effective region boundaries.

In place of looking for terminators to anchor inter-block dependencies,
introduce special entry and exit scheduling units for this purpose.

llvm-svn: 64254
2009-02-10 23:27:53 +00:00
Evan Cheng ce3bbe515b Fix PR3457: Ignore control successors when looking for closest scheduled successor. A control successor doesn't read result(s) produced by the scheduling unit being evaluated.
llvm-svn: 64210
2009-02-10 08:30:11 +00:00
Devang Patel 9b6c1d6313 Validate file id.
llvm-svn: 64204
2009-02-10 06:04:08 +00:00
Evan Cheng 3af42a8a14 If the target cannot issue a copy for the given source and dest registers, abort instead of silently continue.
llvm-svn: 64184
2009-02-09 22:47:36 +00:00
Evan Cheng fe174df170 Simplify code.
llvm-svn: 64164
2009-02-09 21:01:06 +00:00
Evan Cheng 020588cee3 Make sure constant subscript is truncated to ptr size if it may not fit.
llvm-svn: 64163
2009-02-09 20:54:38 +00:00
Evan Cheng f736bd9c79 Re-enable machine sinking pass now that the coalescer bugs and the AnalyzeBrnach bug are fixed.
llvm-svn: 64126
2009-02-09 08:45:39 +00:00
Evan Cheng 81ae066ab6 Fix another case ShortenDeadCopySrcLiveRange is shortening too much. No test case possible since I don't know what to grep for. :-(
llvm-svn: 64125
2009-02-09 08:37:45 +00:00
Evan Cheng 64dfcacd5f Turns out AnalyzeBranch can modify the mbb being analyzed. This is a nasty
suprise to some callers, e.g. register coalescer. For now, add an parameter
that tells AnalyzeBranch whether it's safe to modify the mbb. A better
solution is out there, but I don't have time to deal with it right now.

llvm-svn: 64124
2009-02-09 07:14:22 +00:00
Evan Cheng b3783639cb Fix PR3486. Fix a bug in code that manually patch physical register live interval after its sub-register is coalesced with a virtual register.
llvm-svn: 64082
2009-02-08 11:04:35 +00:00
Evan Cheng 942519306e Strengthen the previous check.
llvm-svn: 64076
2009-02-08 08:24:28 +00:00
Evan Cheng fe014df914 r64073 commit message is lost. Here it is:
Right now if the coalesced copy def is dead and its src is a kill, and that
there are now other uses within the live range, the coalescer would mark the
def of the source register as dead. But it should also check if there are
other kills which means the value has other uses not in the live range.

llvm-svn: 64075
2009-02-08 08:00:36 +00:00
Evan Cheng e5e95f7717 (no commit message)
llvm-svn: 64073
2009-02-08 07:48:37 +00:00
Bill Wendling 5469ec1072 Revert r63999. It was breaking self-hosting builds.
llvm-svn: 64062
2009-02-08 00:58:05 +00:00
Chris Lattner d8f0786c31 Add missing break statements, fixing PR3503.
llvm-svn: 64040
2009-02-07 22:37:06 +00:00
Dale Johannesen 9c310711bb Use getDebugLoc forwarder instead of getNode()->getDebugLoc.
No functional change.

llvm-svn: 64026
2009-02-07 19:59:05 +00:00
Dan Gohman 747e55bc9a Constify TargetInstrInfo::EmitInstrWithCustomInserter, allowing
ScheduleDAG's TLI member to use const.

llvm-svn: 64018
2009-02-07 16:15:20 +00:00
Dale Johannesen 8ba7132128 Make SDNode constructors take a DebugLoc always.
Adjust derived classes to pass UnknownLoc where
a DebugLoc does not make sense.  Pick one of
DebugLoc and non-DebugLoc variants to survive
for all such classes.

llvm-svn: 64000
2009-02-07 02:15:05 +00:00
Evan Cheng 9571621665 Enable machine sinking pass in non-fast mode.
llvm-svn: 63999
2009-02-07 01:57:46 +00:00
Dale Johannesen a72d41a67b Remove now-unused constructors.
llvm-svn: 63995
2009-02-07 01:27:09 +00:00
Evan Cheng 47a65a167d Don't sink the instruction if TargetRegisterInfo::isSafeToMoveRegClassDefs doesn't think it's safe. This works around PR1911.
llvm-svn: 63994
2009-02-07 01:21:47 +00:00
Dale Johannesen 62fd95d6ec Get rid of the last non-DebugLoc versions of getNode!
Many targets build placeholder nodes for special operands, e.g.
GlobalBaseReg on X86 and PPC for the PIC base.  There's no
sensible way to associate debug info with these.  I've left
them built with getNode calls with explicit DebugLoc::getUnknownLoc operands. 
I'm not too happy about this but don't see a good improvement;
I considered adding a getPseudoOperand or something, but it
seems to me that'll just make it harder to read.

llvm-svn: 63992
2009-02-07 00:55:49 +00:00
Dale Johannesen 84935759d5 Remove more non-DebugLoc getNode variants. Use
getCALLSEQ_{END,START} to permit passing no DebugLoc
there.  UNDEF doesn't logically have DebugLoc; add
getUNDEF to encapsulate this.

llvm-svn: 63978
2009-02-06 23:05:02 +00:00
Dale Johannesen dc93bbc4b0 And one more file.
llvm-svn: 63971
2009-02-06 21:55:48 +00:00
Dale Johannesen 400dc2e2e4 Remove more non-DebugLoc versions of getNode.
llvm-svn: 63969
2009-02-06 21:50:26 +00:00
Bill Wendling 03c34d0d3c Clear out the CurDebugLoc info when doing a 'clear' on the SDL object.
llvm-svn: 63967
2009-02-06 21:36:23 +00:00
Dale Johannesen ab8e4425a3 Eliminate remaining non-DebugLoc version of getTargetNode.
llvm-svn: 63951
2009-02-06 19:16:40 +00:00