Commit Graph

11493 Commits

Author SHA1 Message Date
Jakob Stoklund Olesen
fe3f99f95c Be more strict about the first/last interference-free use.
If the interference overlaps the instruction, we cannot separate it.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124918 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-05 01:06:39 +00:00
Jakob Stoklund Olesen
de71095a1a Add assertions to verify that the new interval is clear of the interference.
If these inequalities don't hold, we are creating a live range split that won't
allocate.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124917 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-05 01:06:36 +00:00
Jakob Stoklund Olesen
45e53975f8 Apparently, it is possible for a block with a landing pad successor to have no calls.
In that case we simply ignore the landing pad and split live ranges before the
first terminator.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124907 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-04 23:11:13 +00:00
Devang Patel
6c3ea9012e Merge .debug_loc entries whenever possible to reduce debug_loc size.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124904 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-04 22:57:18 +00:00
Nick Lewycky
c57ef56142 Mark that the return is using EAX so that we don't use it for some other
purpose. Fixes PR9080!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124903 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-04 22:44:08 +00:00
Jakob Stoklund Olesen
63935420ef Be more accurate about live range splitting at the end of blocks.
If interference reaches the last split point, it is effectively live out and
should be marked as 'MustSpill'.

This can make a difference when the terminator uses a register. There is no way
that register can be reused in the outgoing CFG bundle, even if it isn't live
out.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124900 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-04 21:42:06 +00:00
Jakob Stoklund Olesen
cb6404711b Add LiveIntervals::getLastSplitPoint().
A live range cannot be split everywhere in a basic block. A split must go before
the first terminator, and if the variable is live into a landing pad, the split
must happen before the call that can throw.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124894 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-04 19:33:11 +00:00
Jakob Stoklund Olesen
9b3d24bf3d Verify that one of the ranges produced by region splitting is allocatable.
We should not be attempting a region split if it won't lead to at least one
directly allocatable interval. That could cause infinite splitting loops.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124893 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-04 19:33:07 +00:00
Andrew Trick
92e946630d Introducing a new method of tracking register pressure. We can't
precisely track pressure on a selection DAG, but we can at least keep
it balanced. This design accounts for various interesting aspects of
selection DAGS: register and subregister copies, glued nodes, dead
nodes, unused registers, etc.

Added SUnit::NumRegDefsLeft and ScheduleDAGSDNodes::RegDefIter.

Note: I disabled PrescheduleNodesWithMultipleUses when register
pressure is enabled, based on no evidence other than I don't think it
makes sense to have both enabled.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124853 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-04 03:18:17 +00:00
Devang Patel
f827cd717b DebugLoc associated with a machine instruction is used to emit location entries. DebugLoc associated with a DBG_VALUE is used to identify lexical scope of the variable. After register allocation, while inserting DBG_VALUE remember original debug location for the first instruction and reuse it, otherwise dwarf writer may be mislead in identifying the variable's scope.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124845 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-04 01:43:25 +00:00
Evan Cheng
c8b90e22a8 Update comments.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124843 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-04 01:10:12 +00:00
Jakob Stoklund Olesen
9ecd1e7197 Skip unused values.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124842 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-04 00:59:23 +00:00
Jakob Stoklund Olesen
45139874a7 Also compute interference intervals for blocks with no uses.
When the live range is live through a block that doesn't use the register, but
that has interference, region splitting wants to split at the top and bottom of
the basic block.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124839 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-04 00:39:20 +00:00
Jakob Stoklund Olesen
a7b586ba74 Verify kill flags conservatively.
Allow a live range to end with a kill flag, but don't allow a kill flag that
doesn't end the live range.

This makes the machine code verifier more useful during register allocation when
kill flag computation is deferred.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124838 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-04 00:39:18 +00:00
Andrew Trick
cd5af07c45 whitespace
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124827 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-03 23:00:17 +00:00
Jakob Stoklund Olesen
2dfbb3e912 Ensure that the computed interference intervals actually overlap their basic blocks.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124815 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-03 20:29:43 +00:00
Jakob Stoklund Olesen
97af98678c Tweak debug output from SlotIndexes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124814 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-03 20:29:41 +00:00
Jakob Stoklund Olesen
c50f077b06 Add debug output and asserts to the phi-connecting code.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124813 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-03 20:29:39 +00:00
Jakob Stoklund Olesen
08eb8dd616 Fix coloring bug when mapping values in the middle of a live-through block.
If the found value is not live-through the block, we should only add liveness up
to the requested slot index. When the value is live-through, the whole block
should be colored.

Bug found by SSA verification in the machine code verifier.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124812 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-03 20:29:36 +00:00
Jakob Stoklund Olesen
207c868c92 Return live range end points from SplitEditor::enter*/leave*.
These end points come from the inserted copies, and can be passed directly to
useIntv. This simplifies the coloring code.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124799 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-03 17:04:16 +00:00
Jakob Stoklund Olesen
9590c7fbca Silence an MSVC warning
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124798 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-03 17:04:12 +00:00
Eric Christopher
0f43811903 Reapply this.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124779 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-03 06:18:29 +00:00
Eric Christopher
463a2977b1 Temporarily revert 124765 in an attempt to find the cycle breaking bootstrap.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124778 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-03 05:40:54 +00:00
Jakob Stoklund Olesen
2cd2111959 Defer SplitKit value mapping until all defs are available.
The greedy register allocator revealed some problems with the value mapping in
SplitKit. We would sometimes start mapping values before all defs were known,
and that could change a value from a simple 1-1 mapping to a multi-def mapping
that requires ssa update.

The new approach collects all defs and register assignments first without
filling in any live intervals. Only when finish() is called, do we compute
liveness and mapped values. At this time we know with certainty which values map
to multiple values in a split range.

This also has the advantage that we can compute live ranges based on the
remaining uses after rematerializing at split points.

The current implementation has many opportunities for compile time optimization.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124765 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-03 00:54:23 +00:00
Devang Patel
e7d93877c6 Add support to describe template value parameter in debug info.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124755 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-02 22:35:53 +00:00
Devang Patel
7e2cb11655 Add support to describe template parameter type in debug info.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124752 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-02 21:38:25 +00:00
Evan Cheng
31959b19a7 Given a pair of floating point load and store, if there are no other uses of
the load, then it may be legal to transform the load and store to integer
load and store of the same width.

This is done if the target specified the transformation as profitable. e.g.
On arm, this can transform:
vldr.32 s0, []
vstr.32 s0, []

to

ldr r12, []
str r12, []

