1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 19:12:56 +02:00
Commit Graph

148 Commits

Author SHA1 Message Date
Pete Cooper
a76a82ef6f Refactored the LiveRangeEdit interface so that MachineFunction, TargetInstrInfo, MachineRegisterInfo, LiveIntervals, and VirtRegMap are all passed into the constructor and stored as members instead of passed in to each method.
llvm-svn: 153903
2012-04-02 22:22:53 +00:00
Jakob Stoklund Olesen
2055fc1331 Make InlineSpiller bundle-aware.
Simply treat bundles as instructions. Spill code is inserted between
bundles, never inside a bundle.  Rewrite all operands in a bundle at
once.

Don't attempt and memory operand folding inside bundles.

llvm-svn: 151787
2012-03-01 01:43:25 +00:00
Jakob Stoklund Olesen
44c5cece20 Don't store COPY pointers in VNInfo.
If a value is defined by a COPY, that instuction can easily and cheaply
be found by getInstructionFromIndex(VNI->def).

This reduces the size of VNInfo from 24 to 16 bytes, and improves
llc compile time by 3%.

llvm-svn: 149763
2012-02-04 05:20:49 +00:00
Pete Cooper
2675c6f8b3 Fixed register allocator splitting a live range on a spilling variable.
If we create new intervals for a variable that is being spilled, then those new intervals are not guaranteed to also spill.  This means that anything reading from the original spilling value might not get the correct value if spills were missed.

Fixes <rdar://problem/10546864>

llvm-svn: 146428
2011-12-12 22:16:27 +00:00
Evan Cheng
1acd685d87 Add bundle aware API for querying instruction properties and switch the code
generator to it. For non-bundle instructions, these behave exactly the same
as the MC layer API.

For properties like mayLoad / mayStore, look into the bundle and if any of the
bundled instructions has the property it would return true.
For properties like isPredicable, only return true if *all* of the bundled
instructions have the property.
For properties like canFoldAsLoad, isCompare, conservatively return false for
bundles.

llvm-svn: 146026
2011-12-07 07:15:52 +00:00
Jakob Stoklund Olesen
25e009690c Use getVNInfoBefore() when it makes sense.
llvm-svn: 144517
2011-11-14 01:39:36 +00:00
Jakob Stoklund Olesen
4255046343 Terminate all dead defs at the dead slot instead of the 'next' slot.
This makes no difference for normal defs, but early clobber dead defs
now look like:

  [Slot_EarlyClobber; Slot_Dead)

instead of:

  [Slot_EarlyClobber; Slot_Register).

Live ranges for normal dead defs look like:

  [Slot_Register; Slot_Dead)

as before.

llvm-svn: 144512
2011-11-13 22:42:13 +00:00
Jakob Stoklund Olesen
9b34607bdf Rename SlotIndexes to match how they are used.
The old naming scheme (load/use/def/store) can be traced back to an old
linear scan article, but the names don't match how slots are actually
used.

The load and store slots are not needed after the deferred spill code
insertion framework was deleted.

The use and def slots don't make any sense because we are using
half-open intervals as is customary in C code, but the names suggest
closed intervals.  In reality, these slots were used to distinguish
early-clobber defs from normal defs.

The new naming scheme also has 4 slots, but the names match how the
slots are really used.  This is a purely mechanical renaming, but some
of the code makes a lot more sense now.

llvm-svn: 144503
2011-11-13 20:45:27 +00:00
Jakob Stoklund Olesen
eb77ff7f7d Stop tracking spill slot uses in VirtRegMap.
Nobody cared, StackSlotColoring scans the instructions to find used stack
slots.

llvm-svn: 144485
2011-11-13 01:23:30 +00:00
Jakob Stoklund Olesen
bc48cd34b6 Strip old implicit operands after foldMemoryOperand.
The TII.foldMemoryOperand hook preserves implicit operands from the
original instruction.  This is not what we want when those implicit
operands refer to the register being spilled.

Implicit operands referring to other registers are preserved.

This fixes PR11347.

llvm-svn: 144247
2011-11-10 00:17:03 +00:00
Jakob Stoklund Olesen
98e48aef6f Add value numbers when spilling dead defs.
When spilling around an instruction with a dead def, remember to add a
value number for the def.

