The old invalidation lattice was incorrect because changes to control flow could cause changes to the
call graph, so we've decided to change the way passes invalidate analysis. In the new scheme, the lattice
is replaced with a list of traits that passes preserve or invalidate. The current traits are Calls and Branches.
Now, passes report which traits they preserve, which is the opposite of the previous implementation where
passes needed to report what they invalidate.
Node: I tried to limit the changes in this commit to mechanical changes to ease the review. I will cleanup some
of the code in a following commit.
Swift SVN r26449
This allows types to be lowered as scalar reference-counted types without requiring them to have AST-level reference semantics. For now, put in a staging assertion to ensure isReferenceCounted == hasReferenceSemantics to make sure we set the bit properly everywhere.
Swift SVN r26238
TerminatorInsts. Now you can walk over the successor list of a terminator
and actually modify the SILSuccessor directly, allowing better CFG
transformations. NFC.
Swift SVN r26140
This is just good to do and hopefully will help prevent people from forgetting
to check in the future by annotating the API explicitly as returning a
potentially nullptr.
Swift SVN r25364
without a valid SILDebugScope. An assertion in IRGenSIL prevents future
optimizations from regressing in this regard.
Introducing SILBuilderWithScope and SILBuilderwithPostprocess to ease the
transition.
This patch is large, but mostly mechanical.
<rdar://problem/18494573> Swift: Debugger is not stopping at the set breakpoint
Swift SVN r22978
Also, only hoist releases into switch regions late in the pipeline.
I made retain sinking more aggressive so that we can move more retains into (and
then hopefully out of) switch regions.
Hoisting releases up into switch regions blocks moving the retains out of the
switch region. To remove retain/releases we would have to iterate between
codemotion and global-arc-opts. Instead just don't move releases into switch
regions until late in the pipeline (the late iteration of the SSAPasses).
This fixes the remaining regressions from the array changes in RC4. And gives
some nice further gains.
-O results speedup(SU) = minbefore/minafter:
TEST``````````SMPL`MIN``MAX```MEAN``SD```MEDIAN`MIN``MAX``MEAN`SD```MEDIAN``SU
Forest````````10```4985`5456``5319``156``5376```4423`4914`4700`169``4789````1.12
ImageProc`````10```7852`7873``7858``6````7857```8260`8272`8264`3````8263````0.95
InsertionSort`10```6098`6109``6104``3````6104```6720`6736`6726`4````6727````0.90
PrimeNum``````10```9202`18296`12514`2690`12368``4098`7552`5953`1164`6319````2.24
Prims`````````10```2058`3486``2787``513``3025```1877`2429`2049`196``2007````1.09
QuickSort`````10```6101`6116``6107``5````6107```6380`6415`6396`11```6398````0.95
RC4```````````10```8639`8684``8655``14```8653```7821`7926`7876`32```7880````1.10
Richards``````10```2243`2254``2249``3````2250```1729`1740`1736`3````1738````1.29
StrToInt``````10```4298`4317``4309``6````4310```4090`4107`4097`6````4098````1.05
StringWalk````10```6478`6511``6486``10```6482```5784`5797`5790`4````5790````1.11
Walsh`````````10```5971`7374``6831``515``7103```4780`4803`4789`7````4788````1.24
InsertionSort: Looking at the profile of insertion sort the regression is not
due to increased retain/release traffic. In fact, it is hard to tell where
those 10% come from.
Quicksort: The quicksort function is identical and takes 95% of the time. Not
clear where the 5% are coming from. It is not extra retain/release traffic
AFAICT.
ImageProc: Same story as InsertionSort.
rdar://17653593
Swift SVN r22694
Simplify binary switches to select_enum instead of enum_is_tag, and make a first attempt at changing passes over to recognize limited forms of select_enum instead of enum_is_tag. There is one case in test/SILPasses/simplify_cfg.sil I wasn't able to figure out, and there are a lot more general passes we could define in terms of select_enum.
Swift SVN r22615
Currently, the pass just calls a local version of that function. After OzU, I
will enable the full pass (which is currently disabled behind a flag).
Swift SVN r21894
This ensures that if we fail to merge the state of one value, we do not
invalidate the enum to enum bb case list map for other values preventing us from
sinking retains out of switch regions.
rdar://18297445
Swift SVN r21860
I also added the enum simplification tests to sil code motion since this change
to sil code motion causes the output from the two passes to diverge on that test
.sil file.
rdar://18027730
Swift SVN r21558
The reason why this is being done is that this eliminates phase ordering issues
between these two sinking passes. Specifically, a retain should be able to move
through multiple iterated switch regions if there are no intervening
instructions that may decrement its ref count. With the passes separate, sil
code motion would move the retain into the switch region until the end of the
switch region. Then it could not move it out of the switch region. Then enum
simplification would move it out of the switch region but would move it no
further. Thus the retain would need to wait for the ARC Optimizer or
SILCodeMotion to move the retain to the next switch. Then enum simplification
could process it again. Thus given the number of times that we iterate, given
enough switches the optimizer would be unable to push the retains.
Now that this has been done, after we move the retain out of the switch region,
we can keep sinking it to the next switch region, move the retain into there,
etc. That work will be done in a later radar.
Given where we are in the schedule I am not going to remove the old enum
simplification pass or combine together the two passes more than crudely so that
(hopefully) cherry-picking will be easier if necessary. I will perform more
indepth combination later.
<rdar://problem/18033238>
Swift SVN r21502
Sinking retains will simply make the unique check useless and eliminate
Array copies even when we need them.
Fix for:
<rdar://problem/18109082> ARC: make _isUniquelyReferenced a barrier to avoid lost copies
Swift SVN r21485
We currently only sink retains to successor BBs.
However, if a retain can't be moved to a successor, we may still want to move it as late in the current BB as
possible. For example, we want retains after called to _swift_isUniquelyReferenced and not before it.
Here are performance numbers for -O. Note that i'm about to commit improvements to enum_is_tag which fixes the
regressions here.
Ackermann``````,``````````1413.00```,`````````````````1566.00```,``````````153.00``,`````````````````-9.8%
ArrayLiteral```,``````````834.00````,`````````````````859.00````,``````````25.00```,`````````````````-2.9%
Ary````````````,``````````1110.00```,`````````````````1121.00```,``````````11.00```,`````````````````-1.0%
Ary2```````````,``````````1092.00```,`````````````````1105.00```,``````````13.00```,`````````````````-1.2%
Ary3```````````,``````````1164.00```,`````````````````1193.00```,``````````29.00```,`````````````````-2.4%
DeltaBlue``````,``````````2195.00```,`````````````````2204.00```,``````````9.00````,`````````````````-0.4%
Dictionary`````,``````````502.00````,`````````````````512.00````,``````````10.00```,`````````````````-2.0%
Dictionary2````,``````````884.00````,`````````````````895.00````,``````````11.00```,`````````````````-1.2%
Dictionary3````,``````````859.00````,`````````````````870.00````,``````````11.00```,`````````````````-1.3%
EditDistance```,``````````1344.00```,`````````````````1344.00```,``````````0.00````,`````````````````0.0%
Fibonacci``````,``````````1382.00```,`````````````````1309.00```,``````````73.00```,`````````````````5.6%
ForLoops```````,``````````1318.00```,`````````````````1324.00```,``````````6.00````,`````````````````-0.5%
Forest`````````,``````````757.00````,`````````````````775.00````,``````````18.00```,`````````````````-2.3%
GlobalClass````,``````````1617.00```,`````````````````1620.00```,``````````3.00````,`````````````````-0.2%
Hash```````````,``````````660.00````,`````````````````718.00````,``````````58.00```,`````````````````-8.1%
HeapSort```````,``````````1256.00```,`````````````````1292.00```,``````````36.00```,`````````````````-2.8%
Histogram``````,``````````313.00````,`````````````````296.00````,``````````17.00```,`````````````````5.7%
InsertionSort``,``````````1223.00```,`````````````````1351.00```,``````````128.00``,`````````````````-9.5%
Life```````````,``````````69.00`````,`````````````````70.00`````,``````````1.00````,`````````````````-1.4%
LinkedList`````,``````````1516.00```,`````````````````1529.00```,``````````13.00```,`````````````````-0.9%
MatMul`````````,``````````224.00````,`````````````````239.00````,``````````15.00```,`````````````````-6.3%
Memset`````````,``````````43.00`````,`````````````````43.00`````,``````````0.00````,`````````````````0.0%
MonteCarloE````,``````````905.00````,`````````````````900.00````,``````````5.00````,`````````````````0.6%
MonteCarloPi```,``````````643.00````,`````````````````654.00````,``````````11.00```,`````````````````-1.7%
NBody``````````,``````````42.00`````,`````````````````41.00`````,``````````1.00````,`````````````````2.4%
NestedLoop`````,``````````931.00````,`````````````````876.00````,``````````55.00```,`````````````````6.3%
NopDeinit``````,``````````1119.00```,`````````````````1117.00```,``````````2.00````,`````````````````0.2%
Phonebook``````,``````````1424.00```,`````````````````1395.00```,``````````29.00```,`````````````````2.1%
PrimeNum```````,``````````214.00````,`````````````````219.00````,``````````5.00````,`````````````````-2.3%
Prims``````````,``````````1182.00```,`````````````````1198.00```,``````````16.00```,`````````````````-1.3%
QuickSort``````,``````````1196.00```,`````````````````1166.00```,``````````30.00```,`````````````````2.6%
R17315246``````,``````````798.00````,`````````````````798.00````,``````````0.00````,`````````````````0.0%
RC4````````````,``````````25.00`````,`````````````````25.00`````,``````````0.00````,`````````````````0.0%
RIPEMD`````````,``````````724.00````,`````````````````746.00````,``````````22.00```,`````````````````-2.9%
Random`````````,``````````960.00````,`````````````````963.00````,``````````3.00````,`````````````````-0.3%
Rectangles`````,``````````836.00````,`````````````````849.00````,``````````13.00```,`````````````````-1.5%
Richards```````,``````````220.00````,`````````````````225.00````,``````````5.00````,`````````````````-2.2%
SelectionSort``,``````````931.00````,`````````````````932.00````,``````````1.00````,`````````````````-0.1%
SmallPT````````,``````````1014.00```,`````````````````1039.00```,``````````25.00```,`````````````````-2.4%
StdlibSort`````,``````````1617.00```,`````````````````1602.00```,``````````15.00```,`````````````````0.9%
StrCat`````````,``````````1061.00```,`````````````````1121.00```,``````````60.00```,`````````````````-5.4%
StrSplitter````,``````````1607.00```,`````````````````1533.00```,``````````74.00```,`````````````````4.8%
StrToInt```````,``````````616.00````,`````````````````612.00````,``````````4.00````,`````````````````0.7%
StringBuilder``,``````````701.00````,`````````````````682.00````,``````````19.00```,`````````````````2.8%
StringWalk`````,``````````1165.00```,`````````````````1182.00```,``````````17.00```,`````````````````-1.4%
Totals`````````,``````````42392.00``,`````````````````42778.00``,``````````386.00``,`````````````````-0.9%
TwoSum`````````,``````````581.00````,`````````````````564.00````,``````````17.00```,`````````````````3.0%
Walsh``````````,``````````105.00````,`````````````````104.00````,``````````1.00````,`````````````````1.0%
Swift SVN r21133
This enables us to pair up retains with releases on the fast path with inline
cache. The run time of rdar://17327077 is down to 0.07s from 0.7s.
We should be able to simplify the code for sinking retains down switch_enum,
now we have the enum simplification.
Thanks Michael for the review.
Swift SVN r19283
This commit reuses utility methods from the ARC optimizer to know if an
instruction can decrement the ref count of a retain_value's operand. If
we can conservatively ascertain that it can not, we can ignore the
instruction for the purposes of determining if we can move the
retain_value into the switch region.
<rdar://problem/17225910>
Swift SVN r18894
This class allows you to deal with tuple and nominal projections in a way that
is agnostic of either of them.
Expect some incoming utilities based off of this for dealing with what I call
'aggregate type trees'.
Swift SVN r13735
Now the pass does not need to know about the pass manager. We also don't have
runOnFunction or runOnModule anymore because the trnasformation knows
which module it is processing. The Pass itself knows how to invalidate the
analysis, based on the injected pass manager that is internal to the
transformation.
Now our DCE transformation looks like this:
class DCE : public SILModuleTransform {
void run() {
performSILDeadCodeElimination(getModule());
invalidateAnalysis(SILAnalysis::InvalidationKind::All);
}
};
Swift SVN r13598