Commit Graph

89 Commits

Author SHA1 Message Date
practicalswift
50baf2e53b Use consistent formatting in top of file headers. 2016-01-04 02:17:48 +01:00
practicalswift
6c32688275 Fix recently introduced typos. 2016-01-03 21:16:23 +01:00
Xin Tong
4ea79fec2b There are simply too many locations and too many basic blocks in some
functions for dead store elimination to handle.  In the worst case, The number of
memory behavior or alias queries we need to do is roughly linear to
the # BBs x(times) # of locations.

Put in some heuristic to trade off accuracy for compilation time.

NOTE: we are not disabling DSE for these offending functions. instead we are running
a one iteration pessimistic data flow as supposed to the multiple iteration optimistic
data flow we've done previously.

With this change. I see compilation time on StdlibUnitTest drops significantly.
50%+ drop in time spent in DSE in StdlibUnit with a release compiler.

I will update more Instruments data post-commit once i get close to my desktop.

I see a slight drop in # of dead stores (DS) elimination in stdlib and stdlibUnit test.

stdlib: 203 DS -> 202 DS. (RLE is affected slightly as well. 6313 -> 6295 RL).

stdlibunittest :  43 DS -> 42. (RLE is not affected).

We are passing all existing dead store tests.
2016-01-03 10:48:02 -08:00
Xin Tong
013d08d439 Add a bailout location # threshold in DSE.
In StdlibUnitTest, there is this function that has too many (2450) LSLocations
and the data flow in DSE takes too long to converge.