The missing value number wouldn't normally create problems since there
would be an incoming live range as well.  However, due to another bug
we could spill a dead V_SET0 instruction which doesn't read any values.

The missing value number caused an empty live range to be created which
is dangerous since it doesn't interfere with anything.

This fixes part of PR11125.

llvm-svn: 141923
2011-10-14 00:34:31 +00:00
Jakob Stoklund Olesen
9596294e98 Disable local spill hoisting for non-killing copies.
If the source register is live after the copy being spilled, there is no
point to hoisting it.  Hoisting inside a basic block only serves to
resolve interferences by shortening the live range of the source.

llvm-svn: 139882
2011-09-16 00:03:33 +00:00
Jakob Stoklund Olesen
6ccd8e9c0d Add an option to disable spill hoisting.
When -split-spill-mode is enabled, spill hoisting is performed by
SplitKit instead of by InlineSpiller.  This hidden command line option
is for testing the splitter spill mode.

llvm-svn: 139845
2011-09-15 21:06:00 +00:00
Jakob Stoklund Olesen
74cb8c037a Count correctly when a COPY turns into a spill or reload.
The number of spills could go negative since a folded COPY is just a
spill, and it may be eliminated.

llvm-svn: 139815
2011-09-15 18:22:52 +00:00
Jakob Stoklund Olesen
444ae3ddc7 Count inserted spills and reloads more accurately.
Adjust counters when removing spill and reload instructions.

We still don't account for reloads being removed by eliminateDeadDefs().

llvm-svn: 139806
2011-09-15 17:54:28 +00:00
Jakob Stoklund Olesen
f608389173 Trace through sibling PHIs in bulk.
When traceSiblingValue() encounters a PHI-def value created by live
range splitting, don't look at all the predecessor blocks.  That can be
very expensive in a complicated CFG.

Instead, consider that all the non-PHI defs jointly dominate all the
PHI-defs.  Tracing directly to all the non-PHI defs is much faster that
zipping around in the CFG when there are many PHIs with many
predecessors.

This significantly improves compile time for indirectbr interpreters.

llvm-svn: 139797
2011-09-15 16:41:12 +00:00
Jakob Stoklund Olesen
659d713274 Reapply r139247: Cache intermediate results during traceSiblingValue.
In some cases such as interpreters using indirectbr, the CFG can be very
complicated, and live range splitting may be forced to insert a large
number of phi-defs.  When that happens, traceSiblingValue can spend a
lot of time zipping around in the CFG looking for defs and reloads.

This patch causes more information to be cached in SibValues, and the
cached values are used to terminate searches early.  This speeds up
spilling by 20x in one interpreter test case.  For more typical code,
this is just a 10% speedup of spilling.

The previous version had bugs that caused miscompilations. They have
been fixed.

llvm-svn: 139378
2011-09-09 18:11:41 +00:00
Jakob Stoklund Olesen
6853bdde5b Revert r139247 "Cache intermediate results during traceSiblingValue."
It broke the self host and clang-x86_64-darwin10-RA.

llvm-svn: 139259
2011-09-07 21:43:52 +00:00
Jakob Stoklund Olesen
46444bd655 Cache intermediate results during traceSiblingValue.
In some cases such as interpreters using indirectbr, the CFG can be very
complicated, and live range splitting may be forced to insert a large
number of phi-defs.  When that happens, traceSiblingValue can spend a
lot of time zipping around in the CFG looking for defs and reloads.

This patch causes more information to be cached in SibValues, and the
cached values are used to terminate searches early.  This speeds up
spilling by 20x in one interpreter test case.  For more typical code,
this is just a 10% speedup of spilling.

llvm-svn: 139247
2011-09-07 19:07:31 +00:00
Jakob Stoklund Olesen
ff7cf9e336 Revert r138794, "Do not try to rematerialize a value from a partial definition."
The problem is fixed for all register allocators by r138944, so this
patch is no longer necessary.

<rdar://problem/10032939>

llvm-svn: 138945
2011-09-01 17:25:18 +00:00
Bob Wilson
cc7b5b71eb Do not try to rematerialize a value from a partial definition.
I don't currently have a good testcase for this; will try to get one
tomorrow.  <rdar://problem/10032939>

