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

135 Commits

Author SHA1 Message Date
Jakob Stoklund Olesen
bdd6204582 Teach the SplitKit blitter to handle multiply defined values as well.
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-15 17:24:49 +00:00
Jakob Stoklund Olesen
d7db076abc Stop using dead function.
llvm-svn: 129442
2011-04-13 15:00:11 +00:00
Jakob Stoklund Olesen
1db776a52e Create new intervals for isolated blocks during region splitting.
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-12 19:32:53 +00:00
Jakob Stoklund Olesen
33a5706748 Add SplitKit API to query and select the current interval being worked on.
This makes it possible to target multiple registers in one pass.

llvm-svn: 129374
2011-04-12 18:11:31 +00:00
Jakob Stoklund Olesen
5add6d16b7 Build the Hopfield network incrementally when splitting global live ranges.
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-09 02:59:09 +00:00
Jakob Stoklund Olesen
bb79ab5ba3 Analyze blocks with uses separately from live-through blocks without uses.
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-06 03:57:00 +00:00
Jakob Stoklund Olesen
50ab0391d7 Sign error
llvm-svn: 128963
2011-04-05 23:43:16 +00:00
Jakob Stoklund Olesen
2bba415e6f Don't crash when a value is defined after the last split point.
llvm-svn: 128962
2011-04-05 23:43:14 +00:00
Jakob Stoklund Olesen
731b0d77a2 Use std::unique instead of a SmallPtrSet to ensure unique instructions in 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-05 15:18:18 +00:00
Jakob Stoklund Olesen
6bd6e03755 Stop precomputing last split points, query the SplitAnalysis cache on demand.
llvm-svn: 128875
2011-04-05 04:20:29 +00:00
Jakob Stoklund Olesen
65c8f18b8d Cache the fairly expensive last split point computation and provide a fast
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-05 04:20:27 +00:00
Jakob Stoklund Olesen
78d65c6632 Stop caching basic block index ranges now that SlotIndexes can keep up.
llvm-svn: 128821
2011-04-04 15:32:15 +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
a92d74e8cb Handle the special case when all uses follow the last split point.
llvm-svn: 128450
2011-03-29 03:12:04 +00:00
Jakob Stoklund Olesen
18eaae730c Amend debug output.
llvm-svn: 128398
2011-03-27 22:49:23 +00:00
Jakob Stoklund Olesen
7f9de06cc4 Process all dead defs after rematerializing during splitting.
llvm-svn: 127973
2011-03-20 19:46:23 +00:00
Jakob Stoklund Olesen
08bfed9973 Be more accurate about the slot index reading a register when dealing with defs
and early clobbers.

Assert when trying to find an undefined value.

llvm-svn: 127856
2011-03-18 03:06:02 +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
2786187b43 Rewrite instructions as part of ConnectedVNInfoEqClasses::Distribute.
llvm-svn: 127779
2011-03-17 00:23:45 +00:00
Jakob Stoklund Olesen
992adc7152 Preserve both isPHIDef and isDefByCopy bits when copying parent values.
llvm-svn: 127697
2011-03-15 21:13:22 +00:00
Jakob Stoklund Olesen
b8f5f15468 Delete dead code after rematerializing.
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-08 22:46:11 +00:00
Jakob Stoklund Olesen
1d0ca5680a Work around a coalescer bug.
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-05 18:33:49 +00:00
Jakob Stoklund Olesen
c3193f4aa8 Tweak debug output. No functional changes.
llvm-svn: 127006
2011-03-04 18:08:26 +00:00
Jakob Stoklund Olesen
5bc7a96cca Use an IndexedMap instead of a DenseMap for the live-out cache.
This speeds up updateSSA() so it only accounts for 5% of the live range
splitting time.

llvm-svn: 126972
2011-03-04 00:15:36 +00:00
Jakob Stoklund Olesen
2759a169ea Cache basic block bounds instead of asking SlotIndexes::getMBBRange all the time.
This speeds up the greedy register allocator by 15%.
DenseMap is not as fast as one might hope.

llvm-svn: 126921
2011-03-03 03:41:29 +00:00
Jakob Stoklund Olesen
09a1939164 Change the SplitEditor interface to a single instance can be shared for multiple splits.
llvm-svn: 126912
2011-03-03 01:29:13 +00:00
Jakob Stoklund Olesen
df789f852e Only run the updateSSA loop when we have actually seen multiple values.
When only a single value has been seen, new PHIDefs are never needed.

llvm-svn: 126911
2011-03-03 01:29:10 +00:00
Jakob Stoklund Olesen
c5dc2c61fc Turn the Edit member into a pointer so it can change dynamically.
No functional change.

