This commit splits DominanceAnalysis into two analysis (Dom and PDom) that
can be cached and invalidates using the common FunctionAnalysisBase interface
independent of one another.
Swift SVN r26643
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
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
For better consistency with other address-only instruction variants, and to open the door to new exciting existential representations (such as a refcounted boxed representation for ErrorType).
Swift SVN r25902
We never run into this case in the stdlib/PerfTestSuite. So for Xcode 6.4, be conservative.
Longer term, I was planning to follow def-use chains through projections.
When we do this, we can also follow projects of loaded values to find any retain points.
That would give us a proper indication of the lifetime of referenced objects.
Fixes <rdar://problem/19724405> [NSObject] as! [NSWindow] sends messages to deallocated __NSArrayI
Swift SVN r25188
If there are any nontrivial issues with this pass, aside from random inlining
noise, we should disable it for Xcode 6.4. This can be verified via:
--extra-swift-args=".;-Xllvm\;enable-copyforwarding=false\;-Xllvm\;-enable-destroyhoisting=false"
This is not enabled at -Onone. We don't currently have a way to
control the optimization without potentially affecting the debugging
experience. People may expect debug values for variables past their
last use.
It looks like this is about a 3% compile time improvement on stdlib-RA
due to reducing SIL early in the pipeline.
Performance:
Most of the big gains with this optimization disappeared when generic
inlining was enabled. This is good, because it means generic inlining
is doing its job. CopyForwarding mainly benefits generic code that
doesn't get inlined. There are still plenty of significant performance
improvements, along with reducing the size of the SIL code early.
The regressions shown below related to inlining heuristics, not the
optimization itself. CopyForwarding is actually a speedup or neutral
in all of these cases when we just increase the inlining threshold. By
reducing the size of the SIL code, inlining decisions are very
different because we use a silly bottom-up threshold approach. I've
been fixing regressions for months in preparation for enabling the
feature, but it's a losing battle. e.g the Ary and PrimeNum
regressions did not exist before generic inlining was enabled this
week. Instead, I'm just tracking the inlining issues, which are in the
process of being fixed.
-O slowdowns
|_RangeAssignment___________|____-81.6%_|
|_Ary_______________________|____-38.7%_|
|_Ary2______________________|____-29.9%_|
|_PrimeNum__________________|____-22.6%_|
|_EditDistance______________|____-13.2%_|
<rdar://problem/19426897> [Inliner] Fail to fully optimize RangeAssignment (especially with copy forwarding)
<rdar://problem/19430635> [Inliner] 2x regression on Ary and Ary2 with copyforwarding
<rdar://problem/19431694> [Inliner] 24% slowdown in PrimeNum with CopyForwarding
<rdar://problem/19432662> [Inliner] 19% slowdown in EditDistance with CopyForwarding
-O speedups
|_Phonebook_______________|_____57.2%_|
|_ProtocolDispatch________|_____36.4%_|
|_SwiftStructuresTrie_____|_____32.5%_|
|_StdlibSort______________|_____27.7%_|
|_StringWalk______________|_____20.4%_|
|_ArrayOfRef______________|_____19.7%_|
|_ArrayOfGenericRef_______|_____18.3%_|
|_JSONHelperDeserialize___|_____14.1%_|
|_DollarFilter____________|_____14.0%_|
|_NSXMLParser_____________|_____13.9%_|
|_CaptureProp_____________|_____12.6%_|
|_Havlak__________________|_____10.7%_|
|_DollarMap_______________|_____10.3%_|
|_SortStrings_____________|______9.5%_|
|_DollarReduce____________|______9.5%_|
|_SwiftStructuresStack____|______9.1%_|
|_NopDeinit_______________|______8.7%_|
|_Dictionary3_____________|______8.6%_|
|_DollarChain_____________|______6.4%_|
|_DollarFunction__________|______5.6%_|
|_StrSplitter_____________|______5.4%_|
|_PolymorphicCalls________|______5.4%_|
|_GenericStack____________|______5.3%_|
|_NSDictionaryImplicitConversion_|______5.4%__|
Possible_improvements,_but_likely_noise:
|_Random__________________|_5.5%_(!)_|
|_RecursiveOwnedParameter_|_5.2%_(!)_|
-Ounchecked slowdowns
|_RangeAssignment______|_-69.4%_|
|_Ary__________________|_-41.8%_|
|_Ary2_________________|_-32.6%_|
|_PopFrontArrayGeneric_|_-14.2%_|
|_EditDistance_________|_-10.3%_|
|_ImageProc____________|__-8.7%_|
|_PrimeNum_____________|__-7.3%_|
<rdar://problem/19433097> [Inliner] 10% slowdown in PopFrontGeneric with CopyForwarding and -Ounchecked
(the rest are covered by -O)
-Ounchecked speedups
|_Phonebook_________________|____53.7%_|
|_SwiftStructuresTrie_______|____25.4%_|
|_ArrayOfGenericRef_________|____25.0%_|
|_ArrayOfRef________________|____23.7%_|
|_StdlibSort________________|____21.7%_|
|_StringWalk________________|____17.9%_|
|_JSONHelperDeserialize_____|____14.1%_|
|_ArrayOfGenericPOD_________|____12.3%_|
|_Havlak____________________|____11.8%_|
|_Dictionary2_______________|____11.6%_|
|_ArrayOfPOD________________|____11.2%_|
|_SortStrings_______________|____10.9%_|
|_DollarReduce______________|____10.5%_|
|_SwiftStructuresStack______|____10.2%_|
|_DollarFilter______________|_____9.5%_|
|_StrComplexWalk____________|_____8.6%_|
|_DeltaBlue_________________|_____8.5%_|
|_StringBuilder_____________|_____7.5%_|
|_SwiftStructuresBubbleSort_|_____6.5%_|
|_Life______________________|_____6.2%_|
|_GenericStack______________|_____6.2%_|
|_ArrayLiteral______________|_____6.2%_|
|_Histogram_________________|_____6.1%_|
|_NSXMLParser_______________|_____5.2%_|
|_StrCat____________________|_____5.0%_|
Swift SVN r24391
isn't used yet, but will be for modeling the self argument passed to an
address-only witness implementation. NFC since all this code is dead :-)
Swift SVN r23857
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
Make sure that we see a "deinit" of the copy and only replace uses in
the same block between the copy and the deinit. This should cover all
the cases I care about but is robust and no longer uses dominance.
While doing this cleanup, I added logic to handle Arnold's cases
where we need backward copy propagation.
This isn't super-pretty, still exposes bugs, and needs tests for the
cases that are actually working.
Swift SVN r22274