Commit Graph

11224 Commits

Author SHA1 Message Date
practicalswift
6e3b700b44 Fix typos. 2015-12-23 00:31:13 +01:00
Erik Eckstein
fba34ee629 EscapeAnalysis: fix wrong check for refcounted object 2015-12-22 14:52:40 -08:00
Andrew Trick
0c7ee1f283 Teach CopyForwarding to handle enum initialization sequences.
This requires a bit of code motion.

e.g.

1. %Tmp = alloc_stack
2. copy_addr %InArg to [initialization] %Tmp
3. DataAddr = init_enum_data_addr %OutArg
4. copy_addr %Tmp#1 to [initialization] %DataAddr

becomes

1. %Tmp = alloc_stack
4. DataAddr = init_enum_data_addr %OutArg
2. copy_addr %InArg to [initialization] %DataAddr

Fixes at least one regression resulting from '++' removal.
See rdar://23874709 [perf] -Onone Execution Time regression of up-to 19%

-Onone results
|.benchmark............|.bestbase.|.bestopt.|..delta.|.%delta.|speedup.|
|.StringWalk...........|....33570.|...20967.|.-12603.|.-37.5%.|..1.60x.|
|.OpenClose............|......446.|.....376.|....-70.|.-15.7%.|..1.19x.|
|.SmallPT..............|....98959.|...83964.|.-14995.|.-15.2%.|..1.18x.|
|.StrToInt.............|....17550.|...16377.|..-1173.|..-6.7%.|..1.07x.|
|.BenchLangCallingCFunc|......453.|.....428.|....-25.|..-5.5%.|..1.06x.|
|.CaptureProp..........|....50758.|...48156.|..-2602.|..-5.1%.|..1.05x.|
|.ProtocolDispatch.....|.....5276.|....5017.|...-259.|..-4.9%.|..1.05x.|
|.Join.................|.....1433.|....1372.|....-61.|..-4.3%.|..1.04x.|
2015-12-22 14:35:52 -08:00
Andrew Trick
9a85a0254f Make CopyForwarding more conservative with destination addresses.
AFAICT, this does not fix any existing bug, but eliminates unverified
assumptions about well-formed SIL, which could be broken by future
optimization.

Forward: The optimization will replace all in-scope uses of the
destination address with the source. With this change we will be sure
not eliminate writes into a destination address unless the destination
is an AllocStackInst. This hasn't been a problem in practice because
the optimization requires an in-scope deinit of the destination
address, which can't happen on typical address projections.

Backward: The optimization will replace in-scope uses of the source
with the destination. With this change we will be sure not to write
into the destination location prior to the copy unless the destination
is an AllocStackInst. This hasn't been a problem in practice because
the optimization requires the copy to be an initialization of the
address, which can't happen on typical address projections.

This change prevents both optimizations without an obvious guarantee
that any dependency on the destination address will manifest as a
SIL-level dependence on the address producer. For example,
init_enum_data_addr would not qualify because it simply projects an
address within a value that may have other dependencies.
2015-12-22 14:35:52 -08:00
Erik Eckstein
dc8dce7739 EscapeAnalysis: some fixes and improvements in the basic graph utility functions. 2015-12-22 12:56:21 -08:00
Mark Lacey
4c97fb4e4f Fix 80-column violations. 2015-12-22 12:10:44 -08:00
Max Moiseev
a7339e67ac Merge remote-tracking branch 'origin' into swift-3-api-guidelines 2015-12-22 11:36:07 -08:00
ken0nek
fcd8fcee91 Convert [Cc]an not -> [Cc]annot 2015-12-23 00:55:48 +09:00
Arsen Gasparyan
be738abb7c Fix else code style 2015-12-22 11:13:26 +03:00
Mark Lacey
70938b1aee Add a stand-alone devirtualizer pass.
Add back a stand-alone devirtualizer pass, running prior to generic
specialization. As with the stand-alone generic specializer pass, this
may add functions to the pass manager's work list.

This is another step in unbundling these passes from the performance
inliner.
2015-12-21 23:42:37 -08:00
Mark Lacey
4bb33dc3fd Remove some inadvertantly committed code.
Remove some things that were supposed to have been removed prior to the
original commit, and fix a typo in the DEBUG_TYPE string.
2015-12-21 23:42:37 -08:00
Michael Gottesman
976d39fa08 Add 3 cases that I missed to make a switch truly exhaustive. 2015-12-21 19:06:25 -06:00
Erik Eckstein
79f29e1887 add some comments in AliasAnalysis and EscapeAnalysis 2015-12-21 16:44:52 -08:00
Erik Eckstein
f0645d1b9c Re-apply "AliasAnalysis: use escape analysis for some checks."
This re-applies commit 09c61c61bf [09c61c6]