rdar://8944252


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124708 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-02 01:06:55 +00:00
Matt Beaumont-Gay
9a14a362d0 Take Bill Wendling's suggestion for structuring a couple of asserts.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124688 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-01 22:12:50 +00:00
Devang Patel
e9a7ea6865 Keep track of incoming argument's location while emitting LiveIns.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124611 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-31 21:38:14 +00:00
Richard Osborne
4e3740ee6d Fix bug where ReduceLoadWidth was creating illegal ZEXTLOAD instructions.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124587 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-31 17:41:44 +00:00
Anton Korobeynikov
ed299f6fa9 Clarify the LSDASection NULL check
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124569 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-30 22:07:31 +00:00
Jakob Stoklund Olesen
8352062e52 Respect the -tail-dup-size command line option even when optimizing for size.
This is similar to the -unroll-threshold option. There should be no change in
behavior when -tail-dup-size is not explicit on the llc command line.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124564 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-30 20:38:12 +00:00
Benjamin Kramer
9b108a338d Teach DAGCombine to fold fold (sra (trunc (sr x, c1)), c2) -> (trunc (sra x, c1+c2) when c1 equals the amount of bits that are truncated off.
This happens all the time when a smul is promoted to a larger type.

On x86-64 we now compile "int test(int x) { return x/10; }" into
  movslq  %edi, %rax
  imulq $1717986919, %rax, %rax
  movq  %rax, %rcx
  shrq  $63, %rcx
  sarq  $34, %rax <- used to be "shrq $32, %rax; sarl $2, %eax"
  addl  %ecx, %eax

This fires 96 times in gcc.c on x86-64.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124559 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-30 16:38:43 +00:00
Benjamin Kramer
2c94b4201b Add the missing sub identity "A-(A-B) -> B" to DAGCombine.
This happens e.g. for code like "X - X%10" where we lower the modulo operation
to a series of multiplies and shifts that are then subtracted from X, leading to
this missed optimization.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124532 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-29 12:34:05 +00:00
Evan Cheng
c3f507f98a Re-apply r124518 with fix. Watch out for invalidated iterator.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124526 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-29 04:46:23 +00:00
Evan Cheng
b0a42fdb36 Revert r124518. It broke Linux self-host.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124522 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-29 02:43:04 +00:00
Evan Cheng
5e6940788f Re-commit r124462 with fixes. Tail recursion elim will now dup ret into unconditional predecessor to enable TCE on demand.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124518 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-29 01:29:26 +00:00
Evan Cheng
1b5c0cb71d Revert r124462. There are a few big regressions that I need to fix first.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124478 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-28 07:12:38 +00:00
Nick Lewycky
ed4efd3358 Fix build with stdcxx by using llvm::next. Patch by Joerg Sonnenberger!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124472 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-28 04:00:15 +00:00
Rafael Espindola
1ffb533699 Print the visibility of declarations.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124468 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-28 03:20:10 +00:00
Evan Cheng
40f64cb0de - Stop simplifycfg from duplicating "ret" instructions into unconditional
branches. PR8575, rdar://5134905, rdar://8911460.
- Allow codegen tail duplication to dup small return blocks after register
  allocation is done.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124462 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-28 02:19:21 +00:00
Andrew Trick
e787ddb510 Remove a temporary workaround for a lencod miscompile. Depends on the fix in r124442.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124443 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-27 21:28:51 +00:00
Andrew Trick
5d7ab8503b VirtRegRewriter fix: update kill flags, which are used by the scavenger.
rdar://problem/8893967: JM/lencod miscompile at -arch armv7 -mthumb -O3

Added ResurrectKill to remove kill flags after we decide to reused a
physical register. And (hopefully) ensure that we call it in all the
right places.

Sorry, I'm not checking in a unit test given that it's a miscompile I
can't reproduce easily with a toy example. Failures in the rewriter
depend on a series of heuristic decisions maked during one of the many
upstream phases in codegen. This case would require coercing regalloc
to generate a couple of rematerialzations in a way that causes the
scavenger to reuse the same register at just the wrong point.

The general way to test this is to implement kill flags
verification. Then we could have a simple, robust compile-only unit
test. That would be worth doing if the whole pass was not about to
disappear. At this point we focus verification work on the next
generation of regalloc.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124442 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-27 21:26:43 +00:00
Devang Patel
7e7fc1052a Speculatively revert r124380.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124397 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-27 19:15:01 +00:00
Devang Patel
bfae5f312c While legalizing SDValues do not drop SDDbgValues, trasfer them to new legal nodes.
Take 2. This includes fix for dragonegg crash.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124380 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-27 17:43:53 +00:00
Bob Wilson
adf9c8b0e7 Avoid modifying the OneClassForEachPhysReg map while iterating over it.
Linear scan regalloc is currently assuming that any register aliased with
a member of a regclass must also be in at least one regclass.  That is not
always true.  For example, for X86, RIP is in a regclass but IP is not.
If you're unlucky, this can cause a crash by invalidating the iterator.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124365 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-27 07:26:15 +00:00
Matt Beaumont-Gay
4789aca85e Try harder to not have unused variables.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124350 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-27 02:39:27 +00:00
Matt Beaumont-Gay
a8af137847 Opt-mode -Wunused-variable cleanup
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124346 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-27 01:47:50 +00:00
Devang Patel
39078a8bde Reapply 124301
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124339 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-27 00:13:27 +00:00
Bill Wendling
6b9a293a0c Initialize variable to get rid of clang warning.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124331 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-26 22:21:35 +00:00
Devang Patel
4a95c19977 Revert 124301.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124327 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-26 21:41:22 +00:00
Devang Patel
c47fd9fbf5 Revert r124302
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124320 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-26 21:12:32 +00:00
David Greene
cfe33c46aa [AVX] Add INSERT_SUBVECTOR and support it on x86. This provides a
default implementation for x86, going through the stack in a similr
fashion to how the codegen implements BUILD_VECTOR.  Eventually this
will get matched to VINSERTF128 if AVX is available.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124307 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-26 19:13:22 +00:00
Devang Patel
d2c9793bdf While legalizing SDValues do not drop SDDbgValues, trasfer them to new legal nodes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124302 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-26 18:55:05 +00:00
Devang Patel
6f121fdede Process valid SDDbgValues even if the node does not have any order assigned.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124301 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-26 18:42:32 +00:00
Devang Patel
55d20e8ff1 Refactor.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124300 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-26 18:20:04 +00:00
David Greene
91585098ef [AVX] Support EXTRACT_SUBVECTOR on x86. This provides a default
implementation of EXTRACT_SUBVECTOR for x86, going through the stack
in a similr fashion to how the codegen implements BUILD_VECTOR.
Eventually this will get matched to VEXTRACTF128 if AVX is available.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124292 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-26 15:38:49 +00:00
Jakob Stoklund Olesen
078628465b Rename member variables to follow the rest of LLVM.
No functional change.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124257 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-26 00:50:53 +00:00
Devang Patel
a2e868d34c Provide an interface to transfer SDDbgValue from one SDNode to another.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124245 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-25 23:27:42 +00:00
Devang Patel
8f31428119 Resolve DanglingDbgValue of PHI nodes where the use follows dbg.value intrinisic.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124203 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-25 18:09:58 +00:00
Devang Patel
3a00ffacdc This assertion is too restrictive, it does not apply for dangling dbg value nodes (nodes where dbg.value intrinsic preceds use of the value).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124202 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-25 18:09:33 +00:00
Anton Korobeynikov
d4e0978752 Support printing exception section into the current one. This is the case when LSDASection is blank
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124150 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-24 22:38:40 +00:00
Devang Patel
a3ee3ef71b Speculatively revert r124138.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124142 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-24 20:04:37 +00:00
Devang Patel
224a180d11 Resolve DanglingDbgValue of PHI nodes where the use follows dbg.value intrinisic.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124138 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-24 19:24:37 +00:00
Andrew Trick
c48d50f9c0 Temporarily workaround JM/lencod miscompile (SIGSEGV).
rdar://problem/8893967


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124137 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-24 19:08:15 +00:00
Rafael Espindola
96aa78c8c5 Add support for the --noexecstack option.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124077 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-23 17:55:27 +00:00
Ted Kremenek
584520e8e2 Null initialize a few variables flagged by
clang's -Wuninitialized-experimental warning.
While these don't look like real bugs, clang's
-Wuninitialized-experimental analysis is stricter
than GCC's, and these fixes have the benefit
of being general nice cleanups.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124073 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-23 17:05:06 +00:00
Rafael Espindola
0cf5e3d51d Delay the creation of eh_frame so that the user can change the defaults.
Add support for SHT_X86_64_UNWIND.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124059 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-23 05:43:40 +00:00
Rafael Espindola
1c13026e8f Remove more duplicated code.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124056 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-23 04:43:11 +00:00
Rafael Espindola
c85dca66e6 Remove duplicated code.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124054 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-23 04:28:49 +00:00
Andrew Trick
d1dace8aea Enable support for precise scheduling of the instruction selection
DAG. Disable using "-disable-sched-cycles".

For ARM, this enables a framework for modeling the cpu pipeline and
counting stalls. It also activates several heuristics to drive
scheduling based on the model. Scheduling is inherently imprecise at
this stage, and until spilling is improved it may defeat attempts to
schedule. However, this framework provides greater control over
tuning codegen.

Although the flag is not target-specific, it should have very little
affect on the default scheduler used by x86. The only two changes that
affect x86 are:
- scheduling a high-latency operation bumps the current cycle so independent
  operations can have their latency covered. i.e. two independent 4
  cycle operations can produce results in 4 cycles, not 8 cycles.
- Two operations with equal register pressure impact and no
  latency-based stalls on their uses will be prioritized by depth before height
  (height is irrelevant if no stalls occur in the schedule below this point).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123971 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-21 06:19:05 +00:00
Andrew Trick
c8bfd1d78f Convert -enable-sched-cycles and -enable-sched-hazard to -disable
flags. They are still not enable in this revision.

Added TargetInstrInfo::isZeroCost() to fix a fundamental problem with
the scheduler's model of operand latency in the selection DAG.

Generalized unit tests to work with sched-cycles.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123969 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-21 05:51:33 +00:00
Jakob Stoklund Olesen
c0de995712 SplitKit requires that all defs are in place before calling useIntv().
The value mapping gets confused about which original values have multiple new
definitions so they may need phi insertions.

This could probably be simplified by letting enterIntvBefore() take a live range
to be added following the instruction. As long as the range stays inside the
same basic block, value mapping shouldn't be a problem.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123926 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-20 17:45:23 +00:00
Jakob Stoklund Olesen
d7ca57705e Add LiveIntervalMap::dumpCache() to print out the cache used by the ssa update algorithm.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123925 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-20 17:45:20 +00:00
Eric Christopher
6214373fe9 My editor's indent went crazy. Fix.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123909 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-20 08:56:34 +00:00
Eric Christopher
02050986d9 Expand invalid return values for umulo and smulo. Handle these similarly
to add/sub by doing the normal operation and then checking for overflow
afterwards. This generally relies on the DAG handling the later invalid
operations as well.

Fixes the 64-bit part of rdar://8622122 and rdar://8774702.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123908 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-20 08:54:28 +00:00
Evan Cheng
9fe2009956 Sorry, several patches in one.
TargetInstrInfo:
Change produceSameValue() to take MachineRegisterInfo as an optional argument.
When in SSA form, targets can use it to make more aggressive equality analysis.

Machine LICM:
1. Eliminate isLoadFromConstantMemory, use MI.isInvariantLoad instead.
2. Fix a bug which prevent CSE of instructions which are not re-materializable.
3. Use improved form of produceSameValue.

ARM:
1. Teach ARM produceSameValue to look pass some PIC labels.
2. Look for operands from different loads of different constant pool entries
   which have same values.
3. Re-implement PIC GA materialization using movw + movt. Combine the pair with
   a "add pc" or "ldr [pc]" to form pseudo instructions. This makes it possible
   to re-materialize the instruction, allow machine LICM to hoist the set of
   instructions out of the loop and make it possible to CSE them. It's a bit
   hacky, but it significantly improve code quality.
4. Some minor bug fixes as well.

With the fixes, using movw + movt to materialize GAs significantly outperform the
load from constantpool method. 186.crafty and 255.vortex improved > 20%, 254.gap
and 176.gcc ~10%.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123905 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-20 08:34:58 +00:00
Andrew Trick
0bc308600b Selection DAG scheduler register pressure heuristic fixes.
Added a check for already live regs before claiming HighRegPressure.
Fixed a few cases of checking the wrong number of successors.
Added some tracing until these heuristics are better understood.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123892 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-20 06:21:59 +00:00
Jakob Stoklund Olesen
fd50d76ff8 Check that a live range exists before shortening it. This fixes PR8989.
The live range may have been deleted earlier because of rematerialization.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123891 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-20 06:20:02 +00:00
Jakob Stoklund Olesen
b908a009cf Add hidden -verify-coalescing to run the machine code verifier before and after
register coalescing.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123890 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-20 06:20:00 +00:00
Jakob Stoklund Olesen
b7683c06cb Fix bug found by new clang warning.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123872 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-20 02:43:19 +00:00
Eric Christopher
e3385811aa Use only one API at a time.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123866 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-20 01:29:23 +00:00
Eric Christopher
38a18261b9 If we can, lower the multiply part of a umulo/smulo call to a libcall
with an invalid type then split the result and perform the overflow check
normally.

Fixes the 32-bit parts of rdar://8622122 and rdar://8774702.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123864 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-20 00:29:24 +00:00
Devang Patel
e449d1f189 Fix debug info for merged global.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123862 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-20 00:02:16 +00:00
Jakob Stoklund Olesen
fc7d775178 Divert Hopfield network debug output. It is very noisy.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123859 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-19 23:14:59 +00:00
Jakob Stoklund Olesen
92e6939d29 Don't accidentally leave small gaps in the live ranges when leaving the active
interval after an instruction. The leaveIntvAfter() method only adds liveness
from the instruction's boundary index to the inserted copy.

Ideally, SplitKit should be smarter about this, perhaps by combining useIntv()
and leaveIntvAfter() into one method that guarantees continuity.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123858 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-19 23:14:56 +00:00
Devang Patel
dacde944bd Fix register address expression. Patch by Ken Dyck.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123856 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-19 23:04:47 +00:00
Jakob Stoklund Olesen
ccdb3fcef9 Implement RAGreedy::splitAroundRegion and remove loop splitting.
Region splitting includes loop splitting as a subset, and it is more generic.
The splitting heuristics for variables that are live in more than one block are
now:

1. Try to create a region that covers multiple basic blocks.
2. Try to create a new live range for each block with multiple uses.
3. Spill.

Steps 2 and 3 are similar to what the standard spiller is doing.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123853 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-19 22:11:48 +00:00
Jakob Stoklund Olesen
b5fa933343 Add RAGreedy methods for splitting live ranges around regions.
Analyze the live range's behavior entering and leaving basic blocks. Compute an
interference pattern for each allocation candidate, and use SpillPlacement to
find an optimal region where that register can be live.

This code is still not enabled.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123774 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-18 21:13:27 +00:00
Jeffrey Yasskin
955ed73d12 Remove unused variables found by gcc-4.6's -Wunused-but-set-variable.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123707 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-18 00:51:23 +00:00
Stuart Hastings
f22432282c Remove checking that prevented overlapping CALLSEQ_START/CALLSEQ_END
ranges, add legalizer support for nested calls.  Necessary for ARM
byval support.  Radar 7662569.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123704 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-18 00:09:27 +00:00
Benjamin Kramer
c9b6a3eb90 Fix an off-by-one error in ctpop combining.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123664 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-17 18:00:28 +00:00
Benjamin Kramer
d822892455 Add a DAGCombine to turn (ctpop x) u< 2 into (x & x-1) == 0.
This shaves off 4 popcounts from the hacked 186.crafty source.

This is enabled even when a native popcount instruction is available. The
combined code is one operation longer but it should be faster nevertheless.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123621 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-17 12:04:57 +00:00
Chris Lattner
b99fdee325 reapply my fix for PR8961 with a tweak to properly handle
multi-instruction sequences like calls.  Many thanks to Jakob for
finding a testcase.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123559 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-16 02:27:38 +00:00
Benjamin Kramer
5df5a22d1a Add an assert so we don't silently miscompile ctpop for bit widths > 128.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123549 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-15 21:19:37 +00:00
Benjamin Kramer
b6516aeef1 Reimplement CTPOP legalization with the "best" algorithm from
http://graphics.stanford.edu/~seander/bithacks.html#CountBitsSetParallel

In a silly microbenchmark on a 65 nm core2 this is 1.5x faster than the old
code in 32 bit mode and about 2x faster in 64 bit mode. It's also a lot shorter,
especially when counting 64 bit population on a 32 bit target.

I hope this is fast enough to replace Kernighan-style counting loops even when
the input is rather sparse.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123547 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-15 20:30:30 +00:00
Ted Kremenek
439ea279a5 Update CMake build.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123491 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-14 22:58:11 +00:00
Dan Gohman
ca5f616769 Delete an assignment to ThisBB which isn't needed, and tidy up some
comments.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123479 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-14 22:26:16 +00:00
Anton Korobeynikov
3965b5e974 Add a possibility to switch between CFI directives- and table-based frame description emission. Currently all the backends use table-based stuff.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123476 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-14 21:58:08 +00:00
Anton Korobeynikov
9a1ef4ef36 Add CFI directives-based frame information emission. Not hooked yet.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123474 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-14 21:57:53 +00:00
Anton Korobeynikov
d7e8ddc501 Split stuff as a preparation for CFI directives-based frame information emission
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123473 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-14 21:57:45 +00:00
Andrew Trick
f697c8a19a Support for precise scheduling of the instruction selection DAG,
disabled in this checkin. Sorry for the large diffs due to
refactoring. New functionality is all guarded by EnableSchedCycles.

Scheduling the isel DAG is inherently imprecise, but we give it a best
effort:
- Added MayReduceRegPressure to allow stalled nodes in the queue only
  if there is a regpressure need.
- Added BUHasStall to allow checking for either dependence stalls due to
  latency or resource stalls due to pipeline hazards.
- Added BUCompareLatency to encapsulate and standardize the heuristics
  for minimizing stall cycles (vs. reducing register pressure).
- Modified the bottom-up heuristic (now in BUCompareLatency) to
  prioritize nodes by their depth rather than height. As long as it
  doesn't stall, height is irrelevant. Depth represents the critical
  path to the DAG root.
- Added hybrid_ls_rr_sort::isReady to filter stalled nodes before
  adding them to the available queue.

Related Cleanup: most of the register reduction routines do not need
to be templates.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123468 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-14 21:11:41 +00:00
Jakob Stoklund Olesen
04223909b7 Try for the third time to teach getFirstTerminator() about debug values.
This time let's rephrase to trick gcc-4.3 into not miscompiling.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123432 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-14 06:33:45 +00:00
Jakob Stoklund Olesen
b6436e5be1 Revert r123419. It still breaks llvm-gcc-i386-linux-selfhost.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123423 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-14 02:12:54 +00:00
Chris Lattner
67d9891690 Set the insertion point correctly for instructions generated by load folding:
they should go *before* the new instruction not after it. 


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123420 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-14 01:33:40 +00:00
Jakob Stoklund Olesen
09befe9036 Try again to teach getFirstTerminator() about debug values.
Fix some callers to better deal with debug values.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123419 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-14 01:17:53 +00:00
Jakob Stoklund Olesen
eea666f216 Better terminator avoidance.
This approach also works when the terminator doesn't have a slot index. (Which
can happen??)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123413 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-13 23:35:53 +00:00
Jakob Stoklund Olesen
a6ada9f725 Temporary workaround for an i386 crash in LiveDebugVariables.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123400 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-13 21:28:55 +00:00
Jakob Stoklund Olesen
4f28c1c714 Teach frame lowering to ignore debug values after the terminators.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123399 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-13 21:28:52 +00:00
Devang Patel
a851fd8cd8 Speculatively revert r123384 to make llvm-gcc-i386-linux-selfhost buildbot happy.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123389 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-13 19:27:50 +00:00
Jakob Stoklund Olesen
64f865ceca Teach MachineBasicBlock::getFirstTerminator to ignore debug values.
It will still return an iterator that points to the first terminator or end(),
but there may be DBG_VALUE instructions following the first terminator.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123384 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-13 18:41:05 +00:00
Dan Gohman
dd11ea4a37 Fix r123346 to handle scalar types too.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123352 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-13 01:06:51 +00:00
Jakob Stoklund Olesen
668c9e31df Add missing space in debug output
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123351 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-13 00:57:35 +00:00
Dan Gohman
b86654385a Apply the patch from PR8958, which allows llc to get slightly
further on the associated testcase before aborting.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123346 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-12 23:56:26 +00:00
Jakob Stoklund Olesen
25dc2268a5 Try again enabling LiveDebugVariables.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123342 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-12 23:36:21 +00:00
Jakob Stoklund Olesen
f0704d28f3 Don't emit a DBG_VALUE for a spill slot that the rewriter decided not to use after all.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123339 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-12 23:14:07 +00:00
Jakob Stoklund Olesen
12a40314a9 Fix braino in dominator tree walk.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123338 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-12 23:14:04 +00:00
Jakob Stoklund Olesen
f203627f21 Sometimes, old virtual registers can linger on DBG_VALUE instructions.
Make sure we don't crash in that case, but simply turn them into %noreg instead.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123335 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-12 22:37:49 +00:00
Jakob Stoklund Olesen
ee547095bb Teach VirtRegRewriter to update slot indexes when erasing instructions.
It was leaving dangling pointers in the slot index maps.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123334 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-12 22:28:51 +00:00
Jakob Stoklund Olesen
7fd747ba24 Annotate VirtRegRewriter debug output with slot indexes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123333 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-12 22:28:48 +00:00
Jakob Stoklund Olesen
fc69c370e1 Verify slot index ordering.
The slot indexes must be monotonically increasing through the function.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123324 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-12 21:27:48 +00:00
Jakob Stoklund Olesen
7bd46dae9c Verify that machine instruction parent pointers are consistent.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123322 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-12 21:27:41 +00:00
Jakob Stoklund Olesen
2df5458535 The world is not ready for LiveDebugVariables yet.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123290 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-11 23:20:33 +00:00
Jakob Stoklund Olesen
a518ccc26a Enable LiveDebugVariables by default.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123282 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-11 22:45:28 +00:00
Jakob Stoklund Olesen
b08773749a Don't insert DBG_VALUE instructions after the first terminator.
For one, MachineBasicBlock::getFirstTerminator() doesn't understand what is
happening, and it also makes sense to have all control flow run through the
DBG_VALUE.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123277 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-11 22:11:16 +00:00
Devang Patel
a36478feac Appropriately truncate debug info range in dwarf output.
This is not yet completely enabled.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123274 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-11 21:42:10 +00:00
Eric Christopher
93c70426f5 Move ExpandAtomic into the integer expansion routines - it's only used there.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123202 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-11 00:36:08 +00:00
Dale Johannesen
97fd9a58de Fix PR 8916 (qv for analysis), at least the immediate problem.
There's an inherent tension in DAGCombine between assuming
that things will be put in canonical form, and the Depth
mechanism that disables transformations when recursion gets
too deep.  It would not surprise me if there's a lot of little
bugs like this one waiting to be discovered.  The mechanism
seems fragile and I'd suggest looking at it from a design viewpoint.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123191 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-10 21:53:07 +00:00
Anton Korobeynikov
16c29b5f28 Rename TargetFrameInfo into TargetFrameLowering. Also, put couple of FIXMEs and fixes here and there.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123170 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-10 12:39:04 +00:00
Chris Lattner
622a11bc07 fit in 80 cols and use MBB::isSuccessor instead of a hand
rolled std::find.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123164 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-10 07:51:31 +00:00
Jakob Stoklund Olesen
c9df025e33 Simplify a bunch of isVirtualRegister() and isPhysicalRegister() logic.
These functions not longer assert when passed 0, but simply return false instead.