llvm-svn: 138794
2011-08-30 05:36:02 +00:00
Jakob Stoklund Olesen
b19797de85 Fix PR10387.
When trying to rematerialize a value before an instruction that has an
early-clobber redefine of the virtual register, make sure to look up the
correct value number.

Early-clobber defs are moved one slot back, so getBaseIndex is needed to
find the used value number.

Bugpoint was unable to reduce the test case for this, see PR10388.

llvm-svn: 135378
2011-07-18 05:31:59 +00:00
Jakob Stoklund Olesen
aef38c4f35 Oops, didn't mean to commit that.
Spills should be hoisted out of loops, but we don't want to hoist them
to dominating blocks at the same loop depth. That could cause the spills
to be executed more often.

llvm-svn: 134782
2011-07-09 01:02:44 +00:00
Jakob Stoklund Olesen
fe41eb3bda Hoist spills within a basic block.
Try to move spills as early as possible in their basic block. This can
help eliminate interferences by shortening the live range being
spilled.

This fixes PR10221.

llvm-svn: 134776
2011-07-09 00:25:03 +00:00
Jakob Stoklund Olesen
f95a1068bd Fix PR10277.
Remat during spilling triggers dead code elimination. If a phi-def
becomes unused, that may also cause live ranges to split into separate
connected components.

This type of splitting is different from normal live range splitting. In
particular, there may not be a common original interval.

When the split range is its own original, make sure that the new
siblings are also their own originals. The range being split cannot be
used as an original since it doesn't cover the new siblings.

llvm-svn: 134413
2011-07-05 15:38:41 +00:00
Rafael Espindola
83789b3b8d Create a isFullCopy predicate.
llvm-svn: 134189
2011-06-30 21:15:52 +00:00
Jakob Stoklund Olesen
0e9c54a422 Avoid hoisting spills when looking at a copy from another register that is also
about to be spilled.

This can only happen when two extra snippet registers are included in the spill,
and there is a copy between them. Hoisting the spill creates problems because
the hoist will mark the copy for later dead code elimination, and spilling the
second register will turn the copy into a spill.

<rdar://problem/9420853>

llvm-svn: 131192
2011-05-11 18:25:10 +00:00
Jakob Stoklund Olesen
fa1e44c83e Add some statistics to the splitting and spilling frameworks.
llvm-svn: 130931
2011-05-05 17:22:53 +00:00
Jakob Stoklund Olesen
4ec9e1c33a Avoid using stale entries form the sibling value map.
This could happen when trying to use a value that had been eliminated after dead
code elimination and folding loads.

llvm-svn: 130597
2011-04-30 06:42:21 +00:00
Jakob Stoklund Olesen
22089a66fb Add debug output for rematerializable instructions.
llvm-svn: 129883
2011-04-20 22:14:20 +00:00
Jakob Stoklund Olesen
c2f25578a4 Handle spilling around an instruction that has an early-clobber re-definition of
the spilled register.

This is quite common on ARM now that some stores have early-clobber defines.

llvm-svn: 129714
2011-04-18 20:23:27 +00:00
Jakob Stoklund Olesen
e72dfb1c45 Pick a conservative register class when creating a small live range for remat.
The rematerialized instruction may require a more constrained register class
than the register being spilled. In the test case, the spilled register has been
inflated to the DPR register class, but we are rematerializing a load of the
ssub_0 sub-register which only exists for DPR_VFP2 registers.

The register class is reinflated after spilling, so the conservative choice is
only temporary.

llvm-svn: 128610
2011-03-31 03:54:44 +00:00
Jakob Stoklund Olesen
a292fa3d1e Recompute register class and hint for registers created during spilling.
The spill weight is not recomputed for an unspillable register - it stays infinite.

llvm-svn: 128490
2011-03-29 21:20:19 +00:00
Jakob Stoklund Olesen
229e589bd1 Remember to use the correct register when rematerializing for snippets.
llvm-svn: 128469
2011-03-29 17:47:02 +00:00
Jakob Stoklund Olesen
4676323ac8 Run dead code elimination immediately after rematerialization.
This may eliminate some uses of the spilled registers, and we don't want to
insert reloads for that.

