Commit Graph

49 Commits

Author SHA1 Message Date
Erik Eckstein
80a734ab30 DeadObjectElimination: handle objects for which the destructor is de-virtualized and inlined
Also: add an additional DeadObjectElimination pass in the low level pipeline because
redundant load elimination (which runs before) can turn an object into a dead object.
2018-01-19 11:33:26 -08:00
Erik Eckstein
bf87035a36 GlobalOpt: Move the object outlining from GlobalOpt into a separate pass "ObjectOutliner"
We run GlobalOpt multiple times in the pass pipeline but in some cases object outlining shouldn't be done too early.
Having it done in a separate pass enables to run it independently from GlobalOpt.
2018-01-19 11:32:36 -08:00
eeckstein
b126b62256 Revert "Optimization changes to completely fold OptionSet literals" 2018-01-18 22:05:07 -08:00
Erik Eckstein
442171bca6 DeadObjectElimination: handle objects for which the destructor is de-virtualized and inlined
Also: add an additional DeadObjectElimination pass in the low level pipeline because
redundant load elimination (which runs before) can turn an object into a dead object.
2018-01-18 18:27:17 -08:00
Erik Eckstein
1f511ab846 GlobalOpt: Move the object outlining from GlobalOpt into a separate pass "ObjectOutliner"
We run GlobalOpt multiple times in the pass pipeline but in some cases object outlining shouldn't be done too early.
Having it done in a separate pass enables to run it independently from GlobalOpt.
2018-01-18 18:27:17 -08:00
Roman Levenstein
53754a7a69 Add a new simple utility optimization pass for serialization of SILModules 2017-10-13 23:19:19 -07:00
Roman Levenstein
6f3b326d12 IRGen should not emit bodies of public_external functions unless it is a transparent function.
Recent changes that eliminated the -sil-serialize-all mode and adding this check to IRGen allow us to get rid of ExternalFunctionDefinitionsElimination and ExternalDefsToDecls passes, which are not needed anymore.
2017-10-11 08:29:46 -07:00
Michael Gottesman
9e8a712dfa Merge pull request #11808 from gottesmm/pr-ca42038a7bd82a50a8617ca95957e9556d3e8467
[di] Update definite_initialization for ownership.
2017-09-07 17:25:09 -07:00
Michael Gottesman
4c087097f3 [di] Update definite_initialization for ownership.
rdar://31521023
2017-09-07 15:23:22 -07:00
Arnold Schwaighofer
b625d4da8a Osize: Add a SIL Outliner pass that outlines the bridging of objective c calls.
Implements outlining of bridged objective c property and method calls.

rdar://33387700
2017-09-06 08:37:37 -07:00
Michael Gottesman
aa0ac80c85 [ome] Move OME past MarkUninitializedFixup.
Originally, I was going to update DI at the same time for ownership and to fix
the multiple-projectbox di bug. After a bit messing with it, it is a difficult
change to land due to the size. Instead, I am going to do the ownership update
first and then loop back around and then fix the DI bug.

rdar://31521023
2017-08-30 20:39:15 -07:00
Roman Levenstein
4dbdeaa789 Add another round of retain sinking, because not all of possible retains are sunk in one round. 2017-08-22 12:45:22 -07:00
Roman Levenstein
e51626df6e Run the devirtualizer after the generic specializer
This is very beneficial because many class_method/witness_method instructions may get concrete types after specialization. Doing it this way improves compilation times.
2017-08-22 12:45:22 -07:00
Erik Eckstein
6c93798acc SILOptimizer: Add a new TempRValue optimization pass
This is a separate optimization that detects short-lived temporaries that can be eliminated.
This is necessary now that SILGen no longer performs basic RValue forwarding in some cases.

SR-5508: Performance regression in benchmarks caused by removing SILGen peephole for LoadExpr in +0 context
2017-08-05 17:23:51 -07:00
Roman Levenstein
c042058b82 Modify the optimization pipeline to better support custom array iterators
This patch is supposed to recover the performance regressions that would be introduced by yet to be merged PR #9145, which introduces custom, more efficient array iterators.

The crucial part of this patch is running loop unrolling also during the mid-level optimizations phase, because it may catch more loops with constant trip counts. To make trip counts constant, an additional run of constant propagation is helpful.
2017-08-01 17:04:36 -07:00
Andrew Trick
89985ebacd Use the pass's "tag" for command-line options.
A pass has an ID (C++ identifier), Tag (shell identifier),
and Name (human identifier).

Command line options that identify passes should obviously be compatibile with
with the pass' command line identifier. This is also what the user is used to
typing for the -debug-only option.
2017-07-06 14:10:23 -07:00
Andrew Trick
d45f171c98 Cleanup AccessMarkerElimination.
In raw SIL, access markers are unconditionally retained. In canonical SIL,
markers are still removed prior to optimization.

