Commit Graph

11224 Commits

Author SHA1 Message Date
Xin Tong
0c162cd3d1 Refactor in redundant load elimination. NFC.
1. Update some comments.
2. Rename a few functions, e.g. runIterativeDF -> runIterativeRLE, getLSValueBit -> getValueBit.
3. Remove unused headers.
4. Remove no-longer used function, mergePredecessorStates and mergePredecessorState.
5. A few other small NFCs.
2015-12-29 15:35:49 -08: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
Chris Lattner
151556707a Merge pull request #811 from practicalswift/remove-duplicate-includes
Remove duplicate #include:s
2015-12-29 08:32:55 -08:00
practicalswift
fb314c37aa Fix typos introduced yesterday :-) 2015-12-29 13:16:02 +01:00
practicalswift
f34df59dc6 Remove duplicate #include:s 2015-12-29 12:12:26 +01:00
Aaron Raimist
b196e79b88 SimplifyCFG: Fix typo, Fist to First 2015-12-28 23:04:24 -06:00
Xin Tong
cc1dda478e Move to a genset and killset for the dataflow in redundant load elimination.
Previously we process every instruction every time the data flow re-iterates.
This is very inefficient.

In addition to moving to genset and killset, we also group function into
OneIterationFunction which we know that the data flow would converge in 1 iteration
and functions that requre the iterative data flow, mostly due to backedges in loops.
we process them differently.

I observed that there are ~93% of the functions that require just a single iteration
to perform the RLE.

But the other 7% accounts for 2321 (out of 6318) of the redundant loads we eliminated.

This change reduces RLE compilation from 4.1% to 2.7% of the entire compilation time
(frontend+OPT+LLVM) on stdlib with -O. This represents 6.9% of the time spent
in SILOptimizations (38.8%).