No functional change intended.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123155 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-10 02:58:51 +00:00
Jakob Stoklund Olesen
42e9c96392 Remove MachineRegisterInfo::getLastVirtReg(), it was giving wrong results
when no virtual registers have been allocated.

It was only used to resize IndexedMaps, so provide an IndexedMap::resize()
method such that

 Map.grow(MRI.getLastVirtReg());

can be replaced with the simpler

 Map.resize(MRI.getNumVirtRegs());

This works correctly when no virtuals are allocated, and it bypasses the to/from
index conversions.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123130 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-09 21:58:20 +00:00
Chris Lattner
9dddf08eb8 sort this.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123129 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-09 21:31:39 +00:00
Jakob Stoklund Olesen
be97e906e0 Teach TargetRegisterInfo how to cram stack slot indexes in with the virtual and
physical register numbers.

This makes the hack used in LiveInterval official, and lets LiveInterval be
oblivious of stack slots.

The isPhysicalRegister() and isVirtualRegister() predicates don't know about
this, so when a variable may contain a stack slot, isStackSlot() should always
be tested first.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123128 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-09 21:17:37 +00:00
Jakob Stoklund Olesen
2cfa5b4934 Add a forgotten VireReg2IndexFunctor.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123123 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-09 18:58:33 +00:00
Cameron Zwarich
f78df5ebb8 Eliminate some extra hash table lookups.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123115 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-09 10:54:21 +00:00
Cameron Zwarich
e272deed7b Add an informative comment.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123114 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-09 10:32:30 +00:00
Jakob Stoklund Olesen
0804ead404 Simplify LiveDebugVariables by storing MachineOperand copies locations instead
of using a Location class with the same information.