StdlibUnittest.TestSuite.(addForwardRangeReplaceableCollectionTests <A, B where A: Swift.RangeReplaceableCollectionType, B: Swift.RangeReplaceableCollectionType, A.SubSequence: Swift.CollectionType, B.Generator.Element: Swift.Equatable, A.SubSequence == A.SubSequence.SubSequence, A.Generator.Element == A.SubSequence.Generator.Element> (Swift.String, makeCollection : ([A.Generator.Element]) -> A, wrapValue : (StdlibUnittest.OpaqueValue<Swift.Int>) -> A.Generator.Element, extractValue : (A.Generator.Element) -> StdlibUnittest.OpaqueValue<Swift.Int>, makeCollectionOfEquatable : ([B.Generator.Element]) -> B, wrapValueIntoEquatable : (StdlibUnittest.MinimalEquatableValue) -> B.Generator.Element, extractValueFromEquatable : (B.Generator.Element) -> StdlibUnittest.MinimalEquatableValue, checksAdded : StdlibUnittest.Box<Swift.Set<Swift.String>>, resiliencyChecks : StdlibUnittest.CollectionMisuseResiliencyChecks, outOfBoundsIndexOffset : Swift.Int) -> ()).(closure #18)

This function alone takes ~20% of the total amount of time spent in DSE in StdlibUnitTest.

And DSE does not eliminate any dead store in the function either. I added this threshold
to abort on functions that have too many LSLocations.

I see no difference in # of dead store eliminated in the Stdlib.
2016-01-02 17:37:53 -08:00
Xin Tong
310f48eab0 Improve dead store elimination compilation time.
If we know a function is not a one iteration function which means its
its BBWriteSetIn and BBWriteSetOut have been computed and converged,
and a basic block does not even have StoreInsts, there is no point
in processing every instruction in the last iteration of the data flow
again as no store will be eliminated.

We can simply skip the basic block and rely on the converged BBWriteSetIn
to process its predecessors.

Compilation time improvement: 1.7% to 1.5% of overall compilation time.
on stdlib -O. This represents a 4.0% of all SILOptimzations(37.2%)

Existing tests ensure correctness.
2016-01-01 10:16:42 -08:00
Zach Panzarino
e3a4147ac9 Update copyright date 2015-12-31 23:28:40 +00:00
practicalswift
6dac32e416 Fix typos in code merged today 2015-12-29 23:19:48 +01:00
Xin Tong
be4bf816bd Update some comments and rename runIterativeDF -> runIterativeDSE,
mergeSuccessorStates -> mergeSuccessorLiveIns in DSE. Also fix some includes.
2015-12-29 10:13:02 -08:00
Xin Tong
7c43b47bd0 revert some WIP code 2015-12-28 14:41:16 -08:00
Xin Tong
0c05064429 Speculative disable escape analysis in local variable DSE. There is test case failure
on the real device, but not on simulators. The failure could be a result of this change.
2015-12-28 14:39:54 -08:00
Xin Tong
7e49985b00 Turn a function into early exit sytle. NFC 2015-12-27 17:35:24 -08:00
Xin Tong
656894567f Some of the functions do not really need the iterative data flow in DSE. i.e. for function
of which a single post-order would be enough for DSE. In this case, we do not really
need to compute the genset and killset (which is a costly operation).

On stdlib, i see 93% of the functions are "OneIterationFunction".

With this change, i see the compilation time of DSE drops from 2.0% to 1.7% of the entire compilation.
This represents 4.3% of all the time spent in SILOptimizations (39.5%).
2015-12-26 20:33:35 -08:00
Chris Lattner
bee0d955ff Merge pull request #784 from practicalswift/a-vs-an-again
Fix typos: "a" vs. "an"
2015-12-26 17:45:36 -08:00
Xin Tong
173fc871ff Use a SmallBitVector instead of BitVector in DSE. I observed that most functions
do not have over 64 locations which makes SmallBitVector a more suitable choice
than BitVector.

I see a ~10% drop in compilation time in DSE. i.e. 1430ms to 1270ms (2.2% to 2.0% of
overall compilation time).
2015-12-26 12:30:49 -08:00
Xin Tong
8be2c51875 Merge 2 steps in data flow in DSE into 1. The more we iterate over the instructions in the function,
the more compilation time DSE take.

I see a ~10% drop in DSE compilation time, from 2.4% to 2.2%.

(Last time (~1 week ago) i checked DSE was taking 1.4% of the compilation time.  Now its taking 2.2%.
I will look into where the increase come from later).
2015-12-26 11:06:52 -08:00
practicalswift
fa0b339a21 Fix typos. 2015-12-26 17:51:59 +01:00
practicalswift
22e10737e2 Fix typos 2015-12-26 01:19:40 +01:00
Xin Tong
ed7ef800ab More refactoring in DSE. Split 1 more function and update some comments. 2015-12-24 16:11:19 -08:00
Xin Tong
30ed2f15aa Move local variable store checks into helper function. NFC 2015-12-24 15:26:37 -08:00
Xin Tong
1dd13b5d92 Optimize how basic blocks are processed in DSE. I do not see a real compilation time improvement 2015-12-24 15:10:39 -08:00
Xin Tong
6a942d2d20 Split bigger functions into multiple smaller functions in DSE. NFC 2015-12-24 14:58:44 -08:00
Xin Tong
32dc903339 Enable local variable dead store elimination
If a variable can not escape the function, we mark the store to it as dead before
the function exits.

It was disabled due to some TBAA and side-effect analysis changes.

We were removing 8 dead stores on the stdlib. With this change, we are now removing
203 dead stores.

I only see noise-level performance difference on PerfTestSuite.

I do not see real increase on compilation time either.
2015-12-24 14:18:36 -08:00
Erik Eckstein
dd204e68ef DSE: Use escape analysis for checking if memory locations are dead at the end of a function.
Currently NFC as local DSE is still disabled.
2015-12-23 16:43:11 -08:00
ken0nek
fcd8fcee91 Convert [Cc]an not -> [Cc]annot 2015-12-23 00:55:48 +09:00
Xin Tong
a95e25c887 Refactor in DSE
1. Add some comments regarding how the pass builds and uses genset and killset
2. Merge some similar functions.
3. Rename DSEComputeKind to DSEKind.
4. Some other small comment changes.
2015-12-20 14:19:47 -08:00
Xin Tong
cb94f5fdd1 Update some comments and remove dead code in dead store elimination 2015-12-18 10:18:36 -08:00
Xin Tong
4491d86dc3 Optimize how gen and kill sets are computed in dead store elimination. Existing tests ensure correctness 2015-12-18 09:50:48 -08:00
Dmitri Gribenko
6a66b3cff8 Merge pull request #561 from practicalswift/typos-again
[Typo] Replace PR#514-525 with one large PR
2015-12-18 03:37:02 -08:00
practicalswift
8ab8847684 Fix typos. 2015-12-16 22:09:32 +01:00
Xin Tong
8a0543b49c Rename EnableLocalStoreDSE to DisableLocalStoreDSE and flip the condition 2015-12-15 14:59:08 -08:00
Xin Tong
0f938ef6bd Speculatively disable local dead store. It breaks a test case. It was enabled because TBAA is believed to have been fixed. 2015-12-15 14:55:20 -08:00
Xin Tong
f7cc000e7a Enable local dead store, i.e. a store to a local variable is dead if its not read before function exit. 2015-12-15 09:34:36 -08:00
Xin Tong
1254eaa69e Add the invalidated analysis in DSE 2015-12-15 08:39:31 -08:00
practicalswift
163cb4a062 Fix typo: intefering → interfering 2015-12-14 00:11:58 +01:00
Xin Tong
fb480e9990 Reorder a few header includes 2015-12-13 10:17:15 -08:00
Xin Tong
27b5a40359 Rename MemLocation to LSLocation and LoadStoreValue to LSValue 2015-12-13 10:02:45 -08:00
Xin Tong
642a555a6c Rename MemLocation.h to SILValueProjection.h 2015-12-13 09:31:56 -08:00
Xin Tong
6a5c8701c6 Create a common createExtract function used across DSE and RLE 2015-12-13 09:19:54 -08:00
Andrew Trick
739b0e9c56 Reorganize SILOptimizer directories for better discoverability.
(libraries now)

It has been generally agreed that we need to do this reorg, and now
seems like the perfect time. Some major pass reorganization is in the
works.

This does not have to be the final word on the matter. The consensus
among those working on the code is that it's much better than what we
had and a better starting point for future bike shedding.

Note that the previous organization was designed to allow separate
analysis and optimization libraries. It turns out this is an
artificial distinction and not an important goal.
2015-12-11 15:14:23 -08:00