llvm-svn: 126898
2011-03-02 23:31:50 +00:00
Jakob Stoklund Olesen
9697ef837c Transfer simply defined values directly without recomputing liveness and SSA.
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-02 23:05:19 +00:00
Jakob Stoklund Olesen
22469169cd Extract a method. No functional change.
llvm-svn: 126893
2011-03-02 23:05:16 +00:00
Jakob Stoklund Olesen
6751d65fd6 Move extendRange() into SplitEditor and delete the LiveRangeMap class.
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-02 01:59:34 +00:00
Jakob Stoklund Olesen
a6fd3b66b0 Rename mapValue to extendRange because that is its function now.
Simplify the signature - The return value and ParentVNI are no longer needed.

llvm-svn: 126809
2011-03-02 00:49:28 +00:00
Jakob Stoklund Olesen
4d3c996555 Move LiveIntervalMap::extendTo into LiveInterval itself.
This method could probably be used by LiveIntervalAnalysis::shrinkToUses, and
now it can use extendIntervalEndTo() which coalesces ranges.

llvm-svn: 126803
2011-03-02 00:06:15 +00:00
Jakob Stoklund Olesen
4f3da0eab4 Delete dead code.
llvm-svn: 126801
2011-03-01 23:24:19 +00:00
Jakob Stoklund Olesen
15d9bf0424 Move the value map from LiveIntervalMap to SplitEditor.
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-01 23:14:53 +00:00
Jakob Stoklund Olesen
13b552560b Delete dead code.
Local live range splitting is better driven by interference. This code was just
guessing.

llvm-svn: 126799
2011-03-01 23:14:50 +00:00
Jakob Stoklund Olesen
5edc1f287b It is safe to ignore LastSplitPoint when the variable is not live out.
No code will be inserted after the split point anyway.

llvm-svn: 126319
2011-02-23 18:26:31 +00:00
Jakob Stoklund Olesen
508829f1d1 Add SplitKit::isOriginalEndpoint and use it to force live range splitting to 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-21 23:09:46 +00:00
Jakob Stoklund Olesen
e2833bf683 Give SplitAnalysis a VRM member to access VirtRegMap::getOriginal().
llvm-svn: 126005
2011-02-19 00:53:42 +00:00
Jakob Stoklund Olesen
45ba3718d4 Missed member rename for naming convention.
llvm-svn: 126003
2011-02-19 00:42:33 +00:00
Jakob Stoklund Olesen
52f108703d Delete unused code for analyzing and splitting around loops.
Loop splitting is better handled by the more generic global region splitting
based on the edge bundle graph.

llvm-svn: 125243
2011-02-09 23:56:18 +00:00
Jakob Stoklund Olesen
2205510f0c Use the LiveBLocks array for SplitEditor::splitSingleBlocks() as well.
This fixes a bug where splitSingleBlocks() could split a live range after a
terminator instruction.

llvm-svn: 125237
2011-02-09 23:30:25 +00:00
Jakob Stoklund Olesen
21624a745c Move calcLiveBlockInfo() and the BlockInfo struct into SplitAnalysis.
No functional changes intended.

llvm-svn: 125231
2011-02-09 22:50:26 +00:00
Jakob Stoklund Olesen
5c13598fd7 Ignore <undef> uses when analyzing and rewriting.
llvm-svn: 125226
2011-02-09 21:52:09 +00:00
Jakob Stoklund Olesen
d5ad17c42b Add SplitEditor::overlapIntv() to create small ranges where both registers are live.
If a live range is used by a terminator instruction, and that live range needs
to leave the block on the stack or in a different register, it can be necessary
to have both sides of the split live at the terminator instruction.

Example:

  %vreg2 = COPY %vreg1
  JMP %vreg1

Becomes after spilling %vreg2:

  SPILL %vreg1
  JMP %vreg1

The spill doesn't kill the register as is normally the case.

llvm-svn: 125102
2011-02-08 18:50:21 +00:00
Jakob Stoklund Olesen
5a0048302f Add assertion.
llvm-svn: 125101
2011-02-08 18:50:18 +00:00
Jakob Stoklund Olesen
bf833680ec 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.

llvm-svn: 124894
2011-02-04 19:33:11 +00:00
Jakob Stoklund Olesen
097e61e40f Skip unused values.
llvm-svn: 124842
2011-02-04 00:59:23 +00:00
Jakob Stoklund Olesen
1451898887 Add debug output and asserts to the phi-connecting code.
llvm-svn: 124813
2011-02-03 20:29:39 +00:00
Jakob Stoklund Olesen
eb29913703 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.

llvm-svn: 124812
2011-02-03 20:29:36 +00:00