When making a copy of a MachineOperand that was already stored in a
MachineInstr, it is necessary to clear the parent pointer on the copy. Otherwise
the register use-def lists become inconsistent.

Add MachineOperand::clearParent() to do that. An alternative would be a custom
MachineOperand copy constructor that cleared ParentMI. I didn't want to do that
because of the performance impact.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123109 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-09 05:33:21 +00:00
Jakob Stoklund Olesen
00f93fc046 Shrink a BitVector that didn't mean to store bits for all physical registers.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123108 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-09 03:45:44 +00:00
Jakob Stoklund Olesen
4314268128 Replace TargetRegisterInfo::printReg with a PrintReg class that also works without a TRI instance.
Print virtual registers numbered from 0 instead of the arbitrary
FirstVirtualRegister. The first virtual register is printed as %vreg0.
TRI::NoRegister is printed as %noreg.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123107 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-09 03:05:53 +00:00
Jakob Stoklund Olesen
994c727b57 Use IndexedMap for MachineRegisterInfo as well. No functional change.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123106 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-09 03:05:46 +00:00
Jakob Stoklund Olesen
c7d67f90d3 Fix VirtRegMap to use TRI::index2VirtReg and TRI::virtReg2Index instead of
depending on TRI::FirstVirtualRegister.

Also use TRI::printReg instead of printing virtual registers directly.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123101 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-08 23:11:07 +00:00
Jakob Stoklund Olesen
98c5476070 Fix a MachineVerifier loop that probably didn't mean to skip the last two
virtual registers.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123100 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-08 23:11:02 +00:00
Jakob Stoklund Olesen
b421c566f5 Use an IndexedMap for LiveVariables::VirtRegInfo.
Provide MRI::getNumVirtRegs() and TRI::index2VirtReg() functions to allow
iteration over virtual registers without depending on the representation of
virtual register numbers.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123098 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-08 23:10:57 +00:00
Jakob Stoklund Olesen
358de24dc1 Use an IndexedMap for LiveOutRegInfo to hide its dependence on TargetRegisterInfo::FirstVirtualRegister.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123096 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-08 23:10:50 +00:00
Cameron Zwarich
7c88186309 Fix coding style.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123093 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-08 22:36:53 +00:00
Cameron Zwarich
80f6a507d4 Make more passes preserve dominators (or state that they preserve dominators if
they all ready do). This removes two dominator recomputations prior to isel,
which is a 1% improvement in total llc time for 403.gcc.