llvm-svn: 128468
2011-03-29 17:47:00 +00:00
Jakob Stoklund Olesen
c209e050dd Properly enable rematerialization when spilling after live range splitting.
The instruction to be rematerialized may not be the one defining the register
that is being spilled. The traceSiblingValue() function sees through sibling
copies to find the remat candidate.

llvm-svn: 128449
2011-03-29 03:12:02 +00:00
Jakob Stoklund Olesen
25ff895ebe Use individual register classes when spilling snippets.
The main register class may have been inflated by live range splitting, so that
register class is not necessarily valid for the snippet instructions.

Use the original register class for the stack slot interval.

llvm-svn: 128351
2011-03-26 22:16:41 +00:00
Jakob Stoklund Olesen
6bc47435a9 Also eliminate redundant spills downstream of inserted reloads.
This can happen when multiple sibling registers are spilled after live range
splitting.

llvm-svn: 127965
2011-03-20 05:44:58 +00:00
Jakob Stoklund Olesen
911619d9e2 Change an argument to a LiveInterval instead of a register number to save some redundant lookups.
llvm-svn: 127964
2011-03-20 05:44:55 +00:00
Jakob Stoklund Olesen
bf1a7cb32d Add debug output.
llvm-svn: 127959
2011-03-19 23:02:47 +00:00
Jakob Stoklund Olesen
dbc283787d Hoist spills when the same value is known to be in less loopy sibling registers.
Stack slot real estate is virtually free compared to registers, so it is
advantageous to spill earlier even though the same value is now kept in both a
register and a stack slot.

Also eliminate redundant spills by extending the stack slot live range
underneath reloaded registers.

This can trigger a dead code elimination, removing copies and even reloads that
were only feeding spills.

llvm-svn: 127868
2011-03-18 04:23:06 +00:00
Jakob Stoklund Olesen
047a25b0b0 Dead code elimination may separate the live interval into multiple connected components.
I have convinced myself that it can only happen when a phi value dies. When it
happens, allocate new virtual registers for the components.

llvm-svn: 127827
2011-03-17 20:37:07 +00:00
Jakob Stoklund Olesen
26ac368165 Trace back through sibling copies to hoist spills and find rematerializable defs.
After live range splitting, an original value may be available in multiple
registers. Tracing back through the registers containing the same value, find
the best place to insert a spill, determine if the value has already been
spilled, or discover a reaching def that may be rematerialized.

This is only the analysis part. The information is not used for anything yet.

llvm-svn: 127698
2011-03-15 21:13:25 +00:00
Jakob Stoklund Olesen
da1afc2d80 Rename members to match LLVM naming conventions more closely.
Remove the unused reserved_ bit vector, no functional change intended.

This doesn't break 'svn blame', this file really is all my fault.

llvm-svn: 127607
2011-03-14 19:56:43 +00:00
Jakob Stoklund Olesen
2d87d5139b Tell the register allocator about new unused virtual registers.
This allows the allocator to free any resources used by the virtual register,
including physical register assignments.

llvm-svn: 127560
2011-03-13 01:23:11 +00:00
Jakob Stoklund Olesen
6d02ddbbc3 Include snippets in the live stack interval.
llvm-svn: 127530
2011-03-12 04:25:36 +00:00
Jakob Stoklund Olesen
1f9f236b8a Spill multiple registers at once.
Live range splitting can create a number of small live ranges containing only a
single real use. Spill these small live ranges along with the large range they
are connected to with copies. This enables memory operand folding and maximizes
the spill to fill distance.

Work in progress with known bugs.

llvm-svn: 127529
2011-03-12 04:17:20 +00:00
Jakob Stoklund Olesen
92652a803f Change the Spiller interface to take a LiveRangeEdit reference.
This makes it possible to register delegates and get callbacks when the spiller
edits live ranges.

llvm-svn: 127389
2011-03-10 01:51:42 +00:00
Jakob Stoklund Olesen
70541686bf Make SpillIs an optional pointer. Avoid creating a bunch of temporary SmallVectors.
llvm-svn: 127388
2011-03-10 01:21:58 +00:00
Jakob Stoklund Olesen
eec325fc2f Add a LiveRangeEdit::Delegate protocol.
This will we used for keeping register allocator data structures up to date
while LiveRangeEdit is trimming live intervals.