A new flag, -sil-optimized-access-markers, allows testing access markers in
optimized builds, but it is not yet fully supported.
2017-07-05 15:18:48 -07:00
Joe Shajrawi
edea7d04b3 Add a flag (false by default) for large loadable types pass 2017-05-22 14:25:25 -07:00
Joe Shajrawi
17effee303 Disable large types irgen pass 2017-05-09 18:58:27 -07:00
Bob Wilson
84d1630727 Merge pull request #9142 from shajrawi/loadable_by_addr_split
Code Size: Pass large loadable types by address instead of by value - Updated Version
2017-05-01 12:56:38 -07:00
Joe Shajrawi
4dc0801785 IRGen Mandatory Module Pass: Pass large loadable types by address instead of by value 2017-05-01 12:04:06 -07:00
Andrew Trick
2336a87866 [Exclusivity] Enable access markers for the entire -Onone pipeline.
Dynamic markers are still conditional on the command line option.
2017-04-28 21:33:09 -07:00
Andrew Trick
e8b0947897 [Exclusivity] Allow testing the -Onone pipeline with access markers.
Markers are always eliminated before -O passes.

At -Onone, markers can be enabled via command line for all -Onone passes.
2017-04-26 17:32:48 -07:00
Michael Gottesman
ad7705ed42 [semantic-sil] Update OME for having mark_uninitialized on the alloc_box instead of project_box.
This consists of just removing support from OME for ensuring that all uses of a
box go through the project_box that has as its user a mark_uninitialized. Since
the lowering of mark_uninitialized onto the relevant project_box is done by
MarkUninitializedFixup pass, I can just rip out the hacks from the OME!

rdar://31521023
2017-04-17 21:10:24 -07:00
Michael Gottesman
21973e0abc [semantic-sil] Update allocbox-to-stack for the mark_uninitialized begin on the alloc_box instead of the project_box.
This also moves the eliminator pass behind alloc box to stack.

rdar://31521023
2017-04-17 19:09:15 -07:00
Michael Gottesman
9d6e6dc5b4 [semantic-sil] Update capture promotion for moving mark_uninitialized onto alloc_box instead of project_box and move the fixup pass behind it.
rdar://31521023
2017-04-17 18:27:14 -07:00
Michael Gottesman
aa76c2a5e6 [silgen] (mark_uninitialized (project_box (alloc_box))) -> (project_box (mark_uninitialized (alloc_box)))
I put in a simple fixup pass (MarkUninitializedFixup) for staging purposes. I
don't expect it to be in tree long. I just did not feel comfortable fixing up in
1 commit all of the passes up to DI.

rdar://31521023
2017-04-17 17:45:54 -07:00
Michael Gottesman
e7b8865696 [semantic-sil] Move the ownership model eliminator past no return folding.
rdar://31521023
2017-04-11 11:43:19 -07:00
swift-ci
6956926264 Merge pull request #8686 from rjmccall/access-enforcement-selection-pass 2017-04-11 00:49:29 -07:00
John McCall
b9676d2002 Add a SIL pass to select an access enforcement for allocated boxes.
Tests to come.
2017-04-11 03:10:51 -04:00
Devin Coughlin
fe310f5e4d [SILDiagnostics] Add DiagnoseStaticExclusivity to mandatory opt pipeline
These diagnostics are still off by default. They can be enabled
with -enforce-exclusivity=checked.
2017-04-10 16:16:23 -07:00
Andrew Trick
4355cad83e Add a pass to eliminate access markers. 2017-04-10 09:47:50 -07:00
Andrew Trick
be1881aa1f Remove redundant Transform.getName() definitions.
At some point, pass definitions were heavily macro-ized. Pass
descriptive names were added in two places. This is not only redundant
but a source of confusion. You could waste a lot of time grepping for
the wrong string. I removed all the getName() overrides which, at
around 90 passes, was a fairly significant amount of code bloat.

Any pass that we want to be able to invoke by name from a tool
(sil-opt) or pipeline plan *should* have unique type name, enum value,
commend-line string, and name string. I removed a comment about the
various inliner passes that contradicted that.

Side note: We should be consistent with the policy that a pass is
identified by its type. We have a couple passes, LICM and CSE, which
currently violate that convention.
2017-04-09 15:20:28 -07:00
Michael Gottesman
5e278fdf67 [semantic-arc-opts] Create a new pass called semantic arc opts.
I am going to run it very early and use it to ensure that extra copies due to my
refactoring of SILGenPattern do not cause COW copies to be introduced.

For now, it does a very simple optimization, namely, it eliminates a copy_value,
with only a destroy_value user on a guaranteed parameter.

