summaryrefslogtreecommitdiff
path: root/lib/CodeGen/InlineSpiller.cpp
Commit message (Collapse)AuthorAge
* Add bundle aware API for querying instruction properties and switch the codeEvan Cheng2011-12-07
| | | | | | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@146026 91177308-0d34-0410-b5e6-96231b3b80d8
* Use getVNInfoBefore() when it makes sense.Jakob Stoklund Olesen2011-11-14
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@144517 91177308-0d34-0410-b5e6-96231b3b80d8
* Terminate all dead defs at the dead slot instead of the 'next' slot.Jakob Stoklund Olesen2011-11-13
| | | | | | | | | | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@144512 91177308-0d34-0410-b5e6-96231b3b80d8
* Rename SlotIndexes to match how they are used.Jakob Stoklund Olesen2011-11-13
| | | | | | | | | | | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@144503 91177308-0d34-0410-b5e6-96231b3b80d8
* Stop tracking spill slot uses in VirtRegMap.Jakob Stoklund Olesen2011-11-13
| | | | | | | Nobody cared, StackSlotColoring scans the instructions to find used stack slots. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@144485 91177308-0d34-0410-b5e6-96231b3b80d8
* Strip old implicit operands after foldMemoryOperand.Jakob Stoklund Olesen2011-11-10
| | | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@144247 91177308-0d34-0410-b5e6-96231b3b80d8
* Add value numbers when spilling dead defs.Jakob Stoklund Olesen2011-10-14
| | | | | | | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141923 91177308-0d34-0410-b5e6-96231b3b80d8
* Disable local spill hoisting for non-killing copies.Jakob Stoklund Olesen2011-09-16
| | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139882 91177308-0d34-0410-b5e6-96231b3b80d8
* Add an option to disable spill hoisting.Jakob Stoklund Olesen2011-09-15
| | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139845 91177308-0d34-0410-b5e6-96231b3b80d8
* Count correctly when a COPY turns into a spill or reload.Jakob Stoklund Olesen2011-09-15
| | | | | | | The number of spills could go negative since a folded COPY is just a spill, and it may be eliminated. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139815 91177308-0d34-0410-b5e6-96231b3b80d8
* Count inserted spills and reloads more accurately.Jakob Stoklund Olesen2011-09-15
| | | | | | | | Adjust counters when removing spill and reload instructions. We still don't account for reloads being removed by eliminateDeadDefs(). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139806 91177308-0d34-0410-b5e6-96231b3b80d8
* Trace through sibling PHIs in bulk.Jakob Stoklund Olesen2011-09-15
| | | | | | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139797 91177308-0d34-0410-b5e6-96231b3b80d8
* Reapply r139247: Cache intermediate results during traceSiblingValue.Jakob Stoklund Olesen2011-09-09
| | | | | | | | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139378 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert r139247 "Cache intermediate results during traceSiblingValue."Jakob Stoklund Olesen2011-09-07
| | | | | | It broke the self host and clang-x86_64-darwin10-RA. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139259 91177308-0d34-0410-b5e6-96231b3b80d8
* Cache intermediate results during traceSiblingValue.Jakob Stoklund Olesen2011-09-07
| | | | | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139247 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert r138794, "Do not try to rematerialize a value from a partial definition."Jakob Stoklund Olesen2011-09-01
| | | | | | | | | The problem is fixed for all register allocators by r138944, so this patch is no longer necessary. <rdar://problem/10032939> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@138945 91177308-0d34-0410-b5e6-96231b3b80d8
* Do not try to rematerialize a value from a partial definition.Bob Wilson2011-08-30
| | | | | | | I don't currently have a good testcase for this; will try to get one tomorrow. <rdar://problem/10032939> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@138794 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix PR10387.Jakob Stoklund Olesen2011-07-18
| | | | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135378 91177308-0d34-0410-b5e6-96231b3b80d8
* Oops, didn't mean to commit that.Jakob Stoklund Olesen2011-07-09
| | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@134782 91177308-0d34-0410-b5e6-96231b3b80d8
* Hoist spills within a basic block.Jakob Stoklund Olesen2011-07-09
| | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@134776 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix PR10277.Jakob Stoklund Olesen2011-07-05
| | | | | | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@134413 91177308-0d34-0410-b5e6-96231b3b80d8
* Create a isFullCopy predicate.Rafael Espindola2011-06-30
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@134189 91177308-0d34-0410-b5e6-96231b3b80d8
* Avoid hoisting spills when looking at a copy from another register that is alsoJakob Stoklund Olesen2011-05-11
| | | | | | | | | | | | | 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> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131192 91177308-0d34-0410-b5e6-96231b3b80d8
* Add some statistics to the splitting and spilling frameworks.Jakob Stoklund Olesen2011-05-05
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@130931 91177308-0d34-0410-b5e6-96231b3b80d8
* Avoid using stale entries form the sibling value map.Jakob Stoklund Olesen2011-04-30
| | | | | | | This could happen when trying to use a value that had been eliminated after dead code elimination and folding loads. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@130597 91177308-0d34-0410-b5e6-96231b3b80d8
* Add debug output for rematerializable instructions.Jakob Stoklund Olesen2011-04-20
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129883 91177308-0d34-0410-b5e6-96231b3b80d8
* Handle spilling around an instruction that has an early-clobber re-definition ofJakob Stoklund Olesen2011-04-18
| | | | | | | | the spilled register. This is quite common on ARM now that some stores have early-clobber defines. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129714 91177308-0d34-0410-b5e6-96231b3b80d8
* Pick a conservative register class when creating a small live range for remat.Jakob Stoklund Olesen2011-03-31
| | | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@128610 91177308-0d34-0410-b5e6-96231b3b80d8
* Recompute register class and hint for registers created during spilling.Jakob Stoklund Olesen2011-03-29
| | | | | | The spill weight is not recomputed for an unspillable register - it stays infinite. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@128490 91177308-0d34-0410-b5e6-96231b3b80d8
* Remember to use the correct register when rematerializing for snippets.Jakob Stoklund Olesen2011-03-29
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@128469 91177308-0d34-0410-b5e6-96231b3b80d8
* Run dead code elimination immediately after rematerialization.Jakob Stoklund Olesen2011-03-29
| | | | | | | This may eliminate some uses of the spilled registers, and we don't want to insert reloads for that. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@128468 91177308-0d34-0410-b5e6-96231b3b80d8
* Properly enable rematerialization when spilling after live range splitting.Jakob Stoklund Olesen2011-03-29
| | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@128449 91177308-0d34-0410-b5e6-96231b3b80d8
* Use individual register classes when spilling snippets.Jakob Stoklund Olesen2011-03-26
| | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@128351 91177308-0d34-0410-b5e6-96231b3b80d8
* Also eliminate redundant spills downstream of inserted reloads.Jakob Stoklund Olesen2011-03-20
| | | | | | | This can happen when multiple sibling registers are spilled after live range splitting. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127965 91177308-0d34-0410-b5e6-96231b3b80d8
* Change an argument to a LiveInterval instead of a register number to save ↵Jakob Stoklund Olesen2011-03-20
| | | | | | some redundant lookups. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127964 91177308-0d34-0410-b5e6-96231b3b80d8
* Add debug output.Jakob Stoklund Olesen2011-03-19
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127959 91177308-0d34-0410-b5e6-96231b3b80d8
* Hoist spills when the same value is known to be in less loopy sibling registers.Jakob Stoklund Olesen2011-03-18
| | | | | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127868 91177308-0d34-0410-b5e6-96231b3b80d8
* Dead code elimination may separate the live interval into multiple connected ↵Jakob Stoklund Olesen2011-03-17
| | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127827 91177308-0d34-0410-b5e6-96231b3b80d8
* Trace back through sibling copies to hoist spills and find rematerializable ↵Jakob Stoklund Olesen2011-03-15
| | | | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127698 91177308-0d34-0410-b5e6-96231b3b80d8
* Rename members to match LLVM naming conventions more closely.Jakob Stoklund Olesen2011-03-14
| | | | | | | | Remove the unused reserved_ bit vector, no functional change intended. This doesn't break 'svn blame', this file really is all my fault. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127607 91177308-0d34-0410-b5e6-96231b3b80d8
* Tell the register allocator about new unused virtual registers.Jakob Stoklund Olesen2011-03-13
| | | | | | | This allows the allocator to free any resources used by the virtual register, including physical register assignments. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127560 91177308-0d34-0410-b5e6-96231b3b80d8
* Include snippets in the live stack interval.Jakob Stoklund Olesen2011-03-12
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127530 91177308-0d34-0410-b5e6-96231b3b80d8
* Spill multiple registers at once.Jakob Stoklund Olesen2011-03-12
| | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127529 91177308-0d34-0410-b5e6-96231b3b80d8
* Change the Spiller interface to take a LiveRangeEdit reference.Jakob Stoklund Olesen2011-03-10
| | | | | | | This makes it possible to register delegates and get callbacks when the spiller edits live ranges. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127389 91177308-0d34-0410-b5e6-96231b3b80d8
* Make SpillIs an optional pointer. Avoid creating a bunch of temporary ↵Jakob Stoklund Olesen2011-03-10
| | | | | | SmallVectors. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127388 91177308-0d34-0410-b5e6-96231b3b80d8
* Add a LiveRangeEdit::Delegate protocol.Jakob Stoklund Olesen2011-03-09
| | | | | | | This will we used for keeping register allocator data structures up to date while LiveRangeEdit is trimming live intervals. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127300 91177308-0d34-0410-b5e6-96231b3b80d8
* Make the UselessRegs argument optional in the LiveRangeEdit constructor.Jakob Stoklund Olesen2011-03-07
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127181 91177308-0d34-0410-b5e6-96231b3b80d8
* Use the same spill slot for all live ranges that descend form the same originalJakob Stoklund Olesen2011-02-24
| | | | | | | | | register. This avoids some silly stack slot shuffling when both sides of a copy get spilled. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@126353 91177308-0d34-0410-b5e6-96231b3b80d8
* 80 Col.Jakob Stoklund Olesen2011-02-22
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@126258 91177308-0d34-0410-b5e6-96231b3b80d8
* Set an allocation hint when rematting before a COPY.Jakob Stoklund Olesen2011-02-09
| | | | | | This almost guarantees that the COPY will be coalesced. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@125140 91177308-0d34-0410-b5e6-96231b3b80d8