llvm-svn: 127300
2011-03-09 00:57:29 +00:00
Jakob Stoklund Olesen
158af1f7e9 Make the UselessRegs argument optional in the LiveRangeEdit constructor.
llvm-svn: 127181
2011-03-07 22:42:16 +00:00
Jakob Stoklund Olesen
0f1be641db Use the same spill slot for all live ranges that descend form the same original
register.

This avoids some silly stack slot shuffling when both sides of a copy get
spilled.

llvm-svn: 126353
2011-02-24 01:07:55 +00:00
Jakob Stoklund Olesen
5b9699abdd 80 Col.
llvm-svn: 126258
2011-02-22 23:01:49 +00:00
Jakob Stoklund Olesen
5d66cf0c01 Set an allocation hint when rematting before a COPY.
This almost guarantees that the COPY will be coalesced.

llvm-svn: 125140
2011-02-09 00:25:36 +00:00
Jakob Stoklund Olesen
acdd9ab5ff Avoid folding a load instruction into an instruction that redefines the register.
The target hook doesn't know how to do that. (Neither do I).

llvm-svn: 125108
2011-02-08 19:33:55 +00:00
Jakob Stoklund Olesen
957748e7ac 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.

llvm-svn: 123128
2011-01-09 21:17:37 +00:00
Jakob Stoklund Olesen
bdf06d6c7b Apparently, operandices is not a word.
llvm-svn: 122135
2010-12-18 03:28:32 +00:00
Jakob Stoklund Olesen
e06ded7533 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.

llvm-svn: 122133
2010-12-18 03:04:14 +00:00
Jakob Stoklund Olesen
2879da5e13 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.

llvm-svn: 122113
2010-12-18 00:06:56 +00:00
Jakob Stoklund Olesen
cbd4bac09d Rip out live range splitting support from the inline spiller.
The spiller should only spill. The register allocator will drive live range
splitting, it has the needed information about register pressure and
interferences.

llvm-svn: 121590
2010-12-10 22:54:40 +00:00
Jakob Stoklund Olesen
86fba16eb1 When spilling a register defined by an early clobber, make sure that the new
live ranges for the spill register are also defined at the use slot instead of
the normal def slot.

This fixes PR8612 for the inline spiller. A use was being allocated to the same
register as a spilled early clobber def.

This problem exists in all the spillers. A fix for the standard spiller is
forthcoming.

llvm-svn: 119182
2010-11-15 20:55:49 +00:00
Jakob Stoklund Olesen
6a63cbe06d Hook up AliasAnalysis in InlineSpiller. This is used for rematerializing
constant loads.

llvm-svn: 118741
2010-11-10 23:55:56 +00:00
Andrew Trick
9d60f59b55 RABasic is nearly functionally complete. There are a few remaining
benchmarks hitting an assertion.
Adds LiveIntervalUnion::collectInterferingVRegs.
Fixes "late spilling" by checking for any unspillable live vregs among
all physReg aliases.

llvm-svn: 118701
2010-11-10 19:18:47 +00:00
Jakob Stoklund Olesen
e259b04730 Simplify the LiveRangeEdit::canRematerializeAt() interface a bit.
llvm-svn: 118661
2010-11-10 01:05:12 +00:00
Jakob Stoklund Olesen
aa7acbe740 Disable fancy splitting during spilling unless -extra-spiller-splits is given.
This way, InlineSpiller does the same amount of splitting as the standard
spiller. Splitting should really be guided by the register allocator, and
doesn't belong in the spiller at all.

llvm-svn: 118216
2010-11-04 00:32:32 +00:00
Jakob Stoklund Olesen
7dc4b810ed Tag debug output as regalloc
llvm-svn: 118193
2010-11-03 20:39:23 +00:00
Jakob Stoklund Olesen
66012df062 Don't assign new registers created during a split to the same stack slot, but
give them individual stack slots once the are actually spilled.

llvm-svn: 117945
2010-11-01 19:49:57 +00:00
Jakob Stoklund Olesen
4425035bfd Print out register class of spilled register.
llvm-svn: 117761
2010-10-30 01:26:09 +00:00
Jakob Stoklund Olesen
e446520687 Run a verification pass before any splitting to better distribute blame.
llvm-svn: 117629
2010-10-29 00:40:55 +00:00
Jakob Stoklund Olesen
6f4262448e Make MachineDominators available for SplitEditor. We are going to need it for
proper SSA updating.