It is now disabled behind a flag.
2017-04-05 16:16:57 -07:00
Michael Gottesman
062dd06be7 [semantic-sil] Move allocbox-to-stack *before* the ownership model eliminator.
rdar://29870610
2017-04-03 14:38:20 -07:00
Michael Gottesman
31a4598f91 [semantic-sil] Move the ownership model eliminator *after* capture promotion.
rdar://29870610
2017-04-02 11:44:14 -07:00
Erik Eckstein
777f5aaf7a SILOptimizer: Replace [].append(contentsOf:) with [].append(element:)
if the argument is an array literal.

For example:
  arr += [1, 2, 3]

is replaced by:
  arr.append(1)
  arr.append(2)
  arr.append(3)

This gives considerable speedups up to 10x (for our micro-benchmarks which test this).

This is based on the work of @ben-ng, who implemented the first version of this optimization (thanks!).
2017-03-31 17:16:31 -07:00
Erik Eckstein
dc426bd885 SIL optimizer: add some clean-up passes before the inliner.
This is important in case the inline restarts the pass pipeline.
In a sub-sequent invocation of the inlined it should receive a cleaned-up function so that it can make better estimations for further inlining.

As a compensation, reduce the caller-block limit of the inliner.
And add an overall block limit which is also taken into account for always-inline functions.
2017-03-31 15:31:57 -07:00
Huon Wilson
a9299802bb Factor out first = true; ... if (first) first = false; else ....
There's an `interleave` function for this: let's use it.
2017-03-10 15:44:12 -08:00
Andrew Trick
855918c620 [Lowering] Add an AddressLowering pass. 2017-02-13 17:10:02 -08:00
practicalswift
6d1ae2a39c [gardening] 2016 → 2017 2017-01-06 16:41:22 +01:00
Arnold Schwaighofer
f1c2dcf1fa Add an alloc_stack hoisting pass.
Hoist alloc_stack instructions of 'generic' or resilient type to the entry
block. At the same time also perform a very simple stack coloring analysis.
This does not use a true liveness-analysis yet but rather employs some simple
conservative checks to see whether the live ranges of two alloc_stacks might
interfere.

AllocStackHoisting is an IRGen SIL pass. This allows for using IRGen's type
lowering information. Furthermore, hoisting and merging the alloc_stack
instructions this late does not interfere with SIL optimizations because the
resulting SIL never gets serialized.
2016-12-20 07:51:55 -08:00
Arnold Schwaighofer
f38c912878 Add support of a IRGen lowering SIL pipeline.
This pipeline is run as part of IRGen and has access to the IRGenModule.

Passes that run as part of this pipeline can query for the IRGenModule.

We will use it for the AllocStackHoisting pass. It wants to know if a type is of
non-fixed size.

To break the cyclic dependency between IRGen -> SILOptimizer -> IRGen that would
arise from the SILPassManager having to know about the createIRGENPASS()
function IRGen passes instead of exposing this function dynamically have to add
themselves to the pass manager.
2016-12-20 07:51:47 -08:00
Michael Gottesman
be5ec6f990 [passmanager] Remove ExecutionKind::UntilFixPoint and all of ExecutionKind.
rdar://29650781
2016-12-19 13:38:46 -08:00
practicalswift
92d4aa3b91 [gardening] Use consistent headers. 2016-12-16 21:42:09 +01:00
Michael Gottesman
a7feb67c23 [pass-manager] Do not run mandatory opts until fix point, just run one iteration.
This is most likely an oversight. We should have removed it when the bottom up
pass manager was added.

rdar://29650781
2016-12-14 01:22:35 -08:00
Saleem Abdulrasool
19768170d7 SILOptimizer: IWYU 2016-12-12 22:43:07 -08:00
Michael Gottesman
bf4864bc88 [sil-bug-reducer] Create the sil-passpipeline-dumper tool.
This enables one to dump the various passpipelines in a yaml format. Other
pretty print formats can be added in the future as well if desired. Its intended
usage is to provide a source of pass pipeline information for external python
bug-reducing tools. By integrating this as a compiler-tool, we are guaranteed to
never have to update any of these tools in the face of passpipeline changes.
2016-12-12 15:07:56 -08:00
Michael Gottesman
3c61f783ea [sil-bug-reducer] Add SILPassPipeline{,Plan}. Add current pass pipelines to it.
This commit adds the functionality, but does not change SILPassManager to use
it. The reason why I am doing this is so I can implement sil-opt pass bisecting
functionality in python using a tool that dumps the current pass pipelines
out. This will ensure that even in the face of changes to the pass pipelines,
everything should just work.
2016-12-12 14:38:56 -08:00