The only potentially suspect thing is making GCStrategy recompute dominators if
it used a custom lowering strategy.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123064 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-08 17:01:52 +00:00
Evan Cheng
55d4200336 Recognize inline asm 'rev /bin/bash, ' as a bswap intrinsic call.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123048 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-08 01:24:27 +00:00
Evan Cheng
c36b7069b4 Do not model all INLINEASM instructions as having unmodelled side effects.
Instead encode llvm IR level property "HasSideEffects" in an operand (shared
with IsAlignStack). Added MachineInstrs::hasUnmodeledSideEffects() to check
the operand when the instruction is an INLINEASM.

This allows memory instructions to be moved around INLINEASM instructions.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123044 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-07 23:50:32 +00:00
Devang Patel
51a666f0e5 Speculatively revert r123032.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123039 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-07 22:33:41 +00:00
Devang Patel
1dea232624 Appropriately truncate debug info range in dwarf output.
Enable live debug variables pass.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123032 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-07 21:30:41 +00:00
Evan Cheng
30a343aeed DBG_VALUE does not have any side effects; it also makes no sense to mark it cheap as a copy.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123031 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-07 21:08:26 +00:00
Bob Wilson
5e8b833707 Add ARM patterns to match EXTRACT_SUBVECTOR nodes.
Also fix an off-by-one in SelectionDAGBuilder that was preventing shuffle
vectors from being translated to EXTRACT_SUBVECTOR.
Patch by Tim Northover.

The test changes are needed to keep those spill-q tests from testing aligned
spills and restores.  If the only aligned stack objects are spill slots, we
no longer realign the stack frame.  Prior to this patch, an EXTRACT_SUBVECTOR
was legalized by loading from the stack, which created an aligned frame index.
Now, however, there is nothing except the spill slot in the stack frame, so
I added an aligned alloca.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122995 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-07 04:59:04 +00:00
Bob Wilson
67b067d2f9 Fix a comment typo.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122994 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-07 04:58:58 +00:00
Bob Wilson
6736e19f4c Change EXTRACT_SUBVECTOR to require a constant index.
We were never generating any of these nodes with variable indices, and there
was one legalizer function asserting on a non-constant index.  If we ever have
a need to support variable indices, we can add this back again.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122993 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-07 04:58:56 +00:00
Bill Wendling
8d90b7190f Early exit if we don't have invokes. The 'Unwinds' vector isn't modified unless
we have invokes, so there is no functionality change here.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122990 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-07 02:54:45 +00:00
Duncan Sands
d9aa80038f Fix the other problem reported in PR8582. Testcase and patch by
Nadav Rotem.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122983 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-06 23:45:22 +00:00
Eric Christopher
8d93d19076 Add some fairly duplicated code to let type legalization split illegal
typed atomics. This will lower exclusively to libcalls at the moment.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122979 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-06 22:28:56 +00:00
Devang Patel
76a788c886 Emit 128 bit constant.
This fixes PR 8913 crash.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122971 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-06 21:39:25 +00:00
Evan Cheng
0521928ae7 Re-implement r122936 with proper target hooks. Now getMaxStoresPerMemcpy
etc. takes an option OptSize. If OptSize is true, it would return
the inline limit for functions with attribute OptSize.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122952 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-06 06:52:41 +00:00
Evan Cheng
255874ff52 Revert r122936. I'll re-implement the change.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122949 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-06 06:17:53 +00:00
Jakob Stoklund Olesen
19bb35db1f Zap the last two -Wself-assign warnings in llvm.
Simplify RALinScan::DowngradeRegister with TRI::getOverlaps while we are there.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122940 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-06 01:33:22 +00:00
Jakob Stoklund Olesen
8bfe50871f Add the SpillPlacement analysis pass.
This pass precomputes CFG block frequency information that can be used by the
register allocator to find optimal spill code placement.