~2 weeks ago, RLE was taking 1.9% of the entire compilation time. It rose to 4.1%
mostly due to that we are now eliminating many more redundant loads (mostly thank
to Erik's integragtion of escape analysis in alias analysis). i.e. 3945 redundant
loads elimnated before Erik's change to 6318 redundant loads eliminated now.
2015-12-28 15:04:58 -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
practicalswift
149b50d901 Fix typos in code (non-comment/documentation typos). 2015-12-28 11:42:15 +01:00
Chris Lattner
487b0d1365 Merge pull request #796 from practicalswift/fix-comment-typos
Fix typos in code comments
2015-12-27 20:46:46 -08:00
Xin Tong
7e49985b00 Turn a function into early exit sytle. NFC 2015-12-27 17:35:24 -08:00
practicalswift
fd70b26033 Fix typos in comments. 2015-12-28 02:15:34 +01:00
practicalswift
d89b4d45e1 Fix typos in code (non-comment typos). 2015-12-27 13:05:01 +01: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
85e2e6eb9a Fix a vs. an 2015-12-26 14:40:16 +01:00
practicalswift
db13bcb22e Fix typos. 2015-12-26 14:11:42 +01:00
Nadav Rotem
07d4558c1c [Mangler] Change the Swift mangler into a symbol builder.
This commit changes the Swift mangler from a utility that writes tokens into a
stream into a name-builder that has two phases: "building a name", and "ready".
This clear separation is needed for the implementation of the compression layer.

Users of the mangler can continue to build the name using the mangleXXX methods,
but to access the results the users of the mangler need to call the finalize()
method. This method can write the result into a stream, like before, or return
an std::string.
2015-12-25 21:40:25 -08: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
Dmitri Gribenko
6160b4ef4d Merge pull request #766 from practicalswift/a-few-more-typos
Fix typos
2015-12-24 13:18:33 -08:00
Xin Tong
f9450ea6ab Avoid extraneous generation of AACache and MBCache keys 2015-12-24 09:24:56 -08:00
practicalswift
4ff12be924 Fix typos. 2015-12-24 14:26:57 +01:00
Xin Tong
47afcd4adc Regenerate cache key after the valueenumeraor is invalidated. Exposed by another painful memory behavior cache bug 2015-12-24 00:30:11 -08:00
Erik Eckstein
c7e8cb0332 Remove now unused utility functions for escape checking.
Those functions were replaced by EscapeAnalysis.
2015-12-23 16:48:41 -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
Erik Eckstein
f963b5ce70 AliasAnalysis: conservatively assume @inout may alias, part 2
Use the new swift::isNotAliasingArgument utility function to check for a not-aliased arguments.
2015-12-23 16:12:42 -08:00
Erik Eckstein
f8c82889b8 Fix wrong combination of MemoryBehavior.
Instead of taking the maximum we need to handle the special case MayRead + MayWrite = MayReadWrite
2015-12-23 13:50:08 -08:00
Max Moiseev
200be71583 Merge remote-tracking branch 'origin' into swift-3-api-guidelines 2015-12-23 10:28:04 -08:00
Erik Eckstein
c5ebaee297 EscapeAnalysis: rename utility function for checking reference semantics and use it in canObjectOrContentEscapeTo
This makes canObjectOrContentEscapeTo less conservative when dealing with addresses of references.
2015-12-23 08:33:44 -08:00
practicalswift
81e7439a9a Fix typos. 2015-12-23 11:16:34 +01:00
Mark Lacey
99d17a47f9 Change the invalidation kind for the generic specializer.
It adds functions, so technically it needs to invalidate more than just
the function body.
2015-12-22 23:19:44 -08:00
Mark Lacey
75f2de5c79 Use a more appropriate invalidation kind in the devirtualizer.
We're not touching branches, so we do not need to invalidate those.
2015-12-22 23:18:38 -08:00
Xin Tong
17fe37d715 Use a separate valueenumerator for alias cache and memory behavior cache
If we use a shared valueenumerator, imagine the case when one of the AAcache or MBcache
is cleared and we clear the valueenumerator.

This could give rise to collisions (false positives) in the not-yet-cleared cache!
2015-12-22 22:53:32 -08:00
Nadav Rotem
8d4f777f83 [Mangler] Limit the lifetime of the Mangler
to make sure we are not accessing the buffer before the output is ready. The Mangler is going to be buffered (for compression), and accessing the underlying buffer is a bug.
2015-12-22 22:47:34 -08:00
Andrew Trick
2da0f601d8 Explicitly restrict NRVO optimization to "out" args.
Don't allow this optimization to kick in for "inout" args.
The optimization may expose local writes to any aliases of the argument.
I can't prove that is memory safe.

Erik pointed out this case.
2015-12-22 21:03:03 -08:00
Andrew Trick
000e630b2f Teach CopyForwarding to handle existential initialization
...in addition to enum initialization, as Slava requested.

|.benchmark...|.bestbase.|.bestopt.|.delta.|.%delta.|.speedup.|
|.ArrayAppend.|.....2514.|....2382.|..-132.|..-5.3%.|...1.06x.|
|.NSXMLParser.|....12076.|...11223.|..-853.|..-7.1%.|...1.08x.|
|.NopDeinit...|....54961.|...50619.|.-4342.|..-7.9%.|...1.09x.|
|.StringWalk..|....20503.|...16119.|.-4384.|.-21.4%.|...1.27x.|
2015-12-22 21:03:03 -08:00
Nadav Rotem
a981c80571 [Mangler] Move the SILMangler out of the AST Mangler namespace. 2015-12-22 17:19:40 -08:00
Mark Lacey
b3fe53cff9 Typo in function name: Extenral -> External 2015-12-22 17:16:11 -08:00
Slava Pestov
36ddea64ae Merge pull request #729 from ken0nek/fix-can-not
Convert [Cc]an not -> [Cc]annot
2015-12-22 16:06:20 -08:00
Chris Lattner
5bcd4bc3bd Merge pull request #738 from practicalswift/another-typo-round
[Typos] Fix typos
2015-12-22 15:41:49 -08:00