aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/SplitKit.cpp
AgeCommit message (Collapse)AuthorFilesLines
2011-05-05Add some statistics to the splitting and spilling frameworks.Jakob Stoklund Olesen1-0/+4
llvm-svn: 130931
2011-05-03Gracefully handle invalid live ranges. Fix PR9831.Jakob Stoklund Olesen1-0/+2
Register coalescing can sometimes create live ranges that end in the middle of a basic block without any killing instruction. When SplitKit detects this, it will repair the live range by shrinking it to its uses. Live range splitting also needs to know about this. When the range shrinks so much that it becomes allocatable, live range splitting fails because it can't find a good split point. It is paranoid about making progress, so an allocatable range is considered an error. The coalescer should really not be creating these bad live ranges. They appear when coalescing dead copies. llvm-svn: 130787
2011-05-02Minimize the slot indexes spanned by register ranges created when splitting.Jakob Stoklund Olesen1-2/+7
When an interfering live range ends at a dead slot index between two instructions, make sure that the inserted copy instruction gets a slot index after the dead ones. This makes it possible to avoid the interference. Ideally, there shouldn't be interference ending at a deleted instruction, but physical register coalescing can sometimes do that to sub-registers. This fixes PR9823. llvm-svn: 130687
2011-04-26Add a safe-guard against repeated splitting for some rare cases.Jakob Stoklund Olesen1-0/+23
The number of blocks covered by a live range must be strictly decreasing when splitting, otherwise we can't allow repeated splitting. llvm-svn: 130249
2011-04-21Don't recycle loop variables.Matt Beaumont-Gay1-1/+1
llvm-svn: 129928
2011-04-21Allow allocatable ranges from global live range splitting to be split again.Jakob Stoklund Olesen1-1/+13
These intervals are allocatable immediately after splitting, but they may be evicted because of later splitting. This is rare, but when it happens they should be split again. The remainder intervals that cannot be allocated after splitting still move directly to spilling. SplitEditor::finish can optionally provide a mapping from new live intervals back to the original interval indexes returned by openIntv(). Each original interval index can map to multiple new intervals after connected components have been separated. Dead code elimination may also add existing intervals to the list. The reverse mapping allows the SplitEditor client to treat the new intervals differently depending on the split region they came from. llvm-svn: 129925
2011-04-16Unbreak the MSVC 2010 build.Francois Pichet1-1/+2
For further information on this particular issue see: http://connect.microsoft.com/VisualStudio/feedback/details/520043/error-converting-from-null-to-a-pointer-type-in-std-pair llvm-svn: 129642
2011-04-15Teach the SplitKit blitter to handle multiply defined values as well.Jakob Stoklund Olesen1-85/+183
The transferValues() function can now handle both singly and multiply defined values, as long as the resulting live range is known. Only rematerialized values have their live range recomputed by extendRange(). The updateSSA() function can now insert PHI values in bulk across multiple values in multiple target registers in one pass. The list of blocks received from transferValues() is in layout order which seems to work well for the iterative algorithm. Blocks from extendRange() are still in reverse BFS order, but this function is used so rarely now that it doesn't matter. llvm-svn: 129580
2011-04-13Stop using dead function.Jakob Stoklund Olesen1-11/+0
llvm-svn: 129442
2011-04-12Create new intervals for isolated blocks during region splitting.Jakob Stoklund Olesen1-16/+18
This merges the behavior of splitSingleBlocks into splitAroundRegion, so the RS_Region and RS_Block register stages can be coalesced. That means the leftover intervals after region splitting go directly to spilling instead of a second pass of per-block splitting. llvm-svn: 129379
2011-04-12Add SplitKit API to query and select the current interval being worked on.Jakob Stoklund Olesen1-1/+8
This makes it possible to target multiple registers in one pass. llvm-svn: 129374
2011-04-09Build the Hopfield network incrementally when splitting global live ranges.Jakob Stoklund Olesen1-4/+7
It is common for large live ranges to have few basic blocks with register uses and many live-through blocks without any uses. This approach grows the Hopfield network incrementally around the use blocks, completely avoiding checking interference for some through blocks. llvm-svn: 129188
2011-04-06Analyze blocks with uses separately from live-through blocks without uses.Jakob Stoklund Olesen1-16/+22
About 90% of the relevant blocks are live-through without uses, and the only information required about them is their number. This saves memory and enables later optimizations that need to look at only the use-blocks. llvm-svn: 128985
2011-04-05Sign errorJakob Stoklund Olesen1-1/+1
llvm-svn: 128963
2011-04-05Don't crash when a value is defined after the last split point.Jakob Stoklund Olesen1-1/+2
llvm-svn: 128962
2011-04-05Use std::unique instead of a SmallPtrSet to ensure unique instructions in ↵Jakob Stoklund Olesen1-38/+26
UseSlots. This allows us to always keep the smaller slot for an instruction which is what we want when a register has early clobber defines. Drop the UsingInstrs set and the UsingBlocks map. They are no longer needed. llvm-svn: 128886
2011-04-05Stop precomputing last split points, query the SplitAnalysis cache on demand.Jakob Stoklund Olesen1-9/+4
llvm-svn: 128875
2011-04-05Cache the fairly expensive last split point computation and provide a fastJakob Stoklund Olesen1-10/+36
inlined path for the common case. Most basic blocks don't contain a call that may throw, so the last split point os simply the first terminator. llvm-svn: 128874
2011-04-04Stop caching basic block index ranges now that SlotIndexes can keep up.Jakob Stoklund Olesen1-10/+11
llvm-svn: 128821
2011-03-29Recompute register class and hint for registers created during spilling.Jakob Stoklund Olesen1-9/+1
The spill weight is not recomputed for an unspillable register - it stays infinite. llvm-svn: 128490
2011-03-29Handle the special case when all uses follow the last split point.Jakob Stoklund Olesen1-1/+2
llvm-svn: 128450
2011-03-27Amend debug output.Jakob Stoklund Olesen1-2/+3
llvm-svn: 128398
2011-03-20Process all dead defs after rematerializing during splitting.Jakob Stoklund Olesen1-22/+15
llvm-svn: 127973
2011-03-18Be more accurate about the slot index reading a register when dealing with defsJakob Stoklund Olesen1-4/+20
and early clobbers. Assert when trying to find an undefined value. llvm-svn: 127856
2011-03-17Dead code elimination may separate the live interval into multiple connected ↵Jakob Stoklund Olesen1-4/+4
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-17Rewrite instructions as part of ConnectedVNInfoEqClasses::Distribute.Jakob Stoklund Olesen1-24/+1
llvm-svn: 127779
2011-03-15Preserve both isPHIDef and isDefByCopy bits when copying parent values.Jakob Stoklund Olesen1-5/+4
llvm-svn: 127697
2011-03-08Delete dead code after rematerializing.Jakob Stoklund Olesen1-1/+37
LiveRangeEdit::eliminateDeadDefs() will eventually be used by coalescing, splitting, and spilling for dead code elimination. It can delete chains of dead instructions as long as there are no dependency loops. llvm-svn: 127287
2011-03-05Work around a coalescer bug.Jakob Stoklund Olesen1-3/+22
The coalescer can in very rare cases leave too large live intervals around after rematerializing cheap-as-a-move instructions. Linear scan doesn't really care, but live range splitting gets very confused when a live range is killed by a ghost instruction. I will fix this properly in the coalescer after 2.9 branches. llvm-svn: 127096
2011-03-04Tweak debug output. No functional changes.Jakob Stoklund Olesen1-9/+0
llvm-svn: 127006
2011-03-04Use an IndexedMap instead of a DenseMap for the live-out cache.Jakob Stoklund Olesen1-47/+40
This speeds up updateSSA() so it only accounts for 5% of the live range splitting time. llvm-svn: 126972
2011-03-03Cache basic block bounds instead of asking SlotIndexes::getMBBRange all the ↵Jakob Stoklund Olesen1-11/+10
time. This speeds up the greedy register allocator by 15%. DenseMap is not as fast as one might hope. llvm-svn: 126921
2011-03-03Change the SplitEditor interface to a single instance can be shared for ↵Jakob Stoklund Olesen1-4/+11
multiple splits. llvm-svn: 126912
2011-03-03Only run the updateSSA loop when we have actually seen multiple values.Jakob Stoklund Olesen1-3/+23
When only a single value has been seen, new PHIDefs are never needed. llvm-svn: 126911
2011-03-02Turn the Edit member into a pointer so it can change dynamically.Jakob Stoklund Olesen1-43/+43
No functional change. llvm-svn: 126898
2011-03-02Transfer simply defined values directly without recomputing liveness and SSA.Jakob Stoklund Olesen1-24/+66
Values that map to a single new value in a new interval after splitting don't need new PHIDefs, and if the parent value was never rematerialized the live range will be the same. llvm-svn: 126894
2011-03-02Extract a method. No functional change.Jakob Stoklund Olesen1-27/+24
llvm-svn: 126893
2011-03-02Move extendRange() into SplitEditor and delete the LiveRangeMap class.Jakob Stoklund Olesen1-176/+135
Extract the updateSSA() method from the too long extendRange(). LiveOutCache can be shared among all the new intervals since there is at most one of the new ranges live out from each basic block. llvm-svn: 126818
2011-03-02Rename mapValue to extendRange because that is its function now.Jakob Stoklund Olesen1-20/+9
Simplify the signature - The return value and ParentVNI are no longer needed. llvm-svn: 126809
2011-03-02Move LiveIntervalMap::extendTo into LiveInterval itself.Jakob Stoklund Olesen1-19/+5
This method could probably be used by LiveIntervalAnalysis::shrinkToUses, and now it can use extendIntervalEndTo() which coalesces ranges. llvm-svn: 126803
2011-03-01Delete dead code.Jakob Stoklund Olesen1-59/+0
llvm-svn: 126801
2011-03-01Move the value map from LiveIntervalMap to SplitEditor.Jakob Stoklund Olesen1-58/+61
The value map is currently not used, all values are 'complex mapped' and LiveIntervalMap::mapValue is used to dig them out. This is the first step in a series changes leading to the removal of LiveIntervalMap. Its data structures can be shared among all the live intervals created by a split, so it is wasteful to create a copy for each. llvm-svn: 126800
2011-03-01Delete dead code.Jakob Stoklund Olesen1-69/+0
Local live range splitting is better driven by interference. This code was just guessing. llvm-svn: 126799
2011-02-23It is safe to ignore LastSplitPoint when the variable is not live out.Jakob Stoklund Olesen1-2/+2
No code will be inserted after the split point anyway. llvm-svn: 126319
2011-02-21Add SplitKit::isOriginalEndpoint and use it to force live range splitting to ↵Jakob Stoklund Olesen1-0/+14
terminate. An original endpoint is an instruction that killed or defined the original live range before any live ranges were split. When splitting global live ranges, avoid creating local live ranges without any original endpoints. We may still create global live ranges without original endpoints, but such a range won't be split again, and live range splitting still terminates. llvm-svn: 126151
2011-02-19Give SplitAnalysis a VRM member to access VirtRegMap::getOriginal().Jakob Stoklund Olesen1-3/+4
llvm-svn: 126005
2011-02-19Missed member rename for naming convention.Jakob Stoklund Olesen1-7/+7
llvm-svn: 126003
2011-02-09Delete unused code for analyzing and splitting around loops.Jakob Stoklund Olesen1-315/+2
Loop splitting is better handled by the more generic global region splitting based on the edge bundle graph. llvm-svn: 125243
2011-02-09Use the LiveBLocks array for SplitEditor::splitSingleBlocks() as well.Jakob Stoklund Olesen1-44/+43
This fixes a bug where splitSingleBlocks() could split a live range after a terminator instruction. llvm-svn: 125237
2011-02-09Move calcLiveBlockInfo() and the BlockInfo struct into SplitAnalysis.Jakob Stoklund Olesen1-0/+86
No functional changes intended. llvm-svn: 125231