This doesn't cause MachineDominators to be recomputed since we are already
requiring MachineLoopInfo which uses dominators as well.

llvm-svn: 117598
2010-10-28 20:34:50 +00:00
Jakob Stoklund Olesen
35f9c58245 Add a temporary command line option to verify machine code after each spill or
split.

llvm-svn: 117597
2010-10-28 20:34:47 +00:00
Jakob Stoklund Olesen
b0c10ed95a InlineSpiller can also update LiveStacks.
llvm-svn: 117338
2010-10-26 00:11:35 +00:00
Jakob Stoklund Olesen
9121d7b293 Move some of the InlineSpiller rematerialization code into LiveRangeEdit.
llvm-svn: 116951
2010-10-20 22:00:51 +00:00
Jakob Stoklund Olesen
5d5bcb8ee4 Move stack slot assignments into LiveRangeEdit.
All registers created during splitting or spilling are assigned to the same
stack slot as the parent register.

When splitting or rematting, we may not spill at all. In that case the stack
slot is still assigned, but it will be dead.

llvm-svn: 116546
2010-10-15 00:16:55 +00:00
Jakob Stoklund Olesen
acca65b973 Create a new LiveRangeEdit class to keep track of the new registers created when
splitting or spillling, and to help with rematerialization.

Use LiveRangeEdit in InlineSpiller and SplitKit. This will eventually make it
possible to share remat code between InlineSpiller and SplitKit.

llvm-svn: 116543
2010-10-14 23:49:52 +00:00
Jakob Stoklund Olesen
8137fd6975 Update SplitEditor API to reflect the fact that the original live interval is
never kept after splitting.

Keeping the original interval made sense when the split region doesn't modify
the register, and the original is spilled. We can get the same effect by
detecting reloaded values when spilling around copies.

llvm-svn: 115695
2010-10-05 22:19:33 +00:00
Lang Hames
d342ada445 Fixed some tests to avoid LiveIntervals::getInstructionFromIndex(..) overhead where possible. Thanks to Jakob for the suggestions.
llvm-svn: 114798
2010-09-26 03:37:09 +00:00
Lang Hames
fb22f00975 Removed VNInfo::isDefAccurate(). Def "accuracy" can be checked by testing whether LiveIntervals::getInstructionFromIndex(def) returns NULL.
llvm-svn: 114791
2010-09-25 12:04:16 +00:00
Jakob Stoklund Olesen
44b77ea344 Clean up the Spiller.h interface.
The earliestStart argument is entirely specific to linear scan allocation, and
can be easily calculated by RegAllocLinearScan.

Replace std::vector with SmallVector.

llvm-svn: 111055
2010-08-13 22:56:53 +00:00
Jakob Stoklund Olesen
70604cb116 Implement splitting inside a single block.
When a live range is contained a single block, we can split it around
instruction clusters. The current approach is very primitive, splitting before
and after the largest gap between uses.

llvm-svn: 111043
2010-08-13 21:18:48 +00:00
Jakob Stoklund Olesen
886eebfa6f Implement single block splitting.
Before spilling a live range, we split it into a separate range for each basic
block where it is used. That way we only get one reload per basic block if the
new smaller ranges can allocate to a register.

This type of splitting is already present in the standard spiller.

llvm-svn: 110934
2010-08-12 17:07:14 +00:00
Jakob Stoklund Olesen
6036d58c40 Avoid editing the current live interval during remat.
The live interval may be used for a spill slot as well, and that spill slot
could be shared by split registers. We cannot shrink it, even if we know the
current register won't need the spill slot in that range.

llvm-svn: 110721
2010-08-10 20:45:07 +00:00
Jakob Stoklund Olesen
6944ea9801 Lazily defer duplicating the live interval we are splitting until we know it is
necessary.

Sometimes, live range splitting doesn't shrink the current interval, but simply
changes some instructions to use a new interval. That makes the original more
suitable for spilling. In this case, we don't need to duplicate the original.