This should work now with the recent fix in EscapeAnalysis
2015-12-21 16:44:52 -08:00
Erik Eckstein
b903d7eb6d Re-apply "AliasAnalysis: use escape analysis in the MemoryBehaviorVisitor"
This re-applies commit ae2bf14786

It should now work with the recent fix in EscapeAnalysis.
2015-12-21 16:44:52 -08:00
Erik Eckstein
2ac75840dd EscapeAnalysis: fix bug in alias checking regarding ref_element_addr 2015-12-21 16:44:52 -08:00
Erik Eckstein
9278396769 EscapeAnalysis: fix problem of missing points-to edge in the connection graph.
If a graph had a terminal cycle in a defer-edge path it could end up not having a points-to edge.
2015-12-21 16:44:52 -08:00
Michael Gottesman
3eca15623b Change 6 non-exhaustive switches on ValueKind to be exhaustive switches on TermKind. NFC.
This exposed the first interesting bug found by using TermKind, in DCE we were
not properly handling switch_enum_addr and checked_cast_addr_br.

SR-335
rdar://23980060
2015-12-21 17:12:06 -06:00
Xin Tong
ee1396aaa6 Refactor RLE into stages.
After the refactoring, RLE runs in the following phases:

Phase 1. we use an iterative data flow to compute whether there is an
available value at a given point, we do not yet care about what the value
is.

Phase 2. we compute the real forwardable value at a given point.

Phase 3. we setup the SILValues for the redundant load elimination.

Phase 4. we perform the redundant load elimination.

Previously we were computing available bit as well as what the available
value is every iteration of the data flow.

I do not see a compilation time improvement though, but this helps to move
to a genset and killset later as we only need to expand Phase 1 into a few smaller
phases to compute genset & killset first and then iterate until convergence for
the data flow.

I verified that we are performing same # of RLE on stdlib before the change.

Existing test ensure correctness.
2015-12-21 14:56:56 -08:00
Michael Gottesman
4f69bfc77f [arc] Always visit terminators bottom up so we can handle try_apply correctly.
Previously, we relied on a quirk in the ARC optimizer so that we only
need to visit terminators top down. This simplified the dataflow. Sadly,
try_apply changes this since it is a terminator that provides a call
with the value, causing this assumption to break program correctness.

Now during the bottom up traversal, while performing the dataflow for a
block B, we (after visiting all instructions), visit B's predecessors to
see if any of them have a terminator that is a use or decrement. We then
take the most conservative result among all of the terminators and
advance the sequence accordingly.

I do not think that we can have multiple such predecessors today since all
interesting terminators can not have any critical edges to successors. Thus if
our block is a successor of any such block, it can not have any other
predecessors. This is mainly for future proofing if we decide that this is able
to be done in the future.

rdar://23853221
SR-102
2015-12-21 16:41:24 -06:00
practicalswift
36d7072013 Remove immediately adjacent repeated words ("the the", "for for", "an an", etc.). 2015-12-21 22:16:04 +01:00
Max Moiseev
2f7b64e475 Merge remote-tracking branch 'origin' into swift-3-api-guidelines 2015-12-21 12:02:13 -08:00
Erik Eckstein
b3691c83a6 SimplifyCFG: fix crash if a branch argument is replaced with a SILValue with result number != 0
Fixes https://bugs.swift.org/browse/SR-329
rdar://problem/23969954
2015-12-21 10:08:36 -08:00
Xin Tong
5ce5a5ec4d Move to use SSAUpdater to generate the SILArgument when a location has a covering value,
i.e. multiple different values from predecessors

Previously, RLE is placing the SILArguments and branch edgevalues itself. This is probably
not as reliable/robust as using the SSAupdater.

RLE uses a single SSAupdater to create the SILArguments, this way previously created SILArguments
can be reused.

One test is created specifically for that so that we do not generate extraneous SILArguments.
2015-12-21 00:31:11 -08:00
Dmitri Gribenko
1e6e124326 Merge pull request #692 from practicalswift/fix-incorrect-filenames
Fix incorrect filenames in headers
2015-12-21 00:00:43 -08:00
practicalswift
cd7d8dfaff Fix alignment as requested by @gribozavr in #692 2015-12-21 08:54:24 +01:00
Xin Tong
5d10f31b0e Add a condition on what the maximum of locations there are in a function for RLE to optimize
RLE is an iterative data flow. Functions with too many locations may take a long time for the
data flow to converge.

Once we move to a genset and killset for RLE. we should be able to lessen the condition a bit more.

I have observed no difference in # of redundant loads eliminated on the stdlib (currently we
eliminate 3862 redundant loads).
2015-12-20 22:42:49 -08:00
Xin Tong
ec83f8c661 Revert "Move to use SSAUpdater to generate the SILArgument when a location has a covering value,"
This reverts commit bc172647c7.