Given an interference pattern, placeSpills() will compute which basic blocks
should have the current variable enter or exit in a register, and which blocks
prefer the stack.

The algorithm is ready to consume block frequencies from profiling data, but for
now it gets by with the static estimates used for spill weights.

This is a work in progress and still not hooked up to RegAllocGreedy.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122938 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-06 01:21:53 +00:00
Evan Cheng
9a9d847afa r105228 reduced the memcpy / memset inline limit to 4 with -Os to avoid blowing
up freebsd bootloader. However, this doesn't make much sense for Darwin, whose
-Os is meant to optimize for size only if it doesn't hurt performance.
rdar://8821501


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122936 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-06 01:04:47 +00:00
Evan Cheng
d08e5b48bc Avoid zero extend bit test operands to pointer type if all the masks fit in
the original type of the switch statement key.
rdar://8781238


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122935 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-06 01:02:44 +00:00
Evan Cheng
0b71d3972d Optimize:
r1025 = s/zext r1024, 4
  r1026 = extract_subreg r1025, 4
to:
  r1026 = copy r1024


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122925 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-05 23:06:49 +00:00
Jakob Stoklund Olesen
6b705d4825 Add a hidden command line option to display edge bundle graphs as they are
calculated.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122912 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-05 21:50:24 +00:00
Eric Christopher
762a17a040 80-cols.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122909 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-05 21:45:56 +00:00
Eric Christopher
2d31d14bac Remove TODO, these appear to be implemented.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122849 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-04 22:31:50 +00:00
Jakob Stoklund Olesen
8dd070edc2 Turn the EdgeBundles class into a stand-alone machine CFG analysis pass.
The analysis will be needed by both the greedy register allocator and the
X86FloatingPoint pass. It only needs to be computed once when the CFG doesn't
change.

This pass is very fast, usually showing up as 0.0% wall time.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122832 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-04 21:10:05 +00:00
Cameron Zwarich
26db45818a Switch to path halving from path compression for a small speedup. This also
makes getLeader() nonrecursive.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122811 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-04 16:24:51 +00:00
Cameron Zwarich
645b1d2f12 Eliminate repeated allocation of a per-BB DenseMap for a 4.6% reduction of time
spent in StrongPHIElimination on 403.gcc.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122803 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-04 06:42:27 +00:00
Owen Anderson
fa3306af82 Clean up a funky pass registration that got passed over when I got rid of static constructors.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122795 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-04 00:55:21 +00:00
Cameron Zwarich
53eeba586d Use a RecyclingAllocator to allocate values for MachineCSE's ScopedHashTable for
a 28% speedup of MachineCSE time on 403.gcc.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122735 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-03 04:07:46 +00:00
Chris Lattner
9fc5cdf77c split dom frontier handling stuff out to its own DominanceFrontier header,
so that Dominators.h is *just* domtree.  Also prune #includes a bit.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122714 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-02 22:09:33 +00:00
Benjamin Kramer
80220369b0 Try to reuse the value when lowering memset.
This allows us to compile:
  void test(char *s, int a) {
    __builtin_memset(s, a, 15);
  }
into 1 mul + 3 stores instead of 3 muls + 3 stores.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122710 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-02 19:57:05 +00:00
Benjamin Kramer
8c06aa1c59 Lower the i8 extension in memset to a multiply instead of a potentially long series of shifts and ors.
We could implement a DAGCombine to turn x * 0x0101 back into logic operations
on targets that doesn't support the multiply or it is slow (p4) if someone cares
enough.

Example code:
  void test(char *s, int a) {
      __builtin_memset(s, a, 4);
  }
before:
  _test:                                  ## @test
    movzbl  8(%esp), %eax
    movl  %eax, %ecx
    shll  $8, %ecx
    orl %eax, %ecx
    movl  %ecx, %eax
    shll  $16, %eax
    orl %ecx, %eax
    movl  4(%esp), %ecx
    movl  %eax, 4(%ecx)
    movl  %eax, (%ecx)
    ret
after:
  _test:                                  ## @test
    movzbl  8(%esp), %eax
    imull $16843009, %eax, %eax   ## imm = 0x1010101
    movl  4(%esp), %ecx
    movl  %eax, 4(%ecx)
    movl  %eax, (%ecx)
    ret


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122707 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-02 19:44:58 +00:00
Cameron Zwarich
d16ad3e43c Use getVRegDef() instead of def_iterator. This leads to fewer defs being added
with 2-address instructions, for about a 3.5% speedup of StrongPHIElimination on
403.gcc.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122635 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-30 00:42:23 +00:00
Cameron Zwarich
dd061b3177 None of the other pass names in CodeGen have terminating periods.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122628 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-29 11:49:10 +00:00
Cameron Zwarich
1558f5ed19 Instead of processing every instruction when splitting interferences, only
process those instructions that define phi sources. This is a 47% speedup of
StrongPHIElimination compile time on 403.gcc.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122627 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-29 11:00:09 +00:00
Cameron Zwarich
7fb95d4235 Add a missing word to a comment.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122625 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-29 04:42:39 +00:00
Cameron Zwarich
480b80a746 Add text explaining an assertion.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122617 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-29 03:52:51 +00:00
Cameron Zwarich
cb584d08c0 Simplify some code in MachineVerifier that was doing the correct thing, but not
in the most obvious way.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122610 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-28 23:45:38 +00:00
Cameron Zwarich
438e25ccdc Revert the optimization in r122596. It is correct for all current targets, but
it relies on assumptions that may not be true in the future.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122608 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-28 23:02:56 +00:00
Cameron Zwarich
92f0fcb6df Avoid iterating every operand of an instruction in StrongPHIElimination, since
we are only interested in the defs when discovering interferences.

This is a 28% speedup running StrongPHIElimination on 403.gcc.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122596 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-28 10:49:33 +00:00
Duncan Sands
2aea490e16 Pacify the compiler. BestWeight cannot in fact be used uninitialized
in this function, but the compiler was warning that it might be when
doing a release build.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122595 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-28 10:07:15 +00:00
Cameron Zwarich
c3ab20e62e Change an assertion to assert what the code actually relies upon.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122586 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-27 22:08:42 +00:00
Cameron Zwarich
4e7f23b1b6 Land a first cut at StrongPHIElimination. There are only 5 new test failures
when running without the verifier, and I have not yet checked them to see if
the new results are still correct. There are more verifier failures, but they
all seem to be additional occurrences of verifier failures that occur with the
existing PHIElimination pass. There are a few obvious issues with the code:

1) It doesn't properly update the register equivalence classes during copy
insertion, and instead recomputes them before merging live intervals and
renaming registers. I wanted to keep this first patch simple for debugging
purposes, but it shouldn't be very hard to do this.

2) It doesn't mix the renaming and live interval merging with the copy insertion
process, which leads to a lot of virtual register churn. Virtual registers and
live intervals are created, only to later be merged into others. The code should
be smarter and only create a new virtual register if there is no existing
register in the same congruence class.

3) In one place the code uses a DenseMap per basic block, which is unnecessary
heap allocation. There should be an inline storage version of DenseMap.

I did a quick compile-time test of running llc on 403.gcc with and without
StrongPHIElimination. It is slightly slower with StrongPHIElimination, because
the small decrease in the coalescer runtime can't beat the increase in phi
elimination runtime. Perhaps fixing the above performance issues will narrow
the gap.