llvm-svn: 110481
2010-08-06 22:17:33 +00:00
Jakob Stoklund Olesen
581c54b1fe Keep the MachiuneFunctionPass pointer around. It is useful for verification.
llvm-svn: 110464
2010-08-06 18:47:06 +00:00
Jakob Stoklund Olesen
dc6e812510 Coalesce stack slot accesses that arise when spilling both sides of a COPY.
This helps avoid silly code:

    %R0<def = LOAD <fi#5>
    STORE <fi#5>, %R0<kill>

llvm-svn: 110266
2010-08-04 22:35:11 +00:00
Jakob Stoklund Olesen
ecaa9f6ba4 Checkpoint SplitKit progress.
We are now at a point where we can split around simple single-entry, single-exit
loops, although still with some bugs.

llvm-svn: 110257
2010-08-04 22:08:39 +00:00
Jakob Stoklund Olesen
2b379c4339 Add SplitEditor to SplitKit. This class will be used to edit live intervals and
rewrite instructions for live range splitting.

Still work in progress.

llvm-svn: 109469
2010-07-26 23:44:11 +00:00
Jakob Stoklund Olesen
2e78d6ed2e Change the createSpiller interface to take a MachineFunctionPass argument.
The spillers can pluck the analyses they need from the pass reference.

Switch some never-null pointers to references.

llvm-svn: 108969
2010-07-20 23:50:15 +00:00
Jakob Stoklund Olesen
03e14d78cd Beginning SplitKit - utility classes for live range splitting.
This is a work in progress. So far we have some basic loop analysis to help
determine where it is useful to split a live range around a loop.

The actual loop splitting code from Splitter.cpp is also going to move in here.

llvm-svn: 108842
2010-07-20 15:41:07 +00:00
Jakob Stoklund Olesen
186d86d916 Spillers may alter MachineLoopInfo when breaking critical edges, so make it
non-const.

llvm-svn: 108734
2010-07-19 18:41:20 +00:00
Jakob Stoklund Olesen
ccd252ca08 Change TII::foldMemoryOperand API to require the machine instruction to be
inserted in a MBB, and return an already inserted MI.

This target API change is necessary to allow foldMemoryOperand to call
storeToStackSlot and loadFromStackSlot when folding a COPY to a stack slot
reference in a target independent way.

The foldMemoryOperandImpl hook is going to change in the same way, but I'll wait
until COPY folding is actually implemented. Most targets only fold copies and
won't need to specialize this hook at all.

llvm-svn: 107991
2010-07-09 17:29:08 +00:00
Jakob Stoklund Olesen
6d64b42774 Remove invalid assert
llvm-svn: 107505
2010-07-02 19:54:47 +00:00
Jakob Stoklund Olesen
d969cfd17f Properly handle debug values during inline spilling.
llvm-svn: 107503
2010-07-02 19:54:40 +00:00
Jakob Stoklund Olesen
fc2900126b Rematerialize as much as possible before inserting spills and reloads.
This allows us to recognize the common case where all uses could be
rematerialized, and no stack slot allocation is necessary.

If some values could be fully rematerialized, remove them from the live range
before allocating a stack slot for the rest.

llvm-svn: 107492
2010-07-02 17:44:57 +00:00
Jakob Stoklund Olesen
860a99c62e Add memory operand folding support to InlineSpiller.
llvm-svn: 107355
2010-07-01 00:13:04 +00:00
Jakob Stoklund Olesen
1cd54efaf9 Add support for rematerialization to InlineSpiller.
llvm-svn: 107351
2010-06-30 23:03:52 +00:00
Jakob Stoklund Olesen
38c76cc88a Remember to track spill slot uses in VirtRegMap when inserting loads and stores.
LocalRewriter::runOnMachineFunction uses this information to mark dead spill
slots.

This means that InlineSpiller now also works for functions that spill.

llvm-svn: 107302
2010-06-30 18:19:08 +00:00
Jakob Stoklund Olesen
8918e475af Begin implementation of an inline spiller.
InlineSpiller inserts loads and spills immediately instead of deferring to
VirtRegMap. This is possible now because SlotIndexes allows instructions to be
inserted and renumbered.

This is work in progress, and is mostly a copy of TrivialSpiller so far. It
works very well for functions that don't require spilling.

llvm-svn: 107227
2010-06-29 23:58:39 +00:00