Caused a compiler crash on Linux.
2015-12-20 18:19:40 -08:00
Xin Tong
bc172647c7 Move to use SSAUpdater to generate the SILArgument when a location has a covering value,
i.e. multiple different values from predecessors

Previously, RLE is placing the SILArguments and branch edgevalues itself. This is probably
not as reliable/robust as using the SSAupdater.

RLE uses a single SSAupdater to create the SILArguments, this way previously created SILArguments
can be reused.

One test is created specifically for that so that we do not generate extraneous SILArguments.
2015-12-20 17:40:41 -08:00
practicalswift
176f487d76 Fix incorrect filenames in headers. 2015-12-20 23:59:05 +01:00
Xin Tong
375bef1295 Minor comment fix in DeadObjectElimination.cpp 2015-12-20 14:23:20 -08: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
Erik Eckstein
057323fb15 Partially reverting "AliasAnalysis: use escape analysis for some checks."
Partially revert 09c61c61bf.

In some configuration it triggers an assert in escape analysis.
2015-12-18 17:47:56 -08:00
Doug Gregor
cd1c106e35 Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2015-12-18 15:45:48 -08:00
Erik Eckstein
549321756b Revert "AliasAnalysis: use escape analysis in the MemoryBehaviorVisitor"
This reverts commit ae2bf14786.

It broke one regression test.
2015-12-18 15:20:35 -08:00
Mark Lacey
faba6e56b7 Add a stand-alone generic specializer pass.
Begin unbundling devirtualization, specialization, and inlining by
recreating the stand-alone generic specializer pass.

I've added a use of the pass to the pipeline, but this is almost
certainly not going to be the final location of where it runs. It's
primarily there to ensure this code gets exercised.

Since this is running prior to inlining, it changes the order that some
functions are specialized in, which means differences in the order of
output of one of the tests (one which similarly changed when
devirtualization, specialization, and inlining were bundled together).
2015-12-18 14:08:56 -08:00
Mark Lacey
dbde7cc4c1 Update the pass manager to allow for function creation in function passes.
Add interfaces and update the pass execution logic to allow function
passes to create new functions, or ask for functions to be optimized
prior to continuing.

Doing so results in the pass pipeline halting execution on the current
function, and continuing with newly added functions, returning to the
previous function after the newly added functions are fully optimized.
2015-12-18 14:08:56 -08:00
Erik Eckstein
8b79b0d7f5 Change parameter of isNotAliasedIndirectParameter from bool to an enum.
And fix indentation of switch cases.
2015-12-18 12:57:21 -08:00
Xin Tong
cb94f5fdd1 Update some comments and remove dead code in dead store elimination 2015-12-18 10:18:36 -08:00
Doug Gregor
a97ab6dd14 Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2015-12-18 10:15:47 -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
Erik Eckstein
4aabe88005 ARC: use escape analysis in ARC analysis 2015-12-18 08:02:18 -08:00
Erik Eckstein
ae2bf14786 AliasAnalysis: use escape analysis in the MemoryBehaviorVisitor 2015-12-18 08:02:18 -08:00
Erik Eckstein
09c61c61bf AliasAnalysis: use escape analysis for some checks.
One important additional change here is that alias analsyis doesn't assume that inout is not-aliasing anymore
2015-12-18 08:02:18 -08:00
Erik Eckstein
ae6fa34645 EscapeAnalysis: some new and changed utility functions to be used by alias analysis and ARC analysis. 2015-12-18 08:02:18 -08:00
Erik Eckstein
fc08b60af4 add utility functions for checking not-aliased indirect function arguments. 2015-12-18 08:02:18 -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
Michael Gottesman
b235064c3f [loop-canonicalization] Change pre-header insertion so that it always occurs.
Previously, if a header had multiple predecessors or if the predecessor was not
a cond_br, we would not insert a pre-header. Now we always insert pre-headers.

This is important in terms of ensuring that ARC Sequence Opts is correct when it
inserts retains before loops.

Reviewed by Andy Trick.

rdar://23853221
SR-102
2015-12-17 19:18:45 -06:00
Michael Gottesman
810181c6d1 Add two utility passes, Compute{Dominance,Loop}Info that just build the relevant infos.
This makes it easy to use -sil-verify-all to verify that both type of info are
created correctly and that analyses are properly updating them. I am going to
use this to harden testing of the loop canonicalizer.
2015-12-17 19:18:45 -06:00
Dmitri Gribenko
73ce9ae7e9 Collection.count => .length
And other API changes that naturally fall out from this, like
Array(repeating:count:) => Array(repeating:length:).
2015-12-17 15:55:29 -08:00