I also haven't yet run any tests of the quality of the generated code.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122582 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-27 10:08:19 +00:00
Cameron Zwarich
4eee42cb28 Add knowledge of phi-def and phi-kill valnos to MachineVerifier's predecessor
valno verification. The "Different value live out of predecessor" check is
incorrect in the case of phi-def valnos, so just skip that check for phi-def
valnos and instead check that all of the valnos for predecessors have phi-kill.
Fixes PR8863.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122581 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-27 05:17:23 +00:00
Andrew Trick
a75ce9f5d2 Minor cleanup related to my latest scheduler changes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122545 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-24 07:10:19 +00:00
Andrew Trick
24312230ad Fix a few cases where the scheduler is not checking for phys reg copies. The scheduling node may have a NULL DAG node, yuck.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122544 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-24 06:46:50 +00:00
Andrew Trick
2da8bc8a5f Various bits of framework needed for precise machine-level selection
DAG scheduling during isel. Most new functionality is currently
guarded by -enable-sched-cycles and -enable-sched-hazard.

Added InstrItineraryData::IssueWidth field, currently derived from
ARM itineraries, but could be initialized differently on other targets.

Added ScheduleHazardRecognizer::MaxLookAhead to indicate whether it is
active, and if so how many cycles of state it holds.

Added SchedulingPriorityQueue::HasReadyFilter to allowing gating entry
into the scheduler's available queue.

ScoreboardHazardRecognizer now accesses the ScheduleDAG in order to
get information about it's SUnits, provides RecedeCycle for bottom-up
scheduling, correctly computes scoreboard depth, tracks IssueCount, and
considers potential stall cycles when checking for hazards.

ScheduleDAGRRList now models machine cycles and hazards (under
flags). It tracks MinAvailableCycle, drives the hazard recognizer and
priority queue's ready filter, manages a new PendingQueue, properly
accounts for stall cycles, etc.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122541 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-24 05:03:26 +00:00
Andrew Trick
6e8f4c4048 whitespace
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122539 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-24 04:28:06 +00:00
Cameron Zwarich
ef485d8658 Simplify a check for implicit defs and remove a FIXME.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122537 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-24 03:09:36 +00:00
Chris Lattner
29d8f0cae4 flags -> glue for selectiondag
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122509 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-23 17:24:32 +00:00
Chris Lattner
a4359be032 sdisel flag -> glue.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122507 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-23 17:13:18 +00:00
Andrew Trick
2902736a50 Reorganize ListScheduleBottomUp in preparation for modeling machine cycles and instruction issue.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122491 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-23 05:42:20 +00:00
Andrew Trick
3d420cb2fe Converted LiveRegCycles to LiveRegGens. It's easier to work with and allows multiple nodes per cycle.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122474 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-23 04:16:14 +00:00
Andrew Trick
cb7947b81b In CheckForLiveRegDef use TRI->getOverlaps.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122473 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-23 03:43:21 +00:00
Andrew Trick
1b1658741a Fixes PR8823: add-with-overflow-128.ll
In the bottom-up selection DAG scheduling, handle two-address
instructions that read/write unspillable registers. Treat
the entire chain of two-address nodes as a single live range.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122472 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-23 03:15:51 +00:00
Jeffrey Yasskin
8e68c38735 Change all self assignments X=X to (void)X, so that we can turn on a
new gcc warning that complains on self-assignments and
self-initializations.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122458 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-23 00:58:24 +00:00
Benjamin Kramer
f50125ecaa DAGCombine add (sext i1), X into sub X, (zext i1) if sext from i1 is illegal. The latter usually compiles into smaller code.
example code:
unsigned foo(unsigned x, unsigned y) {
  if (x != 0) y--;
  return y;
}

before:
  _foo:                           ## @foo
    cmpl  $1, 4(%esp)             ## encoding: [0x83,0x7c,0x24,0x04,0x01]
    sbbl  %eax, %eax              ## encoding: [0x19,0xc0]
    notl  %eax                    ## encoding: [0xf7,0xd0]
    addl  8(%esp), %eax           ## encoding: [0x03,0x44,0x24,0x08]
    ret                           ## encoding: [0xc3]

after:
  _foo:                           ## @foo
    cmpl  $1, 4(%esp)             ## encoding: [0x83,0x7c,0x24,0x04,0x01]
    movl  8(%esp), %eax           ## encoding: [0x8b,0x44,0x24,0x08]
    adcl  $-1, %eax               ## encoding: [0x83,0xd0,0xff]
    ret                           ## encoding: [0xc3]



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122455 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-22 23:17:45 +00:00
Jakob Stoklund Olesen
770d42de3b When RegAllocGreedy decides to spill the interferences of the current register,
pick the victim with the lowest total spill weight.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122445 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-22 22:01:30 +00:00
Jakob Stoklund Olesen
c64379da07 Include a shadow of the original CFG edges in the edge bundle graph.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122444 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-22 22:01:28 +00:00
Chris Lattner
cbf68dfbc0 Fix a bug in ReduceLoadWidth that wasn't handling extending
loads properly.  We miscompiled the testcase into:

_test:                                  ## @test
	movl	$128, (%rdi)
	movzbl	1(%rdi), %eax
	ret

Now we get a proper:

_test:                                  ## @test
	movl	$128, (%rdi)
	movsbl	(%rdi), %eax
	movzbl	%ah, %eax
	ret

This fixes PR8757.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122392 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-22 08:02:57 +00:00
Chris Lattner
7a2a7faf9c more cleanups, move a check for "roundedness" earlier to reject
unhanded cases faster and simplify code.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122391 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-22 08:01:44 +00:00
Chris Lattner
4c32bc24de reduce indentation and improve comments, no functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122389 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-22 07:36:50 +00:00
Andrew Trick
feac09801b In DelayForLiveRegsBottomUp, handle instructions that read and write
the same physical register. Simplifies the fix from the previous
checkin r122211.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122370 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-21 22:27:44 +00:00
Andrew Trick
38036d8b36 whitespace
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122368 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-21 22:25:04 +00:00
Dale Johannesen
c72b18cdc8 Reapply 122353-122355 with fixes. 122354 was wrong;
the shift type was needed one place, the shift count
type another.  The transform in 123555 had the same
problem.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122366 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-21 21:55:50 +00:00
Dale Johannesen
d0cf2585a0 Revert 122353-122355 for the moment, they broke stuff.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122360 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-21 21:22:27 +00:00
Dale Johannesen
a83bf35d16 Add a new transform to DAGCombiner.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122355 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-21 20:10:51 +00:00
Dale Johannesen
5ecc340e34 Get the type of a shift from the shift, not from its shift
count operand.  These should be the same but apparently are
not always, and this is cleaner anyway.  This improves the
code in an existing test.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122354 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-21 20:06:19 +00:00
Dale Johannesen
efc96dd38c Shift by the word size is invalid IR; don't create it.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122353 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-21 20:00:06 +00:00
Chris Lattner
90b0364cff fix some typos
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122349 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-21 18:05:22 +00:00
Stuart Hastings
56500edc7a Fix indentation, add comment.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122345 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-21 17:16:58 +00:00
Stuart Hastings
2965e69e04 Missing logic for nested CALLSEQ_START/END.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122342 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-21 17:07:24 +00:00
Cameron Zwarich
47bce43229 Incremental progress towards a new implementation of StrongPHIElimination. Most
of the problems with my last attempt were in the updating of LiveIntervals
rather than the coalescing itself. Therefore, I decided to get that right first
by essentially reimplementing the existing PHIElimination using LiveIntervals.

It works correctly, with only a few tests failing (which may not be legitimate
failures) and no new verifier failures (at least as far as I can tell, I didn't
count the number per file).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122321 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-21 06:54:43 +00:00
Chris Lattner
f1b4eafbfe rename MVT::Flag to MVT::Glue. "Flag" is a terrible name for
something that just glues two nodes together, even if it is
sometimes used for flags.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122310 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-21 02:38:05 +00:00
Chris Lattner
5df1578dec improve "cannot yet select" errors a trivial amount: now
they are just as useless, but at least a bit more gramatical


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122305 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-21 02:07:03 +00:00
Jakob Stoklund Olesen
8d0963f72c Add EdgeBundles to SplitKit.
Edge bundles is an annotation on the CFG that turns it into a bipartite directed
graph where each basic block is connected to an outgoing and an ingoing bundle.
These bundles are useful for identifying regions of the CFG for live range
splitting.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122301 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-21 01:50:21 +00:00
Jakob Stoklund Olesen
b907e8a2d4 Use IntEqClasses to compute connected components of live intervals.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122296 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-21 00:48:17 +00:00
Dale Johannesen
025cc6e1be Cosmetic changes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122259 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-20 20:10:50 +00:00
Cameron Zwarich
2100d21f39 MachineVerifier should count landing pad successors as basic blocks rather than
out-edges. Fixes PR8824.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122228 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-20 04:19:48 +00:00
Cameron Zwarich
0b13d7db28 Teach MachineVerifier that early clobber defs begin at USE slots and other defs
begin at DEF slots. Fixes the second half of PR8813.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122225 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-20 03:15:20 +00:00
Cameron Zwarich
5e61f9916e Add a missing check from r122218.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122224 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-20 02:59:51 +00:00
Chris Lattner
5c3d4f0fc9 implement type legalization promotion support for SMULO and UMULO, giving
ARM (and other 32-bit-only) targets support for i8 and i16 overflow 
multiplies.  The generated code isn't great, but this at least fixes
CodeGen/Generic/overflow.ll when running on ARM hosts.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122221 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-20 02:05:39 +00:00
Cameron Zwarich
636f15ff04 Don't assume that an instruction ending a register's live range always reads
the register; it may be a dead def instead. Fixes PR8820.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122218 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-20 01:22:37 +00:00
Chris Lattner
37944985a5 Fix a bug in the scheduler's handling of "unspillable" vregs.
Imagine we see:

EFLAGS = inst1
EFLAGS = inst2 FLAGS
gpr = inst3 EFLAGS

Previously, we would refuse to schedule inst2 because it clobbers
the EFLAGS of the predecessor.  However, it also uses the EFLAGS
of the predecessor, so it is safe to emit.  SDep edges ensure that
the right order happens already anyway.

This fixes 2 testsuite crashes with the X86 patch I'm going to
commit next.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122211 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-20 00:55:43 +00:00
Chris Lattner
142d21c861 the result of CheckForLiveRegDef is dead, remove it.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122209 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-20 00:51:56 +00:00
Chris Lattner
5078293cc2 reduce indentation, no functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122208 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-20 00:50:16 +00:00
Cameron Zwarich
8ec88ba588 Ignore debug values when performing MachineVerifier liveness checks. Fixes
PR8822.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122207 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-20 00:08:10 +00:00
Cameron Zwarich
1b031ddede Early clobber operands are allowed to be defined at use indices. This fixes one
half of PR8813.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122205 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-19 23:50:53 +00:00
Cameron Zwarich
fb69f6037d Fix PR8815 by checking for an explicit clobber def tied to a use operand in
ConnectedVNInfoEqClasses::Classify().


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122202 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-19 22:12:45 +00:00
Cameron Zwarich
22d67cf6ac Fix PR8811 by teaching MachineVerifier about optional defs.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122199 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-19 21:37:23 +00:00
Cameron Zwarich
c44270dd6f StrongPHIElimination will never run before TwoAddressInstructionPass.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122197 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-19 21:32:29 +00:00
Nick Lewycky
476b242fe7 Add missing standard headers. Patch by Joerg Sonnenberger!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122193 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-19 20:43:38 +00:00
Chris Lattner
da60588402 teach MaskedValueIsZero how to analyze ADDE. This is
enough to teach it that ADDE(0,0) is known 0 except the 
low bit, for example.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122191 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-19 20:38:28 +00:00
Cameron Zwarich
d959da92a5 Remove some checks for StrongPHIElim. These checks make it impossible to use an
alternative register allocator that does not require LiveIntervals by specifying
it on the command-line for a target that has StrongPHIElimination enabled by
default.

These checks are pretty meaningless anyways, since StrongPHIElimination and
PHIElimination are never used at the same time.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122176 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-19 18:03:27 +00:00
Chris Lattner
96ba57fdda fix PR8642: if a critical edge has a PHI value that can trap,
isel is *required* to split the edge.  PHI values get evaluated
on the edge, not in their predecessor block.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122170 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-19 04:58:57 +00:00
Jakob Stoklund Olesen
390482569c Apparently, operandices is not a word.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122135 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-18 03:28:32 +00:00
Jakob Stoklund Olesen
83d1ba5728 Teach the inline spiller to attempt folding a load instruction into its single
use before rematerializing the load.

This allows us to produce:

    addps	LCPI0_1(%rip), %xmm2

Instead of:

    movaps	LCPI0_1(%rip), %xmm3
    addps	%xmm3, %xmm2

Saving a register and an instruction. The standard spiller already knows how to
do this.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122133 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-18 03:04:14 +00:00
Jakob Stoklund Olesen
87c6d25c71 Tweak debug spew.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122132 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-18 03:04:11 +00:00
Jakob Stoklund Olesen
dfe3b6d2a9 Check that the register is live-in to the loop header before inserting copies in
the loop predecessors.

The register can be live-out from a predecessor without being live-in to the
loop header if there is a critical edge from the predecessor.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122123 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-18 01:06:19 +00:00
Nick Lewycky
bb1744ec15 Fix GCC warning:
lib/CodeGen/RegAllocGreedy.cpp:311: error: unused variable 'PhysReg' [-Wunused-variable]


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122122 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-18 01:05:55 +00:00
Jakob Stoklund Olesen
89cab93fe9 Pass a Banner argument to the machine code verifier both from
createMachineVerifierPass and MachineFunction::verify.

The banner is printed before the machine code dump, just like the printer pass.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122113 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-18 00:06:56 +00:00
Jakob Stoklund Olesen
8d12140437 Avoid dereferencing end() in collectInterferingVRegs() when there is no
interference.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122108 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-17 23:16:38 +00:00
Jakob Stoklund Olesen
af24964251 Make the -verify-regalloc command line option available to base classes as
RegAllocBase::VerifyEnabled.

Run the machine code verifier in a few interesting places during RegAllocGreedy.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122107 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-17 23:16:35 +00:00
Jakob Stoklund Olesen
f428eb6c1b Enable loop splitting in RegAllocGreedy.
The heuristics split around the largest loop where the current register may be
allocated without interference.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122106 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-17 23:16:32 +00:00
Bill Wendling
976ef86689 During local stack slot allocation, the materializeFrameBaseRegister function
may be called. If the entry block is empty, the insertion point iterator will be
the "end()" value. Calling ->getParent() on it (among others) causes problems.

Modify materializeFrameBaseRegister to take the machine basic block and insert
the frame base register at the beginning of that block. (It's very similar to
what the code does all ready. The only difference is that it will always insert
at the beginning of the entry block instead of after a previous materialization
of the frame base register. I doubt that that matters here.)

<rdar://problem/8782198>


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122104 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-17 23:09:14 +00:00